Mercurial > hgrepos > Python > libs > ConfigMix
view configmix/json.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 | be6cdc9cb79c |
| children | 5b62d2c0e5a8 |
line wrap: on
line source
# -*- coding: utf-8 -*- #- # :Copyright: (c) 2018, Franz Glasner. All rights reserved. # :License: 3-clause BSD. See LICENSE.txt for details. #- """Read JSON-style configuration files. """ from __future__ import division, absolute_import, print_function import io import json.decoder __all__ = ["load"] def load(filename, encoding="utf-8"): """Load a single JSON file with name `filename` and encoding `encoding`. .. todo:: Allow comments in JSON files .. todo:: Allow all Python string literals .. todo:: Use OrderedDict as default mapping implementation (Python 2.7+) """ with io.open(filename, mode="rt", encoding=encoding) as jsfp: decoder = json.decoder.JSONDecoder( parse_int=lambda n: int(n, 0), strict=False) return decoder.decode(jsfp.read())
