Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/__init__.py @ 98:d6ba53ce2091
Better documentation of the core function in "configmix"
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Wed, 21 Mar 2018 16:53:03 +0100 |
| parents | 778c3bb1fb41 |
| children | 2ee042791197 |
comparison
equal
deleted
inserted
replaced
| 97:1b4d95f60650 | 98:d6ba53ce2091 |
|---|---|
| 26 __all__ = ["load", "Configuration"] | 26 __all__ = ["load", "Configuration"] |
| 27 | 27 |
| 28 | 28 |
| 29 def load(*files): | 29 def load(*files): |
| 30 """Load the given configuration files, merge them in the given order | 30 """Load the given configuration files, merge them in the given order |
| 31 and return the resulting :class:`configmix.config.Configuration` dictionary. | 31 and return the resulting :class:`configmix.config.Configuration` |
| 32 dictionary. | |
| 32 | 33 |
| 33 """ | 34 """ |
| 34 if not files: | 35 if not files: |
| 35 return Configuration() | 36 return Configuration() |
| 36 else: | 37 else: |
| 77 result[k] = deepcopy(v) | 78 result[k] = deepcopy(v) |
| 78 return result | 79 return result |
| 79 | 80 |
| 80 | 81 |
| 81 def merge(user, default, _first=True): | 82 def merge(user, default, _first=True): |
| 82 """A simple (YAML-)tree merge. | 83 """A simple (YAML-)tree-merge. |
| 84 | |
| 85 :param ~configmix.config.Configuration user: | |
| 86 the new configuration that will be merged into `default` | |
| 87 :param ~configmix.config.Configuration default: | |
| 88 the base configuration where `user` is merged into | |
| 89 :param bool _first: an intexrnal argument for controlling recursion | |
| 83 | 90 |
| 84 From http://stackoverflow.com/questions/823196/yaml-merge-in-python | 91 From http://stackoverflow.com/questions/823196/yaml-merge-in-python |
| 85 | 92 |
| 86 .. note:: `_first` is an internal argument. | 93 .. note:: `_first` is an internal argument. |
| 87 | 94 |
