def load(filename): """Load clues from file. :param filename: Name of the files where the clues are stored. @type filename: C{str} :return: Clues extracted from the file. @rtype: C{list} @raise InvalidFile: In case there's a problem while reinterpreting the clues. """ cluefp = open(filename, 'r') reader = csv.reader(cluefp) clues = [] for tup in reader: try: count, localtime, headers = tup except ValueError: raise InvalidFile('Cannot unpack fields') # Recreate the current clue. clue = Clue() try: clue._count = int(count) clue._local = float(localtime) except ValueError: raise InvalidFile('Could not convert fields') # This may be risky from a security standpoint. clue.headers = eval(headers, {}, {}) if not (isinstance(clue.headers, types.ListType) or isinstance(clue.headers, types.TupleType)): raise InvalidFile('Wrong clue header field') clue.parse(clue.headers) clues.append(clue) cluefp.close() return clues