Used for XDG_* env variables to return fallback if unset *or* empty
344529
def get_xdg_env(env_name, fallback):
    
    env = os.environ.get(env_name)
    return env if env else fallback
169489
function envVars(config, backRef)
{
  backRef = backRef || [];

  Object.keys(config).forEach(function(key)
  {
    var value;

    if (typeof config[key] == 'string')
    {
      // try simple match first, for non-empty value
      value = getVar.call(this, config[key], process.env);

      // if not, try parsing for variables
      if (!hasValue(value))
      {
        value = parseTokens.call(this, config[key], process.env);
      }

      // keep the entry if something's been resolved
      // empty or unchanged value signal otherwise
      if (hasValue(value))
      {
        config[key] = value;
      }
      else
      {
        delete config[key];
      }
    }
    else if (isObject(config[key]))
    {
      envVars.call(this, config[key], backRef.concat(key));
    }
    // Unsupported entry type
    else
    {
      throw new Error('Illegal key type for custom-environment-variables at ' + backRef.concat(key).join('.') + ': ' + Object.prototype.toString.call(config[key]));
    }
  }.bind(this));

  return config;
}
519281
function getIfOverriden() {
    var args = process.argv.slice(2);
    var envFlagIndex = args.indexOf('--env');

    // check if environment string passed as argument
    if (!!~envFlagIndex) {
        return args[++envFlagIndex];
    }
    // check if environment is already set
    else if (isset(process.env.NODE_ENV)) {
        return process.env.NODE_ENV;
    } else {
        return false;
    }


}
1026962
def go_env(self, gopath=None):
    """"""
    # Forcibly nullify the GOPATH if the command does not need one - this can prevent bad user
    # GOPATHs from erroring out commands; see: https://github.com/pantsbuild/pants/issues/2321.
    # NB: As of go 1.8, when GOPATH is unset (set to ''), it defaults to ~/go (assuming HOME is
    # set - and we can't unset that since it might legitimately be used by the subcommand); so we
    # set the GOPATH here to a valid value that nonetheless will fail to work if GOPATH is
    # actually used by the subcommand.
    no_gopath = os.devnull
    return OrderedDict(GOROOT=self.goroot, GOPATH=gopath or no_gopath)
603699
def get(cls, key, default=None, separator='.', global_=False):
        
        # first check environnment variables
        # if we're not in global scope
        if not global_:
            ret = os.environ.get(key.upper().replace('.', '_'))
            if ret is not None:
                return ret

        # then check in local and global configuration unless global_=True
        scopes = ['global'] if global_ else ['local', 'global']
        for scope in scopes:
            ret = cls._get(scope, key, default, separator)
            if ret is not None and ret != default:
                return ret

        if ret is None or ret == default:
            return default
1114952
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is not None:
            return default
        else:
            error_msg = 'The environment variable {} was missing, abort...'\
                        .format(var_name)
            raise EnvironmentError(error_msg)
712180
def get_env_default(self, variable, default):
        
        if variable in os.environ:
            env_var = os.environ[variable]
        else:
            env_var = default
        return env_var
491249
def _conditional_exits(self, block_addr):
        

        vex_block = self.project.factory.block(block_addr).vex
        lst = [ ]

        for i, stmt in enumerate(vex_block.statements):
            if isinstance(stmt, pyvex.IRStmt.Exit):
                lst.append(i)

        return lst
1304728
def get_recipe_env(self, arch=None, with_flags_in_cc=True, clang=False):
        
        if arch is None:
            arch = self.filtered_archs[0]
        return arch.get_env(with_flags_in_cc=with_flags_in_cc, clang=clang)
1338259
def DefaultRC():
    
    xdg = os.path.join(os.path.expanduser('~'), '.config')
    if 'XDG_CONFIG_DIR' in os.environ:
        xdg = os.environ['XDG_CONFIG_DIR']
    xdgfile = os.path.join(xdg, 'cmakelintrc')
    if os.path.exists(xdgfile):
        return xdgfile
    return os.path.join(os.path.expanduser('~'), '.cmakelintrc')
945089
Env<AttrContext> methodEnv(JCMethodDecl tree, Env<AttrContext> env) {
        Env<AttrContext> localEnv =
            env.dup(tree, env.info.dup(env.info.scope.dupUnshared(tree.sym)));
        localEnv.enclMethod = tree;
        if (tree.sym.type != null) {
            //when this is called in the enter stage, there's no type to be set
            localEnv.info.returnResult = attr.new ResultInfo(KindSelector.VAL,
                                                             tree.sym.type.getReturnType());
        }
        if ((tree.mods.flags & STATIC) != 0) localEnv.info.staticLevel++;
        return localEnv;
    }
163066
def getenv_escaped(key: str, default: str = None) -> Optional[str]:
    
    value = os.getenv(key, default)
    # noinspection PyDeprecation
    return cgi.escape(value) if value is not None else None
242352
def env(var_name, default=False):
    
    try:
        value = os.environ[var_name]
        if str(value).strip().lower() in ['false', 'no', 'off' '0', 'none', 'null']:
            return None
        return value
    except:
        from traceback import format_exc
        msg = format_exc() + '\n' + "Unable to find the %s environment variable.\nUsing the value %s (the default) instead.\n" % (var_name, default)
        warnings.warn(msg)
        return default
549662
function error( err, env ) {
	var msg = err.message;
	var out;

	msg += ' Environment variable: `' + env + '`.';
	if ( err instanceof TypeError ) {

		out = new TypeError( msg );
	}
	else if ( err instanceof RangeError ) {
		out = new RangeError( msg );
	}
	else {
		out = new Error( msg );
	}
	return out;
}
1273907
function _setEnv(env) {
    let defaults = {
        scheme: "16",
        isBrowser: false,
        debug: false
    };

    if(env.TINTER_TEST === undefined) {

        //"darwin", "freebsd", "linux", "sunos", "win32"

        // if(env.CLICOLOR === "1") {
        //     // No need to do anything
        // } else {console.warn("Warning: Environment variable CLICOLOR is missing or set to zero/no color.");}

        switch(env.TERM) {
            case "xterm":
                defaults.scheme = "16";
                break; // In theory, just 8!
            case "xterm-color":
                defaults.scheme = "16";
                break;
            case "xterm-16color":
                defaults.scheme = "16";
                break;
            case "xterm-256color":
                switch(env.TERM_PROGRAM) {
                    case "Apple_Terminal":
                        defaults.scheme = "16M";
                        break;
                    case "iTerm.app":
                        defaults.scheme = "16M";
                        break;
                    default:
                        if(env.FORCE_COLOR === "true") {
                            defaults.scheme = "16";
                        } else {
                            defaults.scheme = "256";
                        }
                    // Programs like WS have no TERM_PROGRAM VALUE... assume 8/16-color only
                }
                break;
        }

        // TODO - implement smart color selection if COLORFGBG is set.
        // if(env.COLORFGBG !== undefined) {
        //     let [fg, bg] = env.COLORFGBG.split(";");
        //     console.log(`setEnv: FG: ${fg}`);
        //     console.log(`setEnv: BG: ${bg}`);
        // }
    } else if(schemes.includes(env.TINTER_TEST)) {
        defaults.scheme = env.TINTER_TEST;
    }
    return defaults;
}
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
1113612
def prev_deps(env):
    """"""
    # TODO something more clever.
    if not os.path.isfile(env.envctoxfile):
        return []

    with open(env.envctoxfile) as f:
        return f.read().split()