Very simple config values parser.
483209
def _parse(string):
    
    if not isinstance(string, str):
        raise ValueError('Config value "{0}" expected to be string.'
                         .format(string))
    if string in ['true', 'True']:
        return True
    elif string in ['false', 'False']:
        return False
    elif string in ['float64', 'float32', 'float16',
                    'int64', 'int32', 'int16']:
        return getattr(np, string)
    else:
        try:
            return int(string)
        except ValueError:
            pass
        try:
            return float(string)
        except ValueError:
            return string
62821
def to_parser(*args, &block)
      parser = ConfigParser.new(*args, &block)
      traverse do |nesting, config|
        next if config[:hidden] == true || nesting.any? {|nest| nest[:hidden] == true }
        
        nest_keys   = nesting.collect {|nest| nest.key }
        long, short = nesting.collect {|nest| nest.name }.push(config.name).join(':'), nil
        long, short = short, long if long.length == 1
        
        guess_attrs = {
          :long => long,
          :short => short
        }
        
        config_attrs = {
          :key       => config.key, 
          :nest_keys => nest_keys,
          :default   => config.default,
          :callback  => lambda {|value| config.type.cast(value) }
        }
        
        attrs = guess_attrs.merge(config.metadata).merge(config_attrs)
        parser.on(attrs)
      end
      
      parser.sort_opts!
      parser
    end
1044278
protected void extractConfigValues(Map<String, Object> yaml, List<ConfigMetadataNode> configs) {
		for (final ConfigMetadataNode config : configs) {
			Configs.defineConfig(yaml, config, this.injector);
		}
	}
257035
def parse_val(cfg,section,option):
    """"""
    vals = parse_vals(cfg,section,option)
    if len(vals)==0:
        return ''
    else:
        assert len(vals)==1, (section, option, vals, type(vals))
    return vals[0]
1181062
def _parser_options():
    """"""
    #We have two options: get some of the details from the config file,
    import argparse
    from acorn import base
    pdescr = "ACORN setup and custom configuration"
    parser = argparse.ArgumentParser(parents=[base.bparser], description=pdescr)
    for arg, options in script_options.items():
        parser.add_argument(arg, **options)
        
    args = base.exhandler(examples, parser)
    if args is None:
        return

    return args
522265
def parser(self):
        """"""
        parser = configparser.RawConfigParser()
        for filename in self.available_files:
            friendly_name = format_path(filename)
            logger.debug("Loading configuration file: %s", friendly_name)
            loaded_files = parser.read(filename)
            if len(loaded_files) == 0:
                self.report_issue("Failed to load configuration file! (%s)", friendly_name)
        logger.debug("Loaded %s from %s.",
                     pluralize(len(parser.sections()), "section"),
                     pluralize(len(self.available_files), "configuration file"))
        return parser
1172488
def parse_vals(cfg,section,option):
    """"""
    try:
        vals = cfg.get(section,option)
    except ConfigParser.NoSectionError as err:
        if section != 'DEFAULT':
            vals = cfg.get('DEFAULT',option)
        else:
            raise err
    vals = vals.split('#')[0]
    vals = vals.strip()
    vals = vals.split(',')
    vals = [v.strip() for v in vals]
    vals = [v for v in vals if len(v)]
    return vals
1266513
def __parse_config(self):
        

        if self.should_parse_config and (self.args.config or self.config_file):
            self.config = ConfigParser.SafeConfigParser()
            self.config.read(self.args.config or self.config_file)
231392
function parseConfig (configpath) {
  if (program.input) {
    configpath = {
      input: program.input,
      output: program.output || '.'
    };
  }

  return configpath;
}
78626
def parse_options(settings):
    ''''''
    optlist, args = getopt(sys.argv, 'x', [])
    settings['configfile'] = args[1]
    return settings
407817
def normalize_input_values(config, devices):
    '''
    
    '''
    if isinstance(config, list):
        if (config and
                'key' in config[0] and
                'value' in config[0]):
            config = {d['key']: d['value'] for d in config}
        else:
            config = {}

    if isinstance(config, six.string_types):
        raise SaltInvocationError(
            "config can't be a string, validate your YAML input."
        )

    if isinstance(devices, six.string_types):
        raise SaltInvocationError(
            "devices can't be a string, validate your YAML input."
        )

    # Golangs wants strings
    if config is not None:
        for k, v in six.iteritems(config):
            config[k] = six.text_type(v)
    if devices is not None:
        for dn in devices:
            for k, v in six.iteritems(devices[dn]):
                devices[dn][k] = v

    return (config, devices,)
381412
def parse_config(args=sys.argv):
    
    parser = argparse.ArgumentParser(
        description='Read in the config file')
    parser.add_argument(
        'config_file',
        help='Configuration file.',
        metavar='FILE', type=extant_file)
    return parser.parse_args(args[1:])
337405
def parse_config(file_path):
    """"""
    config_parser = configparser.ConfigParser()
    config_parser.read(file_path)
    plugin_config = {}
    options = config_parser.options(CONFIG_OPTION)
    for option in options:
        try:
            plugin_config[option] = config_parser.get(CONFIG_OPTION, option)
            if plugin_config[option] == -1:
                print("skip: %s" % option)
        except Exception as e:
            print("exception on %s!" % option)
            print(e.message)
            plugin_config[option] = None
    return plugin_config
1112799
def parser(self):
        ""
        if not hasattr(self, '_conf'):
            cfile = self.config_file
            logger.debug('loading config %s' % cfile)
            if os.path.isfile(cfile):
                conf = self._create_config_parser()
                conf.read(os.path.expanduser(cfile))
            else:
                if self.robust:
                    logger.debug('no default config file %s--skipping' % cfile)
                else:
                    raise IOError('no such file: %s' % cfile)
                conf = None
            self._conf = conf
        return self._conf
223330
def parse_config(self):
        """"""
        config = config_get()
        mysql_config = {}
        if 'max-connections' in config:
            mysql_config['max_connections'] = config['max-connections']

        if 'wait-timeout' in config:
            mysql_config['wait_timeout'] = config['wait-timeout']

        if 'innodb-flush-log-at-trx-commit' in config:
            mysql_config['innodb_flush_log_at_trx_commit'] = \
                config['innodb-flush-log-at-trx-commit']
        elif 'tuning-level' in config:
            mysql_config['innodb_flush_log_at_trx_commit'] = \
                self.INNODB_FLUSH_CONFIG_VALUES.get(config['tuning-level'], 1)

        if ('innodb-change-buffering' in config and
                config['innodb-change-buffering'] in self.INNODB_VALID_BUFFERING_VALUES):
            mysql_config['innodb_change_buffering'] = config['innodb-change-buffering']

        if 'innodb-io-capacity' in config:
            mysql_config['innodb_io_capacity'] = config['innodb-io-capacity']

        # Set a sane default key_buffer size
        mysql_config['key_buffer'] = self.human_to_bytes('32M')
        total_memory = self.human_to_bytes(self.get_mem_total())

        dataset_bytes = config.get('dataset-size', None)
        innodb_buffer_pool_size = config.get('innodb-buffer-pool-size', None)

        if innodb_buffer_pool_size:
            innodb_buffer_pool_size = self.human_to_bytes(
                innodb_buffer_pool_size)
        elif dataset_bytes:
            log("Option 'dataset-size' has been deprecated, please use"
                "innodb_buffer_pool_size option instead", level="WARN")
            innodb_buffer_pool_size = self.human_to_bytes(
                dataset_bytes)
        else:
            # NOTE(jamespage): pick the smallest of 50% of RAM or 512MB
            #                  to ensure that deployments in containers
            #                  without constraints don't try to consume
            #                  silly amounts of memory.
            innodb_buffer_pool_size = min(
                int(total_memory * self.DEFAULT_INNODB_BUFFER_FACTOR),
                self.DEFAULT_INNODB_BUFFER_SIZE_MAX
            )

        if innodb_buffer_pool_size > total_memory:
            log("innodb_buffer_pool_size; {} is greater than system available memory:{}".format(
                innodb_buffer_pool_size,
                total_memory), level='WARN')

        mysql_config['innodb_buffer_pool_size'] = innodb_buffer_pool_size
        return mysql_config
989058
def config_(name: str, local: bool, package: str, section: str,
            key: Optional[str]):
    """"""
    cfg = config.read_configs(package, name, local=local)
    if key:
        with suppress(NoOptionError, NoSectionError):
            echo(cfg.get(section, key))
    else:
        with suppress(NoSectionError):
            for opt in cfg.options(section):
                colourise.pinfo(opt)
                echo('    {}'.format(cfg.get(section, opt)))
1068631
def parse_config(self):
        
        tree = ElementTree.parse(self.file_xml)
        root = tree.getroot()
        for server in root.findall('server'):
            destination = server.text
            name = server.get("name")
            self.discover_remote(destination, name)