ProsperConfig¶
Parsing global/local configs can be obnoxious. We provide a way to use/override configs. Especially for libraries, a way to control globals or override them.
All Prosper use the ProsperConfig
parser. Powered by py3’s configparser
.
ProsperConfig()¶
import prosper.common.prosper_config as p_config
ConfigObj = ProsperConfig(
'path/to/config.cfg'
local_filepath_override='path/to/custom_config.cfg' #optional
)
option_value = ConfigObj.get_option('SECTION_NAME', 'KEY_NAME', override_value, default_value)
This should give the following priority for option_value
if override_value != default_value: override value
: A value given at arg timelocal_config['SECTION_NAME']['KEY_NAME']
: Untracked local config file (secrets safe)global_config['SECTION_NAME']['KEY_NAME']
: Git tracked config fileos.environ.get('PROSPER_{SECTION_NAME}__{KEY_NAME}')
: Check the environment for values (secrets safe-ish)default_value
as a final result to avoid returningNone
where it wouldn’t be supported