summaryrefslogtreecommitdiff
path: root/patchtracker/PtsIndex.py
diff options
context:
space:
mode:
Diffstat (limited to 'patchtracker/PtsIndex.py')
-rw-r--r--patchtracker/PtsIndex.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/patchtracker/PtsIndex.py b/patchtracker/PtsIndex.py
new file mode 100644
index 0000000..6f60863
--- /dev/null
+++ b/patchtracker/PtsIndex.py
@@ -0,0 +1,33 @@
+import os
+
+import Conf
+from DiffGzHandler import DiffGzHandler
+
+class PtsIndexPackageInfo ( dict ):
+ def __init__ (self, srcpkg):
+ dict.__init__(self)
+ self['type'] = srcpkg.type
+ self['format'] = srcpkg.format
+
+ if srcpkg.diffgz_name:
+ diffgz = os.sep.join([Conf.archive_root,srcpkg.loc,srcpkg.diffgz_name])
+ dh = DiffGzHandler( diffgz )
+ ser = dh.series()
+ if ser:
+ self['series-patches'] = len(ser)
+ self['url'] = '%s/packages/%s/%s'%(Conf.root_url,
+ srcpkg.name,srcpkg.version)
+
+class PtsIndexFile ( dict ):
+ def __init__ (self, archive, suites=None, packages=None):
+ dict.__init__(self)
+ self['index-version'] = 1
+ self['packages'] = {}
+ for s in archive.suites(filter=suites):
+ for c in archive.components(s):
+ for p in archive.sourcepackages(s, c, filter=packages):
+ if not self['packages'].has_key(p.name):
+ url = '%s/packages/%s'%(Conf.root_url, p.name)
+ self['packages'][p.name] = { 'url': url, 'versions': {} }
+ if not self['packages'][p.name].has_key(p.version):
+ self['packages'][p.name]['versions'][p.version]=PtsIndexPackageInfo(p)