Merge lp:~allenap/maas/top-of-file-boilerplate into lp:maas/trunk

Proposed by Gavin Panella on 2012-01-19
Status: Merged
Merged at revision: 24
Proposed branch: lp:~allenap/maas/top-of-file-boilerplate
Merge into: lp:maas/trunk
Diff against target: 485 lines (+198/-37)
21 files modified
setup.py (+3/-1)
src/maas/development.py (+9/-2)
src/maas/production.py (+9/-0)
src/maas/settings.py (+9/-2)
src/maas/testing/__init__.py (+8/-1)
src/maas/testing/runner.py (+12/-0)
src/maas/urls.py (+9/-0)
src/maasserver/api.py (+18/-3)
src/maasserver/context_processors.py (+12/-0)
src/maasserver/macaddress.py (+10/-0)
src/maasserver/models.py (+13/-0)
src/maasserver/testing/factory.py (+19/-3)
src/maasserver/tests/__init__.py (+5/-0)
src/maasserver/tests/test_api.py (+19/-11)
src/maasserver/tests/test_macaddressfield.py (+1/-1)
src/maasserver/urls.py (+19/-5)
src/maasserver/views.py (+13/-0)
templates/module.py (+2/-2)
templates/test.py (+2/-2)
utilities/format-imports (+5/-3)
utilities/python_standard_libs.py (+1/-1)
To merge this branch: bzr merge lp:~allenap/maas/top-of-file-boilerplate
Reviewer Review Type Date Requested Status
Raphaël Badin (community) 2012-01-19 Approve on 2012-01-19
Review via email: mp+89224@code.launchpad.net

Commit Message

Top-of-the-file boilerplate, lint, and import formatting.

To post a comment you must log in.
Raphaël Badin (rvb) wrote :

Looks good.

[1]

230 +__all__ = [
231 + "Factory",

Not sure we need to expose the class itself. The singleton should be sufficient.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2012-01-19 10:48:02 +0000
3+++ setup.py 2012-01-19 11:40:41 +0000
4@@ -1,7 +1,9 @@
5-#!/usr/bin/env python
6+#!/usr/bin/env python2.7
7 # Copyright 2012 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10+from __future__ import print_function
11+
12 """Distutils installer for maas."""
13
14 import os
15
16=== modified file 'src/maas/development.py'
17--- src/maas/development.py 2012-01-19 10:48:02 +0000
18+++ src/maas/development.py 2012-01-19 11:40:41 +0000
19@@ -1,5 +1,12 @@
20-
21-# Django development settings for maas project.
22+# Copyright 2012 Canonical Ltd. This software is licensed under the
23+# GNU Affero General Public License version 3 (see the file LICENSE).
24+
25+from __future__ import print_function
26+
27+"""Django DEVELOPMENT settings for maas project."""
28+
29+__metaclass__ = type
30+__all__ = []
31
32 import os
33
34
35=== modified file 'src/maas/production.py'
36--- src/maas/production.py 2012-01-16 08:33:18 +0000
37+++ src/maas/production.py 2012-01-19 11:40:41 +0000
38@@ -1,2 +1,11 @@
39+# Copyright 2012 Canonical Ltd. This software is licensed under the
40+# GNU Affero General Public License version 3 (see the file LICENSE).
41+
42+from __future__ import print_function
43+
44+"""Django PRODUCTION settings for maas project."""
45+
46+__metaclass__ = type
47+__all__ = []
48
49 from maas.settings import *
50
51=== modified file 'src/maas/settings.py'
52--- src/maas/settings.py 2012-01-19 10:48:02 +0000
53+++ src/maas/settings.py 2012-01-19 11:40:41 +0000
54@@ -1,5 +1,12 @@
55-
56-# Django settings for maas project.
57+# Copyright 2012 Canonical Ltd. This software is licensed under the
58+# GNU Affero General Public License version 3 (see the file LICENSE).
59+
60+from __future__ import print_function
61+
62+"""Django settings for maas project."""
63+
64+__metaclass__ = type
65+__all__ = []
66
67 import os
68
69
70=== modified file 'src/maas/testing/__init__.py'
71--- src/maas/testing/__init__.py 2012-01-18 17:08:17 +0000
72+++ src/maas/testing/__init__.py 2012-01-19 11:40:41 +0000
73@@ -1,5 +1,12 @@
74+# Copyright 2012 Canonical Ltd. This software is licensed under the
75+# GNU Affero General Public License version 3 (see the file LICENSE).
76+
77+from __future__ import print_function
78+
79+"""Test related classes and functions for maas and its applications."""
80+
81+__metaclass__ = type
82 __all__ = []
83-__metaclass__ = type
84
85 import django.test
86 import testresources
87
88=== modified file 'src/maas/testing/runner.py'
89--- src/maas/testing/runner.py 2012-01-18 17:08:17 +0000
90+++ src/maas/testing/runner.py 2012-01-19 11:40:41 +0000
91@@ -1,3 +1,15 @@
92+# Copyright 2012 Canonical Ltd. This software is licensed under the
93+# GNU Affero General Public License version 3 (see the file LICENSE).
94+
95+from __future__ import print_function
96+
97+"""Test runner for maas and its applications."""
98+
99+__metaclass__ = type
100+__all__ = [
101+ "TestRunner",
102+ ]
103+
104 from subprocess import check_call
105
106 from django.test.simple import DjangoTestSuiteRunner
107
108=== modified file 'src/maas/urls.py'
109--- src/maas/urls.py 2012-01-18 17:08:17 +0000
110+++ src/maas/urls.py 2012-01-19 11:40:41 +0000
111@@ -1,3 +1,12 @@
112+# Copyright 2012 Canonical Ltd. This software is licensed under the
113+# GNU Affero General Public License version 3 (see the file LICENSE).
114+
115+from __future__ import print_function
116+
117+"""..."""
118+
119+__metaclass__ = type
120+__all__ = []
121
122 from django.conf import settings
123 from django.conf.urls.defaults import *
124
125=== modified file 'src/maasserver/api.py'
126--- src/maasserver/api.py 2012-01-18 19:16:57 +0000
127+++ src/maasserver/api.py 2012-01-19 11:40:41 +0000
128@@ -1,11 +1,26 @@
129+# Copyright 2012 Canonical Ltd. This software is licensed under the
130+# GNU Affero General Public License version 3 (see the file LICENSE).
131+
132+from __future__ import print_function
133+
134+"""API."""
135+
136+__metaclass__ = type
137+__all__ = [
138+ "NodeHandler",
139+ "NodeMacsHandler",
140+ ]
141+
142 from django.core.exceptions import ValidationError
143 from django.shortcuts import get_object_or_404
144+from maasserver.macaddress import validate_mac
145+from maasserver.models import (
146+ MACAddress,
147+ Node,
148+ )
149 from piston.handler import BaseHandler
150 from piston.utils import rc
151
152-from maasserver.models import Node, MACAddress
153-from maasserver.macaddress import validate_mac
154-
155
156 def bad_request(message):
157 resp = rc.BAD_REQUEST
158
159=== modified file 'src/maasserver/context_processors.py'
160--- src/maasserver/context_processors.py 2012-01-16 16:15:44 +0000
161+++ src/maasserver/context_processors.py 2012-01-19 11:40:41 +0000
162@@ -1,3 +1,15 @@
163+# Copyright 2012 Canonical Ltd. This software is licensed under the
164+# GNU Affero General Public License version 3 (see the file LICENSE).
165+
166+from __future__ import print_function
167+
168+"""Context processors."""
169+
170+__metaclass__ = type
171+__all__ = [
172+ "yui",
173+ ]
174+
175 from django.conf import settings
176
177
178
179=== modified file 'src/maasserver/macaddress.py'
180--- src/maasserver/macaddress.py 2012-01-19 10:48:02 +0000
181+++ src/maasserver/macaddress.py 2012-01-19 11:40:41 +0000
182@@ -1,3 +1,13 @@
183+# Copyright 2012 Canonical Ltd. This software is licensed under the
184+# GNU Affero General Public License version 3 (see the file LICENSE).
185+
186+from __future__ import print_function
187+
188+"""..."""
189+
190+__metaclass__ = type
191+__all__ = []
192+
193 import re
194
195 from django.core.validators import RegexValidator
196
197=== modified file 'src/maasserver/models.py'
198--- src/maasserver/models.py 2012-01-19 10:30:58 +0000
199+++ src/maasserver/models.py 2012-01-19 11:40:41 +0000
200@@ -1,3 +1,16 @@
201+# Copyright 2012 Canonical Ltd. This software is licensed under the
202+# GNU Affero General Public License version 3 (see the file LICENSE).
203+
204+from __future__ import print_function
205+
206+"""Model."""
207+
208+__metaclass__ = type
209+__all__ = [
210+ "Node",
211+ "MACAddress",
212+ ]
213+
214 import datetime
215 import re
216 from uuid import uuid1
217
218=== modified file 'src/maasserver/testing/factory.py'
219--- src/maasserver/testing/factory.py 2012-01-18 19:16:57 +0000
220+++ src/maasserver/testing/factory.py 2012-01-19 11:40:41 +0000
221@@ -1,14 +1,30 @@
222+# Copyright 2012 Canonical Ltd. This software is licensed under the
223+# GNU Affero General Public License version 3 (see the file LICENSE).
224+
225+from __future__ import print_function
226+
227+"""Test object factories."""
228+
229+__metaclass__ = type
230+__all__ = [
231+ "Factory",
232+ "factory",
233+ ]
234+
235+import random
236 import string
237-import random
238
239-from maasserver.models import Node, MACAddress
240+from maasserver.models import (
241+ MACAddress,
242+ Node,
243+ )
244
245
246 class Factory():
247
248 def getRandomString(self, size):
249 return "".join(
250- random.choice(string.letters+string.digits)
251+ random.choice(string.letters + string.digits)
252 for x in xrange(size))
253
254 def make_node(self, hostname='', set_hostname=False, status=None,
255
256=== modified file 'src/maasserver/tests/__init__.py'
257--- src/maasserver/tests/__init__.py 2012-01-19 10:48:02 +0000
258+++ src/maasserver/tests/__init__.py 2012-01-19 11:40:41 +0000
259@@ -1,6 +1,11 @@
260 # Copyright 2012 Canonical Ltd. This software is licensed under the
261 # GNU Affero General Public License version 3 (see the file LICENSE).
262
263+from __future__ import print_function
264+
265+__metaclass__ = type
266+__all__ = []
267+
268 from os.path import dirname
269
270 from django.utils.unittest import defaultTestLoader
271
272=== modified file 'src/maasserver/tests/test_api.py'
273--- src/maasserver/tests/test_api.py 2012-01-18 19:16:57 +0000
274+++ src/maasserver/tests/test_api.py 2012-01-19 11:40:41 +0000
275@@ -1,12 +1,20 @@
276-"""
277-Test maasserver api.
278-"""
279+# Copyright 2012 Canonical Ltd. This software is licensed under the
280+# GNU Affero General Public License version 3 (see the file LICENSE).
281+
282+from __future__ import print_function
283+
284+"""Test maasserver API."""
285+
286+__metaclass__ = type
287+__all__ = []
288
289 import json
290
291-from django.test import TestCase
292-
293-from maasserver.models import Node, MACAddress
294+from maas.testing import TestCase
295+from maasserver.models import (
296+ MACAddress,
297+ Node,
298+ )
299 from maasserver.testing.factory import factory
300
301
302@@ -65,7 +73,7 @@
303
304 self.assertEqual(200, response.status_code)
305 self.assertEqual('diane', parsed_result['hostname'])
306- self.assertEqual(1, Node.objects.filter(hostname= 'diane').count())
307+ self.assertEqual(1, Node.objects.filter(hostname='diane').count())
308
309 def test_node_PUT(self):
310 """
311@@ -79,8 +87,8 @@
312
313 self.assertEqual(200, response.status_code)
314 self.assertEqual('francis', parsed_result['hostname'])
315- self.assertEqual(0, Node.objects.filter(hostname= 'diane').count())
316- self.assertEqual(1, Node.objects.filter(hostname= 'francis').count())
317+ self.assertEqual(0, Node.objects.filter(hostname='diane').count())
318+ self.assertEqual(1, Node.objects.filter(hostname='francis').count())
319
320 def test_node_PUT_404(self):
321 """
322@@ -189,7 +197,7 @@
323 The api allows to add a MAC Address to an existing node.
324
325 """
326- nb_macs = MACAddress.objects.filter(node = self.node).count()
327+ nb_macs = MACAddress.objects.filter(node=self.node).count()
328 response = self.client.post(
329 '/api/nodes/%s/macs/' % self.node.system_id,
330 {'mac_address': 'AA:BB:CC:DD:EE:FF'})
331@@ -199,7 +207,7 @@
332 self.assertEqual('AA:BB:CC:DD:EE:FF', parsed_result['mac_address'])
333 self.assertEqual(
334 nb_macs + 1,
335- MACAddress.objects.filter(node = self.node).count())
336+ MACAddress.objects.filter(node=self.node).count())
337
338 def test_macs_POST_add_mac_invalid(self):
339 """
340
341=== modified file 'src/maasserver/tests/test_macaddressfield.py'
342--- src/maasserver/tests/test_macaddressfield.py 2012-01-19 10:30:58 +0000
343+++ src/maasserver/tests/test_macaddressfield.py 2012-01-19 11:40:41 +0000
344@@ -10,8 +10,8 @@
345
346 from django.core.exceptions import ValidationError
347 from maas.testing import TestCase
348+from maasserver.macaddress import validate_mac
349 from maasserver.models import MACAddress
350-from maasserver.macaddress import validate_mac
351 from maasserver.testing.factory import factory
352
353
354
355=== modified file 'src/maasserver/urls.py'
356--- src/maasserver/urls.py 2012-01-19 10:30:58 +0000
357+++ src/maasserver/urls.py 2012-01-19 11:40:41 +0000
358@@ -1,13 +1,28 @@
359-
360-from django.conf.urls.defaults import *
361+# Copyright 2012 Canonical Ltd. This software is licensed under the
362+# GNU Affero General Public License version 3 (see the file LICENSE).
363+
364+from __future__ import print_function
365+
366+"""URL routing configuration."""
367+
368+__metaclass__ = type
369+__all__ = []
370+
371+from django.conf.urls.defaults import (
372+ patterns,
373+ url,
374+ )
375 from django.views.generic import ListView
376-from piston.resource import Resource
377+from maasserver.api import (
378+ NodeHandler,
379+ NodeMacsHandler,
380+ )
381 from maasserver.models import Node
382 from maasserver.views import (
383 NodesCreateView,
384 NodeView,
385 )
386-from maasserver.api import NodeHandler, NodeMacsHandler
387+from piston.resource import Resource
388
389
390 urlpatterns = patterns('maasserver.views',
391@@ -28,4 +43,3 @@
392 url(r'^api/nodes/([\w\-]+)/$', node_handler),
393 url(r'^api/nodes/$', node_handler),
394 )
395-
396
397=== modified file 'src/maasserver/views.py'
398--- src/maasserver/views.py 2012-01-18 21:41:52 +0000
399+++ src/maasserver/views.py 2012-01-19 11:40:41 +0000
400@@ -1,3 +1,16 @@
401+# Copyright 2012 Canonical Ltd. This software is licensed under the
402+# GNU Affero General Public License version 3 (see the file LICENSE).
403+
404+from __future__ import print_function
405+
406+"""Views."""
407+
408+__metaclass__ = type
409+__all__ = [
410+ "NodeView",
411+ "NodesCreateView",
412+ ]
413+
414 from django.shortcuts import get_object_or_404
415 from django.views.generic import (
416 CreateView,
417
418=== modified file 'templates/module.py'
419--- templates/module.py 2012-01-18 16:20:05 +0000
420+++ templates/module.py 2012-01-19 11:40:41 +0000
421@@ -1,9 +1,9 @@
422 # Copyright 2012 Canonical Ltd. This software is licensed under the
423 # GNU Affero General Public License version 3 (see the file LICENSE).
424
425+from __future__ import print_function
426+
427 """..."""
428
429-from __future__ import print_function
430-
431 __metaclass__ = type
432 __all__ = []
433
434=== modified file 'templates/test.py'
435--- templates/test.py 2012-01-18 16:20:05 +0000
436+++ templates/test.py 2012-01-19 11:40:41 +0000
437@@ -1,10 +1,10 @@
438 # Copyright 2012 Canonical Ltd. This software is licensed under the
439 # GNU Affero General Public License version 3 (see the file LICENSE).
440
441+from __future__ import print_function
442+
443 """..."""
444
445-from __future__ import print_function
446-
447 __metaclass__ = type
448 __all__ = []
449
450
451=== modified file 'utilities/format-imports'
452--- utilities/format-imports 2012-01-18 21:15:50 +0000
453+++ utilities/format-imports 2012-01-19 11:40:41 +0000
454@@ -1,8 +1,10 @@
455-#!/usr/bin/python
456+#!/usr/bin/env python2.7
457 #
458-# Copyright 2010 Canonical Ltd. This software is licensed under the
459+# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
460 # GNU Affero General Public License version 3 (see the file LICENSE).
461
462+from __future__ import print_function
463+
464 """ Format import sections in python files
465
466 = Usage =
467@@ -376,7 +378,7 @@
468 """Process the file with the given path."""
469 changed = reformat_importsection(fpath)
470 if changed:
471- print fpath
472+ print(fpath)
473
474
475 def process_tree(dpath):
476
477=== modified file 'utilities/python_standard_libs.py'
478--- utilities/python_standard_libs.py 2012-01-18 21:41:52 +0000
479+++ utilities/python_standard_libs.py 2012-01-19 11:40:41 +0000
480@@ -1,4 +1,4 @@
481-# Copyright 2010 Canonical Ltd. This software is licensed under the
482+# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
483 # GNU Affero General Public License version 3 (see the file LICENSE).
484
485 """ A list of top-level standard python library names.