ó n”ţfc@sědZddlZddddddd d gZd d d ddddddddddddddgZd d d ddddddddddddddddddd d!gZd d"dd dddddd#d$dddd%gZd d"d&d'ddddd#d$g Zd dddddd ddd#d$dg Zd d"d d d'ddddddddg Zd(Z d)Z d*d+d,gZ d-Z iZ d.„Zd/efd0„ƒYZdd1lmZd2ed2d3ƒefd4„ƒYZd5ed5d6ƒefd7„ƒYZded8„Zd9„Zd:d;„Zd<„Zd=„Zded>„Zd?„Zd@„ZedA„ZdB„Zye Wne!k rŒdC„Z"n XdD„Z"dEZ#e$dF„e#DƒƒZ%ej&dGƒZ'dH„Z(d:d:dI„Z)d:d:dJ„Z*dS(Ks3Parse (absolute and relative) URLs. urlparse module is based upon the following RFC specifications. RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding and L. Masinter, January 2005. RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter and L.Masinter, December 1999. RFC 2396: "Uniform Resource Identifiers (URI)": Generic Syntax by T. Berners-Lee, R. Fielding, and L. Masinter, August 1998. RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zwinski, July 1998. RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M. McCahill, December 1994 RFC 3986 is considered the current standard and any future changes to urlparse module should conform with it. The urlparse module is currently not entirely compliant with this RFC due to defacto scenarios for parsing, and for backward compatibility purposes, some parsing quirks from older RFCs are retained. The testcases in test_urlparse.py provides a good indicator of parsing behavior. The WHATWG URL Parser spec should also be considered. We are not compliant with it either due to existing user code API behavior expectations (Hyrum's Law). It serves as a useful guide when making changes. i˙˙˙˙Nturlparset urlunparseturljoint urldefragturlsplitt urlunsplittparse_qst parse_qsltftpthttptgophertnntptimaptwaistfilethttpstshttptmmstprosperotrtsptrtsputtsftptsvnssvn+sshttelnettsnewstrsynctnfstgitsgit+sshthdltsiptsipstteltmailtotnewssAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.t!  s s s icCstjƒdS(sClear the parse cache.N(t _parse_cachetclear(((s /usr/lib64/python2.7/urlparse.pyt clear_cacheOst ResultMixincBsJeZdZed„ƒZed„ƒZed„ƒZed„ƒZRS(s-Shared methods for the parsed result objects.cCsX|j}d|krT|jddƒd}d|krP|jddƒd}n|SdS(Nt@iit:(tnetloctrsplittsplittNone(tselfR*tuserinfo((s /usr/lib64/python2.7/urlparse.pytusernameWs   cCsR|j}d|krN|jddƒd}d|krN|jddƒdSndS(NR(iiR)(R*R+R,R-(R.R*R/((s /usr/lib64/python2.7/urlparse.pytpasswordas    cCsŠ|jjdƒd}d|krId|krI|jdƒddjƒSd|krl|jdƒdjƒS|dkr|dS|jƒSdS( NR(i˙˙˙˙t[t]iiR)R(R*R,tlowerR-(R.R*((s /usr/lib64/python2.7/urlparse.pythostnamejs  cCsx|jjdƒdjdƒd}d|krt|jdƒd}t|dƒ}d|kohdknrt|SndS( NR(i˙˙˙˙R3R)ii ii˙˙(R*R,tintR-(R.R*tport((s /usr/lib64/python2.7/urlparse.pyR7vs# (t__name__t __module__t__doc__tpropertyR0R1R5R7(((s /usr/lib64/python2.7/urlparse.pyR'Ts    (t namedtuplet SplitResults!scheme netloc path query fragmentcBseZdZd„ZRS(cCs t|ƒS(N(R(R.((s /usr/lib64/python2.7/urlparse.pytgeturl‡s((R8R9t __slots__R>(((s /usr/lib64/python2.7/urlparse.pyR=ƒst ParseResults(scheme netloc path params query fragmentcBseZdZd„ZRS(cCs t|ƒS(N(R(R.((s /usr/lib64/python2.7/urlparse.pyR>s((R8R9R?R>(((s /usr/lib64/python2.7/urlparse.pyR@‹scCsst|||ƒ}|\}}}}}|tkrTd|krTt|ƒ\}}nd}t||||||ƒS(s#Parse a URL into 6 components: :///;?# Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.t;R(Rt uses_paramst _splitparamsR@(turltschemetallow_fragmentsttupleR*tquerytfragmenttparams((s /usr/lib64/python2.7/urlparse.pyR“s cCsed|kr@|jd|jdƒƒ}|dkrO|dfSn|jdƒ}|| ||dfS(Nt/RAiRi(tfindtrfind(RDti((s /usr/lib64/python2.7/urlparse.pyRCĄs    icCsbt|ƒ}x>dD]6}|j||ƒ}|dkrt||ƒ}qqW|||!||fS(Ns/?#i(tlenRLtmin(RDtstarttdelimtctwdelim((s /usr/lib64/python2.7/urlparse.pyt _splitnetlocŞs    cCsĹ| st|tƒ rdSddl}|jddƒ}|jddƒ}|jddƒ}|jddƒ}|jd|ƒ}||kr‘dSx-dD]%}||kr˜td |ƒ‚q˜q˜WdS( Ni˙˙˙˙u@uu:u#u?tNFKCs/?#@:s>netloc %r contains invalid characters under NFKC normalization(t isinstancetunicodet unicodedatatreplacet normalizet ValueError(R*RYtntnetloc2RS((s /usr/lib64/python2.7/urlparse.pyt _checknetloc˛s    cCs'x tD]}|j|dƒ}qW|S(NR(t_UNSAFE_URL_BYTES_TO_REMOVERZ(RDtb((s /usr/lib64/python2.7/urlparse.pyt_remove_unsafe_bytes_from_urlĹs c Cs5t|ƒ}t|ƒ}|jtƒ}|jtƒ}t|ƒ}|||t|ƒt|ƒf}tj|dƒ}|r|St tƒt kr›t ƒnd}}}|j dƒ}|dkrJ|| dkrÝ|| j ƒ}||d}|d dkrYt|dƒ\}}d|kr/d |ksGd |krYd|krYtd ƒ‚qYn|r†d |kr†|jd dƒ\}}nd |kr­|jd dƒ\}}nt|ƒt|||||ƒ} | t|<| Sxj|| D]} | tkrčPqčqčW||d} | s-td „| DƒƒrJ|| j ƒ| }}qJn|d dkrąt|dƒ\}}d|kr‡d |ksŸd |krąd|krątd ƒ‚qąn|rŢd |krŢ|jd dƒ\}}nd |kr|jd dƒ\}}nt|ƒt|||||ƒ} | t|<| S(sParse a URL into 5 components: :///?# Return a 5-tuple: (scheme, netloc, path, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.RR)iR iis//R2R3sInvalid IPv6 URLt#t?css|]}|dkVqdS(t 0123456789N((t.0RS((s /usr/lib64/python2.7/urlparse.pys ősN(Rbtlstript_WHATWG_C0_CONTROL_OR_SPACEtstriptboolttypeR$tgetR-ROtMAX_CACHE_SIZER&RLR4RUR\R,R_R=t scheme_charstany( RDRERFtkeytcachedR*RHRIRNtvRStrest((s /usr/lib64/python2.7/urlparse.pyRĘsb   !         cCsJ|\}}}}}}|r1d||f}nt|||||fƒS(súPut a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).s%s;%s(R(tdataRER*RDRJRHRI((s /usr/lib64/python2.7/urlparse.pyRscCsŔ|\}}}}}|s=|rw|tkrw|d dkrw|r`|d dkr`d|}nd|pld|}n|rŽ|d|}n|rĽ|d|}n|rź|d|}n|S( skCombine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The data argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent).is//iRKRR)RdRc(t uses_netloc(RtRER*RDRHRI((s /usr/lib64/python2.7/urlparse.pyRs( c Csg|s |S|s|St|d|ƒ\}}}}}}t|||ƒ\} } } } } }| |kst| tkrx|S| tkrŻ| rŚt| | | | | |fƒS|} n| d dkrŰt| | | | | |fƒS| r | r |} |} | s|} nt| | | | | |fƒS|jdƒd | jdƒ}|ddkr]d|dtss([-]+)cCsOt|ƒrŚd|kr|Stj|ƒ}|dg}|j}xUtdt|ƒdƒD];}|tt||ƒƒjdƒƒ|||dƒqZWdj |ƒS|jdƒ}t|ƒdkrË|S|dg}|j}x^|dD]R}y$|t |d ƒ||dƒWqět k r=|dƒ||ƒqěXqěWdj |ƒS(s"unquote('abc%20def') -> 'abc def'.t%iiitlatin1R( RŠt_asciireR,tappendtrangeROtunquotetstrtdecodeRyt _hextochrtKeyError(RƒtbitstresR‘RNtitem((s /usr/lib64/python2.7/urlparse.pyR“xs.    #     cCsZi}xMt|||ƒD]9\}}||krE||j|ƒq|g||!sj     -""   =  4