def process_option(keyval): key, value = keyval.split('=', 2) parts = key.split('.') try: setting = self.config_root.find_setting(parts) except KeyError: setting = None if setting is None: exit_warning( _('ERROR: Unknown config option: “{}”').format(key)) setting.value_from_cliarg = value
def die_write_failed(config_obj, err): hint = extract_hint(err) msg = _( '{}: {} “{}”: “{}”{}' ).format( _('ERROR'), _('Failed to write file at'), config_obj.filename, str(err), ' ({})'.format(hint) if hint else '', ) exit_warning(msg)
def create_config(self, force): if not self.config_path: # It's up to the DEV to ensure this. raise AttributeError('ConfigUrable missing ‘config_path’') cfgfile_exists = os.path.exists(self.config_path) if cfgfile_exists and not force: exit_warning(_('Config file exists')) self.reset_config() click_echo( _('Initialized default config file at {}').format( highlight_value(self.config_path), ))
def exit_duplicates(err): msg = _( 'ERROR: Your config file at “{}” has a duplicate setting: “{}”' ).format(configfile_path, str(err)) exit_warning(msg)
def exit_parse_error(err): msg = _( 'ERROR: Your config file at “{}” has a syntax error: “{}”' ).format(configfile_path, str(err)) exit_warning(msg)
def test_exit_warning(click_echo_mock): with pytest.raises(SystemExit): exit_warning('foo') assert click_echo_mock.called