[Sugar-devel] [PATCH 05/21 sugar-toolkit] PEP8 cleanup: fix whitespace around operator

Simon Schampijer simon at schampijer.de
Fri Oct 29 06:46:54 EDT 2010


On 10/15/2010 11:01 PM, Sascha Silbe wrote:
> I've left the powers as-is because IMO they should directly follow the base,
> unlike other operators.

Hmmm, I see your argument, however I think it is not worth to make an 
exception here.

> Signed-off-by: Sascha Silbe<sascha-pgp at silbe.org>
>
> 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())

Why do you prefer operator.add here instead of doing the white spaces 
around the '+'? To me at least it does not get easier to read.

>           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/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):
> --
> 1.7.1
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>



More information about the Sugar-devel mailing list