def _init_config(self, override_dict): defaults = cfg.from_defaults() filecfg = cfg.from_configparser(pathprovider.configurationFile()) custom = defaults.replace(filecfg, on_error=log.e) global config config = custom.replace(override_dict, on_error=log.e) self._check_for_config_updates(defaults, filecfg)
def _init_config(self): global config defaultcfg = configuration.from_defaults() configFilePath = util.configurationFile() log.d('loading configuration from %s', configFilePath) filecfg = configuration.from_configparser(configFilePath) config = defaultcfg + filecfg self._check_for_config_updates(filecfg)
def _init_config(self, override_dict): """update the internal configuration using the following hierarchy: command_line_config > file_config > default_config check if there are new or deprecated configuration keys in the config file """ defaults = cfg.from_defaults() filecfg = cfg.from_configparser(pathprovider.configurationFile()) custom = defaults.replace(filecfg, on_error=log.e) global config config = custom.replace(override_dict, on_error=log.e) self._check_for_config_updates(defaults, filecfg)
def test_file_functions(self): import tempfile tf = tempfile.NamedTemporaryFile() cfg = configuration.from_defaults() configuration.write_to_file(cfg, tf.name) # compare with the limited cfg the configparser can return parsed = configuration.from_configparser(tf.name) assert len(cfg) == len(parsed), '%r <--> %r' % (cfg, parsed) for key in cfg: this, that = cfg[key], parsed[key] assert Key(this.name) == Key(that.name) assert str(this.value) == str(that.value) assert len(cfg) == len(parsed), 'no properties must be added while comparing: %r <--> %r' % (this, that)
def setup_config(override_dict=None): """ Updates the internal configuration using the following hierarchy: override_dict > file_config > default_config Notifies the user if there are new or deprecated configuration keys. See :mod:`~cherrymusicserver.configuration`. """ defaults = cfg.from_defaults() filecfg = cfg.from_configparser(pathprovider.configurationFile()) custom = defaults.replace(filecfg, on_error=log.e) if override_dict: custom = custom.replace(override_dict, on_error=log.e) global config config = custom _notify_about_config_updates(defaults, filecfg)