Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/werkzeug/__pycache__/utils.cpython-37.pyc

344 lines
22 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]<5D>a<00>@s dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm
Z
ddlm Z dd lm Z dd
l mZdd l mZdd l mZydd lmZWn ek
r<EFBFBD>dd lmZYnXe<04>dd<00>Ze<04>d<10>Ze<04>d<11>ZdZGdd<14>de<1A>ZGdd<16>de<0E>ZGdd<18>de<0E>ZGdd<1A>de<1E>Zed<1B>Z ed<1C>Z!dddd d!d"hZ"d#d$<24>Z#d%d&<26>Z$d'd(<28>Z%d)d*<2A>Z&dLd+d,<2C>Z'd-d.<2E>Z(dMd0d1<64>Z)dNd3d4<64>Z*dOd6d7<64>Z+dPd8d9<64>Z,dQd;d<<3C>Z-d=d><3E>Z.Gd?d@<40>d@e/<2F>Z0GdAdB<64>dBe<13>Z1ddCl2m3Z3e3e4dDdEdFdGgdHdIgdJ<64>dK<64>[3dS)RaD
werkzeug.utils
~~~~~~~~~~~~~~
This module implements various utilities for WSGI applications. Most of
them are used by the request and response wrappers but especially for
middleware development it makes sense to use them without the wrappers.
:copyright: 2007 Pallets
:license: BSD-3-Clause
<EFBFBD>N<>)<01> iteritems)<01>PY2)<01>reraise)<01> string_types)<01> text_type)<01>unichr)<01>_DictAccessorProperty)<01>_missing)<01>_parse_signature)<01>name2codepointz\$(?:(%s)|\{(%s)\}))<02>[a-zA-Z_][a-zA-Z0-9_]*r z &([^;]+);z[^A-Za-z0-9_.-]) <0B>CON<4F>AUXZCOM1ZCOM2ZCOM3ZCOM4ZLPT1ZLPT2ZLPT3<54>PRN<52>NULc@s,eZdZdZd dd<04>Zdd<06>Zd
dd<08>ZdS) <0B>cached_propertya<79>A decorator that converts a function into a lazy property. The
function wrapped is called the first time to retrieve the result
and then that calculated result is used the next time you access
the value::
class Foo(object):
@cached_property
def foo(self):
# calculate something important here
return 42
The class has to have a `__dict__` in order for this property to
work.
NcCs*|p|j|_|j|_|p|j|_||_dS)N)<04>__name__<5F>
__module__<EFBFBD>__doc__<5F>func)<04>selfr<00>name<6D>doc<6F>r<00>4/tmp/pip-install-c3kgu56x/Werkzeug/werkzeug/utils.py<70>__init__Ls  zcached_property.__init__cCs||j|j<dS)N)<02>__dict__r)r<00>obj<62>valuerrr<00>__set__Rszcached_property.__set__cCs>|dkr |S|j<00>|jt<03>}|tkr:|<00>|<01>}||j|j<|S)N)r<00>getrr
r)rr<00>typerrrr<00>__get__Us
 zcached_property.__get__)NN)N)rr<00> __qualname__rrr r#rrrrr5s
rc@seZdZdZdZdd<04>ZdS)<06>environ_propertya<79>Maps request attributes to environment variables. This works not only
for the Werzeug request object, but also any other class with an
environ attribute:
>>> class Test(object):
... environ = {'key': 'value'}
... test = environ_property('key')
>>> var = Test()
>>> var.test
'value'
If you pass it a second value it's used as default if the key does not
exist, the third one can be a converter that takes a value and converts
it. If it raises :exc:`ValueError` or :exc:`TypeError` the default value
is used. If no default value is provided `None` is used.
Per default the property is read only. You have to explicitly enable it
by passing ``read_only=False`` to the constructor.
TcCs|jS)N)<01>environ)rrrrr<00>lookupvszenviron_property.lookupN)rrr$rZ read_onlyr'rrrrr%_sr%c@seZdZdZdd<03>ZdS)<05>header_propertyz(Like `environ_property` but for headers.cCs|jS)N)<01>headers)rrrrrr'}szheader_property.lookupN)rrr$rr'rrrrr(zsr(c@s<>eZdZdZe<04>d<02>Ze<07><08>Z de d<ddddd d
d d d dddddddddhZ
dddddddddd d!d"h Z d#hZ d$d%hZ d&d'<27>Zd(d)<29>Zd*d+<2B>Zd,d-<2D>Zd.S)/<2F> HTMLBuildera<72>Helper object for HTML generation.
Per default there are two instances of that class. The `html` one, and
the `xhtml` one for those two dialects. The class uses keyword parameters
and positional parameters to generate small snippets of HTML.
Keyword parameters are converted to XML/SGML attributes, positional
arguments are used as children. Because Python accepts positional
arguments before keyword arguments it's a good idea to use a list with the
star-syntax for some children:
>>> html.p(class_='foo', *[html.a('foo', href='foo.html'), ' ',
... html.a('bar', href='bar.html')])
u'<p class="foo"><a href="foo.html">foo</a> <a href="bar.html">bar</a></p>'
This class works around some browser limitations and can not be used for
arbitrary SGML/XML generation. For that purpose lxml and similar
libraries exist.
Calling the builder escapes the string passed:
>>> html.p(html("<foo>"))
u'<p>&lt;foo&gt;</p>'
z &([^;]+);<3B>'Zapos<6F>area<65>base<73>basefont<6E>br<62>col<6F>command<6E>embed<65>frame<6D>hr<68>img<6D>input<75>keygen<65>isindex<65>link<6E>meta<74>param<61>source<63>wbr<62>selected<65>checked<65>compactZdeclare<72>defer<65>disabled<65>ismap<61>multipleZnohrefZnoresize<7A>noshadeZnowrap<61>textarea<65>script<70>stylecCs
||_dS)N)<01>_dialect)r<00>dialectrrrr<00>szHTMLBuilder.__init__cCst|<01>S)N)<01>escape)r<00>srrr<00>__call__<5F>szHTMLBuilder.__call__cs*<00>dd<01>dkrt<00><01><01><01><00>fdd<04>}|S)N<><00>__cs.d<01>}x<>t|<01>D]x\}}|dkr$q|ddkr<|dd<02>}|<03>jkrj|sLq<12>jdkrdd|d}qzd}ndt|<04>d}|d||7}qW|s<><73><01>jkr<><72>jdkr<>|d 7}n|d
7}|S|d
7}d<07>d d <0C>|D<00><01>}|<05>r<16><01>jkr<>t|<05>}n$<24><01>jk<06>r<16>jdk<02>rd |d}||d<00>d
7}|S)N<><<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<>xhtmlz="<22>"<22><00> z /><3E>>cSsg|]}|dk rt|<01><01>qS)N)r)<02>.0<EFBFBD>xrrr<00>
<listcomp><3E>sz:HTMLBuilder.__getattr__.<locals>.proxy.<locals>.<listcomp>z /*<![CDATA[*/z/*]]>*/z</)r<00>_boolean_attributesrIrK<00>_empty_elements<74>join<69>_plaintext_elements<74> _c_like_cdata)<06>children<65> arguments<74>buffer<65>keyrZchildren_as_string)r<00>tagrr<00>proxy<78>s:  





 z&HTMLBuilder.__getattr__.<locals>.proxy)<01>AttributeError)rrdrer)rrdr<00> __getattr__<5F>s'zHTMLBuilder.__getattr__cCsd|jj|jfS)Nz <%s for %r>)<03> __class__rrI)rrrr<00>__repr__<5F>szHTMLBuilder.__repr__N)rrr$r<00>re<72>compile<6C>
_entity_rer <00>copy<70> _entitiesr\r[r^r_rrMrgrirrrrr*<00>sP
-r*<00>htmlrSzapplication/ecmascriptzapplication/javascriptzapplication/sqlzapplication/xmlzapplication/xml-dtdz&application/xml-external-parsed-entitycCs,|<00>d<01>s|tks|<00>d<02>r(|d|7}|S)aKReturns the full content type string with charset for a mimetype.
If the mimetype represents text, the charset parameter will be
appended, otherwise the mimetype is returned unchanged.
:param mimetype: The mimetype to be used as content type.
:param charset: The charset to be appended for text mimetypes.
:return: The content type.
.. verionchanged:: 0.15
Any type that ends with ``+xml`` gets a charset, not just those
that start with ``application/``. Known text types such as
``application/javascript`` are also given charsets.
ztext/z+xmlz
; charset=)<03>
startswith<EFBFBD>_charset_mimetypes<65>endswith)<02>mimetype<70>charsetrrr<00>get_content_type
s


 rucCs<>|dd<02>}|dd<03>tjkr"dSd|kr.dS|tjtjfkrBdS|dd<08>tjtjfkr^d St|<01>dkr<>|dd<03>d
kr~d S|ddd<08>d kr<>d S|dd<01>d
kr<>dS|ddd<08>d kr<>dSt|<01>dkr<>|<01>d<05>r<>d SdSdS)a<>Detect which UTF encoding was used to encode the given bytes.
The latest JSON standard (:rfc:`8259`) suggests that only UTF-8 is
accepted. Older documents allowed 8, 16, or 32. 16 and 32 can be big
or little endian. Some editors or libraries may prepend a BOM.
:internal:
:param data: Bytes in unknown UTF encoding.
:return: UTF encoding name
.. versionadded:: 0.15
N<><00>z utf-8-sig<69>zutf-8zutf-32rNzutf-16sz utf-32-besz utf-16-berz utf-32-lez utf-16-le)<08>codecs<63>BOM_UTF8<46> BOM_UTF32_BE<42> BOM_UTF32_LE<4C> BOM_UTF16_BE<42> BOM_UTF16_LE<4C>lenrp)<02>data<74>headrrr<00>detect_utf_encoding#s*   r<>cs<00><00>fdd<02>}t<00>|<02><01>S)aXString-template format a string:
>>> format_string('$foo and ${foo}s', dict(foo=42))
'42 and 42s'
This does not do any attribute lookup etc. For more advanced string
formattings have a look at the `werkzeug.template` module.
:param string: the format string.
:param context: a dict with the variables to insert.
cs2<00>|<00>d<01>p|<00>d<02>}t|t<02>s.t<03><01>|<01>}|S)NrrN)<04>group<75>
isinstancerr")<02>matchrY)<02>context<78>stringrr<00>
lookup_arg_s
 z!format_string.<locals>.lookup_arg)<02>
_format_re<EFBFBD>sub)r<>r<>r<>r)r<>r<>r<00> format_stringRs r<>cCs<>t|t<01>r6ddlm}|d|<00><02>dd<05>}ts6|<00>d<04>}x(tjj tjj
fD]}|rH|<00> |d<06>}qHWt t <0A>dd<08>|<00><10><00><01><02><01>d <09>}tjd
kr<>|r<>|<00>d <0B>d<00><13>tkr<>d|}|S) auPass 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 systems 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 abort or
generate a random filename if the function returned an empty one.
.. versionadded:: 0.5
:param filename: the filename to secure
r)<01> normalizeZNFKD<4B>ascii<69>ignorerVrUrRz._<>nt<6E>.)r<>r<00> unicodedatar<61><00>encoder<00>decode<64>os<6F>path<74>sep<65>altsep<65>replace<63>str<74>_filename_ascii_strip_rer<65>r]<00>split<69>stripr<00>upper<65>_windows_device_files)<03>filenamer<65>r<>rrr<00>secure_filenamehs
 

r<>cCs~|dkr dSt|d<03>r"t|<00><02><00>St|t<04>s4t|<00>}|dk rVddlm}|dtdd<08>|<00>d d
<EFBFBD><02>d d <0C><02>d d<0E><02>dd<10>}|S)aReplace special characters "&", "<", ">" and (") to HTML-safe sequences.
There is a special handling for `None` which escapes to an empty string.
.. versionchanged:: 0.9
`quote` is now implicitly on.
:param s: the string to escape.
:param quote: ignored.
NrU<00>__html__r)<01>warnz]The 'quote' parameter is no longer used as of version 0.9 and will be removed in version 1.0.rN)<01>
stacklevel<EFBFBD>&z&amp;rPz&lt;rWz&gt;rTz&quot;) <09>hasattrrr<>r<>r<00>warningsr<73><00>DeprecationWarningr<67>)rL<00>quoter<65>rrrrK<00>s" 
 
  rKcCsdd<02>}t<00>||<00>S)z<>The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape.
cSs<>|<00>d<01>}|tjkr"ttj|<00>SyH|dd<02>dkrJtt|dd<00>d<04><02>S|<01>d<05>rhtt|dd<00><00><01>SWntk
r~YnXdS)NrrN)z#xz#X<><00>#rU)r<>r*rnr<00>intrp<00>
ValueError)<02>mrrrr<00> handle_match<63>s


zunescape.<locals>.handle_match)rlr<>)rLr<>rrr<00>unescape<70>s r<><00>.cCsf|dkrddlm}t|<00>}t|t<04>r>ddlm}||dd<06>}|dt|<00>|f|dd <09>}||jd
<|S) aaReturns a response object (a WSGI application) that, if called,
redirects the client to the target location. Supported codes are
301, 302, 303, 305, 307, and 308. 300 is not supported because
it's not a real redirect and 304 because it's the answer for a
request with a request with defined If-Modified-Since headers.
.. versionadded:: 0.6
The location can now be a unicode string that is encoded using
the :func:`iri_to_uri` function.
.. versionadded:: 0.10
The class used for the Response object can now be passed in.
:param location: the location the response should redirect to.
:param code: the redirect status code. defaults to 302.
:param class Response: a Response class to use when instantiating a
response. The default is :class:`werkzeug.wrappers.Response` if
unspecified.
Nr)<01>Response)<01>
iri_to_uriT)Zsafe_conversionz<6E><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="%s">%s</a>. If not click the link.z text/html)rsZLocation)<08>wrappersr<73>rKr<>r<00>urlsr<73>r))<06>location<6F>coder<65>Zdisplay_locationr<6E><00>responserrr<00>redirect<63>s 
   
r<><00>-cCs6|d<00>d<02>d}|<00>d<03>}|r,|d|7}t||<01>S)a-Redirects to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the status code for the redirect.
Z PATH_INFO<46>/<2F> QUERY_STRING<4E>?)r<>r!r<>)r&r<><00>new_pathZ query_stringrrr<00>append_slash_redirects

 r<>Fc
Cs<>t|<00><01>dd<02>}y<>y t|<00>Wntk
r<d|kr8<72>Yn Xtj|S|<00>dd<03>\}}t|t<07>t<08>|g<01>}y
t ||<03>St
k
r<EFBFBD>}z t|<05><01>Wdd}~XYnXWn@tk
r<EFBFBD>}z"|s<>t t t ||<05>t<04> <0A>d<00>Wdd}~XYnXdS)aCImports an object based on a string. This is useful if you want to
use import paths as endpoints or something similar. An import path can
be specified either in dotted notation (``xml.sax.saxutils.escape``)
or with a colon as object delimiter (``xml.sax.saxutils:escape``).
If `silent` is True the return value will be `None` if the import fails.
:param import_name: the dotted name for the object to import.
:param silent: if set to `True` import errors are ignored and
`None` is returned instead.
:return: imported object
<20>:r<>rNrN)r<>r<><00>
__import__<EFBFBD> ImportError<6F>sys<79>modules<65>rsplit<69>globals<6C>locals<6C>getattrrfr<00>ImportStringError<6F>exc_info)<06> import_name<6D>silent<6E> module_nameZobj_name<6D>module<6C>errr<00> import_strings$ 

r<>c
cs<>t|<00>}t|dd<02>}|dkr(td|<00><01>|jd}xVt<04>|<04>D]H\}}}||}|r<>|r^|V|r<>x"t||d<05>D]
} | VqpWq>|Vq>WdS)a<>Finds all the modules below a package. This can be useful to
automatically import all views / controllers so that their metaclasses /
function decorators have a chance to register themselves on the
application.
Packages are not returned unless `include_packages` is `True`. This can
also recursively list modules but in that case it will import all the
packages to get the correct load path of that module.
:param import_path: the dotted name for the package to find child modules.
:param include_packages: set to `True` if packages should be returned, too.
:param recursive: set to `True` if recursion should happen.
:return: generator
<20>__path__Nz%r is not a packager<65>T)r<>r<>r<>r<00>pkgutil<69> iter_modules<65> find_modules)
Z import_pathZinclude_packages<65> recursiver<65>r<><00>basename<6D> _importer<65>modname<6D>ispkg<6B>itemrrrr<>7s  
 r<>TcCsZt|<00>}|||<02>dd<02>\}}}}}|r6tt|<05><01><01>n|s>|rN|sNtd||<07><03>t|<01>|fS)a<>Checks if the function accepts the arguments and keyword arguments.
Returns a new ``(args, kwargs)`` tuple that can safely be passed to
the function without causing a `TypeError` because the function signature
is incompatible. If `drop_extra` is set to `True` (which is the default)
any extra positional or keyword arguments are dropped automatically.
The exception raised provides three attributes:
`missing`
A set of argument names that the function expected but where
missing.
`extra`
A dict of keyword arguments that the function can not handle but
where provided.
`extra_positional`
A list of values that where given by positional argument but the
function cannot accept.
This can be useful for decorators that forward user submitted data to
a view function::
from werkzeug.utils import ArgumentValidationError, validate_arguments
def sanitize(f):
def proxy(request):
data = request.values.to_dict()
try:
args, kwargs = validate_arguments(f, (request,), data)
except ArgumentValidationError:
raise BadRequest('The browser failed to transmit all '
'the data expected.')
return f(*args, **kwargs)
return proxy
:param func: the function the validation is performed against.
:param args: a tuple of positional arguments.
:param kwargs: a dict of keyword arguments.
:param drop_extra: set to `False` if you don't want extra arguments
to be silently dropped.
:return: tuple in the form ``(args, kwargs)``.
N<>)r <00>ArgumentValidationError<6F>tuple)r<00>args<67>kwargsZ
drop_extra<EFBFBD>parser<65>missing<6E>extra<72>extra_positionalrrr<00>validate_argumentsWs,  r<>cCs<>t|<00>||<02>\}}}}}}}}i} x$t||<01>D]\\}
} } } | | |
<q.W|dk r^t|<05>| |<n |rjtd<02><01>|dk r<>t|<04>tdd<04>|D<00><01>@}|r<>tdttt|<0E><01><01><00><01>|| |<n|r<>tdttt|<04><01><01><00><01>| S)a>Bind the arguments provided into a dict. When passed a function,
a tuple of arguments and a dict of keyword arguments `bind_arguments`
returns a dict of names as the function would see it. This can be useful
to implement a cache decorator that uses the function arguments to build
the cache key based on the values of the arguments.
:param func: the function the arguments should be bound for.
:param args: tuple of positional arguments.
:param kwargs: a dict of keyword arguments.
:return: a :class:`dict` of bound keyword arguments.
Nztoo many positional argumentscSsg|] }|d<00>qS)rr)rXrYrrrrZ<00>sz"bind_arguments.<locals>.<listcomp>z)got multiple values for keyword argument z got unexpected keyword argument )r <00>zipr<70><00> TypeError<6F>set<65>repr<70>next<78>iter)rr<>r<>r<>r<>r<>Zarg_specZ
vararg_varZ kwarg_var<61>valuesrZ _has_default<6C>_defaultrZmultikwrrr<00>bind_arguments<74>s" 
r<>c@seZdZdZddd<04>ZdS)r<>z6Raised if :func:`validate_arguments` fails to validateNcCsPt|pd<01>|_|pi|_|pg|_t<04>|dt|j<01>t|j<02>t|j<03>f<00>dS)Nrz7function arguments invalid. (%d missing, %d additional))r<>r<>r<>r<>r<>rr)rr<>r<>r<>rrrr<00>s

z ArgumentValidationError.__init__)NNN)rrr$rrrrrrr<><00>sr<>c@s(eZdZdZdZdZdd<04>Zdd<06>ZdS)r<>zBProvides information about a failed :func:`import_string` attempt.Nc Cs<>||_||_d}d}g}x<>|<01>dd<04><02>d<04>D]x}||o8d|7}t|dd<06>}|rh|<05>|t|dd<00>f<02>q,dd <09>|D<00>}|<08>d
|<00>||d <0B>|<08>|jj t
|<02>f}Pq,Wt <0B> ||<03>dS) Na1import_string() failed for %r. Possible reasons are:
- missing __init__.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;
Debugged import:
%s
Original exception:
%s: %srUr<>r<>T)r<><00>__file__cSsg|]\}}d||f<00>qS)z- %r found in %r.r)rX<00>n<>irrrrZ<00>sz.ImportStringError.__init__.<locals>.<listcomp>z- %r not found.<2E>
) r<><00> exceptionr<6E>r<>r<><00>appendr<64>r]rhrr<>r<>r) rr<>r<><00>msgrZtracked<65>partZimported<65>trackrrrr<00>s&
  zImportStringError.__init__cCsd|jj|j|jfS)Nz <%s(%r, %r)>)rhrr<>r<>)rrrrri<00>szImportStringError.__repr__)rrr$rr<>r<>rrirrrrr<><00>s
#r<>)<01>_DeprecatedImportModuleZCombinedMultiDictZEnvironHeadersZHeadersZ MultiDictZ dump_cookieZ parse_cookie)z.datastructuresz.httpz Werkzeug 1.0)N)r<>N)r<>)F)FF)T)5rryr<>r<>rjr<><00>_compatrrrrrr<00> _internalr r
r <00> html.entitiesr r<><00>htmlentitydefsrkr<>rlr<>r<><00>propertyrr%r(<00>objectr*rorSrqrur<>r<>r<>rKr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>Zwerkzeugr<67>rrrrr<00><module> st         

*y/2
#
,

(
5)3