pep 8 lines too long
[tiramisu.git] / tiramisu / config.py
index 510d489..df3d7b8 100644 (file)
@@ -151,7 +151,8 @@ class SubConfig(BaseInformation):
 
     def cfgimpl_get_description(self):
         if self._impl_descr is None:
-            raise ConfigError(_('no optiondescription for this config (may be metaconfig without meta)'))
+            raise ConfigError(_('no option description found for this config'
+                                ' (may be metaconfig without meta)'))
         else:
             return self._impl_descr
 
@@ -181,7 +182,9 @@ class SubConfig(BaseInformation):
                                               force_permissive=force_permissive)
         else:
             context = self.cfgimpl_get_context()
-            path = context.cfgimpl_get_description().impl_get_path_by_opt(child._opt)
+            path = context.\
+                   cfgimpl_get_description().\
+                   impl_get_path_by_opt(child._opt)
             context._setattr(path, value, force_permissive=force_permissive)
 
     def __delattr__(self, name):
@@ -203,8 +206,8 @@ class SubConfig(BaseInformation):
         # for instance getattr(self, "creole.general.family.adresse_ip_eth0")
         if '.' in name:
             homeconfig, name = self.cfgimpl_get_home_by_path(name,
-                                                             force_permissive=force_permissive,
-                                                             force_properties=force_properties)
+                               force_permissive=force_permissive,
+                               force_properties=force_properties)
             return homeconfig._getattr(name, force_permissive=force_permissive,
                                        force_properties=force_properties,
                                        validate=validate)
@@ -217,21 +220,22 @@ class SubConfig(BaseInformation):
         # symlink options
         if isinstance(opt_or_descr, SymLinkOption):
             context = self.cfgimpl_get_context()
-            path = context.cfgimpl_get_description().impl_get_path_by_opt(opt_or_descr._opt)
+            path = context.cfgimpl_get_description(
+                   ).impl_get_path_by_opt(opt_or_descr._opt)
             return context._getattr(path, validate=validate,
                                     force_properties=force_properties,
                                     force_permissive=force_permissive)
         elif isinstance(opt_or_descr, OptionDescription):
             self.cfgimpl_get_settings().validate_properties(opt_or_descr,
-                                                            True, False,
-                                                            force_permissive=force_permissive,
-                                                            force_properties=force_properties)
+                 True, False,
+                 force_permissive=force_permissive,
+                 force_properties=force_properties)
             return SubConfig(opt_or_descr, self.cfgimpl_get_context())
         else:
             return self.cfgimpl_get_values().getitem(opt_or_descr,
-                                                     validate=validate,
-                                                     force_properties=force_properties,
-                                                     force_permissive=force_permissive)
+                        validate=validate,
+                        force_properties=force_properties,
+                        force_permissive=force_permissive)
 
     def find(self, bytype=None, byname=None, byvalue=None, type_='option'):
         """
@@ -245,7 +249,8 @@ class SubConfig(BaseInformation):
         return self.cfgimpl_get_context()._find(bytype, byname, byvalue,
                                                 first=False,
                                                 type_=type_,
-                                                _subpath=self.cfgimpl_get_path())
+                                                _subpath=self.cfgimpl_get_path()
+                                                )
 
     def find_first(self, bytype=None, byname=None, byvalue=None,
                    type_='option', display_error=True):
@@ -258,10 +263,10 @@ class SubConfig(BaseInformation):
             :returns: list of matching Option objects
         """
         return self.cfgimpl_get_context()._find(bytype, byname, byvalue,
-                                                first=True,
-                                                type_=type_,
-                                                _subpath=self.cfgimpl_get_path(),
-                                                display_error=display_error)
+                                          first=True,
+                                          type_=type_,
+                                          _subpath=self.cfgimpl_get_path(),
+                                          display_error=display_error)
 
     def _find(self, bytype, byname, byvalue, first, type_='option',
               _subpath=None, check_properties=True, display_error=True):
@@ -273,7 +278,8 @@ class SubConfig(BaseInformation):
         """
         def _filter_by_name():
             try:
-                if byname is None or path == byname or path.endswith('.' + byname):
+                if byname is None or path == byname or \
+                                     path.endswith('.' + byname):
                     return True
             except IndexError:
                 pass
@@ -286,7 +292,8 @@ class SubConfig(BaseInformation):
                 value = getattr(self, path)
                 if value == byvalue:
                     return True
-            except PropertiesOptionError:  # a property restricts the access of the value
+            except PropertiesOptionError:  # a property is a restriction
+                                           # upon the access of the value
                 pass
             return False
 
@@ -309,7 +316,8 @@ class SubConfig(BaseInformation):
         #                return False
         #    return False
         if type_ not in ('option', 'path', 'context', 'value'):
-            raise ValueError(_('unknown type_ type {0} for _find').format(type_))
+            raise ValueError(_('unknown type_ type {0}'
+                               'for _find').format(type_))
         find_results = []
         opts, paths = self.cfgimpl_get_description()._cache_paths
         for index in range(0, len(paths)):
@@ -348,7 +356,8 @@ class SubConfig(BaseInformation):
                 find_results.append(retval)
         if find_results == []:
             if display_error:
-                raise AttributeError(_("no option found in config with these criteria"))
+                raise AttributeError(_("no option found in config"
+                                       " with these criteria"))
             else:
                 #translation is slow
                 raise AttributeError()
@@ -374,15 +383,21 @@ class SubConfig(BaseInformation):
                            `OptionDescription` than the `withoption` itself::
 
                                 >>> print cfg.make_dict(withoption='var1')
-                                {'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
-                                'od2.var1': u'value', 'od1.var1': None,
-                                'od1.var3': None, 'od1.var2': None}
+                                {'od2.var4': None, 'od2.var5': None,
+                                'od2.var6': None,
+                                'od2.var1': u'value',
+                                'od1.var1': None,
+                                'od1.var3': None,
+                                'od1.var2': None}
 
         :param withvalue: returns the options that have the value `withvalue`
                           ::
 
-                            >>> print c.make_dict(withoption='var1', withvalue=u'value')
-                            {'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
+                            >>> print c.make_dict(withoption='var1',
+                                                  withvalue=u'value')
+                            {'od2.var4': None,
+                            'od2.var5': None,
+                            'od2.var6': None,
                             'od2.var1': u'value'}
 
         :returns: dict of Option's name (or path) and values
@@ -402,7 +417,9 @@ class SubConfig(BaseInformation):
                                                          type_='path',
                                                          _subpath=mypath):
                 path = '.'.join(path.split('.')[:-1])
-                opt = self.cfgimpl_get_context().cfgimpl_get_description().impl_get_opt_by_path(path)
+                opt = self.cfgimpl_get_context(
+                           ).cfgimpl_get_description(
+                           ).impl_get_opt_by_path(path)
                 if mypath is not None:
                     if mypath == path:
                         withoption = None
@@ -430,7 +447,8 @@ class SubConfig(BaseInformation):
         if isinstance(opt, OptionDescription):
             try:
                 pathsvalues += getattr(self, path).make_dict(flatten,
-                                                             _currpath + path.split('.'))
+                                                             _currpath +
+                                                             path.split('.'))
             except PropertiesOptionError:
                 pass  # this just a hidden or disabled option
         else:
@@ -480,8 +498,9 @@ class CommonConfig(SubConfig):
         :returns: Option()
         """
         if '.' in path:
-            homeconfig, path = self.cfgimpl_get_home_by_path(path,
-                                                             force_permissive=force_permissive)
+            homeconfig, path = self.cfgimpl_get_home_by_path(
+                                    path,
+                                    force_permissive=force_permissive)
             return getattr(homeconfig.cfgimpl_get_description(), path)
         return getattr(self.cfgimpl_get_description(), path)
 
@@ -512,7 +531,9 @@ class Config(CommonConfig):
         self._impl_meta = None
         self._impl_informations = {}
 
-    def cfgimpl_reset_cache(self, only_expired=False, only=('values', 'settings')):
+    def cfgimpl_reset_cache(self,
+                            only_expired=False,
+                            only=('values', 'settings')):
         if 'values' in only:
             self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
         if 'settings' in only:
@@ -529,13 +550,14 @@ class MetaConfig(CommonConfig):
         if meta:
             for child in children:
                 if not isinstance(child, CommonConfig):
-                    raise ValueError(_("metaconfig's children must be config, not {0}"
-                                       "").format(type(child)))
+                    raise ValueError(_("metaconfig's children "
+                                       "must be config, not {0}"
+                                       ).format(type(child)))
                 if self._impl_descr is None:
                     self._impl_descr = child.cfgimpl_get_description()
                 elif not self._impl_descr is child.cfgimpl_get_description():
-                    raise ValueError(_('all config in metaconfig must have same '
-                                       'optiondescription'))
+                    raise ValueError(_('all config in metaconfig must '
+                                       'have the same optiondescription'))
                 if child.cfgimpl_get_meta() is not None:
                     raise ValueError(_("child has already a metaconfig's"))
                 child._impl_meta = self
@@ -553,7 +575,9 @@ class MetaConfig(CommonConfig):
         "a meta config is a config wich has a setting, that is itself"
         return self
 
-    def cfgimpl_reset_cache(self, only_expired=False, only=('values', 'settings')):
+    def cfgimpl_reset_cache(self,
+                            only_expired=False,
+                            only=('values', 'settings')):
         if 'values' in only:
             self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
         if 'settings' in only:
@@ -618,7 +642,8 @@ def mandatory_warnings(config):
     """
     #if value in cache, properties are not calculated
     config.cfgimpl_reset_cache(only=('values',))
-    for path in config.cfgimpl_get_description().impl_getpaths(include_groups=True):
+    for path in config.cfgimpl_get_description(
+                ).impl_getpaths(include_groups=True):
         try:
             config._getattr(path, force_properties=frozenset(('mandatory',)))
         except PropertiesOptionError, err: