Configuration management library with value substitution for python
sample.json
{"Marco": "Polo"}
sample.py
from subconfig import SubConfig
sc = SubConfig(files=["sample.json"])
print(sc["Marco"])
Output:
Polo
substitute.json
{
"name": "Jane",
"surname": "Doe",
"full_name": "${name} ${surname}"
}
substitute.py
from subconfig import SubConfig
sc = SubConfig(files=["substitute.json"])
print(sc["full_name"])
Output:
Jane Doe
Structured configuration values can be addressed using dot notation
nested.json
{
"books": [{"title": "Little Red Riding Hood"}],
"favorite_book": "${books.0.title}"
}
nested.py
from subconfig import SubConfig
sc = SubConfig(["nested.json"])
print(sc["books.0.title"])
# Dot notation works for value substitution as well
print(sc["favorite_book"])
Output:
Little Red Riding Hood
Little Red Riding Hood