diff options
Diffstat (limited to 'patchtracker/Patch.py')
-rw-r--r-- | patchtracker/Patch.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/patchtracker/Patch.py b/patchtracker/Patch.py index 2f604e1..4ec0594 100644 --- a/patchtracker/Patch.py +++ b/patchtracker/Patch.py @@ -3,6 +3,27 @@ import os import errno from glob import glob +class Diffstat: + def __init__(self, patch): + self.patch = patch + i,o = os.popen2("diffstat") + i.write(str(patch)) + i.close() + self.output = o.readlines() + + def stats(self): + i,o = os.popen2("diffstat -t") + i.write(str(self.patch)) + i.close() + o.readline() + return [l.split(",") for l in o.readlines()] + + def summary(self): + return self.output[-1] + + def __str__(self): + return "".join(self.output) + class Patch: def __init__(self, fh, level=1): self.p = fh.readlines() @@ -15,11 +36,7 @@ class Patch: return len(self.p) def diffstat(self): - i,o = os.popen2("diffstat") - i.write(str(self)) - i.close() - return o.read() - + return Diffstat(self) # XXX this entire __init__ stuff is way to ugly class PatchSeries (list): |