def filesByCell(fnames,cells):
byCell={}<EOL>fnames=smartSort(fnames)<EOL>days = list(set([elem[:<NUM_LIT:5>] for elem in fnames if elem.endswith("<STR_LIT>")])) <EOL>for day in smartSort(days):<EOL><INDENT>parent=None<EOL>for i,fname in enumerate([elem for elem in fnames if elem.startswith(day) and elem.endswith("<STR_LIT>")]):<EOL><INDENT>ID=os.path.splitext(fname)[<NUM_LIT:0>]<EOL>if len([x for x in fnames if x.startswith(ID)])-<NUM_LIT:1>:<EOL><INDENT>parent=ID<EOL><DEDENT>if not parent in byCell:<EOL><INDENT>byCell[parent]=[]<EOL><DEDENT>byCell[parent]=byCell[parent]+[fname]<EOL><DEDENT><DEDENT>return byCell<EOL>
given files and cells, return a dict of files grouped by cell.