From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RHWmr-0002mk-FE for garchives@archives.gentoo.org; Sat, 22 Oct 2011 08:18:38 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 65E0E21C0AB; Sat, 22 Oct 2011 08:18:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 2883A21C0AB for ; Sat, 22 Oct 2011 08:18:30 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 829A91B4002 for ; Sat, 22 Oct 2011 08:18:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B590380042 for ; Sat, 22 Oct 2011 08:18:28 +0000 (UTC) From: "Paweł Hajdan" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" Message-ID: Subject: [gentoo-commits] proj/arch-tools:master commit in: / X-VCS-Repository: proj/arch-tools X-VCS-Files: bugzilla-viewer.py X-VCS-Directories: / X-VCS-Committer: phajdan.jr X-VCS-Committer-Name: Paweł Hajdan X-VCS-Revision: ec0907549e7827f7b32988dff21eaee40b7e45ab Date: Sat, 22 Oct 2011 08:18:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 0904c22b45cee0834543e9073216a5aa commit: ec0907549e7827f7b32988dff21eaee40b7e45ab Author: Pawel Hajdan, Jr gentoo org> AuthorDate: Sat Oct 22 08:17:12 2011 +0000 Commit: Pawe=C5=82 Hajdan gentoo org> CommitDate: Sat Oct 22 08:17:12 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/arch-tools.gi= t;a=3Dcommit;h=3Dec090754 Improvements for the bugzilla viewer: - do brace expansion on the bug summary - make sure every entry for package.keywords ends with a newline - add an option to query only for security bugs --- bugzilla-viewer.py | 49 ++++++++++++++++++++++++++++++++++++++++++----= --- 1 files changed, 42 insertions(+), 7 deletions(-) diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py index c45530a..48b253e 100755 --- a/bugzilla-viewer.py +++ b/bugzilla-viewer.py @@ -17,6 +17,31 @@ import portage.versions =20 CPV_REGEX =3D re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0= -9]+)*[a-z0-9_]*(?:-r[0-9]+)?") =20 +# Snippet from http://bugs.python.org/issue9584 +def expand_braces(orig): + r =3D r'.*(\{.+?[^\\]\})' + p =3D re.compile(r) + + s =3D orig[:] + res =3D list() + + m =3D p.search(s) + if m is not None: + sub =3D m.group(1) + open_brace =3D s.find(sub) + close_brace =3D open_brace + len(sub) - 1 + if ',' in sub: + for pat in sub.strip('{}').split(','): + res.extend(expand_braces(s[:open_brace] + pat + s[close_brace+1:])) + + else: + res.extend(expand_braces(s[:open_brace] + sub.replace('}', '\\}') + s= [close_brace+1:])) + + else: + res.append(s.replace('\\}', '}')) + + return list(set(res)) + def unicode_sanitize(text): """Converts a possibly unicode text to a regular string.""" if type(text) =3D=3D unicode: @@ -48,9 +73,11 @@ class Bug: def detect_cpvs(self): if self.__cpvs_detected: return - for cpv_candidate in CPV_REGEX.findall(self.summary()): - if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate): - self.__cpvs.append(cpv_candidate) + for cpv_string in list(set([self.summary()] + expand_braces(self.summa= ry()))): + for cpv_candidate in CPV_REGEX.findall(cpv_string): + if portage.db["/"]["porttree"].dbapi.cpv_exists(cpv_candidate): + self.__cpvs.append(cpv_candidate) + self.__cpvs =3D list(set(self.__cpvs)) self.__cpvs_detected =3D True =09 def id_number(self): @@ -89,10 +116,10 @@ class BugQueue: def generate_stabilization_list(self): result =3D [] for bug in self.__bug_list: - result.append("# Bug %d: %s" % (bug.id_number(), bug.summary())) + result.append("# Bug %d: %s\n" % (bug.id_number(), bug.summary())) for cpv in bug.cpvs(): - result.append("=3D" + cpv) - return "\n".join(result) + result.append("=3D" + cpv + "\n") + return ''.join(result) =20 # Main class (called with curses.wrapper later). class MainWindow: @@ -273,6 +300,7 @@ if __name__ =3D=3D "__main__": parser.add_option("-o", "--output", dest=3D"output_filename", default=3D= "package.keywords", help=3D"Output filename for generated package.keyword= s file [default=3D%default]") parser.add_option("--repo", dest=3D"repo", help=3D"Path to portage CVS = repository") parser.add_option("-v", "--verbose", dest=3D"verbose", action=3D"store_= true", default=3DFalse, help=3D"Include more output, e.g. related bugs") + parser.add_option("--security", dest=3D"security", action=3D"store_true= ", default=3DFalse, help=3D"Restrict search to security bugs.") =20 (options, args) =3D parser.parse_args() if not options.arch: @@ -285,7 +313,14 @@ if __name__ =3D=3D "__main__": bugzilla =3D bugz.bugzilla.Bugz('http://bugs.gentoo.org', skip_auth=3DT= rue) =20 print "Searching for arch bugs..." - raw_bugs =3D bugzilla.search("", cc=3D"%s@gentoo.org" % options.arch, k= eywords=3D"STABLEREQ", status=3DNone) + criteria =3D { + 'cc': '%s@gentoo.org' % options.arch, + 'keywords': 'STABLEREQ', + 'status': None + } + if options.security: + criteria['assigned_to'] =3D 'security@gentoo.org' + raw_bugs =3D bugzilla.search("", **criteria) bugs =3D [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw= _bugs]).findall("bug")] =20 if not bugs: