summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyrmlint.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/pyrmlint.py b/pyrmlint.py
index 4cb65a7..c32c607 100644
--- a/pyrmlint.py
+++ b/pyrmlint.py
@@ -30,8 +30,6 @@ class File:
class Logreader:
data = {}
duplicates = []
- _curmd5 = None
- _duplist = None
def __init__(self):
for e in ['BLNK', 'OTMP', 'BASE', 'EDIR', 'JNKD', 'JNKF', 'ZERO',
@@ -42,26 +40,31 @@ class Logreader:
with open(fn, 'rb') as f:
self.parse(f)
- def _parsedupl(self, fobj):
- if fobj.dupflag == 'ORIG':
- if self._duplist is not None:
- self.duplicates.append(self._duplist[:])
- self._curmd5 = fobj.md5sum
- self._duplist = [fobj]
- elif fobj.dupflag == 'DUPL':
- if self._curmd5 != fobj.md5sum:
- raise IOError("DUPL with unexpected md5 found")
- self._duplist.append(fobj)
-
def parse(self, f):
+ duplist = []
+ curmd5 = None
+
for line in f:
if line.startswith(b'#'):
continue
fobj = File()
fobj.fromlog(line)
- self.data[fobj.dupflag].append(fobj)
- self._parsedupl(fobj)
- self.duplicates.append(self._duplist[:])
+
+ if fobj.dupflag == 'ORIG':
+ if duplist:
+ self.duplicates.append(duplist)
+ curmd5 = fobj.md5sum
+ duplist = [fobj]
+ elif fobj.dupflag == 'DUPL':
+ if not duplist:
+ raise IOError("DUPL without ORIG found")
+ if curmd5 != fobj.md5sum:
+ raise IOError("DUPL with unexpected md5 found")
+ duplist.append(fobj)
+ else:
+ self.data[fobj.dupflag].append(fobj)
+ if duplist:
+ self.duplicates.append(duplist)
def main():
pass