summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain <syt@logilab.fr>2007-10-26 08:53:28 +0200
committerSylvain <syt@logilab.fr>2007-10-26 08:53:28 +0200
commitd0143399410e7504014dc70e4e42e5e5f26b02f1 (patch)
treefe891cbb612ea735e794f9bae490d97a6d09d8ce
parent4c9f3d2c4ceaa077b9e9f3b0e1afe765ab890bf7 (diff)
parenta5efc1a8b711eaf5106f1986ee3e4287bafa7872 (diff)
downloadlogilab-common-d0143399410e7504014dc70e4e42e5e5f26b02f1.tar.gz
merge
-rw-r--r--ChangeLog9
-rw-r--r--__pkginfo__.py2
-rw-r--r--clcommands.py2
-rw-r--r--configuration.py47
-rw-r--r--debian/changelog12
-rw-r--r--modutils.py8
6 files changed, 54 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index cd5e8db..b3d37d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
ChangeLog for logilab.common
============================
- --
+2007-10-23 -- 0.23.1
+ * modutils: fix load_module_from_* (even with use_sys=False, it should
+ try to get outer packages from sys.modules)
+
+
+2007-10-17 -- 0.23.0
* db:
- mark support_users and support_groups methods as obsolete in
@@ -15,7 +20,7 @@ ChangeLog for logilab.common
* modutils: new load_module_from_file shortcut function
* clcommands: pop_args accept None as value for expected_size_after,
meaning remaining args should not be checked
- * interface: new extend function to dynamically add an implemented interface
+ * interface: new extend function to dynamically add an implemented interface
to a new style class
2007-06-25 -- 0.22.2
diff --git a/__pkginfo__.py b/__pkginfo__.py
index 5272f0e..dd2ac57 100644
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -17,7 +17,7 @@
distname = 'logilab-common'
modname = 'common'
-numversion = (0, 22, 2)
+numversion = (0, 23, 1)
version = '.'.join([str(num) for num in numversion])
license = 'GPL'
diff --git a/clcommands.py b/clcommands.py
index ff8bd13..71427cf 100644
--- a/clcommands.py
+++ b/clcommands.py
@@ -94,7 +94,7 @@ Type "%prog <command> --help" for more information about a specific
command. Available commands are :\n''')
doc = doc.replace('%prog', basename(sys.argv[0]))
print 'usage:', doc
- max_len = max(len(cmd) for cmd in commands)
+ max_len = max([len(cmd) for cmd in commands]) # list comprehension for py 2.3 support
padding = ' '*max_len
for command in commands:
cmd = _COMMANDS[command]
diff --git a/configuration.py b/configuration.py
index 279c3c4..5f79b0f 100644
--- a/configuration.py
+++ b/configuration.py
@@ -479,30 +479,11 @@ class OptionsManagerMixIn(object):
for section, option, optdict in provider.all_options():
if onlysection is not None and section != onlysection:
continue
- default = provider.option_default(option, optdict)
- if optdict['type'] == 'password':
- defaultstr = ': '
- elif default is REQUIRED:
- defaultstr = '(required): '
- else:
- if optdict.get('inputlevel', 0) > inputlevel:
- provider.set_option(option, default, opt_dict=optdict)
- continue
- defaultstr = '(default: %s): ' % format_option_value(optdict, default)
- print ':%s:' % option
- print optdict.get('help') or option
- inputfunc = INPUT_FUNCTIONS[optdict['type']]
- value = inputfunc(optdict, defaultstr)
- while default is REQUIRED and not value:
- print 'please specify a value'
- value = inputfunc(optdict, '%s: ' % option)
- if value is None and default is not None:
- value = default
- provider.set_option(option, value, opt_dict=optdict)
+ provider.input_option(option, optdict, inputlevel)
# now we can generate the configuration file
if stream is not None:
self.generate_config(stream)
-
+
def load_config_file(self):
"""dispatch values previously read from a configuration file to each
options provider)
@@ -615,6 +596,8 @@ class OptionsProviderMixIn:
if action != 'callback':
# callback action have no default
default = self.option_default(opt_name, opt_dict)
+ if default is REQUIRED:
+ continue
self.set_option(opt_name, default, action, opt_dict)
def option_default(self, opt_name, opt_dict=None):
@@ -675,6 +658,28 @@ class OptionsProviderMixIn:
_list.append(value)
else:
raise UnsupportedAction(action)
+
+ def input_option(self, option, optdict, inputlevel=99):
+ default = self.option_default(option, optdict)
+ if default is REQUIRED:
+ defaultstr = '(required): '
+ elif optdict.get('inputlevel', 0) > inputlevel:
+ self.set_option(option, default, opt_dict=optdict)
+ return
+ elif optdict['type'] == 'password':
+ defaultstr = ': '
+ else:
+ defaultstr = '(default: %s): ' % format_option_value(optdict, default)
+ print ':%s:' % option
+ print optdict.get('help') or option
+ inputfunc = INPUT_FUNCTIONS[optdict['type']]
+ value = inputfunc(optdict, defaultstr)
+ while default is REQUIRED and not value:
+ print 'please specify a value'
+ value = inputfunc(optdict, '%s: ' % option)
+ if value is None and default is not None:
+ value = default
+ self.set_option(option, value, opt_dict=optdict)
def get_option_def(self, opt_name):
"""return the dictionary defining an option given it's name"""
diff --git a/debian/changelog b/debian/changelog
index a346054..9dce3d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+logilab-common (0.23.1-1) unstable; urgency=low
+
+ * new upstream release
+
+ -- Sylvain Thénault <sylvain.thenault@logilab.fr> Tue, 23 Oct 2007 21:16:41 +0200
+
+logilab-common (0.23.0-1) unstable; urgency=low
+
+ * new upstream release
+
+ -- Sylvain Thénault <sylvain.thenault@logilab.fr> Wed, 17 Oct 2007 17:09:02 +0200
+
logilab-common (0.22.2-1) unstable; urgency=low
* new upstream release
diff --git a/modutils.py b/modutils.py
index 0c026d3..221d5d6 100644
--- a/modutils.py
+++ b/modutils.py
@@ -109,13 +109,19 @@ def load_module_from_modpath(parts, path=None, use_sys=1):
:rtype: module
:return: the loaded module
"""
+ if use_sys:
+ try:
+ return sys.modules['.'.join(parts)]
+ except KeyError:
+ pass
modpath = []
prevmodule = None
for part in parts:
modpath.append(part)
curname = ".".join(modpath)
module = None
- if use_sys:
+ if len(modpath) != len(parts):
+ # even with use_sys=Fallse, should try to get outer packages from sys.modules
module = sys.modules.get( curname )
if module is None:
mp_file, mp_filename, mp_desc = find_module(part, path)