How to use getcellvalue method in pyatom

Best Python code snippet using pyatom_python

switchconfig_operation.py

Source:switchconfig_operation.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3from openpyxl import *4import quantum780_operation5import terminalcolor as tcolor6#TESTPARAS = ['HRES', 'VRES', 'VRAT', 'VIC', 'AR', 'SCAN', 'HTOT',7# 'HSPD', 'HSPW', 'HSPP', 'VTOT', 'VSPD', 'VSPW', 'VSPP']8class SwitchConfigOperation(object):9 def __init__(self, filename, sheetNum):10 self.filename = filename11 self.sheetNum = sheetNum12 self.wb = load_workbook(filename)13 self.wb.active14 self.mySheet = self.get_sheetNames()[sheetNum]15 self.TESTPARAS= ['HRES', 'VRES', 'VRAT', 'VIC', 'AR', 'SCAN', 'HTOT',16 'HSPD', 'HSPW', 'HSPP', 'VTOT', 'VSPD', 'VSPW', 'VSPP']17 def saveModify(self, filename):18 self.wb.save(filename)19 def get_sheetNames(self):20 """21 get all sheetnames22 :return: a list of all sheetnames23 """24 return self.wb.sheetnames25 def get_sheet(self, sheetName):26 """27 get the sheet according to the sheetname28 :param sheetName:29 :return: a sheet obj30 """31 return self.wb[sheetName]32 def getCellValue(self, row, col):33 sheet = self.get_sheet(self.mySheet)34 return sheet.cell(row,col).value35 def setCellValue(self, row, col, newv):36 sheet = self.get_sheet(self.mySheet)37 sheet.cell(row, col, newv)38 def getRowsLenth(self):39 sheet = self.get_sheet(self.mySheet)40 return sheet.max_row41 def getColumnsLenth(self):42 sheet = self.get_sheet(self.mySheet)43 return sheet.max_column44 # def getSupportTimingCode(self, column):45 # """46 # return a timing code generator if mark 'x' in the column;47 # :param column:48 # :return: a generator49 # """50 # for i in range(1,self.getRowsLenth()+1):51 # #print (self.getCellValue(i+1, 37))52 # if 'x' == self.getCellValue(i, column):53 # yield self.getCellValue(i,3)54 def getSupportTimingList(self, column):55 """56 Return a list of all support input timing57 :param cloumn:58 :return: result[]59 """60 result = []61 for i in range(1, self.getRowsLenth()+1):62 if 'x' == self.getCellValue(i, column):63 result.append(self.getCellValue(i,1))64 return result65 def getSupportTimingCode(self, column):66 """67 Return a list of all support input timing68 :param column:69 :return:70 """71 result = []72 for i in range(1, self.getRowsLenth()+1):73 if 'x' == self.getCellValue(i, column):74 result.append(self.getCellValue(i,3))75 return result76 def getCaseInfo(self, column):77 """78 Return a list of all support input timing79 :param column:80 :return:81 """82 casecmd = []83 casename = []84 casenum = []85 for i in range(1, self.getRowsLenth()+1):86 if 'x' == self.getCellValue(i, column):87 casecmd.append(self.getCellValue(i,3))88 casename.append(self.getCellValue(i,2))89 casenum.append(self.getCellValue(i,1))90 return casecmd,casename,casenum91 def getTestCaseRowNumber(self, column):92 """93 Return a list of all checked test case;94 :param column:95 :return:96 """97 result = []98 for i in range(2, self.getRowsLenth()+1):99 if 'x' == self.getCellValue(i, column):100 result.append(i)101 return result102 def getTestResult(self, column):103 """104 Return a list of all test expect or detect105 :param column:106 :return:107 """108 result = []109 for i in range(2, self.getRowsLenth()+1):110 if 'x' == self.getCellValue(i, 4):111 result.append(self.getCellValue(i,column))112 return result113 def getTimingExpect(self, qdcode):114 """115 Get all input timing expected data;116 :param qdcode:117 :return: A dic of input expected ;118 TESTPARAS = ['HRES', 'VRES', 'VRAT', 'VIC', 'HVIC', 'AR', 'SCAN', 'HTOT',119 'HSPD', 'HSPW', 'HSPP', 'VTOT', 'VSPD', 'VSPW', 'VSPP']120 """121 result = {}122 for i in range(1, self.getRowsLenth() + 1):123 if qdcode == self.getCellValue(i, 3):124 for item in self.TESTPARAS:125 if item == 'HRES':126 result[item] = str(self.getCellValue(i, 16))127 elif item == 'VRES':128 result[item] = str(self.getCellValue(i, 23))129 elif item == 'VRAT':130 result[item] = ("%.2f" % float(self.getCellValue(i, 21)))131 elif item == 'VIC':132 result[item] = str(self.getCellValue(i, 12))133 # elif item == 'HVIC':134 # result[item] = str(self.getCellValue(i, 13))135 elif item == 'AR':136 result[item] = self.getCellValue(i, 14)137 elif item == 'SCAN':138 if 'prog' == self.getCellValue(i, 20):139 result[item] = '1'140 elif 'int' == self.getCellValue(i, 20):141 result[item] = '2'142 else:143 result[item] = self.getCellValue(i, 20)144 elif item == 'HTOT':145 result[item] = str(self.getCellValue(i, 15))146 elif item == 'HSPD':147 result[item] = str(self.getCellValue(i, 17))148 elif item == 'HSPW':149 result[item] = str(self.getCellValue(i, 18))150 elif item == 'HSPP':151 if '+' == self.getCellValue(i, 19):152 result[item] = '1'153 elif '-' == self.getCellValue(i, 19):154 result[item] = '0'155 else: result[item] = self.getCellValue(i, 19)156 elif item == 'VTOT':157 result[item] = str(self.getCellValue(i, 22))158 elif item == 'VSPD':159 result[item] = str(self.getCellValue(i, 24))160 elif item == 'VSPW':161 result[item] = str(self.getCellValue(i, 25))162 elif item == 'VSPP':163 if '+' == self.getCellValue(i, 26):164 result[item] = '1'165 elif '-' == self.getCellValue(i, 26):166 result[item] = '0'167 else: result[item] = self.getCellValue(i, 26)168 else:169 raise("Unknow paras was found!")170 return result171 def getTimingDectec(self, opt):172 qd = quantum780_operation.Quantum780Operation()173 """174 To get Timing paras from 175 :param opt:176 0 - generator177 1 - analyzer 178 :return: a dic of timing paras.179 """180 if '0' == opt:181 return qd.generator_timing_dump()182 if '1' == opt:183 return qd.alyz_timing_dump()184 def getEdid(self, edid, opt):185 """186 return the edid block according to the qdcode;187 :param qdcode:188 :param opt:189 0 - block0190 1 - block1191 :return:192 """193 for i in range(1, self.getRowsLenth()):194 if edid == self.getCellValue(i, 1):195 if opt == '0':196 return self.getCellValue(i,2)197 elif opt == '1':198 return self.getCellValue(i,3)199 else:200 raise ("No edid was found in EDID data!")201 def qdcode2edid(self,qdcode):202 for i in range(1, self.getRowsLenth()):203 if qdcode == self.getCellValue(i, 3):204 return self.getCellValue(i,4)205 else:206 continue207 else:208 raise ("Can not found the qdcode in Resolution Data!")209 def compare_result(self, expected, detected):210 final='PASS'211 for item in expected.keys():212 print("EXPECTED %s is %s and DETECTED %s is %s" % (item, expected[item], item, detected[item]))213 if item == 'VRAT':214 if abs(float(expected['VRAT']) - float(detected['VRAT'])) <= 1:215 tcolor.cprint('PASS','GREEN')216 else:217 tcolor.cprint('FAIL','RED')218 final='FAIL'219 continue220 if expected[item] == detected[item]:221 tcolor.cprint('PASS', 'GREEN')222 else:223 tcolor.cprint('FAIL', 'RED')224 final = 'FAIL'225 return final226 def load_config(self):227 config={}228 for i in range(1, self.getRowsLenth()+1):229 if(self.getCellValue(i,1) and self.getCellValue(i,2)!= None):230 config[self.getCellValue(i,1)]=str(self.getCellValue(i,2))231 continue232 else:233 raise("There is empty value config in file")234 return config235 def getExpectPixelColor(self, inflag, outflag, incolor, outcolor, colume):236 """237 Get expect pixel color of white238 :param inflag: 4k=1, non4k=0239 :param outflag: 4k=1, non4k=0240 :param incolor:241 :param outcolor:242 :param colume: 7=white, 8=red, 9=green, 10=blue243 :return:244 """245 for i in range(1, self.getRowsLenth() + 1):246 if inflag:247 if outflag:248 if incolor =='RGB':249 if outcolor == 'RGB':#1,1,'RGB','RGB'250 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \251 and self.getCellValue(i,4)==outcolor:252 return self.getCellValue(i, colume)253 else: #1,1,'RGB','YCbCr444'254 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \255 and self.getCellValue(i,4)==outcolor:256 return self.getCellValue(i, colume)257 elif incolor == 'YCbCr444':258 if outcolor == 'RGB':#1,1,'YCbCr444','RGB'259 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \260 and self.getCellValue(i,4)==outcolor:261 return self.getCellValue(i, colume)262 else: #1,1,'YCbCr444','YCbCr444'263 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \264 and self.getCellValue(i,4)==outcolor:265 return self.getCellValue(i, colume)266 elif incolor == 'YCbCr422':267 if outcolor == 'RGB':#1,1,'YCbCr422','RGB'268 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \269 and self.getCellValue(i,4)==outcolor:270 return self.getCellValue(i, colume)271 else: #1,1,'YCbCr422','YCbCr444'272 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \273 and self.getCellValue(i,4)==outcolor:274 return self.getCellValue(i, colume)275 elif incolor == 'YCbCr420':276 if outcolor == 'RGB':#1,1,'YCbCr420','RGB'277 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \278 and self.getCellValue(i,4)==outcolor:279 return self.getCellValue(i, colume)280 else: #1,1,'YCbCr420','YCbCr444'281 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \282 and self.getCellValue(i,4)==outcolor:283 return self.getCellValue(i, colume)284 else:raise ("Unknown colorspace")285 elif not outflag:286 if incolor =='RGB':287 if outcolor == 'RGB':#1,0,'RGB','RGB'288 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \289 and self.getCellValue(i,4)==outcolor:290 return self.getCellValue(i, colume)291 else: #1,0,'RGB','YCbCr444'292 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \293 and self.getCellValue(i,4)==outcolor:294 return self.getCellValue(i, colume)295 elif incolor == 'YCbCr444':296 if outcolor == 'RGB':#1,0,'YCbCr444','RGB'297 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \298 and self.getCellValue(i,4)==outcolor:299 return self.getCellValue(i, colume)300 else: #1,0,'YCbCr444','YCbCr444'301 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \302 and self.getCellValue(i,4)==outcolor:303 return self.getCellValue(i, colume)304 elif incolor == 'YCbCr422':305 if outcolor == 'RGB':#1,0,'YCbCr422','RGB'306 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \307 and self.getCellValue(i,4)==outcolor:308 return self.getCellValue(i, colume)309 else: #1,0,'YCbCr422','YCbCr444'310 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \311 and self.getCellValue(i,4)==outcolor:312 return self.getCellValue(i, colume)313 elif incolor == 'YCbCr420':314 if outcolor == 'RGB':#1,0,'YCbCr420','RGB'315 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \316 and self.getCellValue(i,4)==outcolor:317 return self.getCellValue(i, colume)318 else: #1,0,'YCbCr420','YCbCr444'319 if self.getCellValue(i,1)=='x' and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \320 and self.getCellValue(i,4)==outcolor:321 return self.getCellValue(i, colume)322 else:raise ("Unknown colorspace")323 elif not inflag:324 if outflag:325 if incolor =='RGB':326 if outcolor == 'RGB':#0,1,'RGB','RGB'327 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \328 and self.getCellValue(i,4)==outcolor:329 return self.getCellValue(i, colume)330 else: #0,1,'RGB','YCbCr444'331 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \332 and self.getCellValue(i,4)==outcolor:333 return self.getCellValue(i, colume)334 elif incolor == 'YCbCr444':335 if outcolor == 'RGB':#0,1,'YCbCr444','RGB'336 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \337 and self.getCellValue(i,4)==outcolor:338 return self.getCellValue(i, colume)339 else: #0,1,'YCbCr444','YCbCr444'340 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \341 and self.getCellValue(i,4)==outcolor:342 return self.getCellValue(i, colume)343 elif incolor == 'YCbCr422':344 if outcolor == 'RGB':#0,1,'YCbCr422','RGB'345 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \346 and self.getCellValue(i,4)==outcolor:347 return self.getCellValue(i, colume)348 else: #1,1,'YCbCr422','YCbCr444'349 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \350 and self.getCellValue(i,4)==outcolor:351 return self.getCellValue(i, colume)352 elif incolor == 'YCbCr420':353 if outcolor == 'RGB':#0,1,'YCbCr420','RGB'354 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \355 and self.getCellValue(i,4)==outcolor:356 return self.getCellValue(i, colume)357 else: #0,1,'YCbCr420','YCbCr444'358 if self.getCellValue(i,1)==None and self.getCellValue(i,3)=='x' and self.getCellValue(i,2)==incolor \359 and self.getCellValue(i,4)==outcolor:360 return self.getCellValue(i, colume)361 else:raise ("Unknown colorspace")362 elif not outflag:363 if incolor =='RGB':364 if outcolor == 'RGB':#0,0,'RGB','RGB'365 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \366 and self.getCellValue(i,4)==outcolor:367 return self.getCellValue(i, colume)368 else: #0,0,'RGB','YCbCr444'369 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \370 and self.getCellValue(i,4)==outcolor:371 return self.getCellValue(i, colume)372 elif incolor == 'YCbCr444':373 if outcolor == 'RGB':#0,0,'YCbCr444','RGB'374 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \375 and self.getCellValue(i,4)==outcolor:376 return self.getCellValue(i, colume)377 else: #0,0,'YCbCr444','YCbCr444'378 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \379 and self.getCellValue(i,4)==outcolor:380 return self.getCellValue(i, colume)381 elif incolor == 'YCbCr422':382 if outcolor == 'RGB':#0,0,'YCbCr422','RGB'383 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \384 and self.getCellValue(i,4)==outcolor:385 return self.getCellValue(i, colume)386 else: #0,0,'YCbCr422','YCbCr444'387 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \388 and self.getCellValue(i,4)==outcolor:389 return self.getCellValue(i, colume)390 elif incolor == 'YCbCr420':391 if outcolor == 'RGB':#0,0,'YCbCr420','RGB'392 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \393 and self.getCellValue(i,4)==outcolor:394 return self.getCellValue(i, colume)395 else: #0,0,'YCbCr420','YCbCr444'396 if self.getCellValue(i,1)==None and self.getCellValue(i,3)==None and self.getCellValue(i,2)==incolor \397 and self.getCellValue(i,4)==outcolor:398 return self.getCellValue(i, colume)399 else:raise ("Unknown colorspace")400if __name__ == '__main__':401 filename = "D:\hdmi_hdbt_test_suite\\ConfigResolutionData.xlsx"402 edid = "D:\\TestStandDemo\\VideoSwtich\\QdEDID.xlsx"403 sco = SwitchConfigOperation(filename,2)404 #edidobj = SwitchConfigOperation(edid)405 # sheetName = sco.get_sheetNames()406 # print(sheetName)407 # print(sco.getRowsLenth())408 # print(sco.getColumnsLenth())409 # dic = sco.load_config()410 # print(dic)411 # print(dic['OutputPortType'])412 #print(sco.getCellValue(1,1))413 #print(sco.getRowsLenth())414 #print(sco.getColumnsLenth())415 #ge = sco.getSupportTiming(37)416 #ge = sco.getSupportTiming(39)417 #for code in ge:418 # print (code)419 #timing = sco.getSupportTimingList(37)420 #black, white = sco.getPixelColor('YCbCr444', 1)421 print("white is:"+sco.getExpectPixelColor(0,0,'YCbCr420','YCbCr444', 8))422 #print(sco.getCellValue(2,1))423 #print(sco.getTimingExpect(code))424 #print(sco.getEdid('1080p60','0'))425 #print(sco.getEdid('1024x576','1'))426 # qdcode = '1080p60'427 # edidc = sco.qdcode2edid(qdcode)428 # print(edidc)...

Full Screen

Full Screen

GameBoard.py

Source:GameBoard.py Github

copy

Full Screen

1import pygame234class Board:5 def __init__(self, width, height):6 self.width = width7 self.height = height8 self.board = [[0] * width for _ in range(height)]9 self.left = 1010 self.top = 1011 self.cell_size = 3012 self.gameField = []13 self.initField()14 self.imageList = []15 self.size = []16 self.screen = 01718 def set_view(self, left, top, cell_size):19 self.left = left20 self.top = top21 self.cell_size = cell_size2223 def render(self, screen):24 self.size = self.cell_size * self.width, self.cell_size * self.height25 self.screen = screen26 screen2 = pygame.Surface(self.size)27 bg_color = pygame.Color('black')28 cell_color = pygame.Color('white')29 screen2.fill(bg_color)30 for row in range(0, self.height):31 for col in range(0, self.width):32 rect = ((col * self.cell_size, row * self.cell_size), (self.cell_size, self.cell_size))33 if self.gameField[row][col] == -1:34 screen2.fill((0, 0, 0), rect)35 else:36 screen2.fill((105, 105, 105), rect)37 if self.gameField[row][col] >= 0:38 chip = self.imageList[self.gameField[row][col]]39 screen2.blit(chip.getImage(), rect)4041 pygame.draw.rect(screen2, (255, 255, 255), rect, 1)42 screen.blit(screen2, (self.left, self.top))4344 def getCell(self, mouse_pos):45 x, y = mouse_pos46 x, y = x - self.left, y - self.top47 x, y = x + self.cell_size // 2, y + self.cell_size // 248 if x <= 0 or y <= 0 or x >= (self.size[0]) or y >= (self.size[1]):49 print('out', x, y)50 return -1, -151 col = x // self.cell_size52 row = y // self.cell_size53 #print('x: ', x, ', y: ', y, ', row: ', row, ', col: ', col)54 return row, col5556 def onClick(self, cell_coords):57 row, col = cell_coords58 self.gameField[row][col] = 1 if self.board[row][col] == 0 else 05960 def initField(self):61 self.gameField = []62 for i in range(0, self.height):63 row = []64 for j in range(0, self.width):65 row.append(-1)66 self.gameField.append(row)6768 def setCell(self, row, col, cursorIndex):69 self.gameField[row][col] = cursorIndex7071 def setImageList(self, imageList):72 self.imageList = imageList7374 def checkCell(self, row, col, cursorIndex):75 # проверка на занятость клетки76 if self.getCellValue(row, col) >= 0:77 return False7879 # Алтарь?80 if cursorIndex != 0:81 # проверка на отсутствие соседeй82 if self.checkNoNeighbours(row, col) is True:83 return False84 else:85 return True8687 if self.tolcoAltar(row, col) is True:88 return True8990 neighbours = self.getNeighbours(row, col)91 if self.checkNeighbourMatches(cursorIndex, neighbours) is True:92 return True93 return False9495 def getCellValue(self, row, col):96 return self.gameField[row][col]9798 def checkNoNeighbours(self, row, col):99 # (0, 0)100 if row == 0 and col == 0:101 if self.getCellValue(row, col + 1) < 0 and self.getCellValue(row + 1, col) < 0:102 print(row, col, '0,0')103 return True104 else:105 return False106107 # (width, 0)108 if row == 0 and col == self.width - 1:109 if self.getCellValue(row + 1, col) < 0 and \110 self.getCellValue(row, col - 1) < 0:111 print(row, col, 'width,0')112 return True113 else:114 return False115116 # (0, height)117 if row == self.height - 1 and col == 0:118 if self.getCellValue(row - 1, col) < 0 and \119 self.getCellValue(row, col + 1) < 0:120 print(row, col, '0,height')121 return True122 else:123 return False124125 # (width, height)126 if row == self.height - 1 and col == self.width - 1:127 if self.getCellValue(row - 1, col) < 0 and \128 self.getCellValue(row, col - 1) < 0:129 print(row, col, 'width, height')130 return True131 else:132 return False133134 # крайние левые135 if col == 0:136 if self.getCellValue(row - 1, col) < 0 and self.getCellValue(row + 1, col) < 0 and \137 self.getCellValue(row, col + 1) < 0:138 print(row, col, 'крайние левые')139 return True140141 # крайние правые142 if col == self.width - 1:143 if self.getCellValue(row - 1, col) < 0 and self.getCellValue(row + 1, col) < 0 and \144 self.getCellValue(row, col - 1) < 0:145 print(row, col, 'крайние правые')146 return True147 else:148 return False149150 # крайние нижние151 if row == self.height - 1:152 if self.getCellValue(row - 1, col) < 0 and self.getCellValue(row, col - 1) < 0 and \153 self.getCellValue(row, col + 1) < 0:154 print(row, col, 'крайние нижние')155 return True156 else:157 return False158159 # крайние верхние160 if row == 0:161 if self.getCellValue(row + 1, col) < 0 and self.getCellValue(row, col - 1) < 0 and \162 self.getCellValue(row, col + 1) < 0:163 print(row, col, 'крайние верхние')164 return True165 else:166 return False167168 # остальные169 if self.getCellValue(row, col + 1) < 0 and self.getCellValue(row, col - 1) < 0 and \170 self.getCellValue(row + 1, col) < 0 and self.getCellValue(row - 1, col) < 0:171 return True172 else:173 return False174175 # проверка рядом только алтарь176 def tolcoAltar(self, row, col):177 if row == 0 and col == 0:178 if self.getCellValue(row, col + 1) <= 0 and self.getCellValue(row + 1, col) <= 0:179 return True180 else:181 return False182183 # (width, 0)184 if row == 0 and col == self.width - 1:185 if self.getCellValue(row + 1, col) <= 0 and \186 self.getCellValue(row, col - 1) <= 0:187 return True188 else:189 return False190191 # (0, height)192 if row == self.height - 1 and col == 0:193 if self.getCellValue(row - 1, col) <= 0 and \194 self.getCellValue(row, col + 1) <= 0:195 print(row, col, '0,height')196 return True197 else:198 return False199200 # (width, height)201 if row == self.height - 1 and col == self.width - 1:202 if self.getCellValue(row - 1, col) <= 0 and \203 self.getCellValue(row, col - 1) <= 0:204 print(row, col, 'width, height')205 return True206 else:207 return False208209 # крайние левые210 if col == 0:211 if self.getCellValue(row - 1, col) <= 0 and self.getCellValue(row + 1, col) <= 0 and \212 self.getCellValue(row, col + 1) <= 0:213 print(row, col, 'крайние левые')214 return True215216 # крайние правые217 if col == self.width - 1:218 if self.getCellValue(row - 1, col) <= 0 and self.getCellValue(row + 1, col) <= 0 and \219 self.getCellValue(row, col - 1) <= 0:220 print(row, col, 'крайние правые')221 return True222 else:223 return False224225 # крайние нижние226 # print('r', row, self.height, row == self.height - 1)227 if row == self.height - 1:228 if self.getCellValue(row - 1, col) <= 0 and self.getCellValue(row, col - 1) <= 0 and \229 self.getCellValue(row, col + 1) <= 0:230 print(row, col, 'крайние нижние')231 return True232 else:233 return False234235 # крайние верхние236 if row == 0:237 if self.getCellValue(row + 1, col) <= 0 and self.getCellValue(row, col - 1) <= 0 and \238 self.getCellValue(row, col + 1) <= 0:239 print(row, col, 'крайние верхние')240 return True241 else:242 return False243244 # остальные245 if self.getCellValue(row, col + 1) <= 0 and self.getCellValue(row, col - 1) <= 0 and \246 self.getCellValue(row + 1, col) <= 0 and self.getCellValue(row - 1, col) <= 0:247 return True248 else:249 return False250251 def getNeighbours(self, row, col):252 neighbours = []253 # (0, 0)254 if row == 0 and col == 0:255 if self.getCellValue(row, col + 1) > 0:256 neighbours.append(self.getCellValue(row, col + 1))257 if self.getCellValue(row + 1, col) > 0:258 neighbours.append(self.getCellValue(row + 1, col))259 return neighbours260261 # (width, 0)262 if row == 0 and col == self.width - 1:263 if self.getCellValue(row + 1, col) > 0:264 neighbours.append(self.getCellValue(row + 1, col))265 if self.getCellValue(row, col - 1) > 0:266 neighbours.append(self.getCellValue(row, col - 1))267268 # (0, height)269 if row == self.height - 1 and col == 0:270 if self.getCellValue(row - 1, col) > 0:271 neighbours.append(self.getCellValue(row - 1, col))272 if self.getCellValue(row, col + 1) > 0:273 neighbours.append(self.getCellValue(row, col + 1))274 return neighbours275276 # (width, height)277 if row == self.height - 1 and col == self.width - 1:278 if self.getCellValue(row - 1, col) > 0:279 neighbours.append(self.getCellValue(row - 1, col))280 if self.getCellValue(row, col - 1) > 0:281 neighbours.append(self.getCellValue(row, col - 1))282 return neighbours283284 # крайние левые285 if col == 0:286 if self.getCellValue(row - 1, col) > 0:287 neighbours.append(self.getCellValue(row - 1, col))288 if self.getCellValue(row + 1, col) > 0:289 neighbours.append(self.getCellValue(row + 1, col))290 if self.getCellValue(row, col + 1) > 0:291 neighbours.append(self.getCellValue(row, col + 1))292 return neighbours293294 # крайние правые295 if col == self.width - 1:296 if self.getCellValue(row - 1, col) > 0:297 neighbours.append(self.getCellValue(row - 1, col))298 if self.getCellValue(row + 1, col) > 0:299 neighbours.append(self.getCellValue(row + 1, col))300 if self.getCellValue(row, col - 1) > 0:301 neighbours.append(self.getCellValue(row, col - 1))302 return neighbours303304 # крайние нижние305 if row == self.height - 1:306 if self.getCellValue(row - 1, col) > 0:307 neighbours.append(self.getCellValue(row - 1, col))308 if self.getCellValue(row, col - 1) > 0:309 neighbours.append(self.getCellValue(row, col - 1))310 if self.getCellValue(row, col + 1) > 0:311 neighbours.append(self.getCellValue(row, col + 1))312 return neighbours313314 # крайние верхние315 if row == 0:316 if self.getCellValue(row + 1, col) > 0:317 neighbours.append(self.getCellValue(row + 1, col))318 if self.getCellValue(row, col - 1) > 0:319 neighbours.append(self.getCellValue(row, col - 1))320 if self.getCellValue(row, col + 1) > 0:321 neighbours.append(self.getCellValue(row, col + 1))322 return neighbours323 # остальные324 if self.getCellValue(row, col + 1) > 0:325 neighbours.append(self.getCellValue(row, col + 1))326 if self.getCellValue(row, col - 1) > 0:327 neighbours.append(self.getCellValue(row, col - 1))328 if self.getCellValue(row + 1, col) > 0:329 neighbours.append(self.getCellValue(row + 1, col))330 if self.getCellValue(row - 1, col) > 0:331 neighbours.append(self.getCellValue(row - 1, col))332 return neighbours333334 def checkNeighbourMatches(self, cursorIndex, neighbours):335 matches = []336 chip = self.imageList[cursorIndex]337 for i in range(0, len(neighbours)):338 if chip.getType() == self.imageList[neighbours[i]].getType() or \339 chip.getColor() == self.imageList[neighbours[i]].getColor():340 matches.insert(i, 1)341 if len(neighbours) != len(matches):342 return False343 else:344 return True345346 def checkRowCol(self, row, col):347 countCol = 0348 for i in range(0, len(self.gameField)):349 if i == row:350 for j in range(0, len(self.gameField[i])):351 if self.getCellValue(i, j) >= 0:352 countCol += 1353354 countRow = 0355 for i in range(0, len(self.gameField)):356 for j in range(0, len(self.gameField[i])):357 if j == col:358 if self.getCellValue(i, j) >= 0:359 countRow += 1360361 return countCol == self.width, countRow == self.height362363 def clearRow(self, row):364 for j in range(0, self.width):365 self.gameField[row][j] = -2366367 def clearCol(self, col):368 for i in range(0, self.height):369 self.gameField[i][col] = -2370371 def checkFilled(self):372 counter = 0373 for i in range(0, len(self.gameField)):374 for j in range(0, len(self.gameField[i])):375 if self.getCellValue(i, j) == -1:376 counter += 1377 if counter == 0:378 return True379 else: ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful