Did I find the right examples for you? yes no

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
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.

        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
        


src/h/a/halberd-0.2.4/Halberd/shell.py   halberd(Download)
    def execute(self):
        """Reads and interprets clues.
        """
        self.task.clues = Halberd.clues.file.load(self.task.cluefile)
        self._analyze()

src/h/a/halberd-HEAD/Halberd/shell.py   halberd(Download)
    def execute(self):
        """Reads and interprets clues.
        """
        self.task.clues = Halberd.clues.file.load(self.task.cluefile)
        self._analyze()

src/h/a/halberd-HEAD/tests/test_clues_file.py   halberd(Download)
    def testSimpleSaveAndLoad(self):
        try:
            Halberd.clues.file.save(self.filename, [self.clue])
            clues = Halberd.clues.file.load(self.filename)
        finally:

src/h/a/halberd-HEAD/tests/test_clues_analysis.py   halberd(Download)
    def _getClues(self, filename):
        fname = os.path.join('tests', 'data', filename + '.clu')
        return Halberd.clues.file.load(fname)
 
    def analyze(self, filename, expected_raw, expected_analyzed):

src/h/a/halberd-0.2.4/tests/test_clues_file.py   halberd(Download)
    def testSimpleSaveAndLoad(self):
        try:
            Halberd.clues.file.save(self.filename, [self.clue])
            clues = Halberd.clues.file.load(self.filename)
        finally:

src/h/a/halberd-0.2.4/tests/test_clues_analysis.py   halberd(Download)
    def _getClues(self, filename):
        fname = os.path.join('tests', 'data', filename + '.clu')
        return Halberd.clues.file.load(fname)
 
    def analyze(self, filename, expected_raw, expected_analyzed):