�
��c@s dZddddddgZddd d
ddd
ddddddddgZddd d
dddd
ddddddddddddgZd dddddddddg
ZddddddddddddddgZddddddd dddddgZdddd dd
ddddd
ddg
Zd Zd!Z ha
d"�Zd#efd$��YZ
d%e
fd&��YZd'e
fd(��YZded)�Zd*�Zd+d,�Zded-�Zd.�Zd/�Zed0�Zd1�Zd2Zd3�Zed4joe�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.pytclear_cache&st
BaseResultcBs�eZdZd
Zed��Zed��Zed��Zed��Zed��Z ed��Z
ed��Zed��Zed ��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
tSplitResultcBs 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 tParseResultcBs/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:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
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(Rtuses_paramst_splitparamsR;(turlR"tallow_fragmentsttupleR#R%R&R<((s/sys/lib/python/urlparse.pyR�scCsld|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
cCszt|�}|||f}ti|d
�}|o|Sntt�tjot�nd}}}|id�}|djo&|| djo�|| i�}||d}|d djot |d�\}}n|o)d|jo|i
dd�\}}nd |jo|i
d d�\}}nt|||||�} | t|<| SnxG|| D]}
|
tjoPqkqkW|| 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:
<scheme>://<netloc>/<path>?<query>#<fragment>
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)R7tscheme_charstuses_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<nxd|jo|id�qnWxvd}t|�d}xZ||joK||djo,||dd jo||d|d5Pn|d}q�WPq�|ddgjod|d<n6t|�djo"|ddjodg|d)nt| |
di|�||
|f�S(
saJoin a base URL and a possibly relative URL to form an absolute
interpretation of the latter.RiRCi�t.s..ii�(Rs..(Rt
uses_relativeRRRR)tremoveRGtjoin(tbaseR@RAtbschemetbnetloctbpathtbparamstbqueryt bfragmentR"R#R$R<R%R&tsegmentsRFtn((s/sys/lib/python/urlparse.pyR�sP$$
$cCsed|joJt|�\}}}}}}t|||||df�}||fSn|dfSdS(s�Removes any existing fragment from URL.
Returns a tuple of the defragmented URL and the fragment. If
the URL contained no fragments, the second element is the
empty string.
RLRN(RR(R@tsRetptatqtfragtdefrag((s/sys/lib/python/urlparse.pyR$s
s�
http://a/b/c/d
g:h = <URL:g:h>
http:g = <URL:http://a/b/c/g>
http: = <URL:http://a/b/c/d>
g = <URL:http://a/b/c/g>
./g = <URL:http://a/b/c/g>
g/ = <URL:http://a/b/c/g/>
/g = <URL:http://a/g>
//g = <URL:http://g>
?y = <URL:http://a/b/c/d?y>
g?y = <URL:http://a/b/c/g?y>
g?y/./x = <URL:http://a/b/c/g?y/./x>
. = <URL:http://a/b/c/>
./ = <URL:http://a/b/c/>
.. = <URL:http://a/b/>
../ = <URL:http://a/b/>
../g = <URL:http://a/b/g>
../.. = <URL:http://a/>
../../g = <URL:http://a/g>
../../../g = <URL:http://a/../g>
./../g = <URL:http://a/b/g>
./g/. = <URL:http://a/b/c/g/>
/./g = <URL:http://a/./g>
g/./h = <URL:http://a/b/c/g/h>
g/../h = <URL:http://a/b/c/h>
http:g = <URL:http://a/b/c/g>
http: = <URL:http://a/b/c/d>
http:?y = <URL:http://a/b/c/d?y>
http:g?y = <URL:http://a/b/c/g?y>
http:g?y/./x = <URL:http://a/b/c/g?y/./x>
c Cs�ddk}d}|ido7|id}|djo
|i}q�t|�}nGyddkl}Wn#tj
oddkl}nX|t�}x�i�}|pPn|i �}|pq�n|d}t
|�}d||fGHt||�} |p
| }nd| }
d ||
fGHt|�d
jo;|ddjo*|
|djod
G|dGdGHq~q�q�dS(Ni�Rit-(tStringIOis
%-10s : %ss<URL:%s>s
%-10s = %sit=itEXPECTEDs
!!!!!!!!!!(
tsystargvtstdintopent cStringIORmtImportErrort
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.pys<module>sL L + 0 / !
|