Loading configuration

        Parameters
        ----------
        configuration_file : string
            Path to the configuration file (text or HDF5 file).
493339
def load_configuration(self, configuration_file):
        '''
        '''
        if os.path.isfile(configuration_file):
            if not isinstance(configuration_file, tb.file.File) and os.path.splitext(configuration_file)[1].strip().lower() != ".h5":
                load_configuration_from_text_file(self, configuration_file)
            else:
                load_configuration_from_hdf5(self, configuration_file)
        else:
            raise ValueError('Cannot find configuration file specified: %s' % configuration_file)
566879
def load_config(self, settings=None):
        
        self._load_defaults()
        if settings:
            self.update(settings)
        else:
            config_paths = _get_config_files()
            for p in config_paths:
                conf = _process_config_file([p])
                self.update(conf)
        self._loaded = True
        self._validate()
953998
def do_load(self, line):
        
        config_file = self._split_args(line, 0, 1)[0]
        self._command_processor.get_session().load(config_file)
        if config_file is None:
            config_file = (
                self._command_processor.get_session().get_default_pickle_file_path()
            )
        self._print_info_if_verbose("Loaded session from file: {}".format(config_file))
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
905380
def load_config(filename=None):
    
    try:
        with _config_stream(filename) as handle:
            filename = handle.name
            return deserialize_config(handle.read())
    except (OSError, toml.TomlDecodeError, UnicodeDecodeError) as exc:
        raise ConfigError(
            'Error loading configuration from {}'.format(filename)) from exc
479440
public void load(String file) {
		Context context = factory.enterContext();
		
		try {
			URL url = Thread.currentThread().getContextClassLoader().getResource(file);
			
			if (url == null) {
				logger.debug("Configuration [" + file + "] does not exist");
				return;
			}
			
			File f = new File(url.getPath());
			
			if (f.exists()) {
				logger.info("Loading configuration [" + file + "]");
				context.evaluateReader(scope, new FileReader(f), file.substring(file.lastIndexOf("/") + 1), 1, null);
			}
			
		} catch (Exception e) {
			logger.error("Failed to load configuration [" + file + "]", e);
			throw new UncheckedException(e);
		} finally {
			Context.exit();
		}
	}
757928
def _load_config_file(self):
        
        LOGGER.info('Loading configuration from %s', self._file_path)
        if self._file_path.endswith('json'):
            config = self._load_json_config()
        else:
            config = self._load_yaml_config()
        for key, value in [(k, v) for k, v in config.items()]:
            if key.title() != key:
                config[key.title()] = value
                del config[key]
        return flatdict.FlatDict(config)
259655
def read_config(self, filename):
        
        if not os.path.exists(filename):
            raise Exception("Configuration file cannot be found: %s" % filename)
        with io.open(filename, encoding='UTF-8') as stream:
            return yaml.safe_load(stream)
27009
public static ApplicationConfiguration load(File file) throws Exception {
		try (FileInputStream in = new FileInputStream(file)) {
			return load(in);
		}
	}
706646
def get_configuration(config_file=None):
    
    parser = configparser.ConfigParser()
    if config_file is None:
        # fallback to default user config file
        config_file = os.path.join(os.getenv("HOME"), DEFAULT_USER_INI)
        if not os.path.isfile(config_file):
            config_file = None
    else:
        if not os.path.isfile(config_file):
            raise ValueError("%s is not a file" % config_file)

    configs = [get_filename(PRESETS_INI)]
    if config_file:
        configs.append(config_file)
    LOG.debug("Attempting to read configuration from %r", configs)
    read_configs = parser.read(configs)
    LOG.debug("Successfully read configuration from %r", read_configs)
    LOG.debug("config file sections: %r", parser.sections())
    return parser
607708
def _load_config(configfile, section=None):
    '''
    '''
    if os.path.exists(configfile):
        config = read_config(configfile)
        if section is not None:
            if section in config:
                return config._sections[section]
            else:
                bot.warning('%s not found in %s' %(section, configfile))
        return config
120219
def read_config(self):
        

        try:
            parsed_files = self._config.read(self._files, encoding="utf-8")
        except configparser.Error as e:
            log.error("Can't parse configuration file: %s", str(e))
            return
        if not parsed_files:
            log.warning("No configuration file could be found or read")
        else:
            for file in parsed_files:
                log.info("Load configuration file {}".format(file))
                self._watched_files[file] = os.stat(file).st_mtime
1034159
def load_config(file)
      unless File.exists? file
        File.open(file, 'w') do |f| 
          YAML.dump({ default_website: 'default' }, f) 
        end
      end
      YAML.load_file(file)
    end
894970
def _load_config(self, filename):
        
        # Read entire file for metadata
        fh = open(filename, 'r')
        self.file_contents = fh.read()

        # Replace !include directives with content
        config_dir = os.path.split(filename)[0]
        include_re = re.compile('^(.*)!include\s+(.*)$', re.MULTILINE)

        def recursive_load(matchobj, path):
            first_spacing = matchobj.group(1)
            other_spacing = first_spacing.replace('-', ' ')
            fname = os.path.join(path, matchobj.group(2))
            new_path, _ = os.path.split(fname)
            new_path = os.path.realpath(new_path)
            text = ''
            with open(fname) as f:
                text = f.read()
            text = first_spacing + text
            text = text.replace('\n', '\n{}'.format(other_spacing), text.count('\n') - 1)
            return re.sub(include_re, lambda m : recursive_load(m, new_path), text)

#        def include_repl(matchobj):
#            first_spacing = matchobj.group(1)
#            other_spacing = first_spacing.replace('-', ' ')
#            fname = os.path.join(config_dir, matchobj.group(2))
#            text = ''
#            with open(fname) as f:
#                text = f.read()
#            text = first_spacing + text
#            text = text.replace('\n', '\n{}'.format(other_spacing), text.count('\n') - 1)
#            return text

        self.file_contents = re.sub(include_re, lambda m : recursive_load(m, config_dir), self.file_contents)
        # Read in dictionary
        self.config = self.__ordered_load(self.file_contents)

        # Convert functions of other params to true expressions
        for k in self.config.keys():
            self.config[k] = YamlConfig.__convert_key(self.config[k])

        fh.close()

        # Load core configuration
        return self.config
400819
private void readConfigurationFile(final String configFile) {
    InputStream is;
    try {
      is = new FileInputStream(configFile);
      processConfiguration(MtasConfiguration.readConfiguration(is));
      is.close();
    } catch (FileNotFoundException e) {
      log.error("Couldn't find " + configFile, e);
    } catch (IOException e) {
      log.error("Couldn't read " + configFile, e);
    }
  }
220047
def load_configuration_file(self):
        
        if not os.path.exists(self.config_file):
            return
        try:
            with open(self.config_file, 'r') as file:
                csvreader = csv.reader(file, delimiter='=',
                                       escapechar='\\', quoting=csv.QUOTE_NONE)
                for line in csvreader:
                    if len(line) == 2:
                        key, value = line
                        self.config_dict[key] = value
                    else:
                        self.config_dict = dict()
                        self.logger.warning("Malformed configuration file {0}, ignoring it.".
                                            format(self.config_file))
                        return
        except (OSError, IOError) as e:
            self.logger.warning("Could not load configuration file: {0}".\
                format(utils.exc_as_decoded_string(e)))
460235
def load(self, file=CONFIG_FILE):
        
        if not os.path.exists(file):
            print("Config file was not found under %s. Default file has been created" % CONFIG_FILE)
            self._settings = yaml.load(DEFAULT_CONFIG, yaml.RoundTripLoader)
            self.save(file)
            sys.exit()
        with open(file, 'r') as f:
            self._settings = yaml.load(f, yaml.RoundTripLoader)