ó õ^‚Rc@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 iZ d*„Z d+e fd,„ƒYZdd-lmZd.ed.d/ƒefd0„ƒYZd1ed1d2ƒefd3„ƒYZded4„Zd5„Zd6d7„Zded8„Zd9„Zd:„Zed;„Zd<„ZyeWnek red=„Zn Xd>„Zd?Ze d@„eDƒƒZ!ej"dAƒZ#dB„Z$d6d6dC„Z%d6d6dD„Z&dS(EscParse (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. iÿÿÿÿNturlparset urlunparseturljoint urldefragturlsplitt urlunsplittparse_qst parse_qsltftpthttptgophertnntptimaptwaistfilethttpstshttptmmstprosperotrtsptrtsputtsftptsvnssvn+sshttelnettsnewstrsynctnfstgitsgit+sshthdltsiptsipstteltmailtotnewssAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.icCstjƒdS(sClear the parse cache.N(t _parse_cachetclear(((s/usr/lib/python2.7/urlparse.pyt clear_cacheDst 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/lib/python2.7/urlparse.pytusernameLs   cCsR|j}d|krN|jddƒd}d|krN|jddƒdSndS(NR'iiR((R)R*R+R,(R-R)R.((s/usr/lib/python2.7/urlparse.pytpasswordVs    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/lib/python2.7/urlparse.pythostname_s  cCsx|jjdƒdjdƒd}d|krt|jdƒd}t|dƒ}d|kohdknrt|SndS( NR'iÿÿÿÿR2R(ii iiÿÿ(R)R+tintR,(R-R)tport((s/usr/lib/python2.7/urlparse.pyR6ks# (t__name__t __module__t__doc__tpropertyR/R0R4R6(((s/usr/lib/python2.7/urlparse.pyR&Is    (t namedtuplet SplitResults!scheme netloc path query fragmentcBseZdZd„ZRS(cCs t|ƒS(N(R(R-((s/usr/lib/python2.7/urlparse.pytgeturl|s((R7R8t __slots__R=(((s/usr/lib/python2.7/urlparse.pyR<xst ParseResults(scheme netloc path params query fragmentcBseZdZd„ZRS(cCs t|ƒS(N(R(R-((s/usr/lib/python2.7/urlparse.pyR=„s((R7R8R>R=(((s/usr/lib/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/lib/python2.7/urlparse.pyRˆs cCsed|kr@|jd|jdƒƒ}|dkrO|dfSn|jdƒ}|| ||dfS(Nt/R@iRi(tfindtrfind(RCti((s/usr/lib/python2.7/urlparse.pyRB–s    icCsbt|ƒ}x>dD]6}|j||ƒ}|dkrt||ƒ}qqW|||!||fS(Ns/?#i(tlenRKtmin(RCtstarttdelimtctwdelim((s/usr/lib/python2.7/urlparse.pyt _splitnetlocŸs    c Csët|ƒ}|||t|ƒt|ƒf}tj|dƒ}|rI|Sttƒtkretƒnd}}}|jdƒ}|dkr || dkr|| j ƒ}||d}|d dkr#t |dƒ\}}d|krùd |ksd |kr#d|kr#t d ƒ‚q#n|rPd |krP|j d dƒ\}}nd |krw|j d dƒ\}}nt |||||ƒ} | t|<| Sxj|| D]} | tkr¨Pq¨q¨W||d} | sítd „| Dƒƒr || j ƒ| }}q n|d dkrqt |dƒ\}}d|krGd |ks_d |krqd|krqt d ƒ‚qqn|ržd |krž|j d dƒ\}}nd |krÅ|j d dƒ\}}nt |||||ƒ} | 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//R1R2sInvalid IPv6 URLt#t?css|]}|dkVqdS(t 0123456789N((t.0RR((s/usr/lib/python2.7/urlparse.pys ÍsN(tboolttypeR#tgetR,RNtMAX_CACHE_SIZER%RKR3RTt ValueErrorR+R<t scheme_charstany( RCRDREtkeytcachedR)RGRHRMtvRRtrest((s/usr/lib/python2.7/urlparse.pyR§sV !       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(tdataRDR)RCRIRGRH((s/usr/lib/python2.7/urlparse.pyRÞscCsÀ|\}}}}}|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//iRJRR(RVRU(t uses_netloc(RdRDR)RCRGRH((s/usr/lib/python2.7/urlparse.pyRès( 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|dKss([-]+)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+tappendtrangeRNtunquotetstrtdecodeRit _hextochrtKeyError(RttbitstresR…RMtitem((s/usr/lib/python2.7/urlparse.pyR‡Os.    #     cCsZi}xMt|||ƒD]9\}}||krE||j|ƒq|g||sb     -"" 7  4