from os import environ
from banal.bools import as_bool


def get(name, default=None):
    value = environ.get(name)
    if value is not None:
        return str(value)
    if default is not None:
        return str(default)


def to_int(name, default=0):
    """Extract an integer from the environment."""
    try:
        return int(get(name))
    except (TypeError, ValueError):
        return default


def to_bool(name, default=False):
    """Extract a boolean value from the environment consistently."""
    return as_bool(get(name), default=default)


def to_list(name, default=[], separator=":"):
    """Extract a list of values from the environment consistently.
    Multiple values are by default expected to be separated by a colon (':'),
    like in the UNIX $PATH variable.
    """
    value = get(name)
    if value is None:
        return list(default)
    return [e.strip() for e in value.split(separator)]

e10c66a66436b2924cc9b44cce3f0b1af42fe161
<mask token>


def get(name, default=None):
    value = environ.get(name)
    if value is not None:
        return str(value)
    if default is not None:
        return str(default)


def to_int(name, default=0):
    """Extract an integer from the environment."""
    try:
        return int(get(name))
    except (TypeError, ValueError):
        return default


<mask token>

<mask token>


def get(name, default=None):
    value = environ.get(name)
    if value is not None:
        return str(value)
    if default is not None:
        return str(default)


def to_int(name, default=0):
    """Extract an integer from the environment."""
    try:
        return int(get(name))
    except (TypeError, ValueError):
        return default


<mask token>


def to_list(name, default=[], separator=':'):
    """Extract a list of values from the environment consistently.
    Multiple values are by default expected to be separated by a colon (':'),
    like in the UNIX $PATH variable.
    """
    value = get(name)
    if value is None:
        return list(default)
    return [e.strip() for e in value.split(separator)]

<mask token>


def get(name, default=None):
    value = environ.get(name)
    if value is not None:
        return str(value)
    if default is not None:
        return str(default)


def to_int(name, default=0):
    """Extract an integer from the environment."""
    try:
        return int(get(name))
    except (TypeError, ValueError):
        return default


def to_bool(name, default=False):
    """Extract a boolean value from the environment consistently."""
    return as_bool(get(name), default=default)


def to_list(name, default=[], separator=':'):
    """Extract a list of values from the environment consistently.
    Multiple values are by default expected to be separated by a colon (':'),
    like in the UNIX $PATH variable.
    """
    value = get(name)
    if value is None:
        return list(default)
    return [e.strip() for e in value.split(separator)]

from os import environ
from banal.bools import as_bool


def get(name, default=None):
    value = environ.get(name)
    if value is not None:
        return str(value)
    if default is not None:
        return str(default)


def to_int(name, default=0):
    """Extract an integer from the environment."""
    try:
        return int(get(name))
    except (TypeError, ValueError):
        return default


def to_bool(name, default=False):
    """Extract a boolean value from the environment consistently."""
    return as_bool(get(name), default=default)


def to_list(name, default=[], separator=':'):
    """Extract a list of values from the environment consistently.
    Multiple values are by default expected to be separated by a colon (':'),
    like in the UNIX $PATH variable.
    """
    value = get(name)
    if value is None:
        return list(default)
    return [e.strip() for e in value.split(separator)]

from os import environ
from banal.bools import as_bool


def get(name, default=None):
    value = environ.get(name)
    if value is not None:
        return str(value)
    if default is not None:
        return str(default)


def to_int(name, default=0):
    """Extract an integer from the environment."""
    try:
        return int(get(name))
    except (TypeError, ValueError):
        return default


def to_bool(name, default=False):
    """Extract a boolean value from the environment consistently."""
    return as_bool(get(name), default=default)


def to_list(name, default=[], separator=":"):
    """Extract a list of values from the environment consistently.
    Multiple values are by default expected to be separated by a colon (':'),
    like in the UNIX $PATH variable.
    """
    value = get(name)
    if value is None:
        return list(default)
    return [e.strip() for e in value.split(separator)]
