Config .env file.
486865
protected function sqliteEnv()
    {
        passthru('sed -i \'s/^DB_/#DB_/g\' .env ', $error);
        if ($error !== 0) {
            $this->output->writeln('<error>Error commenting DB_ entries in .env file </error>');
        }
        passthru('sed -i \'s/.*DB_HOST.*/DB_CONNECTION=sqlite\n&/\' .env', $error);
        if ($error !== 0) {
            $this->output->writeln('<error>Error adding DB_CONNECTION=sqlite to .env file </error>');
        } else {
            $this->output->writeln('.env file updated successfully');
        }
    }
964584
def use_config_file(self):
        """"""
        self.config_file = self.find_config_file()
        if self.config_file:
            self.apply_config_file(self.config_file)
68252
def settings_module(self):
        """"""
        settings_module = parse_conf_data(
            os.environ.get(
                self.ENVVAR_FOR_DYNACONF, self.SETTINGS_FILE_FOR_DYNACONF
            ),
            tomlfy=True,
        )
        if settings_module != getattr(self, "SETTINGS_MODULE", None):
            self.set("SETTINGS_MODULE", settings_module)
        return self.SETTINGS_MODULE
131279
protected function envFileToUseForDefaults()
    {
        $file = config('setup.dot_env.default_file');

        if ($this->envFileExist() &&
            $this->command->confirm('Existing .env file was found. Use it for defaults?', true)
        )
        {
            $file = '.env';
        }

        return $file;
    }
1238627
protected function setupEnvFile()
    {
        $env    = __DIR__ . '/stubs/env.stub';
        $config = $this->database;

        // Update the env stub file with actual credentials.
        $contents = str_replace(
          array_map(function ($key) {
              return '{{' . $key . '}}';
          }, array_keys($config)),
          array_values($config),
          $this->laravel['files']->get($env)
        );

        // Generate a key
        $contents = str_replace('{{key}}', Str::random(32), $contents);

        // Check if we can actually write the environment file.
        if ($this->laravel['files']->put(($envFile = $this->laravel['path.base'] . '/.env'),
            $contents) === false
        ) {
            throw new \RuntimeException("Could not write env file to [$envFile].");
        }

        // Reload env file
        $this->laravel['Illuminate\Foundation\Bootstrap\DetectEnvironment']->bootstrap($this->laravel);

        // Reload config
        $this->laravel['Illuminate\Foundation\Bootstrap\LoadConfiguration']->bootstrap($this->laravel);

    }
324742
def jinja_env(self):
        """"""
        if self._jinja_env is None:
            self._jinja_env = SandboxedEnvironment(
                extensions=[
                    'jinja2.ext.autoescape', 'jinja2.ext.with_', ],
                autoescape=True,
            )
            self._jinja_env.globals['url_for'] = url_for
            # Load whitelisted configuration variables.
            for var in self.app.config['PAGES_WHITELIST_CONFIG_KEYS']:
                self._jinja_env.globals[var] = self.app.config.get(var)
        return self._jinja_env
547862
def ensure_valid_environment_config(module_name, config):
    """"""
    if not config.get('namespace'):
        LOGGER.fatal("staticsite: module %s's environment configuration is "
                     "missing a namespace definition!",
                     module_name)
        sys.exit(1)
988925
def setup_environment_from_config_file():
    

    from os.path import exists

    config_file = get_config_file()

    if not exists(config_file):
        return

    try:
        config = _ConfigParser.SafeConfigParser()
        config.read(config_file)

        __section = "Environment"

        if config.has_section(__section):
            items = config.items(__section)

            for k, v in items:
                try:
                    os.environ[k.upper()] = v
                except Exception as e:
                    print(("WARNING: Error setting environment variable "
                           "'%s = %s' from config file '%s': %s.")
                          % (k, str(v), config_file, str(e)) )
    except Exception as e:
        print("WARNING: Error reading config file '%s': %s." % (config_file, str(e)))
774463
def prepare_env(cls):
        
        os.environ['PATH'] = cls.get_env_path()
        return os.path.basename(Finder.python())
1082416
def master_config(path, env_var='SALT_MASTER_CONFIG', defaults=None, exit_on_config_errors=False):
    '''
    
    '''
    if defaults is None:
        defaults = DEFAULT_MASTER_OPTS.copy()

    if not os.environ.get(env_var, None):
        # No valid setting was given using the configuration variable.
        # Lets see is SALT_CONFIG_DIR is of any use
        salt_config_dir = os.environ.get('SALT_CONFIG_DIR', None)
        if salt_config_dir:
            env_config_file_path = os.path.join(salt_config_dir, 'master')
            if salt_config_dir and os.path.isfile(env_config_file_path):
                # We can get a configuration file using SALT_CONFIG_DIR, let's
                # update the environment with this information
                os.environ[env_var] = env_config_file_path

    overrides = load_config(path, env_var, DEFAULT_MASTER_OPTS['conf_file'])
    default_include = overrides.get('default_include',
                                    defaults['default_include'])
    include = overrides.get('include', [])

    overrides.update(include_config(default_include, path, verbose=False,
                     exit_on_config_errors=exit_on_config_errors))
    overrides.update(include_config(include, path, verbose=True,
                     exit_on_config_errors=exit_on_config_errors))
    opts = apply_master_config(overrides, defaults)
    _validate_ssh_minion_opts(opts)
    _validate_opts(opts)
    # If 'nodegroups:' is uncommented in the master config file, and there are
    # no nodegroups defined, opts['nodegroups'] will be None. Fix this by
    # reverting this value to the default, as if 'nodegroups:' was commented
    # out or not present.
    if opts.get('nodegroups') is None:
        opts['nodegroups'] = DEFAULT_MASTER_OPTS.get('nodegroups', {})
    if salt.utils.data.is_dictlist(opts['nodegroups']):
        opts['nodegroups'] = salt.utils.data.repack_dictlist(opts['nodegroups'])
    apply_sdb(opts)
    return opts
74449
def setup_config(command, filename, section, vars):
    """"""
    conf = appconfig('config:' + filename)
    load_environment(conf.global_conf, conf.local_conf)
741242
def config(name='EMAIL_URL', default='console://'):
    """"""
    conf = {}
    s = env(name, default)
    if s:
        conf = parse_email_url(s)
    return conf
1290790
def _settings_from_env(self):
        """"""
        return {attr: self._val_from_env(env, attr)
                for env, attr in const.ENV_TO_ATTR.items()
                if env in os.environ}
848541
def get_env(env_file='.env'):
    
    try:
        with open(env_file) as f:
            for line in f.readlines():
                try:
                    key, val = line.split('=', maxsplit=1)
                    os.environ.setdefault(key.strip(), val.strip())
                except ValueError:
                    pass
    except FileNotFoundError:
        pass
832375
def get_config_var(self, path, env=None):
        '''
        
        '''
        if env is None:
            env = {}
        result = self.conf
        for e in path.split('.'):
            if e[0] == '$':
                try:
                    result = result[env[e[1:]]]
                except KeyError as ex:
                    try:
                        result = result['.default']
                    except KeyError:
                        raise ex
            else:
                result = result[e]
        return result
546896
private function load($env = 'local', $file = 'config')
    {
        $path = BASE_PATH . ($file === '.env' ? '' : '/config');

        // File paths
        $configPath = "{$path}/{$file}.yml";
        $envConfigPath = "{$path}/{$file}_{$env}.yml";

        if (!file_exists($configPath)) {
            throw new \Exception("Config file not found at \"{$configPath}\".");
        }

        $data = file_get_contents($configPath);

        if ($data === false) {
            throw new \Exception("Unable to load configuration from: {$configPath}");
        }

        $yaml = new Parser();

        // Load config
        $config = $yaml->parse($data);
        $this->config = $config ? $config : [];

        // Load environment specific config
        if (file_exists($envConfigPath)) {
            $data = file_get_contents($envConfigPath);

            if ($data) {
                $config = $yaml->parse($data);
                $config = $config ? $config : [];

                // Merge config values
                $this->config = array_merge($this->config, $config);
            }
        }
    }
162157
def cli(env):
    """"""

    settings = config.get_settings_from_client(env.client)
    env.fout(config.config_table(settings))