[ooni-probe/master] Implement parsing function for log YAML format

commit 8481646e3325c6126101a62ab2023f06cb3fc82d Author: Arturo Filastò <hellais@gmail.com> Date: Tue Feb 21 10:53:40 2012 -0800 Implement parsing function for log YAML format --- refactor/utils.py | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/refactor/utils.py b/refactor/utils.py index 93bd2fd..79edadb 100644 --- a/refactor/utils.py +++ b/refactor/utils.py @@ -4,6 +4,10 @@ import imp import logging +try: + import yaml +except: + print "Error in importing YAML" class Storage(dict): """ @@ -114,6 +118,11 @@ def import_test(name, config): return None, None class Log(): + """ + This is a class necessary for parsing YAML log files. + It is required because pyYaml has a bug in parsing + log format YAML files. + """ def __init__(self, file=None): if file: self.fh = open(file) @@ -122,10 +131,15 @@ class Log(): return self def next(self): + lines = [] try: line = self.fh.readline() + if not line: + raise StopIteration while not line.startswith("---"): + lines.append(line) line = self.fh.readline() + return lines except: raise StopIteration
participants (1)
-
art@torproject.org