Parses the specified configuration file and stores the values. Raises
        an InvalidConfigurationFile exception if the file is not well-formed.
513841
def read_config(self, config_file):
        
        cfg = ConfigParser.SafeConfigParser()
        try:
            cfg.read(config_file)
        except ConfigParser.MissingSectionHeaderError as e:
            # The file exists, but doesn't have the correct format.
            raise exc.InvalidConfigurationFile(e)

        def safe_get(section, option, default=None):
            try:
                return cfg.get(section, option)
            except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
                return default

        # A common mistake is including credentials in the config file. If any
        # values are found, issue a warning so that the developer can correct
        # this problem.
        creds_found = False
        for section in cfg.sections():
            if section == "settings":
                section_name = "default"
                self._default_set = True
            else:
                section_name = section
            # Check for included credentials
            for key in ("username", "password", "api_key"):
                if creds_found:
                    break
                if safe_get(section, key):
                    creds_found = True
            dct = self._settings[section_name] = {}
            dct["region"] = safe_get(section, "region", default_region)
            ityp = safe_get(section, "identity_type")
            if ityp:
                dct["identity_type"] = _id_type(ityp)
                dct["identity_class"] = _import_identity(ityp)
            # Handle both the old and new names for this setting.
            debug = safe_get(section, "debug")
            if debug is None:
                debug = safe_get(section, "http_debug", "False")
            dct["http_debug"] = debug == "True"
            verify_ssl = safe_get(section, "verify_ssl", "True")
            dct["verify_ssl"] = verify_ssl == "True"
            dct["keyring_username"] = safe_get(section, "keyring_username")
            dct["encoding"] = safe_get(section, "encoding", default_encoding)
            dct["auth_endpoint"] = safe_get(section, "auth_endpoint")
            dct["tenant_name"] = safe_get(section, "tenant_name")
            dct["tenant_id"] = safe_get(section, "tenant_id")
            use_servicenet = safe_get(section, "use_servicenet", "False")
            dct["use_servicenet"] = use_servicenet == "True"
            app_agent = safe_get(section, "custom_user_agent")
            if app_agent:
                # Customize the user-agent string with the app name.
                dct["user_agent"] = "%s %s" % (app_agent, USER_AGENT)
            else:
                dct["user_agent"] = USER_AGENT

            # If this is the first section, make it the default
            if not self._default_set:
                self._settings["default"] = self._settings[section]
                self._default_set = True
        if creds_found:
            warnings.warn("Login credentials were detected in your .pyrax.cfg "
                    "file. These have been ignored, but you should remove "
                    "them and either place them in a credential file, or "
                    "consider using another means of authentication. More "
                    "information on the use of credential files can be found "
                    "in the 'docs/getting_started.md' document.")
1205096
def config_file(self, filename):
        
        if os.path.isfile(filename):
            with open(filename, 'r') as fh:
                self._config_data = json.load(fh)
        else:
            self.tcex.log.error('Could not load configuration file "{}".'.format(filename))
89296
public static ConfigDocument parseFile(File file, ConfigParseOptions options) {
        return Parseable.newFile(file, options).parseConfigDocument();
    }
1181977
public Configurator fromFile(File file) {
        if (!file.exists()) throw new FileNotFoundException(file.getAbsolutePath() + "does not exist.");
        return new Configurator(Uri.fromFile(file));
    }
902167
private static NetworkConfig fromFile(File configFile, boolean isJson) throws InvalidArgumentException, IOException, NetworkConfigurationException {

        // Sanity check
        if (configFile == null) {
            throw new InvalidArgumentException("configFile must be specified");
        }

        if (logger.isTraceEnabled()) {
            logger.trace(format("NetworkConfig.fromFile: %s  isJson = %b", configFile.getAbsolutePath(), isJson));
        }

        NetworkConfig config;

        // Json file
        try (InputStream stream = new FileInputStream(configFile)) {
            config = isJson ? fromJsonStream(stream) : fromYamlStream(stream);
        }

        return config;
    }
290522
public Map<String, Object> parse(JBakeConfiguration config, File file) {
        this.configuration = config;
        List<String> fileContents;
        try (InputStream is = new FileInputStream(file)) {

            fileContents = IOUtils.readLines(is, config.getRenderEncoding());
        } catch (IOException e) {
            LOGGER.error("Error while opening file {}", file, e);

            return null;
        }

        boolean hasHeader = hasHeader(fileContents);
        ParserContext context = new ParserContext(
                file,
                fileContents,
                config,
                hasHeader
        );

        if (hasHeader) {
            // read header from file
            processDefaultHeader(context);
        }
        // then read engine specific headers
        processHeader(context);

        setModelDefaultsIfNotSetInHeader(context);
        sanitizeTags(context);

        if (context.getType().isEmpty() || context.getStatus().isEmpty()) {
            // output error
            LOGGER.warn("Parsing skipped (missing type or status value in header meta data) for file {}!", file);
            return null;
        }

        // generate default body
        processDefaultBody(context);

        // eventually process body using specific engine
        if (validate(context)) {
            processBody(context);
        } else {
            LOGGER.error("Incomplete source file ({}) for markup engine: {}", file, getClass().getSimpleName());
            return null;
        }
        // TODO: post parsing plugins to hook in here?

        return context.getDocumentModel();
    }
735870
def read_file(self):
        

        # don't try to parse config file if we don't have one set
        if not self._cfg_path:
            return

        try:
            cfg_fp = open(self._cfg_path, 'r')
            self.readfp(cfg_fp)
        except IOError as exc:
            raise NipapConfigError(str(exc))
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)
212327
public static Configuration load(String file)
    throws IOException, SAXException {
    ConfigurationImpl cfg = new ConfigurationImpl();

    XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(new ConfigHandler(cfg, file));
    if (file.startsWith("classpath:")) {
      String resource = file.substring("classpath:".length());
      ClassLoader cloader = Thread.currentThread().getContextClassLoader();
      InputStream istream = cloader.getResourceAsStream(resource);
      parser.parse(new InputSource(istream));
    } else
      parser.parse(file);

    return cfg;
  }
389673
def validate_config_file(configfile = location)
      @log.debug "validating config file"
      unless File.file?(configfile)
        @log.error "configuration file not found at: #{configfile}"
        raise Autosign::Exceptions::NotFound
      end

      # check if file is world-readable
      if File.world_readable?(configfile) or File.world_writable?(configfile)
        @log.error "configuration file #{configfile} is world-readable or world-writable, which is a security risk"
        raise Autosign::Exceptions::Permissions
      end

      configfile
    end
668628
def parse(file_path=None, show=False):
    """"""
    if file_path is None:
        file_path = os.path.join(os.getcwd(), '.sciunit')
    if not os.path.exists(file_path):
        raise IOError('No .sciunit file was found at %s' % file_path)

    # Load the configuration file
    config = configparser.RawConfigParser(allow_no_value=True)
    config.read(file_path)

    # List all contents
    for section in config.sections():
        if show:
            print(section)
        for options in config.options(section):
            if show:
                print("\t%s: %s" % (options, config.get(section, options)))
    return config
65254
void parse(File file) throws ParseException {
        if (file == null) {
            Log.warn("parsing NULL file, so fallback on default configuration!");
            return;
        }
        if (!file.exists()) {
            Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()));
            return;
        }
        try {
            FileReader reader = new FileReader(file);
            parse(reader);
        } catch (FileNotFoundException fex) {
            Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()), fex);
            return;
        }
    }
925493
def read_config(self):
        
        _config = self.config["dikicli"]
        # TODO: what if file doesn't exist?
        if self.config_file.is_file():
            logger.debug("Reading config file: %s", self.config_file.as_posix())
            with open(self.config_file, mode="r") as f:
                self.config.read_file(f)

            # DIKI_DATA_DIR should always take precedence if it's set
            if "DIKI_DATA_DIR" in os.environ:
                _config["data dir"] = DATA_DIR.as_posix()

            w = _config.get("linewrap")
            try:
                w = int(w)
                if w < 0:
                    raise ValueError()
            except ValueError:
                logger.warning("Config: Invalid linewrap value. Using default.")
                _config["linewrap"] = self.default_config["linewrap"]

            c = _config.get("colors")
            if c.lower() not in ["yes", "no", "true", "false"]:
                logger.warning("Config: Invalid colors value. Using default.")
                _config["colors"] = self.default_config["colors"]
912677
private void parseDirectoryFiles(WsResource directory, ServerConfiguration configuration) throws ConfigParserException, ConfigValidationException {
        if (directory != null) {
            File[] defaultFiles = getChildXMLFiles(directory);
            if (defaultFiles == null)
                return;

            Arrays.sort(defaultFiles, new AlphaComparator());

            for (int i = 0; i < defaultFiles.length; i++) {
                File file = defaultFiles[i];
                if (!file.isFile())
                    continue;

                WsResource defaultFile = directory.resolveRelative(file.getName());
                if (defaultFile == null) {
                    // This should never happen, but it's conceivable that someone could remove a file
                    // after listFiles and before getChild
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, file.getName() + " was not found in directory " + directory.getName() + ". Ignoring. ");
                    }
                    continue;
                }
                Tr.audit(tc, "audit.dropin.being.processed", defaultFile.asFile());
                try {
                    parser.parseServerConfiguration(defaultFile, configuration);
                } catch (ConfigParserException ex) {
                    parser.handleParseError(ex, null);

                    if (ErrorHandler.INSTANCE.fail()) {
                        // if onError=FAIL, bubble the exception up the stack
                        throw ex;
                    } else {
                        // Mark the last update for the configuration so that we don't try to load it again
                        configuration.updateLastModified(configRoot.getLastModified());
                    }
                }
            }
        }
    }
963020
def _read_config(filename):
    
    parser = configparser.RawConfigParser()
    if filename and not parser.read(filename):
        sys.stderr.write("Unable to open configuration file %s. Use --config='' to disable this warning.\n" % filename)

    config = {}

    for section, defaults in BASE_CONFIG.items():
        # Patterns are handled separately
        if section == 'patterns':
            continue

        for name, descr in defaults.items():
            kind, default = descr
            if section in parser.sections() and name in parser.options(section):
                if kind == 'int':
                    value = parser.getint(section, name)
                elif kind == 'float':
                    value = parser.getfloat(section, name)
                elif kind == 'bool':
                    value = parser.getboolean(section, name)
                else:
                    value = parser.get(section, name)
            else:
                value = default
            config[name] = value

    if 'patterns' in parser.sections():
        patterns = [parser.get('patterns', opt) for opt in parser.options('patterns')]
    else:
        patterns = DEFAULT_PATTERNS
    config['patterns'] = patterns

    return config
87559
def parse_config_files(self, filenames=None, ignore_option_errors=False):
        
        self._parse_config_files(filenames=filenames)

        parse_configuration(self, self.command_options,
                            ignore_option_errors=ignore_option_errors)
        self._finalize_requires()
1113511
def from_file(cls, filename, **kwargs):
        
        filename = os.path.expanduser(filename)
        if not os.path.isfile(filename):
            raise exceptions.PyKubeError("Configuration file {} not found".format(filename))
        with open(filename) as f:
            doc = yaml.safe_load(f.read())
        self = cls(doc, **kwargs)
        self.filename = filename
        return self