py3从单个配置文件中,获取设置
    :param default_section:
    :param ini:
    :return:
343877
def _load_from_ini_py3(ini, default_section=_DEFAULT_SECTION):
    

    cf = configparser.ConfigParser(default_section=default_section)
    cf.read(ini, encoding="UTF8")
    settings = OrderedDict()
    for item in cf.items():
        logger.debug(item[0])
        settings[item[0].upper()] = OrderedDict(item[1])

    logger.debug(settings)
    for k, v in cf.items(default_section):
    # for k, v in cf.items():
        logger.debug(v)
        logger.debug(settings)
        logger.debug(settings.get(k))
        settings[k.upper()] = convert_value(v)
        logger.debug(settings)
        if k.lower() in settings:
            del settings[k.lower()]

    if default_section in settings:
        del settings[default_section]

    logger.debug(settings)
    return settings
756379
def get(self, section, option, default=NoDefault):
        
        section = self._check_section_option(section, option)

        if not self.has_section(section):
            if default is NoDefault:
                raise cp.NoSectionError(section)
            else:
                self.add_section(section)
        
        if not self.has_option(section, option):
            if default is NoDefault:
                raise cp.NoOptionError(option, section)
            else:
                self.set(section, option, default)
                return default
            
        value = cp.ConfigParser.get(self, section, option, raw=self.raw)
        # Use type of default_value to parse value correctly
        default_value = self.get_default(section, option)
        if isinstance(default_value, bool):
            value = ast.literal_eval(value)
        elif isinstance(default_value, float):
            value = float(value)
        elif isinstance(default_value, int):
            value = int(value)
        elif is_text_string(default_value):
            if PY2:
                try:
                    value = value.decode('utf-8')
                    try:
                        # Some str config values expect to be eval after decoding
                        new_value = ast.literal_eval(value)
                        if is_text_string(new_value):
                            value = new_value
                    except (SyntaxError, ValueError):
                        pass
                except (UnicodeEncodeError, UnicodeDecodeError):
                    pass
        else:
            try:
                # lists, tuples, ...
                value = ast.literal_eval(value)
            except (SyntaxError, ValueError):
                pass
        return value
374707
async function defaultSection(ctx, next) {
  const sections = await _getContentSections();
  ctx.state.section = sections[0] || await Section.findGeneral();
  await next();
}
404999
def _set_from_ini(self, namespace, ini_file):
        
        # Isolate global values
        global_vars = dict((key, val)
            for key, val in namespace.items()
            if isinstance(val, basestring)
        )

        # Copy all sections
        for section in ini_file.sections():
            # Get values set so far
            if section == "GLOBAL":
                raw_vars = global_vars
            else:
                raw_vars = namespace.setdefault(section.lower(), {})

            # Override with values set in this INI file
            raw_vars.update(dict(ini_file.items(section, raw=True)))

            # Interpolate and validate all values
            if section == "FORMATS":
                self._interpolation_escape(raw_vars)
            raw_vars.update(dict(
                (key, validate(key, val))
                for key, val in ini_file.items(section, vars=raw_vars)
            ))

        # Update global values
        namespace.update(global_vars)
483272
def get_config(ini_path=None, rootdir=None):
    
    config = Namespace()
    config.default_section = 'pylama'

    if not ini_path:
        path = get_default_config_file(rootdir)
        if path:
            config.read(path)
    else:
        config.read(ini_path)

    return config
254954
def get_main_section(self, linesep=None):
        

        linesep = linesep or self.linesep or os.linesep

        stream = BytesIO()
        ManifestSection.store(self, stream, linesep)
        return stream.getvalue()
930620
def restore_default(self, index):
        
        spec = self.get_configspec_str(index)
        if spec is None or isinstance(spec, Section):
            return
        try:
            default = self._vld.get_default_value(spec)
            defaultstr = self._val_to_str(default)
            self.setData(index, defaultstr)
        except KeyError:
            raise ConfigError("Missing Default Value in spec: \"%s\"" % spec)
715273
def settings(self):
        
        settings_file = os.path.join(os.getcwd(), 'settings', self.module.lower() + '.ini')

        # Loads the settings file once.
        if (not hasattr(self, '_settings') or self._settings is None) and os.path.isfile(settings_file):
            config = ConfigParser.ConfigParser()
            config.read(settings_file)

            settings = dict(config._sections)
            for key in settings:
                settings[key] = dict(config.defaults(), **settings[key])
                settings[key].pop('__name__', None)

            self._settings = SettingsDict(self, settings.get(self.name, {}))

        elif not hasattr(self, '_settings'):
            self._settings = SettingsDict(self, {})

        return self._settings
221177
def _prt_py_section(self, prt, section_name, ntgos):
        """"""
        prt.write('    ("{SEC}", [ # {N} GO-headers\n'.format(SEC=section_name, N=len(ntgos)))
        self.prt_ntgos(prt, ntgos)
        prt.write("    ]),\n")
392152
function parseAwsIni(ini) {
  var section,
      out = Object.create(null),
      re = /^\[([^\]]+)\]\s*$|^([a-z_]+)\s*=\s*(.+?)\s*$/,
      lines = ini.split(/\r?\n/)

  lines.forEach(function(line) {
    var match = line.match(re)
    if (!match) return
    if (match[1]) {
      section = match[1]
      if (out[section] == null) out[section] = Object.create(null)
    } else if (section) {
      out[section][match[2]] = match[3]
    }
  })

  return out
}
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]
101474
def read(self, module_name):
        
        self.parser.read("{}/{}.ini".format(self.path, module_name.split(".")[-1]))
1220875
def default_config_file(self):
        
        import os.path as p
        import pyemma
        return p.join(pyemma.__path__[0], Config.DEFAULT_CONFIG_FILE_NAME)
96104
def _prt_py_sections(self, sec2d_nt, prt=sys.stdout, doc=None):
        """"""
        if doc is None:
            doc = 'Sections variable'
        prt.write('"""{DOC}"""\n\n'.format(DOC=doc))
        self.prt_ver(prt)
        prt.write("# pylint: disable=line-too-long\n")
        strcnt = self.get_summary_str(sec2d_nt)
        prt.write("SECTIONS = [ # {CNTS}\n".format(CNTS=strcnt))
        prt.write('    # ("New Section", [\n')
        prt.write('    # ]),\n')
        for section_name, nthdrgos in sec2d_nt:
            self._prt_py_section(prt, section_name, nthdrgos)
        prt.write("]\n")
743747
def generate_configfile(cfg_file,defaults=defaults):
    
    # Create a directory if needed and write an empty file
    _mkdir_for_config(cfg_file=cfg_file)
    with open(cfg_file, 'w') as f:
        f.write('')
    for section in defaults.keys():
        set_option(section, cfg_file=cfg_file, **defaults[section])
104282
def add_section(self, section_name):
        
        if section_name == "DEFAULT":
            raise Exception("'DEFAULT' is reserved section name.")

        if section_name in self._sections:
            raise Exception(
                "Error! %s is already one of the sections" % section_name)
        else:
            self._sections[section_name] = Section(section_name)
632355
def section(request):
    
    # If SECTIONS setting is not specified, don't do anything.
    try:
        sections = settings.SECTIONS
    except AttributeError:
        return {}

    # Default return is first section.
    section = sections[0]['name']

    try:
        pattern_name = resolve_to_name(request.path_info)
    except Resolver404:
        pattern_name = None

    if pattern_name:
        for option in settings.SECTIONS:
            if pattern_name in option['matching_pattern_names']:
                section = option['name']

    return {'section': section}