3 0f@s`ddlZddlZddlZdddddddd d d d d dddddddddgZdddddddddd d!d"d#d$d%d&d'd(d)gZdddddd*dddd!dd d+d"d#d$d,d&d'd%d-d.d/d(d)gZddd0d"dddd d#d$d1d2d!d%d3gZdd0d4d5d*ddd+d1d2g Zdddddd d!dd#d$d1d2g Zddd0ddd5dddd d+dd"g Z d6Z d7Z d8d9d:gZ d;Z iZdZd?Zd@dAZeefdBdCZeefdDdEZdFdGZGdHdIdIeZGdJdKdKeZGdLdMdMeZGdNdOdOeeZGdPdQdQeeZddRlmZeddSZeddTZeddUZdVe_ dWej!_ dXej"_ dYe_ dZej#_ d[ej$_ d\ej%_ d]ej&_ d^ej"_ d_e_ ej#j ej#_ ej$j ej$_ ej%j ej%_ d`ej'_ ej&j ej&_ ej"j ej"_ eZ(GdaddeeZ)GdbddeeZ*GdcddeeZ+GddddeeZ,GdeddeeZ-GdfddeeZ.dgdhZ/e/[/ddjdZ0dkdlZ1ddmdnZ2dodpZ3dqdrZ4ddsdZ5dtdZ6dudZ7ddvdZ8dwdZ9dxZ:da;dydZdd}dZ?ddd Z@ddd ZAdddZBeCdZDeEeDZFiZGGdddejHZIddd ZJddd ZKddd ZLd~dddeKfddZMddZNddZOdaPddZQdaRddZSddZTddZUdaVddZWdddZXddZYddZZddZ[ddZ\dS)Nurlparse urlunparseurljoin urldefragurlsplit urlunsplit urlencodeparse_qs parse_qslquote quote_plusquote_from_bytesunquote unquote_plusunquote_to_bytes DefragResult ParseResult SplitResultDefragResultBytesParseResultBytesSplitResultBytesZftphttpZgopherZnntpZimapZwaisfileZhttpsZshttpZmmsZprosperoZrtspZrtspuZsftpZsvnzsvn+sshZwsZwssZtelnetZsnewsZrsyncZnfsZgitzgit+sshZhdlZsipZsipsZtelZmailtoZnewszAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.z!     cCstjtjdS)N) _parse_cacheclear _safe_quotersr!r!$/usr/lib64/python3.6/urllib/parse.py clear_cache^sr#asciistrictcCs|S)Nr!)objr!r!r"_noopmsr'cCs |j||S)N)encode)r&encodingerrorsr!r!r"_encode_resultpsr+cstfdd|DS)Nc3s"|]}|r|jndVqdS)rN)decode).0x)r)r*r!r" vsz_decode_args..)tuple)argsr)r*r!)r)r*r" _decode_argstsr2cGsZt|dt}x.|ddD]}|rt|t|krtdqW|rL|tfSt|tfS)Nrz$Cannot mix str and non-str arguments) isinstancestr TypeErrorr'r2r+)r1Z str_inputargr!r!r" _coerce_argsxs  r8c@seZdZfZdddZdS)_ResultMixinStrr$r%cs|jfdd|DS)Nc3s|]}|jVqdS)N)r()r-r.)r)r*r!r"r/sz)_ResultMixinStr.encode..)_encoded_counterpart)selfr)r*r!)r)r*r"r(sz_ResultMixinStr.encodeN)r$r%)__name__ __module__ __qualname__ __slots__r(r!r!r!r"r9sr9c@seZdZfZdddZdS)_ResultMixinBytesr$r%cs|jfdd|DS)Nc3s|]}|jVqdS)N)r,)r-r.)r)r*r!r"r/sz+_ResultMixinBytes.decode..)_decoded_counterpart)r;r)r*r!)r)r*r"r,sz_ResultMixinBytes.decodeN)r$r%)r<r=r>r?r,r!r!r!r"r@sr@c@s@eZdZfZeddZeddZeddZeddZd S) _NetlocResultMixinBasecCs |jdS)Nr) _userinfo)r;r!r!r"usernamesz_NetlocResultMixinBase.usernamecCs |jdS)Nr3)rC)r;r!r!r"passwordsz_NetlocResultMixinBase.passwordcCsD|jd}|sdSt|tr dnd}|j|\}}}|j||S)Nr%%) _hostinfor4r5 partitionlower)r;hostnameZ separatorZpercentZzoner!r!r"rKs  z_NetlocResultMixinBase.hostnamecCs@|jd}|dk rr?propertyrDrErKrOr!r!r!r"rBs    rBc@s(eZdZfZeddZeddZdS)_NetlocResultMixinStrcCsD|j}|jd\}}}|r4|jd\}}}|sr?rPrCrHr!r!r!r"rQs rQc@s(eZdZfZeddZeddZdS)_NetlocResultMixinBytescCsD|j}|jd\}}}|r4|jd\}}}|sr?rPrCrHr!r!r!r"r_s r_) namedtuplez url fragmentz!scheme netloc path query fragmentz(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. zr 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@seZdZfZddZdS)rcCs |jr|jd|jS|jSdS)N#)fragmenturl)r;r!r!r"geturlCszDefragResult.geturlN)r<r=r>r?rhr!r!r!r"rAsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rhKszSplitResult.geturlN)r<r=r>r?rhr!r!r!r"rIsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rhPszParseResult.geturlN)r<r=r>r?rhr!r!r!r"rNsc@seZdZfZddZdS)rcCs |jr|jd|jS|jSdS)N#)rfrg)r;r!r!r"rhVszDefragResultBytes.geturlN)r<r=r>r?rhr!r!r!r"rTsc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rh^szSplitResultBytes.geturlN)r<r=r>r?rhr!r!r!r"r\sc@seZdZfZddZdS)rcCst|S)N)r)r;r!r!r"rhcszParseResultBytes.geturlN)r<r=r>r?rhr!r!r!r"rascCs8ttfttfttff}x|D]\}}||_||_qWdS)N)rrrrrrr:rA)Z _result_pairsZ_decodedZ_encodedr!r!r"_fix_result_transcodinggs  rjTc Csft||\}}}t|||}|\}}}}}|tkrHd|krHt|\}}nd}t||||||} || S)N;r)r8r uses_params _splitparamsr) rgschemeallow_fragments_coerce_resultZ splitresultrTqueryrfparamsresultr!r!r"rts cCsRd|kr,|jd|jd}|dkr6|dfSn |jd}|d|||ddfS)N/rkrrr3)findrfind)rgir!r!r"rms   rmcCsLt|}x*dD]"}|j||}|dkrt||}qW|||||dfS)Nz/?#r)lenrumin)rgstartdelimcZwdelimr!r!r" _splitnetlocs   r}cCs| stdd|D rdSddl}|jdd}|jdd}|jdd}|jdd}|jd |}||krndSx(d D] }||krttd |d d qtWdS)Ncss|]}t|dkVqdS)N)ord)r-r|r!r!r"r/sz_checknetloc..rrRrrSre?NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)any unicodedatareplace normalizerN)rTrnZnetloc2r|r!r!r" _checknetlocs       rcCsxtD]}|j|d}qW|S)Nr)_UNSAFE_URL_BYTES_TO_REMOVEr)rgbr!r!r"_remove_unsafe_bytes_from_urls rc Cst||\}}}t|}t|}|jt}|jt}t|}|||t|t|f}tj|d}|rj||St tt kr|t d}}}|j d} | dkr|d| dkr~|d| j }|| dd}|dddkrt|d\}}d|kod |ksd |krd|krtd |r.)r8rlstrip_WHATWG_C0_CONTROL_OR_SPACEstripbooltypergetrxMAX_CACHE_SIZEr#rurJr}rNsplitrr scheme_charsr) rgrnrorpkeycachedrTrqrfrwvr|restr!r!r"rsd          cCs<t|\}}}}}}}|r&d||f}|t|||||fS)Nz%s;%s)r8r) componentsrnrTrgrrrqrfrpr!r!r"rs cCst|\}}}}}}|s4|r`|tkr`|dddkr`|rP|dddkrPd|}d|pXd|}|rp|d|}|r|d|}|r|d|}||S) Nrz//r3rtrrSrre)r8 uses_netloc)rrnrTrgrqrfrpr!r!r"rs    c Cs|s|S|s|St||\}}}t|d|\}}}}}} t|||\} } } } }}| |ks`| tkrh||S| tkr| r|t| | | | ||fS|} | r| r|} |} |s|}|t| | | | ||fS|jd}|ddkr|d=| dddkr| jd}n(|| jd}td|dd|dd <g}xX|D]P}|dkrdy |jWntk r`YnXn|dkrtq0n |j |q0W|d d kr|j d|t| | dj |pd| ||fS) Nrrtr3...rrrr)rr) r8r uses_relativerrrfilterpop IndexErrorappendjoin)basergrorpZbschemeZbnetlocZbpathZbparamsZbqueryZ bfragmentrnrTpathrrrqrfZ base_partsZsegmentsZ resolved_pathZsegr!r!r"r sT            c CsTt|\}}d|kr>t|\}}}}}}t|||||df}nd}|}|t||S)Nrer)r8rrr) rgrpsrpaqZfragZdefragr!r!r"rOs Z0123456789ABCDEFabcdefc Cs|s|jdSt|tr"|jd}|jd}t|dkr<|S|dg}|j}tdkrbddtDaxb|ddD]R}y(|t|dd||ddWqptk r|d||YqpXqpWdj |S) Nzutf-8rGr3rcSs4i|],}tD]"}tt||dg||jq qS))_hexdigbytesrMr()r-rrr!r!r" usz$unquote_to_bytes..r) rr4r5r(rxr _hextobyterKeyErrorr)stringbitsresritemr!r!r"rbs*     z([-]+)utf-8rcCsd|kr|j|S|dkrd}|dkr*d}tj|}|dg}|j}x@tdt|dD],}|t||j|||||dqVWdj|S)NrFzutf-8rrr3rr)r_asciirerrangerxrr,r)rr)r*rrrrwr!r!r"rs   Fc CsPi}t||||||d}x2|D]*\}} ||kr>||j| q| g||<qW|S)N)r)r*max_num_fields)r r) qskeep_blank_valuesstrict_parsingr)r*rZ parsed_resultpairsnamevaluer!r!r"r scCst|\}}|dk rszparse_qsl..=rzbad query field: %rrr+ )r)r*)r8countrNrrxrrr)rrrr)r*rrp num_fieldsrrZ name_valueZnvrrr!r!r"r s4      cCs|jdd}t|||S)Nrr)rr)rr)r*r!r!r"rs sAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-c@s$eZdZddZddZddZdS)QuotercCstj||_dS)N) _ALWAYS_SAFEunionsafe)r;rr!r!r"__init__szQuoter.__init__cCsd|jjt|fS)Nz<%s %r>) __class__r<dict)r;r!r!r"__repr__szQuoter.__repr__cCs(||jkrt|ndj|}|||<|S)Nz%{:02X})rchrformat)r;rrr!r!r" __missing__szQuoter.__missing__N)r<r=r>rrrr!r!r!r"rsrrtcCsbt|tr8|s|S|dkrd}|dkr*d}|j||}n |dk rHtd|dk rXtdt||S)Nzutf-8r%z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)r4r5r(r6r )rrr)r*r!r!r"r %s cCsdt|trd|ks$t|tr2d|kr2t||||St|trBd}nd}t|||||}|jddS)Nr r)r4r5rr r)rrr)r*Zspacer!r!r"r Qs c st|ttfstd|sdSt|tr6|jdd}ntdd|D}|jt|s^|jSy t |Wn&t k rt |j t |<YnXdj fdd|DS)Nz!quote_from_bytes() expected bytesrr$ignorecSsg|]}|dkr|qS)r!)r-r|r!r!r"rosz$quote_from_bytes..csg|] }|qSr!r!)r-char)quoterr!r"rvs)r4r bytearrayr6r5r(rstrip_ALWAYS_SAFE_BYTESr,r rr __getitem__r)Zbsrr!)rr"r bs  cCst|dr|j}nRy t|r2t|dt r2tWn0tk rdtj\}}}tdj|YnXg} |sxr|D]j\} } t| t r|| |} n|t | |||} t| t r|| |} n|t | |||} | j | d| qtWn,x(|D]\} } t| t r|| |} n|t | |||} t| t rL|| |} | j | d| qt| t rz|| |||} | j | d| qy t| } Wn:tk r|t | |||} | j | d| YqXxJ| D]B} t| t r|| |} n|t | |||} | j | d| qWqWdj | S)Nitemsrz1not a valid non-string sequence or mapping objectrr) hasattrrrxr4r0r6sysexc_infowith_tracebackrr5rr)rqZdoseqrr)r*Z quote_viaZtyZvatblkrr.Zeltr!r!r"rxsP                c CsJt|trFy|jdj}Wn(tk rDtdt|dYnX|S)NASCIIzURL z contains non-ASCII characters)r4r5r(r, UnicodeErrorrepr)rgr!r!r"to_bytess  rcCs`t|j}|dddkr<|dddkr<|ddj}|dddkr\|ddj}|S)Nr3<>zURL:rr)r5r)rgr!r!r"unwraps   rcCsDtdkrtjdtjatj|}|r<|j\}}|j|fSd|fS)Nz ([^/:]+):(.*)) _typeprogrecompileDOTALLmatchgroupsrJ)rgrrndatar!r!r" splittypes   rcCsXtdkrtjdtjatj|}|rP|j\}}|rH|ddkrHd|}||fSd|fS)Nz//([^/#?]*)(.*)rrt) _hostprogrrrrr)rgrZ host_portrr!r!r" splithosts  rcCs |jd\}}}|r|nd|fS)NrR)rU)hostuserr{r!r!r" splitusersrcCs |jd\}}}||r|ndfS)NrS)rI)rr{Zpasswdr!r!r" splitpasswdsrcCsDtdkrtjdtjatj|}|r<|j\}}|r<||fS|dfS)Nz(.*):([0-9]*)$) _portprogrrrrr)rrrOr!r!r" splitports  rr3c CsT|jd\}}}|s|}n2|rLy t|}Wntk rBd}YnX||fS||fS)NrS)rUrMrN)rZdefportr{rOZnportr!r!r" splitnports  rcCs$|jd\}}}|r||fS|dfS)Nr)rU)rgrr{rqr!r!r" splitquery"srcCs$|jd\}}}|r||fS|dfS)Nre)rU)rgrr{tagr!r!r"splittag)srcCs|jd}|d|ddfS)Nrkrr3)r)rgZwordsr!r!r" splitattr0s rcCs |jd\}}}||r|ndfS)Nr)rI)attrr{rr!r!r" splitvalue6sr)rT)r)rT)T)rr)FFrrN)FFrrN)rr)rtNN)rNN)rtr)r)]rr collections__all__rrrlZnon_hierarchicalZ uses_queryZ uses_fragmentrrrrrr#Z_implicit_encodingZ_implicit_errorsr'r+r2r8objectr9r@rBrQr_rdZ_DefragResultBaseZ_SplitResultBaseZ_ParseResultBase__doc__rgrfrnrTrrqrrZ ResultBaserrrrrrrjrrmr}rrrrrrrrrrrrrr r r frozensetrrrr defaultdictrr r r rrrrrrrrrrrrrrrrr!r!r!r""s                 !           @  E   & ;  ,   O