Merge lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 into lp:ubuntu-webcatalog
- law-and-order.1
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 134 | ||||
Merged at revision: | 134 | ||||
Proposed branch: | lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 | ||||
Merge into: | lp:ubuntu-webcatalog | ||||
Prerequisite: | lp:~nataliabidart/ubuntu-webcatalog/law-and-order | ||||
Diff against target: |
511 lines (+78/-72) 13 files modified
src/webcatalog/api/forms.py (+2/-2) src/webcatalog/api/handlers.py (+1/-1) src/webcatalog/api/urls.py (+5/-4) src/webcatalog/management/commands/check_all_latest.py (+4/-4) src/webcatalog/management/commands/cleanup.py (+6/-4) src/webcatalog/management/commands/import_app_install_data.py (+21/-18) src/webcatalog/management/commands/import_exhibits.py (+5/-5) src/webcatalog/management/commands/import_for_purchase_apps.py (+2/-3) src/webcatalog/management/commands/import_ratings_stats.py (+3/-3) src/webcatalog/middleware/exception.py (+3/-3) src/webcatalog/models/applications.py (+19/-17) src/webcatalog/models/oauthtoken.py (+4/-5) src/webcatalog/templatetags/webcatalog.py (+3/-3) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Anthony Lenton (community) | Approve | ||
Review via email: mp+108993@code.launchpad.net |
Commit message
- Fixing pep8 issues (part 1 of LP: #1007626).
Description of the change
To post a comment you must log in.
Revision history for this message
ISD Branch Mangler (isd-branches-mangler) wrote : | # |
The prerequisite lp:~nataliabidart/ubuntu-webcatalog/law-and-order has not yet been merged into lp:ubuntu-webcatalog.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/webcatalog/api/forms.py' |
2 | --- src/webcatalog/api/forms.py 2012-01-06 17:54:47 +0000 |
3 | +++ src/webcatalog/api/forms.py 2012-06-06 16:45:24 +0000 |
4 | @@ -36,7 +36,7 @@ |
5 | fields = ( |
6 | 'hostname', |
7 | 'logo_checksum', |
8 | - ) |
9 | + ) |
10 | |
11 | |
12 | class MachineUpdatePackagesForm(forms.ModelForm): |
13 | @@ -45,4 +45,4 @@ |
14 | fields = ( |
15 | 'packages_checksum', |
16 | 'package_list', |
17 | - ) |
18 | + ) |
19 | |
20 | === modified file 'src/webcatalog/api/handlers.py' |
21 | --- src/webcatalog/api/handlers.py 2012-03-23 20:14:03 +0000 |
22 | +++ src/webcatalog/api/handlers.py 2012-06-06 16:45:24 +0000 |
23 | @@ -28,7 +28,7 @@ |
24 | HttpResponse, |
25 | HttpResponseBadRequest, |
26 | HttpResponseNotFound, |
27 | - ) |
28 | +) |
29 | from piston.handler import BaseHandler |
30 | |
31 | from webcatalog.models import Machine |
32 | |
33 | === modified file 'src/webcatalog/api/urls.py' |
34 | --- src/webcatalog/api/urls.py 2012-04-18 22:29:29 +0000 |
35 | +++ src/webcatalog/api/urls.py 2012-06-06 16:45:24 +0000 |
36 | @@ -37,13 +37,14 @@ |
37 | |
38 | server_status_resource = never_cache(Resource(handler=ServerStatusHandler)) |
39 | list_machines_resource = never_cache(Resource(handler=ListMachinesHandler, |
40 | - authentication=auth)) |
41 | + authentication=auth)) |
42 | machine_resource = never_cache(CSRFExemptResource(handler=MachineHandler, |
43 | - authentication=auth)) |
44 | + authentication=auth)) |
45 | packages_resource = never_cache(CSRFExemptResource(handler=PackagesHandler, |
46 | - authentication=auth)) |
47 | + authentication=auth)) |
48 | |
49 | -urlpatterns = patterns('', |
50 | +urlpatterns = patterns( |
51 | + '', |
52 | # get status of the service (usually just "ok", might be "read-only") |
53 | # to ensure we inform the user when he wants to write a review or |
54 | # send a moderation request |
55 | |
56 | === modified file 'src/webcatalog/management/commands/check_all_latest.py' |
57 | --- src/webcatalog/management/commands/check_all_latest.py 2012-03-16 04:25:10 +0000 |
58 | +++ src/webcatalog/management/commands/check_all_latest.py 2012-06-06 16:45:24 +0000 |
59 | @@ -19,7 +19,7 @@ |
60 | |
61 | from __future__ import ( |
62 | absolute_import, |
63 | - ) |
64 | +) |
65 | |
66 | from django.core.management.base import BaseCommand |
67 | |
68 | @@ -28,7 +28,7 @@ |
69 | __metaclass__ = type |
70 | __all__ = [ |
71 | 'Command', |
72 | - ] |
73 | +] |
74 | |
75 | BATCH_SIZE = 200 |
76 | |
77 | @@ -48,8 +48,8 @@ |
78 | Application.objects.all().update(is_latest=False) |
79 | |
80 | # 2. Update is_latest in batches of BATCH_SIZE. |
81 | - packages = Application.objects.values_list('id', |
82 | - 'package_name').order_by('package_name', '-distroseries__version') |
83 | + packages = Application.objects.values_list('id', 'package_name') |
84 | + packages = packages.order_by('package_name', '-distroseries__version') |
85 | current_package_name = None |
86 | to_update = [] |
87 | for app_id, app_package_name in packages: |
88 | |
89 | === modified file 'src/webcatalog/management/commands/cleanup.py' |
90 | --- src/webcatalog/management/commands/cleanup.py 2012-04-17 16:56:44 +0000 |
91 | +++ src/webcatalog/management/commands/cleanup.py 2012-06-06 16:45:24 +0000 |
92 | @@ -106,13 +106,15 @@ |
93 | help = "Cleans the Django session and OAuth nonce tables." |
94 | |
95 | option_list = LabelCommand.option_list + ( |
96 | - make_option('--cursor-life', default=3600, dest="cursor_secs", |
97 | + make_option( |
98 | + '--cursor-life', default=3600, dest="cursor_secs", |
99 | action='store', |
100 | help="Hold a cursor open a maximum of SECS seconds"), |
101 | - make_option('--batch-time', default=5, dest="batch_secs", |
102 | + make_option( |
103 | + '--batch-time', default=5, dest="batch_secs", |
104 | action="store", |
105 | help="Try to keep batch removal transaction time to SECS seconds"), |
106 | - ) |
107 | + ) |
108 | |
109 | def handle_label(self, table, **options): |
110 | if not psycopg2_available: |
111 | @@ -124,7 +126,7 @@ |
112 | cleaner_cls = CLEANERS.get(table, None) |
113 | if cleaner_cls is None: |
114 | msg = ("Invalid cleaner.\nNo cleaner found for table: %s\n" |
115 | - "Supported tables are: %s" % (table, CLEANERS.keys())) |
116 | + "Supported tables are: %s" % (table, CLEANERS.keys())) |
117 | raise CommandError(msg) |
118 | cleaner = cleaner_cls() |
119 | connection.isolation_level = ISOLATION_LEVEL_AUTOCOMMIT |
120 | |
121 | === modified file 'src/webcatalog/management/commands/import_app_install_data.py' |
122 | --- src/webcatalog/management/commands/import_app_install_data.py 2012-05-09 15:31:34 +0000 |
123 | +++ src/webcatalog/management/commands/import_app_install_data.py 2012-06-06 16:45:24 +0000 |
124 | @@ -20,7 +20,7 @@ |
125 | from __future__ import ( |
126 | absolute_import, |
127 | with_statement, |
128 | - ) |
129 | +) |
130 | |
131 | import os |
132 | import re |
133 | @@ -43,12 +43,11 @@ |
134 | from webcatalog.models import ( |
135 | Application, |
136 | DistroSeries, |
137 | - ) |
138 | +) |
139 | from webcatalog.utilities import create_png_from_file |
140 | |
141 | __metaclass__ = type |
142 | -__all__ = [ |
143 | - ] |
144 | +__all__ = [] |
145 | |
146 | |
147 | class CacheMaker(object): |
148 | @@ -97,21 +96,23 @@ |
149 | class Command(LabelCommand): |
150 | |
151 | help = ("Update Application data from apt cache and " |
152 | - "app-install-data(-partner) packages.") |
153 | + "app-install-data(-partner) packages.") |
154 | option_list = LabelCommand.option_list + ( |
155 | - make_option('--local-app-install-data', |
156 | + make_option( |
157 | + '--local-app-install-data', |
158 | action='store', |
159 | dest='local_app_install_data', |
160 | default='', |
161 | help=('Use a local app-install-data deb package rather than ' |
162 | 'downloading from the archive.')), |
163 | - make_option('--local-app-install-data-partner', |
164 | + make_option( |
165 | + '--local-app-install-data-partner', |
166 | action='store', |
167 | dest='local_app_install_data_partner', |
168 | default='', |
169 | help=('Use a local app-install-data-partner deb package rather ' |
170 | 'than downloading from the archive.')), |
171 | - ) |
172 | + ) |
173 | verbosity = 1 |
174 | |
175 | def set_cache(self, distroseries): |
176 | @@ -141,12 +142,12 @@ |
177 | self.update_from_app_data(package, distroseries, deb_location) |
178 | |
179 | def update_from_app_data(self, package_name, distroseries, |
180 | - deb_location=''): |
181 | + deb_location=''): |
182 | data_dir = tempfile.mkdtemp() |
183 | # Download app install data if necessary |
184 | if deb_location == '': |
185 | - deb_location = self.get_package_data_for_series(package_name, |
186 | - distroseries.code_name, data_dir) |
187 | + deb_location = self.get_package_data_for_series( |
188 | + package_name, distroseries.code_name, data_dir) |
189 | |
190 | # Extract and parse the deb archive. |
191 | deb_file = DebFile(deb_location) |
192 | @@ -166,7 +167,7 @@ |
193 | shutil.rmtree(data_dir) |
194 | |
195 | def get_package_data_for_series(self, package_name, distroseries, |
196 | - working_dir): |
197 | + working_dir): |
198 | install_data_url = self.get_package_uri_for_series( |
199 | package_name, distroseries) |
200 | rest, sep, deb_filename = install_data_url.rpartition('/') |
201 | @@ -180,7 +181,7 @@ |
202 | |
203 | def get_package_uri_for_series(self, package_name, distroseries): |
204 | self.output("Determining URI for current version of " |
205 | - "{0} in {1}.\n".format(package_name, distroseries), 1) |
206 | + "{0} in {1}.\n".format(package_name, distroseries), 1) |
207 | self.set_cache(distroseries) |
208 | return self.cache[package_name].candidate.uri |
209 | |
210 | @@ -267,10 +268,11 @@ |
211 | distroseries, created = DistroSeries.objects.get_or_create( |
212 | code_name=distroseries_name) |
213 | if created: |
214 | - self.output("Created a DistroSeries record called '{0}'.\n".format( |
215 | - distroseries_name), 1) |
216 | + msg = "Created a DistroSeries record called '{0}'.\n" |
217 | + self.output(msg.format(distroseries_name), 1) |
218 | |
219 | - prefetched_apps = dict((app.package_name, app) for app in |
220 | + prefetched_apps = dict( |
221 | + (app.package_name, app) for app in |
222 | Application.objects.filter(distroseries=distroseries)) |
223 | |
224 | self.set_cache(distroseries_name) |
225 | @@ -297,7 +299,8 @@ |
226 | for attribute, value in [ |
227 | ('description', candidate.description), |
228 | ('section', candidate.section), ('version', version), |
229 | - ('name', app_name), ('comment', app_comment)]: |
230 | + ('name', app_name), ('comment', app_comment), |
231 | + ]: |
232 | if getattr(app, attribute) != value: |
233 | setattr(app, attribute, value) |
234 | updated = True |
235 | @@ -312,7 +315,7 @@ |
236 | name=app_name, |
237 | version=version, |
238 | comment=app_comment, |
239 | - ) |
240 | + ) |
241 | |
242 | screenshot_url = package.candidateRecord.get('Screenshot-Url') |
243 | if screenshot_url is not None and ( |
244 | |
245 | === modified file 'src/webcatalog/management/commands/import_exhibits.py' |
246 | --- src/webcatalog/management/commands/import_exhibits.py 2012-04-13 20:49:20 +0000 |
247 | +++ src/webcatalog/management/commands/import_exhibits.py 2012-06-06 16:45:24 +0000 |
248 | @@ -19,7 +19,7 @@ |
249 | |
250 | from __future__ import ( |
251 | absolute_import, |
252 | - ) |
253 | +) |
254 | |
255 | import json |
256 | import urllib |
257 | @@ -31,12 +31,12 @@ |
258 | from webcatalog.models import ( |
259 | DistroSeries, |
260 | Exhibit, |
261 | - ) |
262 | +) |
263 | |
264 | __metaclass__ = type |
265 | __all__ = [ |
266 | 'Command', |
267 | - ] |
268 | +] |
269 | |
270 | |
271 | class Command(BaseCommand): |
272 | @@ -71,7 +71,7 @@ |
273 | Exhibit.objects.filter(pk=instance.pk).update(**args) |
274 | |
275 | distroseries = [DistroSeries.objects.get_or_create(**ds)[0] |
276 | - for ds in exhibit.get('distroseries', [])] |
277 | + for ds in exhibit.get('distroseries', [])] |
278 | |
279 | to_remove = instance.distroseries.exclude( |
280 | pk__in=[x.id for x in distroseries]) |
281 | @@ -81,4 +81,4 @@ |
282 | # Unpublish other exhibits |
283 | Exhibit.objects.filter(published=True).exclude( |
284 | sca_id__in=[xibit['id'] for xibit in exhibits]).update( |
285 | - published=False) |
286 | + published=False) |
287 | |
288 | === modified file 'src/webcatalog/management/commands/import_for_purchase_apps.py' |
289 | --- src/webcatalog/management/commands/import_for_purchase_apps.py 2012-05-02 14:58:15 +0000 |
290 | +++ src/webcatalog/management/commands/import_for_purchase_apps.py 2012-06-06 16:45:24 +0000 |
291 | @@ -22,7 +22,7 @@ |
292 | from __future__ import ( |
293 | absolute_import, |
294 | with_statement, |
295 | - ) |
296 | +) |
297 | |
298 | import json |
299 | import os |
300 | @@ -41,8 +41,7 @@ |
301 | ) |
302 | |
303 | __metaclass__ = type |
304 | -__all__ = [ |
305 | - ] |
306 | +__all__ = [] |
307 | |
308 | |
309 | class Command(BaseCommand): |
310 | |
311 | === modified file 'src/webcatalog/management/commands/import_ratings_stats.py' |
312 | --- src/webcatalog/management/commands/import_ratings_stats.py 2012-03-20 22:23:31 +0000 |
313 | +++ src/webcatalog/management/commands/import_ratings_stats.py 2012-06-06 16:45:24 +0000 |
314 | @@ -20,7 +20,7 @@ |
315 | from datetime import ( |
316 | datetime, |
317 | timedelta, |
318 | - ) |
319 | +) |
320 | import json |
321 | |
322 | from django.core.management.base import LabelCommand |
323 | @@ -29,11 +29,11 @@ |
324 | Application, |
325 | DistroSeries, |
326 | ReviewStatsImport, |
327 | - ) |
328 | +) |
329 | from webcatalog.utilities import ( |
330 | dampened_rating, |
331 | WebServices, |
332 | - ) |
333 | +) |
334 | |
335 | |
336 | class Command(LabelCommand): |
337 | |
338 | === modified file 'src/webcatalog/middleware/exception.py' |
339 | --- src/webcatalog/middleware/exception.py 2011-09-12 13:58:47 +0000 |
340 | +++ src/webcatalog/middleware/exception.py 2012-06-06 16:45:24 +0000 |
341 | @@ -55,9 +55,9 @@ |
342 | lineno = tb.tb_lineno - 1 |
343 | loader = tb.tb_frame.f_globals.get('__loader__') |
344 | module_name = tb.tb_frame.f_globals.get('__name__') |
345 | - pre_context_lineno, pre_context, context_line, post_context = \ |
346 | - self._get_lines_from_file(filename, lineno, 7, loader, |
347 | - module_name) |
348 | + lines = self._get_lines_from_file( |
349 | + filename, lineno, 7, loader, module_name) |
350 | + pre_context_lineno, pre_context, context_line, post_context = lines |
351 | if pre_context_lineno is not None: |
352 | frames.append({ |
353 | 'tb': tb, |
354 | |
355 | === modified file 'src/webcatalog/models/applications.py' |
356 | --- src/webcatalog/models/applications.py 2012-06-06 16:45:24 +0000 |
357 | +++ src/webcatalog/models/applications.py 2012-06-06 16:45:24 +0000 |
358 | @@ -20,7 +20,7 @@ |
359 | from __future__ import ( |
360 | absolute_import, |
361 | with_statement, |
362 | - ) |
363 | +) |
364 | |
365 | import logging |
366 | from datetime import datetime |
367 | @@ -43,7 +43,7 @@ |
368 | 'Exhibit', |
369 | 'Machine', |
370 | 'ReviewStatsImport', |
371 | - ] |
372 | +] |
373 | |
374 | |
375 | class DistroSeries(models.Model): |
376 | @@ -82,18 +82,19 @@ |
377 | categories = models.CharField(max_length=255, blank=True) |
378 | departments = models.ManyToManyField('Department', blank=True) |
379 | icon_name = models.CharField(max_length=255, blank=True) |
380 | - icon = models.ImageField(upload_to='icons/%Y/%m', max_length=200, |
381 | - null=True, blank=True) |
382 | + icon = models.ImageField( |
383 | + upload_to='icons/%Y/%m', max_length=200, null=True, blank=True) |
384 | for_purchase = models.BooleanField(default=False) |
385 | - archive_id = models.CharField(max_length=64, null=True, |
386 | - db_index=True, blank=True) |
387 | - price = models.DecimalField(max_digits=7, decimal_places=2, null=True, |
388 | + archive_id = models.CharField( |
389 | + max_length=64, null=True, db_index=True, blank=True) |
390 | + price = models.DecimalField( |
391 | + max_digits=7, decimal_places=2, null=True, |
392 | blank=True, help_text="For-purchase applications (in US Dollars).") |
393 | application_id = models.IntegerField(null=True, blank=True) |
394 | |
395 | ratings_total = models.IntegerField(null=True, blank=True) |
396 | - ratings_average = models.DecimalField(max_digits=3, decimal_places=2, |
397 | - null=True, blank=True) |
398 | + ratings_average = models.DecimalField( |
399 | + max_digits=3, decimal_places=2, null=True, blank=True) |
400 | ratings_histogram = models.CharField(max_length=128, blank=True) |
401 | is_latest = models.BooleanField() |
402 | wilson_score = models.FloatField(null=True, blank=True, db_index=True) |
403 | @@ -154,7 +155,7 @@ |
404 | name=dept_name, defaults={'slug': slugify(dept_name)}) |
405 | if created: |
406 | logging.warn("Department %s automatically created!" % |
407 | - dept_name) |
408 | + dept_name) |
409 | self.departments.add(dept) |
410 | break |
411 | |
412 | @@ -164,8 +165,9 @@ |
413 | crumbs = depts[0].crumbs(distro=self.distroseries.code_name) |
414 | else: |
415 | crumbs = [{'name': 'All Apps', 'url': reverse('wc-index')}] |
416 | - crumbs.append({'name': self.name, 'url': reverse('wc-package-detail', |
417 | - args=[self.distroseries.code_name, self.package_name])}) |
418 | + url = reverse('wc-package-detail', |
419 | + args=[self.distroseries.code_name, self.package_name]) |
420 | + crumbs.append({'name': self.name, 'url': url}) |
421 | return crumbs |
422 | |
423 | def license_type(self): |
424 | @@ -198,7 +200,7 @@ |
425 | ('icon_128', 'Icon 128x128'), |
426 | ('screenshot', 'Screenshot'), |
427 | ('video', 'Video'), |
428 | - ) |
429 | + ) |
430 | |
431 | application = models.ForeignKey(Application) |
432 | media_type = models.CharField(max_length=16, choices=MEDIA_CHOICES) |
433 | @@ -268,7 +270,7 @@ |
434 | published = models.BooleanField() |
435 | display = models.NullBooleanField( |
436 | help_text="Yes: Always display. No: Never display. " |
437 | - "Unknown: Display if published") |
438 | + "Unknown: Display if published") |
439 | weight = models.IntegerField(default=0) |
440 | |
441 | class Meta: |
442 | @@ -281,7 +283,7 @@ |
443 | if not pkg_name: |
444 | return '' |
445 | return reverse('wc-package-detail', |
446 | - kwargs={'package_name': pkg_name}) |
447 | + kwargs={'package_name': pkg_name}) |
448 | |
449 | - return reverse('wc-package-list') + '?' + '&'.join( |
450 | - ['pkg_name=%s' % pkg_name for pkg_name in pkg_names]) |
451 | + pkgs = '&'.join('pkg_name=%s' % pkg_name for pkg_name in pkg_names) |
452 | + return reverse('wc-package-list') + '?' + pkgs |
453 | |
454 | === modified file 'src/webcatalog/models/oauthtoken.py' |
455 | --- src/webcatalog/models/oauthtoken.py 2012-01-06 17:54:47 +0000 |
456 | +++ src/webcatalog/models/oauthtoken.py 2012-06-06 16:45:24 +0000 |
457 | @@ -24,7 +24,7 @@ |
458 | 'Consumer', |
459 | 'Nonce', |
460 | 'DataStore', |
461 | - ] |
462 | +] |
463 | |
464 | import os.path |
465 | import random |
466 | @@ -45,9 +45,7 @@ |
467 | |
468 | |
469 | def _set_seed(): |
470 | - if (not hasattr(_set_seed, 'seed') and |
471 | - os.path.exists("/dev/random")): |
472 | - |
473 | + if (not hasattr(_set_seed, 'seed') and os.path.exists("/dev/random")): |
474 | data = open("/dev/random").read(struct.calcsize('Q')) |
475 | random.seed(struct.unpack('Q', data)) |
476 | _set_seed.seed = True |
477 | @@ -92,7 +90,8 @@ |
478 | |
479 | key = models.CharField(max_length=64) |
480 | |
481 | - secret = models.CharField(max_length=255, blank=True, null=False, |
482 | + secret = models.CharField( |
483 | + max_length=255, blank=True, null=False, |
484 | default=partial(generate_random_string, CONSUMER_SECRET_LENGTH)) |
485 | |
486 | created_at = models.DateTimeField(auto_now_add=True) |
487 | |
488 | === modified file 'src/webcatalog/templatetags/webcatalog.py' |
489 | --- src/webcatalog/templatetags/webcatalog.py 2012-03-12 20:14:34 +0000 |
490 | +++ src/webcatalog/templatetags/webcatalog.py 2012-06-06 16:45:24 +0000 |
491 | @@ -20,12 +20,12 @@ |
492 | from __future__ import ( |
493 | absolute_import, |
494 | with_statement, |
495 | - ) |
496 | +) |
497 | |
498 | __metaclass__ = type |
499 | __all__ = [ |
500 | 'install_options', |
501 | - ] |
502 | +] |
503 | |
504 | import string |
505 | |
506 | @@ -198,4 +198,4 @@ |
507 | stars.append(0) |
508 | |
509 | return dict(stars=stars, total=num_ratings, |
510 | - STATIC_URL=settings.STATIC_URL, size=size) |
511 | + STATIC_URL=settings.STATIC_URL, size=size) |
+1