Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/py.py @ 125:c11dd36279d9
More documentation for the configmix.py module
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Wed, 04 Apr 2018 10:56:54 +0200 |
| parents | 218807d7d883 |
| children | e2e8d21b4122 |
comparison
equal
deleted
inserted
replaced
| 124:be6cdc9cb79c | 125:c11dd36279d9 |
|---|---|
| 23 | 23 |
| 24 __all__ = ["load"] | 24 __all__ = ["load"] |
| 25 | 25 |
| 26 | 26 |
| 27 def load(filename, extract=None): | 27 def load(filename, extract=None): |
| 28 """Load Python-style configuration files. | |
| 29 | |
| 30 Files are loaded and **executed** with :func:`exec` using an empty | |
| 31 dict as global and local context.# | |
| 32 | |
| 33 :param filename: the path to the configuration file | |
| 34 :param extract: an optional list of variable names (keys) to extract | |
| 35 into the resulting configuration dictionary | |
| 36 :returns: the configuration as dictionary | |
| 37 :rtype: collections.OrderedDict or ordereddict.OrderedDict or dict | |
| 38 | |
| 39 """ | |
| 28 if extract is not None: | 40 if extract is not None: |
| 29 if not isinstance(extract, (type([]), type(tuple()), type(set()), )): | 41 if not isinstance(extract, (type([]), type(tuple()), type(set()), )): |
| 30 raise TypeError("`extract' must be a sequence") | 42 raise TypeError("`extract' must be a sequence") |
| 31 gcontext = DictImpl() | 43 gcontext = DictImpl() |
| 32 lcontext = DictImpl() | 44 lcontext = DictImpl() |
