Create a default configuration object, with all parameters filled
4490
def create_default_config():
    
    config = configparser.RawConfigParser()
    config.add_section('global')
    config.set('global', 'env_source_rc', False)
    config.add_section('shell')
    config.set('shell', 'bash', "true")
    config.set('shell', 'zsh', "true")
    config.set('shell', 'gui', "true")
    return config
838203
public function create_config()
    {
        $config = array();

        foreach ($this->config as $prop => $default) {
            $is_default = !isset($_POST["_$prop"]);
            $value      = !$is_default || $this->bool_config_props[$prop] ? $_POST["_$prop"] : $default;

            // always disable installer
            if ($prop == 'enable_installer') {
                $value = false;
            }

            // reset useragent to default (keeps version up-to-date)
            if ($prop == 'useragent' && stripos($value, 'Roundcube Webmail/') !== false) {
                $value = $this->defaults[$prop];
            }

            // generate new encryption key, never use the default value
            if ($prop == 'des_key' && $value == $this->defaults[$prop]) {
                $value = rcube_utils::random_bytes(24);
            }

            // convert some form data
            if ($prop == 'debug_level' && !$is_default) {
                if (is_array($value)) {
                    $val = 0;
                    foreach ($value as $dbgval) {
                        $val += intval($dbgval);
                    }
                    $value = $val;
                }
            }
            else if ($prop == 'db_dsnw' && !empty($_POST['_dbtype'])) {
                if ($_POST['_dbtype'] == 'sqlite') {
                    $value = sprintf('%s://%s?mode=0646', $_POST['_dbtype'],
                        $_POST['_dbname']{0} == '/' ? '/' . $_POST['_dbname'] : $_POST['_dbname']);
                }
                else if ($_POST['_dbtype']) {
                    $value = sprintf('%s://%s:%s@%s/%s', $_POST['_dbtype'],
                        rawurlencode($_POST['_dbuser']), rawurlencode($_POST['_dbpass']), $_POST['_dbhost'], $_POST['_dbname']);
                }
            }
            else if ($prop == 'smtp_auth_type' && $value == '0') {
                $value = '';
            }
            else if ($prop == 'default_host' && is_array($value)) {
                $value = self::_clean_array($value);
                if (count($value) <= 1) {
                    $value = $value[0];
                }
            }
            else if ($prop == 'mail_pagesize' || $prop == 'addressbook_pagesize') {
                $value = max(2, intval($value));
            }
            else if ($prop == 'smtp_user' && !empty($_POST['_smtp_user_u'])) {
                $value = '%u';
            }
            else if ($prop == 'smtp_pass' && !empty($_POST['_smtp_user_u'])) {
                $value = '%p';
            }
            else if (is_bool($default)) {
                $value = (bool) $value;
            }
            else if (is_numeric($value)) {
                $value = intval($value);
            }
            else if ($prop == 'plugins' && !empty($_POST['submit'])) {
                $value = array();
                foreach (array_keys($_POST) as $key) {
                    if (preg_match('/^_plugins_*/', $key)) {
                        array_push($value, $_POST[$key]);
                    }
                }
            }

            // skip this property
            if ($value == $this->defaults[$prop]
                && (!in_array($prop, $this->local_config)
                    || in_array($prop, array_merge($this->obsolete_config, array_keys($this->replaced_config)))
                    || preg_match('/^db_(table|sequence)_/', $prop)
                )
            ) {
                continue;
            }

            // save change
            $this->config[$prop] = $value;
            $config[$prop]       = $value;
        }

        $out = "<?php\n\n";
        $out .= "/* Local configuration for Roundcube Webmail */\n\n";

        foreach ($config as $prop => $value) {
            // copy option descriptions from existing config or defaults.inc.php
            $out .= $this->comments[$prop];
            $out .= "\$config['$prop'] = " . self::_dump_var($value, $prop) . ";\n\n";
        }

        return $out;
    }
118253
def _init_config(self):
        
        options = self.parser.parse_args()
        if options.config is None and options.input is None:
            self.parser.print_help()
            sys.exit(2)

        if options.config is not None:
            configFactory = ConfigFactory()
            config = configFactory.load_from_file(options.config)
        else:
            config = ConfigObject()

        if options.input is not None:
            config["input"]["locations"] = [str(x) for x in options.input]
        if options.arguments is not None:
            config["input"]["arguments"] = dict((x.partition("=")[0], x.partition("=")[2]) for x in options.arguments)

        if options.output is not None:
            config["output"]["location"] = options.output

        if options.no_validate is not None:
            config["input"]["validate"] = not options.no_validate

        if options.dry_run is not None:
            self.dry_run = options.dry_run
        if options.watch is not None:
            self.watch = options.watch
        if options.traceback is not None:
            self.traceback = options.traceback

        if options.quiet is not None:
            self.logger.setLevel(logging.WARNING)
        if options.silence is not None:
            logging.disable(logging.CRITICAL)

        configService = ConfigService()
        configService.validate(config)
        self.config = config
715513
def _generate_configs_from_default(self, overrides=None):
        # type: (Dict[str, int]) -> Dict[str, int]
        
        config = DEFAULT_CONFIG.copy()
        if not overrides:
            overrides = {}
        for k, v in overrides.items():
            config[k] = v
        return config
111099
def _prepare_defaults(self):
		""""""
		
		for name, field in self.__fields__.items():
			if field.assign:
				getattr(self, name)
1051701
def main(self, configuration):
    
    _custom_func_arguments = {"conf"}
    filename = os.path.basename(os.path.abspath(sys.argv[0]))

    default_arg_list = [item for item in configuration.get("default") if len(item.strip()) != 0]
    if len(default_arg_list) == 0:
      sys.stdout.write(self.generate_help(filename=filename))
      return

    command_name = default_arg_list.pop(0)
    if command_name not in self._modules.keys():
      sys.stdout.write(self.generate_help(filename=filename))
      return

    command = self._modules[command_name]
    entry_point = command["entry_point"]
    class_path = command["classpath"]
    metainfo = command["metainfo"]
    """:type metainfo ModuleMetaInfo"""

    try:
      args = metainfo.parse_default_arguments(default_arg_list)
      args.update(metainfo.parse_arguments(configuration))

      f_args = entry_point.__code__.co_varnames[:entry_point.__code__.co_argcount]

      if len(f_args) - len(set(f_args) & _custom_func_arguments) != len(set(args.keys()) & set(f_args)):
        raise ArgumentException("Function \"{}\" from module {} doesn't implement all arguments in the signature".format(
          entry_point.__name__, class_path
        ))

      if "conf" in f_args:
        args["conf"] = configuration

      entry_point(**args)
    except ArgumentException as e:
      sys.stdout.write("Application arguments exception: {}\n".format(str(e)))
      return
89282
def set_default(self):
        """"""
        try:
            os.makedirs(os.path.dirname(self._configfile))
        except:
            pass

        self._config = configparser.RawConfigParser()
        self._config.add_section('Settings')

        for key, val in self.DEFAULTS.items():
            self._config.set('Settings', key, val)

        with open(self._configfile, 'w') as f:
            self._config.write(f)
1349522
function (config) {
                if (typeof config !== 'object') {
                    throw new Error('You must provide a valid configuration object to the config setter.');
                }
                // combine config with default
                var mergedConfig = Object.assign({}, config);
                // add config to map
                this._config = new Map(Object.entries(mergedConfig));
            }
603327
def from_config(config):
        
        result = Parameters()
        
        if config == None or len(config) == 0:
            return result
        
        for (key, value) in config.items():
            result.put(key, value)
        
        return result
706950
def derive_configuration(cls):
        
        base_params = cls.base.__parameters__
        if hasattr(cls.type, '__args__'):
            # typing as of commit abefbe4
            tvars = {p: p for p in base_params}
            types = {}
            for t in iter_generic_bases(cls.type):
                if t is cls.base:
                    type_vars = tuple(tvars[p] for p in base_params)
                    parameters = (types.get(tvar, tvar) for tvar in type_vars)
                    break
                if t.__args__:
                    for arg, tvar in zip(t.__args__, t.__origin__.__parameters__):
                        if isinstance(arg, typing.TypeVar):
                            tvars[tvar] = tvars.get(arg, arg)
                        else:
                            types[tvar] = arg
        else:
            # typing 3.5.0
            tvars = [None] * len(base_params)
            for t in iter_generic_bases(cls.type):
                for i, p in enumerate(t.__parameters__):
                    if tvars[i] is None and isinstance(p, typing.TypeVar):
                        tvars[i] = p
                if all(tvars):
                    type_vars = tvars
                    parameters = cls.type.__parameters__
                    break
        cls.type_vars = type_vars
        cls.parameters = tuple(normalize_type(p, 1) for p in parameters)
751177
def build_configuration_parameters(app):
    """"""
    env = Environment(loader=FileSystemLoader("{0}/_data_templates".format(BASEPATH)))
    template_file = env.get_template("configuration-parameters.j2")
    data = {}
    data["schema"] = Config.schema()
    rendered_template = template_file.render(**data)
    output_dir = "{0}/configuration/generated".format(BASEPATH)
    with open("{}/parameters.rst".format(output_dir), "w") as f:
        f.write(rendered_template)
96610
def _set_defaults(self, namespace, optional_cfg_files):
        
        # Add current configuration directory
        namespace["config_dir"] = self.config_dir

        # Load defaults
        for idx, cfg_file in enumerate([self.CONFIG_INI] + optional_cfg_files):
            if any(i in cfg_file for i in set('/' + os.sep)):
                continue # skip any non-plain filenames

            try:
                defaults = pymagic.resource_string("pyrocore", "data/config/" + cfg_file) #@UndefinedVariable
            except IOError as exc:
                if idx and exc.errno == errno.ENOENT:
                    continue
                raise

            ini_file = ConfigParser.SafeConfigParser()
            ini_file.optionxform = str # case-sensitive option names
            ini_file.readfp(StringIO.StringIO(defaults), "<defaults>")
            self._set_from_ini(namespace, ini_file)
1289921
def configure(defaults, metadata, loader):
    
    config = Configuration(defaults)
    config.merge(loader(metadata))
    validate(defaults, metadata, config)
    return config
1011760
def load_config(self, config_source, parameters_source):
        """"""
        with open(config_source) as config_source:
            config_raw = config_source.read()

            parameters = {}
            """Parameteres from file"""
            if os.path.isfile(parameters_source):
                params = self.load_parameters(parameters_source)
                if params is not None:
                    parameters.update(params)

            """Overwrite parameteres with the environment variables"""
            env_params = {}
            env_params.update(os.environ)
            for k, v in env_params.items():
                if is_string(v):
                    env_params[k] = "'" + v + "'"

            parameters.update(env_params)

            """Replace the parameters"""
            final_configuration = config_raw.format(**parameters)
            final_configuration = yaml.safe_load(final_configuration)
            return final_configuration if final_configuration is not None else {}
342211
def __init_configrs(self, rs_cfg):
        """"""
        # Use 'rs_id' to set the id for consistency, but need to rename
        # to 'id' to use with ReplicaSets.create()
        rs_cfg['id'] = rs_cfg.pop('rs_id', None)
        for member in rs_cfg.setdefault('members', [{}]):
            member['procParams'] = self._strip_auth(
                member.get('procParams', {}))
            member['procParams']['configsvr'] = True
            if self.enable_ipv6:
                common.enable_ipv6_single(member['procParams'])
        rs_cfg['sslParams'] = self.sslParams
        self._configsvrs.append(ReplicaSets().create(rs_cfg))
934533
def update_config(config_new, config_default):

    '''
    
    '''
    if any([isinstance(v, dict) for v in list(config_new.values())]):
        for k,v in list(config_new.items()):
            if isinstance(v,dict) and k in config_default:
                update_config(config_new[k],config_default[k])
            else:
                config_default[k] = v
    else:
        config_default.update(config_new)
    return config_default
996658
def config(config, skip_defaults):
    

    configurator = ClickConfigurator(
        vodka.plugin,
        skip_defaults=skip_defaults
    )

    configurator.configure(vodka.config.instance, vodka.config.InstanceHandler)

    try:
        dst = munge_config.parse_url(config)
    except ValueError:
        config = os.path.join(config, "config.yaml")
        dst = munge_config.parse_url(config)

    config_dir = os.path.dirname(config)
    if not os.path.exists(config_dir) and config_dir:
        os.makedirs(config_dir)

    dst.cls().dumpu(vodka.config.instance, dst.url.path)

    if configurator.action_required:
        click.echo("")
        click.echo("not all required values could be set by this script, please manually edit the config and set the following values")
        click.echo("")
        for item in configurator.action_required:
            click.echo("- %s" % item)
        click.echo("")

    click.echo("Config written to %s" % dst.url.path)