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

Proposed by Anthony Lenton
Status: Merged
Merged at revision: 2844
Proposed branch: lp:~elachuni/software-center/pep8-test-part7
Merge into: lp:software-center
Diff against target: 1123 lines (+181/-202)
4 files modified
softwarecenter/ui/gtk3/widgets/animatedimage.py (+14/-16)
softwarecenter/ui/gtk3/widgets/cellrenderers.py (+82/-92)
softwarecenter/ui/gtk3/widgets/containers.py (+84/-92)
test/test_pep8.py (+1/-2)
To merge this branch: bzr merge lp:~elachuni/software-center/pep8-test-part7
Reviewer Review Type Date Requested Status
Kiwinote Approve
Review via email: mp+97011@code.launchpad.net

Description of the change

Another bit of whitespace shuffling. Three more files in softwarecenter/ui/gtk3/widgets, I'm almost done with this package.

To post a comment you must log in.
Revision history for this message
Kiwinote (kiwinote) wrote :

looks good - much thanks!

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/animatedimage.py'
2--- softwarecenter/ui/gtk3/widgets/animatedimage.py 2011-07-26 13:20:59 +0000
3+++ softwarecenter/ui/gtk3/widgets/animatedimage.py 2012-03-12 13:15:22 +0000
4@@ -24,8 +24,9 @@
5
6 class ProgressImage(Gtk.Image):
7
8- ANIMATION_PATH = "/usr/share/icons/hicolor/24x24/status/softwarecenter-progress.png"
9- FRAME_DELAY = 50 # msec
10+ ANIMATION_PATH = ("/usr/share/icons/hicolor/24x24/status/"
11+ "softwarecenter-progress.png")
12+ FRAME_DELAY = 50 # msec
13
14 BUBBLE_BORDER_RADIUS = 6
15 BUBBLE_XPADDING = 4
16@@ -55,7 +56,6 @@
17 # a Pango.Layout for rendering the transaction count
18 layout = self.create_pango_layout("")
19 self.connect("draw", self.on_draw, layout)
20- return
21
22 # overrides
23 def do_get_preferred_width(self):
24@@ -70,20 +70,20 @@
25 x = i * self.h_stride
26 y = j * self.v_stride
27
28- if (i,j) in self._frame_cache:
29- self.frame = self._frame_cache[(i,j)]
30+ if (i, j) in self._frame_cache:
31+ self.frame = self._frame_cache[(i, j)]
32 else:
33 self.frame = GdkPixbuf.Pixbuf.new_subpixbuf(self.pixbuf,
34 x, y,
35 self.h_stride,
36 self.v_stride)
37- self._frame_cache[(i,j)] = self.frame
38+ self._frame_cache[(i, j)] = self.frame
39
40- if i < self.col_count-1:
41+ if i < self.col_count - 1:
42 i += 1
43 else:
44 i = 0
45- if j < self.row_count-1:
46+ if j < self.row_count - 1:
47 j += 1
48 else:
49 j = 0
50@@ -102,13 +102,12 @@
51 x, y,
52 self.h_stride,
53 self.v_stride)
54- self._frame_cache[(i,j)] = self.frame
55+ self._frame_cache[(i, j)] = self.frame
56 return self.frame
57
58 def set_transaction_count(self, transaction_count):
59 self.transaction_count = transaction_count
60 self.queue_draw()
61- return
62
63 def on_draw(self, widget, cr, layout):
64 a = widget.get_allocation()
65@@ -117,7 +116,8 @@
66 y = (a.height - self.v_stride) * 0.5
67 Gdk.cairo_set_source_pixbuf(cr, self.frame, x, y)
68 cr.paint()
69- if self.transaction_count <= 0: return
70+ if self.transaction_count <= 0:
71+ return
72 # paint a bubble with the transaction count
73 layout.set_markup('<small>%i</small>' % self.transaction_count, -1)
74 # determine bubble size
75@@ -129,23 +129,22 @@
76 x += self.h_stride + self.BUBBLE_XPADDING
77 y += (self.v_stride - height) / 2
78 rounded_rect(cr, x, y, width, height, self.BUBBLE_BORDER_RADIUS)
79- cr.set_source_rgba(0,0,0,0.2)
80+ cr.set_source_rgba(0, 0, 0, 0.2)
81 cr.fill()
82 Gtk.render_layout(context, cr,
83 x + self.BUBBLE_XPADDING,
84 y + self.BUBBLE_YPADDING,
85 layout)
86- return
87
88 def is_playing(self):
89 return self.handler is not None
90
91 def start(self):
92- if self.is_playing(): return
93+ if self.is_playing():
94+ return
95 self.position = (0, 0)
96 self.handler = GObject.timeout_add(self.FRAME_DELAY,
97 self.on_new_frame)
98- return
99
100 def stop(self):
101 if self.handler:
102@@ -154,4 +153,3 @@
103
104 self.position = (0, 0)
105 self.queue_draw()
106- return
107
108=== modified file 'softwarecenter/ui/gtk3/widgets/cellrenderers.py'
109--- softwarecenter/ui/gtk3/widgets/cellrenderers.py 2012-03-07 06:02:07 +0000
110+++ softwarecenter/ui/gtk3/widgets/cellrenderers.py 2012-03-12 13:15:22 +0000
111@@ -39,24 +39,23 @@
112
113 # size of the install overlay icon
114 OVERLAY_SIZE = 16
115-
116+
117 # ratings
118 MAX_STARS = 5
119 STAR_SIZE = EM
120
121 __gproperties__ = {
122- 'application' : (GObject.TYPE_PYOBJECT, 'document',
123- 'a xapian document containing pkg information',
124- GObject.PARAM_READWRITE),
125-
126- 'isactive' : (bool, 'isactive', 'is cell active/selected', False,
127- GObject.PARAM_READWRITE),
128- }
129-
130+ 'application': (GObject.TYPE_PYOBJECT, 'document',
131+ 'a xapian document containing pkg information',
132+ GObject.PARAM_READWRITE),
133+
134+ 'isactive': (bool, 'isactive', 'is cell active/selected', False,
135+ GObject.PARAM_READWRITE),
136+ }
137
138 def __init__(self, icons, layout, show_ratings, overlay_icon_name):
139 GObject.GObject.__init__(self)
140-
141+
142 # the icon pixbuf to be displayed in the row
143 self.icon = None
144
145@@ -70,8 +69,10 @@
146
147 # button packing
148 self.button_spacing = 0
149- self._buttons = {Gtk.PackType.START: [],
150- Gtk.PackType.END: []}
151+ self._buttons = {
152+ Gtk.PackType.START: [],
153+ Gtk.PackType.END: []
154+ }
155 self._all_buttons = {}
156
157 # cache a layout
158@@ -88,7 +89,6 @@
159 # icon not present in theme, probably because running uninstalled
160 self._installed = icons.load_icon('emblem-system',
161 self.OVERLAY_SIZE, 0)
162- return
163
164 def _layout_get_pixel_width(self, layout):
165 return layout.get_size()[0] / Pango.SCALE
166@@ -109,12 +109,12 @@
167 x = cell_area.x
168 else:
169 x = cell_area.x + cell_area.width - lw
170- y = cell_area.y + (cell_area.height - lh)/2
171+ y = cell_area.y + (cell_area.height - lh) / 2
172
173 Gtk.render_layout(context, cr, x, y, layout)
174- return
175
176- def _render_price(self, context, cr, app, layout, cell_area, xpad, ypad, is_rtl):
177+ def _render_price(self, context, cr, app, layout, cell_area, xpad, ypad,
178+ is_rtl):
179 layout.set_markup("US$ %s" % self.model.get_price(app), -1)
180
181 if is_rtl:
182@@ -125,15 +125,14 @@
183
184 Gtk.render_layout(context, cr,
185 x, ypad + cell_area.y, layout)
186- return
187
188 def _render_icon(self, cr, app, cell_area, xpad, ypad, is_rtl):
189 # calc offsets so icon is nicely centered
190 self.icon = self.model.get_icon(app)
191 self.icon_x_offset = xpad + cell_area.x
192 self.icon_y_offset = ypad + cell_area.y
193- xo = (self.pixbuf_width - self.icon.get_width())/2
194-
195+ xo = (self.pixbuf_width - self.icon.get_width()) / 2
196+
197 if not is_rtl:
198 x = cell_area.x + xo + xpad
199 else:
200@@ -143,7 +142,7 @@
201 # draw appicon pixbuf
202 Gdk.cairo_set_source_pixbuf(cr, self.icon, x, y)
203 cr.paint()
204-
205+
206 # draw overlay if application is installed
207 if self.model.is_installed(app):
208 if not is_rtl:
209@@ -153,7 +152,6 @@
210 y += (self.pixbuf_width - self.OVERLAY_SIZE + self.OVERLAY_YO)
211 Gdk.cairo_set_source_pixbuf(cr, self._installed, x, y)
212 cr.paint()
213- return
214
215 def _render_summary(self, context, cr, app,
216 cell_area, layout, xpad, ypad,
217@@ -165,20 +163,21 @@
218 layout.set_width(-1)
219 lw = self._layout_get_pixel_width(layout)
220 max_layout_width = (cell_area.width - self.pixbuf_width -
221- 3*xpad - star_width)
222-
223- max_layout_width = cell_area.width - self.pixbuf_width - 3*xpad
224-
225+ 3 * xpad - star_width)
226+
227+ max_layout_width = cell_area.width - self.pixbuf_width - 3 * xpad
228+
229 stats = self.model.get_review_stats(app)
230 if self.show_ratings and stats:
231- max_layout_width -= star_width+6*xpad
232-
233- if self.props.isactive and self.model.get_transaction_progress(app) > 0:
234+ max_layout_width -= star_width + 6 * xpad
235+
236+ if (self.props.isactive and
237+ self.model.get_transaction_progress(app) > 0):
238 action_btn = self.get_button_by_name(CellButtonIDs.ACTION)
239- max_layout_width -= (xpad + action_btn.width)
240+ max_layout_width -= (xpad + action_btn.width)
241
242 if lw >= max_layout_width:
243- layout.set_width((max_layout_width)*Pango.SCALE)
244+ layout.set_width((max_layout_width) * Pango.SCALE)
245 layout.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
246 lw = max_layout_width
247
248@@ -187,21 +186,22 @@
249 self.apptitle_height = apptitle_extents.height
250
251 if not is_rtl:
252- x = cell_area.x+2*xpad+self.pixbuf_width
253+ x = cell_area.x + 2 * xpad + self.pixbuf_width
254 else:
255- x = cell_area.x+cell_area.width-lw-self.pixbuf_width-2*xpad
256+ x = (cell_area.x + cell_area.width - lw - self.pixbuf_width -
257+ 2 * xpad)
258
259- y = cell_area.y+ypad
260+ y = cell_area.y + ypad
261
262 Gtk.render_layout(context, cr, x, y, layout)
263- return
264
265 def _render_rating(self, context, cr, app,
266 cell_area, layout, xpad, ypad,
267 star_width, star_height, is_rtl):
268
269 stats = self.model.get_review_stats(app)
270- if not stats: return
271+ if not stats:
272+ return
273
274 sr = self._stars
275
276@@ -212,14 +212,14 @@
277 x = (cell_area.x + cell_area.width
278 - 3 * xpad
279 - self.pixbuf_width
280- - self.apptitle_width
281+ - self.apptitle_width
282 - star_width)
283
284- y = cell_area.y + ypad + (self.apptitle_height-self.STAR_SIZE)/2
285+ y = cell_area.y + ypad + (self.apptitle_height - self.STAR_SIZE) / 2
286
287 sr.rating = stats.ratings_average
288 sr.render_star(context, cr, x, y)
289-
290+
291 # and nr-reviews in parenthesis to the right of the title
292 nreviews = stats.ratings_total
293 s = "(%i)" % nreviews
294@@ -227,19 +227,19 @@
295 layout.set_markup("<small>%s</small>" % s, -1)
296
297 if not is_rtl:
298- x += xpad+star_width
299+ x += xpad + star_width
300 else:
301- x -= xpad+self._layout_get_pixel_width(layout)
302+ x -= xpad + self._layout_get_pixel_width(layout)
303
304 context.save()
305 context.add_class("cellrenderer-avgrating-label")
306 Gtk.render_layout(context, cr, x, y, layout)
307 context.restore()
308- return
309
310 def _render_progress(self, context, cr, progress, cell_area, ypad, is_rtl):
311 percent = progress * 0.01
312- # per the spec, the progressbar should be the width of the action button
313+ # per the spec, the progressbar should be the width of the action
314+ # button
315 action_btn = self.get_button_by_name(CellButtonIDs.ACTION)
316
317 x, _, w, h = action_btn.allocation
318@@ -252,26 +252,25 @@
319 Gtk.render_background(context, cr, x, y, w, h)
320 Gtk.render_frame(context, cr, x, y, w, h)
321
322- context.restore ()
323+ context.restore()
324
325 bar_size = w * percent
326
327- context.save ()
328- context.add_class ("progressbar")
329+ context.save()
330+ context.add_class("progressbar")
331
332 if (bar_size > 0):
333 if is_rtl:
334 x += (w - bar_size)
335 Gtk.render_activity(context, cr, x, y, bar_size, h)
336
337- context.restore ()
338- return
339+ context.restore()
340
341- def _render_buttons(
342- self, context, cr, cell_area, layout, xpad, ypad, is_rtl):
343+ def _render_buttons(self, context, cr, cell_area, layout, xpad, ypad,
344+ is_rtl):
345
346 # layout buttons and paint
347- y = cell_area.y+cell_area.height-ypad
348+ y = cell_area.y + cell_area.height - ypad
349 spacing = self.button_spacing
350
351 if not is_rtl:
352@@ -286,30 +285,26 @@
353 xb = cell_area.x + cell_area.width - 2 * xpad - self.pixbuf_width
354
355 for btn in self._buttons[start]:
356- btn.set_position(xs, y-btn.height)
357+ btn.set_position(xs, y - btn.height)
358 btn.render(context, cr, layout)
359 xs += btn.width + spacing
360
361 for btn in self._buttons[end]:
362 xb -= btn.width
363- btn.set_position(xb, y-btn.height)
364+ btn.set_position(xb, y - btn.height)
365 btn.render(context, cr, layout)
366
367 xb -= spacing
368- return
369
370 def set_pixbuf_width(self, w):
371 self.pixbuf_width = w
372- return
373
374 def set_button_spacing(self, spacing):
375 self.button_spacing = spacing
376- return
377
378 def get_button_by_name(self, name):
379 if name in self._all_buttons:
380 return self._all_buttons[name]
381- return None
382
383 def get_buttons(self):
384 btns = ()
385@@ -320,15 +315,12 @@
386 def button_pack(self, btn, pack_type=Gtk.PackType.START):
387 self._buttons[pack_type].append(btn)
388 self._all_buttons[btn.name] = btn
389- return
390
391 def button_pack_start(self, btn):
392 self.button_pack(btn, Gtk.PackType.START)
393- return
394
395 def button_pack_end(self, btn):
396 self.button_pack(btn, Gtk.PackType.END)
397- return
398
399 def do_set_property(self, pspec, value):
400 setattr(self, pspec.name, value)
401@@ -345,7 +337,8 @@
402
403 def do_render(self, cr, widget, bg_area, cell_area, flags):
404 app = self.props.application
405- if not app: return
406+ if not app:
407+ return
408
409 self.model = widget.appmodel
410
411@@ -356,9 +349,11 @@
412 is_rtl = widget.get_direction() == Gtk.TextDirection.RTL
413 layout = self._layout
414
415- # important! ensures correct text rendering, esp. when using hicolor theme
416+ # important! ensures correct text rendering, esp. when using hicolor
417+ # theme
418 #~ if (flags & Gtk.CellRendererState.SELECTED) != 0:
419- #~ # this follows the behaviour that gtk+ uses for states in treeviews
420+ #~ # this follows the behaviour that gtk+ uses for states in
421+ #~ # treeviews
422 #~ if widget.has_focus():
423 #~ state = Gtk.StateFlags.SELECTED
424 #~ else:
425@@ -388,7 +383,7 @@
426 xpad, ypad,
427 star_width,
428 is_rtl)
429-
430+
431 # only show ratings if we have one
432 if self.show_ratings:
433 self._render_rating(context, cr, app,
434@@ -421,7 +416,6 @@
435 is_rtl)
436
437 context.restore()
438- return
439
440
441 class CellButtonRenderer(object):
442@@ -441,28 +435,30 @@
443 self.visible = True
444
445 self.widget = widget
446- return
447
448 def _layout_reset(self, layout):
449 layout.set_width(-1)
450 layout.set_ellipsize(Pango.EllipsizeMode.NONE)
451- return
452-
453- @property
454- def x(self): return self.allocation[0]
455-
456- @property
457- def y(self): return self.allocation[1]
458-
459- @property
460- def width(self): return self.allocation[2]
461-
462- @property
463- def height(self): return self.allocation[3]
464+
465+ @property
466+ def x(self):
467+ return self.allocation[0]
468+
469+ @property
470+ def y(self):
471+ return self.allocation[1]
472+
473+ @property
474+ def width(self):
475+ return self.allocation[2]
476+
477+ @property
478+ def height(self):
479+ return self.allocation[3]
480
481 def configure_geometry(self, layout):
482 self._layout_reset(layout)
483- max_size = (0,0)
484+ max_size = (0, 0)
485
486 for k, variant in self.markup_variants.items():
487 safe_markup = GObject.markup_escape_text(utf8(variant))
488@@ -474,8 +470,7 @@
489 w /= Pango.SCALE
490 h /= Pango.SCALE
491
492- self.set_size(w+2*self.xpad, h+2*self.ypad)
493- return
494+ self.set_size(w + 2 * self.xpad, h + 2 * self.ypad)
495
496 def point_in(self, px, py):
497 x, y, w, h = self.allocation
498@@ -487,22 +482,21 @@
499
500 def set_position(self, x, y):
501 self.allocation[:2] = int(x), int(y)
502- return
503
504 def set_size(self, w, h):
505 self.allocation[2:] = int(w), int(h)
506- return
507
508 def set_state(self, state):
509 if not isinstance(state, Gtk.StateFlags):
510- msg = "state should be of type Gtk.StateFlags, got %s" % type(state)
511+ msg = ("state should be of type Gtk.StateFlags, got %s" %
512+ type(state))
513 raise TypeError(msg)
514
515- elif state == self.state: return
516+ elif state == self.state:
517+ return
518
519 self.state = state
520 self.widget.queue_draw_area(*self.allocation)
521- return
522
523 def set_sensitive(self, is_sensitive):
524 if is_sensitive:
525@@ -510,7 +504,6 @@
526 else:
527 state = Gtk.StateFlags.INSENSITIVE
528 self.set_state(state)
529- return
530
531 def show(self):
532 self.visible = True
533@@ -520,22 +513,20 @@
534
535 def set_markup(self, markup):
536 self.markup_variant = (markup,)
537- return
538
539 def set_markup_variants(self, markup_variants):
540 if not isinstance(markup_variants, dict):
541 msg = type(markup_variants)
542 raise TypeError("Expects a dict object, got %s" % msg)
543
544- elif not markup_variants: return
545+ elif not markup_variants:
546+ return
547
548 self.markup_variants = markup_variants
549 self.current_variant = markup_variants.keys()[0]
550- return
551
552 def set_variant(self, current_var):
553 self.current_variant = current_var
554- return
555
556 def is_sensitive(self):
557 return self.state == Gtk.StateFlags.INSENSITIVE
558@@ -576,4 +567,3 @@
559 context.restore()
560
561 context.restore()
562- return
563
564=== modified file 'softwarecenter/ui/gtk3/widgets/containers.py'
565--- softwarecenter/ui/gtk3/widgets/containers.py 2012-02-28 13:53:59 +0000
566+++ softwarecenter/ui/gtk3/widgets/containers.py 2012-03-12 13:15:22 +0000
567@@ -1,7 +1,7 @@
568 import cairo
569 import os
570 from math import pi as PI
571-PI_OVER_180 = PI/180
572+PI_OVER_180 = PI / 180
573 import softwarecenter.paths
574
575 from gi.repository import Gtk, Gdk
576@@ -25,7 +25,6 @@
577 self.n_rows = 0
578 self.paint_grid_pattern = paint_grid_pattern
579 self._cell_size = None
580- return
581
582 # private
583 def _get_n_columns_for_width(self, width, cell_w, col_spacing):
584@@ -33,7 +32,8 @@
585 return n_cols
586
587 def _layout_children(self, a):
588- if not self.get_visible(): return
589+ if not self.get_visible():
590+ return
591
592 children = self.get_children()
593 width = a.width
594@@ -45,7 +45,8 @@
595 cell_w, cell_h = self.get_cell_size()
596 n_cols = self._get_n_columns_for_width(width, cell_w, col_spacing)
597
598- if n_cols == 0: return
599+ if n_cols == 0:
600+ return
601 cell_w = width / n_cols
602 self.n_columns = n_cols
603
604@@ -54,11 +55,11 @@
605 #~ xo = h_overhang / (n_cols-1)
606 #~ else:
607 #~ xo = h_overhang
608-
609+
610 if len(children) % n_cols:
611- self.n_rows = len(children)/n_cols + 1
612+ self.n_rows = len(children) / n_cols + 1
613 else:
614- self.n_rows = len(children)/n_cols
615+ self.n_rows = len(children) / n_cols
616
617 y = 0
618 for i, child in enumerate(children):
619@@ -67,7 +68,7 @@
620 #~ x = a.x + (i % n_cols) * (cell_w + col_spacing + xo)
621 #~ if n_cols == 1:
622 #~ x += xo/2
623- if (i%n_cols) == 0:
624+ if (i % n_cols) == 0:
625 y = a.y + (i / n_cols) * (cell_h + row_spacing)
626
627 child_alloc = child.get_allocation()
628@@ -76,7 +77,6 @@
629 child_alloc.width = cell_w
630 child_alloc.height = cell_h
631 child.size_allocate(child_alloc)
632- return
633
634 # overrides
635 def do_get_request_mode(self):
636@@ -84,13 +84,15 @@
637
638 def do_get_preferred_height_for_width(self, width):
639 old = self.get_allocation()
640- if width == old.width: old.height, old.height
641+ if width == old.width:
642+ old.height, old.height
643
644 cell_w, cell_h = self.get_cell_size()
645 n_cols = self._get_n_columns_for_width(
646 width, cell_w, self.column_spacing)
647
648- if not n_cols: return self.MIN_HEIGHT, self.MIN_HEIGHT
649+ if not n_cols:
650+ return self.MIN_HEIGHT, self.MIN_HEIGHT
651
652 children = self.get_children()
653 n_rows = len(children) / n_cols
654@@ -99,7 +101,7 @@
655 if len(children) % n_cols:
656 n_rows += 1
657
658- pref_h = n_rows*cell_h + (n_rows-1)*self.row_spacing + 1
659+ pref_h = n_rows * cell_h + (n_rows - 1) * self.row_spacing + 1
660 pref_h = max(self.MIN_HEIGHT, pref_h)
661 return pref_h, pref_h
662
663@@ -107,16 +109,16 @@
664 def do_size_allocate(self, allocation):
665 self.set_allocation(allocation)
666 self._layout_children(allocation)
667- return
668
669 def do_draw(self, cr):
670- if not (self.n_columns and self.n_rows): return
671+ if not (self.n_columns and self.n_rows):
672+ return
673
674 if self.paint_grid_pattern:
675 self.render_grid(cr)
676
677- for child in self: self.propagate_draw(child, cr)
678- return
679+ for child in self:
680+ self.propagate_draw(child, cr)
681
682 # public
683 def render_grid(self, cr):
684@@ -135,24 +137,22 @@
685 w = a.width / self.n_columns
686
687 for i in range(self.n_columns):
688- cr.move_to(i*w+0.5, 0)
689- cr.rel_line_to(0, a.height-3)
690+ cr.move_to(i * w + 0.5, 0)
691+ cr.rel_line_to(0, a.height - 3)
692 cr.stroke()
693
694 w = a.height / self.n_rows
695
696 for i in range(self.n_rows):
697- cr.move_to(2, i*w+0.5)
698- cr.rel_line_to(a.width-4, 0)
699+ cr.move_to(2, i * w + 0.5)
700+ cr.rel_line_to(a.width - 4, 0)
701 cr.stroke()
702
703 cr.restore()
704- return
705
706 def add_child(self, child):
707 self._cell_size = None
708 self.put(child, 0, 0)
709- return
710
711 def get_cell_size(self):
712 if self._cell_size is not None:
713@@ -170,22 +170,22 @@
714
715 def set_row_spacing(self, value):
716 self.row_spacing = value
717- return
718
719 def set_column_spacing(self, value):
720 self.column_spacing = value
721 self._layout_children(self.get_allocation())
722- return
723
724 def remove_all(self):
725 self._cell_size = None
726 for child in self:
727 self.remove(child)
728- return
729+
730
731 # first tier of caching, cache component assets from which frames are
732 # rendered
733 _frame_asset_cache = {}
734+
735+
736 class Frame(Gtk.Alignment):
737
738 BORDER_RADIUS = 8
739@@ -200,7 +200,7 @@
740 # set padding + some additional padding in the bottom, left and
741 # right edges to factor in the dropshadow width, and ensure even
742 # visual border
743- self.set_padding(padding, padding+2, padding+1, padding+1)
744+ self.set_padding(padding, padding + 2, padding + 1, padding + 1)
745
746 # corner lable jazz
747 #~ self.show_corner_label = False
748@@ -218,11 +218,9 @@
749 self._allocation = Gdk.Rectangle()
750 self.connect("size-allocate", self.on_size_allocate)
751 self.connect("style-updated", self.on_style_updated)
752- return
753
754 def on_style_updated(self, widget):
755 self._frame_surface_cache = None
756- return
757
758 def on_size_allocate(self, *args):
759 old = self._allocation
760@@ -237,7 +235,8 @@
761 global _frame_asset_cache
762 at = self.ASSET_TAG
763 assets = _frame_asset_cache
764- if at in assets: return assets
765+ if at in assets:
766+ return assets
767
768 def cache_corner_surface(tag, xo, yo):
769 sw = sh = cnr_slice
770@@ -247,7 +246,6 @@
771 cr.paint()
772 assets[tag] = surf
773 del cr
774- return
775
776 def cache_edge_pattern(tag, xo, yo, sw, sh):
777 surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, sw, sh)
778@@ -258,7 +256,6 @@
779 ptrn.set_extend(cairo.EXTEND_REPEAT)
780 assets[tag] = ptrn
781 del cr
782- return
783
784 # register the asset tag within the asset_cache
785 assets[at] = 'loaded'
786@@ -275,24 +272,24 @@
787 # northern edge pattern
788 cache_edge_pattern("%s-n" % at,
789 -cnr_slice, 0,
790- w-2*cnr_slice, cnr_slice)
791+ w - 2 * cnr_slice, cnr_slice)
792 # north-east corner
793- cache_corner_surface("%s-ne" % at, -(w-cnr_slice), 0)
794+ cache_corner_surface("%s-ne" % at, -(w - cnr_slice), 0)
795 # eastern edge pattern
796 cache_edge_pattern("%s-e" % at,
797- -(w-cnr_slice), -cnr_slice,
798- cnr_slice, h-2*cnr_slice)
799+ -(w - cnr_slice), -cnr_slice,
800+ cnr_slice, h - 2 * cnr_slice)
801 # south-east corner
802- cache_corner_surface("%s-se" % at, -(w-cnr_slice), -(h-cnr_slice))
803+ cache_corner_surface("%s-se" % at, -(w - cnr_slice), -(h - cnr_slice))
804 # southern edge pattern
805 cache_edge_pattern("%s-s" % at,
806- -cnr_slice, -(h-cnr_slice),
807- w-2*cnr_slice, cnr_slice)
808+ -cnr_slice, -(h - cnr_slice),
809+ w - 2 * cnr_slice, cnr_slice)
810 # south-west corner
811- cache_corner_surface("%s-sw" % at, 0, -(h-cnr_slice))
812+ cache_corner_surface("%s-sw" % at, 0, -(h - cnr_slice))
813 # western edge pattern
814 cache_edge_pattern("%s-w" % at, 0, -cnr_slice,
815- cnr_slice, h-2*cnr_slice)
816+ cnr_slice, h - 2 * cnr_slice)
817 # all done!
818 return assets
819
820@@ -300,17 +297,17 @@
821 cr.save()
822 self.on_draw(cr)
823 cr.restore()
824- return
825
826 def on_draw(self, cr):
827 a = self.get_allocation()
828 self.render_frame(cr, a, self.BORDER_RADIUS, _frame_asset_cache)
829
830- for child in self: self.propagate_draw(child, cr)
831- return
832+ for child in self:
833+ self.propagate_draw(child, cr)
834
835 #~ def on_draw_after(self, widget, cr, assets, layout):
836- #~ if not self.show_corner_label: return
837+ #~ if not self.show_corner_label:
838+ #~ return
839 #~ cr.save()
840 #~ surf = assets["corner-label"]
841 #~ w = surf.get_width()
842@@ -320,7 +317,7 @@
843 #~ # corner-label.png image...
844
845 #~ # alter the to allow drawing outside of the widget bounds
846- #~ cr.rectangle(-10, -10, w+4, h+4)
847+ #~ cr.rectangle(-10, -10, w + 4, h + 4)
848 #~ cr.clip()
849 #~ cr.set_source_surface(surf, -7, -8)
850 #~ cr.paint()
851@@ -329,16 +326,16 @@
852 #~ # transalate to the visual center of the corner-label
853 #~ cr.translate(19, 18)
854 #~ # rotate counter-clockwise
855- #~ cr.rotate(-pi*0.25)
856+ #~ cr.rotate(-pi * 0.25)
857 #~ # paint normal markup
858 #~ Gtk.render_layout(widget.get_style_context(),
859- #~ cr, -ex.width/2, -ex.height/2, layout)
860+ #~ cr, -ex.width / 2, -ex.height / 2, layout)
861 #~ cr.restore()
862- #~ return
863
864 def set_show_corner_label(self, show_label):
865 if (not self.layout.get_text() and
866- self.show_corner_label == show_label): return
867+ self.show_corner_label == show_label):
868+ return
869 global _frame_asset_cache
870 assets = _frame_asset_cache
871
872@@ -349,14 +346,13 @@
873
874 self.show_corner_label = show_label
875 self.queue_draw()
876- return
877
878 #~ def set_corner_label(self, markup):
879- #~ markup = '<span font_desc="12" color="white"><b>%s</b></span>' % markup
880+ #~ markup = ('<span font_desc="12" color="white"><b>%s</b></span>' %
881+ #~ markup)
882 #~ self.set_show_corner_label(True)
883 #~ self.layout.set_markup(markup, -1)
884 #~ self.queue_draw()
885- #~ return
886
887 def render_frame(self, cr, a, border_radius, assets):
888 # we cache as much of the drawing as possible
889@@ -379,56 +375,56 @@
890 # paint north length
891 _cr.save()
892 _cr.set_source(assets["%s-n" % at])
893- _cr.rectangle(cnr_slice, 0, width-2*cnr_slice, cnr_slice)
894+ _cr.rectangle(cnr_slice, 0, width - 2 * cnr_slice, cnr_slice)
895 _cr.clip()
896 _cr.paint()
897 _cr.restore()
898
899 # paint north-east corner
900 _cr.set_source_surface(assets["%s-ne" % at],
901- width-cnr_slice, 0)
902+ width - cnr_slice, 0)
903 _cr.paint()
904
905 # paint east length
906 _cr.save()
907- _cr.translate(width-cnr_slice, cnr_slice)
908+ _cr.translate(width - cnr_slice, cnr_slice)
909 _cr.set_source(assets["%s-e" % at])
910- _cr.rectangle(0, 0, cnr_slice, height-2*cnr_slice)
911+ _cr.rectangle(0, 0, cnr_slice, height - 2 * cnr_slice)
912 _cr.clip()
913 _cr.paint()
914 _cr.restore()
915
916 # paint south-east corner
917 _cr.set_source_surface(assets["%s-se" % at],
918- width-cnr_slice,
919- height-cnr_slice)
920+ width - cnr_slice,
921+ height - cnr_slice)
922 _cr.paint()
923
924 # paint south length
925 _cr.save()
926- _cr.translate(cnr_slice, height-cnr_slice)
927+ _cr.translate(cnr_slice, height - cnr_slice)
928 _cr.set_source(assets["%s-s" % at])
929- _cr.rectangle(0, 0, width-2*cnr_slice, cnr_slice)
930+ _cr.rectangle(0, 0, width - 2 * cnr_slice, cnr_slice)
931 _cr.clip()
932 _cr.paint()
933 _cr.restore()
934
935 # paint south-west corner
936 _cr.set_source_surface(assets["%s-sw" % at],
937- 0, height-cnr_slice)
938+ 0, height - cnr_slice)
939 _cr.paint()
940
941 # paint west length
942 _cr.save()
943 _cr.translate(0, cnr_slice)
944 _cr.set_source(assets["%s-w" % at])
945- _cr.rectangle(0, 0, cnr_slice, height-2*cnr_slice)
946+ _cr.rectangle(0, 0, cnr_slice, height - 2 * cnr_slice)
947 _cr.clip()
948 _cr.paint()
949 _cr.restore()
950
951 # fill interior
952- rounded_rect(_cr, 3, 2, a.width-6, a.height-6, border_radius)
953+ rounded_rect(_cr, 3, 2, a.width - 6, a.height - 6, border_radius)
954 context = self.get_style_context()
955 bg = context.get_background_color(self.get_state_flags())
956
957@@ -447,14 +443,13 @@
958 # paint the cached surface and apply a rounded rect clip to
959 # child draw ops
960 A = self.get_allocation()
961- xo, yo = a.x-A.x, a.y-A.y
962+ xo, yo = a.x - A.x, a.y - A.y
963
964 cr.set_source_surface(self._frame_surface_cache, xo, yo)
965 cr.paint()
966
967 #~ rounded_rect(cr, xo+3, yo+2, a.width-6, a.height-6, border_radius)
968 #~ cr.clip()
969- return
970
971
972 class SmallBorderRadiusFrame(Frame):
973@@ -462,20 +457,20 @@
974 BORDER_RADIUS = 3
975 ASSET_TAG = "small"
976 BORDER_IMAGE = os.path.join(
977- softwarecenter.paths.datadir, "ui/gtk3/art/frame-border-image-2px-border-radius.png")
978+ softwarecenter.paths.datadir,
979+ "ui/gtk3/art/frame-border-image-2px-border-radius.png")
980
981 def __init__(self, padding=3):
982 Frame.__init__(self, padding)
983- return
984
985
986 class FramedBox(Frame):
987
988- def __init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=0, padding=0):
989+ def __init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=0,
990+ padding=0):
991 Frame.__init__(self, padding)
992 self.box = Gtk.Box.new(orientation, spacing)
993 Gtk.Alignment.add(self, self.box)
994- return
995
996 def add(self, *args, **kwargs):
997 return self.box.add(*args, **kwargs)
998@@ -496,7 +491,7 @@
999 class FramedHeaderBox(FramedBox):
1000
1001 MARKUP = '<b>%s</b>'
1002-
1003+
1004 # pages for the spinner notebook
1005 (CONTENT,
1006 SPINNER) = range(2)
1007@@ -517,7 +512,6 @@
1008 # finally, a notebook for the spinner and the content box to share
1009 self.spinner_notebook = SpinnerNotebook(self.content_box)
1010 self.box.add(self.spinner_notebook)
1011- return
1012
1013 def on_draw(self, cr):
1014 a = self.get_allocation()
1015@@ -525,8 +519,8 @@
1016 a = self.header_alignment.get_allocation()
1017 self.render_header(cr, a, Frame.BORDER_RADIUS, _frame_asset_cache)
1018
1019- for child in self: self.propagate_draw(child, cr)
1020- return
1021+ for child in self:
1022+ self.propagate_draw(child, cr)
1023
1024 def add(self, *args, **kwargs):
1025 return self.content_box.add(*args, **kwargs)
1026@@ -536,7 +530,7 @@
1027
1028 def pack_end(self, *args, **kwargs):
1029 return self.content_box.pack_end(*args, **kwargs)
1030-
1031+
1032 # XXX: non-functional with current code...
1033 #~ def set_header_expand(self, expand):
1034 #~ alignment = self.header_alignment
1035@@ -564,13 +558,11 @@
1036 self.title.show()
1037
1038 self.title.set_markup(self.MARKUP % label)
1039- return
1040
1041 def header_implements_more_button(self):
1042 if not hasattr(self, "more"):
1043 self.more = MoreLink()
1044 self.header.pack_end(self.more, False, False, 0)
1045- return
1046
1047 def render_header(self, cr, a, border_radius, assets):
1048
1049@@ -596,35 +588,35 @@
1050 w = ta.width + StockEms.MEDIUM
1051
1052 cr.new_sub_path()
1053- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
1054- cr.line_to(x+w, y)
1055- cr.line_to(x+w - StockEms.MEDIUM, y + h/2)
1056- cr.line_to(x+w, y+h)
1057- cr.line_to(x, y+h)
1058+ cr.arc(r + x, r + y, r, PI, 270 * PI_OVER_180)
1059+ cr.line_to(x + w, y)
1060+ cr.line_to(x + w - StockEms.MEDIUM, y + h / 2)
1061+ cr.line_to(x + w, y + h)
1062+ cr.line_to(x, y + h)
1063 cr.close_path()
1064
1065 cr.fill()
1066
1067- cr.move_to(x+w, y)
1068- cr.line_to(x+w - StockEms.MEDIUM, y + h/2)
1069- cr.line_to(x+w, y+h)
1070+ cr.move_to(x + w, y)
1071+ cr.line_to(x + w - StockEms.MEDIUM, y + h / 2)
1072+ cr.line_to(x + w, y + h)
1073
1074 else:
1075 x = ta.x - a.x - StockEms.MEDIUM
1076 w = ta.width + StockEms.MEDIUM - 1
1077
1078 cr.move_to(x, y)
1079- cr.arc(x+w-r, y+r, r, 270*PI_OVER_180, 0)
1080- cr.line_to(x+w, y+h)
1081- cr.line_to(x, y+h)
1082- cr.line_to(x + StockEms.MEDIUM, y + h/2)
1083+ cr.arc(x + w - r, y + r, r, 270 * PI_OVER_180, 0)
1084+ cr.line_to(x + w, y + h)
1085+ cr.line_to(x, y + h)
1086+ cr.line_to(x + StockEms.MEDIUM, y + h / 2)
1087 cr.close_path()
1088
1089 cr.fill()
1090
1091 cr.move_to(x, y)
1092- cr.line_to(x + StockEms.MEDIUM, y + h/2)
1093- cr.line_to(x, y+h)
1094+ cr.line_to(x + StockEms.MEDIUM, y + h / 2)
1095+ cr.line_to(x, y + h)
1096
1097 bc = context.get_border_color(self.get_state_flags())
1098 Gdk.cairo_set_source_rgba(cr, bc)
1099@@ -634,8 +626,8 @@
1100 cr.restore()
1101
1102 # paint the containers children
1103- for child in self: self.propagate_draw(child, cr)
1104- return
1105+ for child in self:
1106+ self.propagate_draw(child, cr)
1107
1108
1109 # this is used in the automatic tests
1110
1111=== modified file 'test/test_pep8.py'
1112--- test/test_pep8.py 2012-03-10 02:05:59 +0000
1113+++ test/test_pep8.py 2012-03-12 13:15:22 +0000
1114@@ -16,8 +16,7 @@
1115 packages = [softwarecenter.ui.qml,
1116 softwarecenter.ui.gtk3.widgets,
1117 softwarecenter.db.pkginfo_impl]
1118- exclude = ['containers.py', 'cellrenderers.py', 'buttons.py',
1119- 'apptreeview.py', 'animatedimage.py', 'actionbar.py']
1120+ exclude = ['buttons.py', 'apptreeview.py', 'actionbar.py']
1121
1122 def message(self, text):
1123 self.errors.append(text)