Return the value of an optional environment variable, and use
    the provided default if it's not set.
511219
def get_optional_env(key):
    
    environment_variable_value = os.environ.get(key)
    if environment_variable_value:
        return environment_variable_value
    elif key in CONSTANTS:
        return CONSTANTS[key]
    else:
        raise Exception("The variable {1} is not set".format(key))
1176932
def _default(self, key, default=None):
        
        try:
            value = self.theme.themeables.property(key)
        except KeyError:
            value = None

        return value if value is not None else default
879673
def get_env(name):
    ""
    res = os.environ.get(name,'')
    return res if len(res) else "Unknown"
500085
def get(key, default=None):
    
    try:
        # Attempt to evaluate into python literal
        return ast.literal_eval(os.environ.get(key.upper(), default))
    except (ValueError, SyntaxError):
        return os.environ.get(key.upper(), default)
407141
def required_from_env(key):
    
    val = os.environ.get(key)
    if not val:
        raise ValueError(
            "Required argument '{}' not supplied and not found in environment variables".format(key))
    return val
1153849
def getvar(key, default=None, template='OPENSHIFT_{key}'):
    
    return os.environ.get(template.format(key=key), default)
155757
def env(*vars, **kwargs):
    
    for v in vars:
        value = os.environ.get(v)
        if value:
            return value
    return kwargs.get('default', '')
997819
def get(self, option, default=None):
        ''''''
        val = self[option]
        return (val is None and default) or val
210062
def env(*args, **kwargs):
    
    for arg in args:
        value = os.environ.get(arg, None)
        if value:
            return value
    return kwargs.get("default", "")
209604
def _get_exe(prog):
        ''''''
        if prog in prog_to_env_var:
            env_var = prog_to_env_var[prog]
            if env_var in os.environ:
                return os.environ[env_var]

        return prog_to_default[prog]
1092648
def config(env=DEFAULT_ENV, default=None):
    """"""

    conf = {}

    s = os.environ.get(env, default)

    if s:
        conf = parse(s)

    return conf
1123506
def getenv(name, **kwargs):
    
    default_value = kwargs.pop('default', None)
    desired_type = kwargs.pop('type', str)
    list_separator = kwargs.pop('separator', ',')

    value = os.getenv(name, None)

    if value is None:
        if default_value is None:
            return None
        else:
            return default_value

    if desired_type is bool:
        if value.lower() in ['false', '0']:
            return False
        else:
            return bool(value)

    if desired_type is list or desired_type is tuple:
        value = value.split(list_separator)
        return desired_type(value)

    if desired_type is dict:
        return dict(literal_eval(value))

    return desired_type(value)
788992
def env(key, default=None, required=False):
    
    try:
        value = os.environ[key]
        return ast.literal_eval(value)
    except (SyntaxError, ValueError):
        return value
    except KeyError:
        if default or not required:
            return default
        raise ImproperlyConfigured(
            "Missing required environment variable '%s'" % key)
1279990
public static Boolean getEnvironmentBoolean(String name, Boolean defaultValue) {
        if (envVars == null) {
            throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentBoolean.");
        }

        String value = getEnvironmentString(name, null);

        if (value == null) {
            return defaultValue;
        }
        else {
            return BOOLEAN_PATTERN.matcher(value).matches();
        }
    }
1188979
def from_envvar(self, variable_name):
        
        config_file = os.environ.get(variable_name)
        if not config_file:
            raise RuntimeError(
                "The environment variable %r is not set and "
                "thus configuration could not be loaded." % variable_name
            )
        return self.from_pyfile(config_file)
711759
def has_value(self):
        
        if self._get_envvar_value() is not not_set:
            return True
        else:
            return self.default is not not_set or self._value is not not_set
746623
def default_value(self):
        
        if callable(self.default) and self.call_default:
            return self.default()
        return self.default