5
from lptools import config
11
sys.stderr.write('getting project... ')
12
project = launchpad.projects[project_name]
13
sys.stderr.write('%s (%s)\n' % (project.name, project.title))
17
class BugCategory(object):
18
"""Holds a set of logically-related bugs"""
29
def get_link_url(self):
33
class HasPatchBugCategory(BugCategory):
38
def get_link_url(self):
39
return 'https://bugs.edge.launchpad.net/%s/+bugs' \
40
'?search=Search&field.has_patch=on' \
44
class StatusBugCategory(BugCategory):
46
def __init__(self, status):
47
BugCategory.__init__(self)
53
def get_link_url(self):
54
return 'https://bugs.edge.launchpad.net/%s/+bugs?search=Search&field.status=%s' \
55
% (project_name, self.status)
58
class CannedQuery(object):
60
def __init__(self, project):
61
self.project = project
63
def _run_query(self, from_collection):
64
sys.stderr.write(self.get_name())
65
for bt in from_collection:
68
sys.stderr.write('\n')
71
# print self.get_name()
72
for category in self.query_categories():
73
print('%6d %s %s' % (category.count_bugs(),
75
category.get_link_url() or ''))
79
class PatchCannedQuery(CannedQuery):
81
def get_collection(self):
82
return self.project.searchTasks(has_patch=True)
85
return 'Bugs with patches'
87
def query_categories(self):
88
has_patches = HasPatchBugCategory()
89
for bt in self._run_query(
90
self.project.searchTasks(has_patch=True)):
95
class StatusCannedQuery(CannedQuery):
100
def query_categories(self):
102
for bugtask in self._run_query(self.project.searchTasks()):
103
if bugtask.status not in by_status:
104
by_status[bugtask.status] = StatusBugCategory(bugtask.status)
105
by_status[bugtask.status].add(bugtask)
106
return list(by_status.values())
109
def show_bug_report(project):
110
for query_class in StatusCannedQuery, PatchCannedQuery:
111
query_class(project).show_text()
114
launchpad = config.get_launchpad("capture-bug-counts")
115
project = get_project()
116
show_bug_report(project)