Returns a configparser.SafeConfigParser instance with configs
    read from the config file. Default location of the config file is
    at ~/.wakatime.cfg.
966057
def parseConfigFile(configFile=None):
    

    # get config file location from ENV
    if not configFile:
        configFile = getConfigFile()

    configs = configparser.ConfigParser(delimiters=('='), strict=False)
    try:
        with open(configFile, 'r', encoding='utf-8') as fh:
            try:
                configs.read_file(fh)
            except configparser.Error:
                print(traceback.format_exc())
                raise SystemExit(CONFIG_FILE_PARSE_ERROR)
    except IOError:
        pass
    return configs
592465
def _setup_parser(self, filename=None):
        
        assert isinstance(filename, str) or filename is None

        # If we are not overriding the config filename
        if not filename:
            filename = MACKUP_CONFIG_FILE

        parser = configparser.SafeConfigParser(allow_no_value=True)
        parser.read(os.path.join(os.path.join(os.environ['HOME'], filename)))

        return parser
449429
def _read_config(cls):
        

        cls._config_parser = configparser.ConfigParser()
        cls._config_parser.read(cls._default_attribute_values_configuration_file_path)
243654
def find_config():
    
    config_locations = [
        '/etc/foremast/foremast.cfg',
        expanduser('~/.foremast/foremast.cfg'),
        './.foremast/foremast.cfg',
    ]
    configurations = ConfigParser()

    cfg_file = configurations.read(config_locations)
    dynamic_config_file = getenv('FOREMAST_CONFIG_FILE', DEFAULT_DYNAMIC_CONFIG_FILE)

    if cfg_file:
        LOG.info('Loading static configuration file.')
    elif exists(dynamic_config_file):
        LOG.info('Loading dynamic configuration file.')
        configurations = load_dynamic_config(config_file=dynamic_config_file)
    else:
        config_locations.append(dynamic_config_file)
        LOG.warning('No configuration found in the following locations:\n%s', '\n'.join(config_locations))
        LOG.warning('Using defaults...')

    return dict(configurations)
238015
def configparser(self):
        
        if self._configparser_adapter is None:
            self._configparser_adapter = ConfigPersistenceAdapter(
                config=self,
                reader_writer=ConfigParserReaderWriter(
                    config_parser_factory=self.settings.configparser_factory,
                ),
            )
        return self._configparser_adapter
188005
def read_config(config_file=CONFIG_FILE_DEFAULT, override_url=None):
    ''' '''
    config = ConfigParser()
    config.read_dict(DEFAULT_SETTINGS)

    try:
        config.readfp(open(config_file))
        logger.debug("Using config file at " + config_file)
    except:
        logger.error(
            "Could not find {0}, running with defaults.".format(config_file))

    if not logger.handlers:
        # Before doing anything else, configure logging
        # Handlers might be already registered in repeated test suite runs
        # In production, this should never happen
        if config.getboolean("Logging", "to_file"):
            handler = logging.FileHandler(config.get("Logging", "file"))
        else:
            handler = logging.StreamHandler()
        handler.setFormatter(logging.Formatter(
            config.get("Logging", "format")))
        logger.addHandler(handler)
    logger.setLevel(config.get("Logging", "level"))

    if override_url:
        config['Server']['url'] = override_url

    return config
1086719
def read_config():
    """"""
    config = configparser.RawConfigParser(allow_no_value=True)
    config.read(get_config_path())
    if not config.has_section('credentials'):
        config.add_section('credentials')
        config.set('credentials', 'key', '')
        config.set('credentials', 'secret', '')
        write_config(config)
    return config
297668
def load_config():
    
    configuration = MyParser()
    configuration.read(_config)

    d = configuration.as_dict()

    if 'jira' not in d:
        raise custom_exceptions.NotConfigured

    # Special handling of the boolean for error reporting
    d['jira']['error_reporting'] = configuration.getboolean('jira', 'error_reporting')

    return d
271700
def _get_file(self, config):
        
        config_file = SafeConfigParser()
        config_file.read([os.path.expanduser('~/.scrapekit.ini')])
        if config_file.has_section('scrapekit'):
            config.update(dict(config_file.items('scrapekit')))
        if config_file.has_section(self.scraper.name):
            config.update(dict(config_file.items(self.scraper.name)))
        return config
701305
def config_read():
    """"""
    config_file = (u"{0}config.ini".format(CONFIG_DIR))
    if not os.path.isfile(config_file):
        config_make(config_file)
    config = configparser.ConfigParser(allow_no_value=True)
    try:
        config.read(config_file, encoding='utf-8')
    except IOError:
        print("Error reading config file: {}".format(config_file))
        sys.exit()
    # De-duplicate provider-list
    providers = config_prov(config)
    # Read credentials for listed providers
    (cred, to_remove) = config_cred(config, providers)
    # remove unsupported and credential-less providers
    for item in to_remove:
        providers.remove(item)
    return cred, providers
1299854
def _read_config(config_location):
    
    global LOGGING_CONFIG
    with open(config_location, "r") as config_loc:
        cfg_file = json.load(config_loc)
        if "logging" in cfg_file:
            log_dict = cfg_file.get("logging")
            with open(os.path.abspath(os.path.join(__file__,
                                                   os.path.pardir,
                                                   'logging_schema.json'))) as schema_file:
                logging_schema = json.load(schema_file)
                jsonschema.validate(log_dict, logging_schema)
                merged = jsonmerge.merge(LOGGING_CONFIG, log_dict)
                LOGGING_CONFIG = merged
24023
def get_config(path):
    
    if configparser is None:
        return None

    # Check for env specific configs first
    if os.path.exists(os.path.join(ROOT, 'config', NAME, path)):
        path = os.path.join(ROOT, 'config', NAME, path)
    else:
        path = os.path.join(ROOT, 'config', path)

    if not os.path.isfile(path):
        return None

    conf = open(path, 'rt').read()
    conf = os.path.expandvars(conf)

    config = configparser.SafeConfigParser()
    if sys.version_info[0] == 2:
        from io import StringIO
        config.readfp(StringIO(unicode(conf)))
    else:
        config.read_string(conf)
    return config
1016322
def _cfgs_to_read(self):
        
        # use these files to extend/overwrite the conf_values.
        # Last red file always overwrites existing values!
        cfg = Config.DEFAULT_CONFIG_FILE_NAME
        filenames = [
            self.default_config_file,
            cfg,  # conf_values in current directory
            os.path.join(os.path.expanduser('~' + os.path.sep), cfg),  # config in user dir
            '.pyemma.cfg',
        ]

        # look for user defined files
        if self.cfg_dir:
            from glob import glob
            filenames.extend(glob(self.cfg_dir + os.path.sep + "*.cfg"))
        return filenames
96362
def parse_config(args):
    
    # Try user config or return default location early
    config_path = path.expanduser(args.config_file)
    if not path.exists(config_path):
        # Complain if they provided non-existant config
        if args.config_file != DEFAULT_JOURNAL_RC:
            print("journal: error: config file '" + args.config_file + "' not found")
            sys.exit()
        else:
            # If no config file, use default journal location
            return DEFAULT_JOURNAL

    # If we get here, assume valid config file
    config = ConfigParser.SafeConfigParser({
        'journal':{'default':'__journal'},
        '__journal':{'location':DEFAULT_JOURNAL}
    })
    config.read(config_path)

    journal_location = config.get(config.get('journal', 'default'), 'location');
    if args.journal:
        journal_location = config.get(args.journal, 'location');
    return journal_location
28411
def get_default_config_parsers() -> List[AnyParser]:
    
    return [SingleFileParserFunction(parser_function=read_config,
                                     streaming_mode=True,
                                     supported_exts={'.cfg', '.ini'},
                                     supported_types={ConfigParser}),
            ]
994272
def read_config(cls, configparser):
        """"""
        config = dict()
        section = cls.__name__
        option = sslcertwarndays
        if configparser.has_option(section, option):
            num = configparser.getint(section, option)
            if num > 0:
                config[option] = num
            else:
                msg = _("invalid value for %s: %d must not be less than %d") % (option, num, 0)
                raise LinkCheckerError(msg)
        else:
            # set the default
            config[option] = 30
        return config
600952
def read_raw_parser_conf(data: str) -> dict:
    
    config = configparser.ConfigParser(allow_no_value=True)
    config.read_string(data)
    try:
        _data: dict = dict(config["commitizen"])
        if "files" in _data:
            files = _data["files"]
            _f = json.loads(files)
            _data.update({"files": _f})

        return _data

    except KeyError:
        return {}