Recursively goes through config structure and builds final Apache configuration

    :param conf: defined config structure
    :param slot: name of section container if needed
181088
def _parse_config(conf, slot=None):
    '''
    
    '''
    ret = cStringIO()
    if isinstance(conf, six.string_types):
        if slot:
            print('{0} {1}'.format(slot, conf), file=ret, end='')
        else:
            print('{0}'.format(conf), file=ret, end='')
    elif isinstance(conf, list):
        is_section = False
        for item in conf:
            if 'this' in item:
                is_section = True
                slot_this = six.text_type(item['this'])
        if is_section:
            print('<{0} {1}>'.format(slot, slot_this), file=ret)
            for item in conf:
                for key, val in item.items():
                    if key != 'this':
                        print(_parse_config(val, six.text_type(key)), file=ret)
            print('</{0}>'.format(slot), file=ret)
        else:
            for value in conf:
                print(_parse_config(value, six.text_type(slot)), file=ret)
    elif isinstance(conf, dict):
        try:
            print('<{0} {1}>'.format(slot, conf['this']), file=ret)
        except KeyError:
            raise SaltException('Apache section container "<{0}>" expects attribute. '
                                'Specify it using key "this".'.format(slot))
        for key, value in six.iteritems(conf):
            if key != 'this':
                if isinstance(value, six.string_types):
                    print('{0} {1}'.format(key, value), file=ret)
                elif isinstance(value, list):
                    print(_parse_config(value, key), file=ret)
                elif isinstance(value, dict):
                    print(_parse_config(value, key), file=ret)
        print('</{0}>'.format(slot), file=ret)

    ret.seek(0)
    return ret.read()
656748
def configure(self, conf={}):
        
        if not conf: return
        if isinstance(conf, Configuration):
            conf = dict(conf.options())
        for key, value in conf.items():
            opt = self.get(key, None)
            if isinstance(opt, Configuration):
                opt.configure(value)
            else:
                setattr(self, key, value)
802927
public static Config buildConfig(TopologyDef topologyDef) {
        // merge contents of `config` into topology config
        Config conf = new Config();
        conf.putAll(topologyDef.getConfig());
        return conf;
    }
738306
def _getConfiguration(self):
        
        configDirectoryPath = os.path.join("application", "config")
        config = Config(configDirectoryPath)
        configData = config.getData()

        # setting application parameters
        reactor.suggestThreadPoolSize(
            int(configData["performance"]["threadPoolSize"])
        )

        return configData
148706
def get_config(self, section=None):
        
        config = self.session.config
        section = self.config_section() if section is None else section
        try:
            return config[section]
        except KeyError:
            config.add_section(section)
            return config[section]
383147
def _set_up_pool_config(self):
    '''
    
    '''
    self._max_conns = self.settings_dict['OPTIONS'].get('MAX_CONNS', pool_config_defaults['MAX_CONNS'])
    self._min_conns = self.settings_dict['OPTIONS'].get('MIN_CONNS', self._max_conns)
                
    self._test_on_borrow = self.settings_dict["OPTIONS"].get('TEST_ON_BORROW', 
                                                             pool_config_defaults['TEST_ON_BORROW'])
    if self._test_on_borrow:
        self._test_on_borrow_query = self.settings_dict["OPTIONS"].get('TEST_ON_BORROW_QUERY', 
                                                                       pool_config_defaults['TEST_ON_BORROW_QUERY'])
    else: 
        self._test_on_borrow_query = None
526714
def _build_config(self):
        '''
        
        '''
        if not self.config_dict:
            if not self.config_path:
                # No custom config path requested
                # Read the native config files
                self.config_path = os.path.join(
                    os.path.dirname(os.path.realpath(__file__)),
                    'config'
                )
            log.info('Reading the configuration from %s', self.config_path)
            self.config_dict = self._load_config(self.config_path)
        if not self.extension_config_dict and\
           self.extension_config_path and\
           os.path.normpath(self.extension_config_path) != os.path.normpath(self.config_path):  # same path?
            # When extension config is not sent as dict
            # But `extension_config_path` is specified
            log.info('Reading extension configuration from %s', self.extension_config_path)
            self.extension_config_dict = self._load_config(self.extension_config_path)
        if self.extension_config_dict:
            napalm_logs.utils.dictupdate(self.config_dict, self.extension_config_dict)
1029002
def build(self, config=None):
        

        # If we are passed a config object, then rebuild that object instead of building a new lintconfig object from
        # scratch
        if not config:
            config = LintConfig()

        config._config_path = self._config_path

        # Set general options first as this might change the behavior or validity of the other options
        general_section = self._config_blueprint.get('general')
        if general_section:
            for option_name, option_value in general_section.items():
                config.set_general_option(option_name, option_value)

        for section_name, section_dict in self._config_blueprint.items():
            for option_name, option_value in section_dict.items():
                # Skip over the general section, as we've already done that above
                if section_name != "general":
                    config.set_rule_option(section_name, option_name, option_value)

        return config
807252
def pools_from_config
      configs = {}

      pools_config_contents.each do |section|
        # Hash section name and content
        d = Digest::SHA2.new(256)
        hash = d.reset.update(section[0]).update(section[1].to_s).to_s

        configs[hash] = {
          name: section[0],
          config: section[1]
        }
      end
      configs
    end
1157532
def write(self, config_dir=None, config_name=None, codec=None):
        
        # get name of config directory
        if not config_dir:
            config_dir = self._meta_config_dir
            if not config_dir:
                raise IOError("config_dir not set")

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        if codec:
            codec = munge.get_codec(codec)()
        else:
            codec = munge.get_codec(self._defaults['codec'])()

        config_dir = os.path.expanduser(config_dir)
        if not os.path.exists(config_dir):
            os.mkdir(config_dir)

        codec.dumpu(self.data, os.path.join(config_dir, 'config.' + codec.extension))
1104681
private Map<String, Object> _processConf(Map<String, ?> conf) {
        Map<String, Object> m = new HashMap<String, Object>(conf.size());
        for (String s : conf.keySet()) {
            Object o = conf.get(s);
            if (s.startsWith("rythm.")) s = s.replaceFirst("rythm\\.", "");
            m.put(s, o);
        }
        return m;
    }
75941
def _get_config():
    '''
    
    '''
    cfg = os.path.expanduser('~/.dockercfg')
    try:
        fic = open(cfg)
        try:
            config = json.loads(fic.read())
        finally:
            fic.close()
    except Exception:
        config = {'rootPath': '/dev/null'}
    if not 'Configs' in config:
        config['Configs'] = {}
    return config
1071195
def __load_config(self):
        '''
        '''

        # top_path is where .scuba.yml is found, and becomes the top of our bind mount.
        # top_rel is the relative path from top_path to the current working directory,
        # and is where we'll set the working directory in the container (relative to
        # the bind mount point).
        try:
            top_path, top_rel = find_config()
            self.config = load_config(os.path.join(top_path, SCUBA_YML))
        except ConfigNotFoundError as cfgerr:
            # SCUBA_YML can be missing if --image was given.
            # In this case, we assume a default config
            if not self.image_override:
                raise ScubaError(str(cfgerr))
            top_path, top_rel = os.getcwd(), ''
            self.config = ScubaConfig(image=None)
        except ConfigError as cfgerr:
            raise ScubaError(str(cfgerr))

        # Mount scuba root directory at the same path in the container...
        self.add_volume(top_path, top_path)

        # ...and set the working dir relative to it
        self.set_workdir(os.path.join(top_path, top_rel))

        self.add_env('SCUBA_ROOT', top_path)
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)
1170859
def run_configurations(callback, sections_reader):
    """"""
    base = dict(OPTIONS)
    sections = sections_reader()
    if sections is None:
        logger.info("Configuration not found in .ini files. "
                    "Running with default settings")
        recompile()
    elif sections == []:
        logger.info("Configuration does not match current runtime. "
                    "Exiting")
    results = []
    for section, options in sections:
        OPTIONS.clear()
        OPTIONS.update(base)
        OPTIONS.update(options)
        logger.debug("Running configuration from section \"%s\". OPTIONS: %r",
                     section, OPTIONS)
        results.append(callback())
    return results
200053
def build_network_settings(**settings):
    '''
    
    '''
    # Read current configuration and store default values
    current_network_settings = _parse_rh_config(_RH_NETWORK_FILE)

    # Build settings
    opts = _parse_network_settings(settings, current_network_settings)
    try:
        template = JINJA.get_template('network.jinja')
    except jinja2.exceptions.TemplateNotFound:
        log.error('Could not load template network.jinja')
        return ''
    network = template.render(opts)

    if settings['test']:
        return _read_temp(network)

    # Write settings
    _write_file_network(network, _RH_NETWORK_FILE)

    return _read_file(_RH_NETWORK_FILE)
1116714
def _config_section(config, section):
    """"""
    path = os.path.join(config.get('config_path'), config.get('config_file'))
    conf = _config_ini(path)
    return conf.get(section)