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): dict.__init__(self) self['index-version'] = 1 self['packages'] = {} def add (self, pkg): if not self['packages'].has_key(pkg.name): url = '%s/packages/%s'%(Conf.root_url, pkg.name) self['packages'][pkg.name] = { 'url': url, 'versions': {} } if not self['packages'][pkg.name].has_key(pkg.version): self['packages'][pkg.name]['versions'][pkg.version]=PtsIndexPackageInfo(pkg)