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

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2856
Proposed branch: lp:~elachuni/software-center/pep8-test-part13
Merge into: lp:software-center
Prerequisite: lp:~elachuni/software-center/pep8-test-part12
Diff against target: 1029 lines (+202/-165)
8 files modified
softwarecenter/ui/gtk3/dialogs/__init__.py (+27/-23)
softwarecenter/ui/gtk3/dialogs/deauthorize_dialog.py (+16/-12)
softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py (+24/-15)
softwarecenter/ui/gtk3/models/appstore2.py (+66/-61)
softwarecenter/ui/gtk3/models/navlogstore.py (+0/-1)
softwarecenter/ui/gtk3/models/pendingstore.py (+26/-21)
softwarecenter/ui/gtk3/models/viewstore.py (+39/-32)
test/test_pep8.py (+4/-0)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part13
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+97555@code.launchpad.net

Description of the change

Made all files in softwarecenter.ui.gtk3.models and softwarecenter.ui.gtk3.dialogs pep8-compliant

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

Lucky 13, thanks 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/dialogs/__init__.py'
2--- softwarecenter/ui/gtk3/dialogs/__init__.py 2011-12-15 08:43:58 +0000
3+++ softwarecenter/ui/gtk3/dialogs/__init__.py 2012-03-15 01:44:19 +0000
4@@ -24,12 +24,13 @@
5
6 from gettext import gettext as _
7
8+
9 class SimpleGtkbuilderDialog(object):
10 def __init__(self, datadir, domain):
11 # setup ui
12 self.builder = Gtk.Builder()
13 self.builder.set_translation_domain(domain)
14- self.builder.add_from_file(datadir+"/ui/gtk3/dialogs.ui")
15+ self.builder.add_from_file(datadir + "/ui/gtk3/dialogs.ui")
16 self.builder.connect_signals(self)
17 for o in self.builder.get_objects():
18 if issubclass(type(o), Gtk.Buildable):
19@@ -37,13 +38,14 @@
20 setattr(self, name, o)
21
22 # for unitesting only
23-_DIALOG=None
24+_DIALOG = None
25+
26
27 def confirm_repair_broken_cache(parent, datadir):
28 glade_dialog = SimpleGtkbuilderDialog(datadir, domain="software-center")
29 dialog = glade_dialog.dialog_broken_cache
30 global _DIALOG
31- _DIALOG=dialog
32+ _DIALOG = dialog
33 dialog.set_default_size(380, -1)
34 dialog.set_transient_for(parent)
35 result = dialog.run()
36@@ -52,15 +54,16 @@
37 return True
38 return False
39
40+
41 class DetailsMessageDialog(Gtk.MessageDialog):
42 """Message dialog with optional details expander"""
43 def __init__(self,
44- parent=None,
45- title="",
46- primary=None,
47- secondary=None,
48+ parent=None,
49+ title="",
50+ primary=None,
51+ secondary=None,
52 details=None,
53- buttons=Gtk.ButtonsType.OK,
54+ buttons=Gtk.ButtonsType.OK,
55 type=Gtk.MessageType.INFO):
56 Gtk.MessageDialog.__init__(self, parent, 0, type, buttons, primary)
57 self.set_title(title)
58@@ -71,7 +74,8 @@
59 textview.get_buffer().set_text(details)
60 scroll = Gtk.ScrolledWindow()
61 scroll.set_size_request(500, 300)
62- scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
63+ scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
64+ Gtk.PolicyType.AUTOMATIC)
65 scroll.add(textview)
66 expand = Gtk.Expander().new(_("Details"))
67 expand.add(scroll)
68@@ -81,31 +85,33 @@
69 self.set_modal(True)
70 self.set_property("skip-taskbar-hint", True)
71
72-def messagedialog(parent=None,
73- title="",
74- primary=None,
75- secondary=None,
76+
77+def messagedialog(parent=None,
78+ title="",
79+ primary=None,
80+ secondary=None,
81 details=None,
82- buttons=Gtk.ButtonsType.OK,
83+ buttons=Gtk.ButtonsType.OK,
84 type=Gtk.MessageType.INFO,
85 alternative_action=None):
86 """ run a dialog """
87 dialog = DetailsMessageDialog(parent=parent, title=title,
88 primary=primary, secondary=secondary,
89- details=details, type=type,
90+ details=details, type=type,
91 buttons=buttons)
92 global _DIALOG
93- _DIALOG=dialog
94+ _DIALOG = dialog
95 if alternative_action:
96 dialog.add_button(alternative_action, Gtk.ResponseType.YES)
97 result = dialog.run()
98 dialog.destroy()
99 return result
100
101+
102 def error(parent, primary, secondary, details=None, alternative_action=None):
103 """ show a untitled error dialog """
104 return messagedialog(parent=parent,
105- primary=primary,
106+ primary=primary,
107 secondary=secondary,
108 details=details,
109 type=Gtk.MessageType.ERROR,
110@@ -114,17 +120,15 @@
111
112 if __name__ == "__main__":
113 print("Running remove dialog")
114-
115+
116 print("Running broken apt-cache dialog")
117 confirm_repair_broken_cache(None, "./data")
118-
119+
120 print("Showing message dialog")
121 messagedialog(None, primary="first, no second")
122 print("showing error")
123 error(None, "first", "second")
124 error(None, "first", "second", "details ......")
125- res = error(None, "first", "second", "details ......", alternative_action="Do Something Else")
126+ res = error(None, "first", "second", "details ......",
127+ alternative_action="Do Something Else")
128 print "res: ", res
129-
130-
131-
132
133=== modified file 'softwarecenter/ui/gtk3/dialogs/deauthorize_dialog.py'
134--- softwarecenter/ui/gtk3/dialogs/deauthorize_dialog.py 2011-08-09 08:47:43 +0000
135+++ softwarecenter/ui/gtk3/dialogs/deauthorize_dialog.py 2012-03-15 01:44:19 +0000
136@@ -33,7 +33,9 @@
137 #FIXME: These need to come from the main app
138 ICON_SIZE = 24
139
140-def deauthorize_computer(parent, datadir, db, icons, account_name, purchased_packages):
141+
142+def deauthorize_computer(parent, datadir, db, icons, account_name,
143+ purchased_packages):
144 """ Display a dialog to deauthorize the current computer for purchases
145 """
146 cache = db._aptcache
147@@ -41,7 +43,7 @@
148
149 (primary, button_text) = distro.get_deauthorize_text(account_name,
150 purchased_packages)
151-
152+
153 # build the dialog
154 glade_dialog = SimpleGtkbuilderDialog(datadir, domain="software-center")
155 dialog = glade_dialog.dialog_deauthorize
156@@ -54,24 +56,26 @@
157 if (icon_name is None or
158 not icons.has_icon(icon_name)):
159 icon_name = Icons.MISSING_APP
160- glade_dialog.image_icon.set_from_icon_name(icon_name,
161+ glade_dialog.image_icon.set_from_icon_name(icon_name,
162 Gtk.IconSize.DIALOG)
163
164 # set the texts
165- glade_dialog.label_deauthorize_primary.set_text("<span font_weight=\"bold\" font_size=\"large\">%s</span>" % primary)
166+ glade_dialog.label_deauthorize_primary.set_text(
167+ "<span font_weight=\"bold\" font_size=\"large\">%s</span>" % primary)
168 glade_dialog.label_deauthorize_primary.set_use_markup(True)
169 glade_dialog.button_deauthorize_do.set_label(button_text)
170
171 # add the list of packages to remove, if there are any
172 if len(purchased_packages) > 0:
173- view = PackageNamesView(_("Deauthorize"), cache, purchased_packages, icons, ICON_SIZE, db)
174+ view = PackageNamesView(_("Deauthorize"), cache, purchased_packages,
175+ icons, ICON_SIZE, db)
176 view.set_headers_visible(False)
177 # FIXME: work out how not to select?/focus?/activate? first item
178 glade_dialog.scrolledwindow_purchased_packages.add(view)
179 glade_dialog.scrolledwindow_purchased_packages.show_all()
180 else:
181 glade_dialog.viewport_purchased_packages.hide()
182-
183+
184 result = dialog.run()
185 dialog.hide()
186 if result == Gtk.ResponseType.ACCEPT:
187@@ -80,7 +84,8 @@
188
189
190 if __name__ == "__main__":
191- import sys, os
192+ import sys
193+ import os
194
195 if len(sys.argv) > 1:
196 datadir = sys.argv[1]
197@@ -120,7 +125,7 @@
198 db.open()
199 except xapian.DatabaseCorruptError as e:
200 logging.exception("xapian open failed")
201- dialogs.error(None,
202+ dialogs.error(None,
203 _("Sorry, can not open the software database"),
204 _("Please re-install the 'software-center' "
205 "package."))
206@@ -134,13 +139,12 @@
207 purchased_packages.add('chromium-browser')
208 purchased_packages.add('cheese')
209 purchased_packages.add('aisleriot')
210-
211+
212 account_name = "max.fischer@rushmoreacademy.edu"
213
214- deauthorize_computer(None,
215- "./data",
216+ deauthorize_computer(None,
217+ "./data",
218 db,
219 icons,
220 account_name,
221 purchased_packages)
222-
223
224=== modified file 'softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py'
225--- softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py 2011-10-17 09:21:58 +0000
226+++ softwarecenter/ui/gtk3/dialogs/dependency_dialogs.py 2012-03-15 01:44:19 +0000
227@@ -35,10 +35,12 @@
228 ICON_SIZE = 24
229
230 # for the unittests only
231-_DIALOG=None
232+_DIALOG = None
233+
234+
235 def confirm_install(parent, datadir, app, db, icons):
236 """Confirm install of the given app
237-
238+
239 (currently only shows a dialog if a installed app needs to be removed
240 in order to install the application)
241 """
242@@ -51,15 +53,18 @@
243 depends = cache.get_packages_removed_on_install(appdetails.pkg)
244 if not depends:
245 return True
246- (primary, button_text) = distro.get_install_warning_text(cache, appdetails.pkg, app.name, depends)
247- return _confirm_internal(parent, datadir, app, db, icons, primary, button_text, depends, cache)
248+ (primary, button_text) = distro.get_install_warning_text(cache,
249+ appdetails.pkg, app.name, depends)
250+ return _confirm_internal(parent, datadir, app, db, icons, primary,
251+ button_text, depends, cache)
252+
253
254 def confirm_remove(parent, datadir, app, db, icons):
255 """ Confirm removing of the given app """
256 cache = db._aptcache
257 distro = get_distro()
258 appdetails = app.get_details(db)
259- # FIXME: use
260+ # FIXME: use
261 # backend = get_install_backend()
262 # backend.simulate_remove(app.pkgname)
263 # once it works
264@@ -70,9 +75,12 @@
265 return True
266 (primary, button_text) = distro.get_removal_warning_text(
267 db._aptcache, appdetails.pkg, app.name, depends)
268- return _confirm_internal(parent, datadir, app, db, icons, primary, button_text, depends, cache)
269-
270-def _get_confirm_internal_dialog(parent, datadir, app, db, icons, primary, button_text, depends, cache):
271+ return _confirm_internal(parent, datadir, app, db, icons, primary,
272+ button_text, depends, cache)
273+
274+
275+def _get_confirm_internal_dialog(parent, datadir, app, db, icons, primary,
276+ button_text, depends, cache):
277 glade_dialog = SimpleGtkbuilderDialog(datadir, domain="software-center")
278 dialog = glade_dialog.dialog_dependency_alert
279 dialog.set_resizable(True)
280@@ -85,26 +93,29 @@
281 if (icon_name is None or
282 not icons.has_icon(icon_name)):
283 icon_name = Icons.MISSING_APP
284- glade_dialog.image_package_icon.set_from_icon_name(icon_name,
285+ glade_dialog.image_package_icon.set_from_icon_name(icon_name,
286 Gtk.IconSize.DIALOG)
287
288 # set the texts
289- glade_dialog.label_dependency_primary.set_text("<span font_weight=\"bold\" font_size=\"large\">%s</span>" % primary)
290+ glade_dialog.label_dependency_primary.set_text(
291+ "<span font_weight=\"bold\" font_size=\"large\">%s</span>" % primary)
292 glade_dialog.label_dependency_primary.set_use_markup(True)
293 glade_dialog.button_dependency_do.set_label(button_text)
294
295 # add the dependencies
296- view = PackageNamesView(_("Dependency"), cache, depends, icons, ICON_SIZE, db)
297+ view = PackageNamesView(_("Dependency"), cache, depends, icons, ICON_SIZE,
298+ db)
299 view.set_headers_visible(False)
300 # FIXME: work out how not to select?/focus?/activate? first item
301 glade_dialog.scrolledwindow_dependencies.add(view)
302 glade_dialog.scrolledwindow_dependencies.show_all()
303 return dialog
304
305+
306 def _confirm_internal(*args):
307 dialog = _get_confirm_internal_dialog(*args)
308 global _DIALOG
309- _DIALOG=dialog
310+ _DIALOG = dialog
311 result = dialog.run()
312 dialog.hide()
313 if result == Gtk.ResponseType.ACCEPT:
314@@ -112,8 +123,6 @@
315 return False
316
317
318-
319-
320 def get_test_dialog():
321 import softwarecenter
322 from softwarecenter.db.application import Application
323@@ -132,7 +141,7 @@
324 db=db, icons=icons, primary=primary, button_text=button_text,
325 depends=depends, cache=db._aptcache)
326 return dia
327-
328+
329
330 if __name__ == "__main__":
331
332
333=== modified file 'softwarecenter/ui/gtk3/models/appstore2.py'
334--- softwarecenter/ui/gtk3/models/appstore2.py 2012-03-08 15:22:19 +0000
335+++ softwarecenter/ui/gtk3/models/appstore2.py 2012-03-15 01:44:19 +0000
336@@ -24,11 +24,15 @@
337
338 from gettext import gettext as _
339
340-from softwarecenter.enums import (Icons,
341+from softwarecenter.enums import (Icons,
342 XapianValues)
343
344
345-from softwarecenter.utils import ExecutionTime, SimpleFileDownloader, split_icon_ext
346+from softwarecenter.utils import (
347+ ExecutionTime,
348+ SimpleFileDownloader,
349+ split_icon_ext,
350+ )
351 from softwarecenter.backend import get_install_backend
352 from softwarecenter.backend.reviews import get_review_loader
353 from softwarecenter.paths import SOFTWARE_CENTER_ICON_CACHE_DIR
354@@ -44,8 +48,9 @@
355 LOG = logging.getLogger(__name__)
356 _FREE_AS_IN_BEER = ("0.00", "")
357
358+
359 class CategoryRowReference:
360- """ A simple container for Category properties to be
361+ """ A simple container for Category properties to be
362 displayed in a AppListStore or AppTreeStore
363 """
364
365@@ -55,7 +60,6 @@
366 #self.subcategories = subcats
367 self.pkg_count = pkg_count
368 self.vis_count = pkg_count
369- return
370
371
372 class UncategorisedRowRef(CategoryRowReference):
373@@ -70,7 +74,6 @@
374 untranslated_name,
375 display_name,
376 None, pkg_count)
377- return
378
379
380 class AppPropertiesHelper(GObject.GObject):
381@@ -79,13 +82,14 @@
382 """
383
384 __gsignals__ = {
385- "needs-refresh" : (GObject.SignalFlags.RUN_LAST,
386- None,
387- (str, ),
388- ),
389+ "needs-refresh": (GObject.SignalFlags.RUN_LAST,
390+ None,
391+ (str, ),
392+ ),
393 }
394
395- def __init__(self, db, cache, icons, icon_size=48, global_icon_cache=False):
396+ def __init__(self, db, cache, icons, icon_size=48,
397+ global_icon_cache=False):
398 GObject.GObject.__init__(self)
399 self.db = db
400 self.cache = cache
401@@ -102,31 +106,35 @@
402 self.icons = icons
403 self.icon_size = icon_size
404
405- # cache the 'missing icon' used in the treeview for apps without an icon
406+ # cache the 'missing icon' used in the treeview for apps without an
407+ # icon
408 self._missing_icon = icons.load_icon(Icons.MISSING_APP, icon_size, 0)
409 if global_icon_cache:
410 self.icon_cache = _app_icon_cache
411 else:
412 self.icon_cache = {}
413- return
414
415 def _download_icon_and_show_when_ready(self, url, pkgname, icon_file_name):
416- LOG.debug("did not find the icon locally, must download %s" % icon_file_name)
417+ LOG.debug("did not find the icon locally, must download %s" %
418+ icon_file_name)
419
420 def on_image_download_complete(downloader, image_file_path, pkgname):
421 LOG.debug("download for '%s' complete" % image_file_path)
422 pb = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file_path,
423 self.icon_size,
424 self.icon_size)
425- # replace the icon in the icon_cache now that we've got the real one
426+ # replace the icon in the icon_cache now that we've got the real
427+ # one
428 icon_file = split_icon_ext(os.path.basename(image_file_path))
429 self.icon_cache[icon_file] = pb
430 self.emit("needs-refresh", pkgname)
431-
432+
433 if url is not None:
434- icon_file_path = os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, icon_file_name)
435+ icon_file_path = os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR,
436+ icon_file_name)
437 image_downloader = SimpleFileDownloader()
438- image_downloader.connect('file-download-complete', on_image_download_complete, pkgname)
439+ image_downloader.connect('file-download-complete',
440+ on_image_download_complete, pkgname)
441 image_downloader.download_file(url, icon_file_path)
442
443 def update_availability(self, doc):
444@@ -134,7 +142,6 @@
445 doc.installed = None
446 doc.purchasable = None
447 self.is_installed(doc)
448- return
449
450 def is_available(self, doc):
451 if doc.available is None:
452@@ -152,7 +159,8 @@
453
454 def is_purchasable(self, doc):
455 if doc.purchasable is None:
456- doc.purchasable = doc.get_value(XapianValues.PRICE) not in _FREE_AS_IN_BEER
457+ doc.purchasable = (doc.get_value(XapianValues.PRICE) not in
458+ _FREE_AS_IN_BEER)
459 return doc.purchasable
460
461 def get_pkgname(self, doc):
462@@ -195,7 +203,7 @@
463 # icons.load_icon takes between 0.001 to 0.01s on my
464 # machine, this is a significant burden because get_value
465 # is called *a lot*. caching is the only option
466-
467+
468 # look for the icon on the iconpath
469 if self.icons.has_icon(icon_name):
470 icon = self.icons.load_icon(icon_name, self.icon_size, 0)
471@@ -224,11 +232,11 @@
472 return -1
473
474 def _category_translate(self, catname):
475- """ helper that will look into the categories we got from the
476+ """ helper that will look into the categories we got from the
477 parser and returns the translated name if it find it,
478 otherwise it resorts to plain gettext
479 """
480- # look into parsed categories that use .directory translation
481+ # look into parsed categories that use .directory translation
482 for cat in self.all_categories:
483 if cat.untranslated_name == catname:
484 return cat.name
485@@ -271,17 +279,20 @@
486 ICON_SIZE = 32
487
488 # the amount of items to initially lo
489- LOAD_INITIAL = 75
490+ LOAD_INITIAL = 75
491
492 def __init__(self, db, cache, icons, icon_size, global_icon_cache):
493- AppPropertiesHelper.__init__(self, db, cache, icons, icon_size,
494+ AppPropertiesHelper.__init__(self, db, cache, icons, icon_size,
495 global_icon_cache)
496
497 # backend stuff
498 self.backend = get_install_backend()
499- self.backend.connect("transaction-progress-changed", self._on_transaction_progress_changed)
500- self.backend.connect("transaction-started", self._on_transaction_started)
501- self.backend.connect("transaction-finished", self._on_transaction_finished)
502+ self.backend.connect("transaction-progress-changed",
503+ self._on_transaction_progress_changed)
504+ self.backend.connect("transaction-started",
505+ self._on_transaction_started)
506+ self.backend.connect("transaction-finished",
507+ self._on_transaction_finished)
508
509 # keep track of paths for transactions in progress
510 self.transaction_path_map = {}
511@@ -294,12 +305,12 @@
512
513 # other stuff
514 self.active = False
515- return
516
517- # FIXME: port from
518+ # FIXME: port from
519 @property
520 def installable_apps(self):
521 return []
522+
523 @property
524 def existing_apps(self):
525 return []
526@@ -307,15 +318,15 @@
527 def notify_action_request(self, doc, path):
528 pkgname = str(self.get_pkgname(doc))
529 self.transaction_path_map[pkgname] = (path, self.get_iter(path))
530- return
531
532 def set_from_matches(self, matches):
533 # stub
534 raise NotImplementedError
535
536 # the following methods ensure that the contents data is refreshed
537- # whenever a transaction potentially changes it:
538- def _on_transaction_started(self, backend, pkgname, appname, trans_id, trans_type):
539+ # whenever a transaction potentially changes it:
540+ def _on_transaction_started(self, backend, pkgname, appname, trans_id,
541+ trans_type):
542 #~ self._refresh_transaction_map()
543 pass
544
545@@ -323,7 +334,6 @@
546 if pkgname in self.transaction_path_map:
547 path, it = self.transaction_path_map[pkgname]
548 self.row_changed(path, it)
549- return
550
551 def _on_transaction_finished(self, backend, result):
552 pkgname = str(result.pkgname)
553@@ -356,16 +366,17 @@
554 #~ print "Appstore buffered icons in %s seconds" % t_lapsed
555 #from softwarecenter.utils import get_nice_size
556 #~ cache_size = get_nice_size(sys.getsizeof(_app_icon_cache))
557- #~ print "Number of icons in cache: %s consuming: %sb" % (len(_app_icon_cache), cache_size)
558+ #~ print "Number of icons in cache: %s consuming: %sb" % (
559+ #~ len(_app_icon_cache), cache_size)
560 return False # remove from sources on completion
561
562 if self.current_matches is not None:
563 GObject.idle_add(buffer_icons)
564- return
565
566 def load_range(self, indices, step):
567 # stub
568- return
569+ pass
570+
571
572 class AppListStore(Gtk.ListStore, AppGenericStore):
573 """ use for flat applist views. for large lists this appends rows approx
574@@ -373,18 +384,18 @@
575 """
576
577 __gsignals__ = {
578- "appcount-changed" : (GObject.SignalFlags.RUN_LAST,
579- None,
580- (GObject.TYPE_PYOBJECT, ),
581- ),
582+ "appcount-changed": (GObject.SignalFlags.RUN_LAST,
583+ None,
584+ (GObject.TYPE_PYOBJECT, ),
585+ ),
586 # meh, this is a signal from AppPropertiesHelper
587- "needs-refresh" : (GObject.SignalFlags.RUN_LAST,
588- None,
589- (str, ),
590- ),
591+ "needs-refresh": (GObject.SignalFlags.RUN_LAST,
592+ None,
593+ (str, ),
594+ ),
595 }
596
597- def __init__(self, db, cache, icons, icon_size=AppGenericStore.ICON_SIZE,
598+ def __init__(self, db, cache, icons, icon_size=AppGenericStore.ICON_SIZE,
599 global_icon_cache=True):
600 AppGenericStore.__init__(
601 self, db, cache, icons, icon_size, global_icon_cache)
602@@ -392,8 +403,6 @@
603 self.set_column_types(self.COL_TYPES)
604
605 self.current_matches = None
606- return
607-
608
609 def set_from_matches(self, matches):
610 """ set the content of the liststore based on a list of
611@@ -401,9 +410,9 @@
612 """
613 self.current_matches = matches
614 n_matches = len(matches)
615- if n_matches == 0:
616+ if n_matches == 0:
617 return
618-
619+
620 extent = min(self.LOAD_INITIAL, n_matches)
621
622 with ExecutionTime("store.append_initial"):
623@@ -411,7 +420,7 @@
624 doc.available = doc.installed = doc.purchasable = None
625 self.append((doc,))
626
627- if n_matches == extent:
628+ if n_matches == extent:
629 return
630
631 with ExecutionTime("store.append_placeholders"):
632@@ -420,7 +429,6 @@
633
634 self.emit('appcount-changed', len(matches))
635 self.buffer_icons()
636- return
637
638 def load_range(self, indices, step):
639 db = self.db.xapiandb
640@@ -440,39 +448,37 @@
641 except IndexError:
642 break
643
644- if row_content: continue
645+ if row_content:
646+ continue
647 doc = db.get_document(matches[i].docid)
648 doc.available = doc.installed = doc.purchasable = None
649 self[(i,)][0] = doc
650- return
651
652 def clear(self):
653 # reset the tranaction map because it will now be invalid
654 self.transaction_path_map = {}
655 self.current_matches = None
656 Gtk.ListStore.clear(self)
657- return
658
659
660 class AppTreeStore(Gtk.TreeStore, AppGenericStore):
661 """ A treestore based application model
662 """
663
664- def __init__(self, db, cache, icons, icon_size=AppGenericStore.ICON_SIZE,
665+ def __init__(self, db, cache, icons, icon_size=AppGenericStore.ICON_SIZE,
666 global_icon_cache=True):
667 AppGenericStore.__init__(
668 self, db, cache, icons, icon_size, global_icon_cache)
669 Gtk.TreeStore.__init__(self)
670 self.set_column_types(self.COL_TYPES)
671- return
672
673 def set_documents(self, parent, documents):
674 for doc in documents:
675- doc.available = None; doc.installed = doc.purchasable = None
676+ doc.available = None
677+ doc.installed = doc.purchasable = None
678 self.append(parent, (doc,))
679
680 self.transaction_path_map = {}
681- return
682
683 def set_category_documents(self, cat, documents):
684 category = CategoryRowReference(cat.untranslated_name,
685@@ -484,7 +490,8 @@
686 self.set_documents(it, documents)
687 return it
688
689- def set_nocategory_documents(self, documents, untranslated_name=None, display_name=None):
690+ def set_nocategory_documents(self, documents, untranslated_name=None,
691+ display_name=None):
692 category = UncategorisedRowRef(untranslated_name,
693 display_name,
694 len(documents))
695@@ -496,5 +503,3 @@
696 # reset the tranaction map because it will now be invalid
697 self.transaction_path_map = {}
698 Gtk.TreeStore.clear(self)
699- return
700-
701
702=== modified file 'softwarecenter/ui/gtk3/models/navlogstore.py'
703--- softwarecenter/ui/gtk3/models/navlogstore.py 2011-07-12 12:37:27 +0000
704+++ softwarecenter/ui/gtk3/models/navlogstore.py 2012-03-15 01:44:19 +0000
705@@ -1,1 +0,0 @@
706-
707
708=== modified file 'softwarecenter/ui/gtk3/models/pendingstore.py'
709--- softwarecenter/ui/gtk3/models/pendingstore.py 2011-12-02 14:45:05 +0000
710+++ softwarecenter/ui/gtk3/models/pendingstore.py 2012-03-15 01:44:19 +0000
711@@ -17,25 +17,25 @@
712
713 # column names
714 (COL_TID,
715- COL_ICON,
716- COL_NAME,
717- COL_STATUS,
718+ COL_ICON,
719+ COL_NAME,
720+ COL_STATUS,
721 COL_PROGRESS,
722 COL_PULSE,
723 COL_CANCEL) = range(7)
724
725 # column types
726- column_types = (str, # COL_TID
727+ column_types = (str, # COL_TID
728 GdkPixbuf.Pixbuf, # COL_ICON
729- str, # COL_NAME
730- str, # COL_STATUS
731- float, # COL_PROGRESS
732- int, # COL_PULSE
733- str) # COL_CANCEL
734+ str, # COL_NAME
735+ str, # COL_STATUS
736+ float, # COL_PROGRESS
737+ int, # COL_PULSE
738+ str) # COL_CANCEL
739
740 # icons
741 PENDING_STORE_ICON_CANCEL = Gtk.STOCK_CANCEL
742- PENDING_STORE_ICON_NO_CANCEL = "" # Gtk.STOCK_YES
743+ PENDING_STORE_ICON_NO_CANCEL = "" # Gtk.STOCK_YES
744
745 ICON_SIZE = 24
746
747@@ -46,7 +46,7 @@
748
749 self._transactions_watcher = get_transactions_watcher()
750 self._transactions_watcher.connect("lowlevel-transactions-changed",
751- self._on_lowlevel_transactions_changed)
752+ self._on_lowlevel_transactions_changed)
753 # data
754 self.icons = icons
755 # the apt-daemon stuff
756@@ -62,8 +62,10 @@
757 del sig
758 self._signals = []
759
760- def _on_lowlevel_transactions_changed(self, watcher, current_tid, pending_tids):
761- logging.debug("on_transaction_changed %s (%s)" % (current_tid, len(pending_tids)))
762+ def _on_lowlevel_transactions_changed(self, watcher, current_tid,
763+ pending_tids):
764+ logging.debug("on_transaction_changed %s (%s)" % (current_tid,
765+ len(pending_tids)))
766 self.clear()
767 for tid in [current_tid] + pending_tids:
768 if not tid:
769@@ -79,11 +81,13 @@
770 # add pending purchases as pseudo transactions
771 for pkgname in self.backend.pending_purchases:
772 iconname = self.backend.pending_purchases[pkgname].iconname
773- icon = get_icon_from_theme(self.icons, iconname=iconname, iconsize=self.ICON_SIZE)
774+ icon = get_icon_from_theme(self.icons, iconname=iconname,
775+ iconsize=self.ICON_SIZE)
776 appname = self.backend.pending_purchases[pkgname].appname
777 status_text = self._render_status_text(
778 appname or pkgname, _(u'Installing purchase\u2026'))
779- self.append([pkgname, icon, pkgname, status_text, float(0), 1, None])
780+ self.append([pkgname, icon, pkgname, status_text, float(0), 1,
781+ None])
782
783 def _pulse_purchase_helper(self):
784 for item in self:
785@@ -105,7 +109,7 @@
786 trans.connect("status-changed", self._on_status_changed))
787 self._signals.append(
788 trans.connect(
789- "cancellable-changed",self._on_cancellable_changed))
790+ "cancellable-changed", self._on_cancellable_changed))
791
792 if "sc_appname" in trans.meta_data:
793 appname = trans.meta_data["sc_appname"]
794@@ -121,15 +125,16 @@
795 except KeyError:
796 icon = get_icon_from_theme(self.icons, iconsize=self.ICON_SIZE)
797 else:
798- icon = get_icon_from_theme(self.icons, iconname=iconname, iconsize=self.ICON_SIZE)
799+ icon = get_icon_from_theme(self.icons, iconname=iconname,
800+ iconsize=self.ICON_SIZE)
801 if trans.is_waiting():
802 status = trans.status_details
803 else:
804 status = trans.get_status_description()
805 status_text = self._render_status_text(appname, status)
806 cancel_icon = self._get_cancel_icon(trans.cancellable)
807- self.append([trans.tid, icon, appname, status_text, float(trans.progress),
808- -1, cancel_icon])
809+ self.append([trans.tid, icon, appname, status_text,
810+ float(trans.progress), -1, cancel_icon])
811
812 def _on_cancellable_changed(self, trans, cancellable):
813 #print "_on_allow_cancel: ", trans, allow_cancel
814@@ -161,7 +166,8 @@
815 total_bytes_str = GLib.format_size(total_bytes)
816 status = _("Downloaded %s of %s") % \
817 (current_bytes_str, total_bytes_str)
818- row[self.COL_STATUS] = self._render_status_text(name, status)
819+ row[self.COL_STATUS] = self._render_status_text(name,
820+ status)
821
822 def _on_progress_changed(self, trans, progress):
823 # print "_on_progress_changed: ", trans, progress
824@@ -187,4 +193,3 @@
825 if not name:
826 name = ""
827 return "%s\n<small>%s</small>" % (utf8(name), utf8(status))
828-
829
830=== modified file 'softwarecenter/ui/gtk3/models/viewstore.py'
831--- softwarecenter/ui/gtk3/models/viewstore.py 2011-07-05 13:52:07 +0000
832+++ softwarecenter/ui/gtk3/models/viewstore.py 2012-03-15 01:44:19 +0000
833@@ -32,8 +32,9 @@
834
835 LOG = logging.getLogger(__name__)
836
837+
838 class ViewStore(Gtk.TreeStore):
839-
840+
841 # columns
842 (COL_ICON,
843 COL_NAME,
844@@ -44,27 +45,29 @@
845
846 ICON_SIZE = 24
847
848- ANIMATION_PATH = "/usr/share/icons/hicolor/24x24/status/softwarecenter-progress.png"
849-
850- __gsignals__ = {'channels-refreshed':(GObject.SignalFlags.RUN_FIRST,
851- None,
852- ())}
853-
854+ ANIMATION_PATH = ("/usr/share/icons/hicolor/24x24/status/"
855+ "softwarecenter-progress.png")
856+
857+ __gsignals__ = {'channels-refreshed': (GObject.SignalFlags.RUN_FIRST,
858+ None,
859+ ())}
860
861 def __init__(self, view_manager, datadir, db, cache, icons):
862 Gtk.TreeStore.__init__(self)
863- self.set_column_types((GObject.TYPE_PYOBJECT, # COL_ICON
864- str, # COL_NAME
865- GObject.TYPE_PYOBJECT, # COL_ACTION
866- GObject.TYPE_PYOBJECT, # COL_CHANNEL
867- str, # COL_BUBBLE_TEXT
868- )) # must match columns above
869+ self.set_column_types((GObject.TYPE_PYOBJECT, # COL_ICON
870+ str, # COL_NAME
871+ GObject.TYPE_PYOBJECT, # COL_ACTION
872+ GObject.TYPE_PYOBJECT, # COL_CHANNEL
873+ str, # COL_BUBBLE_TEXT
874+ )) # must match columns above
875 self.view_manager = view_manager
876 self.icons = icons
877 self.datadir = datadir
878 self.backend = get_install_backend()
879- self.backend.connect("transactions-changed", self.on_transactions_changed)
880- self.backend.connect("transaction-finished", self.on_transaction_finished)
881+ self.backend.connect("transactions-changed",
882+ self.on_transactions_changed)
883+ self.backend.connect("transaction-finished",
884+ self.on_transaction_finished)
885 self.db = db
886 self.cache = cache
887 self.distro = get_distro()
888@@ -74,13 +77,15 @@
889
890 # first, the availablepane items
891 available_icon = self._get_icon("softwarecenter")
892- self.available_iter = self.append(None, [available_icon, _("Get Software"), ViewPages.AVAILABLE, None, None])
893+ self.available_iter = self.append(None, [available_icon,
894+ _("Get Software"), ViewPages.AVAILABLE, None, None])
895
896 # the installedpane items
897 icon = self._get_icon("computer")
898- self.installed_iter = self.append(None, [icon, _("Installed Software"), ViewPages.INSTALLED, None, None])
899-
900- # the channelpane
901+ self.installed_iter = self.append(None, [icon, _("Installed Software"),
902+ ViewPages.INSTALLED, None, None])
903+
904+ # the channelpane
905 self.channel_manager = ChannelsManager(db, icons)
906 # do initial channel list update
907 self._update_channel_list()
908@@ -89,13 +94,15 @@
909 icon = self._get_icon("document-open-recent")
910 self.append(None, [icon, _("History"), ViewPages.HISTORY, None, None])
911 icon = None
912- self.append(None, [icon, "<span size='1'> </span>", ViewPages.SEPARATOR_1, None, None])
913-
914+ self.append(None, [icon, "<span size='1'> </span>",
915+ ViewPages.SEPARATOR_1, None, None])
916+
917 # the progress pane is build on demand
918
919 # emit a transactions-changed signal to ensure that we display any
920 # pending transactions
921- self.backend.emit("transactions-changed", self.backend.pending_transactions)
922+ self.backend.emit("transactions-changed",
923+ self.backend.pending_transactions)
924
925 def on_transactions_changed(self, backend, total_transactions):
926 LOG.debug("on_transactions_changed '%s'" % total_transactions)
927@@ -108,13 +115,13 @@
928 else:
929 icon = GdkPixbuf.new_from_file(self.ANIMATION_PATH)
930 #~ icon.start()
931- self.append(None, [icon, _("In Progress..."),
932+ self.append(None, [icon, _("In Progress..."),
933 ViewPages.PENDING, None, str(pending)])
934 else:
935 for (i, row) in enumerate(self):
936 if row[self.COL_ACTION] == ViewPages.PENDING:
937 del self[(i,)]
938-
939+
940 def on_transaction_finished(self, backend, result):
941 if result.success:
942 self._update_channel_list_installed_view()
943@@ -123,19 +130,20 @@
944 def get_channel_iter_for_name(self, channel_name, installed_only):
945 """ get the liststore iterator for the given name, consider
946 installed-only too because channel names may be duplicated
947- """
948+ """
949 LOG.debug("get_channel_iter_for_name %s %s" % (channel_name,
950 installed_only))
951+
952 def _get_iter_for_channel_name(it):
953 """ internal helper """
954 while it:
955 if self.get_value(it, self.COL_NAME) == channel_name:
956 return it
957 it = self.iter_next(it)
958- return None
959
960 # check root iter first
961- channel_iter_for_name = _get_iter_for_channel_name(self.get_iter_first())
962+ channel_iter_for_name = _get_iter_for_channel_name(
963+ self.get_iter_first())
964 if channel_iter_for_name:
965 LOG.debug("found '%s' on root level" % channel_name)
966 return channel_iter_for_name
967@@ -149,7 +157,7 @@
968 child = self.iter_children(parent_iter)
969 channel_iter_for_name = _get_iter_for_channel_name(child)
970 return channel_iter_for_name
971-
972+
973 def _get_icon(self, icon_name):
974 return self.icons.load_icon(icon_name, 22, 0)
975
976@@ -158,7 +166,7 @@
977 self._update_channel_list_available_view()
978 self._update_channel_list_installed_view()
979 self.emit("channels-refreshed")
980-
981+
982 # FIXME: this way of updating is really not ideal because it
983 # will trigger set_cursor signals and that causes the
984 # UI to behave funny if the user is in a channel view
985@@ -167,7 +175,7 @@
986 # check what needs to be cleared. we need to append first, kill
987 # afterward because otherwise a row without children is collapsed
988 # by the view.
989- #
990+ #
991 # normally GtkTreeIters have a limited life-cycle and are no
992 # longer valid after the model changed, fortunately with the
993 # Gtk.TreeStore (that we use) they are persisent
994@@ -187,7 +195,7 @@
995 # delete the old ones
996 for child in iters_to_kill:
997 self.remove(child)
998-
999+
1000 def _update_channel_list_installed_view(self):
1001 # see comments for _update_channel_list_available_view() method above
1002 child = self.iter_children(self.installed_iter)
1003@@ -224,4 +232,3 @@
1004 # delete the old ones
1005 for child in iters_to_kill:
1006 self.remove(child)
1007-
1008
1009=== modified file 'test/test_pep8.py'
1010--- test/test_pep8.py 2012-03-15 01:44:19 +0000
1011+++ test/test_pep8.py 2012-03-15 01:44:19 +0000
1012@@ -8,6 +8,8 @@
1013
1014 # Only test these two packages for now:
1015 import softwarecenter.db.pkginfo_impl
1016+import softwarecenter.ui.gtk3.dialogs
1017+import softwarecenter.ui.gtk3.models
1018 import softwarecenter.ui.gtk3.panes
1019 import softwarecenter.ui.gtk3.session
1020 import softwarecenter.ui.gtk3.views
1021@@ -17,6 +19,8 @@
1022 class PackagePep8TestCase(unittest.TestCase):
1023 maxDiff = None
1024 packages = [softwarecenter.ui.qml,
1025+ softwarecenter.ui.gtk3.dialogs,
1026+ softwarecenter.ui.gtk3.models,
1027 softwarecenter.ui.gtk3.panes,
1028 softwarecenter.ui.gtk3.session,
1029 softwarecenter.ui.gtk3.views,