/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__/urls.cpython-36.pyc (36414B)
3 _TBg? @sTUdZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z ej r|dd lmZejd Zeed Zd Zd deDZddedDZGdddejZGdddeZGdddeZGdddeZeeiZej ej!e"ej e#e"ffdmej$e%e#fej$e%e#fe#dddZ&ej$ej'e%e%fej(ej)e%e%ffe%e*ej+ej,ej)e%e%fgej-fej.e%ddd Z/dne%e%e%d!d"d#Z0doe%ej+e%e*ed%d&d'Z1dpe%e%ej$e%e#fej$e%e#fej,e#ge%fd+d,d-Z2e2Z3e2d.d/d0Z4e#e%d1d2d3Z5dqej$e%e#fe%e%ej$e%e#fej$e%e#fe%d4d5d6Z6dre%e%e%e%e%d7d8d9Z7ej)e%e%e%e%e%fe%d:d;d<Z8dsej$e%e#fe%e%e%e%d>d?d@Z9dtej$e%e#fe%e%e%dAdBdCZ:due%e%e%dDdEdFZ;djej)e%e"fdIdJdKZ?ej@dLe?dvej$e%ej)e%e%e%e%e%ffe%e%e%dMdNdOZAdPZBdwej$e%ej)e%e%e%e%e%ffe%e%e*e%dRdSdTZCdxejDe%de*e%e%ej+ejEdVdWdXdYdZZFdyejGe#e%de*e%e#ej+ejEdVej+e"e*dWd\ d]d^ZHej(ejDe%e*e%ej.ej)e%e%fd_d`daZIdzej$ej'e%e%fej(ej)e%e%ffe%de*ej+ej,ej)e%e%fgej-fe%e%dbdcddZJd{ej$ej'e%e%fej(ej)e%e%ffej+ejGe%e%de*ej+ej,ej)e%e%fgej-fe%ddedfdgZKd|ej$e%ej)e%e%e%e%e%ffej$e%ej)e%e%e%e%e%ffe*e%dhdidjZLGdkdldlZMdS)}zFunctions for working with URLs. Contains implementations of functions from :mod:`urllib.parse` that handle bytes and strings. N)_check_str_tuple) _decode_idna) _encode_idna)_make_encode_wrapper)_to_str)datastructuresz^[a-zA-Z0-9+-.]+$sBabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~0123456789ABCDEFabcdefcCs8i|]0}tD]&}t||d||jdq qS)ascii) _hexdigitsintencode).0abr1/tmp/pip-build-0s3hx122/Werkzeug/werkzeug/urls.py #srcCsg|]}d|djdqS)%02Xr )r)rcharrrr (src@s"eZdZUeeeeedS) _URLTupleN) __name__ __module__ __qualname__strschemenetlocpathqueryfragmentrrrrr+s rc@s eZdZUdZfZeeee edddZ e j ddddZ ee jeddd Zee jedd d Zee jedd d Zee jedddZee jedddZee jedddZee jedddZee jedddZe j e j ddddZe j e j ddddZedddZedd d!Zedd"d#Zddd$d%Zddd&d'Zd2e jee j e jee jefd)d*d+Z!e j e jeefdd,d-Z"e j e jee jefdd.d/Z#e j e jee jefdd0d1Z$d(S)3BaseURLz7Superclass of :py:class:`URL` and :py:class:`BytesURL`.)returncCs|jS)N)to_url)selfrrr__str__<szBaseURL.__str__)kwargsr%cKs |jf|S)zReturn an URL with the same values, except for those parameters given new values by whichever keyword arguments are specified.)_replace)r'r)rrrreplace?szBaseURL.replacecCs |jdS)zThe host part of the URL if available, otherwise `None`. The host is either the hostname or the IP address mentioned in the URL. It will not contain the port. r) _split_host)r'rrrhostDsz BaseURL.hostc CsR|j}|dk rFt|trFy t|}Wn tk rD|jdd}YnXt|ddS)a Works exactly like :attr:`host` but will return a result that is restricted to ASCII. If it finds a netloc that is not ASCII it will attempt to idna decode it. This is useful for socket operations when the URL might include internationalized characters. Nr ignore)r- isinstancerr UnicodeErrorrr)r'rvrrr ascii_hostLs zBaseURL.ascii_hostc CsRy4tt|jd}d|ko(dknr2|SWnttfk rLYnXdS)z}The port in the URL as an integer if it was present, `None` otherwise. This does not fill in default ports. rriN)r rr, ValueError TypeError)r'r1rrrport[sz BaseURL.portcCs |jdS)zSThe authentication part in the URL if available, `None` otherwise. r) _split_netloc)r'rrrauthhsz BaseURL.authcCs |jd}|dk rt|SdS)zThe username if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a string. rN) _split_auth_url_unquote_legacy)r'r1rrrusernameos zBaseURL.usernamecCs |jdS)zThe username if it was part of the URL, `None` otherwise. Unlike :attr:`username` this one is not being decoded. r)r8)r'rrr raw_usernameyszBaseURL.raw_usernamecCs |jd}|dk rt|SdS)zThe password if it was part of the URL, `None` otherwise. This undergoes URL decoding and will always be a string. rN)r8r9)r'r1rrrpasswords zBaseURL.passwordcCs |jdS)zThe password if it was part of the URL, `None` otherwise. Unlike :attr:`password` this one is not being decoded. r)r8)r'rrr raw_passwordszBaseURL.raw_passwordzds.MultiDict[str, str])argsr)r%cOst|jf||S)zDecodes the query part of the URL. Ths is a shortcut for calling :func:`url_decode` on the query argument. The arguments and keyword arguments are forwarded to :func:`url_decode` unchanged. ) url_decoder")r'r>r)rrr decode_queryszBaseURL.decode_querycOstt|f||S)zJoins this URL with another one. This is just a convenience function for calling into :meth:`url_join` and then parsing the return value again. ) url_parseurl_join)r'r>r)rrrjoinsz BaseURL.joincCst|S)zReturns a URL string or bytes depending on the type of the information stored. This is just a convenience function for calling :meth:`url_unparse` for this URL. ) url_unparse)r'rrrr&szBaseURL.to_urlc Cs|jpd}d|krd|d}|j}|dk r:|d|}djtdt|jpLddddt|jp^ddddg}|r|d |}|S) z6Encodes the netloc part to an ASCII safe URL as bytes.:[]Nzutf-8strictz/:%@)r2r5rCfilter url_quoter;r=)r'r1r5r7rrr encode_netlocs  zBaseURL.encode_netloccCst|jp d}d|kr"d|d}|j}|dk r>|d|}djtdt|jpPddt|jp^ddg}|r||d|}|S)z&Decodes the netloc part into a string.rErFrGrHNz/:%@rJ)rr-r5rCrKr9r;r=)r'r1r5r7rrr decode_netlocs zBaseURL.decode_netloccCs tt|S)a*Returns a :class:`BytesURL` tuple that holds a URI. This will encode all the information in the URL properly to ASCII using the rules a web browser would follow. It's usually more interesting to directly call :meth:`iri_to_uri` which will return a string. )rA iri_to_uri)r'rrr to_uri_tupleszBaseURL.to_uri_tuplecCs tt|S)aSReturns a :class:`URL` tuple that holds a IRI. This will try to decode as much information as possible in the URL without losing information similar to how a web browser does it for the URL bar. It's usually more interesting to directly call :meth:`uri_to_iri` which will return a string. )rA uri_to_iri)r'rrr to_iri_tuples zBaseURL.to_iri_tupleN) pathformatr%cCs>|jdkrdSt|j}|jp d}|dkr>tjdkr:d}nd}|dkr|dddkr|ddjr|dd d kr|ddd |d d}|dd dk}d dl}|j|}|o|dkr(|j d j d d}t |dkr|\}}n |d }d}n,|dkrd dl }|j|}nt d||dkr6d}||fS)a@Returns a tuple with the location of the file in the form ``(server, location)``. If the netloc is empty in the URL or points to localhost, it's represented as ``None``. The `pathformat` by default is autodetection but needs to be set when working with URLs of a specific system. The supported values are ``'windows'`` when working with Windows or DOS paths and ``'posix'`` when working with posix paths. If the URL does not point to a local file, the server and location are both represented as ``None``. :param pathformat: The expected format of the path component. Currently ``'windows'`` and ``'posix'`` are supported. Defaults to ``None`` which is autodetect. fileNntZwindowsposixr/z|:rF\rrEzInvalid path format 127.0.0.1::1 localhost)NN\\\///)r^r_)r[r\r])r url_unquoter!r osnameisalphantpathnormpathlstripsplitlen posixpathr4)r'rSr!r-Z windows_sharerdpartsrirrrget_file_locations6     0      zBaseURL.get_file_locationcCs2|j|jkr(|jj|j\}}}||fSd|jfS)N)_atr partition)r'r7_r rrrr6$s zBaseURL._split_netloccCs@|jd}|sdS|j|kr&|dfS|j|j\}}}||fS)Nr)NN)r6_colonrm)r'r7r:rnr<rrrr8*s  zBaseURL._split_authcCs|jd}|sdS|j|jsL|j|krD|j|j\}}}||fS|dfS|j|j}|dkrh|dfS|d|}||dd}|j|jr||ddfS|dfS)Nrr)NN)r6 startswith _lbracketrormfind _rbracket)r'r1r-rnr5idxrestrrrr,4s       zBaseURL._split_host)N)%rrr__doc__ __slots__rrlrorqrsr(tAnyr+propertyOptionalr-r2r r5r7r:r;r<r=r@rCr&rMrNrPrRTuplerkr6r8r,rrrrr$3sH      $<$ r$c@s8eZdZdZfZdZdZdZdZd e e dd d d Z d S)URLzRepresents a parsed URL. This behaves like a regular tuple but also has some extra attributes that give further insight into the URL. rJrFrGrHutf-8r+BytesURL)charseterrorsr%cCs:t|jjd|j|jj|||jj|||jj||S)zEncodes the URL to a tuple made out of bytes. The charset is only being used for the path, query and fragment. r )rrrrMr!r"r#)r'rrrrrrVs    z URL.encodeN)r~r+) rrrrvrwrlrorqrsrrrrrrr}Jsr}c@sTeZdZdZfZdZdZdZdZe dddZ e dd d Z de e d dddZ dS)rz!Represents a parsed URL in bytes.@:[])r%cCs|jjddS)Nzutf-8r+)r&decode)r'rrrr(lszBytesURL.__str__cCs|jS)z&Returns the netloc unchanged as bytes.)r )r'rrrrMoszBytesURL.encode_netlocutf-8r+r})rrr%cCs:t|jjd|j|jj|||jj|||jj||S)zDecodes the URL to a tuple made out of strings. The charset is only being used for the path, query and fragment. r )r}rrrNr!r"r#)r'rrrrrrss    zBytesURL.decodeN)rr+)rrrrvrwrlrorqrsrr(bytesrMrrrrrrcsrrE)stringunsafer%c st|tr|jd}ttr(jdttt|jd}tt|d}y t}Wn2t k rfddt j D}t<YnXxV|D]N}|dd}||kr|j |||j |ddq|j d|j |qWt|S)Nzutf-8%csi|]\}}|kr||qSrr)rhr)rrrrsz%_unquote_to_bytes..rX%)r/rr frozenset bytearrayiterrgnext _unquote_mapsKeyError _hextobyteitemsappendextendr)rrgroupsresultZ hex_to_bytegroupcoder)rr_unquote_to_bytess(          r)objrsortkeyr%c csddlm}||}|r$t||d}xn|D]f\}}|dkrszurl_parse..rXz//z/?#rGrHzInvalid IPv6 URL#?)rr/rrr _scheme_rematchranylowerrhminr3rgr}r) rrrZ is_text_basedr r"r#irudelimrwdelimZ result_typer)rrrAs4 " rAutf-8rI/:)rrsaferr%csvttrj||t|tr,|j||}tttBtt|fddtdDttdfdd }|S)aPrecompile the translation table for a URL encoding function. Unlike :func:`url_quote`, the generated function only takes the string to quote. :param charset: The charset to encode the result with. :param errors: How to handle encoding errors. :param safe: An optional sequence of safe characters to never encode. :param unsafe: An optional sequence of unsafe characters to always encode. cs(g|] }|krt|n d|dqS)rr)chr)rr)rrrrsz(_make_fast_url_quote..r)rr%csdjfdd|DS)NrEcsg|] }|qSrr)rr)tablerrrsz7_make_fast_url_quote..quote..)rC)r)rrrquotesz#_make_fast_url_quote..quote)r/rrrr _always_saferanger)rrrrrr)rrr_make_fast_url_quotes    r +)rr)rr%cCst|jddS)Nrr)_fast_quote_plusr+)rrrrrsr)rrrrrr%cCst|tttfst|}t|tr.|j||}t|trD|j||}t|trZ|j||}tt|tBtt|}t}x2t|D]&}||kr|j|q|jt |qWt|j |S)aDURL encode a single string with a given encoding. :param s: the string to quote. :param charset: the charset to be used. :param safe: an optional sequence of safe characters. :param unsafe: an optional sequence of unsafe characters. .. versionadded:: 0.9.2 The `unsafe` parameter was added. ) r/rrrrrrrr _bytetohexr)rrrrrr1rrrrrL#s       rL)rrrrr%cCst||||ddjddS)zURL encode a single string with the given encoding and convert whitespace to "+". :param s: The string to quote. :param charset: The charset to be used. :param safe: An optional sequence of safe characters. rr)rLr+)rrrrrrrurl_quote_plusFs r) componentsr%cCst||\}}}}}t|}|d}|s<|rz|j|drz|r`|dd|dkr`|d|}|d|pp|d|}n |r||7}|r||d|}|r||d|}|r||d|}|S) zThe reverse operation to :meth:`url_parse`. This accepts arbitrary as well as :class:`URL` tuples and returns a URL as a string. :param components: the parsed URL as tuple which should be converted into a URL string. rErWNrz//rFrr)rrrp)rrr r!r"r#rrrrrrDSs" rDr+)rrrrr%cCs"t||}|dkr|S|j||S)afURL decode a single string with a given encoding. If the charset is set to `None` no decoding is performed and raw bytes are returned. :param s: the string to unquote. :param charset: the charset of the query string. If set to `None` no decoding will take place. :param errors: the error handling for the charset decoding. N)rr)rrrrr1rrrr`rs r`)rrrr%cCs0t|tr|jdd}n |jdd}t|||S)aURL decode a single string with the given `charset` and decode "+" to whitespace. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. :param s: The string to unquote. :param charset: the charset of the query string. If set to `None` no decoding will take place. :param errors: The error handling for the `charset` decoding. rr+ )r/rr+r`)rrrrrrurl_unquote_pluss  r)rrr%cCst||djdd}|jdrP|ddjrP|dddkrPd |dd }t|}t|j|d d }t|j|dd }t|j |dd }t |j |j |||fS)aSometimes you get an URL by a user that just isn't a real URL because it contains unsafe characters like ' ' and so on. This function can fix some of the problems in a similar way browsers handle data entered by the user: >>> url_fix('http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)') 'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)' :param s: the string with the URL to fix. :param charset: The target charset for the URL if the url was given as a string. r+rZrWzfile:// :/|/zfile:///Nz /%+$!*'(),)rz :&%=+$!*'(),)rr) rr+rprcrArLr!rr"r#rDrrM)rrrr!qsanchorrrrurl_fixs*rcCsg|]}|tkrt|qSr)rr)rrrrrrs)er%cCs t|j|j|j}||jfS)zRUsed in :func:`uri_to_iri` after unquoting to re-quote any invalid bytes. )_fast_url_quoteobjectstartend)routrrr_codec_error_url_quotesrwerkzeug.url_quote)urirrr%cCsht|trt|}tt||}t|j||t}t|j||t}t|j ||t}t|j |j |||fS)aConvert a URI to an IRI. All valid UTF-8 characters are unquoted, leaving all reserved and invalid characters quoted. If the URL has a domain, it is decoded from Punycode. >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF") 'http://\u2603.net/p\xe5th?q=\xe8ry%DF' :param uri: The URI to convert. :param charset: The encoding to encode unquoted bytes with. :param errors: Error handler to use during ``bytes.encode``. By default, invalid bytes are left quoted. .. versionchanged:: 0.15 All reserved and invalid characters remain quoted. Previously, only some reserved characters were preserved, and invalid bytes were replaced instead of left quoted. .. versionadded:: 0.6 ) r/tuplerDrArr`r!_to_iri_unsafer"r#rrN)rrrr!r"r#rrrrQs rQz:/?#[]@!$&'()*+,;=%F)irirrsafe_conversionr%c Cst|trt|}|rVy*t|}|jd}t|jdkr>|SWntk rTYnXtt|||}t |j ||t }t |j ||t }t |j ||t }t|j|j|||fS)aConvert an IRI to a URI. All non-ASCII and unsafe characters are quoted. If the URL has a domain, it is encoded to Punycode. >>> iri_to_uri('http://\u2603.net/p\xe5th?q=\xe8ry%DF') 'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF' :param iri: The IRI to convert. :param charset: The encoding of the IRI. :param errors: Error handler to use during ``bytes.encode``. :param safe_conversion: Return the URL unchanged if it only contains ASCII characters and no whitespace. See the explanation below. There is a general problem with IRI conversion with some protocols that are in violation of the URI specification. Consider the following two IRIs:: magnet:?xt=uri:whatever itms-services://?action=download-manifest After parsing, we don't know if the scheme requires the ``//``, which is dropped if empty, but conveys different meanings in the final URL if it's present or not. In this case, you can use ``safe_conversion``, which will return the URL unchanged if it only contains ASCII characters and no whitespace. This can result in a URI with unquoted characters if it was not already quoted correctly, but preserves the URL's semantics. Werkzeug uses this for the ``Location`` header for redirects. .. versionchanged:: 0.15 All reserved characters remain unquoted. Previously, only some reserved characters were left unquoted. .. versionchanged:: 0.9.6 The ``safe_conversion`` parameter was added. .. versionadded:: 0.6 r r)r/rrDrrrhrgr0rArLr! _to_uri_safer"r#rrM) rrrrZ native_iriZ ascii_irir!r"r#rrrrOs+  rO&z ds.MultiDictzds.MultiDict[str, str])rr decode_keys include_emptyr separatorclsr%cCs|dk rtjdtdd|dkr0ddlm}|}t|trVt|t rV|j|pPd}n$t|trzt|t rz|j |pvd}|t |j ||||S)awParse a query string and return it as a :class:`MultiDict`. :param s: The query string to parse. :param charset: Decode bytes to string with this charset. If not given, bytes are returned as-is. :param include_empty: Include keys with empty values in the dict. :param errors: Error handling behavior when decoding bytes. :param separator: Separator character between pairs. :param cls: Container to hold result instead of :class:`MultiDict`. .. versionchanged:: 2.0 The ``decode_keys`` parameter is deprecated and will be removed in Werkzeug 2.1. .. versionchanged:: 0.5 In previous versions ";" and "&" could be used for url decoding. Now only "&" is supported. If you want to use ";", a different ``separator`` can be provided. .. versionchanged:: 0.5 The ``cls`` parameter was added. Nz@'decode_keys' is deprecated and will be removed in Werkzeug 2.1.rX) stacklevelr) MultiDictr ) warningswarnDeprecationWarningrrr/rrrr_url_decode_implrg)rrrrrrrrrrrr?3s r?&) streamrrrrrrlimitreturn_iteratorr%c Csvddlm} |dk r$tjdtdd| |||} t| |||} |rVtjdtdd| S|dkrnddlm} | }|| S) a_Works like :func:`url_decode` but decodes a stream. The behavior of stream and limit follows functions like :func:`~werkzeug.wsgi.make_line_iter`. The generator of pairs is directly fed to the `cls` so you can consume the data while it's parsed. :param stream: a stream with the encoded querystring :param charset: the charset of the query string. If set to `None` no decoding will take place. :param include_empty: Set to `False` if you don't want empty values to appear in the dict. :param errors: the decoding error behavior. :param separator: the pair separator to be used, defaults to ``&`` :param cls: an optional dict class to use. If this is not specified or `None` the default :class:`MultiDict` is used. :param limit: the content length of the URL data. Not necessary if a limited stream is provided. .. versionchanged:: 2.0 The ``decode_keys`` and ``return_iterator`` parameters are deprecated and will be removed in Werkzeug 2.1. .. versionadded:: 0.8 r)make_chunk_iterNz@'decode_keys' is deprecated and will be removed in Werkzeug 2.1.rX)rzD'return_iterator' is deprecated and will be removed in Werkzeug 2.1.)r)Zwsgirrrrrrr) rrrrrrrrrr pair_iterdecoderrrrrurl_decode_streamgs$#   r)rrrrr%c csnxh|D]`}|sqt|}|d}||kr:|j|d\}}n|s@q|}|d}t|||t|||fVqWdS)NrrrE)rrgr) rrrrpairrequalrrrrrrs  r)rr encode_keysrrrr%cCs6|dk rtjdtddt|d}|jt||||S)aURL encode a dict/`MultiDict`. If a value is `None` it will not appear in the result string. Per default only values are encoded into the target charset strings. :param obj: the object to encode into a query string. :param charset: the charset of the query string. :param sort: set to `True` if you want parameters to be sorted by `key`. :param separator: the separator to be used for the pairs. :param key: an optional function to be used for sorting. For more details check out the :func:`sorted` documentation. .. versionchanged:: 2.0 The ``encode_keys`` parameter is deprecated and will be removed in Werkzeug 2.1. .. versionchanged:: 0.5 Added the ``sort``, ``key``, and ``separator`` parameters. Nz@'encode_keys' is deprecated and will be removed in Werkzeug 2.1.rX)rr )rrrrrCr)rrrrrrrrr url_encodes r)rrrrrrrr%c Csn|dk rtjdtddt|d}t||||}|dkr<|Sx,t|D] \}} |r\|j||j| qFWdS)aLike :meth:`url_encode` but writes the results to a stream object. If the stream is `None` a generator over all encoded pairs is returned. :param obj: the object to encode into a query string. :param stream: a stream to write the encoded object into or `None` if an iterator over the encoded pairs should be returned. In that case the separator argument is ignored. :param charset: the charset of the query string. :param sort: set to `True` if you want parameters to be sorted by `key`. :param separator: the separator to be used for the pairs. :param key: an optional function to be used for sorting. For more details check out the :func:`sorted` documentation. .. versionchanged:: 2.0 The ``encode_keys`` parameter is deprecated and will be removed in Werkzeug 2.1. .. versionadded:: 0.8 Nz@'encode_keys' is deprecated and will be removed in Werkzeug 2.1.rX)rr )rrrrr enumeratewrite) rrrrrrrgenrtchunkrrrurl_encode_streams  r)baserrr%cst|trt|}t|tr$t|}t||ft||s@|S|sH|St||d\}}}}}t|||\}} } } } ||kr|S| rt|| | | | fS|} | dddkr| jd} n@| s|jd} | s|} n$|jddd | jd} | d dkrd| d <fdd| D} xvd}t| d}x^||kr| |d kr| |ddd fkr| |d|d=P|d7}qBWPq0Wdd g}x| dd |kr| d=qWdj| } t|| | | | fS)a Join a base URL and a possibly relative URL to form an absolute interpretation of the latter. :param base: the base URL for the join operation. :param url: the URL to join. :param allow_fragments: indicates whether fragments should be allowed. )rNrrW.rEcsg|]}|dkr|qS)rr)rZsegment)rrrr?szurl_join..z..rXrr) r/rrDrrrArgrhrC)rrrbschemebnetlocbpathbquery bfragmentrr r!r"r#segmentsrnZunwanted_markerr)rrrB sT   $   0 rBc@s*eZdZdZd ddZdd Zd d ZdS) HrefanImplements a callable that constructs URLs with the given base. The function can be called with any number of positional and keyword arguments which than are used to assemble the URL. Works with URLs and posix paths. Positional arguments are appended as individual segments to the path of the URL: >>> href = Href('/foo') >>> href('bar', 23) '/foo/bar/23' >>> href('foo', bar=23) '/foo/foo?bar=23' If any of the arguments (positional or keyword) evaluates to `None` it will be skipped. If no keyword arguments are given the last argument can be a :class:`dict` or :class:`MultiDict` (or any other dict subclass), otherwise the keyword arguments are used for the query parameters, cutting off the first trailing underscore of the parameter name: >>> href(is_=42) '/foo?is=42' >>> href({'foo': 'bar'}) '/foo?foo=bar' Combining of both methods is not allowed: >>> href({'foo': 'bar'}, bar=42) Traceback (most recent call last): ... TypeError: keyword arguments and query-dicts can't be combined Accessing attributes on the href object creates a new href object with the attribute name as prefix: >>> bar_href = href.bar >>> bar_href("blub") '/foo/bar/blub' If `sort` is set to `True` the items are sorted by `key` or the default sorting algorithm: >>> href = Href("/", sort=True) >>> href(a=1, b=2, c=3) '/?a=1&b=2&c=3' .. deprecated:: 2.0 Will be removed in Werkzeug 2.1. Use :mod:`werkzeug.routing` instead. .. versionadded:: 0.5 `sort` and `key` were added. ./utf-8FNcCs4tjdtdd|sd}||_||_||_||_dS)NzY'Href' is deprecated and will be removed in Werkzeug 2.1. Use 'werkzeug.routing' instead.rX)rz./)rrrrrrr)r'rrrrrrr__init__sz Href.__init__cCsP|dddkrt||j}|dddkr6|d7}tt|||j|j|jS)NrX__rrWr)AttributeErrorrrrBrrr)r'rbrrrr __getattr__s zHref.__getattr__c s|r6t|d tr6|rtd|d |dd}}n|rLdd|jD}djfdd|Djd}j}|r|jds|d7}t|d|}|r|d t t |j j j d d 7}|S)Nrz3keyword arguments and query-dicts can't be combinedcSs,i|]$\}}||jdr$|ddn|qS)rnNrr)endswith)rkvrrrrsz!Href.__call__..rWcs&g|]}|dk rtt|jdqS)Nr )rrLr)rx)r'rrrsz!Href.__call__..z./r)rrr rrr)r/dictr4rrCrfrrrBrrrrr)r'r!r"r1r)r'r__call__s&   z Href.__call__)r r FN)rrrrvr rrrrrrrTs5 r)rE)rE)NT)rrIrrE)rrIrrE)rrIrE)rr+rE)rr+)r)rr)rrIF)rNTr+rN)rNTr+rNNF)rNFNr)NrNFNr)T)NrvcodecsrareZtypingrxrZ _internalrrrrrZ TYPE_CHECKINGrErZdscompilerrrrr rrrZ NamedTuplerr$r}rrDictZ FrozenSetr rUnionrrMappingIterabler|boolr{CallableryIteratorrr9rArrrrrLrrDr`rrrCrr0rregister_errorrQrrOZAnyStrTyper?ZIOrrrrrBrrrrrs       ( & 2 *  ! "$?.,6P^)<C