Helper function to re-render command-line options.

    This assumes that command-line options use the same name as their
    key in the options dictionary.
171554
def rerender_options(options):
    
    args = []
    for name,value in options.iteritems():
        name = name.replace("_","-")
        if value is None:
            pass
        elif isinstance(value,bool):
            if value:
                args.append("--%s" % (name,))
        elif isinstance(value,list):
            for item in value:
                args.append("--%s=%s" % (name,item))
        else:
            args.append("--%s=%s" % (name,value))
    return " ".join(args)
952037
def add_local_option(self, *args, **kw):
        
        try:
            group = self.local_option_group
        except AttributeError:
            group = SConsOptionGroup(self, 'Local Options')
            group = self.add_option_group(group)
            self.local_option_group = group

        result = group.add_option(*args, **kw)

        if result:
            # The option was added successfully.  We now have to add the
            # default value to our object that holds the default values
            # (so that an attempt to fetch the option's attribute will
            # yield the default value when not overridden) and then
            # we re-parse the leftover command-line options, so that
            # any value overridden on the command line is immediately
            # available if the user turns around and does a GetOption()
            # right away.
            setattr(self.values.__defaults__, result.dest, result.default)
            self.reparse_local_options()

        return result
972357
function replacePath (path, keys) {
  var index = 0;

  function replace (_, escaped, prefix, key, capture, group, suffix, escape) {
    if (escaped) {
      return escaped;
    }

    if (escape) {
      return '\\' + escape;
    }

    var repeat   = suffix === '+' || suffix === '*';
    var optional = suffix === '?' || suffix === '*';

    keys.push({
      name:      key || index++,
      delimiter: prefix || '/',
      optional:  optional,
      repeat:    repeat
    });

    prefix = prefix ? ('\\' + prefix) : '';
    capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?');

    if (repeat) {
      capture = capture + '(?:' + prefix + capture + ')*';
    }

    if (optional) {
      return '(?:' + prefix + '(' + capture + '))?';
    }

    // Basic parameter support.
    return prefix + '(' + capture + ')';
  }

  return path.replace(PATH_REGEXP, replace);
}
1193178
def option(self, key=None):
        
        if key is None:
            return self._args.options()

        return self._args.option(key)
1112618
def update_args(self, args):
        
        for cfg in args:
            keys, v = cfg.split('=', maxsplit=1)
            keylist = keys.split('.')

            dic = self
            for i, k in enumerate(keylist[:-1]):
                assert k in dir(dic), "Unknown config key: {}".format(keys)
                dic = getattr(dic, k)
            key = keylist[-1]

            oldv = getattr(dic, key)
            if not isinstance(oldv, str):
                v = eval(v)
            setattr(dic, key, v)
938740
function resetOptions(grunt, parsedOptions){
	for (var i in parsedOptions){
		if (parsedOptions.hasOwnProperty(i) && i != 'argv'){
			grunt.option(i, parsedOptions[i]);
		}
	}
}
206082
def do_refresh(self, arg):
        
        if arg:
            raise CmdError("too many arguments")
        if self.cmdprefix:
            process = self.get_process_from_prefix()
            process.scan()
        else:
            self.debug.system.scan()
1304239
def handle_command_line(options):
    
    options = merge(options, constants.DEFAULT_OPTIONS)
    engine = plugins.ENGINES.get_engine(
        options[constants.LABEL_TEMPLATE_TYPE],
        options[constants.LABEL_TMPL_DIRS],
        options[constants.LABEL_CONFIG_DIR],
    )
    if options[constants.LABEL_TEMPLATE] is None:
        if options[constants.POSITIONAL_LABEL_TEMPLATE] is None:
            raise exceptions.NoTemplate(constants.ERROR_NO_TEMPLATE)
        else:
            engine.render_string_to_file(
                options[constants.POSITIONAL_LABEL_TEMPLATE],
                options[constants.LABEL_CONFIG],
                options[constants.LABEL_OUTPUT],
            )
    else:
        engine.render_to_file(
            options[constants.LABEL_TEMPLATE],
            options[constants.LABEL_CONFIG],
            options[constants.LABEL_OUTPUT],
        )
    engine.report()
    HASH_STORE.save_hashes()
    exit_code = reporter.convert_to_shell_exit_code(
        engine.number_of_templated_files()
    )
    return exit_code
235474
function( elem, options, callback ) {
		var old = {};

		// Remember the old values, and insert the new ones
		for ( var name in options ) {
			old[ name ] = elem.style[ name ];
			elem.style[ name ] = options[ name ];
		}

		callback.call( elem );

		// Revert the old values
		for ( var name in options ) {
			elem.style[ name ] = old[ name ];
		}
	}
645675
def _add_cli_param(params, key, value):
    '''
    
    '''
    if value is not None:
        params.append('--{0}={1}'.format(key, value))
217047
def _set_render_options(cls, options, backend=None):
        
        if backend:
            backend = backend.split(':')[0]
        else:
            backend = Store.current_backend

        cls.set_backend(backend)
        if 'widgets' in options:
            options['widget_mode'] = options['widgets']
        renderer = Store.renderers[backend]
        render_options = {k: options[k] for k in cls.render_params if k in options}
        renderer.param.set_param(**render_options)
111500
def update_options(cls, options, items):
        
        # Get new backend
        backend_spec = items.get('backend', Store.current_backend)
        split = backend_spec.split(':')
        backend, mode = split if len(split)==2 else (split[0], 'default')
        if ':' not in backend_spec:
            backend_spec += ':default'

        if 'max_branches' in items:
            print('Warning: The max_branches option is now deprecated. Ignoring.')
            del items['max_branches']

        # Get previous backend
        prev_backend = Store.current_backend
        renderer = Store.renderers[prev_backend]
        prev_backend_spec = prev_backend+':'+renderer.mode

        # Update allowed formats
        for p in ['fig', 'holomap']:
            cls.allowed[p] = list_formats(p, backend_spec)

        # Return if backend invalid and let validation error
        if backend not in Store.renderers:
            options['backend'] = backend_spec
            return options

        # Get backend specific options
        backend_options = dict(cls._backend_options[backend_spec])
        cls._backend_options[prev_backend_spec] = {k: v for k, v in cls.options.items()
                                                   if k in cls.remembered}

        # Fill in remembered options with defaults
        for opt in cls.remembered:
            if opt not in backend_options:
                backend_options[opt] = cls.defaults[opt]

        # Switch format if mode does not allow it
        for p in ['fig', 'holomap']:
            if backend_options.get(p) not in cls.allowed[p]:
                backend_options[p] = cls.allowed[p][0]

        # Ensure backend and mode are set
        backend_options['backend'] = backend_spec
        backend_options['mode'] = mode

        return backend_options
1307663
def rearrange_options!(args, options)
      prefix_options = {}
      (PREFIX_OPTIONS + PREFIX_OPTIONS.map { |o| o.to_s }).each do |k|
        if options.has_key?(k)
          value = options.delete(k)
          prefix_options[k.to_sym] = value
        end
      end
      hash_to_options(prefix_options).reverse.each { |o| args.unshift(o) }
    end
74219
def transform_arguments(arguments, prev_values, inputs)
      arguments = arguments.replace_values_from_previous(prev_values)
      arguments.each do |arg_name, arg_values|
        arguments[arg_name] = {} unless arguments[arg_name].is_a?(Hash)
        arguments[arg_name]['value'] = ''
        if inputs.key?(arg_name)
          arguments[arg_name]['value'] = inputs[arg_name]
        elsif arg_values.is_a?(Hash) && arg_values.key?('default')
          arguments[arg_name]['value'] = arg_values['default']
        end
      end
    end
359838
def options(self, glob=False, **args):
        
        kwargs = {}
        for argname, argarg in args.items():
            if argname == "sort":
                argarg = self._getPattern(argarg)
            if argname not in ["done", "undone"]:
                kwargs[argname] = argarg
        if "done" in args or "undone" in args:
            kwargs["done"] = self._getDone(
                args.get("done"), args.get("undone")
            )

        self.model.setOptions(glob=glob, **kwargs)
882896
def reload(self):
        
        self._conf = configparser.ConfigParser()
        # Preserve the case of sections and keys.
        self._conf.optionxform = str
        self._conf.read(self.config_file_path)
        if 'general' not in self._conf.keys():
            raise IncompleteConfigurationFile('Missing the general section')
        general = self._replace_data_types(dict(self._conf.items('general')))
        self._conf.remove_section('general')
        plugin = []
        for section in self._conf.sections():
            plugin.append(dict(self._conf.items(section)))
            plugin[-1].update({'name': section})
            plugin[-1] = self._replace_data_types(plugin[-1])
        return (plugin, general)
445388
def _make_renderer(self, at_paths, at_encoding, **kwargs):
        
        for eopt in ("file_encoding", "string_encoding"):
            default = self._roptions.get(eopt, at_encoding.lower())
            self._roptions[eopt] = kwargs.get(eopt, default)

        pkey = "search_dirs"
        paths = kwargs.get(pkey, []) + self._roptions.get(pkey, [])
        if at_paths is not None:
            paths = at_paths + paths
        self._roptions[pkey] = paths

        return pystache.renderer.Renderer(**self._roptions)