diff options
author | Sylvain <syt@logilab.fr> | 2006-09-19 11:38:16 +0200 |
---|---|---|
committer | Sylvain <syt@logilab.fr> | 2006-09-19 11:38:16 +0200 |
commit | c60bed25b0d53ab9f604f353bb6f97e90a499847 (patch) | |
tree | b462c0b0a1c7d62dcc1fd06e0dec7a41c6634238 /optik_ext.py | |
parent | cf88be2a16e01a12785ad0cfc9ba5cc69a143409 (diff) | |
download | logilab-common-c60bed25b0d53ab9f604f353bb6f97e90a499847.tar.gz |
* db:
- fixed bug when querying boolean on sqlite using python's bool type
- added "drop_on_commit" argument to create_temporary_table on db helper
- added missing implementation of executemany on pysqlite2 wrapper to
support pyargs correctly like execute
* optik_ext: fixed "named" type option to support csv values and to return
a dictionary
Diffstat (limited to 'optik_ext.py')
-rw-r--r-- | optik_ext.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/optik_ext.py b/optik_ext.py index 17f0513..6eb73e6 100644 --- a/optik_ext.py +++ b/optik_ext.py @@ -78,7 +78,7 @@ def check_csv(option, opt, value): return get_csv(value) except ValueError: raise OptionValueError( - "option %s: invalid regexp value: %r" % (opt, value)) + "option %s: invalid csv value: %r" % (opt, value)) def check_yn(option, opt, value): """check a yn value @@ -95,14 +95,18 @@ def check_yn(option, opt, value): def check_named(option, opt, value): """check a named value - return a 2-uple (name, value) + return a dictionnary containing (name, value) associations """ - if isinstance(value, (list, tuple)) and len(value) % 2 == 0: + if isinstance(value, dict): return value - if value.find('=') != -1: - return value.split('=', 1) - if value.find(':') != -1: - return value.split(':', 1) + values = [] + for value in check_csv(option, opt, value): + if value.find('=') != -1: + values.append(value.split('=', 1)) + elif value.find(':') != -1: + values.append(value.split(':', 1)) + if values: + return dict(values) msg = "option %s: invalid named value %r, should be <NAME>=<VALUE> or \ <NAME>:<VALUE>" raise OptionValueError(msg % (opt, value)) |