def read(file): with open(file, 'r') as f: if os.stat(file).st_size == 0: raise FileNotFoundError lines = f.readlines() B = [[None for x in range(16)] for y in range(9)] for line in lines: line = line.strip('\n') l = line.split(';') x = int(int(l[1]) / 100) y = int(int(l[2]) / 100) if l[0] == 'wall': e = Wall(x, y) e.up = to_rgb(l[3]) e.left = to_rgb(l[4]) e.down = to_rgb(l[5]) e.right = to_rgb(l[6]) e.color = to_rgb(l[7]) B[x][y] = e if l[0] == 'piece': e = Piece(x, y) e.up = to_rgb(l[3]) e.left = to_rgb(l[4]) e.down = to_rgb(l[5]) e.right = to_rgb(l[6]) if int(l[7]) == 1: e.upside = True B[x][y] = e if l[0] == 'blank': e = Blank(x, y) B[x][y] = e return B