diff options
author | 2011-10-22 10:17:12 +0200 | |
---|---|---|
committer | 2011-10-22 10:17:12 +0200 | |
commit | ec0907549e7827f7b32988dff21eaee40b7e45ab (patch) | |
tree | 472c62cb664aa25f2efc86eabc71a8a36863d16b | |
parent | Fix bugs: (diff) | |
download | arch-tools-ec0907549e7827f7b32988dff21eaee40b7e45ab.tar.gz arch-tools-ec0907549e7827f7b32988dff21eaee40b7e45ab.tar.bz2 arch-tools-ec0907549e7827f7b32988dff21eaee40b7e45ab.zip |
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
-rwxr-xr-x | 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 CPV_REGEX = re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0-9]+)*[a-z0-9_]*(?:-r[0-9]+)?") +# Snippet from http://bugs.python.org/issue9584 +def expand_braces(orig): + r = r'.*(\{.+?[^\\]\})' + p = re.compile(r) + + s = orig[:] + res = list() + + m = p.search(s) + if m is not None: + sub = m.group(1) + open_brace = s.find(sub) + close_brace = 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) == 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.summary()))): + 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 = list(set(self.__cpvs)) self.__cpvs_detected = True def id_number(self): @@ -89,10 +116,10 @@ class BugQueue: def generate_stabilization_list(self): result = [] 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("=" + cpv) - return "\n".join(result) + result.append("=" + cpv + "\n") + return ''.join(result) # Main class (called with curses.wrapper later). class MainWindow: @@ -273,6 +300,7 @@ if __name__ == "__main__": parser.add_option("-o", "--output", dest="output_filename", default="package.keywords", help="Output filename for generated package.keywords file [default=%default]") parser.add_option("--repo", dest="repo", help="Path to portage CVS repository") parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help="Include more output, e.g. related bugs") + parser.add_option("--security", dest="security", action="store_true", default=False, help="Restrict search to security bugs.") (options, args) = parser.parse_args() if not options.arch: @@ -285,7 +313,14 @@ if __name__ == "__main__": bugzilla = bugz.bugzilla.Bugz('http://bugs.gentoo.org', skip_auth=True) print "Searching for arch bugs..." - raw_bugs = bugzilla.search("", cc="%s@gentoo.org" % options.arch, keywords="STABLEREQ", status=None) + criteria = { + 'cc': '%s@gentoo.org' % options.arch, + 'keywords': 'STABLEREQ', + 'status': None + } + if options.security: + criteria['assigned_to'] = 'security@gentoo.org' + raw_bugs = bugzilla.search("", **criteria) bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")] if not bugs: |