

def env(key, default='', factory=None):
    if ((default is RaiseException) and (key not in os.environ)):
        raise KeyError(key)
    val = os.environ.get(key, default)
    if isinstance(val, basestring):
        val = val.strip()
    if (val == default == NotSet):
        return NotSet
    if (factory != NotSet):
        if ((not factory) and (default != NotSet)):
            factory = type(default)
        if factory:
            if (factory == bool):
                if (isinstance(val, basestring) and (val.lower() in ['no', 'false', 'off', '0'])):
                    val = False
            val = factory(val)
    return val

dataset/ETHPy150Open amitu/importd/importd/__init__.py env/original