Shortcut for run_getgist() reading username from env var
192758
def run_getmy(filename, **kwargs):
    """"""
    assume_yes = kwargs.get("yes_to_all")
    user = getenv("GETGIST_USER")
    getgist = GetGist(user=user, filename=filename, assume_yes=assume_yes)
    getgist.get()
885202
def env(*_vars, **kwargs):
    
    for v in _vars:
        value = os.environ.get(v, None)
        if value:
            return value
    return kwargs.get('default', '')
356916
function getPathVariableName() {
    // windows calls it's path 'Path' usually, but this is not guaranteed.
    if (process.platform === 'win32') {
        for (const key of Object.keys(process.env))
            if (key.match(/^PATH$/i))
                return key;
        return 'Path';
    }
    return "PATH";
}
12786
def show(config, username):  # pragma: no cover
        """"""
        client = Client()
        client.prepare_connection()
        key_api = API(client)
        for key, value in key_api.get_keys_from_ldap(username).items():
            print(value)
662405
function getUser (argv, next) {
  if (argv.user) return next()

  const conf = rc('npm')
  if (!conf) return next('no npm config found')

  const github = conf['init.author.github']
  if (!github) return next('no init.author.github set')

  const name = conf['init.author.name']
  if (!name) return next('no init.author.name set')

  argv.user = github
  argv.realName = name
  next()
}
387346
def run_putgist(filename, user, **kwargs):
    """"""
    assume_yes = kwargs.get("yes_to_all")
    private = kwargs.get("private")
    getgist = GetGist(
        user=user,
        filename=filename,
        assume_yes=assume_yes,
        create_private=private,
        allow_none=True,
    )
    getgist.put()
1039262
def cli(obj, show_userinfo):
    """"""
    client = obj['client']
    userinfo = client.userinfo()
    if show_userinfo:
        for k, v in userinfo.items():
            if isinstance(v, list):
                v = ', '.join(v)
            click.echo('{:20}: {}'.format(k, v))
    else:
        click.echo(userinfo['preferred_username'])
1153849
def getvar(key, default=None, template='OPENSHIFT_{key}'):
    
    return os.environ.get(template.format(key=key), default)
1290413
def override_env_variables():
    """"""
    env_vars = ("LOGNAME", "USER", "LNAME", "USERNAME")
    old = [os.environ[v] if v in os.environ else None for v in env_vars]

    for v in env_vars:
        os.environ[v] = "test"
    yield

    for i, v in enumerate(env_vars):
        if old[i]:
            os.environ[v] = old[i]
142897
def get_api_envs():
    """"""
    client_id = os.environ.get('CLIENT_ID')
    user_id = os.environ.get('USER_ID')
    if not client_id or not user_id:
        raise ValueError('API keys are not found in the environment')
    return client_id, user_id
195831
def _parse_username(self, config):
        
        (username, priv, role, nopass, fmt, secret, sshkey) = config
        resource = dict()
        resource['privilege'] = priv
        resource['role'] = role
        resource['nopassword'] = nopass == 'nopassword'
        resource['format'] = fmt
        resource['secret'] = secret
        resource['sshkey'] = sshkey
        return {username: resource}
100240
def cli(obj, username):
    """"""
    client = obj['client']
    provider = obj['provider']
    client_id = obj['client_id']

    try:
        if provider == 'azure':
            token = azure.login(client, obj['azure_tenant'], client_id)['token']
        elif provider == 'github':
            token = github.login(client, obj['github_url'], client_id)['token']
        elif provider == 'gitlab':
            token = gitlab.login(client, obj['gitlab_url'], client_id)['token']
        elif provider == 'google':
            if not username:
                username = click.prompt('Email')
            token = google.login(client, username, client_id)['token']
        elif provider == 'openid':
            token = oidc.login(client, obj['oidc_auth_url'], client_id)['token']
        elif provider == 'basic':
            if not username:
                username = click.prompt('Email')
            password = click.prompt('Password', hide_input=True)
            token = client.login(username, password)['token']
        else:
            click.echo('ERROR: unknown provider {provider}'.format(provider=provider))
            sys.exit(1)
    except Exception as e:
        raise AuthError(e)

    jwt = Jwt()
    preferred_username = jwt.parse(token)['preferred_username']
    if preferred_username:
        save_token(client.endpoint, preferred_username, token)
        click.echo('Logged in as {}'.format(preferred_username))
    else:
        click.echo('Failed to login.')
        sys.exit(1)
913971
def read_user_config(username, path=settings.LOGIN_FILE):
    
    return _decode_config(load_users(path=path)[username]["full_name"])
747365
def get_user_cmd(node_dict):
    """"""
    key_lu = {"q": ["quit", True], "r": ["run", True],
              "s": ["stop", True], "u": ["update", True],
              "c": ["connect", True], "d": ["details", True]}
    ui_cmd_bar()
    cmd_valid = False
    input_flush()
    with term.cbreak():
        while not cmd_valid:
            val = input_by_key()
            cmd_name, cmd_valid = key_lu.get(val.lower(), ["invalid", False])
            if not cmd_valid:
                ui_print(" - {0}Invalid Entry{1}".format(C_ERR, C_NORM))
                sleep(0.5)
                ui_cmd_bar()
    return cmd_name
353106
def env(var_name, default=False):
    
    try:
        value = os.environ[var_name]
        if str(value).strip().lower() in ['false', 'f', 'no', 'off' '0', 'none', 'null', '', ]:
            return None
        return value
    except:
        from traceback import format_exc
        msg = "Unable to find the %s environment variable.\nUsing the value %s (the default) instead.\n" % (var_name, default)
        sys.stderr.write(format_exc())
        sys.stderr.write(msg)
        return default
1179911
def load_variables():
    """"""
    if (not os.environ.get("PYCONFLUENCE_TOKEN") or
            not os.environ.get("PYCONFLUENCE_USER") or
            not os.environ.get("PYCONFLUENCE_ORG")):
        print ("One or more pyconfluence environment variables are not set. "
               "See README for directions on how to resolve this.")
        sys.exit("Error")

    global token
    global user
    global base_url
    token = os.environ["PYCONFLUENCE_TOKEN"]
    user = os.environ["PYCONFLUENCE_USER"]
    base_url = ("https://" + os.environ["PYCONFLUENCE_ORG"] + ".atlassian"
                ".net/wiki/rest/api/content")
960661
def envget(var, default=None):
    """"""

    if 'pyraf' in sys.modules:
        #ONLY if pyraf is already loaded, import iraf into the namespace
        from pyraf import iraf
    else:
        # else set iraf to None so it knows to not use iraf's environment
        iraf = None

    try:
        if iraf:
            return iraf.envget(var)
        else:
            raise KeyError
    except KeyError:
        try:
            return _varDict[var]
        except KeyError:
            try:
                return os.environ[var]
            except KeyError:
                if default is not None:
                    return default
                elif var == 'TERM':
                    # Return a default value for TERM
                    # TERM gets caught as it is found in the default
                    # login.cl file setup by IRAF.
                    print("Using default TERM value for session.")
                    return 'xterm'
                else:
                    raise KeyError("Undefined environment variable `%s'" % var)