Package: reportbug Version: 4.5 Severity: normal Tags: patch Hi,
This patch allows --mbox to fetch bugs given the package name. You also can provide several package names, or you can mix bug numbers and package names, e.g : $ querybts -m checkgmail > mbox $ querybts -m checkgmail 222621 > mbox $ querybts -m checkgmail pydance > mbox Bye, Carl Chenet -- Package-specific info: ** Environment settings: DEBEMAIL="cha...@ohmytux.com" DEBFULLNAME="Carl Chenet" INTERFACE="text" ** /home/chaica/.reportbugrc: reportbug_version "4.5" mode novice ui text smtphost "smtp.free.fr" -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages reportbug depends on: ii apt 0.7.21 Advanced front-end for dpkg ii python 2.5.4-2 An interactive high-level object-o ii python-reportbug 4.5 Python modules for interacting wit reportbug recommends no packages. Versions of packages reportbug suggests: pn debconf-utils <none> (no description available) ii debsums 2.0.44 verification of installed package pn dlocate <none> (no description available) ii exim4 4.69-9 metapackage to ease Exim MTA (v4) ii exim4-daemon-light [mail-tran 4.69-9 lightweight Exim MTA (v4) daemon ii file 5.00-1 Determines file type using "magic" ii gnupg 1.4.9-4 GNU privacy guard - a free PGP rep pn python-gnome2-extras <none> (no description available) pn python-gtk2 <none> (no description available) pn python-urwid <none> (no description available) pn python-vte <none> (no description available) -- no debconf information
>From 98f8b564aeeb30455c0618dfde99aadfc0f43fe4 Mon Sep 17 00:00:00 2001 From: chaica <cha...@ohmytux.com> Date: Sat, 25 Jul 2009 16:18:14 +0200 Subject: [PATCH] --mbox manages package names --- bin/querybts | 44 ++++++++++++++++++++++++++++---------------- man/querybts.1 | 4 ++-- reportbug/ui/text_ui.py | 11 ++++++++++- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/bin/querybts b/bin/querybts index 5f66f21..c259d9b 100755 --- a/bin/querybts +++ b/bin/querybts @@ -152,22 +152,6 @@ def main(): urlutils.launch_browser(url) return - if mbox: - for bugnum in args: - m = re.match('^#?(\d+)$', bugnum) - if not m: - print >> sys.stderr, "You must specify a bug number when using the --mbox option." - sys.exit(1) - num = int(m.group(1)) - url = debianbts.get_report_url(system, num, archived, mbox=True) - try: - report = urlutils.open_url(url) - sys.stdout.write(report.read()) - except urlutils.urllib2.URLError, ex: - print >> sys.stderr, "Error while accessing mbox report (%s)." % ex - sys.exit(1) - return - if interface: global ui, ui_mode iface = '%(interface)s_ui' % vars() @@ -182,6 +166,34 @@ def main(): print ui.initialize () + if mbox: + for bugnum in args: + package = bugnum + m = re.match('^#?(\d+)$', bugnum) + if not m: + mboxbuglist = [] + mboxbuglist = ui.handle_bts_query(package, system, mirrors, http_proxy, + queryonly=True, title=VERSION, archived=archived, + source=source, mbox=mbox) + for num in mboxbuglist: + url = debianbts.get_report_url(system, num, archived, mbox=True) + try: + report = urlutils.open_url(url) + sys.stdout.write(report.read()) + except urlutils.urllib2.URLError, ex: + print >> sys.stderr, "Error while accessing mbox report (%s)." % ex + else: + num = int(m.group(1)) + url = debianbts.get_report_url(system, num, archived, mbox=True) + try: + report = urlutils.open_url(url) + sys.stdout.write(report.read()) + except urlutils.urllib2.URLError, ex: + print >> sys.stderr, "Error while accessing mbox report (%s)." % ex + sys.exit(1) + return + + reportre = re.compile(r'^#?(\d+)$') try: if len(args) > 1: diff --git a/man/querybts.1 b/man/querybts.1 index 708b57b..da04268 100644 --- a/man/querybts.1 +++ b/man/querybts.1 @@ -37,8 +37,8 @@ You can specify to get a list of supported servers. .TP .B \-m, \-\-mbox -Retrieve the given bug number as a mailbox file, instead of viewing -it. It will be dumped to standard output. +Retrieve the given bug number(s) or package name(s) as a mailbox file, instead of viewing +it. It will be dumped to standard output. .TP .B \-\-proxy=PROXY, \-\-http_proxy=PROXY Specify the WWW proxy server to use to handle the query of the bug diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py index e6f7360..967385b 100644 --- a/reportbug/ui/text_ui.py +++ b/reportbug/ui/text_ui.py @@ -462,7 +462,7 @@ def show_report(number, system, mirrors, def handle_bts_query(package, bts, mirrors=None, http_proxy="", queryonly=False, title="", screen=None, archived='no', - source=False, version=None): + source=False, version=None, mbox=False): root = debianbts.SYSTEMS[bts].get('btsroot') if not root: ewrite('%s bug tracking system has no web URL; bypassing query\n', @@ -503,6 +503,15 @@ def handle_bts_query(package, bts, mirrors=None, http_proxy="", bug_re = re.compile(r'#(\d+) \[[^]]+\] \[[^]]+\] (.*) Reported by.*') hierarchy_new = [] + if mbox: + mboxbuglist = [] + for entry in hierarchy: + for bug in entry[1]: + match = bug_re.match(bug) + if match: + mboxbuglist.append(int(match.group(1))) + return mboxbuglist + for entry in hierarchy: # first item is the title of the section entry_new = entry[0] -- 1.6.2.3