[Sugar-devel] [PATCH sugar v2 06/21] PEP8 cleanup: ensure lines are shorter than 80 characters

Simon Schampijer simon at schampijer.de
Wed Nov 24 15:02:46 EST 2010


On 11/24/2010 08:30 PM, Sascha Silbe wrote:
> Excerpts from Simon Schampijer's message of Wed Nov 24 19:24:40 +0100 2010:
>
> [src/jarabe/journal/model.py]
>>> -PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 'creation_time', 'filesize',
>>> -              'keep', 'buddies', 'icon-color', 'mime_type', 'progress',
>>> -              'activity', 'mountpoint', 'activity_id', 'bundle_id']
>>> +PROPERTIES = [
>>> +    'activity', 'activity_id', 'buddies', 'bundle_id', 'creation_time',
>>> +    'filesize', 'icon-color', 'keep', 'mime_type', 'mountpoint', 'mtime',
>>> +    'progress', 'timestamp', 'title', 'uid',
>>> +]
>>
>> That one looked better before.
>
> I disagree. And as PEP-8 says nothing about how to format large list and
> dictionary literals, I went for the style I found in
> /usr/lib/python2.6/pydoc.py:
>
> class Helper:
> [...]
>      _symbols_inverse = {
>          'STRINGS' : ("'", "'''", "r'", "u'", '"""', '"', 'r"', 'u"'),
>          'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<','>>','&',
>                         '|', '^', '~', '<','>','<=', '>=', '==', '!=', '<>'),
>          'COMPARISON' : ('<','>','<=', '>=', '==', '!=', '<>'),
>          'UNARY' : ('-', '~'),
>          'AUGMENTEDASSIGNMENT' : ('+=', '-=', '*=', '/=', '%=', '&=', '|=',
>                                  '^=', '<<=', '>>=', '**=', '//='),
>          'BITWISE' : ('<<','>>','&', '|', '^', '~'),
>          'COMPLEX' : ('j', 'J')
>      }
>
> But this change is not worth another jiffie, so I now reformatted it to
> match the previous style:

jiffie? :) Is good now.

>
> @@ -38,9 +38,9 @@ DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore'
>   DS_DBUS_PATH = '/org/laptop/sugar/DataStore'
>
>   # Properties the journal cares about.
> -PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 'creation_time', 'filesize',
> -              'keep', 'buddies', 'icon-color', 'mime_type', 'progress',
> -              'activity', 'mountpoint', 'activity_id', 'bundle_id']
> +PROPERTIES = ['activity', 'activity_id', 'buddies', 'bundle_id',
> +              'creation_time', 'filesize', 'icon-color', 'keep', 'mime_type',
> +              'mountpoint', 'mtime', 'progress', 'timestamp', 'title', 'uid']
>
>   MIN_PAGES_TO_CACHE = 3
>   MAX_PAGES_TO_CACHE = 5
>
>
>
> [src/jarabe/model/bundleregistry.py]
>>> @@ -331,7 +330,8 @@ class BundleRegistry(gobject.GObject):
>>>        def set_bundle_position(self, bundle_id, version, x, y):
>>>            key = self._get_favorite_key(bundle_id, version)
>>>            if key not in self._favorite_bundles:
>>> -            raise ValueError('Bundle %s %s not favorite' % (bundle_id, version))
>>> +            raise ValueError('Bundle %s %s not favorite' % (bundle_id,
>>> +                                                            version))
>>
>> version)) should be aligned with 'Bundle.
>
> Why? It's still inside the % (...) scope.
> PEP-8 breaks at the %, though, so that's what I do now:
>
> @@ -334,7 +333,8 @@ class BundleRegistry(gobject.GObject):
>       def set_bundle_position(self, bundle_id, version, x, y):
>           key = self._get_favorite_key(bundle_id, version)
>           if key not in self._favorite_bundles:
> -            raise ValueError('Bundle %s %s not favorite' % (bundle_id, version))
> +            raise ValueError('Bundle %s %s not favorite' %
> +                             (bundle_id, version))
>
>           if self._favorite_bundles[key] is None:
>               self._favorite_bundles[key] = {}
>

Yeah, that looks good.

Regards,
    Simon


More information about the Sugar-devel mailing list