Update global config from YAML file

    If fn is None, looks in global config directory, which is either defined
    by the INTAKE_CONF_DIR env-var or is ~/.intake/ .
15920
def load_conf(fn=None):
    
    if fn is None:
        fn = cfile()
    if os.path.isfile(fn):
        with open(fn) as f:
            try:
                conf.update(yaml_load(f))
            except Exception as e:
                logger.warning('Failure to load config file "{fn}": {e}'
                               ''.format(fn=fn, e=e))
1128325
def parse_config(config_file):
    """"""
    try:
        with open(config_file, 'r') as f:
            return yaml.load(f)
    except IOError:
        print "Configuration file {} not found or not readable.".format(config_file)
        raise
1343595
function writeYAMLConfigFile(config, filePath) {
    debug(`Writing YAML config file: ${filePath}`);

    // lazy load YAML to improve performance when not used
    const yaml = require("js-yaml");

    const content = yaml.safeDump(config, { sortKeys: true });

    fs.writeFileSync(filePath, content, "utf8");
}
910226
def override_config(self, path):
        
        status = (True, None)
        config_override = False

        try:
            # parse the yml file
            c_dict = {}
            if exists(self.plugin_config_file):
                with open(self.plugin_config_file, 'r') as config_file:
                    c_dict = yaml.safe_load(config_file.read())

            # check for environment variable overrides
            check_c_dict = c_dict.copy()
            for tool in check_c_dict:
                for section in check_c_dict[tool]:
                    for key in check_c_dict[tool][section]:
                        if key in environ:
                            c_dict[tool][section][key] = getenv(key)

            # assume the name of the plugin is its directory
            plugin_name = path.split('/')[-1]
            if plugin_name == '':
                plugin_name = path.split('/')[-2]
            plugin_config_path = path + '/config/' + plugin_name + '.config'

            if exists(plugin_config_path):
                plugin_template = Template(plugin_config_path)
                plugin_options = c_dict[plugin_name]
                for section in plugin_options:
                    for option in plugin_options[section]:
                        plugin_template.set_option(section, option,
                                                   str(plugin_options[section][option]))
                plugin_template.write_config()
                config_override = True
        except Exception as e:  # pragma: no cover
            status = (False, str(e))

        return status, config_override
1145952
def locate_config(self):
        '''  '''
        for f in self.__potential:
            f = FileHelper.abspath(f)
            if os.path.isfile(f):
                return f
        return None
83035
def load_config(filename):
    
    package_path = ding0.__path__[0]
    FILE = path.join(package_path, 'config', filename)

    try:
        cfg.read(FILE)
        global _loaded
        _loaded = True
    except:
        logger.exception("configfile not found.")
1080638
def load_config(check_dir):
    

    # Defaults for top-level keys
    options = {
        "checks": "__init__.py",
        "dependencies": None,
        "translations": None
    }

    # Defaults for translation keys
    translation_options = {
        "localedir": "locale",
        "domain": "messages",
    }

    config_file = Path(check_dir) / ".cs50.yaml"

    with open(config_file) as f:
        config = lib50.config.load(f.read(), "check50")

    if isinstance(config, dict):
        options.update(config)

    if options["translations"]:
        if isinstance(options["translations"], dict):
            translation_options.update(options["translations"])
        options["translations"] = translation_options

    if isinstance(options["checks"], dict):
        # Compile simple checks
        with open(check_dir / "__init__.py", "w") as f:
            f.write(simple.compile(options["checks"]))
        options["checks"] = "__init__.py"

    return options
1224291
def _update_config_file(username, password, email, url, config_path):
        """"""
        try:
            # read the existing config
            config = json.load(open(config_path, "r"))
        except ValueError:
            config = dict()

        if not config.get('auths'):
            config['auths'] = dict()

        if not config['auths'].get(url):
            config['auths'][url] = dict()
        encoded_credentials = dict(
            auth=base64.b64encode(username + b':' + password),
            email=email
        )
        config['auths'][url] = encoded_credentials
        try:
            json.dump(config, open(config_path, "w"), indent=5, sort_keys=True)
        except Exception as exc:
            raise exceptions.AnsibleContainerConductorException(
                u"Failed to write registry config to {0} - {1}".format(config_path, exc)
            )
39718
def setup_config(command, filename, section, vars):
    """"""
    confuri = "config:" + filename
    if ":" in section:
        confuri += "#" + section.rsplit(":", 1)[-1]
    conf = appconfig(confuri)

    load_environment(conf.global_conf, conf.local_conf)
532988
def configfile(f):
    

    @click.pass_context
    def new_func(ctx, *args, **kwargs):
        ctx.config = yaml.load(open(ctx.obj["configfile"]))
        return ctx.invoke(f, *args, **kwargs)

    return update_wrapper(new_func, f)
228724
def _check_global_settings():
    
    global settings
    if settings is not None:
        #We must have already loaded this and everything was okay!
        return True
    
    from os import getenv
    result = False
    
    if getenv("PYCI_XML") is None:
        err("The environment variable PYCI_XML for the global configuration "
            "has not been set.")
    else:
        from os import path
        fullpath = path.abspath(path.expanduser(getenv("PYCI_XML")))
        if not path.isfile(fullpath):
            err("The file {} for global configuration does not exist.".format(fullpath))
        else:
            from pyci.config import GlobalSettings
            settings = GlobalSettings()
            result = True

    return result
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
396533
def load_configs(self, conf_file):
        
        with open(conf_file) as stream:
            lines = itertools.chain(("[global]",), stream)
            self._config.read_file(lines)
        return self._config['global']
1368354
def on_config(self, config):
        ""
        #print("Here is the config:", config)

        # fetch variables from YAML file:
        self._variables = config.get(YAML_SUBSET)

        # add variables and functions from the module:
        module_reader.load_variables(self._variables, config)

        print("Variables:", self.variables)
1154607
def load_env():
    """"""
    # environment variables take precedence over conf file
    for key, envvar in [['cache_dir', 'INTAKE_CACHE_DIR'],
                        ['catalog_path', 'INTAKE_PATH'],
                        ['persist_path', 'INTAKE_PERSIST_PATH']]:
        if envvar in os.environ:
            conf[key] = make_path_posix(os.environ[envvar])
    conf['catalog_path'] = intake_path_dirs(conf['catalog_path'])
    for key, envvar in [['cache_disabled', 'INTAKE_DISABLE_CACHING'],
                        ['cache_download_progress', 'INTAKE_CACHE_PROGRESS']]:
        if envvar in os.environ:
            conf[key] = os.environ[envvar].lower() in ['true', 't', 'y', 'yes']
    if 'INTAKE_LOG_LEVEL' in os.environ:
        conf['logging'] = os.environ['INTAKE_LOG_LEVEL']
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
869490
def _load_config_file(self):
        """"""
        with open(self._config_file) as f:
            config = yaml.safe_load(f)
            patch_config(config, self.__environment_configuration)
            return config