summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-11-22 14:00:47 +0100
committerFlorian Bruhin <git@the-compiler.org>2013-11-22 14:00:47 +0100
commit2549d129bb48021b7112f00cfbdd1d11e5caf637 (patch)
tree150500a9a9886ce62aa42bf5ed55c917ec79c35f
parentbca8857053948280a38b10471de300fc571d72cc (diff)
downloadpyrmlint-2549d129bb48021b7112f00cfbdd1d11e5caf637.tar.gz
pyrmlint-2549d129bb48021b7112f00cfbdd1d11e5caf637.zip
Add output test tool
-rw-r--r--testout.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/testout.py b/testout.py
new file mode 100644
index 0000000..6383a1a
--- /dev/null
+++ b/testout.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+import sys
+import pyrmlint
+
+def fobj2str(fobj):
+ return b'//'.join([
+ fobj.dupflag.encode('ASCII'),
+ fobj.md5sum.encode('ASCII'),
+ fobj.path.replace(b"'", b"'\"'\"'"),
+ str(fobj.size).encode('ASCII'),
+ str(fobj.devid).encode('ASCII'),
+ str(fobj.inode).encode('ASCII'),
+ b''
+ ])
+
+r = pyrmlint.Logreader()
+with open(sys.argv[1], 'rb') as f:
+ r.parse(f)
+for lst in r.data.values():
+ for fobj in lst:
+ if fobj.dupflag not in ['DUPL', 'ORIG']:
+ out = fobj2str(fobj)
+ sys.stdout.buffer.write(out + b'\n')
+ sys.stdout.flush()
+for dupl in r.duplicates:
+ for i, f in enumerate(dupl):
+ if i == 0:
+ fobj.dupflag = 'ORIG'
+ else:
+ fobj.dupflag = 'DUPL'
+ out = fobj2str(fobj)
+ sys.stdout.buffer.write(out + b'\n')
+ sys.stdout.flush()