Ensure that CLI options take precedence over configuration values.

For each name/option tuple, if the option is set, override configuration
value.
545841
function ensure (env, options, names) {
  for (let k of Object.keys(names)) {
    let v = names[k]

    if (options[v]) {
      env[k] = options[v]
      env[k + 'Cwd'] = true
    }
  }
}
1029285
def set_overrides(args, _conf=None):
    
    # Get the subcommand name to avoid overwritting values from other
    # subcommands that are not going to be used
    subcommand = args.func.__name__
    command_section = 'ceph-deploy-%s' % subcommand
    conf = _conf or load()

    for section_name in conf.sections():
        if section_name in ['ceph-deploy-global', command_section]:
            override_subcommand(
                section_name,
                conf.items(section_name),
                args
            )
    return args
1286291
def set_option(name, value):
    
    d = globals()

    if name in {'get_option', 'set_option'} or name not in d:
        from ..exceptions import PlotnineError
        raise PlotnineError("Unknown option {}".format(name))

    old = d[name]
    d[name] = value
    return old
15229
function overrideConfig() {
    _.merge(Elixir.config, require(path.join(process.cwd(), 'elixirConfig.js')));
}
1066323
def define_options(default_conf):
    
    default = {}
    with open(default_conf, 'rb') as f:
        exec_in(native_str(f.read()), {}, default)

    for name, value in default.iteritems():
        # if the option is already defined by tornado
        # override the value
        # a list of options set by tornado:
        # log_file_num_backups, logging, help,
        # log_to_stderr, log_file_max_size, log_file_prefix
        if name in options:
            setattr(options, name, value)
        # otherwise define the option
        else:
            define(name, value)
499940
def override(self, config_params):
        
        map = StringValueMap.from_maps(self, config_params)
        return ConfigParams(map)
950913
public void overrideSetting(String name, float value) {
        overrides.put(name, Float.toString(value));
    }
52528
def change_option_default(self, opt_name, default_val):
        
        if not self.has_option(opt_name):
            raise ValueError("Unknow option name (%s)" % opt_name)
        self._options[opt_name].default = default_val
243200
def override(self, key, value):
        
        keys = key.split('.')
        if len(keys) > 1:
            if keys[0] != "plugins":
                raise AttributeError("no such setting: %r" % key)
            self.plugins.override(keys[1:], value)
        else:
            self.overrides[key] = value
            self._uncache(key)
910226
def override_config(self, path):
        
        status = (True, None)
        config_override = False

        try:
            # parse the yml file
            c_dict = {}
            if exists(self.plugin_config_file):
                with open(self.plugin_config_file, 'r') as config_file:
                    c_dict = yaml.safe_load(config_file.read())

            # check for environment variable overrides
            check_c_dict = c_dict.copy()
            for tool in check_c_dict:
                for section in check_c_dict[tool]:
                    for key in check_c_dict[tool][section]:
                        if key in environ:
                            c_dict[tool][section][key] = getenv(key)

            # assume the name of the plugin is its directory
            plugin_name = path.split('/')[-1]
            if plugin_name == '':
                plugin_name = path.split('/')[-2]
            plugin_config_path = path + '/config/' + plugin_name + '.config'

            if exists(plugin_config_path):
                plugin_template = Template(plugin_config_path)
                plugin_options = c_dict[plugin_name]
                for section in plugin_options:
                    for option in plugin_options[section]:
                        plugin_template.set_option(section, option,
                                                   str(plugin_options[section][option]))
                plugin_template.write_config()
                config_override = True
        except Exception as e:  # pragma: no cover
            status = (False, str(e))

        return status, config_override
949840
def set(self, section, option, value=''):
        '''
        
        '''
        self._string_check(value)
        super(GitConfigParser, self).set(section, option, value)
720373
def config_args(self, section="main"):
        
        if self._config_parsed:
            return
        for a in self._filtered_actions("config"):
            for o in a.option_strings:
                try:
                    i = sys.argv.index(o)
                    sys.argv.pop(i)  # remove the option string
                    sys.argv.pop(i)  # remove the value that follows
                except ValueError:
                    pass
        for a in self._sorted_actions():
            self._set_arg(a, section, True)
        self._config_parsed = True
1094198
public synchronized void setOption(String key, String value)
	{
		if (key == null || value == null) {
			return;
		}
		config.put(key, value);
	}
186916
def might_prefer(self, **items):
        ''''''
        self._overrides = dict((k, v) for (k, v) in items.items() if v is not None)
371572
def _set_opt(config_dict, path, value):
    """"""
    if value is None:
        return

    if '.' not in path:
        config_dict[path] = value
        return

    key, rest = path.split(".", 1)
    if key not in config_dict:
        config_dict[key] = {}

    _set_opt(config_dict[key], rest, value)
577055
def do_opt(self, *args, **kwargs):
        
        args = list(args)
        if not args:
            largest = 0
            keys = [key for key in self.conf if not key.startswith("_")]
            for key in keys:
                largest = max(largest, len(key))
            for key in keys:
                print("%s : %s" % (key.rjust(largest), self.conf[key]))
            return
        option = args.pop(0)
        if not args and not kwargs:
            method = getattr(self, "getopt_" + option, None)
            if method is None:
                self.getopt_default(option)
            else:
                method()
        else:
            method = getattr(self, "opt_" + option, None)
            if method is None:
                print("Unrecognized option %r" % option)
            else:
                method(*args, **kwargs)
                self.save_config()
1365456
def override_if_not_in_args(flag, argument, args):
  """"""
  if flag not in args:
    args.extend([flag, argument])