From f0d7e799d1b28c833090ad497870ebaa706dba80 Mon Sep 17 00:00:00 2001 From: tsimpson Date: Tue, 10 Apr 2012 14:05:29 +0100 Subject: [PATCH] Merge ubottu Bugtracker with bzr. Treat the Architecture key from apt-cache as a list, rather than a single string. --- Bugtracker/plugin.py | 18 ++++++++++++++++-- PackageInfo/packages.py | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Bugtracker/plugin.py b/Bugtracker/plugin.py index 0254f54..500172a 100644 --- a/Bugtracker/plugin.py +++ b/Bugtracker/plugin.py @@ -772,8 +772,22 @@ class Launchpad(IBugtracker): if tasks.total_size != 1: tasks = list(tasks) - tasks.sort(self._sort) - taskdata = tasks[-1] + try: + tasks.sort(self._sort) + taskdata = tasks[-1] + except ValueError: + tasks = [_ for _ in tasks if _.bug_target_name.endswith(u'(Ubuntu)')] + if tasks: + if len(tasks) != 1: + try: + tasks.sort(self._sort) + taskdata = tasks[-1] + except ValueError: + taskdata = bugdata.bug_tasks[bugdata.bug_tasks.total_size - 1] + else: + taskdata = tasks[-1] + else: + taskdata = tasks[-1] else: taskdata = tasks[0] diff --git a/PackageInfo/packages.py b/PackageInfo/packages.py index e54bbb4..5401d15 100644 --- a/PackageInfo/packages.py +++ b/PackageInfo/packages.py @@ -45,7 +45,8 @@ class Apt: self.aptfilecommand = """apt-file -s %s/%%s.list -c %s/apt-file/%%s -l search %%s""" % (self.aptdir, self.aptdir) def find(self, pkg, chkdistro, filelookup=True): - _pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-_+']) + _pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-_+/']) + distro = '' if len(pkg.strip().split()) > 1: distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '.-_+']) if not distro: @@ -129,8 +130,17 @@ class Apt: del parser archs = '' if maxp2.has_key('Architecture'): - if maxp2['Architecture'] not in ('all','any'): - archs = ' (Only available for %s)' % maxp2['Architecture'] + archs = [_.strip() for _ in maxp2['Architecture'].split() if _.strip()] + for arch in archs: + if arch not in ('any', 'all'): + continue + else: + archs = '' + break + + if archs: + archs = ' (Only available for %s)' % '; '.join(archs) + maxp["Distrobution"] = distro return("%s (source: %s): %s. In component %s, is %s. Version %s (%s), package size %s kB, installed size %s kB%s" % (maxp['Package'], maxp['Source'] or maxp['Package'], maxp['Description'].split('\n')[0], component(maxp['Section']),