/usr/local/lib/python3.6/site-packages/werkzeug/__pycache__
NameSizeModeActions
datastructures.cpython-36.pyc1077480644editdlrm
exceptions.cpython-36.pyc306390644editdlrm
filesystem.cpython-36.pyc20250644editdlrm
formparser.cpython-36.pyc138140644editdlrm
http.cpython-36.pyc379050644editdlrm
local.cpython-36.pyc226910644editdlrm
routing.cpython-36.pyc729310644editdlrm
security.cpython-36.pyc80400644editdlrm
serving.cpython-36.pyc304780644editdlrm
test.cpython-36.pyc389610644editdlrm
testapp.cpython-36.pyc95490644editdlrm
urls.cpython-36.pyc364140644editdlrm
useragents.cpython-36.pyc74170644editdlrm
user_agent.cpython-36.pyc17200644editdlrm
utils.cpython-36.pyc329600644editdlrm
wsgi.cpython-36.pyc301020644editdlrm
_internal.cpython-36.pyc182680644editdlrm
_reloader.cpython-36.pyc118990644editdlrm
__init__.cpython-36.pyc3100644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/werkzeug/__pycache__/wsgi.cpython-36.pyc (30102B)
3 _TBg@s:ddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl m Z dd l mZdd lmZdd lmZdd lmZdd lmZddlmZddlmZejrddlmZddlmZejdPddddZdQdeeeejej e!e!dddZ"dejej#e!eje$fdddZ%dRdejej e!e!dd d!Z&deje$dd"d#Z'dSdeej(e)d%d&d'Z*de!dd(d)Z+dTde!e!e!d,d-d.Z,dUde!e!e!d,d/d0Z-dVde!e!eje!d,d1d2Z.dWde!e!eje!d,d3d4Z/dXej0e!dfej0e!efe!e!eeje!d6d7d8Z1Gd9d:d:Z2dYdej(e)e$ej e)d<d=d>Z3Gd?d@d@Z4GdAdBdBZ5ej0ej e)ej(e)feje$e$ej6e)dCdDdEZ7d[ej0ej e)ej(e)feje$e$eej6e)dHdIdJZ8d]ej0ej e)ej(e)fe)eje$e$eej6e)dKdLdMZ9GdNdOdOej:Z;dS)^N)partial)update_wrapper)chain)_make_encode_wrapper) _to_bytes)_to_str)utils)host_is_trusted) _URLTuple) uri_to_iri)url_join) url_parse) url_quote)WSGIApplication)WSGIEnvironment.r)freturncstfddS)a Marks a function as responder. Decorate a function with it and it will automatically call the return value as WSGI application. Example:: @responder def application(environ, start_response): return Response('Hello World!') cs||ddS)N)a)rr1/tmp/pip-build-0s3hx122/Werkzeug/werkzeug/wsgi.py"szresponder..)r)rr)rr responders rFr)environ root_onlystrip_querystring host_only trusted_hostsrcCsb|dt||d}|sV|jdd|d<|sV|jdd|d<|sV|jddjd |d <tjf|S) aXRecreate the URL for a request from the parts in a WSGI environment. The URL is an IRI, not a URI, so it may contain Unicode characters. Use :func:`~werkzeug.urls.iri_to_uri` to convert it to ASCII. :param environ: The WSGI environment to get the URL parts from. :param root_only: Only build the root path, don't include the remaining path or query string. :param strip_querystring: Don't include the query string. :param host_only: Only build the scheme and host. :param trusted_hosts: A list of trusted host names to validate the host against. zwsgi.url_scheme)schemehost SCRIPT_NAME root_path PATH_INFOpath QUERY_STRINGlatin1Z query_string)get_hostgetencode _sansio_utilsget_current_url)rrrrrpartsrrrr-%sr-)rrc CsP|jd}|dkrdSyt|jdd}Wnttfk rFd}YnX||fS)NZ SERVER_NAMEZ SERVER_PORT)r*int TypeError ValueError)rnameportrrr _get_serverKs  r4)rrrcCstj|d|jdt||S)arReturn the host for the given WSGI environment. The ``Host`` header is preferred, then ``SERVER_NAME`` if it's not set. The returned host will only contain the port if it is different than the standard port for the protocol. Optionally, verify that the host is trusted using :func:`host_is_trusted` and raise a :exc:`~werkzeug.exceptions.SecurityError` if it is not. :param environ: A WSGI environment dict. :param trusted_hosts: A list of trusted host names. :return: Host, with port if necessary. :raise ~werkzeug.exceptions.SecurityError: If the host is not trusted. zwsgi.url_schemeZ HTTP_HOST)r,r)r*r4)rrrrrr)\s r)c CsR|jdddkrdS|jd}|dk rNytdt|Sttfk rLYnXdS)aReturns the content length from the WSGI environment as integer. If it's not available or chunked transfer encoding is used, ``None`` is returned. .. versionadded:: 0.9 :param environ: the WSGI environ to fetch the content length from. ZHTTP_TRANSFER_ENCODINGr#chunkedNCONTENT_LENGTHr)r*maxr/r1r0)rcontent_lengthrrrget_content_lengthxs  r9T)r safe_fallbackrcCs\tjtjt|d}t|}|jdr,|S|dkrD|r@tjS|Stjtjtt||S)a Returns the input stream from the WSGI environment and wraps it in the most sensible way possible. The stream returned is not the raw WSGI stream in most cases but one that is safe to read from without taking into account the content length. If content length is not set, the stream will be empty for safety reasons. If the WSGI server supports chunked or infinite streams, it should set the ``wsgi.input_terminated`` value in the WSGI environ to indicate that. .. versionadded:: 0.9 :param environ: the WSGI environ to fetch the stream from. :param safe_fallback: use an empty stream as a safe fallback when the content length is not set. Disabling this allows infinite streams, which can be a denial-of-service risk. z wsgi.inputzwsgi.input_terminatedN) tcastIObytesr9r*ioBytesIO LimitedStream)rr:streamr8rrrget_input_streams rCcCs|jddjd}t|ddS)aReturns the ``QUERY_STRING`` from the WSGI environment. This also takes care of the WSGI decoding dance. The string returned will be restricted to ASCII characters. :param environ: WSGI environment to get the query string from. .. versionadded:: 0.9 r'r#r(z :&%=+$!*'(),)safe)r*r+r)rqsrrrget_query_strings rFutf-8replace)rcharseterrorsrcCs"|jddjd}t|||ddS)a[Return the ``PATH_INFO`` from the WSGI environment and decode it unless ``charset`` is ``None``. :param environ: WSGI environment to get the path from. :param charset: The charset for the path info, or ``None`` if no decoding should be performed. :param errors: The decoding error handling. .. versionadded:: 0.9 r%r#r(T)allow_none_charset)r*r+r)rrIrJr&rrr get_path_infos rLcCs"|jddjd}t|||ddS)a]Return the ``SCRIPT_NAME`` from the WSGI environment and decode it unless `charset` is set to ``None``. :param environ: WSGI environment to get the path from. :param charset: The charset for the path, or ``None`` if no decoding should be performed. :param errors: The decoding error handling. .. versionadded:: 0.9 r"r#r(T)rK)r*r+r)rrIrJr&rrrget_script_names rMcCs|jd}|sdS|jdd}|}|jd}||krL|dt|t|7}d|krtd|d<|||d<|jd}n4|jdd\}}d||d<|||d<|jd}t|||dd S) aRemoves and returns the next segment of `PATH_INFO`, pushing it onto `SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`. If the `charset` is set to `None` bytes are returned. If there are empty segments (``'/foo//bar``) these are ignored but properly pushed to the `SCRIPT_NAME`: >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'} >>> pop_path_info(env) 'a' >>> env['SCRIPT_NAME'] '/foo/a' >>> pop_path_info(env) 'b' >>> env['SCRIPT_NAME'] '/foo/a/b' .. versionadded:: 0.5 .. versionchanged:: 0.9 The path is now decoded and a charset and encoding parameter can be provided. :param environ: the WSGI environment that is modified. :param charset: The ``encoding`` parameter passed to :func:`bytes.decode`. :param errors: The ``errors`` paramater passed to :func:`bytes.decode`. r%Nr"r#/r(rT)rK)r*lstriplenr+splitr)rrIrJr& script_nameZold_pathrvZsegmentrrr pop_path_infos"!       rTcCs<|jddjdjdd}|r8t|djd||ddSd S) a'Returns the next segment on the `PATH_INFO` or `None` if there is none. Works like :func:`pop_path_info` without modifying the environment: >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'} >>> peek_path_info(env) 'a' >>> peek_path_info(env) 'a' If the `charset` is set to `None` bytes are returned. .. versionadded:: 0.5 .. versionchanged:: 0.9 The path is now decoded and a charset and encoding parameter can be provided. :param environ: the WSGI environment that is checked. r%r#rNrrr(T)rKN)r*rOrQrr+)rrIrJsegmentsrrrpeek_path_infos rVwerkzeug.url_quote)environ_or_baseurl path_or_urlrIrJcollapse_http_schemesrcCstttddd}t|||}t|tr4t|dd}t|||}t|dd\}} } tt||dd\} } } ||| } || | } |rx2|| fD]}|d krdSqWn|d ko|| ksdS| | krdS| jd } | j| sdSd | t | dj d S) a%Extracts the path info from the given URL (or WSGI environment) and path. The path info returned is a string. The URLs might also be IRIs. If the path info could not be determined, `None` is returned. Some examples: >>> extract_path_info('http://example.com/app', '/app/hello') '/hello' >>> extract_path_info('http://example.com/app', ... 'https://example.com/app/hello') '/hello' >>> extract_path_info('http://example.com/app', ... 'https://example.com/app/hello', ... collapse_http_schemes=False) is None True Instead of providing a base URL you can also pass a WSGI environment. :param environ_or_baseurl: a WSGI environment dict, a base URL or base IRI. This is the root of the application. :param path_or_url: an absolute path from the server root, a relative path (in which case it's the path info) or a full URL. :param charset: the charset for byte data in URLs :param errors: the error handling on decode :param collapse_http_schemes: if set to `False` the algorithm does not assume that http and https on the same server point to the same resource. .. versionchanged:: 0.15 The ``errors`` parameter defaults to leaving invalid bytes quoted instead of replacing them. .. versionadded:: 0.6 )r netlocrcSsx|jddd jdd}t|dkrR|\}}|dkr<|dksL|dkr^|dkr^d}n |d }d}|dk rt|d|7}|S) N@r:rhttp80httpsZ443r)rQrP)r r[r.r3rrr_normalize_netlocls z,extract_path_info.._normalize_netlocT)rNr^r`rN)r^r`)r^r`) strr isinstancedictr-rr rstrip startswithrPrO)rXrYrIrJrZrbr&Zbase_iriZ base_schemeZ base_netloc base_pathZ cur_schemeZ cur_netlocZcur_pathr rrrextract_path_info>s*.         rjc @s~eZdZdZd ejeejejej gdfejej gdffddddZ ddddZ edd d Z ddd d Z dS)ClosingIteratoraAThe WSGI specification requires that all middlewares and gateways respect the `close` callback of the iterable returned by the application. Because it is useful to add another close action to a returned iterable and adding a custom iterable is a boring task this class can be used for that:: return ClosingIterator(app(environ, start_response), [cleanup_session, cleanup_locals]) If there is just one close function it can be passed instead of the list. A closing iterator is not needed if the application uses response objects and finishes the processing if the response is started:: try: return response(environ, start_response) finally: cleanup_session() cleanup_locals() N)iterable callbacksrcCsrt|}tjtjgtftt||_|dkr4g}nt|rD|g}nt |}t |dd}|rh|j d|||_ dS)Ncloser) iterr;r<Callabler>rnext_nextcallablelistgetattrinsert _callbacks)selfrlrmiteratorZiterable_closerrr__init__s  zClosingIterator.__init__)rcCs|S)Nr)rxrrr__iter__szClosingIterator.__iter__cCs|jS)N)rr)rxrrr__next__szClosingIterator.__next__cCsx|jD] }|qWdS)N)rw)rxcallbackrrrrns zClosingIterator.close)N)__name__ __module__ __qualname____doc__r;Iterabler>OptionalUnionrprzr{r|rnrrrrrks 6rk )rfile buffer_sizercCs|jdt||S)aWraps a file. This uses the WSGI server's file wrapper if available or otherwise the generic :class:`FileWrapper`. .. versionadded:: 0.5 If the file wrapper from the WSGI server is used it's important to not iterate over it from inside the application but to pass it through unchanged. If you want to pass out a file wrapper inside a response object you have to set :attr:`Response.direct_passthrough` to `True`. More information about file wrappers are available in :pep:`333`. :param file: a :class:`file`-like object with a :meth:`~file.read` method. :param buffer_size: number of bytes for one iteration. zwsgi.file_wrapper)r* FileWrapper)rrrrrr wrap_files rc@seZdZdZdejeeddddZdddd Z e dd d Z ej dd d dZ ejedddZddddZedddZdS)ra\This class can be used to convert a :class:`file`-like object into an iterable. It yields `buffer_size` blocks until the file is fully read. You should not use this class directly but rather use the :func:`wrap_file` function that uses the WSGI server's file wrapper support if it's available. .. versionadded:: 0.5 If you're using this object together with a :class:`Response` you have to use the `direct_passthrough` mode. :param file: a :class:`file`-like object with a :meth:`~file.read` method. :param buffer_size: number of bytes for one iteration. N)rrrcCs||_||_dS)N)rr)rxrrrrrrzszFileWrapper.__init__)rcCst|jdr|jjdS)Nrn)hasattrrrn)rxrrrrns zFileWrapper.closecCs*t|jdr|jjSt|jdr&dSdS)NseekableseekTF)rrr)rxrrrrs    zFileWrapper.seekable)argsrcGst|jdr|jj|dS)Nr)rrr)rxrrrrr s zFileWrapper.seekcCst|jdr|jjSdS)Ntell)rrr)rxrrrrs  zFileWrapper.tellcCs|S)Nr)rxrrrr{szFileWrapper.__iter__cCs |jj|j}|r|StdS)N)rreadr StopIteration)rxdatarrrr|szFileWrapper.__next__)r)r~rrrr;r=r>r/rzrnboolrZAnyrrrr{r|rrrrrsrc@seZdZdZdejejeejefe ej e dddZ dddd Z edd d Z ejej ee fdd d ZedddZedddZddddZdS) _RangeWrapperasThis class can be used to convert an iterable object into an iterable that will only yield a piece of the underlying content. It yields blocks until the underlying stream range is fully read. The yielded blocks will have a size that can't exceed the original iterator defined block size, but that can be smaller. If you're using this object together with a :class:`Response` you have to use the `direct_passthrough` mode. :param iterable: an iterable object with a :meth:`__next__` method. :param start_byte: byte from which read will start. :param byte_range: how many bytes to read. rN)rl start_byte byte_rangecCsRt||_||_||_d|_|dk r.|||_d|_t|doD|j|_d|_dS)NrrF) rorlrrend_byte read_lengthrr end_reached)rxrlrrrrrrz1s  z_RangeWrapper.__init__)rcCs|S)Nr)rxrrrr{Esz_RangeWrapper.__iter__c CsBy t|j}|jt|7_|Stk r<d|_YnXdS)NT)rqrlrrPrr)rxchunkrrr _next_chunkHs z_RangeWrapper._next_chunkcCspd}|jr,|jj|j|jj|_|j}nr=r/rrzr{rTuplerrrr|rnrrrrr s0 r)rBlimitrrccst|tttfrtdt|ds>x|D]}|r(|Vq(WdStjtjt|}t|t  r||dk r|tjtjtt ||}|j }x||}|sP|VqWdS)z-Helper for the line and chunk iter functions.zBPassed a string or byte object instead of true iterator or stream.rN) rer> bytearrayrdr0rr;r<r=rAr)rBrritem_readrrr_make_chunk_iterys"   r i)rBrr cap_at_bufferrc #st||td}|sdSt|}tjt|dtjt|d}tjt|d}tjt|dtjtjtt|ftjtdfdd }} x@|D]6} | |kr| d d|kr| | 7} } | r| V| } qW| r| VdS) aSafely iterates line-based over an input stream. If the input stream is not a :class:`LimitedStream` the `limit` parameter is mandatory. This uses the stream's :meth:`~file.read` method internally as opposite to the :meth:`~file.readline` method that is unsafe and can only be used in violation of the WSGI specification. The same problem applies to the `__iter__` function of the input stream which calls :meth:`~file.readline` without arguments. If you need line-by-line processing it's strongly recommended to iterate over the input stream using this helper function. .. versionchanged:: 0.8 This function now ensures that the limit was reached. .. versionadded:: 0.9 added support for iterators as input stream. .. versionadded:: 0.11.10 added support for the `cap_at_buffer` parameter. :param stream: the stream or iterate to iterate over. :param limit: the limit in bytes for the stream. (Usually content length. Not necessary if the `stream` is a :class:`LimitedStream`. :param buffer_size: The optional buffer size. :param cap_at_buffer: if this is set chunks are split if they are longer than the buffer size. Internally this is implemented that the buffer size might be exhausted by a factor of two however. r#N  z )rc3sj}g}xtd}|sPg}d}xtjtjtt||jdD]}|j||t |7}|r|ddkr||Vg}qDrD|krD||}x*t |kr|dV|d}qW|g}qDW|}q W|r||VdS)Nr#rTrra) joinrqr;r<Iteratorr>r splitlinesappendrP)_joinbuffernew_datanew_bufbuf_sizerrS)_iterrrcrlfemptyrr_iter_basic_liness0      z)make_line_iter.._iter_basic_linesrra)rrqrr;r<r>rr) rBrrr first_itemscrlfrpreviousrr)rrrrrrmake_line_iters*%    r)rB separatorrrrrccsnt|||}t|d}|sdStjtjtt|f|}t|trlt |}t j dt j |dj }dj}n(t|}t j dt j |dj }dj}g} xt|d} | sP|| } g} d} xt| | D]}||kr|| Vg} d} q| t|7} | j||r| |kr|| }x.t||kr>|d|V||d}qW|g} t|} qW| } qW| rj|| VdS) a Works like :func:`make_line_iter` but accepts a separator which divides chunks. If you want newline based processing you should use :func:`make_line_iter` instead as it supports arbitrary newline markers. .. versionadded:: 0.8 .. versionadded:: 0.9 added support for iterators as input stream. .. versionadded:: 0.11.10 added support for the `cap_at_buffer` parameter. :param stream: the stream or iterate to iterate over. :param separator: the separator that divides chunks. :param limit: the limit in bytes for the stream. (Usually content length. Not necessary if the `stream` is otherwise already limited). :param buffer_size: The optional buffer size. :param cap_at_buffer: if this is set chunks are split if they are longer than the buffer size. Internally this is implemented that the buffer size might be exhausted by a factor of two however. N()r#()r)rrqr;r<rr>rrerdrrecompileescaperQrrrPr)rBrrrrrr_splitrrrchunksrrrrSrrrmake_chunk_itersJ         rc@seZdZdZejeeddddZddddZ e e dd d Z edd d Z edd dZd"eddddZd#ejeedddZd$ejeedddZd%ejeejedddZedddZedddZe ddd ZdS)&rAaWraps a stream so that it doesn't read more than n bytes. If the stream is exhausted and the caller tries to get more bytes from it :func:`on_exhausted` is called which by default returns an empty string. The return value of that function is forwarded to the reader function. So if it returns an empty string :meth:`read` will return an empty string as well. The limit however must never be higher than what the stream can output. Otherwise :meth:`readlines` will try to read past the limit. .. admonition:: Note on WSGI compliance calls to :meth:`readline` and :meth:`readlines` are not WSGI compliant because it passes a size argument to the readline methods. Unfortunately the WSGI PEP is not safely implementable without a size argument to :meth:`readline` because there is no EOF marker in the stream. As a result of that the use of :meth:`readline` is discouraged. For the same reason iterating over the :class:`LimitedStream` is not portable. It internally calls :meth:`readline`. We strongly suggest using :meth:`read` only or using the :func:`make_line_iter` which safely iterates line-based over a WSGI input stream. :param stream: the stream to wrap. :param limit: the limit for the stream, must not be longer than what the string can provide if the stream does not end with `EOF` (like `wsgi.input`) N)rBrrcCs |j|_|j|_d|_||_dS)Nr)rrreadline _readline_posr)rxrBrrrrrz^szLimitedStream.__init__)rcCs|S)Nr)rxrrrr{dszLimitedStream.__iter__cCs |j|jkS)z4If the stream is exhausted this attribute is `True`.)rr)rxrrr is_exhaustedgszLimitedStream.is_exhaustedcCs |jdS)zThis is called when the stream tries to read past the limit. The return value of this function is returned from the reading function. r)r)rxrrr on_exhaustedlszLimitedStream.on_exhaustedcCsddlm}|dS)aWhat should happen if a disconnect is detected? The return value of this function is returned from read functions in case the client went away. By default a :exc:`~werkzeug.exceptions.ClientDisconnected` exception is raised. r)ClientDisconnectedN) exceptionsr)rxrrrr on_disconnectus zLimitedStream.on_disconnecti@) chunk_sizercCs>|j|j}|}x(|dkr8t||}|j|||8}qWdS)aExhaust the stream. This consumes all the data left until the limit is reached. :param chunk_size: the size for a chunk. It will read the chunk until the stream is exhausted and throw away the results. rN)rrminr)rxrto_readrrrrexhausts     zLimitedStream.exhaust)sizerc Cs|j|jkr|jS|dks$|dkr*|j}t|j|j|}y|j|}Wnttfk rf|jSX|rt||kr|jS|jt|7_|S)zyRead `size` bytes or if size is not provided everything is read. :param size: the number of bytes read. Nrra) rrrrrOSErrorr1rrP)rxrrrrrrrs  zLimitedStream.readc Cs|j|jkr|jS|dkr*|j|j}nt||j|j}y|j|}Wnttfk rf|jSX|rz| rz|jS|jt|7_|S)zReads one line from the stream.N) rrrrrr1rrrP)rxrlinerrrrs   zLimitedStream.readlinecCst|j}g}|dk r$t|j||}n|j}xD|dk rB|||j8}|j|krNP|j|j||dk r,|j}q,W|S)zReads a file into a list of strings. It calls :meth:`readline` until the file is read to the end. It does support the optional `size` argument if the underlying stream supports it for `readline`. N)rrrrr)rxrZlast_posresultendrrr readliness  zLimitedStream.readlinescCs|jS)zKReturns the position of the stream. .. versionadded:: 0.9 )r)rxrrrrszLimitedStream.tellcCs|j}|st|S)N)rr)rxrrrrr|szLimitedStream.__next__cCsdS)NTr)rxrrrreadableszLimitedStream.readable)r)N)N)N)r~rrrr;r=r>r/rzr{propertyrrrrrrrrZListrrr|rrrrrrA<s   rA).r)FFFN)N)T)rGrH)rGrH)rGrH)rGrH)rGrWT)r()NrF()NrF)rCrFrLrMrTrVrrjrkrrrrrrrIOBaserArrrrs|               !$$9  \64Z&Z(G