diff options
author | Sean Finney <seanius@debian.org> | 2008-06-10 08:19:10 +0200 |
---|---|---|
committer | Sean Finney <seanius@debian.org> | 2008-06-10 08:19:10 +0200 |
commit | 9a0d276e494f148a9c8a383f7293aeb4bc852965 (patch) | |
tree | 11c92bb263e8bb592871ec3a122edb7246220730 /patchtracker | |
parent | 56cd4ae0bbb2f9fa35e98135fea1f5b2520bd4e5 (diff) | |
download | patch-tracker-9a0d276e494f148a9c8a383f7293aeb4bc852965.tar.gz |
sorting fixups/cleanups
Diffstat (limited to 'patchtracker')
-rwxr-xr-x | patchtracker/SourceArchive.py | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/patchtracker/SourceArchive.py b/patchtracker/SourceArchive.py index ba3ae42..1f12001 100755 --- a/patchtracker/SourceArchive.py +++ b/patchtracker/SourceArchive.py @@ -17,15 +17,11 @@ class Archive: self.distsdir = os.sep.join([dir, "dists"]) def suites(self, filter=None): - for s in os.listdir(self.distsdir): - if not filter: - yield s - else: - try: - filter.index(s) - yield s - except: - pass + slist = os.listdir(self.distsdir) + if filter: + slist = set(filter).intersection(set(slist)) + for s in sorted(slist): + yield s def components(self, suite): f = file(self.distsdir + os.sep + os.sep.join([suite, "Release"])) @@ -36,15 +32,15 @@ class Archive: def sourcepackages(self, suite, component, filter=None): sfile=os.sep.join([self.distsdir,suite,component,"/source/Sources.gz"]) k = itemgetter('Package') + fdict = {} + if filter: + for name in filter: + fdict[name] = True for ent in sorted(deb822.Sources.iter_paragraphs(GzipFile(sfile)), key=k): - if not filter: - yield SourcePackage(ent) + if filter and not fdict.has_key(ent['Package']): + continue else: - try: - filter.index(ent['Package']) - yield SourcePackage(ent) - except: - pass + yield SourcePackage(ent) def __str__(self): return "Archive rooted at "+self.root @@ -94,6 +90,5 @@ class SourcePackageIndex: self.pkgs[idx][srcpkg.name][rel] = srcpkg def indices(self): - self.pkgs.sort() - for k,v in self.pkgs.iteritems(): + for k,v in sorted(self.pkgs.iteritems()): yield (k,v) |