³ò £l‡Jc@s dZddddddgZddd d d d d ddddddddgZddd d dd d d ddddddddddddgZd ddddd d dddg Zddddd dddddddddgZdd d dddd dddddg Zdddd dd d dddd ddg Zd Zd!Z ha d"„Z d#e fd$„ƒYZ d%e fd&„ƒYZd'e fd(„ƒYZded)„Zd*„Zd+d,„Zded-„Zd.„Zd/„Zed0„Zd1„Zd2Zd3„Zed4jo eƒnd5S(6sParse (absolute and relative) URLs. See RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. turlparset urlunparseturljoint urldefragturlsplitt urlunsplittftpthttptgophertnntptimaptwaistfilethttpstshttptmmstprosperotrtsptrtsputtsftpttelnettsnewstrsynctsvnssvn+sshthdltmailtotnewstsiptsipssAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.icCs hadS(sClear the parse cache.N(t _parse_cache(((s/sys/lib/python/urlparse.pyt clear_cache&st BaseResultcBs›eZdZd Zed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ RS( sBase class for the parsed result objects. This provides the attributes shared by the two derived result objects as read-only properties. The derived classes are responsible for checking the right number of arguments were supplied to the constructor. cCs|dS(Ni((tself((s/sys/lib/python/urlparse.pytscheme:scCs|dS(Ni((R!((s/sys/lib/python/urlparse.pytnetloc>scCs|dS(Ni((R!((s/sys/lib/python/urlparse.pytpathBscCs|dS(Niþÿÿÿ((R!((s/sys/lib/python/urlparse.pytqueryFscCs|dS(Niÿÿÿÿ((R!((s/sys/lib/python/urlparse.pytfragmentJscCs_|i}d|joE|iddƒd}d|jo|iddƒd}n|SndS(Nt@iit:(R#tsplittNone(R!R#tuserinfo((s/sys/lib/python/urlparse.pytusernameQs   cCsY|i}d|jo?|iddƒd}d|jo|iddƒdSqUndS(NR'iiR((R#R)R*(R!R#R+((s/sys/lib/python/urlparse.pytpassword[s    cCsh|i}d|jo|iddƒd}nd|jo|iddƒd}n|iƒpdS(NR'iR(i(R#R)tlowerR*(R!R#((s/sys/lib/python/urlparse.pythostnameds    cCsh|i}d|jo|iddƒd}nd|jo'|iddƒd}t|dƒSndS(NR'iR(i (R#R)tintR*(R!R#tport((s/sys/lib/python/urlparse.pyR1ms   ((t__name__t __module__t__doc__t __slots__tpropertyR"R#R$R%R&R,R-R/R1(((s/sys/lib/python/urlparse.pyR ,s   t SplitResultcBs eZdZd„Zd„ZRS(cCsti||||||fƒS(N(R t__new__(tclsR"R#R$R%R&((s/sys/lib/python/urlparse.pyR8|scCs t|ƒS(N(R(R!((s/sys/lib/python/urlparse.pytgeturl€s((R2R3R5R8R:(((s/sys/lib/python/urlparse.pyR7xs t ParseResultcBs/eZdZd„Zed„ƒZd„ZRS(cCs"ti|||||||fƒS(N(R R8(R9R"R#R$tparamsR%R&((s/sys/lib/python/urlparse.pyR8ˆscCs|dS(Ni((R!((s/sys/lib/python/urlparse.pyR<ŒscCs t|ƒS(N(R(R!((s/sys/lib/python/urlparse.pyR:s((R2R3R5R8R6R<R:(((s/sys/lib/python/urlparse.pyR;„s cCsvt|||ƒ}|\}}}}}|tjo#d|jot|ƒ\}}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;(turlR"tallow_fragmentsttupleR#R%R&R<((s/sys/lib/python/urlparse.pyR”s cCsld|jo:|id|idƒƒ}|djo|dfSqVn|idƒ}|| ||dfS(Nt/R=iRi(tfindtrfind(R@ti((s/sys/lib/python/urlparse.pyR?¢s   icCsVx>dD]*}|i||ƒ}|djoPqqWt|ƒ}|||!||fS(Ns/?#i(RDtlen(R@tstarttctdelim((s/sys/lib/python/urlparse.pyt _splitnetloc«s   c Cszt|ƒ}|||f}ti|d ƒ}|o|Snttƒtjo tƒnd}}}|idƒ}|djo&|| djoË|| iƒ}||d}|d djot |dƒ\}}n|o)d|jo|i ddƒ\}}nd |jo|i d dƒ\}}nt |||||ƒ} | t|<| SnxG|| D]} | t joPqkqkW|| iƒ||d}}n|t jo*|d djot |dƒ\}}n|o6|tjo)d|jo|i ddƒ\}}n|tjo)d |jo|i 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(iRiis//t#t?N(tboolRtgetR*RGtMAX_CACHE_SIZERRDR.RKR)R7t scheme_charst uses_netloct uses_fragmentt uses_query( R@R"RAtkeytcachedR#R%R&RFtvRI((s/sys/lib/python/urlparse.pyR´sH        #! cCsL|\}}}}}}|od||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(t.0R"R#R@R<R%R&((s/sys/lib/python/urlparse.pyRßscCsÏ|\}}}}}|p%|o]|tjoP|d djo?|o|d djod|}nd|pd|}n|o|d|}n|o|d|}n|o|d|}n|S( Nis//iRCRR(RMRL(RR(RXR"R#R@R%R&((s/sys/lib/python/urlparse.pyRès,&c Cs|p|Sn|p|Snt|d|ƒ\}}}}}}t|||ƒ\} } } } } }| |jp | tjo|Sn| tjo1| o t| | | | | |fƒSn|} n| d djo t| | | | | |fƒSn| p | p| p t| | ||||fƒSn|idƒd | idƒ}|ddjod|d http:g = http: = g = ./g = g/ = /g = //g = ?y = g?y = g?y/./x = . = ./ = .. = ../ = ../g = ../.. = ../../g = ../../../g = ./../g = ./g/. = /./g = g/./h = g/../h = http:g = http: = http:?y = http:g?y = http:g?y/./x = c Cs…ddk}d}|ido7|id}|djo |i}qt|ƒ}nGyddkl}Wn#tj oddkl}nX|tƒ}xá|iƒ}|pPn|i ƒ}|pq n|d}t |ƒ}d||fGHt ||ƒ} |p | }nd| } d || fGHt |ƒd jo;|dd jo*| |d jod G|d GdGHq~q q dS(NiÿÿÿÿRit-(tStringIOis %-10s : %sss %-10s = %sit=itEXPECTEDs !!!!!!!!!!( tsystargvtstdintopent cStringIORmt ImportErrort test_inputtreadlineR)RRRG( RpR]tfntfpRmtlinetwordsR@tpartstabstwrapped((s/sys/lib/python/urlparse.pyttestUs:            $t__main__N(R4t__all__RZRRtnon_hierarchicalR>RTRSRQRPRRRBR R7R;tTrueRR?RKRRRRRRvRR2(((s/sys/lib/python/urlparse.pyssL    L  + 0 / !