ó "9QRc@sydZddddddddgZd d d d d ddddddddddddgZd d d d dd dddddddddddddddddgZd d d!d"ddd dd#d$g Zd d dd d ddddd#d$dddgZd dd dddd ddd#d$dg Zd d d d d"d dddddddg Zd%Zd&Z iZ d'„Z d(e fd)„ƒYZ d*d+lmZd,ed,d-ƒe fd.„ƒYZd/ed/d0ƒe fd1„ƒYZded2„Zd3„Zd4d5„Zded6„Zd7„Zd8„Zed9„Zd:„Zd;Zed<„eDƒƒZd=„Zd4d4d>„Zd4d4d?„Z d@S(AscParse (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. turlparset urlunparseturljoint urldefragturlsplitt urlunsplittparse_qst parse_qsltftpthttptgophertnntptimaptwaistfilethttpstshttptmmstprosperotrtsptrtsputtsftptsvnssvn+sshttelnettsnewstrsynctnfstgitsgit+sshthdltmailtotnewstsiptsipssAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.icCstjƒdS(sClear the parse cache.N(t _parse_cachetclear(((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyt clear_cache?st 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((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pytusernameGs   cCsR|j}d|krN|jddƒd}d|krN|jddƒdSndS(NR&iiR'(R(R)R*R+(R,R(R-((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pytpasswordQs    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(((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pythostnameZs  cCsW|jjdƒdjdƒd}d|krO|jdƒd}t|dƒSdSdS(NR&iÿÿÿÿR1R'ii (R(R*tintR+(R,R(tport((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyR5fs #  (t__name__t __module__t__doc__tpropertyR.R/R3R5(((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyR%Ds    iÿÿÿÿ(t namedtuplet SplitResults!scheme netloc path query fragmentcBseZdZd„ZRS(cCs t|ƒS(N(R(R,((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pytgeturlus((R6R7t __slots__R<(((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyR;qst ParseResults(scheme netloc path params query fragmentcBseZdZd„ZRS(cCs t|ƒS(N(R(R,((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyR<}s((R6R7R=R<(((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyR>yscCsst|||ƒ}|\}}}}}|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((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyRs cCsed|kr@|jd|jdƒƒ}|dkrO|dfSn|jdƒ}|| ||dfS(Nt/R?iRi(tfindtrfind(RBti((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyRAs    icCsbt|ƒ}x>dD]6}|j||ƒ}|dkrt||ƒ}qqW|||!||fS(Ns/?#i(tlenRJtmin(RBtstarttdelimtctwdelim((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/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|<| Sxp|| D]} | tkr¨Pq¨q¨Wyt||dƒ} Wqt k r || j ƒ||d}}qXn|d dkrwt |dƒ\}}d|krMd |ksed |krwd|krwt d ƒ‚qwn|r°|tkr°d |kr°|j d dƒ\}}n|tkrãd |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//R0R1sInvalid IPv6 URLt#t?N(tboolttypeR"tgetR+RMtMAX_CACHE_SIZER$RJR2RSt ValueErrorR*R;t scheme_charsR4t uses_fragmentt uses_query( RBRCRDtkeytcachedR(RFRGRLtvRQt _testportnum((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pyR sX !      & 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(tdataRCR(RBRHRFRG((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/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//iRIRR'RURT(t uses_netloc(RbRCR(RBRFRG((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/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|d;scCs½|jdƒ}t|ƒdkr%|S|d}x‡|dD]{}y|t|d |d7}Wq:tk r|d|7}q:tk r´|tt|d dƒƒ|d7}q:Xq:W|S(s"unquote('abc%20def') -> 'abc def'.t%iiii(R*RMt _hextochrtKeyErrortUnicodeDecodeErrortunichrR4(Rrtrestitem((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pytunquote>s   -cCsZi}xMt|||ƒD]9\}}||krE||j|ƒq|g||tTrueRRARSRRRRRRyR‰R~R„RR(((sI/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/urlparse.pytsT    +"" 7  4