Load configuration from existing file.

        :param str filepath: Path to existing config file.
        :raises: ValueError if supplied config file is invalid.
515856
def load(self, filepath):
        
        try:
            self._config.read(filepath)
            self.long_running_operation_timeout = self._config.getint(
                "Azure", "long_running_operation_timeout")
        except (ValueError, EnvironmentError, NoOptionError):
            msg = "Supplied config file incompatible"
            raise_with_traceback(ValueError, msg)
        finally:
            self._clear_config()
        return super(AzureConfiguration, self).load(filepath)
836549
def load_from_configuration(cls, path, uuid, **kwargs):
        
        cfg = ConfigParser.ConfigParser()
        kw = {}
        with open(path, 'r') as _f:
            cfg.readfp(_f)
            if cfg.has_section('General'):
                general = dict(cfg.items('General'))
                kw['filepath'] = kwargs.get('filepath', False) or general['filepath']
                kw['application_name'] = general.get('application_name', '')
                kw['application_version'] = general.get('application_version', '')
                kw['submit_interval_s'] = int(general.get('submit_interval_s', 0))
                kw['check_interval_s'] = int(general.get('check_interval_s', 0))
                kw['debug'] = bool(general.get('debug', False))

            if cfg.has_section('HQ'):
                hq_params = dict(cfg.items('HQ'))
            else:
                hq_params = None

        kw.update(**kwargs)
        tracker = cls(uuid, **kw)
        if hq_params:
            tracker.setup_hq(**hq_params)

        return tracker
3283
def load(config_path=DEFAULT_CONFIG_PATH):
    
    if not pathlib.Path(config_path).exists():
        logger.debug(f"Could not locate {config_path}, using default config.")
        return DEFAULT_CONFIG

    config = configparser.ConfigParser(default_section=DEFAULT_CONFIG_SECTION)
    config.read(config_path)

    operators = config.get(
        section=DEFAULT_CONFIG_SECTION, option="operators", fallback=DEFAULT_OPERATORS
    )
    archiver = config.get(
        section=DEFAULT_CONFIG_SECTION, option="archiver", fallback=DEFAULT_ARCHIVER
    )
    path = config.get(section=DEFAULT_CONFIG_SECTION, option="path", fallback=".")
    max_revisions = int(
        config.get(
            section=DEFAULT_CONFIG_SECTION,
            option="max_revisions",
            fallback=DEFAULT_MAX_REVISIONS,
        )
    )

    return WilyConfig(
        operators=operators, archiver=archiver, path=path, max_revisions=max_revisions
    )
661469
def __load_project_from_file_path(file_path):
    '''
    
    '''
    try:
        project = get_project(project_dir=os.path.dirname(file_path),
                              config_path=[os.path.basename(file_path)])
    except Exception as inst:
        return __handle_except(inst)
    return project
467961
def load_conf(cfg_path):
    
    global config
    try:
        cfg = open(cfg_path, 'r')
    except Exception as ex:
        if verbose:
            print("Unable to open {0}".format(cfg_path))
            print(str(ex))
        return False

    # Read the entire contents of the conf file
    cfg_json = cfg.read()
    cfg.close()
    # print(cfg_json)

    # Try to parse the conf file into a Python structure
    try:
        config = json.loads(cfg_json)
    except Exception as ex:
        print("Unable to parse configuration file as JSON")
        print(str(ex))
        return False

    # This config was successfully loaded
    return True
847144
function handleConfiguration(filePath) {
    if (fs.existsSync(filePath)) {
        filePath = path.resolve(filePath);
    }
    else {
        console.error('Invalid path to configuration file.');
        return 1;
    }
    return setupConfigurationFile(filePath);
}
996025
private Config loadNodeFileWithOverrides(Path filePath) throws IOException {
    Config nodeConfig = this.pullFileLoader.loadPullFile(filePath, emptyConfig, false);
    return getNodeConfigWithOverrides(nodeConfig, filePath);
  }
357710
def load_config_file(self, path, profile=None):
        """"""
        config_cls = self.get_config_reader()
        return config_cls.load_config(self, path, profile=profile)
960483
def load_config(self, config_path=None):
        """"""
        if config_path is None:
            config_path = self.config_path
        else:
            self.config_path = config_path

        config = ConfigParser.SafeConfigParser(self.DEFAULT_SUBSTITUTIONS,
                                               allow_no_value=True)
        # Avoid the configparser automatically lowercasing keys
        config.optionxform = str
        self.initialize_config(config)
        try:
            with open(config_path) as f:
                config.readfp(f)
        except (IOError, ConfigParser.Error):
            _log.exception("Ignoring config from %s due to error.", config_path)
            return False

        self.config = config
        self.reload_modules()
        return True
773746
def _load_config(self, path):
        
        try:
            with open(path) as f:
                values = yaml.safe_load(f)
                if isinstance(values, dict):
                    return values
                else:
                    raise yaml.YAMLError('Unable to parse/load {}'.format(path))
        except(IOError, yaml.YAMLError) as e:
            if self.ignore_errors:
                return None
            else:
                raise e
518968
def _loadfilepath(self, filepath, **kwargs):
        
        with open(filepath, "r") as f:
            data = json.load(f, **kwargs)
        return data
1328396
def _load(self, file_path: Text) -> None:
        

        # noinspection PyUnresolvedReferences
        module_ = types.ModuleType('settings')
        module_.__file__ = file_path

        try:
            with open(file_path, encoding='utf-8') as f:
                exec(compile(f.read(), file_path, 'exec'), module_.__dict__)
        except IOError as e:
            e.strerror = 'Unable to load configuration file ({})'\
                .format(e.strerror)
            raise

        for key in dir(module_):
            if CONFIG_ATTR.match(key):
                self[key] = getattr(module_, key)
1242106
private function loadConfiguration($filePath)
    {
        if (!is_file($filePath)) {
            throw new \InvalidArgumentException(sprintf('The configuration file "%s" does not exit', $filePath));
        }

        $config = include $filePath;

        if (!$config instanceof Configuration) {
            throw new \InvalidArgumentException(
                sprintf(
                    'The configuration file "%s" must return a "Akeneo\CouplingDetector\Configuration\Configuration"',
                    $filePath
                )
            );
        }

        return $config;
    }
966750
def setup(self, filepath):
        
        if self.log is not None:
            self.log.warning("Disallowed multiple setup of config.")
            return

        self.log = logging.getLogger(__name__)
        self.parser = ConfigParser.RawConfigParser()
        self.parser.read(filepath)
        self.sections = self.parser.sections()
        self.log_output.append(
            {"level": "info", "msg": "Loading config-file (%s)" % filepath})
        self.load_config()
        self.handle_logging()
154316
def load_config(configfile):
    

    configfile = os.path.abspath(configfile)
    config = configobj.ConfigObj(configfile)

    config_extension = '.conf'

    #########################################################################
    # Load up other config files
    #########################################################################

    if 'configs' in config:
        config_extension = config['configs'].get('extension', config_extension)

        # Load other configs
        if 'path' in config['configs']:
            for cfgfile in os.listdir(config['configs']['path']):
                cfgfile = os.path.join(config['configs']['path'],
                                       cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                newconfig = configobj.ConfigObj(cfgfile)
                config.merge(newconfig)

    #########################################################################

    if 'server' not in config:
        raise Exception('Failed to load config file %s!' % configfile)

    #########################################################################
    # Load up handler specific configs
    #########################################################################

    if 'handlers' not in config:
        config['handlers'] = configobj.ConfigObj()

    if 'handlers_config_path' in config['server']:
        handlers_config_path = config['server']['handlers_config_path']
        if os.path.exists(handlers_config_path):
            for cfgfile in os.listdir(handlers_config_path):
                cfgfile = os.path.join(handlers_config_path, cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                filename = os.path.basename(cfgfile)
                handler = os.path.splitext(filename)[0]

                if handler not in config['handlers']:
                    config['handlers'][handler] = configobj.ConfigObj()

                newconfig = configobj.ConfigObj(cfgfile)
                config['handlers'][handler].merge(newconfig)

    #########################################################################
    # Load up Collector specific configs
    #########################################################################

    if 'collectors' not in config:
        config['collectors'] = configobj.ConfigObj()

    if 'collectors_config_path' in config['server']:
        collectors_config_path = config['server']['collectors_config_path']
        if os.path.exists(collectors_config_path):
            for cfgfile in os.listdir(collectors_config_path):
                cfgfile = os.path.join(collectors_config_path, cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                filename = os.path.basename(cfgfile)
                collector = os.path.splitext(filename)[0]

                if collector not in config['collectors']:
                    config['collectors'][collector] = configobj.ConfigObj()

                try:
                    newconfig = configobj.ConfigObj(cfgfile)
                except Exception as e:
                    raise Exception("Failed to load config file %s due to %s" %
                                    (cfgfile, e))

                config['collectors'][collector].merge(newconfig)

    # Convert enabled to a bool
    for collector in config['collectors']:
        if 'enabled' in config['collectors'][collector]:
            config['collectors'][collector]['enabled'] = str_to_bool(
                config['collectors'][collector]['enabled']
            )

    #########################################################################

    return config
1260458
def from_filepath(cls, filepath):
        ''''''
        assert(os.path.exists(filepath))
        return cls(read_file(filepath))
1234052
def import_config(config_path):
    
    if not os.path.isfile(config_path):
        raise ConfigBuilderError(
                'Could not find config file: ' + config_path)
    loader = importlib.machinery.SourceFileLoader(config_path, config_path)
    module = loader.load_module()

    if not hasattr(module, 'config') or not isinstance(module.config, Config):
        raise ConfigBuilderError(
            'Could not load config file "{}": config files must contain '
            'a variable called "config" that is '
            'assigned to a Config object.'.format(config_path))
    return module.config