Merge lp:~elachuni/software-center/pep8-test-part10 into lp:software-center

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2853
Proposed branch: lp:~elachuni/software-center/pep8-test-part10
Merge into: lp:software-center
Diff against target: 1214 lines (+179/-183)
2 files modified
softwarecenter/ui/gtk3/views/appdetailsview.py (+178/-182)
test/test_pep8.py (+1/-1)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part10
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+97540@code.launchpad.net

Description of the change

This branch makes a single (large) file pass the pep8 test, softwarecenter/ui/gtk3/views/appdetailsview.py.

There were a couple of places where splitting long lines got tricky:
 - Lines 120-125 of the diff, I chose to make a variable name shorter. I think my second option would have been to use a backslash to cut the line before the last period.
 - Lines 628-630 of the diff, here I preferred to create a new local variable. I think my second option again would have been to use a backslash before the last period. In both cases I'm a bit on the fence and open to suggestions, let me know what you think.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

I think the two cases you mention look just fine. Thanks as always, Anthony!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview.py'
2--- softwarecenter/ui/gtk3/views/appdetailsview.py 2012-02-27 16:05:43 +0000
3+++ softwarecenter/ui/gtk3/views/appdetailsview.py 2012-03-14 23:52:20 +0000
4@@ -38,11 +38,11 @@
5 from softwarecenter.db import DebFileApplication
6 from softwarecenter.backend.reviews import ReviewStats
7 #from softwarecenter.backend.zeitgeist_simple import zeitgeist_singleton
8-from softwarecenter.enums import (AppActions,
9+from softwarecenter.enums import (AppActions,
10 PkgStates,
11- Icons,
12+ Icons,
13 SOFTWARE_CENTER_PKGNAME)
14-from softwarecenter.utils import (is_unity_running,
15+from softwarecenter.utils import (is_unity_running,
16 upstream_version,
17 get_exec_line_from_desktop,
18 SimpleFileDownloader,
19@@ -82,10 +82,11 @@
20 from softwarecenter.backend import get_install_backend
21
22
23-LOG=logging.getLogger(__name__)
24+LOG = logging.getLogger(__name__)
25+
26
27 class StatusBar(Gtk.Alignment):
28- """ Subclass of Gtk.Alignment that draws a small dash border
29+ """ Subclass of Gtk.Alignment that draws a small dash border
30 around the rectangle.
31 """
32
33@@ -102,7 +103,6 @@
34 self._bg = [1, 1, 1, 0.3]
35
36 self.connect("style-updated", self.on_style_updated)
37- return
38
39 def on_style_updated(self, widget):
40 context = self.get_style_context()
41@@ -110,7 +110,6 @@
42 context = widget.get_style_context()
43 border = context.get_border(Gtk.StateFlags.NORMAL)
44 self._border_width = max(1, max(border.top, border.bottom))
45- return
46
47 def do_draw(self, cr):
48 cr.save()
49@@ -118,7 +117,7 @@
50 width = self._border_width
51
52 # fill bg
53- cr.rectangle(-width, 0, a.width+2*width, a.height)
54+ cr.rectangle(-width, 0, a.width + 2 * width, a.height)
55 cr.set_source_rgba(*self._bg)
56 cr.fill_preserve()
57
58@@ -130,14 +129,15 @@
59 context.restore()
60
61 Gdk.cairo_set_source_rgba(cr, bc)
62- cr.set_dash((width, 2*width), 1)
63- cr.set_line_width(2*width)
64+ cr.set_dash((width, 2 * width), 1)
65+ cr.set_line_width(2 * width)
66 cr.stroke()
67
68 cr.restore()
69- for child in self:
70+ for child in self:
71 self.propagate_draw(child, cr)
72
73+
74 class WarningStatusBar(StatusBar):
75
76 def __init__(self, view):
77@@ -153,6 +153,7 @@
78 # override _bg
79 self._bg = [1, 1, 0, 0.3]
80
81+
82 class PackageStatusBar(StatusBar):
83 """ Package specific status bar that contains a state label,
84 a action button and a progress bar.
85@@ -160,7 +161,7 @@
86
87 def __init__(self, view):
88 StatusBar.__init__(self, view)
89- self.installed_icon = Gtk.Image.new_from_icon_name(
90+ self.installed_icon = Gtk.Image.new_from_icon_name(
91 Icons.INSTALLED_OVERLAY, Gtk.IconSize.DIALOG)
92 self.label = Gtk.Label()
93 self.label.set_line_wrap(True)
94@@ -242,20 +243,17 @@
95 app, addons_to_install, addons_to_remove)
96 elif state == PkgStates.NEEDS_SOURCE:
97 app_manager.enable_software_source(app)
98- return
99
100 def set_label(self, label):
101 m = '<big><b>%s</b></big>' % label
102 self.label.set_markup(m)
103- return
104
105 def get_label(self):
106 return self.label.get_text()
107
108 def set_button_label(self, label):
109 self.button.set_label(label)
110- return
111-
112+
113 def get_button_label(self):
114 return self.button.get_label()
115
116@@ -263,14 +261,14 @@
117 # the currently forced archive_suite for the given app
118 app_version = self.app_details.version
119 # all available not-automatic (version, archive_suits)
120- not_automatic_suites = self.app_details.get_not_automatic_archive_versions()
121- # populat the combobox if
122- if not_automatic_suites:
123+ not_auto_suites = self.app_details.get_not_automatic_archive_versions()
124+ # populat the combobox if
125+ if not_auto_suites:
126 combo = self.combo_multiple_versions
127 combo.disconnect_by_func(self._on_combo_multiple_versions_changed)
128 model = self.combo_multiple_versions.get_model()
129 model.clear()
130- for i, archive_suite in enumerate(not_automatic_suites):
131+ for i, archive_suite in enumerate(not_auto_suites):
132 # get the version, archive_suite
133 ver, archive_suite = archive_suite
134 # the string to display is something like:
135@@ -278,9 +276,9 @@
136 displayed_archive_suite = archive_suite
137 if i == 0:
138 displayed_archive_suite = _("default")
139- s = "v%s (%s)" % (upstream_version(ver),
140+ s = "v%s (%s)" % (upstream_version(ver),
141 displayed_archive_suite)
142- model.append( (s, archive_suite) )
143+ model.append((s, archive_suite))
144 if app_version == ver:
145 self.combo_multiple_versions.set_active(i)
146 # if nothing is found, set to default
147@@ -321,9 +319,9 @@
148 self.progress.hide()
149 self.installed_icon.hide()
150
151- # FIXME: Use a Gtk.Action for the Install/Remove/Buy/Add
152+ # FIXME: Use a Gtk.Action for the Install/Remove/Buy/Add
153 # Source/Update Now action so that all UI controls
154- # (menu item, applist view button and appdetails view button)
155+ # (menu item, applist view button and appdetails view button)
156 # are managed centrally: button text, button sensitivity,
157 # and the associated callback.
158 if state == PkgStates.INSTALLING:
159@@ -340,32 +338,34 @@
160 self.set_label(_(u'Upgrading\u2026'))
161 self.button.set_sensitive(False)
162 elif state == PkgStates.INSTALLED or state == PkgStates.REINSTALLABLE:
163- #special label only if the app being viewed is software centre itself
164+ # special label only if the app being viewed is software centre
165+ # itself
166 self.installed_icon.show()
167- if app_details.pkgname== SOFTWARE_CENTER_PKGNAME:
168- self.set_label(_(u'Installed (you\u2019re using it right now)'))
169+ if app_details.pkgname == SOFTWARE_CENTER_PKGNAME:
170+ self.set_label(
171+ _(u'Installed (you\u2019re using it right now)'))
172 else:
173 if app_details.purchase_date:
174- # purchase_date is a string, must first convert to
175+ # purchase_date is a string, must first convert to
176 # datetime.datetime
177 pdate = self._convert_purchase_date_str_to_datetime(
178 app_details.purchase_date)
179- # TRANSLATORS : %Y-%m-%d formats the date as 2011-03-31,
180- # please specify a format per your locale (if you prefer,
181- # %x can be used to provide a default locale-specific date
182+ # TRANSLATORS : %Y-%m-%d formats the date as 2011-03-31,
183+ # please specify a format per your locale (if you prefer,
184+ # %x can be used to provide a default locale-specific date
185 # representation)
186 self.set_label(pdate.strftime(_('Purchased on %Y-%m-%d')))
187 elif app_details.installation_date:
188- # TRANSLATORS : %Y-%m-%d formats the date as 2011-03-31,
189- # please specify a format per your locale (if you prefer,
190- # %x can be used to provide a default locale-specific date
191+ # TRANSLATORS : %Y-%m-%d formats the date as 2011-03-31,
192+ # please specify a format per your locale (if you prefer,
193+ # %x can be used to provide a default locale-specific date
194 # representation)
195 template = _('Installed on %Y-%m-%d')
196 self.set_label(app_details.installation_date.strftime(
197 template))
198 else:
199 self.set_label(_('Installed'))
200- if state == PkgStates.REINSTALLABLE: # only deb files atm
201+ if state == PkgStates.REINSTALLABLE: # only deb files atm
202 self.set_button_label(_('Reinstall'))
203 elif state == PkgStates.INSTALLED:
204 self.set_button_label(_('Remove'))
205@@ -374,7 +374,7 @@
206 # get that info from the software-center-agent/payments
207 # service.
208 # NOTE: the currency string for this label is purposely not
209- # translatable when hardcoded, since it (currently)
210+ # translatable when hardcoded, since it (currently)
211 # won't vary based on locale and as such we don't want
212 # it translated
213 self.set_label("US$ %s" % app_details.price)
214@@ -389,11 +389,12 @@
215 PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED,
216 PkgStates.PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES):
217
218- # purchase_date is a string, must first convert to datetime.datetime
219+ # purchase_date is a string, must first convert to
220+ # datetime.datetime
221 pdate = self._convert_purchase_date_str_to_datetime(
222 app_details.purchase_date)
223- # TRANSLATORS : %Y-%m-%d formats the date as 2011-03-31, please
224- # specify a format per your locale (if you prefer, %x can be used
225+ # TRANSLATORS : %Y-%m-%d formats the date as 2011-03-31, please
226+ # specify a format per your locale (if you prefer, %x can be used
227 # to provide a default locale-specific date representation)
228 label = pdate.strftime(_('Purchased on %Y-%m-%d'))
229 self.set_button_label(_('Install'))
230@@ -408,7 +409,7 @@
231 elif state == PkgStates.UNINSTALLED:
232 #special label only if the app being viewed is software centre
233 # itself
234- if app_details.pkgname== SOFTWARE_CENTER_PKGNAME:
235+ if app_details.pkgname == SOFTWARE_CENTER_PKGNAME:
236 self.set_label(_(u'Removed (close it and it\u2019ll be gone)'))
237 else:
238 # TRANSLATORS: Free here means Gratis
239@@ -436,12 +437,12 @@
240 self.set_label(_("Error"))
241 elif state == PkgStates.NOT_FOUND:
242 # this is used when the pkg is not in the cache and there is no
243- # request we display the error in the summary field and hide the
244+ # request we display the error in the summary field and hide the
245 # rest
246 pass
247 elif state == PkgStates.NEEDS_SOURCE:
248 channelfile = self.app_details.channelfile
249- # it has a price and is not available
250+ # it has a price and is not available
251 if channelfile:
252 self.set_button_label(_("Use This Source"))
253 # check if it comes from a non-enabled component
254@@ -460,13 +461,13 @@
255
256 sensitive = network_state_is_connected()
257 self.button.set_sensitive(sensitive)
258- return
259-
260+
261 def _convert_purchase_date_str_to_datetime(self, purchase_date):
262 if purchase_date is not None:
263 return datetime.datetime.strptime(
264 purchase_date, "%Y-%m-%d %H:%M:%S")
265
266+
267 class PackageInfo(Gtk.HBox):
268 """ Box with labels for package specific information like version info
269 """
270@@ -485,14 +486,13 @@
271 self.a11y = self.get_accessible()
272
273 self.connect('realize', self._on_realize)
274- return
275
276 def _on_realize(self, widget):
277 # key
278 k = Gtk.Label()
279 k.set_name("subtle-label")
280 key_markup = '<b>%s</b>'
281- k.set_markup(key_markup % self.key)
282+ k.set_markup(key_markup % self.key)
283 k.set_alignment(1, 0)
284
285 # determine max width of all keys
286@@ -516,22 +516,23 @@
287
288 self.set_property("can-focus", True)
289 self.show_all()
290- return
291-
292+
293 def set_width(self, width):
294- return
295+ pass
296
297 def set_value(self, value):
298 self.value_label.set_markup(value)
299 self.a11y.set_name(utf8(self.key) + ' ' + utf8(value))
300
301+
302 class PackageInfoHW(PackageInfo):
303- """ special version of packageinfo that uses the custom
304+ """ special version of packageinfo that uses the custom
305 HardwareRequirementsBox as the "label"
306 """
307 def __init__(self, *args):
308 super(PackageInfoHW, self).__init__(*args)
309 self.value_label = HardwareRequirementsBox()
310+
311 def set_value(self, value):
312 self.value_label.set_hardware_requirements(value)
313
314@@ -553,7 +554,6 @@
315 self.checkbutton.pkgname = self.app.pkgname
316 self.pack_start(self.checkbutton, False, False, 12)
317 self.connect('realize', self._on_realize, icons, pkgname)
318- return
319
320 def _on_realize(self, widget, icons, pkgname):
321 # icon
322@@ -610,15 +610,15 @@
323 self.checkbutton.set_active(is_active)
324
325 def set_width(self, width):
326- return
327+ pass
328
329
330 class AddonsTable(Gtk.VBox):
331 """ Widget to display a table of addons. """
332
333- __gsignals__ = {'table-built' : (GObject.SignalFlags.RUN_FIRST,
334- None,
335- ()),
336+ __gsignals__ = {'table-built': (GObject.SignalFlags.RUN_FIRST,
337+ None,
338+ ()),
339 }
340
341 def __init__(self, addons_manager):
342@@ -687,18 +687,18 @@
343 This will become visible if any addons are scheduled for install
344 or remove.
345 """
346-
347+
348 def __init__(self, addons_manager):
349 StatusBar.__init__(self, addons_manager.view)
350 self.addons_manager = addons_manager
351 self.cache = self.addons_manager.view.cache
352
353 self.applying = False
354-
355- # TRANSLATORS: Free here means Gratis
356+
357+ # TRANSLATORS: Free here means Gratis
358 self.label_price = Gtk.Label(_("Free"))
359 self.hbox.pack_start(self.label_price, False, False, 0)
360-
361+
362 self.hbuttonbox = Gtk.HButtonBox()
363 self.hbuttonbox.set_layout(Gtk.ButtonBoxStyle.END)
364 self.button_apply = Gtk.Button(_("Apply Changes"))
365@@ -711,9 +711,9 @@
366
367 def configure(self):
368 LOG.debug("AddonsStatusBarConfigure")
369- # FIXME: addons are not always free, but the old implementation
370+ # FIXME: addons are not always free, but the old implementation
371 # of determining price was buggy
372- if (not self.addons_manager.addons_to_install and
373+ if (not self.addons_manager.addons_to_install and
374 not self.addons_manager.addons_to_remove):
375 self.hide()
376 else:
377@@ -721,7 +721,7 @@
378 self.button_apply.set_sensitive(sensitive)
379 self.button_cancel.set_sensitive(sensitive)
380 self.show_all()
381-
382+
383 def _on_button_apply_clicked(self, button):
384 self.applying = True
385 self.button_apply.set_sensitive(False)
386@@ -791,27 +791,28 @@
387
388
389 _asset_cache = {}
390+
391+
392 class AppDetailsView(Viewport):
393 """ The view that shows the application details """
394
395 # the size of the icon on the left side
396- APP_ICON_SIZE = 96 # Gtk.IconSize.DIALOG ?
397+ APP_ICON_SIZE = 96 # Gtk.IconSize.DIALOG ?
398 # art stuff
399 BACKGROUND = os.path.join(softwarecenter.paths.datadir,
400 "ui/gtk3/art/itemview-background.png")
401
402-
403- # need to include application-request-action here also since we are
404+ # need to include application-request-action here also since we are
405 # multiple-inheriting
406- __gsignals__ = {'selected':(GObject.SignalFlags.RUN_FIRST,
407- None,
408- (GObject.TYPE_PYOBJECT,)),
409- "different-application-selected" : (GObject.SignalFlags.RUN_LAST,
410- None,
411- (GObject.TYPE_PYOBJECT, )),
412+ __gsignals__ = {'selected': (GObject.SignalFlags.RUN_FIRST,
413+ None,
414+ (GObject.TYPE_PYOBJECT,)),
415+ "different-application-selected": (
416+ GObject.SignalFlags.RUN_LAST,
417+ None,
418+ (GObject.TYPE_PYOBJECT, )),
419 }
420
421-
422 def __init__(self, db, distro, icons, cache, datadir):
423 Viewport.__init__(self)
424 # basic stuff
425@@ -856,7 +857,7 @@
426 self.backend.connect(
427 "transaction-finished", self._on_transaction_finished)
428 self.backend.connect(
429- "transaction-progress-changed",
430+ "transaction-progress-changed",
431 self._on_transaction_progress_changed)
432
433 # network status watcher
434@@ -874,7 +875,7 @@
435 self._reviews_server_language = None
436 self._reviews_relaxed = False
437 self._review_sort_method = 0
438-
439+
440 # switches
441 self._show_overlay = False
442
443@@ -883,14 +884,14 @@
444 self._cache_art_assets()
445 self.connect('realize', self._on_realize)
446 self.loaded = True
447- return
448
449 def _on_destroy(self, widget):
450 self.cache.disconnect_by_func(self._on_cache_ready)
451
452 def _cache_art_assets(self):
453 global _asset_cache
454- if _asset_cache: return _asset_cache
455+ if _asset_cache:
456+ return _asset_cache
457 assets = _asset_cache
458 # cache the bg pattern
459 surf = cairo.ImageSurface.create_from_png(self.BACKGROUND)
460@@ -911,8 +912,7 @@
461 self.addon_view.addons_set_sensitive(sensitive)
462 self.addons_statusbar.button_apply.set_sensitive(sensitive)
463 self.addons_statusbar.button_cancel.set_sensitive(sensitive)
464- return
465-
466+
467 def _update_recommendations(self, pkgname):
468 self.recommended_for_app_panel.set_pkgname(pkgname)
469
470@@ -920,10 +920,9 @@
471 def _update_reviews(self, app_details):
472 self.reviews.clear()
473 self._check_for_reviews()
474- return
475
476 def _check_for_reviews(self):
477- # self.app may be undefined on network state change events
478+ # self.app may be undefined on network state change events
479 # (LP: #742635)
480 if not self.app:
481 return
482@@ -936,7 +935,7 @@
483 def _on_more_reviews_clicked(self, uilist):
484 self._reviews_server_page += 1
485 self._do_load_reviews()
486-
487+
488 def _on_review_sort_method_changed(self, uilist, sort_method):
489 self._reviews_server_page = 1
490 self._reviews_relaxed = False
491@@ -954,7 +953,7 @@
492 def _do_load_reviews(self):
493 self.reviews.show_spinner_with_message(_('Checking for reviews...'))
494 self.review_loader.get_reviews(
495- self.app, self._reviews_ready_callback,
496+ self.app, self._reviews_ready_callback,
497 page=self._reviews_server_page,
498 language=self._reviews_server_language,
499 sort=self._review_sort_method,
500@@ -965,11 +964,10 @@
501 self.reviews.replace_review(review)
502 elif action == 'remove':
503 self.reviews.remove_review(review)
504- return
505
506 def _update_review_stats_widget(self, stats):
507 if stats:
508- # ensure that the review UI knows about the stats
509+ # ensure that the review UI knows about the stats
510 self.reviews.global_review_stats = stats
511 # update the widget
512 self.review_stats_widget.set_avg_rating(stats.ratings_average)
513@@ -988,7 +986,7 @@
514 """
515 LOG.debug("_review_ready_callback: %s" % app)
516 # avoid possible race if we already moved to a new app when
517- # the reviews become ready
518+ # the reviews become ready
519 # (we only check for pkgname currently to avoid breaking on
520 # software-center totem)
521 if self.app.pkgname != app.pkgname:
522@@ -1000,7 +998,7 @@
523 self._reviews_relaxed = True
524 self._reviews_server_page = 1
525 self.review_loader.get_reviews(
526- self.app, self._reviews_ready_callback,
527+ self.app, self._reviews_ready_callback,
528 page=self._reviews_server_page,
529 language=self._reviews_server_language,
530 sort=self._review_sort_method,
531@@ -1020,15 +1018,16 @@
532 if stats.ratings_total == 0:
533 stats.ratings_average = 0
534 else:
535- stats.ratings_average = sum([x.rating for x in reviews_data]) / float(stats.ratings_total)
536+ stats.ratings_average = (sum([x.rating for x in reviews_data])
537+ / float(stats.ratings_total))
538 # update UI
539 self._update_review_stats_widget(stats)
540 # update global stats cache as well
541 self.review_loader.update_review_stats(app, stats)
542-
543+
544 if my_votes:
545 self.reviews.update_useful_votes(my_votes)
546-
547+
548 if action:
549 self._review_update_single(action, single_review)
550 else:
551@@ -1042,7 +1041,7 @@
552 # We retrieved data, but nothing new. Keep going.
553 self._reviews_server_page += 1
554 self.review_loader.get_reviews(
555- self.app, self._reviews_ready_callback,
556+ self.app, self._reviews_ready_callback,
557 page=self._reviews_server_page,
558 language=self._reviews_server_language,
559 sort=self._review_sort_method,
560@@ -1069,13 +1068,13 @@
561
562 def on_weblive_exception(self, weblive, exception):
563 """ When receiving an exception, reset button and show the error """
564- error(None,"WebLive exception", exception)
565+ error(None, "WebLive exception", exception)
566 self.test_drive.set_label(_("Test drive"))
567 self.test_drive.set_sensitive(True)
568
569 def on_weblive_warning(self, weblive, warning):
570 """ When receiving a warning, just show it """
571- error(None,"WebLive warning", warning)
572+ error(None, "WebLive warning", warning)
573
574 def on_test_drive_clicked(self, button):
575 if self.weblive.client.state == "disconnected":
576@@ -1090,20 +1089,20 @@
577
578 if len(servers) == 0:
579 error(None,
580- "No available server",
581+ "No available server",
582 "There is currently no available WebLive server "
583 "for this application.\nPlease try again later.")
584 elif len(servers) == 1:
585 self.weblive.create_automatic_user_and_run_session(
586- session=cmd,serverid=servers[0].name)
587+ session=cmd, serverid=servers[0].name)
588 button.set_sensitive(False)
589 else:
590 d = ShowWebLiveServerChooserDialog(servers, self.app.pkgname)
591- serverid=None
592+ serverid = None
593 if d.run() == Gtk.ResponseType.OK:
594 for server in d.servers_vbox:
595 if server.get_active():
596- serverid=server.serverid
597+ serverid = server.serverid
598 break
599 d.destroy()
600
601@@ -1122,13 +1121,11 @@
602 self.info_vb.reorder_child(table, 0)
603 if not table.get_property('visible'):
604 table.show_all()
605- return
606
607 def _on_realize(self, widget):
608 self.addons_statusbar.hide()
609 # the install button gets initial focus
610 self.pkg_statusbar.button.grab_focus()
611- return
612
613 def _on_homepage_clicked(self, label, link):
614 import webbrowser
615@@ -1160,7 +1157,7 @@
616 self.title.set_selectable(True)
617 self.subtitle.set_line_wrap(True)
618 self.subtitle.set_selectable(True)
619- vb_inner=Gtk.VBox()
620+ vb_inner = Gtk.VBox()
621 vb_inner.pack_start(self.title, False, False, 0)
622 vb_inner.pack_start(self.subtitle, False, False, 0)
623
624@@ -1189,10 +1186,11 @@
625 # installed where widget
626 self.installed_where_hbox = Gtk.HBox()
627 self.installed_where_hbox.set_spacing(6)
628- self.installed_where_hbox.a11y = self.installed_where_hbox.get_accessible()
629+ hbox_a11y = self.installed_where_hbox.get_accessible()
630+ self.installed_where_hbox.a11y = hbox_a11y
631 vb.pack_start(self.installed_where_hbox, False, False, 0)
632
633- # the hbox that hold the description on the left and the screenshot
634+ # the hbox that hold the description on the left and the screenshot
635 # thumbnail on the right
636 body_hb = Gtk.HBox()
637 body_hb.set_spacing(12)
638@@ -1240,7 +1238,7 @@
639 self.homepage_btn = Gtk.Label()
640 self.homepage_btn.set_name("subtle-label")
641 self.homepage_btn.connect('activate-link', self._on_homepage_clicked)
642-
643+
644 # support site
645 self.support_btn = Gtk.Label()
646 self.support_btn.set_name("subtle-label")
647@@ -1275,10 +1273,12 @@
648 self.datadir, None, self.cache, self.db, self.icons, None)
649 self.recommended_for_app_panel = RecommendationsPanelDetails(catview)
650 self.recommended_for_app_panel.connect(
651- "application-activated", self._on_recommended_application_activated)
652+ "application-activated",
653+ self._on_recommended_application_activated)
654 self.recommended_for_app_panel.show_all()
655- self.info_vb.pack_start(self.recommended_for_app_panel, False, False, 0)
656-
657+ self.info_vb.pack_start(self.recommended_for_app_panel, False,
658+ False, 0)
659+
660 # package info
661 self.info_keys = []
662
663@@ -1310,14 +1310,15 @@
664 # reviews cascade
665 self.reviews.connect("new-review", self._on_review_new)
666 self.reviews.connect("report-abuse", self._on_review_report_abuse)
667- self.reviews.connect("submit-usefulness", self._on_review_submit_usefulness)
668+ self.reviews.connect("submit-usefulness",
669+ self._on_review_submit_usefulness)
670 self.reviews.connect("modify-review", self._on_review_modify)
671 self.reviews.connect("delete-review", self._on_review_delete)
672 self.reviews.connect("more-reviews-clicked",
673 self._on_more_reviews_clicked)
674- self.reviews.connect("different-review-language-clicked",
675+ self.reviews.connect("different-review-language-clicked",
676 self._on_reviews_in_different_language_clicked)
677- self.reviews.connect("review-sort-changed",
678+ self.reviews.connect("review-sort-changed",
679 self._on_review_sort_method_changed)
680 if get_distro().REVIEWS_SERVER:
681 vb.pack_start(self.reviews, False, False, 0)
682@@ -1325,15 +1326,14 @@
683 self.show_all()
684
685 # signals!
686- self.connect('size-allocate', lambda w,a: w.queue_draw())
687- return
688+ self.connect('size-allocate', lambda w, a: w.queue_draw())
689
690 def _on_recommended_application_activated(self, recwidget, app):
691 self.emit("different-application-selected", app)
692
693 def _on_review_new(self, button):
694 self._review_write_new()
695-
696+
697 def _on_review_modify(self, button, review_id):
698 self._review_modify(review_id)
699
700@@ -1347,7 +1347,7 @@
701 self._review_submit_usefulness(review_id, is_useful)
702
703 def _update_title_markup(self, appname, summary):
704- # make title font size fixed as they should look good compared to the
705+ # make title font size fixed as they should look good compared to the
706 # icon (also fixed).
707 font_size = em(1.6) * Pango.SCALE
708 markup = '<span font_size="%s"><b>%s</b></span>'
709@@ -1355,7 +1355,6 @@
710 self.title.set_markup(markup)
711 self.title.a11y.set_name(appname + '. ' + summary)
712 self.subtitle.set_markup(summary)
713- return
714
715 def _update_app_icon(self, app_details):
716 pb = self._get_icon_as_pixbuf(app_details)
717@@ -1363,13 +1362,12 @@
718 # self._show_overlay = app_details.pkg_state == PkgStates.INSTALLED
719 w, h = pb.get_width(), pb.get_height()
720
721- tw = self.APP_ICON_SIZE # target width
722+ tw = self.APP_ICON_SIZE # target width
723 if pb.get_width() < tw:
724 pb = pb.scale_simple(tw, tw, GdkPixbuf.InterpType.TILES)
725
726 self.icon.set_from_pixbuf(pb)
727 self.icon.set_size_request(self.APP_ICON_SIZE, self.APP_ICON_SIZE)
728- return
729
730 def _update_layout_error_status(self, pkg_error):
731 # if we have an error or if we need to enable a source
732@@ -1390,7 +1388,6 @@
733 self.info_vb.show()
734 for hbar in self._hbars:
735 hbar.show()
736- return
737
738 def _update_app_description(self, app_details, appname):
739 # format new app description
740@@ -1401,9 +1398,8 @@
741
742 # a11y for description
743 self.desc.description.a11y.set_name(description)
744- return
745
746- def _update_description_footer_links(self, app_details):
747+ def _update_description_footer_links(self, app_details):
748 # show or hide the homepage button and set uri if homepage specified
749 if app_details.website:
750 self.homepage_btn.show()
751@@ -1420,7 +1416,6 @@
752 self.support_btn.set_tooltip_text(app_details.supportsite)
753 else:
754 self.support_btn.hide()
755- return
756
757 def _update_app_video(self, app_details):
758 self.videoplayer.uri = app_details.video_url
759@@ -1433,20 +1428,20 @@
760 # get screenshot urls and configure the ScreenshotView...
761 if app_details.thumbnail and app_details.screenshot:
762 self.screenshot.fetch_screenshots(app_details)
763- return
764
765 def _update_weblive(self, app_details):
766- if self.weblive.client is None: return
767+ if self.weblive.client is None:
768+ return
769 self.desktop_file = app_details.desktop_file
770 # only enable test drive if we have a desktop file and exec line
771 if (not self.weblive.ready or
772- not self.weblive.is_pkgname_available_on_server(app_details.pkgname) or
773+ not self.weblive.is_pkgname_available_on_server(
774+ app_details.pkgname) or
775 not os.path.exists(self.desktop_file) or
776 not get_exec_line_from_desktop(self.desktop_file)):
777 self.test_drive.hide()
778 else:
779 self.test_drive.show()
780- return
781
782 def _update_warning_bar(self, app_details):
783 # generic error wins over HW issue
784@@ -1462,7 +1457,7 @@
785 app_details.hardware_requirements)
786 if not app_details.region_requirements_satisfied:
787 if len(s) > 0:
788- s += "\n"+REGION_WARNING_STRING
789+ s += "\n" + REGION_WARNING_STRING
790 else:
791 s = REGION_WARNING_STRING
792 self.pkg_warningbar.label.set_text(s)
793@@ -1494,7 +1489,6 @@
794 self.hardware_info.show()
795 else:
796 self.hardware_info.hide()
797- return
798
799 def _update_addons(self, app_details):
800 # refresh addons interface
801@@ -1511,7 +1505,6 @@
802
803 # Update addons state bar
804 self.addons_statusbar.configure()
805- return
806
807 def _update_all(self, app_details, skip_update_addons=False):
808 # reset view to top left
809@@ -1570,7 +1563,6 @@
810
811 # async query zeitgeist and rnr
812 self._update_usage_counter()
813- return
814
815 def _update_minimal(self, app_details):
816 self._update_app_icon(app_details)
817@@ -1583,12 +1575,11 @@
818
819 # # show where it is
820 self._configure_where_is_it()
821- return
822
823 def _add_where_is_it_commandline(self, pkgname):
824 cmdfinder = CmdFinder(self.cache)
825 cmds = cmdfinder.find_cmds_from_pkgname(pkgname)
826- if not cmds:
827+ if not cmds:
828 return
829 vb = Gtk.VBox()
830 vb.set_spacing(12)
831@@ -1604,8 +1595,8 @@
832 #~ title.set_size_request(self.get_allocation().width-24, -1)
833 vb.pack_start(title, False, False, 0)
834 cmds_str = ", ".join(cmds)
835- cmd_label = Gtk.Label(label=
836- '<span font_desc="monospace bold 9">%s</span>' % cmds_str)
837+ cmd_label = Gtk.Label(
838+ label='<span font_desc="monospace bold 9">%s</span>' % cmds_str)
839 cmd_label.set_selectable(True)
840 cmd_label.set_use_markup(True)
841 cmd_label.set_alignment(0, 0.5)
842@@ -1650,9 +1641,10 @@
843 label_name.set_text(app_info.get_name())
844
845 self.installed_where_hbox.pack_start(label_name, False, False, 0)
846- if i+1 < len(where):
847- right_arrow = Gtk.Arrow.new(Gtk.ArrowType.RIGHT, Gtk.ShadowType.NONE)
848- self.installed_where_hbox.pack_start(right_arrow,
849+ if i + 1 < len(where):
850+ right_arrow = Gtk.Arrow.new(Gtk.ArrowType.RIGHT,
851+ Gtk.ShadowType.NONE)
852+ self.installed_where_hbox.pack_start(right_arrow,
853 False, False, 0)
854
855 # create our a11y text
856@@ -1694,7 +1686,7 @@
857 # see if we have the location if its installed
858 if self.app_details.pkg_state == PkgStates.INSTALLED:
859 # first try the desktop file from the DB, then see if
860- # there is a local desktop file with the same name as
861+ # there is a local desktop file with the same name as
862 # the package
863 # try to show menu location if there is a desktop file, but
864 # never show commandline programs for apps with a desktop file
865@@ -1705,7 +1697,6 @@
866 # if there is no desktop file, show commandline
867 else:
868 self._add_where_is_it_commandline(self.app_details.pkgname)
869- return
870
871 # public API
872 def show_app(self, app, force=False):
873@@ -1714,8 +1705,8 @@
874 LOG.debug("no app selected")
875 return
876
877- same_app = (self.app and
878- self.app.pkgname and
879+ same_app = (self.app and
880+ self.app.pkgname and
881 self.app.appname == app.appname and
882 self.app.pkgname == app.pkgname)
883 #print 'SameApp:', same_app
884@@ -1745,8 +1736,9 @@
885 # update all (but skip the addons calculation if this is a
886 # DebFileApplication as this is not useful for this case and it
887 # increases the view load time dramatically)
888+ skip_update_addons = type(self.app) == DebFileApplication
889 self._update_all(self.app_details,
890- skip_update_addons=(type(self.app)==DebFileApplication))
891+ skip_update_addons=skip_update_addons)
892
893 # this is a bit silly, but without it and self.title being selectable
894 # gtk will select the entire title (which looks ugly). this grab works
895@@ -1754,18 +1746,16 @@
896 self.pkg_statusbar.button.grab_focus()
897
898 self.emit("selected", self.app)
899- return
900
901 def refresh_app(self):
902 self.show_app(self.app)
903
904-
905 # common code
906 def _review_write_new(self):
907 if (not self.app or
908 not self.app.pkgname in self.cache or
909 not self.cache[self.app.pkgname].candidate):
910- dialogs.error(None,
911+ dialogs.error(None,
912 _("Version unknown"),
913 _("The version of the application can not "
914 "be detected. Entering a review is not "
915@@ -1778,7 +1768,7 @@
916
917 # FIXME: probably want to not display the ui if we can't review it
918 if not origin:
919- dialogs.error(None,
920+ dialogs.error(None,
921 _("Origin unknown"),
922 _("The origin of the application can not "
923 "be detected. Entering a review is not "
924@@ -1787,7 +1777,8 @@
925
926 if pkg.installed:
927 version = pkg.installed.version
928- # call the loader to do call out the right helper and collect the result
929+ # call the loader to do call out the right helper and collect the
930+ # result
931 parent_xid = ''
932 #parent_xid = get_parent_xid(self)
933 self.reviews.new_review.disable()
934@@ -1796,7 +1787,7 @@
935 parent_xid, self.datadir,
936 self._reviews_ready_callback,
937 done_callback=self._submit_reviews_done_callback)
938-
939+
940 def _review_report_abuse(self, review_id):
941 parent_xid = ''
942 #parent_xid = get_parent_xid(self)
943@@ -1809,7 +1800,7 @@
944 self.review_loader.spawn_submit_usefulness_ui(
945 review_id, is_useful, parent_xid, self.datadir,
946 self._reviews_ready_callback)
947-
948+
949 def _review_modify(self, review_id):
950 parent_xid = ''
951 #parent_xid = get_parent_xid(self)
952@@ -1834,11 +1825,12 @@
953 state = self.pkg_statusbar.pkg_state
954
955 # handle purchase: install purchased has multiple steps
956- if (state == PkgStates.INSTALLING_PURCHASED and
957+ if (state == PkgStates.INSTALLING_PURCHASED and
958 result and
959 not result.pkgname):
960- self.pkg_statusbar.configure(self.app_details, PkgStates.INSTALLING_PURCHASED)
961- elif (state == PkgStates.INSTALLING_PURCHASED and
962+ self.pkg_statusbar.configure(self.app_details,
963+ PkgStates.INSTALLING_PURCHASED)
964+ elif (state == PkgStates.INSTALLING_PURCHASED and
965 result and
966 result.pkgname):
967 self.pkg_statusbar.configure(self.app_details, PkgStates.INSTALLED)
968@@ -1846,7 +1838,8 @@
969 self.reviews.configure_reviews_ui()
970 # normal states
971 elif state == PkgStates.REMOVING:
972- self.pkg_statusbar.configure(self.app_details, PkgStates.UNINSTALLED)
973+ self.pkg_statusbar.configure(self.app_details,
974+ PkgStates.UNINSTALLED)
975 elif state == PkgStates.INSTALLING:
976 self.pkg_statusbar.configure(self.app_details, PkgStates.INSTALLED)
977 elif state == PkgStates.UPGRADING:
978@@ -1862,15 +1855,16 @@
979 # reset the reviews UI now that we have installed the package
980 self.reviews.configure_reviews_ui()
981 elif state == PkgStates.UNINSTALLED:
982- self.pkg_statusbar.configure(self.app_details, PkgStates.UNINSTALLED)
983+ self.pkg_statusbar.configure(self.app_details,
984+ PkgStates.UNINSTALLED)
985 self.adjustment_value = None
986-
987+
988 if self.addons_statusbar.applying:
989 self.addons_statusbar.applying = False
990
991 return False
992
993- def _on_transaction_started(self, backend, pkgname, appname, trans_id,
994+ def _on_transaction_started(self, backend, pkgname, appname, trans_id,
995 trans_type):
996 if self.addons_statusbar.applying:
997 self.pkg_statusbar.configure(self.app_details, AppActions.APPLY)
998@@ -1879,32 +1873,32 @@
999 state = self.pkg_statusbar.pkg_state
1000 LOG.debug("_on_transaction_started %s" % state)
1001 if state == PkgStates.NEEDS_PURCHASE:
1002- self.pkg_statusbar.configure(self.app_details,
1003+ self.pkg_statusbar.configure(self.app_details,
1004 PkgStates.INSTALLING_PURCHASED)
1005 elif (state == PkgStates.UNINSTALLED or
1006 state == PkgStates.FORCE_VERSION):
1007- self.pkg_statusbar.configure(self.app_details, PkgStates.INSTALLING)
1008+ self.pkg_statusbar.configure(self.app_details,
1009+ PkgStates.INSTALLING)
1010 elif state == PkgStates.INSTALLED:
1011 self.pkg_statusbar.configure(self.app_details, PkgStates.REMOVING)
1012 elif state == PkgStates.UPGRADABLE:
1013 self.pkg_statusbar.configure(self.app_details, PkgStates.UPGRADING)
1014 elif state == PkgStates.REINSTALLABLE:
1015- self.pkg_statusbar.configure(self.app_details, PkgStates.INSTALLING)
1016+ self.pkg_statusbar.configure(self.app_details,
1017+ PkgStates.INSTALLING)
1018 # FIXME: is there a way to tell if we are installing/removing?
1019 # we will assume that it is being installed, but this means that
1020 # during removals we get the text "Installing.."
1021- # self.pkg_statusbar.configure(self.app_details, PkgStates.REMOVING)
1022- return
1023+ # self.pkg_statusbar.configure(self.app_details,
1024+ # PkgStates.REMOVING)
1025
1026 def _on_transaction_stopped(self, backend, result):
1027 self.pkg_statusbar.progress.hide()
1028 self._update_interface_on_trans_ended(result)
1029- return
1030
1031 def _on_transaction_finished(self, backend, result):
1032 self.pkg_statusbar.progress.hide()
1033 self._update_interface_on_trans_ended(result)
1034- return
1035
1036 def _on_transaction_progress_changed(self, backend, pkgname, progress):
1037 if (self.app_details and
1038@@ -1915,11 +1909,10 @@
1039 self.pkg_statusbar.combo_multiple_versions.hide()
1040 self.pkg_statusbar.progress.show()
1041 if pkgname in backend.pending_transactions:
1042- self.pkg_statusbar.progress.set_fraction(progress/100.0)
1043+ self.pkg_statusbar.progress.set_fraction(progress / 100.0)
1044 if progress >= 100:
1045 self.pkg_statusbar.progress.set_fraction(1)
1046 self.adjustment_value = self.get_vadjustment().get_value()
1047- return
1048
1049 def get_app_icon_details(self):
1050 """ helper for unity dbus support to provide details about the
1051@@ -1941,7 +1934,7 @@
1052 else:
1053 icon_size = pb.get_height()
1054 return icon_size
1055-
1056+
1057 def _get_app_icon_xy_position_on_screen(self):
1058 """ helper for unity dbus support to get the x,y position of
1059 the application icon as it is displayed on-screen. if the icon's
1060@@ -1954,15 +1947,15 @@
1061 parent = parent.get_parent()
1062 # get x, y relative to toplevel
1063 try:
1064- (x,y) = self.icon.translate_coordinates(parent, 0, 0)
1065+ (x, y) = self.icon.translate_coordinates(parent, 0, 0)
1066 except Exception as e:
1067 LOG.warning("couldn't translate icon coordinates on-screen "
1068 "for unity dbus message: %s" % e)
1069- return (0,0)
1070+ return (0, 0)
1071 # get toplevel window position
1072 (px, py) = parent.get_position()
1073- return (px+x, py+y)
1074-
1075+ return (px + x, py + y)
1076+
1077 def _get_icon_as_pixbuf(self, app_details):
1078 if app_details.icon:
1079 if self.icons.has_icon(app_details.icon):
1080@@ -1978,9 +1971,10 @@
1081 LOG.debug("did not find the icon locally, must download it")
1082
1083 def on_image_download_complete(downloader, image_file_path):
1084- # when the download is complete, replace the icon in the
1085+ # when the download is complete, replace the icon in the
1086 # view with the downloaded one
1087- logging.debug("_get_icon_as_pixbuf:image_downloaded() %s" % image_file_path)
1088+ logging.debug("_get_icon_as_pixbuf:image_downloaded() %s" %
1089+ image_file_path)
1090 try:
1091 pb = GdkPixbuf.Pixbuf.new_from_file(image_file_path)
1092 # fixes crash in testsuite if window is destroyed
1093@@ -1989,15 +1983,17 @@
1094 if self.icon.get_property("visible"):
1095 self.icon.set_from_pixbuf(pb)
1096 except Exception as e:
1097- LOG.warning("couldn't load downloadable icon file '%s': %s" % (image_file_path, e))
1098-
1099+ LOG.warning(
1100+ "couldn't load downloadable icon file '%s': %s" %
1101+ (image_file_path, e))
1102+
1103 image_downloader = SimpleFileDownloader()
1104 image_downloader.connect(
1105 'file-download-complete', on_image_download_complete)
1106 image_downloader.download_file(
1107 app_details.icon_url, app_details.cached_icon_file_path)
1108 return self.icons.load_icon(Icons.MISSING_APP, self.APP_ICON_SIZE, 0)
1109-
1110+
1111 def update_totalsize(self):
1112 if not self.totalsize_info.get_property('visible'):
1113 return False
1114@@ -2013,7 +2009,7 @@
1115 self.addons_manager.addons_to_remove,
1116 self.app.archive_suite)
1117 total_download_size, total_install_size = res
1118- if res==(0,0) and type(self.app)==DebFileApplication:
1119+ if res == (0, 0) and type(self.app) == DebFileApplication:
1120 total_install_size = self.app_details.installed_size
1121 if total_download_size > 0:
1122 download_size = GLib.format_size(total_download_size)
1123@@ -2032,22 +2028,21 @@
1124 elif total_install_size < 0:
1125 remove_size = GLib.format_size(-total_install_size)
1126 label_string += _("%s to be freed") % (remove_size)
1127-
1128+
1129 self.totalsize_info.set_value(label_string or _("Unknown"))
1130 # self.totalsize_info.show_all()
1131 return False
1132
1133 def set_section(self, section):
1134 self.section = section
1135- return
1136-
1137+
1138 def _update_usage_counter(self):
1139 """ try to get the usage counter from zeitgeist """
1140 def _zeitgeist_callback(counter):
1141 LOG.debug("zeitgeist usage: %s" % counter)
1142 if counter == 0:
1143 # this probably means we just have no idea about it,
1144- # so instead of saying "Used: never" we just return
1145+ # so instead of saying "Used: never" we just return
1146 # this can go away when zeitgeist captures more events
1147 # --there are still cases when we really do want to hide this
1148 self.usage.hide()
1149@@ -2055,7 +2050,7 @@
1150 if counter <= 100:
1151 label_string = gettext.ngettext("Used: one time",
1152 "Used: %(amount)s times",
1153- counter) % { 'amount' : counter, }
1154+ counter) % {'amount': counter}
1155 else:
1156 label_string = _("Used: over 100 times")
1157 self.usage.set_text('<small>%s</small>' % label_string)
1158@@ -2070,6 +2065,7 @@
1159 # LOG.warning("could not update the usage counter: %s " % e)
1160 # self.usage.hide()
1161
1162+
1163 def get_test_window_appdetails():
1164
1165 from softwarecenter.db.pkginfo import get_pkg_info
1166@@ -2082,7 +2078,7 @@
1167 db = StoreDatabase(pathname, cache)
1168 db.open()
1169
1170- import softwarecenter.paths
1171+ import softwarecenter.paths
1172 datadir = softwarecenter.paths.datadir
1173
1174 from softwarecenter.ui.gtk3.utils import get_sc_icon_theme
1175@@ -2090,7 +2086,7 @@
1176
1177 import softwarecenter.distro
1178 distro = softwarecenter.distro.get_distro()
1179-
1180+
1181 # gui
1182 win = Gtk.Window()
1183 scroll = Gtk.ScrolledWindow()
1184@@ -2118,7 +2114,7 @@
1185 scroll.add(view)
1186 scroll.show()
1187 win.add(scroll)
1188- win.set_size_request(600,800)
1189+ win.set_size_request(600, 800)
1190 win.show()
1191 win.connect('destroy', Gtk.main_quit)
1192 win.set_data("view", view)
1193@@ -2132,7 +2128,7 @@
1194 else:
1195 view.show_app(Application("Movie Player", "totem"))
1196 return True
1197-
1198+
1199 win = get_test_window_appdetails()
1200
1201 # keep it spinning to test for re-draw issues and memleaks
1202
1203=== modified file 'test/test_pep8.py'
1204--- test/test_pep8.py 2012-03-14 16:34:56 +0000
1205+++ test/test_pep8.py 2012-03-14 23:52:20 +0000
1206@@ -18,7 +18,7 @@
1207 softwarecenter.ui.gtk3.views,
1208 softwarecenter.ui.gtk3.widgets,
1209 softwarecenter.db.pkginfo_impl]
1210- exclude = ['appdetailsview.py']
1211+ exclude = []
1212
1213 def message(self, text):
1214 self.errors.append(text)