Merge lp:~dholbach/click-reviewers-tools/1363857 into lp:click-reviewers-tools

Proposed by Daniel Holbach
Status: Merged
Merged at revision: 235
Proposed branch: lp:~dholbach/click-reviewers-tools/1363857
Merge into: lp:click-reviewers-tools
Prerequisite: lp:~dholbach/click-reviewers-tools/click-review-refactor
Diff against target: 103 lines (+36/-11)
2 files modified
bin/click-review (+35/-11)
debian/changelog (+1/-0)
To merge this branch: bzr merge lp:~dholbach/click-reviewers-tools/1363857
Reviewer Review Type Date Requested Status
Benjamin Zeller (community) Approve
Martin Albisetti (community) Approve
Review via email: mp+232864@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) :
review: Approve
236. By Daniel Holbach

merge lp:~dholbach/click-reviewers-tools/click-review-refactor again

237. By Daniel Holbach

indicate which section is being printed out

238. By Daniel Holbach

simplify --sdk output format, fix pep8 issues

239. By Daniel Holbach

fix typo in comment

Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

OK!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/click-review'
2--- bin/click-review 2014-09-01 14:52:40 +0000
3+++ bin/click-review 2014-09-01 14:52:40 +0000
4@@ -35,7 +35,7 @@
5 self.click_fn = self.args.filename
6 self.cr_modules = modules.get_modules()
7
8- def _analyse_results(self):
9+ def _sumarise_results(self):
10 for module in self.results:
11 for key in self.results[module]['error']:
12 self.errors[key] = self.results[module]['error'][key]
13@@ -45,10 +45,13 @@
14 for key in self.results[module]['info']:
15 self.info[key] = self.results[module]['info'][key]
16
17- def _report(self):
18- self._analyse_results()
19+ def _complete_report(self):
20+ self._sumarise_results()
21
22- if not self.args.json:
23+ if self.args.json:
24+ print(json.dumps(self.results, sort_keys=True, indent=2,
25+ separators=(',', ': ')))
26+ else:
27 print_findings(self.errors, 'Errors')
28 print_findings(self.warnings, 'Warnings')
29 if self.args.verbose:
30@@ -57,12 +60,23 @@
31 print('%s: FAIL' % self.args.filename)
32 else:
33 print('%s: pass' % self.args.filename)
34- else:
35- print(json.dumps(self.results, sort_keys=True, indent=2,
36- separators=(',', ': ')))
37 if self.warnings or self.errors:
38 self.rc = 1
39
40+ def _report_module(self, section):
41+ '''
42+ This is currently only used in the --sdk option.
43+ It will print the output for each section when it's
44+ available. This will prevent the SDK from having to wait
45+ until all checks have been run.
46+ '''
47+ output = self.results[section]
48+ print('= %s =' % section)
49+ print(json.dumps(output, sort_keys=True, indent=2,
50+ separators=(',', ': ')))
51+ if output['error'] or output['warn']:
52+ self.rc = 1
53+
54 def _run_module_checks(self, module):
55 # What we are doing here is basically what all the
56 # ./bin/click-check-* scripts do as well, so for
57@@ -72,14 +86,21 @@
58 # review.do_checks()
59 # rc = review.do_report()
60 #
61+ section = module.replace('cr_', '')
62 review = modules.init_main_class(module, self.click_fn)
63 review.do_checks()
64- self.results[module.replace('cr_', '')] = review.click_report
65+ self.results[section] = review.click_report
66+ return section
67
68 def run_all_checks(self):
69- for module in self.cr_modules:
70- self._run_module_checks(module)
71- self._report()
72+ if self.args.sdk:
73+ for module in self.cr_modules:
74+ section = self._run_module_checks(module)
75+ self._report_module(section)
76+ else:
77+ for module in self.cr_modules:
78+ self._run_module_checks(module)
79+ self._complete_report()
80
81
82 def main():
83@@ -91,6 +112,9 @@
84 action='store_true')
85 parser.add_argument('--json', help='print json output',
86 action='store_true')
87+ parser.add_argument('--sdk',
88+ help='use output format suitable for the Ubuntu SDK',
89+ action='store_true')
90 args = parser.parse_args()
91
92 if not os.path.exists(args.filename):
93
94=== modified file 'debian/changelog'
95--- debian/changelog 2014-09-01 14:52:40 +0000
96+++ debian/changelog 2014-09-01 14:52:40 +0000
97@@ -3,6 +3,7 @@
98 * Split out code to find Click*Review classes in the clickreviews package
99 into its own module, add tests for it.
100 * Refactor bin/click-review to make it easier to extend.
101+ * Add --sdk option, so the SDK can start using it. (LP: #1363857)
102
103 -- Daniel Holbach <daniel.holbach@ubuntu.com> Wed, 27 Aug 2014 16:22:03 +0200
104

Subscribers

People subscribed via source and target branches