summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-11-22 13:23:35 +0100
committerFlorian Bruhin <git@the-compiler.org>2013-11-22 14:00:56 +0100
commitc95e574c49400b1728b0a0b192b4c11134258424 (patch)
tree58c2064ba55e8677cab419f799afd16b5e7fde3c
parent2549d129bb48021b7112f00cfbdd1d11e5caf637 (diff)
downloadpyrmlint-c95e574c49400b1728b0a0b192b4c11134258424.tar.gz
pyrmlint-c95e574c49400b1728b0a0b192b4c11134258424.zip
Use alternative duplicate parsing
-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