Using TOML format, load config from given path, or write out example based on defaults
358821
def get_or_create_config(path, config):
    """"""
    if os.path.isfile(path):
        with open(path) as fh:
            _LOG.debug("loading config from %s", os.path.abspath(path))
            config._inflate(toml.load(fh))
    else:
        try:
            os.makedirs(os.path.dirname(path))
        except OSError:
            pass
        with open(path, "w") as fh:
            toml.dump(config._deflate(), fh)
453047
function loadYamlConfig (paths) {
  paths = paths || []

  if (!Array.isArray(paths)) {
    paths = new Array(paths)
  }

  // console.log('Paths:', paths)

  if (paths.length === 0) {
    if (checkDefaultConfig()) {
      paths.push('config.yml')
    } else {
      return config
    }
  }

  let files = []
  for (let i = 0; i < paths.length; i++) {
    if (paths[i].endsWith('.yml')) {
      if (fs.existsSync(paths[i])) {
        let keyName = (/([ \w-]+?(?=\.))/.exec(paths[i])[1])
        files[keyName] = path.join(paths[i])
      }
    } else {
      let dirFiles = fs.readdirSync(path.join(paths[i]))
      let dirPath = path.join(paths[i])
      for (let i = 0; i < dirFiles.length; i++) {
        if (dirFiles[i].endsWith('.yml')) {
          let keyName = dirFiles[i].substring(0, dirFiles[i].length - '.yml'.length)
          files[keyName] = path.join(dirPath, dirFiles[i])
        }
      }
    }
  }
  // console.log('Files:', files)
  if (files === []) {
    return
  }
  let rootConfig = {}
  for (var keyName in files) {
    if (files.hasOwnProperty(keyName)) {
      if (keyName === options.root) {
        rootConfig = loadYamlFile(files[keyName])
      } else {
        config[keyName] = loadYamlFile(files[keyName])
      }
    }
  }
  config = Object.assign(rootConfig, config)
  return config
}
991185
def _load_config(self, path):
        
        p = os.path.abspath(os.path.expanduser(path))
        logger.debug('Loading configuration from: %s', p)
        return read_json_file(p)
1136615
def load_configuration(app_name):
    '''
    
    '''
    if sys.prefix == '/usr':
        conf_dir = '/etc'
        share_dir = '/usr/share'
    else:
        conf_dir = os.path.join(sys.prefix, 'etc')
        share_dir = os.path.join(sys.prefix, 'share')
    # Step 1: try to locate pynlp.yml
    yml_config = {}
    for fname in [
            '%s.yml'%(app_name,),
            os.path.expanduser('~/.%s.yml'%(app_name,)),
            os.path.join(conf_dir, '%s.yml'%(app_name,))]:
        if os.path.exists(fname):
            yml_config = yaml.load(open(fname))
            break
    try:
        data_dir = yml_config['paths']['data_dir']
    except KeyError:
        try:
            data_dir = os.environ[app_name.upper()]
        except KeyError:
            data_dir = os.path.join(share_dir, app_name)
    return AppContext(yml_config, data_dir)
1249334
def load_config(name, base='conf'):
    """"""
    fname = pjoin(base, name + '.json')
    if not os.path.exists(fname):
        return {}
    try:
        with open(fname) as f:
            cfg = json.load(f)
    except Exception as e:
        warn("Couldn't load %s: %s" % (fname, e))
        cfg = {}
    return cfg
418994
def load_cli_config(args):
    
    default_cli_config = _load_default_cli_config()
    toml_config = _load_toml_cli_config()

    for config in (toml_config, default_cli_config):
        for key, val in config.items():
            if key in args and getattr(args, key) is not None:
                pass
            else:
                setattr(args, key, val)
61269
def load_scrap(self, path):
        
        try:
            conf = self.load_settings(path)
        except:
            # Should only be IOError
            self.exception("Failed to load file")
            raise WEBFileException("Failed to load from {}".format(path))

        if "scheme" not in conf:
            raise WEBParameterException("Missing scheme definition")
        if "url" not in conf:
            raise WEBParameterException("Missing url definition")
        version = conf.get('version', None)
        if version != "1.0":
            raise WEBParameterException(
                "Unsupported version {}".format(version)
            )
        self.scheme = conf['scheme']
        self.url = conf['url']
        self.timeout = conf.get('timeout', self.timeout)
        if conf.get('html2text'):
            self._set_html2text(conf['html2text'])
251861
function loadConfigFile(configPath) {
	logger.debug('Loading configuration file at:', configPath);

	function loadConfig() {
		return fs.readFileSync(configPath, { encoding: 'utf8' });
	}

	function parseConfig(content, extension) {
		switch (extension) {
		case '.js':
			return require(configPath);

		case '.yaml':
			return jsYaml.safeLoad(content, { filename: configPath });

		case '.json':
			try {
				return JSON.parse(content);
			} catch (error) {
				// Try to provide more specific syntax errors
				lintJson(content);

				// If no syntax errors are found, throw a generic error
				throw new Error('There was a problem loading a configuration file: ' + configPath);
			}

		case '.json5':
			return JSON5.parse(content);

		default:
			throw new Error(`Configuration file is an unsupported type [${supportedTypes.join(', ')}]: ` + configPath);
		}
	}

	var extension = path.extname(configPath);
	var content;

	try {
		content = loadConfig();
	} catch (error) {
		throw new ConfigurationError('Failed to read configuration file', configPath, error);
	}

	try {
		return parseConfig(content, extension);
	} catch (error) {
		throw new ConfigurationError('Failed to parse configuration file', configPath, error);
	}
}
133280
def load(config_path: str):
    
    # we bind the config to _ to keep it alive
    if os.path.splitext(config_path)[1] in ('.yaml', '.yml'):
        _ = load_yaml_configuration(config_path, translator=PipelineTranslator())
    elif os.path.splitext(config_path)[1] == '.py':
        _ = load_python_configuration(config_path)
    else:
        raise ValueError('Unknown configuration extension: %r' % os.path.splitext(config_path)[1])
    yield
275929
def load_config(path):
    """"""
    config = ConfigParser()

    if len(config.read(path)) == 0:
        stderr_and_exit("Couldn't load config {0}\n".format(path))
    if not config.has_section('walls'):
        stderr_and_exit('Config missing [walls] section.\n')

    # Print out all of the missing keys
    keys = ['api_key', 'api_secret', 'tags', 'image_dir', 'width', 'height']
    for key in set(keys):
        if config.has_option('walls', key):
            keys.remove(key)
    if keys:
        stderr_and_exit("Missing config keys: '{0}'\n"
                        .format("', '".join(keys)))

    # Parse integer values
    int_keys = ['width', 'height']
    for key in set(int_keys):
        try:
            config.getint('walls', key)
            int_keys.remove(key)
        except ValueError:
            pass
    if int_keys:
        stderr_and_exit("The following must be integers: '{0}'\n"
                        .format("', '".join(int_keys)))

    # Check destination directory
    path = os.path.expanduser(config.get('walls', 'image_dir'))
    if not os.path.isdir(path):
        stderr_and_exit('The directory {0} does not exist.\n'
                        .format(config.get('walls', 'image_dir')))

    return config
942894
def create_app_from_yml(path):
    """"""

    try:
        with open(path, "rt", encoding="UTF-8") as f:
            try:
                # Substitute ALL occurrences of '%(here)s' with a path to a
                # directory with '.holocron.yml'. Please note, we also want
                # wrap the result into 'io.StringIO' in order to preserve
                # original filename in 'yaml.safe_load()' errors.
                interpolated = io.StringIO(f.read() % {
                    "here": os.path.abspath(os.path.dirname(path))})
                interpolated.name = f.name

                conf = yaml.safe_load(interpolated)
            except yaml.YAMLError as exc:
                raise RuntimeError(
                    "Cannot parse a configuration file. Context: " + str(exc))

    except FileNotFoundError:
        conf = {"metadata": None, "pipes": {}}

    return core.create_app(conf["metadata"], pipes=conf["pipes"])
15498
def load_config(path):
   
   with path.open('rb') as fi:
       file_bytes = fi.read()
       config = yaml.load(file_bytes.decode('utf-8'))

   return config
939370
def load_config(path, opts = {})
    opts.reverse_merge! :reconnect => true
    new_config = self.class.parse_config_file(path)
    update_config(new_config[:config]) if new_config and new_config[:config]
    reconnect(@config[:base_url], @config[:username], @config[:password]) if opts[:reconnect] and connection_info_loaded?
    @config
  end
735358
def load(path):
    '''
    
    '''
    ret = {}
    fmadm = _check_fmadm()
    cmd = '{cmd} load {path}'.format(
        cmd=fmadm,
        path=path
    )
    res = __salt__['cmd.run_all'](cmd)
    retcode = res['retcode']
    result = {}
    if retcode != 0:
        result['Error'] = res['stderr']
    else:
        result = True

    return result
663946
def write_config(path, config):
    
    config_as_string = to_nice_yaml(config)

    config_as_string = "---\n" + config_as_string

    string_to_file(path, config_as_string)
1054561
def load_config(path=None):
    """"""
    if not path or not op.exists(path):
        return Config()
    path = op.realpath(path)
    dirpath, filename = op.split(path)
    file_ext = op.splitext(path)[1]
    logger.debug("Load config file `%s`.", path)
    if file_ext == '.py':
        config = PyFileConfigLoader(filename, dirpath,
                                    log=logger).load_config()
    elif file_ext == '.json':
        config = JSONFileConfigLoader(filename, dirpath,
                                      log=logger).load_config()
    return config
24430
def load(self):
        """"""
        if not self.loaded:
            self.values = configobj.ConfigObj({}, **self.DEFAULT_CONFIG_OPTS)
            for path in self.locations():
                try:
                    part = configobj.ConfigObj(infile=path, **self.DEFAULT_CONFIG_OPTS)
                except configobj.ConfigObjError as cause:
                    raise LoggedFailure("Error in file '{path}': {cause}".format(path=pretty_path(path), cause=cause))
                self.values.merge(part)
            self.loaded = True
        return self.values