bananas/url.py
def get_engine(scheme):
    """
    Perform a lookup in _ENGINE_MAPPING using engine_string.

    :param scheme: '+'-separated string Maximum of 2 parts,
    i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK.
    :return: Engine string
    """
    path = scheme.split("+")
    first, rest = path[0], path[1:]

    second = rest[0] if rest else None

    engine = resolve(ENGINE_MAPPING, first)

    # If the selected engine does not have a second level.
    if not isinstance(engine, list):
        # If second level engine was expected
        if second:
            raise KeyError("%s has no sub-engines" % first)

        return engine

    try:
        engine, extra = engine
    except ValueError:
        # engine was not a list of length 2
        raise ValueError(
            "django-bananas.url' engine "
            "configuration is invalid: %r" % ENGINE_MAPPING
        )

    # Get second-level engine
    if second is not None:
        engine = resolve(extra, second)

    # Sanity-check the value before returning
    assert not isinstance(
        engine, (list, dict)
    ), "Only two levels of engines " "are allowed"
    assert engine, "The returned engine is not truthy"

    return engine
def get_engine(scheme):
    """
    Perform a lookup in _ENGINE_MAPPING using engine_string.

    :param scheme: '+'-separated string Maximum of 2 parts,
    i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK.
    :return: Engine string
    """
    path = scheme.split("+")
    first, rest = path[0], path[1:]

    second = rest[0] if rest else None

    engine = resolve(ENGINE_MAPPING, first)

    # If the selected engine does not have a second level.
    if not isinstance(engine, list):
        # If second level engine was expected
        if second:
            raise KeyError("%s has no sub-engines" % first)

        return engine

    try:
        engine, extra = engine
    except ValueError:
        # engine was not a list of length 2
        raise ValueError(
            "django-bananas.url' engine "
            "configuration is invalid: %r" % ENGINE_MAPPING
        )

    # Get second-level engine
    if second is not None:
        engine = resolve(extra, second)

    # Sanity-check the value before returning
    assert not isinstance(
        engine, (list, dict)
    ), "Only two levels of engines " "are allowed"
    assert engine, "The returned engine is not truthy"

    return engine
Perform a lookup in _ENGINE_MAPPING using engine_string.

    :param scheme: '+'-separated string Maximum of 2 parts,
    i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK.
    :return: Engine string