Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/__init__.py @ 195:28e6c1413947
Added support for TOML style configuration files
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 03 May 2019 21:51:09 +0200 |
| parents | 8af600d0e5c0 |
| children | 7865f28038a4 |
comparison
equal
deleted
inserted
replaced
| 194:0d8dd58afc44 | 195:28e6c1413947 |
|---|---|
| 115 | 115 |
| 116 | 116 |
| 117 def _load_ini(filename): | 117 def _load_ini(filename): |
| 118 from . import ini | 118 from . import ini |
| 119 return ini.load(filename) | 119 return ini.load(filename) |
| 120 | |
| 121 | |
| 122 def _load_toml(filename): | |
| 123 from . import toml | |
| 124 return toml.load(filename) | |
| 120 | 125 |
| 121 | 126 |
| 122 EMACS_MODELINE = re.compile(r"-\*-(.*?)-\*-") | 127 EMACS_MODELINE = re.compile(r"-\*-(.*?)-\*-") |
| 123 EMACS_MODE = re.compile(r"(?:\A\s*|;\s*)mode[:=]\s*([-_.a-zA-Z0-9]+)") | 128 EMACS_MODE = re.compile(r"(?:\A\s*|;\s*)mode[:=]\s*([-_.a-zA-Z0-9]+)") |
| 124 | 129 |
| 152 "python": _load_py, | 157 "python": _load_py, |
| 153 "yaml": _load_yaml, | 158 "yaml": _load_yaml, |
| 154 "conf": _load_ini, | 159 "conf": _load_ini, |
| 155 "conf-windows": _load_ini, | 160 "conf-windows": _load_ini, |
| 156 "ini": _load_ini, | 161 "ini": _load_ini, |
| 162 "toml": _load_toml, | |
| 157 "javascript": _load_json, | 163 "javascript": _load_json, |
| 158 "json": _load_json, | 164 "json": _load_json, |
| 159 } | 165 } |
| 160 """Default associations between file modes and loader functions""" | 166 """Default associations between file modes and loader functions""" |
| 161 | 167 |
| 164 ("*.yml", "yaml"), | 170 ("*.yml", "yaml"), |
| 165 ("*.yaml", "yaml"), | 171 ("*.yaml", "yaml"), |
| 166 ("*.json", "json"), | 172 ("*.json", "json"), |
| 167 ("*.py", "python"), | 173 ("*.py", "python"), |
| 168 ("*.ini", "conf"), | 174 ("*.ini", "conf"), |
| 175 ("*.toml", "toml"), | |
| 169 ] | 176 ] |
| 170 """The builtin default associations of filename extensions with | 177 """The builtin default associations of filename extensions with |
| 171 file modes -- in that order. | 178 file modes -- in that order. |
| 172 | 179 |
| 173 The "mode" part may be a string or a callable with a filename | 180 The "mode" part may be a string or a callable with a filename |
