Reformat offlineimap/CustomConfig.py
Add some spaces, remove lines,... now format is better (lintian).
This commit is contained in:
parent
9f15c05520
commit
8b35dbabe1
@ -36,7 +36,6 @@ class CustomConfigParser(SafeConfigParser):
|
|||||||
else:
|
else:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def getdefaultint(self, section, option, default, *args, **kwargs):
|
def getdefaultint(self, section, option, default, *args, **kwargs):
|
||||||
"""Same as config.getint, but returns the value of `default`
|
"""Same as config.getint, but returns the value of `default`
|
||||||
if there is no such option specified."""
|
if there is no such option specified."""
|
||||||
@ -46,7 +45,6 @@ class CustomConfigParser(SafeConfigParser):
|
|||||||
else:
|
else:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def getdefaultfloat(self, section, option, default, *args, **kwargs):
|
def getdefaultfloat(self, section, option, default, *args, **kwargs):
|
||||||
"""Same as config.getfloat, but returns the value of `default`
|
"""Same as config.getfloat, but returns the value of `default`
|
||||||
if there is no such option specified."""
|
if there is no such option specified."""
|
||||||
@ -74,8 +72,8 @@ class CustomConfigParser(SafeConfigParser):
|
|||||||
return re.split(separator_re, val)
|
return re.split(separator_re, val)
|
||||||
except re.error as e:
|
except re.error as e:
|
||||||
six.reraise(Error,
|
six.reraise(Error,
|
||||||
Error("Bad split regexp '%s': %s"%
|
Error("Bad split regexp '%s': %s" %
|
||||||
(separator_re, e)),
|
(separator_re, e)),
|
||||||
exc_info()[2])
|
exc_info()[2])
|
||||||
|
|
||||||
def getdefaultlist(self, section, option, default, separator_re):
|
def getdefaultlist(self, section, option, default, separator_re):
|
||||||
@ -120,7 +118,7 @@ class CustomConfigParser(SafeConfigParser):
|
|||||||
|
|
||||||
key = key + ' '
|
key = key + ' '
|
||||||
return [x[len(key):] for x in self.sections() \
|
return [x[len(key):] for x in self.sections() \
|
||||||
if x.startswith(key)]
|
if x.startswith(key)]
|
||||||
|
|
||||||
def set_if_not_exists(self, section, option, value):
|
def set_if_not_exists(self, section, option, value):
|
||||||
"""Set a value if it does not exist yet.
|
"""Set a value if it does not exist yet.
|
||||||
@ -131,7 +129,6 @@ class CustomConfigParser(SafeConfigParser):
|
|||||||
if not self.has_option(section, option):
|
if not self.has_option(section, option):
|
||||||
self.set(section, option, value)
|
self.set(section, option, value)
|
||||||
|
|
||||||
|
|
||||||
def apply_xforms(self, string, transforms):
|
def apply_xforms(self, string, transforms):
|
||||||
"""Applies set of transformations to a string.
|
"""Applies set of transformations to a string.
|
||||||
|
|
||||||
@ -150,7 +147,6 @@ class CustomConfigParser(SafeConfigParser):
|
|||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def CustomConfigDefault():
|
def CustomConfigDefault():
|
||||||
"""Just a constant that won't occur anywhere else.
|
"""Just a constant that won't occur anywhere else.
|
||||||
|
|
||||||
@ -161,7 +157,6 @@ def CustomConfigDefault():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigHelperMixin(object):
|
class ConfigHelperMixin(object):
|
||||||
"""Allow comfortable retrieving of config values pertaining
|
"""Allow comfortable retrieving of config values pertaining
|
||||||
to a section.
|
to a section.
|
||||||
@ -206,9 +201,7 @@ class ConfigHelperMixin(object):
|
|||||||
Must be overriden in all classes that use this mix-in."""
|
Must be overriden in all classes that use this mix-in."""
|
||||||
|
|
||||||
raise NotImplementedError("ConfigHelperMixin.getconfig() "
|
raise NotImplementedError("ConfigHelperMixin.getconfig() "
|
||||||
"is to be overriden")
|
"is to be overriden")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getsection(self):
|
def getsection(self):
|
||||||
"""Returns name of configuration section in which our
|
"""Returns name of configuration section in which our
|
||||||
@ -217,10 +210,9 @@ class ConfigHelperMixin(object):
|
|||||||
Must be overriden in all classes that use this mix-in."""
|
Must be overriden in all classes that use this mix-in."""
|
||||||
|
|
||||||
raise NotImplementedError("ConfigHelperMixin.getsection() "
|
raise NotImplementedError("ConfigHelperMixin.getsection() "
|
||||||
"is to be overriden")
|
"is to be overriden")
|
||||||
|
|
||||||
|
def getconf(self, option, default=CustomConfigDefault):
|
||||||
def getconf(self, option, default = CustomConfigDefault):
|
|
||||||
"""Retrieves string from the configuration.
|
"""Retrieves string from the configuration.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -233,8 +225,7 @@ class ConfigHelperMixin(object):
|
|||||||
self.getconfig().getdefault,
|
self.getconfig().getdefault,
|
||||||
self.getconfig().get)
|
self.getconfig().get)
|
||||||
|
|
||||||
|
def getconf_xform(self, option, xforms, default=CustomConfigDefault):
|
||||||
def getconf_xform(self, option, xforms, default = CustomConfigDefault):
|
|
||||||
"""Retrieves string from the configuration transforming the result.
|
"""Retrieves string from the configuration transforming the result.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -249,8 +240,7 @@ class ConfigHelperMixin(object):
|
|||||||
value = self.getconf(option, default)
|
value = self.getconf(option, default)
|
||||||
return self.getconfig().apply_xforms(value, xforms)
|
return self.getconfig().apply_xforms(value, xforms)
|
||||||
|
|
||||||
|
def getconfboolean(self, option, default=CustomConfigDefault):
|
||||||
def getconfboolean(self, option, default = CustomConfigDefault):
|
|
||||||
"""Retrieves boolean value from the configuration.
|
"""Retrieves boolean value from the configuration.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -263,8 +253,7 @@ class ConfigHelperMixin(object):
|
|||||||
self.getconfig().getdefaultboolean,
|
self.getconfig().getdefaultboolean,
|
||||||
self.getconfig().getboolean)
|
self.getconfig().getboolean)
|
||||||
|
|
||||||
|
def getconfint(self, option, default=CustomConfigDefault):
|
||||||
def getconfint(self, option, default = CustomConfigDefault):
|
|
||||||
"""
|
"""
|
||||||
Retrieves integer value from the configuration.
|
Retrieves integer value from the configuration.
|
||||||
|
|
||||||
@ -279,8 +268,7 @@ class ConfigHelperMixin(object):
|
|||||||
self.getconfig().getdefaultint,
|
self.getconfig().getdefaultint,
|
||||||
self.getconfig().getint)
|
self.getconfig().getint)
|
||||||
|
|
||||||
|
def getconffloat(self, option, default=CustomConfigDefault):
|
||||||
def getconffloat(self, option, default = CustomConfigDefault):
|
|
||||||
"""Retrieves floating-point value from the configuration.
|
"""Retrieves floating-point value from the configuration.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -293,9 +281,8 @@ class ConfigHelperMixin(object):
|
|||||||
self.getconfig().getdefaultfloat,
|
self.getconfig().getdefaultfloat,
|
||||||
self.getconfig().getfloat)
|
self.getconfig().getfloat)
|
||||||
|
|
||||||
|
|
||||||
def getconflist(self, option, separator_re,
|
def getconflist(self, option, separator_re,
|
||||||
default = CustomConfigDefault):
|
default=CustomConfigDefault):
|
||||||
"""Retrieves strings from the configuration and splits it
|
"""Retrieves strings from the configuration and splits it
|
||||||
into the list of strings.
|
into the list of strings.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user