Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/__init__.py @ 122:21d92ff8cf31
Begin the handling of JSON-style configuration files
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 04 Apr 2018 09:45:29 +0200 |
| parents | c50ad93eb5dc |
| children | b883f4ef1967 |
comparison
equal
deleted
inserted
replaced
| 121:0d378dcc018b | 122:21d92ff8cf31 |
|---|---|
| 62 fnl = filename.lower() | 62 fnl = filename.lower() |
| 63 if fnl.endswith(".yml") or fnl.endswith("yaml"): | 63 if fnl.endswith(".yml") or fnl.endswith("yaml"): |
| 64 from . import yaml | 64 from . import yaml |
| 65 with open(filename, "rb") as yf: | 65 with open(filename, "rb") as yf: |
| 66 return yaml.safe_load(yf) | 66 return yaml.safe_load(yf) |
| 67 elif fnl.endswith(".json"): | |
| 68 from . import json | |
| 69 return json.load(filename) | |
| 67 elif fnl.endswith(".py"): | 70 elif fnl.endswith(".py"): |
| 68 from . import py | 71 from . import py |
| 69 return py.load(filename) | 72 return py.load(filename) |
| 70 elif fnl.endswith(".ini"): | 73 elif fnl.endswith(".ini"): |
| 71 from . import ini | 74 from . import ini |
