Merge lp:~canonical-platform-qa/qakit/flake8-fixes into lp:~thomir/qakit/trunk

Proposed by Federico Gimenez on 2015-04-17
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/qakit/flake8-fixes
Merge into: lp:~thomir/qakit/trunk
Diff against target: 428 lines (+65/-68)
11 files modified
qakit/__init__.py (+2/-2)
qakit/commands.py (+8/-7)
qakit/config.py (+2/-2)
qakit/format.py (+18/-12)
qakit/lkkb.py (+11/-9)
qakit/tests/__init__.py (+2/-3)
qakit/tests/test_config.py (+2/-4)
qakit/tests/test_format.py (+5/-6)
qakit/tests/test_trello.py (+3/-6)
qakit/trello.py (+7/-12)
setup.py (+5/-5)
To merge this branch: bzr merge lp:~canonical-platform-qa/qakit/flake8-fixes
Reviewer Review Type Date Requested Status
Vincent Ladeuil (community) Approve on 2015-04-18
Leo Arias (community) Approve on 2015-04-17
Thomi Richards 2015-04-17 Pending
Review via email: mp+256674@code.launchpad.net

This proposal has been superseded by a proposal from 2015-04-28.

Commit Message

Flake8 fixes

Description of the Change

Flake8 fixes

To post a comment you must log in.
Leo Arias (elopio) :
review: Approve
Vincent Ladeuil (vila) wrote :

@Federico: Thanks for doing this !

Let's get those flake8 issues out of the way and automated asap.

I have a few questions/comments inline but nothing blocking this MP landing.

review: Approve
Federico Gimenez (fgimenez) wrote :

Hi Vincent, about the license boilerplate this is text that we are using in other projects like ubuntu-sanity-tests, ubuntu-power-tests and ubuntu-ota-tests, for instance [1]. It comes from the FSF recommendation at [2], but seems that we are using the one-file program recommendation for multi-file programs, we should discuss adopting the right one.

Thanks,

[1] http://bazaar.launchpad.net/~canonical-platform-qa/ubuntu-sanity-tests/trunk/view/head:/ubuntu_sanity_tests/selftests/__init__.py
[2] https://www.gnu.org/licenses/gpl-howto.html

Unmerged revisions

6. By Federico Gimenez on 2015-04-17

making flake8 happy

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qakit/__init__.py'
2--- qakit/__init__.py 2014-10-08 01:30:28 +0000
3+++ qakit/__init__.py 2015-04-17 14:40:43 +0000
4@@ -12,8 +12,8 @@
5 # GNU General Public License for more details.
6 #
7 # You should have received a copy of the GNU General Public License
8-# along with this program; if not, write to the Free Software
9-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10+# along with this program. If not, see <http://www.gnu.org/licenses/>.
11+#
12
13
14 __version__ = '0.1'
15
16=== modified file 'qakit/commands.py'
17--- qakit/commands.py 2014-11-12 02:33:22 +0000
18+++ qakit/commands.py 2015-04-17 14:40:43 +0000
19@@ -12,9 +12,8 @@
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23-# along with this program; if not, write to the Free Software
24-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25-
26+# along with this program. If not, see <http://www.gnu.org/licenses/>
27+#
28
29 from argparse import ArgumentParser
30
31@@ -23,6 +22,7 @@
32 trello,
33 )
34
35+
36 def main():
37 """The main program entry point."""
38 parser = ArgumentParser(
39@@ -31,11 +31,12 @@
40 subparsers = parser.add_subparsers(help="Commands", dest="command")
41
42 subparsers.add_parser("silo-backlog", help="Show the current silo testing "
43- "backlog.")
44- subparsers.add_parser("silo-stats", help="Show statistics around completed "
45- "silo testing.")
46+ "backlog.")
47+ subparsers.add_parser("silo-stats",
48+ help="Show statistics around completed "
49+ "silo testing.")
50 subparsers.add_parser("silo-actions", help="Show statistics about overall "
51- "activity per person.")
52+ "activity per person.")
53 subparsers.add_parser("project-backlog", help="Show project backlog")
54 args = parser.parse_args()
55 if args.command == 'silo-backlog':
56
57=== modified file 'qakit/config.py'
58--- qakit/config.py 2014-10-08 01:30:28 +0000
59+++ qakit/config.py 2015-04-17 14:40:43 +0000
60@@ -12,8 +12,8 @@
61 # GNU General Public License for more details.
62 #
63 # You should have received a copy of the GNU General Public License
64-# along with this program; if not, write to the Free Software
65-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
66+# along with this program. If not, see <http://www.gnu.org/licenses/>
67+#
68
69 """Functions for configuration parsing."""
70
71
72=== modified file 'qakit/format.py'
73--- qakit/format.py 2014-10-09 00:52:51 +0000
74+++ qakit/format.py 2015-04-17 14:40:43 +0000
75@@ -12,9 +12,8 @@
76 # GNU General Public License for more details.
77 #
78 # You should have received a copy of the GNU General Public License
79-# along with this program; if not, write to the Free Software
80-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
81-
82+# along with this program. If not, see <http://www.gnu.org/licenses/>
83+#
84
85 "Format functions for output."
86 from collections import defaultdict
87@@ -37,6 +36,7 @@
88 # 'color': 'grey'
89 }
90
91+
92 def print_title(text):
93 print(termcolor.colored(text, **_title_opts))
94
95@@ -64,7 +64,7 @@
96 if a.what not in fields:
97 fields.append(a.what)
98 if a.who not in people:
99- people[a.who] = {'updateCard':0, 'commentCard':0}
100+ people[a.who] = {'updateCard': 0, 'commentCard': 0}
101 if a.what not in people[a.who]:
102 people[a.who][a.what] = 0
103 people[a.who][a.what] += 1
104@@ -75,9 +75,10 @@
105 fields.remove('commentCard')
106 fields.insert(2, 'commentCard')
107
108- foo = [(-v['updateCard'],-v['commentCard'],k,v) for k,v in people.items()]
109+ foo = [(-v['updateCard'], -v['commentCard'], k, v)
110+ for k, v in people.items()]
111 foo.sort()
112- people = [(x[-2],x[-1]) for x in foo]
113+ people = [(x[-2], x[-1]) for x in foo]
114
115 tbl = prettytable.PrettyTable(fields)
116 tbl.align["Name"] = 'l'
117@@ -108,6 +109,7 @@
118 _print_completed_table(cards, period)
119 print("")
120
121+
122 class StatisticGroup(object):
123
124 """Statistics are processed in groups.
125@@ -173,15 +175,16 @@
126 class SiloTesterStatisticGroup(StatisticGroup):
127
128 """A statistic group that keep strack of how many silos each tester has
129- completed. This group yields data points equal to the number of silo testers
130- in the cards processed.
131+ completed. This group yields data points equal to the number of silo
132+ testers in the cards processed.
133
134 """
135 _statistics = {}
136
137 def process_card(self, card, period):
138 if card.assigned_to not in self._statistics:
139- self._statistics[card.assigned_to] = TesterCountStatistic(card.assigned_to)
140+ self._statistics[card.assigned_to] = TesterCountStatistic(
141+ card.assigned_to)
142 self._statistics[card.assigned_to].process_card(card, period)
143
144 def get_rows(self, *periods):
145@@ -192,7 +195,8 @@
146
147 """
148 for s in self._statistics:
149- yield [s] + [self._statistics[s].result_for_period(p) for p in periods]
150+ yield [s] + [self._statistics[s].result_for_period(p)
151+ for p in periods]
152
153
154 class Statistic(object):
155@@ -260,7 +264,8 @@
156 percentage = ''
157 if self._data[period]['total'] > 0:
158 percentage = "(%.0f%%)" % (
159- self._data[period]['passed'] / self._data[period]['total'] * 100
160+ self._data[period]['passed'] /
161+ self._data[period]['total'] * 100
162 )
163 return "%d total, %d passed %s" % (
164 self._data[period]['total'],
165@@ -309,7 +314,8 @@
166 group.process_card(card, period)
167
168 tbl = prettytable.PrettyTable(["Category"] + period_names)
169- tbl.add_row(["Period Starting"] + [p.start.strftime("%c") for p in periods])
170+ tbl.add_row(["Period Starting"] +
171+ [p.start.strftime("%c") for p in periods])
172 for group in stat_groups:
173 for row in group.get_rows(*periods):
174 tbl.add_row(row)
175
176=== modified file 'qakit/lkkb.py'
177--- qakit/lkkb.py 2014-11-12 02:33:22 +0000
178+++ qakit/lkkb.py 2015-04-17 14:40:43 +0000
179@@ -12,16 +12,15 @@
180 # GNU General Public License for more details.
181 #
182 # You should have received a copy of the GNU General Public License
183-# along with this program; if not, write to the Free Software
184-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
185-
186-
187+# along with this program. If not, see <http://www.gnu.org/licenses/>
188+#
189+
190+from bs4 import BeautifulSoup
191 from ConfigParser import RawConfigParser
192 import os.path
193 import sys
194 import csv
195 import requests
196-from pprint import pprint
197 import bleach
198
199
200@@ -39,7 +38,8 @@
201 resp.raise_for_status()
202 data = resp.json()
203 (sorted_lane,) = [
204- l for l in data[u'ReplyData'][0][u'Backlog'] if l[u'Title'] == u'Sorted'
205+ l for l in data[u'ReplyData'][0][u'Backlog']
206+ if l[u'Title'] == u'Sorted'
207 ]
208
209 row_keys = [
210@@ -52,7 +52,7 @@
211 csv_writer = csv.writer(sys.stdout)
212 csv_writer.writerow(row_keys)
213 for card in sorted_lane['Cards']:
214- row = [ clean_text(card[k]) for k in row_keys]
215+ row = [clean_text(card[k]) for k in row_keys]
216 csv_writer.writerow(row)
217 except IOError:
218 handle_file_read_error()
219@@ -92,9 +92,11 @@
220 raise IOError("Could not read file %s" % (config_file_path))
221 if not parser.has_section("LeanKit"):
222 raise ValueError("Could not find 'LeanKit' section in config file.")
223- if not parser.has_option("LeanKit", "Username") or not parser.get("LeanKit", "Username"):
224+ if not parser.has_option("LeanKit", "Username") or \
225+ not parser.get("LeanKit", "Username"):
226 raise ValueError("No username set in config file.")
227- if not parser.has_option("LeanKit", "Password") or not parser.get("LeanKit", "Password"):
228+ if not parser.has_option("LeanKit", "Password") or \
229+ not parser.get("LeanKit", "Password"):
230 raise ValueError("No password set in config file.")
231 return (
232 parser.get("LeanKit", "Username"),
233
234=== modified file 'qakit/tests/__init__.py'
235--- qakit/tests/__init__.py 2014-11-12 02:33:22 +0000
236+++ qakit/tests/__init__.py 2015-04-17 14:40:43 +0000
237@@ -12,9 +12,8 @@
238 # GNU General Public License for more details.
239 #
240 # You should have received a copy of the GNU General Public License
241-# along with this program; if not, write to the Free Software
242-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
243-
244+# along with this program. If not, see <http://www.gnu.org/licenses/>
245+#
246
247 from unittest import TestSuite
248
249
250=== modified file 'qakit/tests/test_config.py'
251--- qakit/tests/test_config.py 2014-10-08 01:30:28 +0000
252+++ qakit/tests/test_config.py 2015-04-17 14:40:43 +0000
253@@ -12,9 +12,8 @@
254 # GNU General Public License for more details.
255 #
256 # You should have received a copy of the GNU General Public License
257-# along with this program; if not, write to the Free Software
258-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
259-
260+# along with this program. If not, see <http://www.gnu.org/licenses/>
261+#
262
263 import os.path
264
265@@ -39,7 +38,6 @@
266 )
267
268
269-
270 def test_suite():
271 from unittest import TestLoader
272 return TestLoader().loadTestsFromName(__name__)
273
274=== modified file 'qakit/tests/test_format.py'
275--- qakit/tests/test_format.py 2014-10-08 01:30:28 +0000
276+++ qakit/tests/test_format.py 2015-04-17 14:40:43 +0000
277@@ -12,9 +12,8 @@
278 # GNU General Public License for more details.
279 #
280 # You should have received a copy of the GNU General Public License
281-# along with this program; if not, write to the Free Software
282-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
283-
284+# along with this program. If not, see <http://www.gnu.org/licenses/>
285+#
286
287 import datetime
288
289@@ -38,13 +37,13 @@
290 dt2 = dt1 + datetime.timedelta(days=1)
291 return _f.Period(dt1, dt2)
292
293+
294 class FormatPeriodTests(TestCase):
295
296-
297 def test_can_construct_with_two_dates(self):
298 dt1 = get_today_utc()
299 dt2 = dt1 + datetime.timedelta(days=1)
300- p = _f.Period(dt1, dt2)
301+ _f.Period(dt1, dt2)
302
303 def test_raises_ValueError_if_start_after_end(self):
304 dt1 = get_today_utc()
305@@ -58,7 +57,7 @@
306
307 def test_can_construct_with_same_date(self):
308 dt1 = get_today_utc()
309- p = _f.Period(dt1, dt1)
310+ _f.Period(dt1, dt1)
311
312 def test_period_includes_start_date(self):
313 p = make_period_with_one_day_duration()
314
315=== modified file 'qakit/tests/test_trello.py'
316--- qakit/tests/test_trello.py 2014-10-08 01:30:28 +0000
317+++ qakit/tests/test_trello.py 2015-04-17 14:40:43 +0000
318@@ -12,11 +12,9 @@
319 # GNU General Public License for more details.
320 #
321 # You should have received a copy of the GNU General Public License
322-# along with this program; if not, write to the Free Software
323-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
324-
325-
326-from functools import partial
327+# along with this program. If not, see <http://www.gnu.org/licenses/>
328+#
329+
330 from testtools import TestCase
331
332 from qakit import trello
333@@ -32,7 +30,6 @@
334 return trello.CompletedCard('Failed', date, assigned_to, name)
335
336
337-
338 class OpenCardFilterTests(TestCase):
339
340 def test_no_backlog(self):
341
342=== modified file 'qakit/trello.py'
343--- qakit/trello.py 2014-10-09 00:52:51 +0000
344+++ qakit/trello.py 2015-04-17 14:40:43 +0000
345@@ -12,23 +12,19 @@
346 # GNU General Public License for more details.
347 #
348 # You should have received a copy of the GNU General Public License
349-# along with this program; if not, write to the Free Software
350-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
351-
352+# along with this program. If not, see <http://www.gnu.org/licenses/>
353+#
354
355 """Functions for trello integration."""
356
357 from __future__ import absolute_import
358-
359 import dateutil.parser
360-
361 import trello
362-
363 from qakit import format
364
365 # some constants:
366-TRELLO_API_KEY='52459e89f279d1dd916ffc65d324ce7c'
367-TRELLO_SILO_TEST_BOARD='AE3swczu'
368+TRELLO_API_KEY = '52459e89f279d1dd916ffc65d324ce7c'
369+TRELLO_SILO_TEST_BOARD = 'AE3swczu'
370
371
372 class Card(object):
373@@ -89,7 +85,7 @@
374
375
376 def test():
377- api = trello.TrelloApi(TRELLO_API_KEY)
378+ trello.TrelloApi(TRELLO_API_KEY)
379
380
381 def _get_all_completed_cards(trello_api):
382@@ -121,7 +117,6 @@
383
384
385 def _get_all_actions(trello_api):
386- actions = []
387 raw_actions = trello_api.boards.get_action(
388 TRELLO_SILO_TEST_BOARD,
389 limit=1000
390@@ -136,8 +131,8 @@
391 act = action[u'type']
392
393 # skip a few action types
394- if act in ('createCard','deleteCard','removeMemberFromCard',
395- 'updateBoard',):
396+ if act in ('createCard', 'deleteCard', 'removeMemberFromCard',
397+ 'updateBoard',):
398 continue
399 # ignore updates which don't traverse lanes
400 # (not entirely sure what all these actions are though)
401
402=== modified file 'setup.py'
403--- setup.py 2014-11-12 02:33:22 +0000
404+++ setup.py 2015-04-17 14:40:43 +0000
405@@ -12,11 +12,10 @@
406 # GNU General Public License for more details.
407 #
408 # You should have received a copy of the GNU General Public License
409-# along with this program; if not, write to the Free Software
410-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
411-
412-
413-import sys
414+# along with this program. If not, see <http://www.gnu.org/licenses/>.
415+#
416+
417+
418 from setuptools import setup, find_packages
419 import qakit
420
421@@ -37,6 +36,7 @@
422 'requests',
423 'termcolor',
424 'trello',
425+ 'beautifulsoup4',
426 ],
427 entry_points={
428 'console_scripts': [

Subscribers

People subscribed via source and target branches