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

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2861
Proposed branch: lp:~elachuni/software-center/pep8-test-part15
Merge into: lp:software-center
Prerequisite: lp:~elachuni/software-center/pep8-test-part14
Diff against target: 2453 lines (+532/-450)
10 files modified
softwarecenter/ui/gtk3/SimpleGtkbuilderApp.py (+1/-1)
softwarecenter/ui/gtk3/app.py (+109/-77)
softwarecenter/ui/gtk3/aptd_gtk3.py (+7/-7)
softwarecenter/ui/gtk3/drawing.py (+26/-21)
softwarecenter/ui/gtk3/em.py (+14/-10)
softwarecenter/ui/gtk3/gmenusearch.py (+24/-21)
softwarecenter/ui/gtk3/review_gui_helper.py (+293/-231)
softwarecenter/ui/gtk3/shapes.py (+47/-63)
softwarecenter/ui/gtk3/utils.py (+9/-7)
test/test_pep8.py (+2/-12)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part15
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+97567@code.launchpad.net

Description of the change

All files under softwarecenter/ui/gtk3/ now pass the pep8 test.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/SimpleGtkbuilderApp.py'
2--- softwarecenter/ui/gtk3/SimpleGtkbuilderApp.py 2011-08-11 09:25:56 +0000
3+++ softwarecenter/ui/gtk3/SimpleGtkbuilderApp.py 2012-03-15 03:21:21 +0000
4@@ -21,6 +21,7 @@
5
6 from gi.repository import Gtk
7
8+
9 # based on SimpleGladeApp
10 class SimpleGtkbuilderApp:
11
12@@ -54,4 +55,3 @@
13 after a program is finished by pressing Control-C.
14 """
15 pass
16-
17
18=== modified file 'softwarecenter/ui/gtk3/app.py'
19--- softwarecenter/ui/gtk3/app.py 2012-03-07 13:19:41 +0000
20+++ softwarecenter/ui/gtk3/app.py 2012-03-15 03:21:21 +0000
21@@ -71,7 +71,7 @@
22 from softwarecenter.db.database import StoreDatabase
23 try:
24 from aptd_gtk3 import InstallBackendUI
25- InstallBackendUI # pyflakes
26+ InstallBackendUI # pyflakes
27 except:
28 from softwarecenter.backend.installbackend import InstallBackendUI
29
30@@ -96,7 +96,10 @@
31
32 from softwarecenter.backend.channel import AllInstalledChannel
33 from softwarecenter.backend.reviews import get_review_loader, UsefulnessCache
34-from softwarecenter.backend.oneconfhandler import get_oneconf_handler, is_oneconf_available
35+from softwarecenter.backend.oneconfhandler import (
36+ get_oneconf_handler,
37+ is_oneconf_available,
38+)
39 from softwarecenter.distro import get_distro
40 from softwarecenter.db.pkginfo import get_pkg_info
41
42@@ -105,10 +108,12 @@
43
44 LOG = logging.getLogger(__name__)
45
46+
47 # py3 compat
48 def callable(func):
49 return isinstance(func, collections.Callable)
50
51+
52 class SoftwarecenterDbusController(dbus.service.Object):
53 """
54 This is a helper to provide the SoftwarecenterIFace
55@@ -164,11 +169,11 @@
56 #~ self.useful_cache = UsefulnessCache(True)
57 #~ self.setup_database_rebuilding_listener()
58 #~ # open plugin manager and load plugins
59- #~ self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)
60+ #~ self.plugin_manager = PluginManager(self,
61+ #~ SOFTWARE_CENTER_PLUGIN_DIRS)
62 #~ self.plugin_manager.load_plugins()
63
64
65-
66 class SoftwareCenterAppGtk3(SimpleGtkbuilderApp):
67
68 WEBLINK_URL = "http://apt.ubuntu.com/p/%s"
69@@ -183,7 +188,7 @@
70
71 self.datadir = datadir
72 SimpleGtkbuilderApp.__init__(self,
73- datadir+"/ui/gtk3/SoftwareCenter.ui",
74+ datadir + "/ui/gtk3/SoftwareCenter.ui",
75 "software-center")
76 gettext.bindtextdomain("software-center", "/usr/share/locale")
77 gettext.textdomain("software-center")
78@@ -215,7 +220,7 @@
79 self._use_axi = not options.disable_apt_xapian_index
80 try:
81 self.db = StoreDatabase(pathname, self.cache)
82- self.db.open(use_axi = self._use_axi)
83+ self.db.open(use_axi=self._use_axi)
84 if self.db.schema_version() != DB_SCHEMA_VERSION:
85 LOG.warn("database format '%s' expected, but got '%s'" % (
86 DB_SCHEMA_VERSION, self.db.schema_version()))
87@@ -224,8 +229,8 @@
88 except xapian.DatabaseOpeningError:
89 # Couldn't use that folder as a database
90 # This may be because we are in a bzr checkout and that
91- # folder is empty. If the folder is empty, and we can find the
92- # script that does population, populate a database in it.
93+ # folder is empty. If the folder is empty, and we can find
94+ # the script that does population, populate a database in it.
95 if os.path.isdir(pathname) and not os.listdir(pathname):
96 self._rebuild_and_reopen_local_db(pathname)
97 except xapian.DatabaseCorruptError:
98@@ -245,12 +250,14 @@
99 with ExecutionTime("creating the backend"):
100 self.backend = get_install_backend()
101 self.backend.ui = InstallBackendUI()
102- self.backend.connect("transaction-finished", self._on_transaction_finished)
103+ self.backend.connect("transaction-finished",
104+ self._on_transaction_finished)
105 self.backend.connect("channels-changed", self.on_channels_changed)
106
107 # high level app management
108 with ExecutionTime("get the app-manager"):
109- self.app_manager = ApplicationManager(self.db, self.backend, self.icons)
110+ self.app_manager = ApplicationManager(self.db, self.backend,
111+ self.icons)
112
113 # misc state
114 self._block_menuitem_view = False
115@@ -280,7 +287,8 @@
116 self.view_manager = ViewManager(self.notebook_view, options)
117
118 with ExecutionTime("building panes"):
119- self.global_pane = GlobalPane(self.view_manager, self.datadir, self.db, self.cache, self.icons)
120+ self.global_pane = GlobalPane(self.view_manager, self.datadir,
121+ self.db, self.cache, self.icons)
122 self.vbox1.pack_start(self.global_pane, False, False, 0)
123 self.vbox1.reorder_child(self.global_pane, 1)
124
125@@ -292,8 +300,10 @@
126 self.datadir,
127 self.navhistory_back_action,
128 self.navhistory_forward_action)
129- self.available_pane.connect("available-pane-created", self.on_available_pane_created)
130- self.view_manager.register(self.available_pane, ViewPages.AVAILABLE)
131+ self.available_pane.connect("available-pane-created",
132+ self.on_available_pane_created)
133+ self.view_manager.register(self.available_pane,
134+ ViewPages.AVAILABLE)
135
136 # installed pane (view not fully initialized at this point)
137 self.installed_pane = InstalledPane(self.cache,
138@@ -301,8 +311,10 @@
139 self.distro,
140 self.icons,
141 self.datadir)
142- #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created)
143- self.view_manager.register(self.installed_pane, ViewPages.INSTALLED)
144+ #~ self.installed_pane.connect("installed-pane-created",
145+ #~ self.on_installed_pane_created)
146+ self.view_manager.register(self.installed_pane,
147+ ViewPages.INSTALLED)
148
149 # history pane (not fully loaded at this point)
150 self.history_pane = HistoryPane(self.cache,
151@@ -316,8 +328,10 @@
152 self.pending_pane = PendingPane(self.icons)
153 self.view_manager.register(self.pending_pane, ViewPages.PENDING)
154
155- # TRANSLATORS: this is the help menuitem label, e.g. Ubuntu Software Center _Help
156- self.menuitem_help.set_label(_("%s _Help")%self.distro.get_app_name())
157+ # TRANSLATORS: this is the help menuitem label,
158+ # e.g. Ubuntu Software Center _Help
159+ self.menuitem_help.set_label(_("%s _Help") %
160+ self.distro.get_app_name())
161
162 # specify the smallest allowable window size
163 self.window_main.set_size_request(730, 470)
164@@ -326,14 +340,16 @@
165 with ExecutionTime("create review loader"):
166 self.review_loader = get_review_loader(self.cache, self.db)
167 # FIXME: add some kind of throttle, I-M-S here
168- self.review_loader.refresh_review_stats(self.on_review_stats_loaded)
169+ self.review_loader.refresh_review_stats(
170+ self.on_review_stats_loaded)
171 #load usefulness votes from server when app starts
172 self.useful_cache = UsefulnessCache(True)
173 self.setup_database_rebuilding_listener()
174
175 with ExecutionTime("create plugin manager"):
176 # open plugin manager and load plugins
177- self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)
178+ self.plugin_manager = PluginManager(self,
179+ SOFTWARE_CENTER_PLUGIN_DIRS)
180 self.plugin_manager.load_plugins()
181
182 # setup window name and about information (needs branding)
183@@ -345,20 +361,23 @@
184
185 # about dialog
186 self.aboutdialog.connect("response", lambda dialog, rid: dialog.hide())
187- self.aboutdialog.connect("delete_event", lambda w,e: self.aboutdialog.hide_on_delete())
188+ self.aboutdialog.connect("delete_event",
189+ lambda w, e: self.aboutdialog.hide_on_delete())
190
191 # restore state
192 self.config = get_config()
193 self.restore_state()
194
195 # Adapt menu entries
196- supported_menuitem = self.builder.get_object("menuitem_view_supported_only")
197+ supported_menuitem = self.builder.get_object(
198+ "menuitem_view_supported_only")
199 supported_menuitem.set_label(self.distro.get_supported_filter_name())
200 file_menu = self.builder.get_object("menu1")
201
202 if not self.distro.DEVELOPER_URL:
203 help_menu = self.builder.get_object("menu_help")
204- developer_separator = self.builder.get_object("separator_developer")
205+ developer_separator = self.builder.get_object(
206+ "separator_developer")
207 help_menu.remove(developer_separator)
208 developer_menuitem = self.builder.get_object("menuitem_developer")
209 help_menu.remove(developer_menuitem)
210@@ -366,39 +385,41 @@
211 # Check if oneconf is available
212 och = is_oneconf_available()
213 if not och:
214- file_menu.remove(self.builder.get_object("menuitem_sync_between_computers"))
215+ file_menu.remove(self.builder.get_object(
216+ "menuitem_sync_between_computers"))
217
218- # restore the state of the add to launcher menu item, or remove the menu
219- # item if Unity is not currently running
220+ # restore the state of the add to launcher menu item, or remove the
221+ # menu item if Unity is not currently running
222 add_to_launcher_menuitem = self.builder.get_object(
223- "menuitem_add_to_launcher")
224+ "menuitem_add_to_launcher")
225 if is_unity_running():
226 add_to_launcher_menuitem.set_active(
227 self.available_pane.add_to_launcher_enabled)
228 else:
229 view_menu = self.builder.get_object("menu_view")
230 add_to_launcher_separator = self.builder.get_object(
231- "add_to_launcher_separator")
232+ "add_to_launcher_separator")
233 view_menu.remove(add_to_launcher_separator)
234 view_menu.remove(add_to_launcher_menuitem)
235
236 # run s-c-agent update
237 if options.disable_buy or not self.distro.PURCHASE_APP_URL:
238- file_menu.remove(self.builder.get_object("menuitem_reinstall_purchases"))
239+ file_menu.remove(self.builder.get_object(
240+ "menuitem_reinstall_purchases"))
241 if not (options.enable_lp or och):
242 file_menu.remove(self.builder.get_object("separator_login"))
243 else:
244 # running the agent will trigger a db reload so we do it later
245 GObject.timeout_add_seconds(30, self._run_software_center_agent)
246
247-
248 # keep the cache clean
249 GObject.timeout_add_seconds(15, self._run_expunge_cache_helper)
250
251 # TODO: Remove the following two lines once we have remove repository
252 # support in aptdaemon (see LP: #723911)
253 file_menu = self.builder.get_object("menu1")
254- file_menu.remove(self.builder.get_object("menuitem_deauthorize_computer"))
255+ file_menu.remove(self.builder.get_object(
256+ "menuitem_deauthorize_computer"))
257
258 # keep track of the current active pane
259 self.active_pane = self.available_pane
260@@ -412,7 +433,6 @@
261 except Exception, e:
262 LOG.debug("launchpad integration error: '%s'" % e)
263
264-
265 # helper
266 def _run_software_center_agent(self):
267 """ helper that triggers the update-software-center-agent helper """
268@@ -462,10 +482,9 @@
269 elif "http_proxy" in os.environ:
270 del os.environ["http_proxy"]
271
272-
273 # callbacks
274 def on_realize(self, widget):
275- return
276+ pass
277
278 def on_available_pane_created(self, widget):
279 self.available_pane.searchentry.grab_focus()
280@@ -490,7 +509,8 @@
281 self.recommender_uuid = ""
282
283 def _on_update_software_center_agent_finished(self, pid, condition):
284- LOG.info("software-center-agent finished with status %i" % os.WEXITSTATUS(condition))
285+ LOG.info("software-center-agent finished with status %i" %
286+ os.WEXITSTATUS(condition))
287 if os.WEXITSTATUS(condition) == 0:
288 self.db.reopen()
289
290@@ -524,7 +544,8 @@
291 self.menuitem_undo.activate()
292
293 if (event.keyval == Gdk.keyval_from_name("Z") and
294- event.state == (Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK)):
295+ event.state == (Gdk.ModifierType.SHIFT_MASK |
296+ Gdk.ModifierType.CONTROL_MASK)):
297 self.menuitem_edit.activate()
298 if self.menuitem_redo.get_sensitive():
299 self.menuitem_redo.activate()
300@@ -550,7 +571,8 @@
301
302 # copy web link
303 if (event.keyval == Gdk.keyval_from_name("C") and
304- event.state == (Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK)):
305+ event.state == (Gdk.ModifierType.SHIFT_MASK |
306+ Gdk.ModifierType.CONTROL_MASK)):
307 self.menuitem_edit.activate()
308 if self.menuitem_copy_web_link.get_sensitive():
309 self.menuitem_copy_web_link.activate()
310@@ -609,7 +631,8 @@
311 def _on_lp_login(self, lp, token):
312 self._lp_login_successful = True
313 private_archives = self.glaunchpad.get_subscribed_archives()
314- self.view_switcher.get_model().channel_manager.feed_in_private_sources_list_entries(
315+ channel_manager = self.view_switcher.get_model().channel_manager
316+ channel_manager.feed_in_private_sources_list_entries(
317 private_archives)
318
319 def _on_sso_login(self, sso, oauth_result):
320@@ -621,20 +644,21 @@
321
322 def _on_style_updated(self, widget, init_css_callback, *args):
323 init_css_callback(widget, *args)
324- return
325
326 def _available_for_me_result(self, scagent, result_list):
327 #print "available_for_me_result", result_list
328 from softwarecenter.db.update import (
329 add_from_purchased_but_needs_reinstall_data)
330- self.available_for_me_query = add_from_purchased_but_needs_reinstall_data(
331- result_list, self.db, self.cache)
332- self.available_pane.on_previous_purchases_activated(self.available_for_me_query)
333+ available = add_from_purchased_but_needs_reinstall_data(result_list,
334+ self.db, self.cache)
335+ self.available_for_me_query = available
336+ self.available_pane.on_previous_purchases_activated(available)
337
338 def get_icon_filename(self, iconname, iconsize):
339 iconinfo = self.icons.lookup_icon(iconname, iconsize, 0)
340 if not iconinfo:
341- iconinfo = self.icons.lookup_icon(Icons.MISSING_APP_ICON, iconsize, 0)
342+ iconinfo = self.icons.lookup_icon(Icons.MISSING_APP_ICON,
343+ iconsize, 0)
344 return iconinfo.get_filename()
345
346 # File Menu
347@@ -668,18 +692,20 @@
348 # update menu items
349 pkg_state = None
350 error = None
351- # FIXME: Use a Gtk.Action for the Install/Remove/Buy/Add Source/Update Now action
352- # so that all UI controls (menu item, applist view button and appdetails
353- # view button) are managed centrally: button text, button sensitivity,
354- # and callback method
355+ # FIXME: Use a Gtk.Action for the Install/Remove/Buy/Add Source/Update
356+ # Now action so that all UI controls (menu item, applist view
357+ # button and appdetails view button) are managed centrally:
358+ # button text, button sensitivity, and callback method
359 # FIXME: Add buy support here by implementing the above
360 appdetails = app.get_details(self.db)
361 if appdetails:
362 pkg_state = appdetails.pkg_state
363 error = appdetails.error
364- if app.pkgname in self.active_pane.app_view.tree_view._action_block_list:
365+ if (app.pkgname in
366+ self.active_pane.app_view.tree_view._action_block_list):
367 return False
368- elif pkg_state == PkgStates.UPGRADABLE or pkg_state == PkgStates.REINSTALLABLE and not error:
369+ elif (pkg_state == PkgStates.UPGRADABLE or
370+ pkg_state == PkgStates.REINSTALLABLE and not error):
371 self.menuitem_install.set_sensitive(True)
372 self.menuitem_remove.set_sensitive(True)
373 elif pkg_state == PkgStates.INSTALLED:
374@@ -689,7 +715,8 @@
375 elif (not pkg_state and
376 not self.active_pane.is_category_view_showing() and
377 app.pkgname in self.cache and
378- not app.pkgname in self.active_pane.app_view.tree_view._action_block_list and
379+ not app.pkgname in
380+ self.active_pane.app_view.tree_view._action_block_list and
381 not error):
382 # when does this happen?
383 pkg = self.cache[app.pkgname]
384@@ -712,7 +739,7 @@
385 #appname = _("Ubuntu Software Center")
386 appname = SOFTWARE_CENTER_NAME_KEYRING
387 help_text = _("To reinstall previous purchases, sign in to the "
388- "Ubuntu Single Sign-On account you used to pay for them.")
389+ "Ubuntu Single Sign-On account you used to pay for them.")
390 #window = self.window_main.get_window()
391 #xid = self.get_window().xid
392 xid = 0
393@@ -729,14 +756,16 @@
394 if not self.scagent:
395 from softwarecenter.backend.scagent import SoftwareCenterAgent
396 self.scagent = SoftwareCenterAgent()
397- self.scagent.connect("available-for-me", self._available_for_me_result)
398+ self.scagent.connect("available-for-me",
399+ self._available_for_me_result)
400
401 def on_menuitem_reinstall_purchases_activate(self, menuitem):
402 self.view_manager.set_active_view(ViewPages.AVAILABLE)
403 self.available_pane.show_appview_spinner()
404 if self.available_for_me_query:
405 # we already have the list of available items, so just show it
406- self.available_pane.on_previous_purchases_activated(self.available_for_me_query)
407+ self.available_pane.on_previous_purchases_activated(
408+ self.available_for_me_query)
409 else:
410 # fetch the list of available items and show it
411 self._create_scagent_if_needed()
412@@ -749,15 +778,12 @@
413 account_name = None
414
415 # get a list of installed purchased packages
416- installed_purchased_packages = self.db.get_installed_purchased_packages()
417+ installed_purchases = self.db.get_installed_purchased_packages()
418
419 # display the deauthorize computer dialog
420 deauthorize = deauthorize_dialog.deauthorize_computer(None,
421- self.datadir,
422- self.db,
423- self.icons,
424- account_name,
425- installed_purchased_packages)
426+ self.datadir, self.db, self.icons, account_name,
427+ installed_purchases)
428 if deauthorize:
429 # clear the ubuntu SSO token for this account
430 clear_token_from_ubuntu_sso(SOFTWARE_CENTER_NAME_KEYRING)
431@@ -765,16 +791,17 @@
432 # uninstall the list of purchased packages
433 # TODO: do we need to check for dependencies and show a removal
434 # dialog for that case? seems not since these are purchased apps
435- for pkgname in installed_purchased_packages:
436+ for pkgname in installed_purchases:
437 app = Application(pkgname=pkgname)
438 appdetails = app.get_details(self.db)
439 self.backend.remove(app, appdetails.icon)
440
441 # TODO: remove the corresponding private PPA sources
442- # FIXME: this should really be done using aptdaemon, update this if/when
443- # remove repository support is added to aptdaemon
444+ # FIXME: this should really be done using aptdaemon, update this
445+ # if/when remove repository support is added to aptdaemon
446 # (private-ppa.launchpad.net_commercial-ppa-uploaders*)
447- purchased_sources = glob.glob("/etc/apt/sources.list.d/private-ppa.launchpad.net_commercial-ppa-uploaders*")
448+ purchased_sources = glob.glob("/etc/apt/sources.list.d/"
449+ "private-ppa.launchpad.net_commercial-ppa-uploaders*")
450 for source in purchased_sources:
451 print("source: %s" % source)
452
453@@ -855,9 +882,9 @@
454 self.active_pane.is_app_details_view_showing()):
455
456 self.menuitem_select_all.set_sensitive(True)
457- sel_text = self.active_pane.app_details_view.desc.get_selected_text()
458+ desc = self.active_pane.app_details_view.desc
459
460- if sel_text:
461+ if desc.get_selected_text():
462 self.menuitem_copy.set_sensitive(True)
463
464 def on_menuitem_undo_activate(self, menuitem):
465@@ -898,7 +925,7 @@
466 app = self.active_pane.get_current_app()
467 if app:
468 display = Gdk.Display.get_default()
469- selection = Gdk.Atom.intern ("CLIPBOARD", False)
470+ selection = Gdk.Atom.intern("CLIPBOARD", False)
471 clipboard = Gtk.Clipboard.get_for_display(display, selection)
472 clipboard.set_text(self.WEBLINK_URL % app.pkgname, -1)
473
474@@ -980,7 +1007,7 @@
475 self.available_pane.refresh_apps()
476 try:
477 self.installed_pane.refresh_apps()
478- except: # may not be initialised
479+ except: # may not be initialised
480 pass
481
482 def on_menuitem_view_supported_only_activate(self, widget):
483@@ -993,13 +1020,15 @@
484 self.available_pane.refresh_apps()
485 try:
486 self.installed_pane.refresh_apps()
487- except: # may not be initialised
488+ except: # may not be initialised
489 pass
490
491 # navigate up if the details page is no longer available
492 #~ ap = self.active_pane
493- #~ if (ap and ap.is_app_details_view_showing and ap.app_details_view.app and
494- #~ not self.distro.is_supported(self.cache, None, ap.app_details_view.app.pkgname)):
495+ #~ if (ap and ap.is_app_details_view_showing and
496+ #~ ap.app_details_view.app and
497+ #~ not self.distro.is_supported(self.cache, None,
498+ #~ ap.app_details_view.app.pkgname)):
499 #~ if len(ap.app_view.get_model()) == 0:
500 #~ ap.navigation_bar.navigate_up_twice()
501 #~ else:
502@@ -1016,7 +1045,8 @@
503 vm = get_viewmanager()
504 vm.nav_back()
505
506- def on_navhistory_forward_action_activate(self, navhistory_forward_action=None):
507+ def on_navhistory_forward_action_activate(self,
508+ navhistory_forward_action=None):
509 vm = get_viewmanager()
510 vm.nav_forward()
511
512@@ -1031,7 +1061,7 @@
513
514 def on_menuitem_help_activate(self, menuitem):
515 # run yelp
516- p = subprocess.Popen(["yelp","ghelp:software-center"])
517+ p = subprocess.Popen(["yelp", "ghelp:software-center"])
518 # collect the exit status (otherwise we leave zombies)
519 GObject.timeout_add_seconds(1, lambda p: p.poll() == None, p)
520
521@@ -1111,7 +1141,9 @@
522 res = iface.IsRebuilding()
523 self._on_database_rebuilding_handler(res)
524 except Exception as e:
525- LOG.debug("query for the update-database exception '%s' (probably ok)" % e)
526+ LOG.debug(
527+ "query for the update-database exception '%s' (probably ok)" %
528+ e)
529
530 # add signal handler
531 bus.add_signal_receiver(self._on_database_rebuilding_handler,
532@@ -1140,7 +1172,7 @@
533 iface.bringToFront('nothing-to-show')
534 sys.exit()
535 except dbus.DBusException:
536- bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter',bus)
537+ bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)
538 self.dbusControler = SoftwarecenterDbusController(self, bus_name)
539
540 def show_available_packages(self, packages):
541@@ -1209,9 +1241,9 @@
542 (x, y) = self.config.get("general", "size").split(",")
543 self.window_main.set_default_size(int(x), int(y))
544 else:
545- # on first launch, specify the default window size to take advantage
546- # of the available screen real estate (but set a reasonable limit
547- # in case of a crazy-huge monitor)
548+ # on first launch, specify the default window size to take
549+ # advantage of the available screen real estate (but set a
550+ # reasonable limit in case of a crazy-huge monitor)
551 screen_height = Gdk.Screen.height()
552 screen_width = Gdk.Screen.width()
553 self.window_main.set_default_size(
554@@ -1247,7 +1279,7 @@
555 self.config.set("general", "maximized", "False")
556 # size only matters when non-maximized
557 size = self.window_main.get_size()
558- self.config.set("general","size", "%s, %s" % (size[0], size[1]))
559+ self.config.set("general", "size", "%s, %s" % (size[0], size[1]))
560 if self.available_pane.add_to_launcher_enabled:
561 self.config.set("general", "add_to_launcher", "True")
562 else:
563
564=== modified file 'softwarecenter/ui/gtk3/aptd_gtk3.py'
565--- softwarecenter/ui/gtk3/aptd_gtk3.py 2011-09-26 22:21:59 +0000
566+++ softwarecenter/ui/gtk3/aptd_gtk3.py 2012-03-15 03:21:21 +0000
567@@ -21,10 +21,11 @@
568 from aptdaemon.gtk3widgets import (AptMediumRequiredDialog,
569 AptConfigFileConflictDialog)
570
571-from softwarecenter.backend.installbackend import InstallBackendUI
572+from softwarecenter.backend.installbackend import InstallBackendUI
573+
574
575 class InstallBackendUI(InstallBackendUI):
576-
577+
578 def ask_config_file_conflict(self, old, new):
579 dia = AptConfigFileConflictDialog(old, new)
580 res = dia.run()
581@@ -44,12 +45,13 @@
582 return True
583 else:
584 return False
585-
586- def error(self, parent, primary, secondary, details=None, alternative_action=None):
587+
588+ def error(self, parent, primary, secondary, details=None,
589+ alternative_action=None):
590 from dialogs import error
591 res = "ok"
592 res = error(parent=parent,
593- primary=primary,
594+ primary=primary,
595 secondary=secondary,
596 details=details,
597 alternative_action=alternative_action)
598@@ -62,7 +64,6 @@
599 from softwarecenter.ui.gtk3.aptd_gtk3 import InstallBackendUI
600 from mock import Mock
601
602-
603 aptd = get_install_backend()
604 aptd.ui = InstallBackendUI()
605 # test config file prompt
606@@ -82,4 +83,3 @@
607 enum = 101
608 res = aptd._show_transaction_failed_dialog(trans, enum)
609 print (res)
610-
611
612=== modified file 'softwarecenter/ui/gtk3/drawing.py'
613--- softwarecenter/ui/gtk3/drawing.py 2011-09-21 11:44:56 +0000
614+++ softwarecenter/ui/gtk3/drawing.py 2012-03-15 03:21:21 +0000
615@@ -1,11 +1,11 @@
616 from math import pi as PI
617-PI_OVER_180 = PI/180
618+PI_OVER_180 = PI / 180
619
620 from gi.repository import Gdk
621
622
623-BLACK = Gdk.RGBA(red=0,green=0,blue=0)
624-WHITE = Gdk.RGBA(red=1,green=1,blue=1)
625+BLACK = Gdk.RGBA(red=0, green=0, blue=0)
626+WHITE = Gdk.RGBA(red=1, green=1, blue=1)
627
628
629 def color_floats(spec):
630@@ -13,16 +13,19 @@
631 rgba.parse(spec)
632 return rgba.red, rgba.green, rgba.blue
633
634+
635 def rgb_to_hex(r, g, b):
636 if isinstance(r, float):
637 r *= 255
638 g *= 255
639 b *= 255
640- return "#%02X%02X%02X" % (r,g,b)
641+ return "#%02X%02X%02X" % (r, g, b)
642+
643
644 def color_to_hex(color):
645 return rgb_to_hex(color.red, color.green, color.blue)
646
647+
648 def mix(fgcolor, bgcolor, mix_alpha):
649 """ Creates a composite rgb of a foreground rgba and a background rgb.
650
651@@ -41,21 +44,25 @@
652 b = ((1 - mix_alpha) * bg_b) + (mix_alpha * src_b)
653 return Gdk.RGBA(red=r, green=g, blue=b)
654
655+
656 def darken(color, amount=0.3):
657 return mix(BLACK, color, amount)
658
659+
660 def lighten(color, amount=0.3):
661 return mix(WHITE, color, amount)
662
663+
664 def rounded_rect(cr, x, y, w, h, r):
665 cr.new_sub_path()
666- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
667- cr.arc(x+w-r, r+y, r, 270*PI_OVER_180, 0)
668- cr.arc(x+w-r, y+h-r, r, 0, 90*PI_OVER_180)
669- cr.arc(r+x, y+h-r, r, 90*PI_OVER_180, PI)
670+ cr.arc(r + x, r + y, r, PI, 270 * PI_OVER_180)
671+ cr.arc(x + w - r, r + y, r, 270 * PI_OVER_180, 0)
672+ cr.arc(x + w - r, y + h - r, r, 0, 90 * PI_OVER_180)
673+ cr.arc(r + x, y + h - r, r, 90 * PI_OVER_180, PI)
674 cr.close_path()
675 return
676
677+
678 def rounded_rect2(cr, x, y, w, h, radii):
679 nw, ne, se, sw = radii
680
681@@ -72,30 +79,28 @@
682 else:
683 cr.move_to(0, 0)
684 if ne:
685- cr.arc(w-ne, ne, ne, 270 * PI_OVER_180, 0)
686+ cr.arc(w - ne, ne, ne, 270 * PI_OVER_180, 0)
687 else:
688- cr.rel_line_to(w-nw, 0)
689+ cr.rel_line_to(w - nw, 0)
690 if se:
691- cr.arc(w-se, h-se, se, 0, 90 * PI_OVER_180)
692+ cr.arc(w - se, h - se, se, 0, 90 * PI_OVER_180)
693 else:
694- cr.rel_line_to(0, h-ne)
695+ cr.rel_line_to(0, h - ne)
696 if sw:
697- cr.arc(sw, h-sw, sw, 90 * PI_OVER_180, PI)
698+ cr.arc(sw, h - sw, sw, 90 * PI_OVER_180, PI)
699 else:
700- cr.rel_line_to(-(w-se), 0)
701+ cr.rel_line_to(-(w - se), 0)
702
703 cr.close_path()
704 cr.restore()
705- return
706+
707
708 def circle(cr, x, y, w, h):
709 cr.new_path()
710
711- r = min(w, h)*0.5
712- x += int((w-2*r)/2)
713- y += int((h-2*r)/2)
714+ r = min(w, h) * 0.5
715+ x += int((w - 2 * r) / 2)
716+ y += int((h - 2 * r) / 2)
717
718- cr.arc(r+x, r+y, r, 0, 360*PI_OVER_180)
719+ cr.arc(r + x, r + y, r, 0, 360 * PI_OVER_180)
720 cr.close_path()
721- return
722-
723
724=== modified file 'softwarecenter/ui/gtk3/em.py'
725--- softwarecenter/ui/gtk3/em.py 2012-02-09 14:42:20 +0000
726+++ softwarecenter/ui/gtk3/em.py 2012-03-15 03:21:21 +0000
727@@ -5,7 +5,8 @@
728
729 import logging
730
731-LOG=logging.getLogger(__name__)
732+LOG = logging.getLogger(__name__)
733+
734
735 def get_em(size=""):
736 # calc the height of a character, use as 1em
737@@ -19,9 +20,11 @@
738 w, h = l.get_layout().get_size()
739 return h / Pango.SCALE
740
741+
742 def get_small_em():
743 return get_em("small")
744
745+
746 def get_big_em():
747 return get_em("big")
748
749@@ -33,19 +36,20 @@
750
751
752 def em(multiplier=1, min=1):
753- return max(int(min), int(round(EM*multiplier, 0)))
754+ return max(int(min), int(round(EM * multiplier, 0)))
755+
756
757 def small_em(multiplier=1, min=1):
758- return max(int(min), int(round(SMALL_EM*multiplier, 0)))
759+ return max(int(min), int(round(SMALL_EM * multiplier, 0)))
760+
761
762 def big_em(multiplier=1, min=1):
763- return max(int(min), int(round(BIG_EM*multiplier, 0)))
764+ return max(int(min), int(round(BIG_EM * multiplier, 0)))
765+
766
767 # common values
768 class StockEms:
769- XLARGE = em(1.33, 5)
770- LARGE = em(min=3)
771- MEDIUM = em(0.666, 2)
772- SMALL = em(0.333, 1)
773-
774-
775+ XLARGE = em(1.33, 5)
776+ LARGE = em(min=3)
777+ MEDIUM = em(0.666, 2)
778+ SMALL = em(0.333, 1)
779
780=== modified file 'softwarecenter/ui/gtk3/gmenusearch.py'
781--- softwarecenter/ui/gtk3/gmenusearch.py 2011-09-13 18:39:34 +0000
782+++ softwarecenter/ui/gtk3/gmenusearch.py 2012-03-15 03:21:21 +0000
783@@ -22,6 +22,7 @@
784
785 LOG = logging.getLogger(__name__)
786
787+
788 class GMenuSearcher(object):
789
790 def __init__(self):
791@@ -36,29 +37,31 @@
792 while current_type is not GMenu.TreeItemType.INVALID:
793 if current_type == GMenu.TreeItemType.DIRECTORY:
794 self._search_gmenu_dir(
795- dirlist+[dir_iter.get_directory()], needle)
796+ dirlist + [dir_iter.get_directory()], needle)
797 elif current_type == GMenu.TreeItemType.ENTRY:
798 item = dir_iter.get_entry()
799 desktop_file_path = item.get_desktop_file_path()
800 # direct match of the desktop file name and the installed
801 # desktop file name
802 if os.path.basename(desktop_file_path) == needle:
803- self._found = dirlist+[item]
804+ self._found = dirlist + [item]
805 return
806- # if there is no direct match, take the part of the path after
807+ # if there is no direct match, take the part of the path after
808 # "applications" (e.g. kde4/amarok.desktop) and
809 # change "/" to "__" and do the match again - this is what
810 # the data extractor is doing
811 if "applications/" in desktop_file_path:
812- path_after_applications = desktop_file_path.split("applications/")[1]
813- if needle == path_after_applications.replace("/", APP_INSTALL_PATH_DELIMITER):
814- self._found = dirlist+[item]
815+ path_after_applications = desktop_file_path.split(
816+ "applications/")[1]
817+ if needle == path_after_applications.replace("/",
818+ APP_INSTALL_PATH_DELIMITER):
819+ self._found = dirlist + [item]
820 return
821 current_type = dir_iter.next()
822-
823+
824 def get_main_menu_path(self, desktop_file, menu_files_list=None):
825 if not desktop_file:
826- return None
827+ return
828 from gi.repository import GMenu
829 from gi.repository import GObject
830 # use the system ones by default, but allow override for
831@@ -74,14 +77,13 @@
832 tree.load_sync()
833 except GObject.GError as e:
834 LOG.warning("could not load GMenu path: %s" % e)
835- return None
836-
837+ return
838+
839 root = tree.get_root_directory()
840 self._search_gmenu_dir([root],
841 os.path.basename(desktop_file))
842 if self._found:
843 return self._found
844- return None
845
846
847 # these are the old static bindinds that are no longer required
848@@ -91,6 +93,7 @@
849
850 def __init__(self):
851 self._found = None
852+
853 def _search_gmenu_dir(self, dirlist, needle):
854 if not dirlist[-1]:
855 return
856@@ -99,28 +102,29 @@
857 for item in dirlist[-1].get_contents():
858 mtype = item.get_type()
859 if mtype == gmenu.TYPE_DIRECTORY:
860- self._search_gmenu_dir(dirlist+[item], needle)
861+ self._search_gmenu_dir(dirlist + [item], needle)
862 elif item.get_type() == gmenu.TYPE_ENTRY:
863 desktop_file_path = item.get_desktop_file_path()
864 # direct match of the desktop file name and the installed
865 # desktop file name
866 if os.path.basename(desktop_file_path) == needle:
867- self._found = dirlist+[item]
868+ self._found = dirlist + [item]
869 return
870- # if there is no direct match, take the part of the path after
871+ # if there is no direct match, take the part of the path after
872 # "applications" (e.g. kde4/amarok.desktop) and
873 # change "/" to "__" and do the match again - this is what
874 # the data extractor is doing
875 if "applications/" in desktop_file_path:
876- path_after_applications = desktop_file_path.split("applications/")[1]
877- if needle == path_after_applications.replace("/", APP_INSTALL_PATH_DELIMITER):
878- self._found = dirlist+[item]
879+ path_after_applications = desktop_file_path.split(
880+ "applications/")[1]
881+ if needle == path_after_applications.replace("/",
882+ APP_INSTALL_PATH_DELIMITER):
883+ self._found = dirlist + [item]
884 return
885
886-
887 def get_main_menu_path(self, desktop_file, menu_files_list=None):
888 if not desktop_file:
889- return None
890+ return
891 import gmenu
892 # use the system ones by default, but allow override for
893 # easier testing
894@@ -128,8 +132,7 @@
895 menu_files_list = ["applications.menu", "settings.menu"]
896 for n in menu_files_list:
897 tree = gmenu.lookup_tree(n)
898- self._search_gmenu_dir([tree.get_root_directory()],
899+ self._search_gmenu_dir([tree.get_root_directory()],
900 os.path.basename(desktop_file))
901 if self._found:
902 return self._found
903- return None
904
905=== modified file 'softwarecenter/ui/gtk3/review_gui_helper.py'
906--- softwarecenter/ui/gtk3/review_gui_helper.py 2012-03-05 15:32:36 +0000
907+++ softwarecenter/ui/gtk3/review_gui_helper.py 2012-03-15 03:21:21 +0000
908@@ -30,20 +30,17 @@
909 import time
910 import threading
911
912-# py3
913+# py3
914 try:
915 from urllib.request import urlopen
916- urlopen # pyflakes
917+ urlopen # pyflakes
918 from queue import Queue
919- Queue # pyflakes
920+ Queue # pyflakes
921 except ImportError:
922 # py2 fallbacks
923 from urllib import urlopen
924 from Queue import Queue
925
926-
927-
928-
929 from gettext import gettext as _
930
931 from softwarecenter.backend.ubuntusso import get_ubuntu_sso_backend
932@@ -69,40 +66,42 @@
933
934 # get current distro and set default server root
935 distro = get_distro()
936-SERVER_ROOT=distro.REVIEWS_SERVER
937+SERVER_ROOT = distro.REVIEWS_SERVER
938
939
940 # server status URL
941-SERVER_STATUS_URL = SERVER_ROOT+"/server-status/"
942+SERVER_STATUS_URL = SERVER_ROOT + "/server-status/"
943+
944
945 class UserCancelException(Exception):
946 """ user pressed cancel """
947 pass
948
949-TRANSMIT_STATE_NONE="transmit-state-none"
950-TRANSMIT_STATE_INPROGRESS="transmit-state-inprogress"
951-TRANSMIT_STATE_DONE="transmit-state-done"
952-TRANSMIT_STATE_ERROR="transmit-state-error"
953+TRANSMIT_STATE_NONE = "transmit-state-none"
954+TRANSMIT_STATE_INPROGRESS = "transmit-state-inprogress"
955+TRANSMIT_STATE_DONE = "transmit-state-done"
956+TRANSMIT_STATE_ERROR = "transmit-state-error"
957+
958
959 class GRatingsAndReviews(GObject.GObject):
960 """ Access ratings&reviews API as a gobject """
961
962 __gsignals__ = {
963 # send when a transmit is started
964- "transmit-start" : (GObject.SIGNAL_RUN_LAST,
965- GObject.TYPE_NONE,
966- (GObject.TYPE_PYOBJECT, ),
967- ),
968+ "transmit-start": (GObject.SIGNAL_RUN_LAST,
969+ GObject.TYPE_NONE,
970+ (GObject.TYPE_PYOBJECT, ),
971+ ),
972 # send when a transmit was successful
973- "transmit-success" : (GObject.SIGNAL_RUN_LAST,
974- GObject.TYPE_NONE,
975- (GObject.TYPE_PYOBJECT, ),
976- ),
977+ "transmit-success": (GObject.SIGNAL_RUN_LAST,
978+ GObject.TYPE_NONE,
979+ (GObject.TYPE_PYOBJECT, ),
980+ ),
981 # send when a transmit failed
982- "transmit-failure" : (GObject.SIGNAL_RUN_LAST,
983- GObject.TYPE_NONE,
984- (GObject.TYPE_PYOBJECT, str),
985- ),
986+ "transmit-failure": (GObject.SIGNAL_RUN_LAST,
987+ GObject.TYPE_NONE,
988+ (GObject.TYPE_PYOBJECT, str),
989+ ),
990 }
991
992 def __init__(self, token):
993@@ -110,39 +109,48 @@
994 # piston worker thread
995 self.worker_thread = Worker(token)
996 self.worker_thread.start()
997- GObject.timeout_add(500,
998+ GObject.timeout_add(500,
999 self._check_thread_status,
1000 None)
1001+
1002 def submit_review(self, review):
1003 self.emit("transmit-start", review)
1004 self.worker_thread.pending_reviews.put(review)
1005+
1006 def report_abuse(self, review_id, summary, text):
1007 self.emit("transmit-start", review_id)
1008 self.worker_thread.pending_reports.put((int(review_id), summary, text))
1009+
1010 def submit_usefulness(self, review_id, is_useful):
1011 self.emit("transmit-start", review_id)
1012 self.worker_thread.pending_usefulness.put((int(review_id), is_useful))
1013+
1014 def modify_review(self, review_id, review):
1015 self.emit("transmit-start", review_id)
1016 self.worker_thread.pending_modify.put((int(review_id), review))
1017+
1018 def delete_review(self, review_id):
1019 self.emit("transmit-start", review_id)
1020 self.worker_thread.pending_delete.put(int(review_id))
1021+
1022 def server_status(self):
1023 self.worker_thread.pending_server_status()
1024+
1025 def shutdown(self):
1026 self.worker_thread.shutdown()
1027+
1028 # internal
1029 def _check_thread_status(self, data):
1030 if self.worker_thread._transmit_state == TRANSMIT_STATE_DONE:
1031 self.emit("transmit-success", "")
1032 self.worker_thread._transmit_state = TRANSMIT_STATE_NONE
1033 elif self.worker_thread._transmit_state == TRANSMIT_STATE_ERROR:
1034- self.emit("transmit-failure", "",
1035+ self.emit("transmit-failure", "",
1036 self.worker_thread._transmit_error_str)
1037 self.worker_thread._transmit_state = TRANSMIT_STATE_NONE
1038 return True
1039
1040+
1041 class Worker(threading.Thread):
1042
1043 def __init__(self, token):
1044@@ -161,9 +169,8 @@
1045 self._transmit_error_str = ""
1046 self.display_name = "No display name"
1047 auth = piston_mini_client.auth.OAuthAuthorizer(token["token"],
1048- token["token_secret"],
1049- token["consumer_key"],
1050- token["consumer_secret"])
1051+ token["token_secret"], token["consumer_key"],
1052+ token["consumer_secret"])
1053 # change default server to the SSL one
1054 distro = get_distro()
1055 service_root = distro.REVIEWS_SERVER
1056@@ -229,7 +236,7 @@
1057 review_text = review['review_text']
1058 rating = review['rating']
1059 try:
1060- res = self.rnrclient.modify_review(review_id=review_id,
1061+ res = self.rnrclient.modify_review(review_id=review_id,
1062 summary=summary,
1063 review_text=review_text,
1064 rating=rating)
1065@@ -241,7 +248,7 @@
1066 self._write_exception_html_log_if_needed(e)
1067 self._transmit_state = TRANSMIT_STATE_ERROR
1068 self._transmit_error_str = err_str
1069- self.pending_modify.task_done()
1070+ self.pending_modify.task_done()
1071
1072 def _submit_delete_if_pending(self):
1073 """ the actual deletion """
1074@@ -281,9 +288,9 @@
1075 self.pending_reports.task_done()
1076
1077 def _write_exception_html_log_if_needed(self, e):
1078- # write out a "oops.html"
1079+ # write out a "oops.html"
1080 if type(e) is piston_mini_client.APIError:
1081- f=tempfile.NamedTemporaryFile(
1082+ f = tempfile.NamedTemporaryFile(
1083 prefix="sc_submit_oops_", suffix=".html", delete=False)
1084 # new piston-mini-client has only the body of the returned data
1085 # older just pushes it into a big string
1086@@ -315,7 +322,7 @@
1087 piston_review.language = review.language
1088 piston_review.arch_tag = get_current_arch()
1089 piston_review.origin = review.origin
1090- piston_review.distroseries=distro.get_codename()
1091+ piston_review.distroseries = distro.get_codename()
1092 try:
1093 res = self.rnrclient.submit_review(review=piston_review)
1094 self._transmit_state = TRANSMIT_STATE_DONE
1095@@ -329,7 +336,7 @@
1096 self._transmit_state = TRANSMIT_STATE_ERROR
1097 self._transmit_error_str = err_str
1098 self.pending_reviews.task_done()
1099-
1100+
1101 def _get_error_messages(self, e):
1102 if type(e) is piston_mini_client.APIError:
1103 try:
1104@@ -340,15 +347,16 @@
1105 for err in errs:
1106 err_str = _("%s\n%s") % (err_str, err)
1107 except:
1108- err_str = _("Unknown error communicating with server. Check your log "
1109- "and consider raising a bug report if this problem persists")
1110+ err_str = _("Unknown error communicating with server. "
1111+ "Check your log and consider raising a bug report "
1112+ "if this problem persists")
1113 logging.warning(e)
1114 else:
1115- err_str = _("Unknown error communicating with server. Check your log "
1116- "and consider raising a bug report if this problem persists")
1117+ err_str = _("Unknown error communicating with server. Check "
1118+ "your log and consider raising a bug report if this "
1119+ "problem persists")
1120 logging.warning(e)
1121 return err_str
1122-
1123
1124 def verify_server_status(self):
1125 """ verify that the server we want to talk to can be reached
1126@@ -369,7 +377,7 @@
1127
1128 def __init__(self, datadir, uifile):
1129 SimpleGtkbuilderApp.__init__(
1130- self, os.path.join(datadir,"ui/gtk3", uifile), "software-center")
1131+ self, os.path.join(datadir, "ui/gtk3", uifile), "software-center")
1132 # generic data
1133 # see bug #773214 for the rational
1134 #self.appname = _("Ubuntu Software Center")
1135@@ -384,24 +392,30 @@
1136 self.config = get_config(configfile)
1137 # status spinner
1138 self.status_spinner = Gtk.Spinner()
1139- self.status_spinner.set_size_request(32,32)
1140- self.login_spinner_vbox.pack_start(self.status_spinner, False, False, 0)
1141+ self.status_spinner.set_size_request(32, 32)
1142+ self.login_spinner_vbox.pack_start(self.status_spinner, False, False,
1143+ 0)
1144 self.login_spinner_vbox.reorder_child(self.status_spinner, 0)
1145 self.status_spinner.show()
1146 #submit status spinner
1147 self.submit_spinner = Gtk.Spinner()
1148- self.submit_spinner.set_size_request(*Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)[:2])
1149+ self.submit_spinner.set_size_request(*Gtk.icon_size_lookup(
1150+ Gtk.IconSize.SMALL_TOOLBAR)[:2])
1151 #submit error image
1152 self.submit_error_img = Gtk.Image()
1153- self.submit_error_img.set_from_stock(Gtk.STOCK_DIALOG_ERROR, Gtk.IconSize.SMALL_TOOLBAR)
1154+ self.submit_error_img.set_from_stock(Gtk.STOCK_DIALOG_ERROR,
1155+ Gtk.IconSize.SMALL_TOOLBAR)
1156 #submit success image
1157 self.submit_success_img = Gtk.Image()
1158- self.submit_success_img.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.SMALL_TOOLBAR)
1159+ self.submit_success_img.set_from_stock(Gtk.STOCK_APPLY,
1160+ Gtk.IconSize.SMALL_TOOLBAR)
1161 #submit warn image
1162 self.submit_warn_img = Gtk.Image()
1163- self.submit_warn_img.set_from_stock(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.SMALL_TOOLBAR)
1164+ self.submit_warn_img.set_from_stock(Gtk.STOCK_DIALOG_INFO,
1165+ Gtk.IconSize.SMALL_TOOLBAR)
1166 #label size to prevent image or spinner from resizing
1167- self.label_transmit_status.set_size_request(-1, Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)[1])
1168+ self.label_transmit_status.set_size_request(-1,
1169+ Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)[1])
1170
1171 def _get_parent_xid_for_login_window(self):
1172 # no get_xid() yet in gir world
1173@@ -422,7 +436,7 @@
1174
1175 def _add_spellcheck_to_textview(self, textview):
1176 """ adds a spellchecker (if available) to the given Gtk.textview """
1177- return None
1178+ pass
1179 #~ try:
1180 #~ import gtkspell
1181 #~ # mvo: gtkspell.get_from_text_view() is broken, so we use this
1182@@ -430,7 +444,7 @@
1183 #~ # use (that is directly passed to pspell)
1184 #~ spell = gtkspell.Spell(textview, None)
1185 #~ except:
1186- #~ return None
1187+ #~ return
1188 #~ return spell
1189
1190 def login(self, show_register=True):
1191@@ -449,16 +463,19 @@
1192
1193 def _login_canceled(self, sso):
1194 self.status_spinner.hide()
1195- self.login_status_label.set_markup('<b><big>%s</big></b>' % _("Login was canceled"))
1196+ self.login_status_label.set_markup(
1197+ '<b><big>%s</big></b>' % _("Login was canceled"))
1198
1199 def _maybe_login_successful(self, sso, oauth_result):
1200- """ called after we have the token, then we go and figure out our name """
1201+ """called after we have the token, then we go and figure out our
1202+ name
1203+ """
1204 logging.debug("_maybe_login_successful")
1205 self.token = oauth_result
1206 self.ssoapi = get_ubuntu_sso_backend()
1207 self.ssoapi.connect("whoami", self._whoami_done)
1208 self.ssoapi.connect("error", self._whoami_error)
1209- # this will automatically verify the token and retrigger login
1210+ # this will automatically verify the token and retrigger login
1211 # if its expired
1212 self.ssoapi.whoami()
1213
1214@@ -472,7 +489,8 @@
1215 logging.error("whoami error '%s'" % e)
1216 # show error
1217 self.status_spinner.hide()
1218- self.login_status_label.set_markup('<b><big>%s</big></b>' % _("Failed to log in"))
1219+ self.login_status_label.set_markup(
1220+ '<b><big>%s</big></b>' % _("Failed to log in"))
1221
1222 def login_successful(self, display_name):
1223 """ callback when the login was successful """
1224@@ -495,23 +513,26 @@
1225 def on_transmit_start(self, api, trans):
1226 self.button_post.set_sensitive(False)
1227 self.button_cancel.set_sensitive(False)
1228- self._change_status("progress", _(self.SUBMIT_MESSAGE))
1229+ self._change_status("progress", _(self.SUBMIT_MESSAGE))
1230
1231 def on_transmit_success(self, api, trans):
1232 self.api.shutdown()
1233 self.quit()
1234
1235 def on_transmit_failure(self, api, trans, error):
1236- self._change_status("fail", error)
1237+ self._change_status("fail", error)
1238 self.button_post.set_sensitive(True)
1239 self.button_cancel.set_sensitive(True)
1240-
1241- def _change_status(self, type, message):
1242- """method to separate the updating of status icon/spinner and message in the submit review window,
1243- takes a type (progress, fail, success, clear, warning) as a string and a message string then updates status area accordingly"""
1244+
1245+ def _change_status(self, type, message):
1246+ """method to separate the updating of status icon/spinner and
1247+ message in the submit review window, takes a type (progress,
1248+ fail, success, clear, warning) as a string and a message
1249+ string then updates status area accordingly
1250+ """
1251 self._clear_status_imagery()
1252 self.label_transmit_status.set_text("")
1253-
1254+
1255 if type == "progress":
1256 self.status_hbox.pack_start(self.submit_spinner, False, False, 0)
1257 self.status_hbox.reorder_child(self.submit_spinner, 0)
1258@@ -523,10 +544,11 @@
1259 self.status_hbox.reorder_child(self.submit_error_img, 0)
1260 self.submit_error_img.show()
1261 self.label_transmit_status.set_text(_(self.FAILURE_MESSAGE))
1262- self.error_textview.get_buffer().set_text(_(message))
1263+ self.error_textview.get_buffer().set_text(_(message))
1264 self.detail_expander.show()
1265 elif type == "success":
1266- self.status_hbox.pack_start(self.submit_success_img, False, False, 0)
1267+ self.status_hbox.pack_start(self.submit_success_img, False, False,
1268+ 0)
1269 self.status_hbox.reorder_child(self.submit_success_img, 0)
1270 self.submit_success_img.show()
1271 self.label_transmit_status.set_text(message)
1272@@ -540,7 +562,7 @@
1273 self.detail_expander.hide()
1274 self.detail_expander.set_expanded(False)
1275
1276- #clears spinner or error image from dialog submission label
1277+ #clears spinner or error image from dialog submission label
1278 # before trying to display one or the other
1279 if self.submit_spinner.get_parent():
1280 self.status_hbox.remove(self.submit_spinner)
1281@@ -550,7 +572,6 @@
1282 self.status_hbox.remove(self.submit_success_img)
1283 if self.submit_warn_img.get_window():
1284 self.status_hbox.remove(self.submit_warn_img)
1285- return
1286
1287
1288 class SubmitReviewsApp(BaseApp):
1289@@ -558,8 +579,9 @@
1290
1291 STAR_SIZE = (32, 32)
1292 APP_ICON_SIZE = 48
1293- #character limits for text boxes and hurdles for indicator changes
1294- # (overall field maximum, limit to display warning, limit to change colour)
1295+ #character limits for text boxes and hurdles for indicator changes
1296+ # (overall field maximum, limit to display warning, limit to change
1297+ # colour)
1298 SUMMARY_CHAR_LIMITS = (80, 60, 70)
1299 REVIEW_CHAR_LIMITS = (5000, 4900, 4950)
1300 #alert colours for character warning labels
1301@@ -569,12 +591,18 @@
1302 FAILURE_MESSAGE = _("Failed to submit review")
1303 SUCCESS_MESSAGE = _("Review submitted")
1304
1305- def __init__(self, app, version, iconname, origin, parent_xid, datadir, action="submit", review_id=0):
1306+ def __init__(self, app, version, iconname, origin, parent_xid, datadir,
1307+ action="submit", review_id=0):
1308 BaseApp.__init__(self, datadir, "submit_review.ui")
1309 self.datadir = datadir
1310 # legal fineprint, do not change without consulting a lawyer
1311- msg = _("By submitting this review, you agree not to include anything defamatory, infringing, or illegal. Canonical may, at its discretion, publish your name and review in Ubuntu Software Center and elsewhere, and allow the software or content author to publish it too.")
1312- self.label_legal_fineprint.set_markup('<span size="x-small">%s</span>' % msg)
1313+ msg = _("By submitting this review, you agree not to include "
1314+ "anything defamatory, infringing, or illegal. Canonical "
1315+ "may, at its discretion, publish your name and review in "
1316+ "Ubuntu Software Center and elsewhere, and allow the "
1317+ "software or content author to publish it too.")
1318+ self.label_legal_fineprint.set_markup(
1319+ '<span size="x-small">%s</span>' % msg)
1320
1321 # additional icons come from app-install-data
1322 self.icons = Gtk.IconTheme.get_default()
1323@@ -584,7 +612,7 @@
1324
1325 self.star_rating = ReactiveStar()
1326 alignment = Gtk.Alignment.new(0.0, 0.5, 1.0, 1.0)
1327- alignment.set_padding(3,3,3,3)
1328+ alignment.set_padding(3, 3, 3, 3)
1329 alignment.add(self.star_rating)
1330 self.star_rating.set_size_as_pixel_value(36)
1331 self.star_caption = Gtk.Label()
1332@@ -598,7 +626,7 @@
1333 self.review_buffer = self.textview_review.get_buffer()
1334
1335 self.detail_expander.hide()
1336-
1337+
1338 self.retrieve_api = RatingsAndReviewsAPI()
1339
1340 # data
1341@@ -625,10 +653,11 @@
1342 self._displaying_cancel_confirmation = False
1343 self.submit_window.connect("key-press-event", self._on_key_press_event)
1344
1345- self.review_summary_entry.connect('changed', self._on_mandatory_text_entry_changed)
1346+ self.review_summary_entry.connect('changed',
1347+ self._on_mandatory_text_entry_changed)
1348 self.star_rating.connect('changed', self._on_mandatory_fields_changed)
1349 self.review_buffer.connect('changed', self._on_text_entry_changed)
1350-
1351+
1352 # gwibber stuff
1353 self.gwibber_combo = Gtk.ComboBoxText.new()
1354 #cells = self.gwibber_combo.get_cells()
1355@@ -638,10 +667,11 @@
1356 self.gwibber_helper = GwibberHelperMock()
1357 else:
1358 self.gwibber_helper = GwibberHelper()
1359-
1360- #get a dict with a saved gwibber_send (boolean) and gwibber account_id for persistent state
1361+
1362+ # get a dict with a saved gwibber_send (boolean) and gwibber
1363+ # account_id for persistent state
1364 self.gwibber_prefs = self._get_gwibber_prefs()
1365-
1366+
1367 # gwibber stuff
1368 self._setup_gwibber_gui()
1369
1370@@ -651,10 +681,10 @@
1371 elif self.action == "modify":
1372 self._init_modify()
1373
1374-
1375 def _init_submit(self):
1376- self.submit_window.set_title(_("Review %s") % gettext.dgettext("app-install-data", self.app.name))
1377-
1378+ self.submit_window.set_title(_("Review %s") %
1379+ gettext.dgettext("app-install-data", self.app.name))
1380+
1381 def _init_modify(self):
1382 self._populate_review()
1383 self.submit_window.set_title(_("Modify Your %(appname)s Review") % {
1384@@ -664,24 +694,28 @@
1385 self.FAILURE_MESSAGE = _("Failed to edit review")
1386 self.SUCCESS_MESSAGE = _("Review updated")
1387 self._enable_or_disable_post_button()
1388-
1389+
1390 def _populate_review(self):
1391 try:
1392- review_data = self.retrieve_api.get_review(review_id=self.review_id)
1393- app = Application(appname=review_data.app_name, pkgname=review_data.package_name)
1394+ review_data = self.retrieve_api.get_review(
1395+ review_id=self.review_id)
1396+ app = Application(appname=review_data.app_name,
1397+ pkgname=review_data.package_name)
1398 self.app = app
1399 self.review_summary_entry.set_text(review_data.summary)
1400 self.star_rating.set_rating(review_data.rating)
1401 self.review_buffer.set_text(review_data.review_text)
1402- #save original review field data, for comparison purposes when user makes changes to fields
1403+ # save original review field data, for comparison purposes when
1404+ # user makes changes to fields
1405 self.orig_summary_text = review_data.summary
1406 self.orig_star_rating = review_data.rating
1407 self.orig_review_text = review_data.review_text
1408 self.version = review_data.version
1409 self.origin = review_data.origin
1410- return
1411 except piston_mini_client.APIError:
1412- logging.warn('Unable to retrieve review id %s for editing. Exiting' % self.review_id)
1413+ logging.warn(
1414+ 'Unable to retrieve review id %s for editing. Exiting' %
1415+ self.review_id)
1416 self.quit(2)
1417
1418 def _setup_details(self, widget, app, iconname, version, display_name):
1419@@ -689,7 +723,8 @@
1420 try:
1421 icon = self.icons.load_icon(iconname, self.APP_ICON_SIZE, 0)
1422 except:
1423- icon = self.icons.load_icon(Icons.MISSING_APP, self.APP_ICON_SIZE, 0)
1424+ icon = self.icons.load_icon(Icons.MISSING_APP, self.APP_ICON_SIZE,
1425+ 0)
1426 self.review_appicon.set_from_pixbuf(icon)
1427
1428 # title
1429@@ -698,16 +733,17 @@
1430 gettext.dgettext("app-install-data", app.name), version))
1431
1432 # review label
1433- self.review_label.set_markup(_('Review by: %s') % display_name.encode('utf8'))
1434+ self.review_label.set_markup(_('Review by: %s') %
1435+ display_name.encode('utf8'))
1436
1437 # review summary label
1438 self.review_summary_label.set_markup(_('Summary:'))
1439-
1440+
1441 #rating label
1442 self.rating_label.set_markup(_('Rating:'))
1443 #error detail link label
1444- self.label_expander.set_markup('<small><u>%s</u></small>' % (_('Error Details')))
1445- return
1446+ self.label_expander.set_markup('<small><u>%s</u></small>' %
1447+ (_('Error Details')))
1448
1449 def _has_user_started_reviewing(self):
1450 summary_chars = self.review_summary_entry.get_text_length()
1451@@ -716,15 +752,15 @@
1452
1453 def _on_mandatory_fields_changed(self, *args):
1454 self._enable_or_disable_post_button()
1455-
1456+
1457 def _on_mandatory_text_entry_changed(self, widget):
1458 self._check_summary_character_count()
1459 self._on_mandatory_fields_changed(widget)
1460-
1461+
1462 def _on_text_entry_changed(self, widget):
1463 self._check_review_character_count()
1464 self._on_mandatory_fields_changed(widget)
1465-
1466+
1467 def _enable_or_disable_post_button(self):
1468 summary_chars = self.review_summary_entry.get_text_length()
1469 review_chars = self.review_buffer.get_char_count()
1470@@ -736,34 +772,42 @@
1471 else:
1472 self.button_post.set_sensitive(False)
1473 self._change_status("clear", "")
1474-
1475- #set post button insensitive, if review being modified is the same as what is currently in the UI fields
1476- #checks if 'original' review attributes exist to avoid exceptions when this method has been called prior to review being retrieved
1477+
1478+ # set post button insensitive, if review being modified is the same
1479+ # as what is currently in the UI fields checks if 'original' review
1480+ # attributes exist to avoid exceptions when this method has been
1481+ # called prior to review being retrieved
1482 if self.action == 'modify' and hasattr(self, "orig_star_rating"):
1483 if self._modify_review_is_the_same():
1484 self.button_post.set_sensitive(False)
1485 self._change_status("warning", _("Can't submit unmodified"))
1486 else:
1487 self._change_status("clear", "")
1488-
1489+
1490 def _modify_review_is_the_same(self):
1491- '''checks if review fields are the same as the review being modified and returns true if so'''
1492-
1493- #perform an initial check on character counts to return False if any don't match, avoids doing unnecessary string comparisons
1494- if (self.review_summary_entry.get_text_length() != len(self.orig_summary_text) or
1495- self.review_buffer.get_char_count() != len(self.orig_review_text)):
1496+ """checks if review fields are the same as the review being modified
1497+ and returns True if so
1498+ """
1499+
1500+ # perform an initial check on character counts to return False if any
1501+ # don't match, avoids doing unnecessary string comparisons
1502+ if (self.review_summary_entry.get_text_length() !=
1503+ len(self.orig_summary_text) or
1504+ self.review_buffer.get_char_count() != len(self.orig_review_text)):
1505 return False
1506 #compare rating
1507 if self.star_rating.get_rating() != self.orig_star_rating:
1508 return False
1509 #compare summary text
1510- if self.review_summary_entry.get_text().decode('utf-8') != self.orig_summary_text:
1511+ if (self.review_summary_entry.get_text().decode('utf-8') !=
1512+ self.orig_summary_text):
1513 return False
1514 #compare review text
1515- if self.review_buffer.get_text(
1516+ if (self.review_buffer.get_text(
1517 self.review_buffer.get_start_iter(),
1518 self.review_buffer.get_end_iter(),
1519- include_hidden_chars=False).decode('utf-8') != self.orig_review_text:
1520+ include_hidden_chars=False).decode('utf-8') !=
1521+ self.orig_review_text):
1522 return False
1523 return True
1524
1525@@ -771,24 +815,24 @@
1526 summary_chars = self.review_summary_entry.get_text_length()
1527 if summary_chars > self.SUMMARY_CHAR_LIMITS[1] - 1:
1528 markup = self._get_fade_colour_markup(
1529- self.NORMAL_COLOUR, self.ERROR_COLOUR,
1530- self.SUMMARY_CHAR_LIMITS[2], self.SUMMARY_CHAR_LIMITS[0],
1531+ self.NORMAL_COLOUR, self.ERROR_COLOUR,
1532+ self.SUMMARY_CHAR_LIMITS[2], self.SUMMARY_CHAR_LIMITS[0],
1533 summary_chars)
1534 self.summary_char_label.set_markup(markup)
1535 else:
1536 self.summary_char_label.set_text('')
1537-
1538- def _check_review_character_count(self):
1539+
1540+ def _check_review_character_count(self):
1541 review_chars = self.review_buffer.get_char_count()
1542 if review_chars > self.REVIEW_CHAR_LIMITS[1] - 1:
1543 markup = self._get_fade_colour_markup(
1544- self.NORMAL_COLOUR, self.ERROR_COLOUR,
1545- self.REVIEW_CHAR_LIMITS[2], self.REVIEW_CHAR_LIMITS[0],
1546- review_chars)
1547+ self.NORMAL_COLOUR, self.ERROR_COLOUR,
1548+ self.REVIEW_CHAR_LIMITS[2], self.REVIEW_CHAR_LIMITS[0],
1549+ review_chars)
1550 self.review_char_label.set_markup(markup)
1551 else:
1552 self.review_char_label.set_text('')
1553-
1554+
1555 def _get_fade_colour_markup(self, full_col, empty_col, cmin, cmax, curr):
1556 """takes two colours as well as a minimum and maximum value then
1557 fades one colour into the other based on the proportion of the
1558@@ -797,37 +841,38 @@
1559 """
1560 markup = '<span fgcolor="#%s">%s</span>'
1561 if curr > cmax:
1562- return markup % (empty_col, str(cmax-curr))
1563- elif curr <= cmin: #saves division by 0 later if same value was passed as min and max
1564- return markup % (full_col, str(cmax-curr))
1565+ return markup % (empty_col, str(cmax - curr))
1566+ elif curr <= cmin: # saves division by 0 later if cmin == cmax
1567+ return markup % (full_col, str(cmax - curr))
1568 else:
1569 #distance between min and max values to fade colours
1570 scale = cmax - cmin
1571 #percentage to fade colour by, based on current number of chars
1572 percentage = (curr - cmin) / float(scale)
1573-
1574+
1575 full_rgb = self._convert_html_to_rgb(full_col)
1576 empty_rgb = self._convert_html_to_rgb(empty_col)
1577-
1578+
1579 #calc changes to each of the r g b values to get the faded colour
1580 red_change = full_rgb[0] - empty_rgb[0]
1581 green_change = full_rgb[1] - empty_rgb[1]
1582 blue_change = full_rgb[2] - empty_rgb[2]
1583-
1584+
1585 new_red = int(full_rgb[0] - (percentage * red_change))
1586 new_green = int(full_rgb[1] - (percentage * green_change))
1587 new_blue = int(full_rgb[2] - (percentage * blue_change))
1588
1589- return_color = self._convert_rgb_to_html(new_red, new_green, new_blue)
1590-
1591- return markup % (return_color, str(cmax-curr))
1592-
1593+ return_color = self._convert_rgb_to_html(new_red, new_green,
1594+ new_blue)
1595+
1596+ return markup % (return_color, str(cmax - curr))
1597+
1598 def _convert_html_to_rgb(self, html):
1599 r = html[0:2]
1600 g = html[2:4]
1601 b = html[4:6]
1602- return (int(r,16), int(g,16), int(b,16))
1603-
1604+ return (int(r, 16), int(g, 16), int(b, 16))
1605+
1606 def _convert_rgb_to_html(self, r, g, b):
1607 return "%s%s%s" % ("%02X" % r,
1608 "%02X" % g,
1609@@ -839,20 +884,20 @@
1610 text_buffer = self.textview_review.get_buffer()
1611 review.text = text_buffer.get_text(text_buffer.get_start_iter(),
1612 text_buffer.get_end_iter(),
1613- False) # include_hidden_chars
1614+ False) # include_hidden_chars
1615 review.summary = self.review_summary_entry.get_text()
1616 review.date = datetime.datetime.now()
1617 review.language = get_language()
1618 review.rating = int(self.star_rating.get_rating())
1619 review.package_version = self.version
1620 review.origin = self.origin
1621-
1622+
1623 if self.action == "submit":
1624 self.api.submit_review(review)
1625 elif self.action == "modify":
1626- changes = {'review_text':review.text,
1627- 'summary':review.summary,
1628- 'rating':review.rating}
1629+ changes = {'review_text': review.text,
1630+ 'summary': review.summary,
1631+ 'rating': review.rating}
1632 self.api.modify_review(self.review_id, changes)
1633
1634 def login_successful(self, display_name):
1635@@ -860,8 +905,7 @@
1636 self._setup_details(self.submit_window, self.app,
1637 self.iconname, self.version, display_name)
1638 self.textview_review.grab_focus()
1639- return
1640-
1641+
1642 def _setup_gwibber_gui(self):
1643 self.gwibber_accounts = self.gwibber_helper.accounts()
1644 list_length = len(self.gwibber_accounts)
1645@@ -871,39 +915,41 @@
1646 self._on_one_gwibber_account()
1647 else:
1648 self._on_multiple_gwibber_accounts()
1649-
1650+
1651 def _get_gwibber_prefs(self):
1652- if self.config.has_option("reviews", "gwibber_send"):
1653+ if self.config.has_option("reviews", "gwibber_send"):
1654 send = self.config.getboolean("reviews", "gwibber_send")
1655 else:
1656 send = False
1657-
1658+
1659 if self.config.has_option("reviews", "account_id"):
1660 account_id = self.config.get("reviews", "account_id")
1661 else:
1662 account_id = False
1663-
1664- return { "gwibber_send" : send,
1665- "account_id" : account_id }
1666-
1667+
1668+ return {
1669+ "gwibber_send": send,
1670+ "account_id": account_id
1671+ }
1672+
1673 def _on_no_gwibber_accounts(self):
1674 self.gwibber_hbox.hide()
1675 self.gwibber_checkbutton.set_active(False)
1676-
1677+
1678 def _on_one_gwibber_account(self):
1679 account = self.gwibber_accounts[0]
1680 self.gwibber_hbox.show()
1681 self.gwibber_combo.hide()
1682 from softwarecenter.utils import utf8
1683- acct_text = utf8(_("Also post this review to %s (@%s)")) % (
1684- utf8(account['service'].capitalize()), utf8(account['username']) )
1685+ acct_text = utf8(_("Also post this review to %s (@%s)")) % (
1686+ utf8(account['service'].capitalize()), utf8(account['username']))
1687 self.gwibber_checkbutton.set_label(acct_text)
1688 # simplifies on_transmit_successful later
1689 self.gwibber_combo.append_text(acct_text)
1690 self.gwibber_combo.set_active(0)
1691 # auto select submit via gwibber checkbutton if saved prefs say True
1692 self.gwibber_checkbutton.set_active(self.gwibber_prefs['gwibber_send'])
1693-
1694+
1695 def _on_multiple_gwibber_accounts(self):
1696 self.gwibber_hbox.show()
1697 self.gwibber_combo.show()
1698@@ -911,14 +957,13 @@
1699 # setup accounts combo
1700 self.gwibber_checkbutton.set_label(_("Also post this review to: "))
1701 for account in self.gwibber_accounts:
1702- acct_text = "%s (@%s)" % (
1703- account['service'].capitalize(), account['username'] )
1704+ acct_text = "%s (@%s)" % (
1705+ account['service'].capitalize(), account['username'])
1706 self.gwibber_combo.append_text(acct_text)
1707
1708 # add "all" to both combo and accounts (the later is only pseudo)
1709 self.gwibber_combo.append_text(_("All my Gwibber services"))
1710- self.gwibber_accounts.append({ "id" : "pseudo-sc-all",
1711- })
1712+ self.gwibber_accounts.append({"id": "pseudo-sc-all"})
1713
1714 # reapply preferences
1715 self.gwibber_checkbutton.set_active(self.gwibber_prefs['gwibber_send'])
1716@@ -934,16 +979,17 @@
1717 """
1718 status_text = _("Posting to %s") % account['service'].capitalize()
1719 self._change_status("progress", status_text)
1720- return self.gwibber_helper.send_message(msg,account['id'])
1721+ return self.gwibber_helper.send_message(msg, account['id'])
1722
1723 def on_transmit_success(self, api, trans):
1724- """on successful submission of a review, try to send to gwibber as well"""
1725- self._run_gwibber_submits(api,trans)
1726+ """on successful submission of a review, try to send to gwibber as
1727+ well
1728+ """
1729+ self._run_gwibber_submits(api, trans)
1730
1731 def _on_key_press_event(self, widget, event):
1732 if event.keyval == Gdk.KEY_Escape:
1733 self._confirm_cancellation()
1734- return
1735
1736 def _confirm_cancellation(self):
1737 if (self._has_user_started_reviewing() and not
1738@@ -952,6 +998,7 @@
1739 def do_cancel(widget):
1740 self.submit_window.destroy()
1741 self.quit()
1742+
1743 def undo_cancel(widget):
1744 self._displaying_cancel_confirmation = False
1745 self.response_hbuttonbox.set_visible(True)
1746@@ -971,23 +1018,27 @@
1747 else:
1748 self.submit_window.destroy()
1749 self.quit()
1750- return
1751
1752 def _get_send_accounts(self, sel_index):
1753- """return the account referenced by the passed in index, or all accounts
1754- if the index of the combo points to the pseudo-sc-all string"""
1755+ """return the account referenced by the passed in index, or all
1756+ accounts if the index of the combo points to the pseudo-sc-all
1757+ string
1758+ """
1759 if self.gwibber_accounts[sel_index]["id"] == "pseudo-sc-all":
1760 return self.gwibber_accounts
1761 else:
1762 return [self.gwibber_accounts[sel_index]]
1763-
1764- def _submit_to_gwibber(self,msg,send_accounts):
1765+
1766+ def _submit_to_gwibber(self, msg, send_accounts):
1767 """for each send_account passed in, try to submit to gwibber
1768- then return a list of accounts that failed to submit (empty list if all succeeded"""
1769- #list of gwibber accounts that failed to submit, used later to allow selective re-send if user desires
1770- failed_accounts=[]
1771+ then return a list of accounts that failed to submit (empty list
1772+ if all succeeded)
1773+ """
1774+ #list of gwibber accounts that failed to submit, used later to allow
1775+ # selective re-send if user desires
1776+ failed_accounts = []
1777 for account in send_accounts:
1778- if account["id"]!= "pseudo-sc-all":
1779+ if account["id"] != "pseudo-sc-all":
1780 if not self._post_to_one_gwibber_account(msg, account):
1781 failed_accounts.append(account)
1782 return failed_accounts
1783@@ -1002,10 +1053,11 @@
1784 send_accounts = self._get_send_accounts(i)
1785 self._save_gwibber_state(True, self.gwibber_accounts[i]['id'])
1786 #tries to send to gwibber, and gets back any failed accounts
1787- failed_accounts = self._submit_to_gwibber(msg,send_accounts)
1788+ failed_accounts = self._submit_to_gwibber(msg, send_accounts)
1789 if len(failed_accounts) > 0:
1790 gwibber_success = False
1791- #FIXME: send an error string to this method instead of empty string
1792+ #FIXME: send an error string to this method instead of empty
1793+ # string
1794 self._on_gwibber_fail(api, trans, failed_accounts, "")
1795 else:
1796 # prevent _save_gwibber_state from overwriting the account id
1797@@ -1024,39 +1076,43 @@
1798 gwibber_success = True
1799 failed_accounts = []
1800 msg = (self._gwibber_message())
1801-
1802+
1803 for account in accounts:
1804 if not self._post_to_one_gwibber_account(msg, account):
1805 failed_accounts.append(account)
1806 gwibber_success = False
1807-
1808+
1809 if not gwibber_success:
1810 #FIXME: send an error string to this method instead of empty string
1811 self._on_gwibber_fail(api, trans, failed_accounts, "")
1812 else:
1813 self._success_status()
1814 BaseApp.on_transmit_success(self, api, trans)
1815-
1816+
1817 def _success_status(self):
1818- """Updates status area to show success for 2 seconds then allows window to proceed"""
1819+ """Updates status area to show success for 2 seconds then allows
1820+ window to proceed
1821+ """
1822 self._change_status("success", _(self.SUCCESS_MESSAGE))
1823 while Gtk.events_pending():
1824 Gtk.main_iteration()
1825 time.sleep(2)
1826
1827 def _on_gwibber_fail(self, api, trans, failed_accounts, error):
1828- self._change_status("fail",_("Problems posting to Gwibber"))
1829+ self._change_status("fail", _("Problems posting to Gwibber"))
1830 #list to hold service strings in the format: "Service (@username)"
1831 failed_services = []
1832 for account in failed_accounts:
1833- failed_services.append("%s (@%s)" % (account['service'].capitalize(), account['username']))
1834-
1835- glade_dialog = SimpleGtkbuilderDialog(self.datadir, domain="software-center")
1836+ failed_services.append("%s (@%s)" % (
1837+ account['service'].capitalize(), account['username']))
1838+
1839+ glade_dialog = SimpleGtkbuilderDialog(self.datadir,
1840+ domain="software-center")
1841 dialog = glade_dialog.dialog_gwibber_error
1842 dialog.set_transient_for(self.submit_window)
1843 # build the failure string
1844 # TRANSLATORS: the part in %s can either be a single entry
1845- # like "facebook" or a string like
1846+ # like "facebook" or a string like
1847 # "factbook and twister"
1848 error_str = gettext.ngettext(
1849 "There was a problem posting this review to %s.",
1850@@ -1071,40 +1127,38 @@
1851 self._gwibber_retry_some(api, trans, failed_accounts)
1852 else:
1853 BaseApp.on_transmit_success(self, api, trans)
1854-
1855+
1856 def _save_gwibber_state(self, gwibber_send, account_id):
1857 if not self.config.has_section("reviews"):
1858 self.config.add_section("reviews")
1859-
1860+
1861 self.config.set("reviews", "gwibber_send", str(gwibber_send))
1862 if account_id:
1863 self.config.set("reviews", "account_id", account_id)
1864-
1865+
1866 self.config.write()
1867- return
1868-
1869-
1870+
1871 def _gwibber_message(self, max_len=140):
1872 """ build a gwibber message of max_len"""
1873 def _gwibber_message_string_from_data(appname, rating, summary, link):
1874 """ helper so that we do not duplicate the "reviewed..." string """
1875 return _("reviewed %(appname)s in Ubuntu: %(rating)s "
1876 "%(summary)s %(link)s") % {
1877- 'appname' : appname,
1878- 'rating' : rating,
1879- 'summary' : summary,
1880- 'link' : link }
1881-
1882+ 'appname': appname,
1883+ 'rating': rating,
1884+ 'summary': summary,
1885+ 'link': link}
1886+
1887 rating = self.star_rating.get_rating()
1888 rating_string = ''
1889-
1890+
1891 #fill star ratings for string
1892- for i in range(1,6):
1893+ for i in range(1, 6):
1894 if i <= rating:
1895 rating_string = rating_string + u"\u2605"
1896 else:
1897 rating_string = rating_string + u"\u2606"
1898-
1899+
1900 review_summary_text = self.review_summary_entry.get_text()
1901 # FIXME: currently the link is not useful (at all) for most
1902 # people not runnig ubuntu
1903@@ -1112,22 +1166,24 @@
1904 app_link = ""
1905 gwib_msg = _gwibber_message_string_from_data(
1906 self.app.name, rating_string, review_summary_text, app_link)
1907-
1908+
1909 #check char count and ellipsize review summary if larger than 140 chars
1910 if len(gwib_msg) > max_len:
1911- chars_to_reduce = len(gwib_msg) - (max_len-1)
1912+ chars_to_reduce = len(gwib_msg) - (max_len - 1)
1913 new_char_count = len(review_summary_text) - chars_to_reduce
1914- review_summary_text = review_summary_text[:new_char_count] + u"\u2026"
1915+ review_summary_text = (review_summary_text[:new_char_count] +
1916+ u"\u2026")
1917 gwib_msg = _gwibber_message_string_from_data(
1918 self.app.name, rating_string, review_summary_text, app_link)
1919-
1920+
1921 return gwib_msg
1922
1923+
1924 class ReportReviewApp(BaseApp):
1925 """ report a given application or package """
1926
1927 APP_ICON_SIZE = 48
1928-
1929+
1930 SUBMIT_MESSAGE = _(u"Sending report\u2026")
1931 FAILURE_MESSAGE = _("Failed to submit report")
1932
1933@@ -1157,33 +1213,38 @@
1934 self.submit_window.set_position(Gtk.WindowPosition.MOUSE)
1935 # simple APIs ftw!
1936 self.combobox_report_summary = Gtk.ComboBoxText.new()
1937- self.report_body_vbox.pack_start(self.combobox_report_summary, False, False, 0)
1938+ self.report_body_vbox.pack_start(self.combobox_report_summary, False,
1939+ False, 0)
1940 self.report_body_vbox.reorder_child(self.combobox_report_summary, 2)
1941 self.combobox_report_summary.show()
1942- for term in [ _(u"Please make a selection\u2026"),
1943- # TRANSLATORS: The following is one entry in a combobox that is
1944- # located directly beneath a label asking 'Why is this review inappropriate?'.
1945- # This text refers to a possible reason for why the corresponding
1946- # review is being flagged as inappropriate.
1947- _("Offensive language"),
1948- # TRANSLATORS: The following is one entry in a combobox that is
1949- # located directly beneath a label asking 'Why is this review inappropriate?'.
1950- # This text refers to a possible reason for why the corresponding
1951- # review is being flagged as inappropriate.
1952- _("Infringes copyright"),
1953- # TRANSLATORS: The following is one entry in a combobox that is
1954- # located directly beneath a label asking 'Why is this review inappropriate?'.
1955- # This text refers to a possible reason for why the corresponding
1956- # review is being flagged as inappropriate.
1957- _("Contains inaccuracies"),
1958- # TRANSLATORS: The following is one entry in a combobox that is
1959- # located directly beneath a label asking 'Why is this review inappropriate?'.
1960- # This text refers to a possible reason for why the corresponding
1961- # review is being flagged as inappropriate.
1962- _("Other") ]:
1963+ for term in [_(u"Please make a selection\u2026"),
1964+ # TRANSLATORS: The following is one entry in a combobox that is
1965+ # located directly beneath a label asking 'Why is this review
1966+ # inappropriate?'.
1967+ # This text refers to a possible reason for why the corresponding
1968+ # review is being flagged as inappropriate.
1969+ _("Offensive language"),
1970+ # TRANSLATORS: The following is one entry in a combobox that is
1971+ # located directly beneath a label asking 'Why is this review
1972+ # inappropriate?'.
1973+ # This text refers to a possible reason for why the corresponding
1974+ # review is being flagged as inappropriate.
1975+ _("Infringes copyright"),
1976+ # TRANSLATORS: The following is one entry in a combobox that is
1977+ # located directly beneath a label asking 'Why is this review
1978+ # inappropriate?'.
1979+ # This text refers to a possible reason for why the corresponding
1980+ # review is being flagged as inappropriate.
1981+ _("Contains inaccuracies"),
1982+ # TRANSLATORS: The following is one entry in a combobox that is
1983+ # located directly beneath a label asking 'Why is this review
1984+ # inappropriate?'.
1985+ # This text refers to a possible reason for why the corresponding
1986+ # review is being flagged as inappropriate.
1987+ _("Other")]:
1988 self.combobox_report_summary.append_text(term)
1989 self.combobox_report_summary.set_active(0)
1990-
1991+
1992 self.combobox_report_summary.connect(
1993 "changed", self._enable_or_disable_report_button)
1994
1995@@ -1200,12 +1261,12 @@
1996 self.report_label.set_markup(_('Please give details:'))
1997
1998 # review summary label
1999- self.report_summary_label.set_markup(_('Why is this review inappropriate?'))
2000-
2001+ self.report_summary_label.set_markup(
2002+ _('Why is this review inappropriate?'))
2003+
2004 #error detail link label
2005- self.label_expander.set_markup('<small><u>%s</u></small>' % (_('Error Details')))
2006-
2007- return
2008+ self.label_expander.set_markup('<small><u>%s</u></small>'
2009+ % (_('Error Details')))
2010
2011 def on_button_post_clicked(self, button):
2012 logging.debug("report_abuse ok button")
2013@@ -1225,7 +1286,7 @@
2014
2015 class SubmitUsefulnessApp(BaseApp):
2016 SUBMIT_MESSAGE = _(u"Sending usefulness\u2026")
2017-
2018+
2019 def __init__(self, review_id, parent_xid, is_useful, datadir):
2020 BaseApp.__init__(self, datadir, "submit_usefulness.ui")
2021 # data
2022@@ -1243,7 +1304,7 @@
2023 logging.debug("submit usefulness")
2024 self.main_notebook.set_current_page(1)
2025 self.api.submit_usefulness(self.review_id, self.is_useful)
2026-
2027+
2028 def on_transmit_failure(self, api, trans, error):
2029 logging.warn("exiting - error: %s" % error)
2030 self.api.shutdown()
2031@@ -1254,21 +1315,22 @@
2032 # stub ui that can be useful for testing
2033 def run(self):
2034 self.login()
2035-
2036- # override UI update methods from BaseApp to prevent them
2037+
2038+ # override UI update methods from BaseApp to prevent them
2039 # causing errors if called when UI is hidden
2040 def _clear_status_imagery(self):
2041 pass
2042-
2043+
2044 def _change_status(self, type, message):
2045 pass
2046
2047+
2048 class DeleteReviewApp(BaseApp):
2049 SUBMIT_MESSAGE = _(u"Deleting review\u2026")
2050 FAILURE_MESSAGE = _("Failed to delete review")
2051-
2052+
2053 def __init__(self, review_id, parent_xid, datadir):
2054- # uses same UI as submit usefulness because
2055+ # uses same UI as submit usefulness because
2056 # (a) it isn't shown and (b) it's similar in usage
2057 BaseApp.__init__(self, datadir, "submit_usefulness.ui")
2058 # data
2059@@ -1284,8 +1346,8 @@
2060 def login_successful(self, display_name):
2061 logging.debug("delete review")
2062 self.main_notebook.set_current_page(1)
2063- self.api.delete_review(self.review_id)
2064-
2065+ self.api.delete_review(self.review_id)
2066+
2067 def on_transmit_failure(self, api, trans, error):
2068 logging.warn("exiting - error: %s" % error)
2069 self.api.shutdown()
2070@@ -1296,11 +1358,11 @@
2071 # stub ui that can be useful for testing
2072 def run(self):
2073 self.login()
2074-
2075- # override UI update methods from BaseApp to prevent them
2076+
2077+ # override UI update methods from BaseApp to prevent them
2078 # causing errors if called when UI is hidden
2079 def _clear_status_imagery(self):
2080 pass
2081-
2082+
2083 def _change_status(self, type, message):
2084 pass
2085
2086=== modified file 'softwarecenter/ui/gtk3/shapes.py'
2087--- softwarecenter/ui/gtk3/shapes.py 2011-08-09 08:47:43 +0000
2088+++ softwarecenter/ui/gtk3/shapes.py 2012-03-15 03:21:21 +0000
2089@@ -7,7 +7,7 @@
2090
2091 # pi constants
2092 from math import pi as PI
2093-PI_OVER_180 = PI/180
2094+PI_OVER_180 = PI / 180
2095
2096
2097 def radian(deg):
2098@@ -15,6 +15,7 @@
2099
2100 # directional shapes
2101
2102+
2103 class Shape:
2104
2105 """ Base class for a Shape implementation.
2106@@ -28,7 +29,7 @@
2107
2108 If the Shape is direction dependent, the Shape MUST
2109 implement <_layout_ltr> and <_layout_rtl> methods.
2110-
2111+
2112 If the Shape is not direction dependent, then it simply can
2113 override the <layout> method.
2114
2115@@ -46,14 +47,12 @@
2116
2117 def __init__(self, direction):
2118 self.direction = direction
2119- return
2120
2121 def layout(self, cr, x, y, w, h, *args, **kwargs):
2122 if self.direction != Gtk.TextDirection.RTL:
2123 self._layout_ltr(cr, x, y, w, h, *args, **kwargs)
2124 else:
2125 self._layout_rtl(cr, x, y, w, h, *args, **kwargs)
2126- return
2127
2128
2129 class ShapeRoundedRectangle(Shape):
2130@@ -70,18 +69,16 @@
2131
2132 def __init__(self, direction=Gtk.TextDirection.LTR):
2133 Shape.__init__(self, direction)
2134- return
2135
2136 def layout(self, cr, x, y, w, h, *args, **kwargs):
2137 r = kwargs['radius']
2138
2139 cr.new_sub_path()
2140- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
2141- cr.arc(w-r, r+y, r, 270*PI_OVER_180, 0)
2142- cr.arc(w-r, h-r, r, 0, 90*PI_OVER_180)
2143- cr.arc(r+x, h-r, r, 90*PI_OVER_180, PI)
2144+ cr.arc(r + x, r + y, r, PI, 270 * PI_OVER_180)
2145+ cr.arc(w - r, r + y, r, 270 * PI_OVER_180, 0)
2146+ cr.arc(w - r, h - r, r, 0, 90 * PI_OVER_180)
2147+ cr.arc(r + x, h - r, r, 90 * PI_OVER_180, PI)
2148 cr.close_path()
2149- return
2150
2151
2152 class ShapeRoundedRectangleIrregular(Shape):
2153@@ -100,7 +97,6 @@
2154
2155 def __init__(self, direction=Gtk.TextDirection.LTR):
2156 Shape.__init__(self, direction)
2157- return
2158
2159 def layout(self, cr, x, y, w, h, *args, **kwargs):
2160 nw, ne, se, sw = kwargs['radii']
2161@@ -113,161 +109,149 @@
2162 else:
2163 cr.move_to(0, 0)
2164 if ne:
2165- cr.arc(w-ne, ne, ne, 270 * PI_OVER_180, 0)
2166+ cr.arc(w - ne, ne, ne, 270 * PI_OVER_180, 0)
2167 else:
2168- cr.rel_line_to(w-nw, 0)
2169+ cr.rel_line_to(w - nw, 0)
2170 if se:
2171- cr.arc(w-se, h-se, se, 0, 90 * PI_OVER_180)
2172+ cr.arc(w - se, h - se, se, 0, 90 * PI_OVER_180)
2173 else:
2174- cr.rel_line_to(0, h-ne)
2175+ cr.rel_line_to(0, h - ne)
2176 if sw:
2177- cr.arc(sw, h-sw, sw, 90 * PI_OVER_180, PI)
2178+ cr.arc(sw, h - sw, sw, 90 * PI_OVER_180, PI)
2179 else:
2180- cr.rel_line_to(-(w-se), 0)
2181+ cr.rel_line_to(-(w - se), 0)
2182
2183 cr.close_path()
2184 cr.restore()
2185- return
2186
2187
2188 class ShapeStartArrow(Shape):
2189
2190 def __init__(self, direction=Gtk.TextDirection.LTR):
2191 Shape.__init__(self, direction)
2192- return
2193
2194 def _layout_ltr(self, cr, x, y, w, h, *args, **kwargs):
2195 aw = kwargs['arrow_width']
2196 r = kwargs['radius']
2197
2198 cr.new_sub_path()
2199- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
2200+ cr.arc(r + x, r + y, r, PI, 270 * PI_OVER_180)
2201 # arrow head
2202- cr.line_to(w-aw, y)
2203- cr.line_to(w-x+1, (h+y)/2)
2204- cr.line_to(w-aw, h)
2205- cr.arc(r+x, h-r, r, 90*PI_OVER_180, PI)
2206+ cr.line_to(w - aw, y)
2207+ cr.line_to(w - x + 1, (h + y) / 2)
2208+ cr.line_to(w - aw, h)
2209+ cr.arc(r + x, h - r, r, 90 * PI_OVER_180, PI)
2210 cr.close_path()
2211- return
2212
2213 def _layout_rtl(self, cr, x, y, w, h, *args, **kwargs):
2214 aw = kwargs['arrow_width']
2215 r = kwargs['radius']
2216
2217 cr.new_sub_path()
2218- cr.move_to(x, (h+y)/2)
2219+ cr.move_to(x, (h + y) / 2)
2220 cr.line_to(aw, y)
2221- cr.arc(w-r, r+y, r, 270*PI_OVER_180, 0)
2222- cr.arc(w-r, h-r, r, 0, 90*PI_OVER_180)
2223+ cr.arc(w - r, r + y, r, 270 * PI_OVER_180, 0)
2224+ cr.arc(w - r, h - r, r, 0, 90 * PI_OVER_180)
2225 cr.line_to(aw, h)
2226 cr.close_path()
2227- return
2228
2229
2230 class ShapeMidArrow(Shape):
2231
2232 def __init__(self, direction=Gtk.TextDirection.LTR):
2233 Shape.__init__(self, direction)
2234- return
2235
2236 def _layout_ltr(self, cr, x, y, w, h, *args, **kwargs):
2237 aw = kwargs['arrow_width']
2238
2239 cr.move_to(x, y)
2240 # arrow head
2241- cr.line_to(w-aw, y)
2242- cr.line_to(w-x+1, (h+y)/2)
2243- cr.line_to(w-aw, h)
2244+ cr.line_to(w - aw, y)
2245+ cr.line_to(w - x + 1, (h + y) / 2)
2246+ cr.line_to(w - aw, h)
2247 cr.line_to(x, h)
2248 cr.close_path()
2249- return
2250
2251 def _layout_rtl(self, cr, x, y, w, h, *args, **kwargs):
2252 aw = kwargs['arrow_width']
2253
2254- cr.move_to(x, (h+y)/2)
2255+ cr.move_to(x, (h + y) / 2)
2256 cr.line_to(aw, y)
2257 cr.line_to(w, y)
2258 cr.line_to(w, h)
2259 cr.line_to(aw, h)
2260 cr.close_path()
2261- return
2262
2263
2264 class ShapeEndCap(Shape):
2265
2266 def __init__(self, direction=Gtk.TextDirection.LTR):
2267 Shape.__init__(self, direction)
2268- return
2269
2270 def _layout_ltr(self, cr, x, y, w, h, *args, **kwargs):
2271 r = kwargs['radius']
2272 aw = kwargs['arrow_width']
2273
2274- cr.move_to(x-1, y)
2275- cr.arc(w-r, r+y, r, 270*PI_OVER_180, 0)
2276- cr.arc(w-r, h-r, r, 0, 90*PI_OVER_180)
2277- cr.line_to(x-1, h)
2278- cr.line_to(x+aw, (h+y)/2)
2279+ cr.move_to(x - 1, y)
2280+ cr.arc(w - r, r + y, r, 270 * PI_OVER_180, 0)
2281+ cr.arc(w - r, h - r, r, 0, 90 * PI_OVER_180)
2282+ cr.line_to(x - 1, h)
2283+ cr.line_to(x + aw, (h + y) / 2)
2284 cr.close_path()
2285- return
2286
2287 def _layout_rtl(self, cr, x, y, w, h, *args, **kwargs):
2288 r = kwargs['radius']
2289
2290- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
2291+ cr.arc(r + x, r + y, r, PI, 270 * PI_OVER_180)
2292 cr.line_to(w, y)
2293 cr.line_to(w, h)
2294- cr.arc(r+x, h-r, r, 90*PI_OVER_180, PI)
2295+ cr.arc(r + x, h - r, r, 90 * PI_OVER_180, PI)
2296 cr.close_path()
2297- return
2298
2299
2300 class Circle(Shape):
2301
2302 def __init__(self, direction=Gtk.TextDirection.LTR):
2303 Shape.__init__(self, direction)
2304- return
2305
2306 @staticmethod
2307 def layout(cr, x, y, w, h, *args, **kwargs):
2308 cr.new_path()
2309
2310- r = min(w, h)*0.5
2311- x += int((w-2*r)/2)
2312- y += int((h-2*r)/2)
2313+ r = min(w, h) * 0.5
2314+ x += int((w - 2 * r) / 2)
2315+ y += int((h - 2 * r) / 2)
2316
2317- cr.arc(r+x, r+y, r, 0, 360*PI_OVER_180)
2318+ cr.arc(r + x, r + y, r, 0, 360 * PI_OVER_180)
2319 cr.close_path()
2320- return
2321
2322
2323 class ShapeStar(Shape):
2324
2325 def __init__(self, points, indent=0.61, direction=Gtk.TextDirection.LTR):
2326- self.coords = self._calc_coords(points, 1-indent)
2327+ self.coords = self._calc_coords(points, 1 - indent)
2328
2329 def _calc_coords(self, points, indent):
2330 coords = []
2331- step = radian(180.0/points)
2332+ step = radian(180.0 / points)
2333
2334- for i in range(2*points):
2335- if i%2:
2336- x = (sin(step*i)+1)*0.5
2337- y = (cos(step*i)+1)*0.5
2338+ for i in range(2 * points):
2339+ if i % 2:
2340+ x = (sin(step * i) + 1) * 0.5
2341+ y = (cos(step * i) + 1) * 0.5
2342 else:
2343- x = (sin(step*i)*indent+1)*0.5
2344- y = (cos(step*i)*indent+1)*0.5
2345+ x = (sin(step * i) * indent + 1) * 0.5
2346+ y = (cos(step * i) * indent + 1) * 0.5
2347
2348- coords.append((x,y))
2349+ coords.append((x, y))
2350 return coords
2351
2352 def layout(self, cr, x, y, w, h):
2353- points = [ (sx_sy[0]*w+x,sx_sy[1]*h+y) for sx_sy in self.coords ]
2354+ points = [(sx_sy[0] * w + x, sx_sy[1] * h + y)
2355+ for sx_sy in self.coords]
2356 cr.move_to(*points[0])
2357
2358 for p in points[1:]:
2359 cr.line_to(*p)
2360
2361 cr.close_path()
2362- return
2363
2364=== modified file 'softwarecenter/ui/gtk3/utils.py'
2365--- softwarecenter/ui/gtk3/utils.py 2012-02-09 14:42:20 +0000
2366+++ softwarecenter/ui/gtk3/utils.py 2012-03-15 03:21:21 +0000
2367@@ -32,6 +32,7 @@
2368 return (rect.x <= px <= rect.x + rect.width and
2369 rect.y <= py <= rect.y + rect.height)
2370
2371+
2372 def init_sc_css_provider(toplevel, settings, screen, datadir):
2373 context = toplevel.get_style_context()
2374 theme_name = settings.get_property("gtk-theme-name").lower()
2375@@ -41,7 +42,7 @@
2376 # style provider
2377 if toplevel._css_provider._theme_name == theme_name:
2378 return
2379- else: # clean up old css provider if exixts
2380+ else: # clean up old css provider if exixts
2381 context.remove_provider_for_screen(screen, toplevel._css_provider)
2382
2383 # munge css path for theme-name
2384@@ -57,9 +58,10 @@
2385 # check fallback exists as well... if not return None but warn
2386 # its not the end of the world if there is no fallback, just some
2387 # styling will be derived from the plain ol' Gtk theme
2388- msg = "Could not set software-center CSS provider. File '%s' does not exist!"
2389+ msg = ("Could not set software-center CSS provider. File '%s' does "
2390+ "not exist!")
2391 LOG.warn(msg % css_path)
2392- return None
2393+ return
2394
2395 # things seem ok, now set the css provider for softwarecenter
2396 msg = "Softwarecenter style provider for %s Gtk theme: %s"
2397@@ -73,18 +75,19 @@
2398 context.add_provider_for_screen(screen, provider, 800)
2399 return css_path
2400
2401+
2402 def get_sc_icon_theme(datadir):
2403 # additional icons come from app-install-data
2404 icons = Gtk.IconTheme.get_default()
2405 icons.append_search_path(ICON_PATH)
2406- icons.append_search_path(os.path.join(datadir,"icons"))
2407- icons.append_search_path(os.path.join(datadir,"emblems"))
2408+ icons.append_search_path(os.path.join(datadir, "icons"))
2409+ icons.append_search_path(os.path.join(datadir, "emblems"))
2410
2411 # uninstalled run
2412 if os.path.exists('./data/app-stream/icons'):
2413 icons.append_search_path('./data/app-stream/icons')
2414
2415- # add the humanity icon theme to the iconpath, as not all icon
2416+ # add the humanity icon theme to the iconpath, as not all icon
2417 # themes contain all the icons we need
2418 # this *shouldn't* lead to any performance regressions
2419 path = '/usr/share/icons/Humanity'
2420@@ -107,4 +110,3 @@
2421 os.makedirs(icon_cache_dir)
2422 icons.append_search_path(icon_cache_dir)
2423 return icons
2424-
2425
2426=== modified file 'test/test_pep8.py'
2427--- test/test_pep8.py 2012-03-15 01:39:09 +0000
2428+++ test/test_pep8.py 2012-03-15 03:21:21 +0000
2429@@ -8,23 +8,13 @@
2430
2431 # Only test these two packages for now:
2432 import softwarecenter.db.pkginfo_impl
2433-import softwarecenter.ui.gtk3.dialogs
2434-import softwarecenter.ui.gtk3.models
2435-import softwarecenter.ui.gtk3.panes
2436-import softwarecenter.ui.gtk3.session
2437-import softwarecenter.ui.gtk3.views
2438-import softwarecenter.ui.gtk3.widgets
2439+import softwarecenter.ui.gtk3
2440 import softwarecenter.ui.qml
2441
2442 class PackagePep8TestCase(unittest.TestCase):
2443 maxDiff = None
2444 packages = [softwarecenter.ui.qml,
2445- softwarecenter.ui.gtk3.dialogs,
2446- softwarecenter.ui.gtk3.models,
2447- softwarecenter.ui.gtk3.panes,
2448- softwarecenter.ui.gtk3.session,
2449- softwarecenter.ui.gtk3.views,
2450- softwarecenter.ui.gtk3.widgets,
2451+ softwarecenter.ui.gtk3,
2452 softwarecenter.db.pkginfo_impl]
2453 exclude = []
2454