def load_sessions_from_file(files=DEFAULT_FILES): sessions = set() corruptions = set() try: with open('data/corruptions', 'r') as f: for line in f: corruptions.add(line[:-1]) except: pass for record in utilities.glob(files): if record not in corruptions: with open(record, 'r') as f: try: sessions.add(cPickle.load(f)) except: corruptions.add(record) if corruptions: print("Warning! Failed to pickle {} sessions stored locally.".format( len(corruptions) )) with open('data/corruptions', 'w') as f: for s in corruptions: f.write("{}\n".format(s)) return sessions
def file_sessions(files=DEFAULT_FILES): regexp = re.compile(files.replace('*', '(.*)')) return set([regexp.match(s).group(1) for s in utilities.glob(files)])