summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Hajdan, Jr <phajdan.jr@gentoo.org>2012-01-27 15:54:19 +0100
committerPawel Hajdan, Jr <phajdan.jr@gentoo.org>2012-01-27 15:54:19 +0100
commit8aff939c6831ac73eb6a6a4a07a6c475e15ed308 (patch)
treedb5239f2b4388bbb63bc40e382af68e909089a64 /bugzilla-viewer.py
parentFix bugs related to empty lines handling. (diff)
downloadarch-tools-8aff939c6831ac73eb6a6a4a07a6c475e15ed308.tar.gz
arch-tools-8aff939c6831ac73eb6a6a4a07a6c475e15ed308.tar.bz2
arch-tools-8aff939c6831ac73eb6a6a4a07a6c475e15ed308.zip
Begin work on maintainer-timeout script.
Extract common parts to common.py Fix bug where only first 100 bug details were retrieved from Bugzilla.
Diffstat (limited to 'bugzilla-viewer.py')
-rwxr-xr-xbugzilla-viewer.py77
1 files changed, 4 insertions, 73 deletions
diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index e3cbcac..8a1e131 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -15,32 +15,7 @@ import xml.etree
import bugz.bugzilla
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))
+from common import Bug, chunks
def unicode_sanitize(text):
"""Converts a possibly unicode text to a regular string."""
@@ -53,52 +28,6 @@ def unicode_sanitize(text):
class TermTooSmall(Exception):
pass
-class Bug:
- def __init__(self, xml=None, id_number=None, summary=None, status=None):
- if xml is not None:
- self.__id = int(xml.find("bug_id").text)
- self.__summary = xml.find("short_desc").text
- self.__status = xml.find("bug_status").text
- self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
- self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
- if id_number is not None:
- self.__id = id_number
- if summary is not None:
- self.__summary = summary
- if status is not None:
- self.__status = status
- self.__cpvs_detected = False
- self.__cpvs = []
-
- def detect_cpvs(self):
- if self.__cpvs_detected:
- return
- 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):
- return self.__id
-
- def summary(self):
- return self.__summary
-
- def status(self):
- return self.__status
-
- def depends_on(self):
- return self.__depends_on
-
- def comments(self):
- return self.__comments
-
- def cpvs(self):
- assert(self.__cpvs_detected)
- return self.__cpvs
-
class BugQueue:
def __init__(self):
self.__bug_list = []
@@ -320,8 +249,10 @@ if __name__ == "__main__":
}
if options.security:
criteria['assigned_to'] = 'security@gentoo.org'
+ bugs = []
raw_bugs = bugzilla.search("", **criteria)
- bugs = [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in raw_bugs]).findall("bug")]
+ for chunk in chunks(raw_bugs, 100):
+ bugs += [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in chunk]).findall("bug")]
if not bugs:
print 'The bug list is empty. Exiting.'