a i@sddlZddlZddlZddlZddlZddlZgdZgdZgdZgdZ gdZ gdZ gdZ d Z d Zgd Zd ZiZd dZdZdZddZeefddZeefddZddZGdddeZGdddeZGdddeZGdd d eeZGd!d"d"eeZdd#lmZed$d%Z ed&d'Z!ed(d)Z"d*e _#d+e j$_#d,e j%_#d-e!_#d.e!j&_#d/e!j'_#d0e!j(_#d1e!j)_#d2e!j%_#d3e"_#e!j&j#e"j&_#e!j'j#e"j'_#e!j(j#e"j(_#d4e"j*_#e!j)j#e"j)_#e!j%j#e"j%_#eZ+Gd5d$d$e eZ,Gd6d&d&e!eZ-Gd7d(d(e"eZ.Gd8d9d9e eZ/Gd:d;d;e!eZ0Gdd?Z2e2[2ddBdCZ3dDdEZ4ddFdGZ5dHdIZ6dJdKZ7dLdMZ8ddNdOZ9dPdQZ:dRdSZ;ddTdUZda?dYdZZ@eAd[ZBdd^d_ZCddbdcZDddddeZEddfdgZFeGdhZHeIeHZJiZKGdidjdjejLZMddldmZNddndoZOddpdqZPd`d@ddeOfdrdsZQdtduZRdvdwZSdxdyZTdzd{ZUdaVd|d}ZWd~dZXdaYddZZddZ[ddZ\ddZ]ddZ^ddZ_da`ddZadddZbdddZcddZdddZeddZfddZgddZhddZiddZjddZkdS)N)urlparse urlunparseurljoin urldefragurlsplit urlunsplit urlencodeparse_qs parse_qslquote quote_plusquote_from_bytesunquote unquote_plusunquote_to_bytes DefragResult ParseResult SplitResultDefragResultBytesParseResultBytesSplitResultBytes)ftphttpgophernntpimapwaisfilehttpsshttpmmsprosperortsprtspusftpsvnsvn+sshwswss)rrrrrtelnetrrrr!rr snewsr"r#r$rsyncr&r'r%nfsgitzgit+sshr(r))rrhdlr"rrrr r#r$sipsipsr!r%tel) rr/mailtonewsr*rrr+r0r1) rrrrrr r!rr#r$r0r1) rrr/rrr4rrrr r+rr"zAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!  )   cCsttdSN) _parse_cacheclear _safe_quotersr=r=$/usr/lib64/python3.9/urllib/parse.py clear_cacheasr?asciistrictcCs|Sr9r=)objr=r=r>_nooppsrCcCs |||Sr9encode)rBencodingerrorsr=r=r>_encode_resultssrHcstfdd|DS)Nc3s"|]}|r|ndVqdS)rNdecode.0xrFrGr=r> yz_decode_args..)tuple)argsrFrGr=rNr> _decode_argswsrScGsVt|dt}|ddD]}|rt|t|krtdq|rH|tfSt|tfS)Nrz$Cannot mix str and non-str arguments) isinstancestr TypeErrorrCrSrH)rR str_inputargr=r=r> _coerce_args{s  rZc@seZdZdZdddZdS)_ResultMixinStrr=r@rAcs|jfdd|DS)Nc3s|]}|VqdSr9rDrKrNr=r>rOrPz)_ResultMixinStr.encode..)_encoded_counterpartselfrFrGr=rNr>rEsz_ResultMixinStr.encodeN)r@rA)__name__ __module__ __qualname__ __slots__rEr=r=r=r>r[sr[c@seZdZdZdddZdS)_ResultMixinBytesr=r@rAcs|jfdd|DS)Nc3s|]}|VqdSr9rIrKrNr=r>rOrPz+_ResultMixinBytes.decode..)_decoded_counterpartr]r=rNr>rJsz_ResultMixinBytes.decodeN)r@rA)r_r`rarbrJr=r=r=r>rcsrcc@sJeZdZdZeddZeddZeddZedd Ze e j Z d S) _NetlocResultMixinBaser=cCs |jdS)Nr _userinfor^r=r=r>usernamesz_NetlocResultMixinBase.usernamecCs |jdS)NrTrfrhr=r=r>passwordsz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|tr dnd}||\}}}|||S)Nr%%) _hostinforUrV partitionlower)r^hostname separatorpercentzoner=r=r>rps  z_NetlocResultMixinBase.hostnamecCsj|jd}|durfzt|d}Wn&tyFd|}t|dYn0d|kr\dksfntd|S)NrT z+Port could not be cast to integer value as rizPort out of range 0-65535)rmint ValueError)r^portmessager=r=r>rws   z_NetlocResultMixinBase.portN) r_r`rarbpropertyrirjrprw classmethodtypes GenericAlias__class_getitem__r=r=r=r>res    rec@s(eZdZdZeddZeddZdS)_NetlocResultMixinStrr=cCsD|j}|d\}}}|r4|d\}}}|srgsz_NetlocResultMixinStr._userinfocCsl|j}|d\}}}|d\}}}|rL|d\}}}|d\}}}n|d\}}}|sdd}||fS)Nr[]rrr^r_r have_open_br bracketedrprwr=r=r>rmsz_NetlocResultMixinStr._hostinfoNr_r`rarbryrgrmr=r=r=r>r~s  r~c@s(eZdZdZeddZeddZdS)_NetlocResultMixinBytesr=cCsD|j}|d\}}}|r4|d\}}}|srgsz!_NetlocResultMixinBytes._userinfocCsl|j}|d\}}}|d\}}}|rL|d\}}}|d\}}}n|d\}}}|sdd}||fS)Nr[]rrrr=r=r>rmsz!_NetlocResultMixinBytes._hostinfoNrr=r=r=r>rs  r) namedtuplerz url fragmentrz!scheme netloc path query fragmentrz(scheme netloc path params query fragmentz DefragResult(url, fragment) A 2-tuple that contains the url without fragment identifier and the fragment identifier as a separate argument. z$The URL with no fragment identifier.z Fragment identifier separated from URL, that allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information. z SplitResult(scheme, netloc, path, query, fragment) A 5-tuple that contains the different components of a URL. Similar to ParseResult, but does not split params. z%Specifies URL scheme for the request.z0 Network location where the request is made to. z@ The hierarchical path, such as the path to a file to download. z The query component, that contains non-hierarchical data, that along with data in path component, identifies a resource in the scope of URI's scheme and network location. z Fragment identifier, that allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information. zq ParseResult(scheme, netloc, path, params, query, fragment) A 6-tuple that contains components of a parsed URL. z Parameters for last path element used to dereference the URI in order to provide access to perform some operation on the resource. c@seZdZdZddZdS)rr=cCs |jr|jd|jS|jSdSN#fragmenturlrhr=r=r>geturlLszDefragResult.geturlNr_r`rarbrr=r=r=r>rJsc@seZdZdZddZdS)rr=cCst|Sr9rrhr=r=r>rTszSplitResult.geturlNrr=r=r=r>rRsc@seZdZdZddZdS)rr=cCst|Sr9rrhr=r=r>rYszParseResult.geturlNrr=r=r=r>rWsc@seZdZdZddZdS)rr=cCs |jr|jd|jS|jSdS)N#rrhr=r=r>r_szDefragResultBytes.geturlNrr=r=r=r>r]src@seZdZdZddZdS)rr=cCst|Sr9rrhr=r=r>rgszSplitResultBytes.geturlNrr=r=r=r>resrc@seZdZdZddZdS)rr=cCst|Sr9rrhr=r=r>rlszParseResultBytes.geturlNrr=r=r=r>rjsrcCs4ttfttfttff}|D]\}}||_||_qdSr9)rrrrrrr\rd)Z _result_pairsZ_decodedZ_encodedr=r=r>_fix_result_transcodingps rrTc Csft||\}}}t|||}|\}}}}}|tvrHd|vrHt|\}}nd}t||||||} || S)N;r)rZr uses_params _splitparamsr) rschemeallow_fragments_coerce_result splitresultrqueryrparamsresultr=r=r>r}s rcCsRd|vr,|d|d}|dkr6|dfSn |d}|d|||ddfS)N/rrrrT)findrfind)rir=r=r>rs   rcCsHt|}dD]"}|||}|dkr t||}q |||||dfS)Nz/?#r)lenrmin)rstartdelimcwdelimr=r=r> _splitnetlocs   rcCs|r |rdSddl}|dd}|dd}|dd}|dd}|d|}||kr`dSdD] }||vrdtd |d d qddS) Nrrrrr?NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)isascii unicodedatareplace normalizerv)rrnnetloc2rr=r=r> _checknetlocs       rcCsr|dd}|d\}}}|rV|r.td|d\}}}|rf|dsftdn|d\}}}t|dS)NrrInvalid IPv6 URLrr)rrnrv startswith_check_bracketed_host)rhostname_and_portbefore_bracketrrrprrwr=r=r>_check_bracketed_netlocs rcCsB|dr td|s>tdnt|}t|tjr>tddS)Nvz\Av[a-fA-F0-9]+\..+\ZzIPvFuture address is invalidz%An IPv4 address cannot be in brackets)rrematchrv ipaddress ip_addressrU IPv4Address)rpipr=r=r>rs      rc Cst||\}}}|t}|t}tD]}||d}||d}q(t|}|||t|t|f}t |d}|r|||St tt krt d}}} | d} | dkr|d| D]} | tvrqq|d| || dd}}|dddkrXt|d\}}d|vr d|vs4d|vrrsL       " rcCs<t|\}}}}}}}|r&d||f}|t|||||fS)Nz%s;%s)rZr) componentsrrrrrrrr=r=r>rs  rcCst|\}}}}}}|s4|r$|tvs4|dddkr`|rP|dddkrPd|}d|pXd|}|rp|d|}|r|d|}|r|d|}||S) NrrrTrrrrr)rZ uses_netloc)rrrrrrrr=r=r>r#s    rc Cs|s|S|s|St||\}}}t|d|\}}}}}} t|||\} } } } }}| |ks`| tvrh||S| tvr| r|t| | | | ||fS|} | s| s|} |} |s|}|t| | | | ||fS|d}|ddkr|d=| dddkr| d}n(|| d}td|dd|dd<g}|D]N}|dkrZz |WntyVYn0n|dkrjq(n | |q(|ddvr| d|t| | d |pd| ||fS)NrrrT...)rr) rZr uses_relativerrrfilterpop IndexErrorappendjoin)baserrrbschemebnetlocbpathbparamsbquery bfragmentrrpathrrr base_partssegments resolved_pathsegr=r=r>r6sb            rc CsTt|\}}d|vr>t|\}}}}}}t|||||df}nd}|}|t||S)Nrr)rZrrr) rrsrpaqfragdefragr=r=r>r{s r0123456789ABCDEFabcdefc Cs|s|jdSt|tr"|d}|d}t|dkr<|S|dg}|j}tdurbddtDa|ddD]P}z(|t|dd||ddWqnty|d||Yqn0qnd |S) NrPutf-8rlrTrcSs.i|]&}tD]}||t||q qSr=)_hexdigrEbytesfromhex)rLrrr=r=r> s z$unquote_to_bytes..r) rrUrVrErr _hextobyterKeyErrorr)stringbitsresritemr=r=r>rs,      rz([-]+)rrcCst|trt|||Sd|vr,|j|S|dur8d}|durDd}t|}|dg}|j}tdt|dD],}|t|||||||dqnd |S)NrkrrrrTrr) rUrrrJr_asciirerrangerr)rrFrGrrrrr=r=r>rs   rF&c CsNi}t|||||||d}|D]*\} } | |vr>|| | q| g|| <q|S)N)rFrGmax_num_fieldsrq)r r) qskeep_blank_valuesstrict_parsingrFrGrrq parsed_resultpairsnamevaluer=r=r>r s  r cCs.t|\}}t|\}}|r*t|ttfs2td|durXd||} || krXtddd||D} g} | D]} | s|sqt| dd} t| dkr|rtd| f|rt| d nqtt| ds|rt| d  d d }t |||d }||}| d d d }t |||d }||}| ||fqt| S)Nz*Separator must be of type string or bytes.rTzMax number of fields exceededcSsg|]}|qSr=r=)rLs1r=r=r> rPzparse_qsl..=rzbad query field: %rrr+ rN) rZrUrVrrvcountrrrrr)rr r rFrGrrqrr num_fieldsr r name_valuenvr rr=r=r>r s:     r cCs|dd}t|||S)Nrr)rr)rrFrGr=r=r>r7s rsBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-~c@s$eZdZddZddZddZdS)QuotercCst||_dSr9) _ALWAYS_SAFEunionsafe)r^rr=r=r>__init__OszQuoter.__init__cCsd|jjt|fS)Nz<%s %r>) __class__r_dictrhr=r=r>__repr__SszQuoter.__repr__cCs(||jvrt|nd|}|||<|S)Nz%{:02X})rchrformat)r^rrr=r=r> __missing__WszQuoter.__missing__N)r_r`rarr r#r=r=r=r>rGsrrcCsbt|tr8|s|S|durd}|dur*d}|||}n |durHtd|durXtdt||S)NrrAz,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)rUrVrErWr )rrrFrGr=r=r>r ]s' r cCsdt|trd|vs$t|tr2d|vr2t||||St|trBd}nd}t|||||}|ddS)Nr r)rUrVrr r)rrrFrGspacer=r=r>r s r cst|ttfstd|sdSt|tr6|dd}ntdd|D}|t|s^|Sz t |Wn$t yt |j t |<Yn0d fdd|DS)Nz!quote_from_bytes() expected bytesrr@ignorecSsg|]}|dkr|qS)r=)rLrr=r=r>rrPz$quote_from_bytes..csg|] }|qSr=r=)rLcharquoterr=r>rrP)rUr bytearrayrWrVrErstrip_ALWAYS_SAFE_BYTESrJr<rr __getitem__r)bsrr=r)r>r s   r c Cst|dr|}nNzt|r0t|dts0tWn.ty`t\}}}td|Yn0g} |s|D]j\} } t| t r|| |} n|t | |||} t| t r|| |} n|t | |||} | | d| qnn |D]\} } t| t r|| |} n|t | |||} t| t r@|| |} | | d| qt| t rn|| |||} | | d| qz t| } Wn8ty|t | |||} | | d| Yq0| D]B} t| t r|| |} n|t | |||} | | d| qqd | S)Nitemsrz1not a valid non-string sequence or mapping objectrr) hasattrr0rrUrQrWsysexc_infowith_tracebackrrVrr)rdoseqrrFrG quote_viatyvatblkrrMeltr=r=r>rsR                 rcCstjdtddt|S)Nz/urllib.parse.to_bytes() is deprecated as of 3.8r stacklevel)warningswarnDeprecationWarning _to_bytesrr=r=r>to_bytes srDcCsHt|trDz|d}Wn&tyBtdt|dYn0|S)NASCIIzURL z contains non-ASCII characters)rUrVrErJ UnicodeErrorreprrCr=r=r>rBs    rBcCs`t|}|dddkr<|dddkr<|dd}|dddkr\|dd}|S)NrTzURL:)rVrrCr=r=r>unwraps   rKcCstjdtddt|S)NzUurllib.parse.splittype() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splittyperCr=r=r> splittype,srMcCsDtdurtdtjat|}|r<|\}}||fSd|fS)Nz ([^/:]+):(.*)) _typeprogrcompileDOTALLrgroupsro)rrrdatar=r=r>rL4s   rLcCstjdtddt|S)NzUurllib.parse.splithost() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splithostrCr=r=r> splithostAsrTcCsXtdurtdtjat|}|rP|\}}|rH|ddkrHd|}||fSd|fS)Nz//([^/#?]*)(.*)rr) _hostprogrrOrPrrQ)rr host_portrr=r=r>rSIs  rScCstjdtddt|S)NzUurllib.parse.splituser() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splituserhostr=r=r> splituserXsrZcCs |d\}}}|r|nd|fS)Nrr)rYuserrr=r=r>rW_srWcCstjdtddt|S)NzWurllib.parse.splitpasswd() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splitpasswd)r\r=r=r> splitpasswdesr^cCs |d\}}}||r|ndfSNrrn)r\rpasswdr=r=r>r]lsr]cCstjdtddt|S)NzUurllib.parse.splitport() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splitportrXr=r=r> splitportrsrccCsDtdurtdtjat|}|r<|\}}|r<||fS|dfS)Nz (.*):([0-9]*)) _portprogrrOrP fullmatchrQ)rYrrwr=r=r>rb{s  rbrcCstjdtddt||S)NzVurllib.parse.splitnport() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splitnport)rYdefportr=r=r> splitnportsrhcCsR|d\}}}|s|}n0|rJz t|}Wnty@d}Yn0||fS||fSr_)rrurv)rYrgrrwnportr=r=r>rfs   rfcCstjdtddt|S)NzVurllib.parse.splitquery() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splitqueryrCr=r=r> splitquerysrkcCs$|d\}}}|r||fS|dfS)Nrr[)rrrrr=r=r>rjsrjcCstjdtddt|S)NzTurllib.parse.splittag() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splittagrCr=r=r>splittagsrmcCs$|d\}}}|r||fS|dfSrr[)rrrtagr=r=r>rlsrlcCstjdtddt|S)NzUurllib.parse.splitattr() is deprecated as of 3.8, use urllib.parse.urlparse() insteadrr=)r?r@rA _splitattrrCr=r=r> splitattrsrpcCs|d}|d|ddfS)NrrrT)r)rwordsr=r=r>ros rocCstjdtddt|S)NzWurllib.parse.splitvalue() is deprecated as of 3.8, use urllib.parse.parse_qsl() insteadrr=)r?r@rA _splitvalue)attrr=r=r> splitvaluesrtcCs |d\}}}||r|ndfS)Nrr`)rsrrr=r=r>rrsrr)rT)r)rT)T)rr)FFrrNr)FFrrNr)rr)rNN)rNN)r)r)r)lrr2r{ collectionsr?r__all__rrrnon_hierarchical uses_query uses_fragmentrrrrr:r?_implicit_encoding_implicit_errorsrCrHrSrZobjectr[rcrer~rr_DefragResultBase_SplitResultBase_ParseResultBase__doc__rrrrrrr ResultBaserrrrrrrrrrrrrrrrrrrrrrOrrr r r frozensetrrr-r< defaultdictrr r r rrDrBrKrMrNrLrTrUrSrZrWr^r]rcrdrbrhrfrkrjrmrlrprortrrr=r=r=r>"s    '           >  E   * C  6   Q