# Path: easymode/middleware.py
# USE_SHORT_LANGUAGE_CODES = getattr(settings, 'USE_SHORT_LANGUAGE_CODES', False)
# MATCH_LANGUAGE_CODE = re.compile(
#     r"^/(%s)/.*" % "|".join(map(lambda l: l[0], settings.LANGUAGES)))
# MATCH_SHORT_LANGUAGE_CODE = re.compile(
#     r"^/(%s)/.*" % "|".join(get_short_language_codes()))
#     HREF_REGEX = re.compile(
#         ur'<a([^>]+)href="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l + "/" , get_short_language_codes())), 
#             settings.MEDIA_URL[1:], 
#             settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
#     FORM_REGEX = re.compile(
#         ur'<form([^>]+)action="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l + "/" , get_short_language_codes())),
#              settings.MEDIA_URL[1:],
#              settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
#     HREF_REGEX = re.compile(
#         ur'<a([^>]+)href="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l[0] + "/" , settings.LANGUAGES)), 
#             settings.MEDIA_URL[1:], 
#             settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
#     FORM_REGEX = re.compile(
#         ur'<form([^>]+)action="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l[0] + "/" , settings.LANGUAGES)),
#              settings.MEDIA_URL[1:],
#              settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
# def has_lang_prefix(path):
#     def process_response(self, request, response):
#     def process_request(self, request):
#     def process_response(self, request, response):
#     def process_response(self, request, response):
#     def process_request(self, request):
#     def process_response(self, request, response):
# class NoVaryOnCookieSessionMiddleWare(SessionMiddleware):
# class LocaleFromUrlMiddleWare(LocaleMiddleware):
# class LocaliseUrlsMiddleware(object):
# class ShortLocaleFromUrlMiddleWare(LocaleFromUrlMiddleWare):
# class ShortLocaleLocaliseUrlsMiddleware(LocaliseUrlsMiddleware):
# 
# Path: easymode/utils/languagecode.py
# USE_SHORT_LANGUAGE_CODES = getattr(settings, 'USE_SHORT_LANGUAGE_CODES', False)
#     STRIP_LANGUAGE_CODE_REGEX = re.compile(ur'/(?:%s)/' % "|".join(get_short_language_codes()))
#     STRIP_LANGUAGE_CODE_REGEX = re.compile(ur'/(?:%s)/' % "|".join(get_language_codes()))
# def get_language_codes():
# def get_short_language_codes():
# def get_all_language_codes():
# def get_shorthand_from_language_code(locale):
# def get_language_code_from_shorthand(short_locale):
# def strip_language_code(url):
# def fix_language_code(url, current_language):
# def get_real_fieldname(field, lang):
# def localize_fieldnames(fields, internationalized_fields):
# def get_language_codes_as_disjunction():


from django.conf import settings
from django.http import HttpResponse
from django.test import TestCase
from django.utils.decorators import decorator_from_middleware
from easymode import middleware
from easymode.tests.testcases import initdb
from easymode.utils import languagecode



__all__ = ('TestLocaliseUrlsMiddleware', 'TestLocaleFromUrlMiddleWare')

@decorator_from_middleware(middleware.LocaliseUrlsMiddleware)
def localise_urls_middleware_view(request):
    return HttpResponse("""
    <a href="/example/modifyme.html">hhh</a>
    <a href="/en/example/staysthesame.html">hhh</a>
    <a href="/xx/notareallangugaecode.html"/>
    <a href="/de/reallanguagecode.html"/>
    """)

@initdb
class TestLocaliseUrlsMiddleware(TestCase):
    """Test the middlewares that come with easymode"""

    def tearDown(self):
        self.settingsManager.revert()

# Path: easymode/middleware.py
# USE_SHORT_LANGUAGE_CODES = getattr(settings, 'USE_SHORT_LANGUAGE_CODES', False)
# MATCH_LANGUAGE_CODE = re.compile(
#     r"^/(%s)/.*" % "|".join(map(lambda l: l[0], settings.LANGUAGES)))
# MATCH_SHORT_LANGUAGE_CODE = re.compile(
#     r"^/(%s)/.*" % "|".join(get_short_language_codes()))
#     HREF_REGEX = re.compile(
#         ur'<a([^>]+)href="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l + "/" , get_short_language_codes())), 
#             settings.MEDIA_URL[1:], 
#             settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
#     FORM_REGEX = re.compile(
#         ur'<form([^>]+)action="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l + "/" , get_short_language_codes())),
#              settings.MEDIA_URL[1:],
#              settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
#     HREF_REGEX = re.compile(
#         ur'<a([^>]+)href="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l[0] + "/" , settings.LANGUAGES)), 
#             settings.MEDIA_URL[1:], 
#             settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
#     FORM_REGEX = re.compile(
#         ur'<form([^>]+)action="/(?!(%s|%s|%s))([^"]*)"([^>]*)>' % (
#             "|".join(map(lambda l: l[0] + "/" , settings.LANGUAGES)),
#              settings.MEDIA_URL[1:],
#              settings.ADMIN_MEDIA_PREFIX[1:]
#         )
#     )
# def has_lang_prefix(path):
#     def process_response(self, request, response):
#     def process_request(self, request):
#     def process_response(self, request, response):
#     def process_response(self, request, response):
#     def process_request(self, request):
#     def process_response(self, request, response):
# class NoVaryOnCookieSessionMiddleWare(SessionMiddleware):
# class LocaleFromUrlMiddleWare(LocaleMiddleware):
# class LocaliseUrlsMiddleware(object):
# class ShortLocaleFromUrlMiddleWare(LocaleFromUrlMiddleWare):
# class ShortLocaleLocaliseUrlsMiddleware(LocaliseUrlsMiddleware):
# 
# Path: easymode/utils/languagecode.py
# USE_SHORT_LANGUAGE_CODES = getattr(settings, 'USE_SHORT_LANGUAGE_CODES', False)
#     STRIP_LANGUAGE_CODE_REGEX = re.compile(ur'/(?:%s)/' % "|".join(get_short_language_codes()))
#     STRIP_LANGUAGE_CODE_REGEX = re.compile(ur'/(?:%s)/' % "|".join(get_language_codes()))
# def get_language_codes():
# def get_short_language_codes():
# def get_all_language_codes():
# def get_shorthand_from_language_code(locale):
# def get_language_code_from_shorthand(short_locale):
# def strip_language_code(url):
# def fix_language_code(url, current_language):
# def get_real_fieldname(field, lang):
# def localize_fieldnames(fields, internationalized_fields):
# def get_language_codes_as_disjunction():


# Path: easymode/tests/testcases/testmiddleware.py
from django.conf import settings
from django.http import HttpResponse
from django.test import TestCase
from django.utils.decorators import decorator_from_middleware
from easymode import middleware
from easymode.tests.testcases import initdb
from easymode.utils import languagecode




__all__ = ('TestLocaliseUrlsMiddleware', 'TestLocaleFromUrlMiddleWare')

@decorator_from_middleware(middleware.LocaliseUrlsMiddleware)
def localise_urls_middleware_view(request):
    return HttpResponse("""
    <a href="/example/modifyme.html">hhh</a>
    <a href="/en/example/staysthesame.html">hhh</a>
    <a href="/xx/notareallangugaecode.html"/>
    <a href="/de/reallanguagecode.html"/>
    """)

@initdb
class TestLocaliseUrlsMiddleware(TestCase):
    """Test the middlewares that come with easymode"""

    def tearDown(self):
        self.settingsManager.revert()

        reload(languagecode)