control: tags -1 patch

This also fixes #876373

Other related bugs: #502860, #599290, #882130
>From 4612729648fd17955e80a250baca120ce9747251 Mon Sep 17 00:00:00 2001
From: Nis Martensen <nis.marten...@web.de>
Date: Mon, 4 Dec 2017 13:39:38 +0100
Subject: [PATCH] Look up short package descriptions using python3-apt

---
 debian/control     | 2 +-
 reportbug/utils.py | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/debian/control b/debian/control
index 9afcc7d..144dcfa 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Homepage: http://alioth.debian.org/projects/reportbug/
 
 Package: reportbug
 Architecture: all
-Depends: ${misc:Depends}, ${python3:Depends}, apt, python3-reportbug (= ${source:Version})
+Depends: ${misc:Depends}, ${python3:Depends}, apt, python3-reportbug (= ${source:Version}), python3-apt
 Suggests: postfix | exim4 | mail-transport-agent, gnupg | pgp, debconf-utils (>> 1.1.0), debsums (>= 2.0.47), file (>> 1.30), dlocate, python3-urwid, python3-gi, python3-gi-cairo, gir1.2-gtk-3.0, gir1.2-vte-2.91, python3-gtkspellcheck, xdg-utils, emacs24-bin-common | emacs25-bin-common, claws-mail (>= 3.8.0)
 Description: reports bugs in the Debian distribution
  reportbug is a tool designed to make the reporting of bugs in Debian
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 8139668..c9eb73a 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -24,6 +24,7 @@ import sys
 import os
 import re
 import platform
+import apt
 
 try:
     import pwd
@@ -550,6 +551,8 @@ def get_source_package(package):
     retlist = []
     found = {}
 
+    apt_cache = apt.Cache()
+
     data = get_command_output('apt-cache showsrc ' + pipes.quote(package))
     binre = re.compile(r'^Binary: (.*)$')
     for line in data.split('\n'):
@@ -560,7 +563,10 @@ def get_source_package(package):
             packages += packlist
 
     for p in packages:
-        desc = available_package_description(p)
+        try:
+            desc = apt_cache[p].versions[0].summary
+        except KeyError:
+            continue
         if desc and (p not in found):
             retlist += [(p, desc)]
             found[p] = desc
-- 
2.11.0

_______________________________________________
Reportbug-maint mailing list
Reportbug-maint@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reportbug-maint

Reply via email to