[tor-commits] [ooni-probe/master] Add a method for line by line asset parsing
art at torproject.org
art at torproject.org
Thu Mar 15 06:26:18 UTC 2012
commit 2e9472e4989985ebdb770c193856a02616a3d8e4
Author: Arturo Filastò <hellais at gmail.com>
Date: Wed Mar 14 23:20:43 2012 -0700
Add a method for line by line asset parsing
---
plugoo/assets.py | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/plugoo/assets.py b/plugoo/assets.py
index 6f566fe..eded997 100644
--- a/plugoo/assets.py
+++ b/plugoo/assets.py
@@ -26,6 +26,13 @@ class Asset:
self.fh.seek(0)
return i + 1
+ def parse_line(self, line):
+ """
+ Override this method if you need line
+ by line parsing of an Asset.
+ """
+ return line.replace('\n','')
+
def next_asset(self):
"""
Return the next asset.
@@ -34,7 +41,9 @@ class Asset:
# clean me up please...
line = self.fh.readline()
if line:
- return line.replace('\n','')
+ parsed_line = self.parse_line(line)
+ if parsed_line:
+ return parsed_line
else:
self.fh.seek(0)
raise StopIteration
More information about the tor-commits
mailing list