summaryrefslogtreecommitdiff
path: root/patchtracker/Patch.py
diff options
context:
space:
mode:
authorSean Finney <seanius@seanius.net>2009-12-02 20:24:48 +0100
committerSean Finney <seanius@seanius.net>2009-12-02 20:24:48 +0100
commite5fd3dd111d34276aa705f8eac09494cda178c98 (patch)
treeb36476974d180210253237f8968803bc0f717780 /patchtracker/Patch.py
parent11db52a1fedf54f728a9c7f6a890c1bc6d28bd7c (diff)
downloadpatch-tracker-e5fd3dd111d34276aa705f8eac09494cda178c98.tar.gz
initial support for source package format 3.0 (quilt)
the changes aren't as pretty as i'd like them to be, but i don't want to hold things up on mere aesthetic grounds and it seems to work anyway :)
Diffstat (limited to 'patchtracker/Patch.py')
-rw-r--r--patchtracker/Patch.py65
1 files changed, 42 insertions, 23 deletions
diff --git a/patchtracker/Patch.py b/patchtracker/Patch.py
index 670f389..e19ad8c 100644
--- a/patchtracker/Patch.py
+++ b/patchtracker/Patch.py
@@ -2,6 +2,7 @@ import sys
import os
import errno
from glob import glob
+import tarfile
class Diffstat:
def __init__(self, patch):
@@ -38,9 +39,35 @@ class Patch:
def diffstat(self):
return Diffstat(self)
-# XXX this entire __init__ stuff is way to ugly
-class PatchSeries (list):
+class GenericPatchSeries (list):
+ def blank(self):
+ self.names = []
+ self.style = "unknown"
+ self.patches = {}
+ self.patchargs = {}
+
+ # WTF am i doing this for, again?
+ def iterpatches(self):
+ for p in self.names:
+ yield (p, self.patches[p])
+
+ def __iter__(self):
+ return self.iterpatches()
+
+ def __getitem__(self, y):
+ return self.patches[self.names[y]]
+
+ def __len__(self):
+ return len(self.names)
+
+ def fetch(self, name):
+ return self.patches[name]
+
+ def __str__(self):
+ return "\n".join(self.names)
+# XXX this entire __init__ stuff is way to ugly
+class PatchSeries (GenericPatchSeries):
def __init__(self, dir):
fd = None
self.blank()
@@ -110,27 +137,19 @@ class PatchSeries (list):
for p in removelater:
self.names.remove(p)
- def blank(self):
- self.names = []
- self.style = "unknown"
- self.patches = {}
- self.patchargs = {}
-
- def iterpatches(self):
- for p in self.names:
- yield (p, self.patches[p])
-
- def __getitem__(self, y):
- return self.patches[self.names[y]]
-
- def __len__(self):
- return len(self.names)
-
- def fetch(self, name):
- return self.patches[name]
-
- def __str__(self):
- return "\n".join(self.names)
+class Quilt30PatchSeries (GenericPatchSeries):
+ def __init__(self, tarBall):
+ self.blank()
+ self.style = "quilt (3.0)"
+ self.tarfh = tarfile.open(tarBall, 'r:*')
+ try:
+ series_fh = self.tarfh.extractfile("debian/patches/debian.series")
+ except KeyError:
+ series_fh = self.tarfh.extractfile("debian/patches/series")
+ self.names = ["debian/patches/"+fn.strip() for fn in series_fh.readlines()]
+ # XXX to lazy eval this might be better
+ for name in self.names:
+ self.patches[name] = Patch(self.tarfh.extractfile(name))
if __name__ == "__main__":
print "Patch.py testing"