Merge lp:~abentley/lp-release-manager-tools/extract-pull-bugs into lp:~sinzui/lp-release-manager-tools/trunk

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 30
Proposed branch: lp:~abentley/lp-release-manager-tools/extract-pull-bugs
Merge into: lp:~sinzui/lp-release-manager-tools/trunk
Diff against target: 73 lines (+25/-10)
2 files modified
lp_release_tools/pull_bugs.py (+21/-9)
lp_release_tools/report_bugs.py (+4/-1)
To merge this branch: bzr merge lp:~abentley/lp-release-manager-tools/extract-pull-bugs
Reviewer Review Type Date Requested Status
Curtis Hovey code Approve
Review via email: mp+223466@code.launchpad.net

Commit message

Extract pull_bugs and get_bug_records.

Description of the change

This branch extracts pull_bugs, transform_bugs and get_bug_records, so that bugs can be stored and retrieved in alternative ways (i.e. mongodb).

pull_bugs becomes a method that updates bugs, accept and outputing JSON.

transform_bugs is used before supplying data to pull_bugs.

get_bug_records is used to transform bugs into records, so that report_bugs does not require file access.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lp_release_tools/pull_bugs.py'
2--- lp_release_tools/pull_bugs.py 2014-05-15 20:03:33 +0000
3+++ lp_release_tools/pull_bugs.py 2014-06-17 18:32:39 +0000
4@@ -45,8 +45,11 @@
5 with open(options.union_file, 'r') as in_file:
6 previous_json = in_file.read()
7 previous_data = json.loads(previous_json)
8- previous_bugs = dict([(b['bug_id'], b) for b in previous_data['bugs']])
9- return previous_bugs
10+ return transform_bug_data(previous_data)
11+
12+
13+def transform_bug_data(previous_data):
14+ return dict([(b['bug_id'], b) for b in previous_data['bugs']])
15
16
17 def get_bug_data(target, all_bugs, search_params, private=False):
18@@ -139,13 +142,24 @@
19 'milestone-report',
20 service_root='https://api.launchpad.net',
21 version='devel', credentials_file=options.credentials)
22+ json_source = pull_bugs(
23+ project, lp, all_bugs, status=options.statuses,
24+ modified_since=options.since, importance=options.importance,
25+ milestone=options.milestone, tags=options.tags,
26+ private=options.private)
27+ json_data = json.dumps(json_source, indent=0)
28+ with open(options.outfile, 'w') as json_file:
29+ json_file.write(json_data)
30+
31+
32+def pull_bugs(project, lp, all_bugs, status, modified_since, importance,
33+ milestone, tags, private):
34 targets = get_targets(lp, project)
35 search_params = dict(
36- status=options.statuses, modified_since=options.since,
37- importance=options.importance, milestone=options.milestone,
38- tags=options.tags, tags_combinator='All')
39+ status=status, modified_since=modified_since, importance=importance,
40+ milestone=milestone, tags=tags, tags_combinator='All')
41 for target in targets:
42- count = get_bug_data(target, all_bugs, search_params, options.private)
43+ count = get_bug_data(target, all_bugs, search_params, private)
44 print(count)
45 print(len(all_bugs))
46 now = datetime.utcnow()
47@@ -153,9 +167,7 @@
48 u'date_retrieved': now.isoformat(' '),
49 u'bugs': all_bugs.values(),
50 }
51- json_data = json.dumps(json_source, indent=0)
52- with open(options.outfile, 'w') as json_file:
53- json_file.write(json_data)
54+ return json_source
55
56
57 if __name__ == '__main__':
58
59=== modified file 'lp_release_tools/report_bugs.py'
60--- lp_release_tools/report_bugs.py 2014-06-17 16:29:18 +0000
61+++ lp_release_tools/report_bugs.py 2014-06-17 18:32:39 +0000
62@@ -111,7 +111,10 @@
63 def get_bugs(json_file):
64 with open(json_file, 'r') as in_file:
65 bug_json = in_file.read()
66- bug_data = json.loads(bug_json)
67+ return get_bug_records(json.loads(bug_json))
68+
69+
70+def get_bug_records(bug_data):
71 bugs = []
72 for bug in bug_data['bugs']:
73 for field in bug:

Subscribers

People subscribed via source and target branches

to all changes: