load env from file do not override
348214
public function loadEnvironment()
    {
        if (is_file($this->getFullEnvFilePath())) {
            $env = new DotEnv($this->basePath, $this->getEnvFile());
            $env->load();
        }
    }
519084
def load_config(path, env_var, default_path=None, exit_on_config_errors=True):
    '''
    
    '''
    if path is None:
        # When the passed path is None, we just want the configuration
        # defaults, not actually loading the whole configuration.
        return {}

    if default_path is None:
        # This is most likely not being used from salt, i.e., could be salt-cloud
        # or salt-api which have not yet migrated to the new default_path
        # argument. Let's issue a warning message that the environ vars won't
        # work.
        import inspect
        previous_frame = inspect.getframeinfo(inspect.currentframe().f_back)
        log.warning(
            "The function '%s()' defined in '%s' is not yet using the "
            "new 'default_path' argument to `salt.config.load_config()`. "
            "As such, the '%s' environment variable will be ignored",
            previous_frame.function, previous_frame.filename, env_var
        )
        # In this case, maintain old behavior
        default_path = DEFAULT_MASTER_OPTS['conf_file']

    # Default to the environment variable path, if it exists
    env_path = os.environ.get(env_var, path)
    if not env_path or not os.path.isfile(env_path):
        env_path = path
    # If non-default path from `-c`, use that over the env variable
    if path != default_path:
        env_path = path

    path = env_path

    # If the configuration file is missing, attempt to copy the template,
    # after removing the first header line.
    if not os.path.isfile(path):
        template = '{0}.template'.format(path)
        if os.path.isfile(template):
            log.debug('Writing %s based on %s', path, template)
            with salt.utils.files.fopen(path, 'w') as out:
                with salt.utils.files.fopen(template, 'r') as ifile:
                    ifile.readline()  # skip first line
                    out.write(ifile.read())

    opts = {}

    if salt.utils.validate.path.is_readable(path):
        try:
            opts = _read_conf_file(path)
            opts['conf_file'] = path
        except salt.exceptions.SaltConfigurationError as error:
            log.error(error)
            if exit_on_config_errors:
                sys.exit(salt.defaults.exitcodes.EX_GENERIC)
    else:
        log.debug('Missing configuration file: %s', path)

    return opts
912092
def _load_with_overrides(base) -> Dict[str, str]:
    
    should_write = False
    overrides = _get_environ_overrides()
    try:
        index = json.load((base/_CONFIG_FILENAME).open())
    except (OSError, json.JSONDecodeError) as e:
        sys.stderr.write("Error loading config from {}: {}\nRewriting...\n"
                         .format(str(base), e))
        should_write = True
        index = generate_config_index(overrides)

    for key in CONFIG_ELEMENTS:
        if key.name not in index:
            sys.stderr.write(
                f"New config index key {key.name}={key.default}"
                "\nRewriting...\n")
            if key.kind in (ConfigElementType.DIR, ConfigElementType.FILE):
                index[key.name] = base/key.default
            else:
                index[key.name] = key.default
            should_write = True

    if should_write:
        try:
            write_config(index, path=base)
        except Exception as e:
            sys.stderr.write(
                "Error writing config to {}: {}\nProceeding memory-only\n"
                .format(str(base), e))
    index.update(overrides)
    return index
1014684
def read_envfile(path=None, **overrides):
        
        if path is None:
            frame = inspect.currentframe().f_back
            caller_dir = os.path.dirname(frame.f_code.co_filename)
            path = os.path.join(os.path.abspath(caller_dir), '.env')

        try:
            with open(path, 'r') as f:
                content = f.read()
        except getattr(__builtins__, 'FileNotFoundError', IOError):
            logger.debug('envfile not found at %s, looking in parent dir.',
                         path)
            filedir, filename = os.path.split(path)
            pardir = os.path.abspath(os.path.join(filedir, os.pardir))
            path = os.path.join(pardir, filename)
            if filedir != pardir:
                Env.read_envfile(path, **overrides)
            else:
                # Reached top level directory.
                warnings.warn('Could not any envfile.')
            return

        logger.debug('Reading environment variables from: %s', path)
        for line in content.splitlines():
            tokens = list(shlex.shlex(line, posix=True))
            # parses the assignment statement
            if len(tokens) < 3:
                continue
            name, op = tokens[:2]
            value = ''.join(tokens[2:])
            if op != '=':
                continue
            if not re.match(r'[A-Za-z_][A-Za-z_0-9]*', name):
                continue
            value = value.replace(r'\n', '\n').replace(r'\t', '\t')
            os.environ.setdefault(name, value)

        for name, value in overrides.items():
            os.environ.setdefault(name, value)
157006
def load_config(cls, configfile="logging.yaml"):
        
        configfile = getenv(cls.CONFIGFILE_ENV_KEY, configfile)
        if isfile(configfile):
            with open(configfile, "r") as cf:
                # noinspection PyBroadException
                try:
                    dictConfig(load(cf))
                except ValueError:
                    debug("Learn to config foooo! Improper config at %s", configfile)
                except Exception:
                    exception("Something went wrong while reading %s.", configfile)
        else:
            raise ValueError("Invalid configfile specified: {}".format(configfile))
1011760
def load_config(self, config_source, parameters_source):
        """"""
        with open(config_source) as config_source:
            config_raw = config_source.read()

            parameters = {}
            """Parameteres from file"""
            if os.path.isfile(parameters_source):
                params = self.load_parameters(parameters_source)
                if params is not None:
                    parameters.update(params)

            """Overwrite parameteres with the environment variables"""
            env_params = {}
            env_params.update(os.environ)
            for k, v in env_params.items():
                if is_string(v):
                    env_params[k] = "'" + v + "'"

            parameters.update(env_params)

            """Replace the parameters"""
            final_configuration = config_raw.format(**parameters)
            final_configuration = yaml.safe_load(final_configuration)
            return final_configuration if final_configuration is not None else {}
430615
def update_from_env(yaml_dict, prefix=None):
    '''
    
    '''
    prefix = prefix or ""

    def _set_env_var(path, node):
        env_path = "{0}{1}{2}".format(
            prefix.upper(),
            '_' if prefix else '',
            '_'.join([str(key).upper() for key in path])
        )
        env_val = os.environ.get(env_path, None)
        if env_val is not None:
            # convert the value to a YAML-defined type
            env_dict = yamldict.load('val: {0}'.format(env_val))
            return env_dict.val
        else:
            return None

    # traverse yaml_dict with the callback function
    yaml_dict.traverse(_set_env_var)
1319656
def from_env(cls, hashbang):
    
    paths = os.getenv('PATH', '').split(':')
    for path in paths:
      for fn in cls.expand_path(path):
        basefile = os.path.basename(fn)
        if hashbang == basefile:
          try:
            return cls.from_binary(fn)
          except Exception as e:
            TRACER.log('Could not identify %s: %s' % (fn, e))
890196
function env(file, inject) {
    const envs = {};
    if (!path.isAbsolute(file)) {
        file = path.resolve(process.cwd(), file);
    }
    if (fs.existsSync(file) && fs.lstatSync(file).isFile()) {
        const content = fs.readFileSync(file, 'utf8');
        content.split('\n').forEach(line => {
            const kv = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
            if (kv) {
                const k = kv[1];
                let v = kv[2] || '';
                if (
                    v &&
                    v.length > 0 &&
                    v.charAt(0) === '"' &&
                    v.charAt(v.length - 1) === '"'
                ) {
                    v = v.replace(/\\n/gm, '\n');
                }
                v = v.replace(/(^['"]|['"]$)/g, '').trim();
                envs[k] = v;
            }
        });
    }

    if (inject) {
        Object.keys(envs).forEach(k => {
            if (!(k in process.env)) {
                process.env[k] = envs[k];
            }
        });
    }

    return envs;
}
1147483
def override(settings, yaml=None, env=None):
    
    if yaml is not None:
        if hasattr(yaml, 'read'):
            settings.update(load_yaml(yaml.read()))
        else:
            if os.path.exists(yaml):
                with open(yaml) as f:
                    settings.update(load_yaml(f.read()))

    if env is not None:
        for k, v in os.environ.items():
            if k.startswith(env):
                settings[k[len(env):]] = load_yaml(v)
195556
def load_env(self):
        
        for key, value in self.spec.items():
            if value['type'] in (dict, list):
                envar = (self.env_prefix + "_" + key).upper()
                try:
                    envvar = env.json(envar,
                                      default=getattr(self, key.upper(), value.get('default')))
                except ConfigurationError as _err:  #pragma: no cover
                    print(_err)
                    self.log.critical(f"Error parsing json from env var. {os.environ.get(envar)}")
                    print(envar)
                    raise
            else:
                envvar = env((self.env_prefix + "_" + key).upper(),
                             default=getattr(self, key.upper(), value.get('default')),
                             cast=value['type'])
            setattr(self, key.upper(), envvar)
386032
function load() {
		Object.keys(envs).forEach(function(envName) {
			environments[envName] = envs[envName];
		});
	}
1306701
def load(filename, loader=None, implicit_tuple=True, env={}, schema=None):
  """"""
  with open(filename, 'r') as f:
    return loads(f.read(),
                 filename=filename,
                 loader=loader,
                 implicit_tuple=implicit_tuple,
                 env=env,
                 schema=schema)
1081539
def create_env(env_file):
    """"""

    environ = {}
    with open(env_file, 'r') as f:
        for line in f.readlines():
            line = line.rstrip(os.linesep)
            if '=' not in line:
                continue
            if line.startswith('#'):
                continue
            key, value = line.split('=', 1)
            environ[key] = parse_value(value)
    return environ
567447
def load(pipfile_path=None, inject_env=True):
    

    if pipfile_path is None:
        pipfile_path = Pipfile.find()

    return Pipfile.load(filename=pipfile_path, inject_env=inject_env)
755531
public function loadConfigFile($file, $env = null)
    {
        $file = str_replace('%env%', $env ?: $this->name, $file);
        $config = $this->getFileConfig($file);
        if ($config) {
            $this->wei->setConfig($config);
        }
        return $this;
    }
1049957
def load_config_from_file(app, filepath):
    """"""
    try:
        app.config.from_pyfile(filepath)
        return True
    except IOError:
        # TODO: Can we print to sys.stderr in production? Should this go to
        # logs instead?
        print("Did not find settings file %s for additional settings, skipping it" % filepath, file=sys.stderr)
        return False