summaryrefslogtreecommitdiff
path: root/configuration.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2010-10-11 09:36:12 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2010-10-11 09:36:12 +0200
commit4142bc20473def96e9dfca3dc280308a91f4b090 (patch)
tree47fc3668597bc1a186d6243b75c3a77fd6c87675 /configuration.py
parent885ead94dc7fb402137f86b2ed0200db94ae0215 (diff)
downloadlogilab-common-4142bc20473def96e9dfca3dc280308a91f4b090.tar.gz
make OptionError available through the module
Diffstat (limited to 'configuration.py')
-rw-r--r--configuration.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/configuration.py b/configuration.py
index 7e0333d..cc2df6d 100644
--- a/configuration.py
+++ b/configuration.py
@@ -119,6 +119,8 @@ from logilab.common.compat import str_encode as _encode
from logilab.common.textutils import normalize_text, unquote
from logilab.common import optik_ext as optparse
+OptionError = optparse.OptionError
+
REQUIRED = []
class UnsupportedAction(Exception):
@@ -359,6 +361,10 @@ def ini_format_section(stream, section, options, encoding=None, doc=None):
if doc:
print >> stream, _encode(comment(doc), encoding)
print >> stream, '[%s]' % section
+ ini_format(stream, options, encoding)
+
+def ini_format(stream, options, encoding):
+ """format options using the INI format"""
for optname, optdict, value in options:
value = format_option_value(optdict, value)
help = optdict.get('help')
@@ -852,7 +858,8 @@ class OptionsProviderMixIn(object):
for option in self.options:
if option[0] == opt:
return option[1]
- raise optparse.OptionError('no such option in section %r' % self.name, opt)
+ raise OptionError('no such option %s in section %r'
+ % (self.name, opt), opt)
def all_options(self):
@@ -937,7 +944,7 @@ class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn):
def get(self, key, default=None):
try:
return getattr(self.config, self.option_name(key))
- except (optparse.OptionError, AttributeError):
+ except (OptionError, AttributeError):
return default