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

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2840
Proposed branch: lp:~elachuni/software-center/pep8-test-part5
Merge into: lp:software-center
Diff against target: 1056 lines (+210/-190)
7 files modified
softwarecenter/ui/gtk3/widgets/exhibits.py (+82/-87)
softwarecenter/ui/gtk3/widgets/imagedialog.py (+7/-2)
softwarecenter/ui/gtk3/widgets/labels.py (+19/-13)
softwarecenter/ui/gtk3/widgets/menubutton.py (+30/-20)
softwarecenter/ui/gtk3/widgets/oneconfviews.py (+33/-27)
softwarecenter/ui/gtk3/widgets/recommendations.py (+38/-39)
test/test_pep8.py (+1/-2)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part5
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+96758@code.launchpad.net

Description of the change

Made 6 more files in softwarecenter/ui/gtk3/widgets/ pass the pep8 test.

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

Thank you, 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/widgets/exhibits.py'
2--- softwarecenter/ui/gtk3/widgets/exhibits.py 2012-02-27 16:56:32 +0000
3+++ softwarecenter/ui/gtk3/widgets/exhibits.py 2012-03-09 13:04:23 +0000
4@@ -37,7 +37,7 @@
5 from softwarecenter.ui.gtk3.utils import point_in
6 import softwarecenter.paths
7
8-LOG=logging.getLogger(__name__)
9+LOG = logging.getLogger(__name__)
10
11 _asset_cache = {}
12 _HAND = Gdk.Cursor.new(Gdk.CursorType.HAND2)
13@@ -75,34 +75,40 @@
14 </body></html>
15 """
16
17+
18 class FeaturedExhibit(object):
19
20 def __init__(self):
21 self.id = 0
22- self.package_names = "armagetronad,calibre,cheese,homebank,stellarium,gimp,inkscape,blender,audacity,gufw,frozen-bubble,fretsonfire,moovida,liferea,arista,gtg,freeciv-client-gtk,openshot,supertuxkart,tumiki-fighters,tuxpaint,webservice-office-zoho"
23+ self.package_names = ("armagetronad,calibre,cheese,homebank,"
24+ "stellarium,gimp,inkscape,blender,audacity,gufw,frozen-bubble,"
25+ "fretsonfire,moovida,liferea,arista,gtg,freeciv-client-gtk,"
26+ "openshot,supertuxkart,tumiki-fighters,tuxpaint,"
27+ "webservice-office-zoho")
28 self.title_translated = _("Our star apps")
29 self.published = True
30- self.banner_url = "file:%s" % (os.path.abspath(os.path.join(softwarecenter.paths.datadir, "default_banner/fallback.png")))
31- self.html = EXHIBIT_HTML % {
32- 'banner_url' : self.banner_url,
33- 'title' : _("Our star apps"),
34- 'subtitle' : _("Come and explore our favourites"),
35- }
36+ self.banner_url = "file:%s" % (os.path.abspath(os.path.join(
37+ softwarecenter.paths.datadir, "default_banner/fallback.png")))
38+ self.html = EXHIBIT_HTML % {
39+ 'banner_url': self.banner_url,
40+ 'title': _("Our star apps"),
41+ 'subtitle': _("Come and explore our favourites"),
42+ }
43 # we should extract this automatically from the html
44 #self.atk_name = _("Default Banner")
45- #self.atk_description = _("You see this banner because you have no cached banners")
46+ #self.atk_description = _("You see this banner because you have no "
47+ # "cached banners")
48
49
50 class _HtmlRenderer(Gtk.OffscreenWindow):
51
52 __gsignals__ = {
53- "render-finished" : (GObject.SignalFlags.RUN_LAST,
54- None,
55+ "render-finished": (GObject.SignalFlags.RUN_LAST,
56+ None,
57 (),
58 )
59 }
60
61-
62 def __init__(self):
63 Gtk.OffscreenWindow.__init__(self)
64 self.view = WebKit.WebView()
65@@ -120,11 +126,10 @@
66 self.on_download_error)
67 self.exhibit = None
68 self.view.connect("notify::load-status", self._on_load_status)
69- return
70
71 def _on_load_status(self, view, prop):
72- if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:
73- # this needs to run with a timeout because otherwise the
74+ if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:
75+ # this needs to run with a timeout because otherwise the
76 # status is emited before the offscreen image is finihsed
77 GObject.timeout_add(100, lambda: self.emit("render-finished"))
78
79@@ -137,26 +142,25 @@
80 if hasattr(self.exhibit, "html") and self.exhibit.html:
81 html = self.exhibit.html
82 else:
83- html = EXHIBIT_HTML % { 'banner_url' : self.exhibit.banner_url,
84- 'title' : self.exhibit.title_translated,
85- 'subtitle' : "",
86- }
87- # replace the server side path with the local image name, this
88+ html = EXHIBIT_HTML % {
89+ 'banner_url': self.exhibit.banner_url,
90+ 'title': self.exhibit.title_translated,
91+ 'subtitle': "",
92+ }
93+ # replace the server side path with the local image name, this
94 # assumes that the image always comes from the same server as
95 # the html
96 scheme, netloc, server_path, para, query, frag = urlparse(
97 self.exhibit.banner_url)
98 html = html.replace(server_path, image_name)
99- self.view.load_string(html, "text/html", "UTF-8",
100+ self.view.load_string(html, "text/html", "UTF-8",
101 "file:%s/" % cache_dir)
102- return
103
104 def set_exhibit(self, exhibit):
105 self.exhibit = exhibit
106- self.loader.download_file(exhibit.banner_url,
107+ self.loader.download_file(exhibit.banner_url,
108 use_cache=True,
109 simple_quoting_for_webkit=True)
110- return
111
112
113 class ExhibitButton(Gtk.Button):
114@@ -183,7 +187,6 @@
115 self._dropshadow = self.DROPSHADOW.scale_simple(
116 a.width, a.width, GdkPixbuf.InterpType.BILINEAR)
117 self._margin = int(float(a.width) / self.DROPSHADOW.get_width() * 15)
118- return
119
120 def do_draw(self, cr):
121 a = self.get_allocation()
122@@ -194,9 +197,9 @@
123 y = (a.height - ds_h) / 2
124 Gdk.cairo_set_source_pixbuf(cr, self._dropshadow, 0, y)
125 cr.paint()
126- Circle.layout(cr, self._margin, (a.height-ds_h)/2 + self._margin,
127- a.width-2*self._margin,
128- a.width-2*self._margin)
129+ Circle.layout(cr, self._margin, (a.height - ds_h) / 2 + self._margin,
130+ a.width - 2 * self._margin,
131+ a.width - 2 * self._margin)
132 if self.is_active:
133 color = context.get_background_color(Gtk.StateFlags.SELECTED)
134 else:
135@@ -205,9 +208,8 @@
136 Gdk.cairo_set_source_rgba(cr, color)
137 cr.fill()
138
139- for child in self:
140+ for child in self:
141 self.propagate_draw(child, cr)
142- return
143
144
145 class ExhibitArrowButton(ExhibitButton):
146@@ -215,24 +217,24 @@
147 def __init__(self, arrow_type, shadow_type=Gtk.ShadowType.IN):
148 ExhibitButton.__init__(self)
149 a = Gtk.Alignment()
150- a.set_padding(1,1,1,1)
151- a.add(Gtk.Arrow.new(arrow_type, shadow_type))
152+ a.set_padding(1, 1, 1, 1)
153+ a.add(Gtk.Arrow.new(arrow_type, shadow_type))
154 self.add(a)
155- return
156
157
158 class ExhibitBanner(Gtk.EventBox):
159- # FIXME: sometimes despite set_exhibit being called the new exhibit isn't actually displayed
160+ # FIXME: sometimes despite set_exhibit being called the new exhibit isn't
161+ # actually displayed
162
163 __gsignals__ = {
164- "show-exhibits-clicked" : (GObject.SignalFlags.RUN_LAST,
165- None,
166- (GObject.TYPE_PYOBJECT,),
167- )
168+ "show-exhibits-clicked": (GObject.SignalFlags.RUN_LAST,
169+ None,
170+ (GObject.TYPE_PYOBJECT,),
171+ )
172 }
173
174 DROPSHADOW_HEIGHT = 11
175- MAX_HEIGHT = 200 # pixels
176+ MAX_HEIGHT = 200 # pixels
177 TIMEOUT_SECONDS = 10
178
179 def __init__(self):
180@@ -274,8 +276,8 @@
181 self.pressed = False
182
183 self.alpha = 1.0
184- self.image = None
185- self.old_image = None
186+ self.image = None
187+ self.old_image = None
188 self.renderer = _HtmlRenderer()
189 self.renderer.connect("render-finished", self.on_banner_rendered)
190
191@@ -295,9 +297,9 @@
192
193 def _init_event_handling(self):
194 self.set_can_focus(True)
195- self.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK|
196- Gdk.EventMask.BUTTON_PRESS_MASK|
197- Gdk.EventMask.ENTER_NOTIFY_MASK|
198+ self.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK |
199+ Gdk.EventMask.BUTTON_PRESS_MASK |
200+ Gdk.EventMask.ENTER_NOTIFY_MASK |
201 Gdk.EventMask.LEAVE_NOTIFY_MASK)
202 self.connect("enter-notify-event", self.on_enter_notify)
203 self.connect("leave-notify-event", self.on_leave_notify)
204@@ -316,12 +318,10 @@
205
206 def on_enter_notify(self, *args):
207 self._init_mouse_pointer()
208- return
209
210 def on_leave_notify(self, *args):
211 window = self.get_window()
212 window.set_cursor(None)
213- return
214
215 def on_button_release(self, widget, event):
216 if not point_in(self.get_allocation(),
217@@ -333,14 +333,11 @@
218 if exhibit.package_names and self.pressed:
219 self.emit("show-exhibits-clicked", exhibit)
220 self.pressed = False
221- return
222
223 def on_button_press(self, widget, event):
224- if not point_in(self.get_allocation(),
225- int(event.x), int(event.y)):
226- return
227- self.pressed = True
228- return
229+ if point_in(self.get_allocation(),
230+ int(event.x), int(event.y)):
231+ self.pressed = True
232
233 def on_key_press(self, widget, event):
234 # activate
235@@ -366,18 +363,15 @@
236 def on_next_clicked(self, *args):
237 self.next_exhibit()
238 self.queue_next()
239- return
240
241 def on_previous_clicked(self, *args):
242 self.previous()
243 self.queue_next()
244- return
245
246 def cleanup_timeout(self):
247 if self._timeout > 0:
248 GObject.source_remove(self._timeout)
249 self._timeout = 0
250- return
251
252 def _render_exhibit_at_cursor(self):
253 # init the mouse pointer
254@@ -402,7 +396,7 @@
255
256 # next() is a special function in py3 so we call this next_exhibit
257 def next_exhibit(self):
258- if len(self.exhibits)-1 == self.cursor:
259+ if len(self.exhibits) - 1 == self.cursor:
260 self.cursor = 0
261 else:
262 self.cursor += 1
263@@ -411,7 +405,7 @@
264
265 def previous(self):
266 if self.cursor == 0:
267- self.cursor = len(self.exhibits)-1
268+ self.cursor = len(self.exhibits) - 1
269 else:
270 self.cursor -= 1
271 self._render_exhibit_at_cursor()
272@@ -433,7 +427,8 @@
273 return
274
275 from gi.repository import Atk
276- self.get_accessible().set_name(self.exhibits[self.cursor].title_translated)
277+ self.get_accessible().set_name(
278+ self.exhibits[self.cursor].title_translated)
279 self.get_accessible().set_role(Atk.Role.PUSH_BUTTON)
280 self._fade_in()
281 self.queue_next()
282@@ -455,12 +450,11 @@
283 return retval
284
285 GObject.timeout_add(50, fade_step)
286- return
287
288 def _cache_art_assets(self):
289 global _asset_cache
290 assets = _asset_cache
291- if assets:
292+ if assets:
293 return assets
294
295 #~ surf = cairo.ImageSurface.create_from_png(self.NORTHERN_DROPSHADOW)
296@@ -490,7 +484,7 @@
297
298 a = self.get_allocation()
299
300- cr.set_source_rgb(1,1,1)
301+ cr.set_source_rgb(1, 1, 1)
302 cr.paint()
303
304 # workaround a really odd bug in the offscreen window of the
305@@ -519,7 +513,7 @@
306 highlight = context.get_background_color(self.get_state_flags())
307 context.restore()
308
309- rounded_rect(cr, 1, 1, a.width-2, a.height-3, 5)
310+ rounded_rect(cr, 1, 1, a.width - 2, a.height - 3, 5)
311 Gdk.cairo_set_source_rgba(cr, highlight)
312 cr.set_line_width(6)
313 cr.stroke()
314@@ -531,26 +525,25 @@
315 #~ cr.paint()
316 #~ cr.reset_clip()
317
318- cr.rectangle(0, a.height-self.DROPSHADOW_HEIGHT,
319+ cr.rectangle(0, a.height - self.DROPSHADOW_HEIGHT,
320 a.width, self.DROPSHADOW_HEIGHT)
321 cr.clip()
322 cr.save()
323- cr.translate(0, a.height-self.DROPSHADOW_HEIGHT)
324+ cr.translate(0, a.height - self.DROPSHADOW_HEIGHT)
325 cr.set_source(_asset_cache["s"])
326 cr.paint()
327 cr.restore()
328
329 cr.set_line_width(1)
330- cr.move_to(-0.5, a.height-0.5)
331- cr.rel_line_to(a.width+1, 0)
332- cr.set_source_rgba(1,1,1,0.75)
333+ cr.move_to(-0.5, a.height - 0.5)
334+ cr.rel_line_to(a.width + 1, 0)
335+ cr.set_source_rgba(1, 1, 1, 0.75)
336 cr.stroke()
337
338 cr.restore()
339
340- for child in self:
341+ for child in self:
342 self.propagate_draw(child, cr)
343- return
344
345 def _init_pause_handling_if_needed(self):
346 # nothing todo if we have the toplevel already
347@@ -564,7 +557,7 @@
348 if not isinstance(w, Gtk.Window):
349 return
350 # connect to property changes for the toplevel focus
351- w.connect("notify::has-toplevel-focus",
352+ w.connect("notify::has-toplevel-focus",
353 self._on_main_window_is_active_changed)
354 self._toplevel_window = w
355
356@@ -579,8 +572,7 @@
357 self.cleanup_timeout()
358
359 def set_exhibits(self, exhibits_list):
360-
361- if not exhibits_list:
362+ if not exhibits_list:
363 return
364
365 self.exhibits = exhibits_list
366@@ -600,13 +592,13 @@
367 self._dotsigs.append(
368 dot.connect("clicked",
369 self.on_paging_dot_clicked,
370- len(self.exhibits) - 1 - i) # index
371+ len(self.exhibits) - 1 - i) # index
372 )
373 self.index_hbox.pack_end(dot, False, False, 0)
374 self.index_hbox.show_all()
375
376 self._render_exhibit_at_cursor()
377- return
378+
379
380 def get_test_exhibits_window():
381 from mock import Mock
382@@ -618,19 +610,22 @@
383
384 exhibits_list = [FeaturedExhibit()]
385 for (i, (title, url)) in enumerate([
386- ("1 some title", "https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=orangeubuntulogo.png"),
387- ("2 another title", "https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=blackeubuntulogo.png"),
388- ("3 yet another title", "https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=xubuntu.png"),
389- ]):
390- exhibit = Mock()
391- exhibit.id = i
392- exhibit.package_names = "apt,2vcard"
393- exhibit.published = True
394- exhibit.style = "some uri to html"
395- exhibit.title_translated = title
396- exhibit.banner_url = url
397- exhibit.html = None
398- exhibits_list.append(exhibit)
399+ ("1 some title", "https://wiki.ubuntu.com/Brand?"
400+ "action=AttachFile&do=get&target=orangeubuntulogo.png"),
401+ ("2 another title", "https://wiki.ubuntu.com/Brand?"
402+ "action=AttachFile&do=get&target=blackeubuntulogo.png"),
403+ ("3 yet another title", "https://wiki.ubuntu.com/Brand?"
404+ "action=AttachFile&do=get&target=xubuntu.png"),
405+ ]):
406+ exhibit = Mock()
407+ exhibit.id = i
408+ exhibit.package_names = "apt,2vcard"
409+ exhibit.published = True
410+ exhibit.style = "some uri to html"
411+ exhibit.title_translated = title
412+ exhibit.banner_url = url
413+ exhibit.html = None
414+ exhibits_list.append(exhibit)
415
416 exhibit_banner.set_exhibits(exhibits_list)
417
418
419=== modified file 'softwarecenter/ui/gtk3/widgets/imagedialog.py'
420--- softwarecenter/ui/gtk3/widgets/imagedialog.py 2011-09-06 09:06:41 +0000
421+++ softwarecenter/ui/gtk3/widgets/imagedialog.py 2012-03-09 13:04:23 +0000
422@@ -22,12 +22,15 @@
423
424 ICON_EXCEPTIONS = ["gnome"]
425
426+
427 class Url404Error(IOError):
428 pass
429
430+
431 class Url403Error(IOError):
432 pass
433
434+
435 class SimpleShowImageDialog(Gtk.Dialog):
436 """A dialog that shows a image """
437
438@@ -61,7 +64,7 @@
439 self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
440 self.set_default_size(SimpleShowImageDialog.DEFAULT_WIDTH,
441 SimpleShowImageDialog.DEFAULT_HEIGHT)
442-
443+
444 def run(self):
445 # show all and run the real thing
446 self.show_all()
447@@ -71,5 +74,7 @@
448 if __name__ == "__main__":
449
450 # pixbuf
451- d = SimpleShowImageDialog("Synaptic Screenshot", GdkPixbuf.Pixbuf.new_from_file("/usr/share/software-center/images/arrows.png"))
452+ d = SimpleShowImageDialog("Synaptic Screenshot",
453+ GdkPixbuf.Pixbuf.new_from_file(
454+ "/usr/share/software-center/images/arrows.png"))
455 d.run()
456
457=== modified file 'softwarecenter/ui/gtk3/widgets/labels.py'
458--- softwarecenter/ui/gtk3/widgets/labels.py 2012-01-26 22:11:41 +0000
459+++ softwarecenter/ui/gtk3/widgets/labels.py 2012-03-09 13:04:23 +0000
460@@ -21,26 +21,27 @@
461
462 from softwarecenter.hw import TAG_DESCRIPTION
463
464+
465 class HardwareRequirementsLabel(Gtk.HBox):
466- """ contains a single HW requirement string and a image that shows if
467- the requirements are meet
468+ """ contains a single HW requirement string and a image that shows if
469+ the requirements are meet
470 """
471
472 SUPPORTED_SYM = {
473 # TRANSLATORS: symbol for "hardware-supported"
474- 'yes' : _(u'\u2713'),
475+ 'yes': _(u'\u2713'),
476 # TRANSLATORS: symbol for hardware "not-supported"
477- 'no' : u'<span foreground="red">%s</span>' % _(u'\u2718'),
478+ 'no': u'<span foreground="red">%s</span>' % _(u'\u2718'),
479 }
480
481- # TRANSLATORS: this is a substring that used to build the
482+ # TRANSLATORS: this is a substring that used to build the
483 # "hardware-supported" string, where sym is
484 # either a unicode checkmark or a cross
485 # and hardware is the short hardware description
486 # Note that this is the last substr, no trailing ","
487 LABEL_LAST_ITEM = _("%(sym)s%(hardware)s")
488
489- # TRANSLATORS: this is a substring that used to build the
490+ # TRANSLATORS: this is a substring that used to build the
491 # "hardware-supported" string, where sym is
492 # either a unicode checkmark or a cross
493 # and hardware is the short hardware description
494@@ -53,27 +54,31 @@
495 self.result = None
496 self.last_item = last_item
497 self._build_ui()
498+
499 def _build_ui(self):
500 self._label = Gtk.Label()
501 self._label.show()
502 self.pack_start(self._label, True, True, 0)
503+
504 def get_label(self):
505 # get the right symbol
506 sym = self.SUPPORTED_SYM[self.result]
507- # we add a trailing
508+ # we add a trailing
509 if self.last_item:
510 s = self.LABEL_LAST_ITEM
511 else:
512- s= self.LABEL
513+ s = self.LABEL
514 return _(s) % {
515- "sym" : sym,
516- "hardware" : _(TAG_DESCRIPTION[self.tag]),
517+ "sym": sym,
518+ "hardware": _(TAG_DESCRIPTION[self.tag]),
519 }
520+
521 def set_hardware_requirement(self, tag, result):
522 self.tag = tag
523 self.result = result
524 self._label.set_markup(self.get_label())
525
526+
527 class HardwareRequirementsBox(Gtk.HBox):
528 """ A collection of HW requirement labels """
529
530@@ -107,9 +112,10 @@
531 win = Gtk.Window()
532 win.set_size_request(300, 200)
533
534- HW_TEST_RESULT = { 'hardware::gps' : 'yes',
535- 'hardware::video:opengl' : 'no',
536- }
537+ HW_TEST_RESULT = {
538+ 'hardware::gps': 'yes',
539+ 'hardware::video:opengl': 'no',
540+ }
541
542 # add it
543 hwbox = HardwareRequirementsBox()
544
545=== modified file 'softwarecenter/ui/gtk3/widgets/menubutton.py'
546--- softwarecenter/ui/gtk3/widgets/menubutton.py 2012-01-05 09:49:23 +0000
547+++ softwarecenter/ui/gtk3/widgets/menubutton.py 2012-03-09 13:04:23 +0000
548@@ -18,11 +18,12 @@
549
550 from gi.repository import Gtk
551
552+
553 class MenuButton(Gtk.Button):
554
555 def __init__(self, menu, icon=None, label=None):
556 super(MenuButton, self).__init__()
557-
558+
559 box = Gtk.Box()
560 self.add(box)
561
562@@ -30,12 +31,12 @@
563 box.pack_start(icon, False, True, 1)
564 if label:
565 box.pack_start(Gtk.Label(label), True, True, 0)
566-
567+
568 arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.OUT)
569 box.pack_start(arrow, False, False, 1)
570
571 self.menu = menu
572-
573+
574 self.connect("button-press-event", self.on_button_pressed, menu)
575 self.connect("clicked", self.on_keyboard_clicked, menu)
576
577@@ -44,18 +45,21 @@
578 return self.menu
579
580 def on_button_pressed(self, button, event, menu):
581- menu.popup(None, None, self.menu_positionner, (button, event.x), event.button, event.time)
582+ menu.popup(None, None, self.menu_positionner, (button, event.x),
583+ event.button, event.time)
584
585 def on_keyboard_clicked(self, button, menu):
586- menu.popup(None, None, self.menu_positionner, (button, None), 1, Gtk.get_current_event_time())
587+ menu.popup(None, None, self.menu_positionner, (button, None), 1,
588+ Gtk.get_current_event_time())
589
590 def menu_positionner(self, menu, (button, x_cursor_pos)):
591 (button_id, x, y) = button.get_window().get_origin()
592
593 # compute button position
594 x_position = x + button.get_allocation().x
595- y_position = y + button.get_allocation().y + button.get_allocated_height()
596-
597+ y_position = (y + button.get_allocation().y +
598+ button.get_allocated_height())
599+
600 # if pressed by the mouse, center the X position to it
601 if x_cursor_pos:
602 x_position += x_cursor_pos
603@@ -63,19 +67,24 @@
604
605 # computer current monitor height
606 current_screen = button.get_screen()
607- num_monitor = current_screen.get_monitor_at_point(x_position, y_position)
608+ num_monitor = current_screen.get_monitor_at_point(x_position,
609+ y_position)
610 monitor_geo = current_screen.get_monitor_geometry(num_monitor)
611-
612+
613 # if the menu width is of the current monitor, shift is a little
614 if x_position < monitor_geo.x:
615 x_position = monitor_geo.x
616- if x_position + menu.get_allocated_width() > monitor_geo.x + monitor_geo.width:
617- x_position = monitor_geo.x + monitor_geo.width - menu.get_allocated_width()
618-
619- # if the menu height is too long for the monitor, put it above the widget
620+ if (x_position + menu.get_allocated_width() > monitor_geo.x +
621+ monitor_geo.width):
622+ x_position = (monitor_geo.x + monitor_geo.width -
623+ menu.get_allocated_width())
624+
625+ # if the menu height is too long for the monitor, put it above the
626+ # widget
627 if monitor_geo.height < y_position + menu.get_allocated_height():
628- y_position = y_position - button.get_allocated_height() - menu.get_allocated_height()
629-
630+ y_position = (y_position - button.get_allocated_height() -
631+ menu.get_allocated_height())
632+
633 return (x_position, y_position, True)
634
635
636@@ -93,23 +102,24 @@
637 menuitem2.show()
638
639 box1 = Gtk.Box()
640- box1.pack_start(Gtk.Label("something before to show we don't cheat"), True, True, 0)
641+ box1.pack_start(Gtk.Label("something before to show we don't cheat"),
642+ True, True, 0)
643 win.add(box1)
644
645 box2 = Gtk.Box()
646- box2.set_orientation(Gtk.Orientation.VERTICAL)
647+ box2.set_orientation(Gtk.Orientation.VERTICAL)
648 box1.pack_start(box2, True, True, 0)
649 box2.pack_start(Gtk.Label("first label with multiple line"), True, True, 0)
650-
651+
652 image = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.BUTTON)
653 label = "fooo"
654 button_with_menu = MenuButton(menu, image, label)
655- box2.pack_start(button_with_menu, False, False, 1)
656+ box2.pack_start(button_with_menu, False, False, 1)
657
658 win.connect("destroy", lambda x: Gtk.main_quit())
659 win.show_all()
660
661 settings = Gtk.Settings.get_default()
662 settings.set_property("gtk-button-images", True)
663-
664+
665 Gtk.main()
666
667=== modified file 'softwarecenter/ui/gtk3/widgets/oneconfviews.py'
668--- softwarecenter/ui/gtk3/widgets/oneconfviews.py 2012-01-05 09:49:23 +0000
669+++ softwarecenter/ui/gtk3/widgets/oneconfviews.py 2012-03-09 13:04:23 +0000
670@@ -25,26 +25,28 @@
671 class OneConfViews(Gtk.TreeView):
672
673 __gsignals__ = {
674- "computer-changed" : (GObject.SIGNAL_RUN_LAST,
675- GObject.TYPE_NONE,
676- (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT),
677- ),
678- "current-inventory-refreshed" : (GObject.SIGNAL_RUN_LAST,
679- GObject.TYPE_NONE,
680- (),),
681+ "computer-changed": (GObject.SIGNAL_RUN_LAST,
682+ GObject.TYPE_NONE,
683+ (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT),
684+ ),
685+ "current-inventory-refreshed": (GObject.SIGNAL_RUN_LAST,
686+ GObject.TYPE_NONE,
687+ (),
688+ ),
689 }
690-
691+
692 (COL_ICON, COL_HOSTID, COL_HOSTNAME) = range(3)
693
694 def __init__(self, icons):
695 super(OneConfViews, self).__init__()
696- model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_STRING)
697+ model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
698+ GObject.TYPE_STRING)
699 model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)
700 model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)
701 self.set_model(model)
702 self.set_headers_visible(False)
703 self.col = Gtk.TreeViewColumn('hostname')
704-
705+
706 hosticon_renderer = Gtk.CellRendererPixbuf()
707 hostname_renderer = Gtk.CellRendererText()
708 self.col.pack_start(hosticon_renderer, False)
709@@ -57,9 +59,9 @@
710
711 # TODO: load the dynamic one (if present), later
712 self.default_computer_icon = icons.load_icon("computer", 22, 0)
713-
714+
715 self.connect("cursor-changed", self.on_cursor_changed)
716-
717+
718 def register_computer(self, hostid, hostname):
719 '''Add a new computer to the model'''
720 model = self.get_model()
721@@ -73,17 +75,20 @@
722 model.append([self.default_computer_icon, hostid, hostname])
723
724 def store_packagelist_changed(self, hostid):
725- '''Emit a signal for refreshing the installedpane if current view is concerned'''
726+ '''Emit a signal for refreshing the installedpane if current view is
727+ concerned
728+ '''
729 if hostid == self.current_hostid:
730 self.emit("current-inventory-refreshed")
731-
732+
733 def remove_computer(self, hostid):
734 '''Remove a computer from the model'''
735 model = self.get_model()
736 if not model:
737 return
738 if hostid not in self.hostids:
739- LOG.warning("ask to remove a computer that isn't registered: %s" % hostid)
740+ LOG.warning("ask to remove a computer that isn't registered: %s" %
741+ hostid)
742 return
743 iter_id = model.get_iter_first()
744 while iter_id:
745@@ -92,8 +97,7 @@
746 self.hostids.remove(hostid)
747 break
748 iter_id = model.iter_next(iter_id)
749-
750-
751+
752 def on_cursor_changed(self, widget):
753
754 (path, column) = self.get_cursor()
755@@ -101,28 +105,30 @@
756 return
757 model = self.get_model()
758 if not model:
759- return
760+ return
761 hostid = model[path][self.COL_HOSTID]
762 hostname = model[path][self.COL_HOSTNAME]
763 if hostid != self.current_hostid:
764 self.current_hostid = hostid
765 self.emit("computer-changed", hostid, hostname)
766-
767+
768 def select_first(self):
769 '''Select first item'''
770 self.set_cursor(Gtk.TreePath.new_first(), None, False)
771-
772+
773 def _sort_hosts(self, model, iter1, iter2, user_data):
774 '''Sort hosts, with "this computer" (NONE HOSTID) as first'''
775 if not self.get_model().get_value(iter1, self.COL_HOSTID):
776 return -1
777 if not self.get_model().get_value(iter2, self.COL_HOSTID):
778- return 1
779- if self.get_model().get_value(iter1, self.COL_HOSTNAME) > self.get_model().get_value(iter2, self.COL_HOSTNAME):
780+ return 1
781+ if (self.get_model().get_value(iter1, self.COL_HOSTNAME) >
782+ self.get_model().get_value(iter2, self.COL_HOSTNAME)):
783 return 1
784 else:
785 return -1
786-
787+
788+
789 def get_test_window():
790
791 w = OneConfViews(Gtk.IconTheme.get_default())
792@@ -141,14 +147,14 @@
793 w.register_computer("CCCCC", "NameC")
794 w.register_computer("", "This computer should be first")
795 w.select_first()
796-
797+
798 GObject.timeout_add_seconds(5, w.register_computer, "EEEEE", "NameE")
799-
800+
801 def print_selected_hostid(widget, hostid, hostname):
802 print "%s selected for %s" % (hostid, hostname)
803-
804+
805 w.connect("computer-changed", print_selected_hostid)
806-
807+
808 w.remove_computer("DDDDD")
809 win.show_all()
810 return win
811
812=== modified file 'softwarecenter/ui/gtk3/widgets/recommendations.py'
813--- softwarecenter/ui/gtk3/widgets/recommendations.py 2012-03-01 10:43:09 +0000
814+++ softwarecenter/ui/gtk3/widgets/recommendations.py 2012-03-09 13:04:23 +0000
815@@ -32,16 +32,17 @@
816
817 LOG = logging.getLogger(__name__)
818
819+
820 class RecommendationsPanel(FramedHeaderBox):
821 """
822 Base class for widgets that display recommendations
823 """
824
825 __gsignals__ = {
826- "application-activated" : (GObject.SIGNAL_RUN_LAST,
827- GObject.TYPE_NONE,
828- (GObject.TYPE_PYOBJECT,),
829- ),
830+ "application-activated": (GObject.SIGNAL_RUN_LAST,
831+ GObject.TYPE_NONE,
832+ (GObject.TYPE_PYOBJECT,),
833+ ),
834 }
835
836 def __init__(self, catview):
837@@ -53,31 +54,32 @@
838 self.catview.connect(
839 "application-activated", self._on_application_activated)
840 self.recommender_agent = RecommenderAgent()
841+
842 def _on_application_activated(self, catview, app):
843 self.emit("application-activated", app)
844
845+
846 class RecommendationsPanelLobby(RecommendationsPanel):
847 """
848- Panel for use in the lobby view that manages the recommendations experience,
849- includes the initial opt-in screen and display of recommendations once they
850- have been received from the recommender agent
851+ Panel for use in the lobby view that manages the recommendations
852+ experience, includes the initial opt-in screen and display of
853+ recommendations once they have been received from the recommender agent
854 """
855-
856 __gsignals__ = {
857- "recommendations-opt-in" : (GObject.SIGNAL_RUN_LAST,
858- GObject.TYPE_NONE,
859- (GObject.TYPE_STRING,),
860+ "recommendations-opt-in": (GObject.SIGNAL_RUN_LAST,
861+ GObject.TYPE_NONE,
862+ (GObject.TYPE_STRING,),
863+ ),
864+ "recommendations-opt-out": (GObject.SIGNAL_RUN_LAST,
865+ GObject.TYPE_NONE,
866+ (),
867 ),
868- "recommendations-opt-out" : (GObject.SIGNAL_RUN_LAST,
869- GObject.TYPE_NONE,
870- (),
871- ),
872 }
873-
874+
875 def __init__(self, catview):
876 RecommendationsPanel.__init__(self, catview)
877 self.set_header_label(_(u"Recommended for You"))
878-
879+
880 # if we already have a recommender UUID, then the user is already
881 # opted-in to the recommender service
882 self.recommended_for_you_content = None
883@@ -85,14 +87,14 @@
884 self._update_recommended_for_you_content()
885 else:
886 self._show_opt_in_view()
887-
888+
889 def _show_opt_in_view(self):
890 # opt in box
891 vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, StockEms.MEDIUM)
892 vbox.set_border_width(StockEms.LARGE)
893 self.opt_in_vbox = vbox # for tests
894 self.recommended_for_you_content = vbox # hook it up to the rest
895-
896+
897 self.add(self.recommended_for_you_content)
898
899 # opt in button
900@@ -111,7 +113,7 @@
901 label.set_alignment(0, 0.5)
902 label.set_line_wrap(True)
903 vbox.pack_start(label, False, False, 0)
904-
905+
906 def _on_opt_in_button_clicked(self, button):
907 # we upload the user profile here, and only after this is finished
908 # do we fire the request for recommendations and finally display
909@@ -119,11 +121,11 @@
910 # wants a progress bar, but we don't have access to real-time
911 # progress info)
912 self._upload_user_profile_and_get_recommendations()
913-
914+
915 def _upload_user_profile_and_get_recommendations(self):
916 # initiate upload of the user profile here
917 self._upload_user_profile()
918-
919+
920 def _upload_user_profile(self):
921 self.spinner_notebook.show_spinner(_("Submitting inventory…"))
922 self.recommender_agent.connect("submit-profile-finished",
923@@ -131,7 +133,7 @@
924 self.recommender_agent.connect("error",
925 self._on_profile_submitted_error)
926 self.recommender_agent.post_submit_profile(self.catview.db)
927-
928+
929 def _on_profile_submitted(self, agent, profile, recommender_uuid):
930 # after the user profile data has been uploaded, make the request
931 # and load the the recommended_for_you content
932@@ -139,13 +141,13 @@
933 "submitted to the recommender agent")
934 self.emit("recommendations-opt-in", recommender_uuid)
935 self._update_recommended_for_you_content()
936-
937+
938 def _on_profile_submitted_error(self, agent, msg):
939 LOG.warn("Error while submitting the recommendations profile to the "
940 "recommender agent: %s" % msg)
941 # TODO: handle this! display an error message in the panel
942 self._hide_recommended_for_you_panel()
943-
944+
945 def _update_recommended_for_you_content(self):
946 # destroy the old content to ensure we don't see it twice
947 # (also removes the opt-in panel if it was there)
948@@ -163,7 +165,7 @@
949 self._on_recommended_for_you_agent_refresh)
950 self.recommended_for_you_cat.connect('recommender-agent-error',
951 self._on_recommender_agent_error)
952-
953+
954 def _on_recommended_for_you_agent_refresh(self, cat):
955 docs = cat.get_documents(self.catview.db)
956 # display the recommendedations
957@@ -179,8 +181,7 @@
958 # TODO: this test for zero docs is temporary and will not be
959 # needed once the recommendation agent is up and running
960 self._hide_recommended_for_you_panel()
961- return
962-
963+
964 def _on_recommender_agent_error(self, agent, msg):
965 LOG.warn("Error while accessing the recommender agent for the "
966 "lobby recommendations: %s" % msg)
967@@ -190,8 +191,8 @@
968 def _hide_recommended_for_you_panel(self):
969 # and hide the pane
970 self.hide()
971-
972-
973+
974+
975 class RecommendationsPanelDetails(RecommendationsPanel):
976 """
977 Panel for use in the details view to display recommendations for a given
978@@ -202,7 +203,7 @@
979 self.set_header_label(_(u"People Also Installed"))
980 self.app_recommendations_content = FlowableGrid()
981 self.add(self.app_recommendations_content)
982-
983+
984 def set_pkgname(self, pkgname):
985 self.pkgname = pkgname
986 self._update_app_recommendations_content()
987@@ -217,7 +218,7 @@
988 self._on_app_recommendations_agent_refresh)
989 self.app_recommendations_cat.connect('recommender-agent-error',
990 self._on_recommender_agent_error)
991-
992+
993 def _on_app_recommendations_agent_refresh(self, cat):
994 docs = cat.get_documents(self.catview.db)
995 # display the recommendations
996@@ -228,8 +229,7 @@
997 self.spinner_notebook.hide_spinner()
998 else:
999 self._hide_app_recommendations_panel()
1000- return
1001-
1002+
1003 def _on_recommender_agent_error(self, agent, msg):
1004 LOG.warn("Error while accessing the recommender agent for the "
1005 "details view recommendations: %s" % msg)
1006@@ -239,7 +239,7 @@
1007 def _hide_app_recommendations_panel(self):
1008 # and hide the pane
1009 self.hide()
1010-
1011+
1012
1013 # test helpers
1014 def get_test_window():
1015@@ -247,7 +247,6 @@
1016 softwarecenter.log.root.setLevel(level=logging.DEBUG)
1017 fmt = logging.Formatter("%(name)s - %(message)s", None)
1018 softwarecenter.log.handler.setFormatter(fmt)
1019-
1020
1021 # this is *way* to complicated we should *not* need a CatView
1022 # here! see FIXME in RecommendationsPanel.__init__()
1023@@ -259,7 +258,7 @@
1024 icons = get_test_gtk3_icon_cache()
1025 catview = CategoriesViewGtk(softwarecenter.paths.datadir,
1026 softwarecenter.paths.APP_INSTALL_PATH,
1027- cache,
1028+ cache,
1029 db,
1030 icons)
1031
1032@@ -271,9 +270,9 @@
1033 win.set_data("rec_panel", view)
1034 win.set_size_request(600, 200)
1035 win.show_all()
1036-
1037+
1038 return win
1039-
1040+
1041
1042 if __name__ == "__main__":
1043 win = get_test_window()
1044
1045=== modified file 'test/test_pep8.py'
1046--- test/test_pep8.py 2012-03-08 22:33:18 +0000
1047+++ test/test_pep8.py 2012-03-09 13:04:23 +0000
1048@@ -16,8 +16,7 @@
1049 packages = [softwarecenter.ui.qml,
1050 softwarecenter.ui.gtk3.widgets,
1051 softwarecenter.db.pkginfo_impl]
1052- exclude = ['recommendations.py', 'oneconfviews.py', 'menubutton.py',
1053- 'labels.py', 'imagedialog.py', 'exhibits.py', 'description.py',
1054+ exclude = ['description.py',
1055 'containers.py', 'cellrenderers.py', 'buttons.py', 'backforward.py',
1056 'apptreeview.py', 'animatedimage.py', 'actionbar.py']
1057