# Path: werkzeug/_compat.py
# PY2 = sys.version_info[0] == 2
#     def fix_tuple_repr(obj):
#         def __repr__(self):
#     def implements_iterator(cls):
#     def implements_to_string(cls):
#     def native_string_result(func):
#         def wrapper(*args, **kwargs):
#     def implements_bool(cls):
#     def make_literal_wrapper(reference):
#     def normalize_string_tuple(tup):
#     def try_coerce_native(s):
#     def wsgi_decoding_dance(s, charset='utf-8', errors='replace'):
#     def wsgi_encoding_dance(s, charset='utf-8', errors='replace'):
#     def to_bytes(x, charset=sys.getdefaultencoding(), errors='strict'):
#     def to_native(x, charset=sys.getdefaultencoding(), errors='strict'):
#     def iter_bytes(b):
#     def reraise(tp, value, tb=None):
#     def make_literal_wrapper(reference):
#     def normalize_string_tuple(tup):
#     def wsgi_get_bytes(s):
#     def wsgi_decoding_dance(s, charset='utf-8', errors='replace'):
#     def wsgi_encoding_dance(s, charset='utf-8', errors='replace'):
#     def to_bytes(x, charset=sys.getdefaultencoding(), errors='strict'):
#     def to_native(x, charset=sys.getdefaultencoding(), errors='strict'):
# def to_unicode(x, charset=sys.getdefaultencoding(), errors='strict',
#                allow_none_charset=False):
# 
# Path: werkzeug/_internal.py
# class _Missing(object):
# class _DictAccessorProperty(object):
#     def __repr__(self):
#     def __reduce__(self):
# def _get_environ(obj):
# def _log(type, message, *args, **kwargs):
# def _parse_signature(func):
#     def parse(args, kwargs):
# def _date_to_unix(arg):
#     def __init__(self, name, default=None, load_func=None, dump_func=None,
#                  read_only=None, doc=None):
#     def __get__(self, obj, type=None):
#     def __set__(self, obj, value):
#     def __delete__(self, obj):
#     def __repr__(self):
# def _cookie_quote(b):
# def _cookie_unquote(b):
# def _cookie_parse_impl(b):
# def _encode_idna(domain):
# def _decode_idna(domain):
# def _make_cookie_domain(domain):
# def _easteregg(app=None):
#     def bzzzzzzz(gyver):
#     def easteregged(environ, start_response):
#         def injecting_start_response(status, headers, exc_info=None):


import re
import os
import sys
import pkgutil
    from html.entities import name2codepoint
    from htmlentitydefs import name2codepoint
from werkzeug._compat import unichr, text_type, string_types, iteritems, \
    reraise, PY2
from werkzeug._internal import _DictAccessorProperty, \
     _parse_signature, _missing
        from unicodedata import normalize
        from warnings import warn
    from werkzeug.wrappers import Response
        from werkzeug.urls import iri_to_uri
from werkzeug.http import quote_header_value, unquote_header_value, \
     cookie_date
from werkzeug.datastructures import MultiDict, CombinedMultiDict, \
     Headers, EnvironHeaders
from werkzeug.http import parse_cookie, dump_cookie
        return x
    return _format_re.sub(lookup_arg, string)


def secure_filename(filename):
    r"""Pass it a filename and it will return a secure version of it.  This
    filename can then safely be stored on a regular file system and passed
    to :func:`os.path.join`.  The filename returned is an ASCII only string
    for maximum portability.

    On windows system the function also makes sure that the file is not
    named after one of the special device files.

    >>> secure_filename("My cool movie.mov")
    'My_cool_movie.mov'
    >>> secure_filename("../../../etc/passwd")
    'etc_passwd'
    >>> secure_filename(u'i contain cool \xfcml\xe4uts.txt')
    'i_contain_cool_umlauts.txt'

    The function might return an empty filename.  It's your responsibility
    to ensure that the filename is unique and that you generate random
    filename if the function returned an empty one.

    .. versionadded:: 0.5

    :param filename: the filename to secure
    """
    if isinstance(filename, text_type):
        filename = normalize('NFKD', filename).encode('ascii', 'ignore')

# Path: werkzeug/_compat.py
# PY2 = sys.version_info[0] == 2
#     def fix_tuple_repr(obj):
#         def __repr__(self):
#     def implements_iterator(cls):
#     def implements_to_string(cls):
#     def native_string_result(func):
#         def wrapper(*args, **kwargs):
#     def implements_bool(cls):
#     def make_literal_wrapper(reference):
#     def normalize_string_tuple(tup):
#     def try_coerce_native(s):
#     def wsgi_decoding_dance(s, charset='utf-8', errors='replace'):
#     def wsgi_encoding_dance(s, charset='utf-8', errors='replace'):
#     def to_bytes(x, charset=sys.getdefaultencoding(), errors='strict'):
#     def to_native(x, charset=sys.getdefaultencoding(), errors='strict'):
#     def iter_bytes(b):
#     def reraise(tp, value, tb=None):
#     def make_literal_wrapper(reference):
#     def normalize_string_tuple(tup):
#     def wsgi_get_bytes(s):
#     def wsgi_decoding_dance(s, charset='utf-8', errors='replace'):
#     def wsgi_encoding_dance(s, charset='utf-8', errors='replace'):
#     def to_bytes(x, charset=sys.getdefaultencoding(), errors='strict'):
#     def to_native(x, charset=sys.getdefaultencoding(), errors='strict'):
# def to_unicode(x, charset=sys.getdefaultencoding(), errors='strict',
#                allow_none_charset=False):
# 
# Path: werkzeug/_internal.py
# class _Missing(object):
# class _DictAccessorProperty(object):
#     def __repr__(self):
#     def __reduce__(self):
# def _get_environ(obj):
# def _log(type, message, *args, **kwargs):
# def _parse_signature(func):
#     def parse(args, kwargs):
# def _date_to_unix(arg):
#     def __init__(self, name, default=None, load_func=None, dump_func=None,
#                  read_only=None, doc=None):
#     def __get__(self, obj, type=None):
#     def __set__(self, obj, value):
#     def __delete__(self, obj):
#     def __repr__(self):
# def _cookie_quote(b):
# def _cookie_unquote(b):
# def _cookie_parse_impl(b):
# def _encode_idna(domain):
# def _decode_idna(domain):
# def _make_cookie_domain(domain):
# def _easteregg(app=None):
#     def bzzzzzzz(gyver):
#     def easteregged(environ, start_response):
#         def injecting_start_response(status, headers, exc_info=None):


# Path: werkzeug/utils.py
import re
import os
import sys
import pkgutil
    from html.entities import name2codepoint
    from htmlentitydefs import name2codepoint
from werkzeug._compat import unichr, text_type, string_types, iteritems, \
    reraise, PY2
from werkzeug._internal import _DictAccessorProperty, \
     _parse_signature, _missing
        from unicodedata import normalize
        from warnings import warn
    from werkzeug.wrappers import Response
        from werkzeug.urls import iri_to_uri
from werkzeug.http import quote_header_value, unquote_header_value, \
     cookie_date
from werkzeug.datastructures import MultiDict, CombinedMultiDict, \
     Headers, EnvironHeaders
from werkzeug.http import parse_cookie, dump_cookie

        return x
    return _format_re.sub(lookup_arg, string)


def secure_filename(filename):
    r"""Pass it a filename and it will return a secure version of it.  This
    filename can then safely be stored on a regular file system and passed
    to :func:`os.path.join`.  The filename returned is an ASCII only string
    for maximum portability.

    On windows system the function also makes sure that the file is not
    named after one of the special device files.

    >>> secure_filename("My cool movie.mov")
    'My_cool_movie.mov'
    >>> secure_filename("../../../etc/passwd")
    'etc_passwd'
    >>> secure_filename(u'i contain cool \xfcml\xe4uts.txt')
    'i_contain_cool_umlauts.txt'

    The function might return an empty filename.  It's your responsibility
    to ensure that the filename is unique and that you generate random
    filename if the function returned an empty one.

    .. versionadded:: 0.5

    :param filename: the filename to secure
    """
    if isinstance(filename, text_type):
        filename = normalize('NFKD', filename).encode('ascii', 'ignore')

        if not PY2: