3
# Copyright (C) 2012, Canonical Ltd.
4
# Written by Brian Murray
6
# ##################################################################
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU General Public License
10
# as published by the Free Software Foundation; version 3.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# See file /usr/share/common-licenses/GPL-3 for more details.
19
# ##################################################################
21
from lptools import config
22
from datetime import datetime
29
def check_duplicate(bug, prop, key):
30
if prop == 'reporter':
33
return datetime.strftime(bug.date_created, '%Y-%m')
35
return datetime.strftime(bug.date_created, '%Y-%m-%d')
37
return ' '.join(bug.tags)
39
rtags = set(release_tags).intersection(bug.tags)
40
return ' '.join(list(rtags))
42
APPORT_TAGS = ['apport-crash', 'apport-bug', 'apport-kerneloops', 'apport-package']
43
if not set(APPORT_TAGS).intersection(bug.tags):
45
description = bug.description
46
if key not in description:
48
for line in description.splitlines():
49
if not line.startswith(key):
51
if key == line.split(': ')[0]:
52
value = line.split(': ')[-1]
57
parser = argparse.ArgumentParser(prog='lp-bug-dupe-properties')
58
group = parser.add_mutually_exclusive_group()
59
group.add_argument('-r', '--reporter', default=False,
60
action='store_true', help='Display reporter of duplicates')
61
group.add_argument('-m', '--month', default=False,
62
action='store_true', help='Display month duplicates were reported')
63
group.add_argument('-d', '--day', default=False,
64
action='store_true', help='Display day duplicates were reported')
65
group.add_argument('-t', '--tags', default=False,
66
action='store_true', help='Display tags of duplicates')
67
group.add_argument('-rt', '--rtags', default=False,
68
action='store_true', help='Display Ubuntu release tags of duplicates')
69
group.add_argument('-D', '--desc', default=False, type=str,
70
help='Search apport bug description for this key e.g. Package')
71
parser.add_argument('-b', '--bug', type=int,
72
help='Bug number of which to check the duplicates')
74
opts = parser.parse_args()
75
launchpad = config.get_launchpad("bug-dupe-properties")
78
bug = launchpad.bugs[bug_number]
92
ubuntu = launchpad.distributions['ubuntu']
93
for series in ubuntu.series:
94
release_tags.append(series.name)
101
if bug.number_of_duplicates == 0:
102
print(('LP: #%s has no duplicates!' % bug_number))
105
for dupe in bug.duplicates:
107
prop = check_duplicate(dupe, search, key)
108
if prop in list(dupe_props.keys()):
109
dupe_props[prop].append(str(dupe_num))
111
dupe_props[prop] = [str(dupe_num)]
113
dupe_count = bug.number_of_duplicates
115
print(('LP: #%s has %s duplicates' % (bug_number, dupe_count)))
116
elif dupe_count == 1:
117
print(('LP: #%s has %s duplicate' % (bug_number, dupe_count)))
119
for prop, bugs in sorted(dupe_props.items()):
120
print((' %s: %s' % (prop, ' '.join(bugs))))
123
if __name__ == '__main__':