[Sugar-devel] [PATCH 05/21 v2 sugar-toolkit] PEP8 cleanup: fix whitespace around operator
Sascha Silbe
sascha-pgp at silbe.org
Fri Nov 19 11:20:29 EST 2010
Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
---
v1->v2: add whitespace around powers (a**b), too
src/sugar/activity/bundlebuilder.py | 3 ++-
src/sugar/bundle/activitybundle.py | 2 +-
src/sugar/graphics/alert.py | 2 +-
src/sugar/graphics/palettewindow.py | 4 ++--
src/sugar/network.py | 6 +++---
src/sugar/util.py | 8 ++++----
6 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py
index fc8ebc8..2952d71 100644
--- a/src/sugar/activity/bundlebuilder.py
+++ b/src/sugar/activity/bundlebuilder.py
@@ -19,6 +19,7 @@
STABLE.
"""
+import operator
import os
import sys
import zipfile
@@ -84,7 +85,7 @@ class Config(object):
self.version = bundle.get_activity_version()
self.activity_name = bundle.get_bundle_name()
self.bundle_id = bundle.get_bundle_id()
- self.bundle_name = reduce(lambda x, y: x+y, self.activity_name.split())
+ self.bundle_name = reduce(operator.add, self.activity_name.split())
self.bundle_root_dir = self.bundle_name + '.activity'
self.tar_root_dir = '%s-%d' % (self.bundle_name, self.version)
diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
index 3bbc250..2bb0729 100644
--- a/src/sugar/bundle/activitybundle.py
+++ b/src/sugar/bundle/activitybundle.py
@@ -334,7 +334,7 @@ class ActivityBundle(Bundle):
# Is anything in MANIFEST left over after accounting for all files?
if manifestfiles:
- err = ("Bundle %s: files in MANIFEST not included: %s"%
+ err = ("Bundle %s: files in MANIFEST not included: %s" %
(self._name, str(manifestfiles)))
if strict_manifest:
raise MalformedBundleException(err)
diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py
index 0202a66..f032871 100644
--- a/src/sugar/graphics/alert.py
+++ b/src/sugar/graphics/alert.py
@@ -357,7 +357,7 @@ class _TimeoutIcon(hippo.CanvasText, hippo.CanvasItem):
radius = min(width * 0.5, height * 0.5)
hippo.cairo_set_source_rgba32(cr, self.props.background_color)
- cr.arc(xval, yval, radius, 0, 2*math.pi)
+ cr.arc(xval, yval, radius, 0, 2 * math.pi)
cr.fill_preserve()
diff --git a/src/sugar/graphics/palettewindow.py b/src/sugar/graphics/palettewindow.py
index e76e952..0250f4a 100644
--- a/src/sugar/graphics/palettewindow.py
+++ b/src/sugar/graphics/palettewindow.py
@@ -110,8 +110,8 @@ class MouseSpeedDetector(gobject.GObject):
(x, y) = self._get_mouse_position()
self._mouse_pos = (x, y)
- dist2 = (oldx - x)**2 + (oldy - y)**2
- if dist2 > self._threshold**2:
+ dist2 = (oldx - x) ** 2 + (oldy - y) ** 2
+ if dist2 > self._threshold ** 2:
return True
else:
return False
diff --git a/src/sugar/network.py b/src/sugar/network.py
index b72acad..069a980 100644
--- a/src/sugar/network.py
+++ b/src/sugar/network.py
@@ -250,11 +250,11 @@ class GlibURLDownloader(gobject.GObject):
fidx = data.find(ftag)
if fidx < 0:
return None
- fname = data[fidx+len(ftag):]
+ fname = data[fidx + len(ftag):]
if fname[0] == '"' or fname[0] == "'":
fname = fname[1:]
- if fname[len(fname)-1] == '"' or fname[len(fname)-1] == "'":
- fname = fname[:len(fname)-1]
+ if fname[len(fname) - 1] == '"' or fname[len(fname) - 1] == "'":
+ fname = fname[:len(fname) - 1]
return fname
def _read_next_chunk(self, source, condition):
diff --git a/src/sugar/util.py b/src/sugar/util.py
index 3625f21..e1bcf88 100644
--- a/src/sugar/util.py
+++ b/src/sugar/util.py
@@ -346,9 +346,9 @@ def format_size(size):
return _('Empty')
elif size < 1024:
return _('%d B') % size
- elif size < 1024**2:
+ elif size < 1024 ** 2:
return _('%d KB') % (size / 1024)
- elif size < 1024**3:
- return _('%d MB') % (size / 1024**2)
+ elif size < 1024 ** 3:
+ return _('%d MB') % (size / 1024 ** 2)
else:
- return _('%d GB') % (size / 1024**3)
+ return _('%d GB') % (size / 1024 ** 3)
--
1.7.2.3
More information about the Sugar-devel
mailing list