bananas/environment.py
def get_settings():
    """
    Get and parse prefixed django settings from env.

    TODO: Implement support for complex settings
        DATABASES = {}
        CACHES = {}
        INSTALLED_APPS -> EXCLUDE_APPS ?

    :return dict:
    """
    settings = {}
    prefix = environ.get("DJANGO_SETTINGS_PREFIX", "DJANGO_")

    for key, value in environ.items():
        _, _, key = key.partition(prefix)
        if key:
            if key in UNSUPPORTED_ENV_SETTINGS:
                raise ValueError(
                    'Django setting "{}" can not be '
                    "configured through environment.".format(key)
                )

            default_value = getattr(global_settings, key, UNDEFINED)

            if default_value is not UNDEFINED:
                if default_value is None and key in SETTINGS_TYPES.keys():
                    # Handle typed django settings defaulting to None
                    parse = get_parser(SETTINGS_TYPES[key])
                else:
                    # Determine parser by django setting type
                    parse = get_parser(type(default_value))

                value = parse(value)

            settings[key] = value

    return settings
def get_settings():
    settings = {}
    prefix = environ.get("DJANGO_SETTINGS_PREFIX", "DJANGO_")

    for key, value in environ.items():
        _, _, key = key.partition(prefix)
        if key:
            if key in UNSUPPORTED_ENV_SETTINGS:
                raise ValueError(
                    'Django setting "{}" can not be '
                    "configured through environment.".format(key)
                )

            default_value = getattr(global_settings, key, UNDEFINED)

            if default_value is not UNDEFINED:
                if default_value is None and key in SETTINGS_TYPES.keys():
                    # Handle typed django settings defaulting to None
                    parse = get_parser(SETTINGS_TYPES[key])
                else:
                    # Determine parser by django setting type
                    parse = get_parser(type(default_value))

                value = parse(value)

            settings[key] = value

    return settings
def get_settings ( ) : settings = { } prefix = environ . get ( "DJANGO_SETTINGS_PREFIX" , "DJANGO_" ) for key , value in environ . items ( ) : _ , _ , key = key . partition ( prefix ) if key : if key in UNSUPPORTED_ENV_SETTINGS : raise ValueError ( 'Django setting "{}" can not be ' "configured through environment." . format ( key ) ) default_value = getattr ( global_settings , key , UNDEFINED ) if default_value is not UNDEFINED : if default_value is None and key in SETTINGS_TYPES . keys ( ) : # Handle typed django settings defaulting to None parse = get_parser ( SETTINGS_TYPES [ key ] ) else : # Determine parser by django setting type parse = get_parser ( type ( default_value ) ) value = parse ( value ) settings [ key ] = value return settings
Get and parse prefixed django settings from env.

    TODO: Implement support for complex settings
        DATABASES = {}
        CACHES = {}
        INSTALLED_APPS -> EXCLUDE_APPS ?

    :return dict:
Get and parse prefixed django settings from env .