build a list of variables from ENV_FILE and yeilds it
488690
def get_variables
      return unless File.exists?(ENV_FILE)

      File.open(ENV_FILE).each do |line|
        var_name = line.split("=").first
        yield var_name unless line =~ /^\#/
      end
    end
352276
def with_environment(env)
      old_env = {}
      env.each do |var, value|
        old_env[var] = ENV[var.to_s]
        ENV[var.to_s] = value
      end

      yield
    ensure
      old_env.each { |var, value| ENV[var.to_s] = value }
    end
741303
def set_env_vars(variables)
      save_vars = {}
      variables.each do |k, v|
        k = k.to_s
        save_vars[k] = ENV[k]
        ENV[k] = v.nil? ? v : v.to_s
      end
      begin
        yield
      ensure
        variables.each_key do |k|
          k = k.to_s
          ENV[k] = save_vars[k]
        end
      end
      true
    end
770283
def _include_paths_from_environ(env_prefix=''):
    """"""
    paths = os.environ.get(env_prefix + 'WSGI_AUTH_PATHS')
    if not paths:
        return []
    return paths.split(';')
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)
155757
def env(*vars, **kwargs):
    
    for v in vars:
        value = os.environ.get(v)
        if value:
            return value
    return kwargs.get('default', '')
1010654
def load_environment_vars(self):
        
        for k, v in os.environ.items():
            if k.startswith(MACH9_PREFIX):
                _, config_key = k.split(MACH9_PREFIX, 1)
                self[config_key] = v
597489
def environment_variables
      global_variables = @config.environment_variables
      process_vars = @config.process_options[@name] ? @config.process_options[@name]['env'] || {} : {}
      process_local_vars = @config.local_process_options[@name] ? @config.local_process_options[@name]['env'] || {} : {}
      global_variables.merge(process_vars.merge(process_local_vars)).each_with_object({}) do |(key, value), hash|
        hash[key.to_s] = value.to_s
      end
    end
1127785
def symlink_list(load):
    '''
    
    '''
    if 'env' in load:
        # "env" is not supported; Use "saltenv".
        load.pop('env')

    ret = {}
    if load['saltenv'] not in __opts__['file_roots'] and '__env__' not in __opts__['file_roots']:
        return ret

    if 'prefix' in load:
        prefix = load['prefix'].strip('/')
    else:
        prefix = ''

    symlinks = _file_lists(load, 'links')
    return dict([(key, val)
                 for key, val in six.iteritems(symlinks)
                 if key.startswith(prefix)])
527445
def write_env_vars(env_vars=None):  # type: (dict) -> None
    
    env_vars = env_vars or {}
    env_vars['PYTHONPATH'] = ':'.join(sys.path)

    for name, value in env_vars.items():
        os.environ[name] = value
1314361
def generate(env):
    """"""
    link.generate(env)
    
    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -G')

    env['RPATHPREFIX'] = '-R'
    env['RPATHSUFFIX'] = ''
    env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'

    # Support for versioned libraries
    link._setup_versioned_lib_variables(env, tool = 'sunlink', use_soname = True) 
    env['LINKCALLBACKS'] = link._versioned_lib_callbacks()
85766
def _list(env, key, more, loader, _all=False, output=None):
    
    if env:
        env = env.strip()
    if key:
        key = key.strip()
    if loader:
        loader = loader.strip()

    if env:
        settings.setenv(env)

    cur_env = settings.current_env.lower()

    click.echo(
        click.style(
            "Working in %s environment " % cur_env,
            bold=True,
            bg="blue",
            fg="bright_black",
        )
    )

    if not loader:
        data = settings.as_dict(env=env, internal=_all)
    else:
        identifier = "{}_{}".format(loader, cur_env)
        data = settings._loaded_by_loaders.get(identifier, {})
        data = data or settings._loaded_by_loaders.get(loader, {})

    # remove to avoid displaying twice
    data.pop("SETTINGS_MODULE", None)

    def color(_k):
        if _k in dir(default_settings):
            return "blue"
        return "green"

    if not key:
        datalines = "\n".join(
            "%s: %s"
            % (click.style(k, bg=color(k), fg="white"), pprint.pformat(v))
            for k, v in data.items()
        )
        (click.echo_via_pager if more else click.echo)(datalines)
        if output:
            with open(output, "w") as output_file:
                json.dump({cur_env: data}, output_file)
    else:
        key = key.upper()
        value = data.get(key)
        if not value:
            click.echo(click.style("Key not found", bg="red", fg="white"))
            return
        click.echo(
            "%s: %s"
            % (
                click.style(key.upper(), bg=color(key), fg="white"),
                pprint.pformat(value),
            )
        )
        if output:
            with open(output, "w") as output_file:
                json.dump({cur_env: {key.upper(): value}}, output_file)

    if env:
        settings.setenv()
104898
def get_env_args(env):
    """"""
    for arg, val in env.vars.get('global_args', {}).items():
        if val is True:
            yield '--%s' % arg
        elif isinstance(val, int):
            for _ in range(val):
                yield '--%s' % arg
        elif val is None:
            continue
        else:
            yield '--%s=%s' % (arg, val)
1202225
def from_env(cls):
        """"""
        token = getenv(cls.TOKEN_ENV_VAR)
        if token is None:
            msg = 'missing environment variable: {!r}'.format(cls.TOKEN_ENV_VAR)
            raise ValueError(msg)
        return cls(api_token=token)
89505
def list_envs():
    """"""
    for env in lib.get_environments():
        margin_left = lib.get_margin(len(env['name']))
        print("{0}{1}{2}".format(
            env['name'], margin_left,
            env.get('description', '(no description)')))
1230915
def added_env_paths(env_vars, env=None):
    
    if not env_vars:
        return None

    if not env:
        env = dict(os.environ)

    result = dict(env)
    for env_var, paths in env_vars.items():
        separator = paths[0]
        paths = paths[1:]
        current = env.get(env_var, "")
        current = [x for x in current.split(separator) if x]

        added = 0
        for path in paths.split(separator):
            if path not in current:
                added += 1
                current.append(path)

        if added:
            result[env_var] = separator.join(current)

    return result
400856
def load_env(file):
    

    env = yaml.load(open(file))

    for org in env.get('organizations', []):
        if not org.get('applications'):
            org['applications'] = []

        if org.get('starter-kit'):
            kit_meta = get_starter_kit_meta(org.get('starter-kit'))
            for meta_app in get_applications_from_metadata(kit_meta):
                org['applications'].append(meta_app)

        if org.get('meta'):
            for meta_app in get_applications_from_metadata(org.get('meta')):
                org['applications'].append(meta_app)

        for app in org.get('applications', []):
            if app.get('file'):
                app['file'] = os.path.realpath(os.path.join(os.path.dirname(file), app['file']))
    return env