# Path: src/slim/exceptions.py
# class LocaleurlImportError(ImportError):
#     """LocaleUrl import error exception."""
# 
#     # This is as good as deprecated.
# 
# Path: src/slim/utils.py
# def locale_url_is_installed():
#     """Check if localeurl is installed in the Django project.
# 
#     :return bool:
#     """
#     # This is good as deprecated.
# 
#     if USE_LOCALEURL is True \
#             and 'localeurl' in settings.INSTALLED_APPS \
#             and 'localeurl.middleware.LocaleURLMiddleware' \
#                 in settings.MIDDLEWARE_CLASSES:
#         return True
#     return False


from ..exceptions import LocaleurlImportError
from ..utils import locale_url_is_installed
    from localeurl.templatetags.localeurl_tags import chlocale
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = (
    'prepend_language',
    'localeurl_prepend_language',
    'auto_prepend_language'
)


def prepend_language(func, language_field='language'):
    """Prepend the language from the model to the path resolved."""
    def inner(self, *args, **kwargs):
        return "/%s%s" % (getattr(self, language_field),
                          func(self, *args, **kwargs))
    return inner

if LOCALE_URL_IS_IMPORTABLE:
    # Note, that ``localeurl_prepend_language`` is to be deprecated soon.

    def localeurl_prepend_language(func, language_field='language'):
        """Prepend the language from the model to the path resolved.

        Used when `django-localeurl` package is used."""
        def inner(self, *args, **kwargs):
            return chlocale(func(self, *args, **kwargs),
                            getattr(self, language_field))
        return inner

    # If `localeurl` is available gets the `localeurl` based decorator.
    # Otherwise, gets `prepend_language` based decorator.
    if locale_url_is_installed():

# Path: src/slim/exceptions.py
# class LocaleurlImportError(ImportError):
#     """LocaleUrl import error exception."""
# 
#     # This is as good as deprecated.
# 
# Path: src/slim/utils.py
# def locale_url_is_installed():
#     """Check if localeurl is installed in the Django project.
# 
#     :return bool:
#     """
#     # This is good as deprecated.
# 
#     if USE_LOCALEURL is True \
#             and 'localeurl' in settings.INSTALLED_APPS \
#             and 'localeurl.middleware.LocaleURLMiddleware' \
#                 in settings.MIDDLEWARE_CLASSES:
#         return True
#     return False


# Path: src/slim/models/decorators.py
from ..exceptions import LocaleurlImportError
from ..utils import locale_url_is_installed
    from localeurl.templatetags.localeurl_tags import chlocale

__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = (
    'prepend_language',
    'localeurl_prepend_language',
    'auto_prepend_language'
)


def prepend_language(func, language_field='language'):
    """Prepend the language from the model to the path resolved."""
    def inner(self, *args, **kwargs):
        return "/%s%s" % (getattr(self, language_field),
                          func(self, *args, **kwargs))
    return inner

if LOCALE_URL_IS_IMPORTABLE:
    # Note, that ``localeurl_prepend_language`` is to be deprecated soon.

    def localeurl_prepend_language(func, language_field='language'):
        """Prepend the language from the model to the path resolved.

        Used when `django-localeurl` package is used."""
        def inner(self, *args, **kwargs):
            return chlocale(func(self, *args, **kwargs),
                            getattr(self, language_field))
        return inner

    # If `localeurl` is available gets the `localeurl` based decorator.
    # Otherwise, gets `prepend_language` based decorator.
    if locale_url_is_installed():

        auto_prepend_language = localeurl_prepend_language