Load settings from ini files
Allow loading settings from ini files. The taurus.tauruscustomsettings
remains the main interface for accessing and setting configurations, but its members can now be modified from system and user ini files.
- Implement
tauruscustomsettings.load_configs()
to load configs from system-wide and user-specific files. - Add
tauruscustomsettings.SYSTEM_CFG_FILE
(location of system-wide config file) - Add
tauruscustomsettings.USER_CFG_FILE
(location of user-specific config file) - Add the
--settings
option to the taurus CLI command to pass additional settings file(s) to be loaded
The SYSTEM_CFG_FILE and USER_CFG_FILE variables are set with platform dependent values:
- on posix systems we follow the xdg standard:
/etc/xdg/taurus/taurus.ini
and~/.config/taurus/taurus.ini
- on windows machines we use
%PROGRAMDATA%\taurus\taurus.ini
and%APPDATA%\taurus\taurus.ini
)
The load_configs()
function can be called at any point to load other configuration files (overwriting existing config keys in case of conflict).
The ini files are of the form:
[taurus]
FOO = "bar"
BAR = [1, 2, 3]
baz = False
The keys are then exposed as tauruscustomsettings
variables and their values are interpreted as python literals (e.g. tauruscustomsettings.BAR
would be a list
in the above example.
Closes #1181 (closed)
Edited by Carlos Pascual