configpy is a JSON configuration file reader with support for variable look-ahead and look-behind, expressions, and comments.
Variables are represented by ${var_name} and
values are evaluated when surrounded by {{ }}.
config_str = """
/* Some example configuration items */
{
"a": 10,
"b": 2,
"c": "{{ ${a} / ${b} }}",
"d": "{{ ${c} * ${a} }}",
"e": "{{ ${d} + 50 }}",
"f": "{{ ${e} - 25 }}"
}
"""
config = Config(config_str)
assert 10 == config.a
assert 2 == config.b
assert 5 == config.c
assert 50 == config.d
assert 100 == config.e
assert 75 == config.f
To grab the code, raise an issue or keep track of any updates visit the repository.