Storages¶
Cfgtree does not make any assumption of the way settings are stored, appart from the fact they are all organized in a hierarchicla structure.
Some common storage format are provided out of the box by cfgtree, but developers can easily implement their own configuration file format.
AnyConfig handled configuration file¶
anyconfig
is a library abstracting the load of a variety of configuration file format (ini,
json, yaml,…)
Single Json file¶
-
class
cfgtree.storages.json.
JsonFileConfigStorage
(environ_var=None, long_param=None, short_param=None, default_filename=None)[source]¶ Settings are stored in a single JSON file
Example:
{ 'version': 1, 'general': { 'verbose': true , 'logfile': 'logfile.log' } }
Usage:
class MyAppConfig(ConfigBaseModel): ... storage = JsonFileConfigStorage( environ_var="MYAPP_COMMON_CONFIG_FILE", long_param="--config", short_param="-c", default_filename="config.json", ) ...
-
default_filename
= None¶ Default filename for the JSON configuration file
Example:
myconfig.json
-
environ_var
= None¶ Environment variable to set the configuration file name
Example:
DOPPLERR_COMMON_CONFIG_FILE="myconfig.json"
-
find_default_filename
(model)¶
-
get_config_file
()¶
-
long_param
= None¶ Short parameter to specify the configure file name
Example:
--config-file myconfig.json
-
short_param
= None¶ Short parameter to specify the configure file name
Example:
-g myconfig.json
-