def dimensions(): max_x = 0 max_y = 0 for cell in utils.cells(): max_x = max(max_x, cell.x) max_y = max(max_y, cell.y) return max_x * WIDE_CELL, max_y
import utils from itertools import groupby types = ['dim', 'flag', 'metric'] sortedcells = sorted(utils.cells(), key=lambda cell: cell.sortkey) for y, (_row, cells) in enumerate(groupby(sortedcells, lambda cell: cell.sortkey)): for cell in cells: if cell.is_empty: continue color = types.index(cell.type) print '%s %d %d %d %d' % (cell.key, cell.x, y, 0 if cell.type == 'flag' else 1, color)
import utils types = ['dim', 'flag', 'metric'] for cell in utils.cells(): if cell.is_empty: continue color = types.index(cell.type) print '%s %d %d %d %d' % (cell.key, cell.x, cell.y, 0 if cell.type == 'flag' else 1, color)
import utils from itertools import groupby types = ['dim', 'flag', 'metric'] skey = lambda cell: cell.sortkey.split()[0] sortedcells = sorted(utils.cells(), key=skey) for y, (row, cells) in enumerate(groupby(sortedcells, skey)): for cell in cells: if cell.is_empty: continue color = types.index(cell.type) print '%s %d %d %d %d' % (cell.key, cell.x, y, 0 if cell.type == 'flag' else 1, color)
import utils from itertools import groupby types = ['dim', 'flag', 'metric'] skey = lambda cell: cell.sortkey.split()[0] sortedcells = sorted(utils.cells(), key=skey) for y, (_row, cells) in enumerate(groupby(sortedcells, skey)): for i, (_row, cells) in enumerate(groupby(cells, lambda cell: cell.y)): x = 0 for cell in cells: if cell.is_empty: continue color = 3 if i > 0 else types.index(cell.type) print '%s %d %d %d %d' % (cell.key, x, y, 0 if cell.type == 'flag' else 1, color) x += 1
import utils from itertools import groupby types = ["dim", "flag", "metric"] sortedcells = sorted(utils.cells(), key=lambda cell: cell.sortkey) for y, (_row, cells) in enumerate(groupby(sortedcells, lambda cell: cell.sortkey)): for cell in cells: if cell.is_empty: continue color = types.index(cell.type) print "%s %d %d %d %d" % (cell.key, cell.x, y, 0 if cell.type == "flag" else 1, color)