summaryrefslogtreecommitdiffstats
path: root/pyrmlint.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyrmlint.py')
-rw-r--r--pyrmlint.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/pyrmlint.py b/pyrmlint.py
index 72d320b..9e0fa63 100644
--- a/pyrmlint.py
+++ b/pyrmlint.py
@@ -24,20 +24,24 @@ class File:
class Logreader:
data = {}
duplicates = []
+ _curmd5 = None
+ _duplist = None
def __init__(self):
for e in ['BLNK', 'OTMP', 'BASE', 'EDIR', 'JNKD', 'JNKF', 'ZERO',
'NBIN', 'BGID', 'BUID', 'ORIG', 'DUPL']:
self.data[e] = []
- def _parsedupl(self):
- d = {}
- for f in self.data['ORIG'] + self.data['DUPL']:
- if f.md5sum in d:
- d[f.md5sum].append(f)
- else:
- d[f.md5sum] = [f]
- self.duplicates = list(d.values())
+ 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):
for line in f:
@@ -46,7 +50,8 @@ class Logreader:
fobj = File()
fobj.fromlog(line)
self.data[fobj.dupflag].append(fobj)
- self._parsedupl()
+ if fobj.dupflag in ['ORIG', 'DUPL']:
+ self._parsedupl(fobj)
def main():
pass