Get and set config options from config file
553798
def get_config(self):
        
        if 'rmq_port' in self.config:
            self.rmq_port = int(self.config['rmq_port'])

        if 'rmq_user' in self.config:
            self.rmq_user = self.config['rmq_user']

        if 'rmq_password' in self.config:
            self.rmq_password = self.config['rmq_password']

        if 'rmq_vhost' in self.config:
            self.rmq_vhost = self.config['rmq_vhost']

        if 'rmq_exchange_type' in self.config:
            self.rmq_exchange_type = self.config['rmq_exchange_type']

        if 'rmq_durable' in self.config:
            self.rmq_durable = bool(self.config['rmq_durable'])

        if 'rmq_heartbeat_interval' in self.config:
            self.rmq_heartbeat_interval = int(
                self.config['rmq_heartbeat_interval'])
332078
def _config_options(self):
        """"""
        self._config_sortable(self._sortable)
        self._config_drag_cols(self._drag_cols)
508638
def get_options(self):
        
        super(ScriptBaseWithConfig, self).get_options()

        self.config_dir = os.path.abspath(os.path.expanduser(self.options.config_dir
            or os.environ.get('PYRO_CONFIG_DIR', None)
            or self.CONFIG_DIR_DEFAULT))
        load_config.ConfigLoader(self.config_dir).load(self.OPTIONAL_CFG_FILES + self.options.config_file)
        if self.options.debug:
            config.debug = True

        for key_val in self.options.defines:
            try:
                key, val = key_val.split('=', 1)
            except ValueError, exc:
                raise error.UserError("Bad config override %r (%s)" % (key_val, exc))
            else:
                setattr(config, key, load_config.validate(key, val))
299663
def get_config_set(self, section, option):
		
		values = set()
		for cp, filename, fp in self.layers:
			filename = filename # pylint
			fp = fp # pylint
			if cp.has_option(section, option):
				values.add(cp.get(section, option))
		return values
10088
def __get_global_options(cmd_line_options, conf_file_options=None):
    
    options = {}

    for option in DEFAULT_OPTIONS['global'].keys():
        options[option] = DEFAULT_OPTIONS['global'][option]

        if conf_file_options and option in conf_file_options:
            options[option] = conf_file_options[option]

        if cmd_line_options and option in cmd_line_options:
            options[option] = cmd_line_options[option]

    return options
281004
def config_conf(obj):
    ""
    # If we ever want to add some default options this is where to do that
    cfg = {}
    for name in dir(obj):
        if name in CONFIG_PARSER_CFG: # argument of ConfigParser
            cfg[name] = getattr(obj, name)
    return cfg
181215
private Map<String, String> getOptionsFromConfigFile(String newConfigFile) throws MojoExecutionException {

        this.getLog().debug("Using search path at: " + this.basedir.getAbsolutePath());
        this.resourceManager.addSearchPath(FileResourceLoader.ID, this.basedir.getAbsolutePath());

        try (InputStream configInput = this.resourceManager.getResourceAsInputStream(newConfigFile)) {
            return new ConfigReader().read(configInput);
        } catch (ResourceNotFoundException e) {
            throw new MojoExecutionException("Cannot find config file [" + newConfigFile + "]");
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot read config file [" + newConfigFile + "]", e);
        } catch (SAXException e) {
            throw new MojoExecutionException("Cannot parse config file [" + newConfigFile + "]", e);
        } catch (ConfigReadException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
622625
def parse_config(config_file=None):
    '''
    
    '''
    if config_file is None:
        config_file = _config_file()
    ret = {}
    if _check_config_exists(config_file):
        with salt.utils.files.fopen(config_file) as ifile:
            for line in ifile:
                key, val = salt.utils.stringutils.to_unicode(line).split('=')
                ret[key] = val
        return ret

    return 'Could not find {0} on file system'.format(config_file)
1128325
def parse_config(config_file):
    """"""
    try:
        with open(config_file, 'r') as f:
            return yaml.load(f)
    except IOError:
        print "Configuration file {} not found or not readable.".format(config_file)
        raise
1060362
def parse_config(config, key, options):
        """"""
        conf = {}
        for source, destination, opt_type in options:
            opt_value = _get_opt(config, key, source, opt_type)
            if opt_value is not None:
                _set_opt(conf, destination, opt_value)
        return conf
681797
def initialize_options(cls):
        
        cls.CONFIG_OPTIONS = cls.CFG.get(cls.CONFIG_PATH, return_type=dict)
635101
def process_settings(self, settings):
        """"""
        logging.debug("Using configuration from: %s", settings.name)
        exec(compile(settings.read(), settings.name, 'exec'), globals(), locals())
1356014
def config_to_options(config):
    
    class Options:
        host=config.get('smtp', 'host', raw=True)
        port=config.getint('smtp', 'port')
        to_addr=config.get('mail', 'to_addr', raw=True)
        from_addr=config.get('mail', 'from_addr', raw=True)
        subject=config.get('mail', 'subject', raw=True)
        encoding=config.get('mail', 'encoding', raw=True)
        username=config.get('auth', 'username')
    opts = Options()
    # format
    opts.from_addr % {'host': opts.host, 'prog': 'notify'}
    opts.to_addr % {'host': opts.host, 'prog': 'notify'}
    return opts
988925
def setup_environment_from_config_file():
    

    from os.path import exists

    config_file = get_config_file()

    if not exists(config_file):
        return

    try:
        config = _ConfigParser.SafeConfigParser()
        config.read(config_file)

        __section = "Environment"

        if config.has_section(__section):
            items = config.items(__section)

            for k, v in items:
                try:
                    os.environ[k.upper()] = v
                except Exception as e:
                    print(("WARNING: Error setting environment variable "
                           "'%s = %s' from config file '%s': %s.")
                          % (k, str(v), config_file, str(e)) )
    except Exception as e:
        print("WARNING: Error reading config file '%s': %s." % (config_file, str(e)))
974658
def get_config(filename, *search_dirs, **kwargs):
    """"""
    config = kwargs.get("config_reader_class", configparser.ConfigParser)()

    paths = config_search_paths(filename, *search_dirs)
    successes = config.read(reversed(paths))
    if successes:
        LOG.debug("Read config from %s", str(successes))
        return config, successes

    LOG.warning("Couldn't file any config file matching %s", filename)
    return None, []
661337
def load_config(config_file='~/.stancache.ini'):
    
    if not os.path.exists(config_file):
        logging.warning('Config file does not exist: {}. Using default settings.'.format(config_file))
        return
    ## get user-level config in *.ini format
    config = configparser.ConfigParser()
    config.read(config_file)
    if not config.has_section('main'):
        raise ValueError('Config file {} has no section "main"'.format(config_file))
    for (key, val) in config.items('main'):
        _set_value(key.upper(), val)
    return
497035
def get_config_value_from_file(key, config_path=None, default=None):
    
    config = _get_config_dict_from_file(config_path)
    if key not in config:
        return default
    return config[key]