20 from sys
import version_info
21 if version_info >= (3, ):
26 CALLABLE_FORMAT = re.compile(
27 r'^(?P<module>[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*):(?P<callable>[a-zA-Z_][a-zA-Z0-9_]*)$'
33 from collections.abc
import Mapping
35 from collections
import Mapping
36 if not isinstance(iterable, Mapping):
37 return {c.name: c
for c
in iterable}
43 Merge configuration dictionaries ({'name': Configurable('name'), ...}) or
44 lists ([Configurable('name'), ...]) into one configuration dictionary.
46 **warning** the configurable instances passed are not cloned during the
47 merging, so the arguments to this function cannot be used afterwards
50 for config
in configs:
54 result[name].
merge(config[name])
56 result[name] = config[name]
61 from importlib
import import_module
63 if not callable(func):
64 if isinstance(func, basestring):
65 m = CALLABLE_FORMAT.match(func)
68 import_module(m.group(
'module')), m.group(
'callable'))
70 raise ValueError(
'invalid callable id %r' % func)
73 'expected either a callable or a string as first argument')