[Reportbug-commits] [reportbug] 10/11: support LANG declined Description-xx field in package information; thanks to Robert Luberda for the report; Closes: #683116
Sandro Tosi
morph at moszumanska.debian.org
Wed Apr 15 18:08:51 UTC 2015
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository reportbug.
commit 435307f1fcffd0f431abd33aae99a45abdf085b8
Author: Sandro Tosi <morph at debian.org>
Date: Tue Apr 14 00:42:06 2015 +0100
support LANG declined Description-xx field in package information; thanks to Robert Luberda for the report; Closes: #683116
---
debian/changelog | 5 ++++-
reportbug/utils.py | 6 +++---
test/test_utils.py | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8ee1c6a..9f6d2c0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -21,8 +21,11 @@ reportbug (6.6.4) UNRELEASED; urgency=medium
* bin/reportbug, reportbug/ui/urwid_ui.py
- make the Cancel button in Urwid interface works for tags and severity
lists; thanks to Ryan Kavanagh for report and patch; Closes: #702521
+ * reportbug/utils.py
+ - support LANG declined Description-xx field in package information; thanks
+ to Robert Luberda for the report; Closes: #683116
- -- Sandro Tosi <morph at debian.org> Mon, 13 Apr 2015 15:46:52 +0100
+ -- Sandro Tosi <morph at debian.org> Mon, 13 Apr 2015 21:28:49 +0100
reportbug (6.6.3) unstable; urgency=medium
diff --git a/reportbug/utils.py b/reportbug/utils.py
index fd93aef..fede038 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -319,7 +319,7 @@ def get_package_status(package, avail=False):
statusre = re.compile('Status: ')
originre = re.compile('Origin: ')
bugsre = re.compile('Bugs: ')
- descre = re.compile('Description: ')
+ descre = re.compile('Description(?:-.*)?: ')
fullre = re.compile(' ')
srcre = re.compile('Source: ')
sectionre = re.compile('Section: ')
@@ -499,7 +499,7 @@ def get_avail_database():
def available_package_description(package):
data = commands.getoutput('apt-cache show'+commands.mkarg(package))
data = data.decode('utf-8', 'replace')
- descre = re.compile(r'^Description(?:-en): (.*)$')
+ descre = re.compile('^Description(?:-.*)?: (.*)$')
for line in data.split('\n'):
m = descre.match(line)
if m:
@@ -572,7 +572,7 @@ def get_package_info(packages, skip_notfound=False):
packob = re.compile('^Package: (?P<pkg>.*)$', re.MULTILINE)
statob = re.compile('^Status: (?P<stat>.*)$', re.MULTILINE)
versob = re.compile('^Version: (?P<vers>.*)$', re.MULTILINE)
- descob = re.compile('^Description: (?P<desc>.*)$', re.MULTILINE)
+ descob = re.compile('^Description(?:-.*)?: (?P<desc>.*)$', re.MULTILINE)
ret = []
for p in packinfo:
diff --git a/test/test_utils.py b/test/test_utils.py
index b16d497..443d5aa 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -207,6 +207,46 @@ class TestPackages(unittest2.TestCase):
#self.assertEqual(result[0][0], pkg)
+ def test_bts683116(self):
+ """Check Description and Description-LANG are recognized"""
+
+ pkginfo = """Package: reportbug
+Status: install ok installed
+Version: 6.6.3
+%s: reports bugs in the Debian distribution
+ """
+ pkg = 'reportbug'
+
+ __save = commands.getoutput
+ commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
+ result = utils.available_package_description(pkg)
+ self.assertEqual(u'reports bugs in the Debian distribution', result)
+ commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
+ result = utils.available_package_description(pkg)
+ self.assertEqual(u'reports bugs in the Debian distribution', result)
+ commands.getoutput = __save
+ del __save
+
+ __save = commands.getoutput
+ commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
+ result = utils.get_package_status(pkg)
+ self.assertEqual(u'reports bugs in the Debian distribution', result[11])
+ commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
+ result = utils.get_package_status(pkg)
+ self.assertEqual(u'reports bugs in the Debian distribution', result[11])
+ commands.getoutput = __save
+ del __save
+
+ __save = utils.get_dpkg_database
+ utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description',])
+ result = utils.get_package_info([((pkg,), pkg)])
+ self.assertEqual(u'reports bugs in the Debian distribution', result[0][3])
+ utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description-en',])
+ result = utils.get_package_info([((pkg,), pkg)])
+ self.assertEqual(u'reports bugs in the Debian distribution', result[0][3])
+ utils.get_dpkg_database = __save
+ del __save
+
def test_packages_providing(self):
pkg = 'editor'
result = utils.packages_providing(pkg)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git
More information about the Reportbug-commits
mailing list