[Checkins] SVN: cipher.configstore/trunk/src/cipher/configstore/ pep8

Adam Groszer cvs-admin at zope.org
Thu Aug 30 14:20:48 UTC 2012


Log message for revision 127628:
  pep8

Changed:
  U   cipher.configstore/trunk/src/cipher/configstore/configstore.py
  U   cipher.configstore/trunk/src/cipher/configstore/interfaces.py

-=-
Modified: cipher.configstore/trunk/src/cipher/configstore/configstore.py
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/configstore.py	2012-08-30 14:18:12 UTC (rev 127627)
+++ cipher.configstore/trunk/src/cipher/configstore/configstore.py	2012-08-30 14:20:44 UTC (rev 127628)
@@ -34,11 +34,13 @@
 
 novalue = object()
 
+
 def stringify(s):
     if s is None:
         return ''
     return unicode(s)
 
+
 def parse_time(s):
     return dateutil.parser.parse(s).time()
 
@@ -67,8 +69,8 @@
     def load_type_Timedelta(self, unicode, field):
         if not unicode:
             return
-        h, m , s = [int(p) for p in unicode.strip().split(':')]
-        return datetime.timedelta(seconds=h*3600+m*60+s)
+        h, m, s = [int(p) for p in unicode.strip().split(':')]
+        return datetime.timedelta(seconds=h * 3600 + m * 60 + s)
 
     def load_type_Text(self, value, field):
         return value.replace('\n<BLANKLINE>\n', '\n\n')
@@ -97,10 +99,10 @@
             # skip read-only fields, especially __name__
             return False
         field_type = field.__class__
-        if hasattr(self, 'load_'+name):
-            converter = getattr(self, 'load_'+name, None)
-        elif hasattr(self, 'load_type_'+field_type.__name__):
-            converter = getattr(self, 'load_type_'+field_type.__name__, None)
+        if hasattr(self, 'load_' + name):
+            converter = getattr(self, 'load_' + name, None)
+        elif hasattr(self, 'load_type_' + field_type.__name__):
+            converter = getattr(self, 'load_type_' + field_type.__name__, None)
             converter = lambda v, converter=converter: converter(v, field)
         elif zope.schema.interfaces.IFromUnicode.providedBy(field):
             converter = field.bind(context).fromUnicode
@@ -179,10 +181,10 @@
             # skip read-only fields, we won't be loading them
             return
         field_type = field.__class__
-        if hasattr(self, 'dump_'+name):
-            converter = getattr(self, 'dump_'+name)
-        elif hasattr(self, 'dump_type_'+field_type.__name__):
-            converter = getattr(self, 'dump_type_'+field_type.__name__)
+        if hasattr(self, 'dump_' + name):
+            converter = getattr(self, 'dump_' + name)
+        elif hasattr(self, 'dump_type_' + field_type.__name__):
+            converter = getattr(self, 'dump_type_' + field_type.__name__)
             converter = lambda v, converter=converter: converter(v, field)
         elif zope.schema.interfaces.IFromUnicode.providedBy(field):
             converter = stringify
@@ -205,7 +207,7 @@
     def dump(self, config=None):
         if config is None:
             config = ConfigParser.RawConfigParser(dict_type=odict.odict)
-            config.optionxform = str # don't lowercase
+            config.optionxform = str  # don't lowercase
         # Write object's configuration.
         self._dump(config)
         # Write any sub-object configuration.
@@ -216,6 +218,7 @@
             store.dump(config)
         return config
 
+
 class CollectionConfigurationStore(ConfigurationStore):
     section_prefix = None
     item_factory = None
@@ -263,7 +266,7 @@
             # Note sends a ContainerModifiedEvent which would causes a config
             # dump, overwriting the original file with partial information.
             # That's why we have this _v_load_in_progress "lock".
-            self._add(name,  item)
+            self._add(name, item)
             self._applyPostAddConfig(item, config, section)
         zope.event.notify(
             interfaces.ObjectConfigurationLoadedEvent(self.context))
@@ -271,7 +274,7 @@
     def dump(self, config=None):
         if config is None:
             config = ConfigParser.RawConfigParser(dict_type=odict.odict)
-            config.optionxform = str # don't lowercase
+            config.optionxform = str  # don't lowercase
         for name, item in self._getItems():
             if getattr(item, '__parent__', self) is None:
                 # Sad story: you remove an item from a BTreeContainer
@@ -288,9 +291,10 @@
             item_store.dump(config)
         return config
 
+
 def createConfigurationStore(schema, section=None):
     return type(
-        schema.getName()[1:]+'Store', (ConfigurationStore,),
+        schema.getName()[1:] + 'Store', (ConfigurationStore,),
         {'section': section, 'schema': schema})
 
 
@@ -303,7 +307,7 @@
         return None
 
     def get_filename(self):
-        return self.context.__name__+'.ini'
+        return self.context.__name__ + '.ini'
 
     def _load_from_external(self, config):
         # Load general attributes.
@@ -328,7 +332,7 @@
             self.get_config_dir(), config.get(self.section, 'config-path'))
         __traceback_info__ = fn
         ext_config = ConfigParser.RawConfigParser(dict_type=odict.odict)
-        ext_config.optionxform = str # don't lowercase
+        ext_config.optionxform = str  # don't lowercase
         ext_config.read(fn)
         self._load_from_external(ext_config)
 
@@ -339,7 +343,7 @@
             self.get_config_dir(), cs.__name__, self.get_filename())
         # Create a new configuration for the table-specific API.
         config = ConfigParser.RawConfigParser(dict_type=odict.odict)
-        config.optionxform = str # don't lowercase
+        config.optionxform = str  # don't lowercase
         # Write object's configuration.
         orig_section = self.section
         self.section = 'general'
@@ -360,7 +364,7 @@
     def dump(self, config=None):
         if config is None:
             config = ConfigParser.RawConfigParser(dict_type=odict.odict)
-            config.optionxform = str # don't lowercase
+            config.optionxform = str  # don't lowercase
         # Write any sub-object configuration into a separate configuration file.
         fn = self._dump_to_external()
         # Just a small stub in the main config.

Modified: cipher.configstore/trunk/src/cipher/configstore/interfaces.py
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/interfaces.py	2012-08-30 14:18:12 UTC (rev 127627)
+++ cipher.configstore/trunk/src/cipher/configstore/interfaces.py	2012-08-30 14:20:44 UTC (rev 127628)
@@ -32,8 +32,8 @@
     schema = zope.interface.Attribute('The schema to be serialized.')
 
     section = zope.schema.ASCIILine(
-        title = u'Section Name',
-        description = u'The name of the section in the configuration.',
+        title=u'Section Name',
+        description=u'The name of the section in the configuration.',
         required=True)
 
     def load(config):
@@ -45,6 +45,7 @@
         If the `config` paramter is `None`, a configuration object is created.
         """
 
+
 class ICipherObject(zope.interface.Interface):
     "mark all Cipher objects"
 



More information about the checkins mailing list