Files
PowerToys/PythonHome/Lib/urlparse.pyc

136 lines
15 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@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*<00>Z d+e fd,<00><00>YZdd-lmZd.ed.d/<00>efd0<00><00>YZd1ed1d2<00>efd3<00><00>YZded4<00>Zd5<00>Zd6d7<00>Zded8<00>Zd9<00>Zd:<00>Zed;<00>Zd<<00>ZyeWnek
red=<00>Zn
Xd><00>Zd?Ze d@<00>eD<><00>Z!ej"dA<00>Z#dB<00>Z$d6d6dC<00>Z%d6d6dD<00>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<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Nturlparset
urlunparseturljoint urldefragturlsplitt
2014-07-10 23:57:08 +08:00
urlunsplittparse_qst parse_qsltftpthttptgophertnntptimaptwaistfilethttpstshttptmmstprosperotrtsptrtsputtsftptsvnssvn+sshttelnettsnewstrsynctnfstgitsgit+sshthdltsiptsipstteltmailtotnewssAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.icCstj<00>dS(sClear the parse cache.N(t _parse_cachetclear(((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyt clear_cacheDst ResultMixincBsJeZdZed<00><00>Zed<00><00>Zed<00><00>Zed<00><00>ZRS(s-Shared methods for the parsed result objects.cCsX|j}d|krT|jdd<00>d}d|krP|jdd<00>d}n|SdS(Nt@iit:(tnetloctrsplittsplittNone(tselfR)tuserinfo((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pytusernameLs   cCsR|j}d|krN|jdd<00>d}d|krN|jdd<00>dSndS(NR'iiR((R)R*R+R,(R-R)R.((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pytpasswordVs    cCs<>|jjd<00>d}d|krId|krI|jd<00>ddj<00>Sd|krl|jd<00>dj<00>S|dkr|dS|j<00>SdS( NR'i<><69><EFBFBD><EFBFBD>t[t]iiR(R(R)R+tlowerR,(R-R)((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pythostname_s  cCs<>|jjd<00>djd<00>d}d|kr}|jd<00>d}|r}t|d<00>}d|kondknrz|Sq}ndS( NR'i<><69><EFBFBD><EFBFBD>R2R(ii
ii<><69>(R)R+tintR,(R-R)tport((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR6ks# 
2014-07-09 18:15:23 +08:00
(t__name__t
2014-07-10 23:57:08 +08:00
__module__t__doc__tpropertyR/R0R4R6(((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR&Is
2014-07-09 18:15:23 +08:00

  (t
namedtuplet SplitResults!scheme netloc path query fragmentcBseZdZd<00>ZRS(cCs
2014-07-10 23:57:08 +08:00
t|<00>S(N(R(R-((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pytgeturl}s((R7R8t __slots__R=(((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<yst ParseResults(scheme netloc path params query fragmentcBseZdZd<00>ZRS(cCs
t|<00>S(N(R(R-((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR=<00>s((R7R8R>R=(((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR?<00>scCsst|||<00>}|\}}}}}|tkrTd|krTt|<00>\}}nd}t||||||<00>S(s#Parse a URL into 6 components:
2014-07-09 18:15:23 +08:00
<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
2014-07-10 23:57:08 +08:00
(e.g. netloc is a single string) and we don't expand % escapes.t;R(Rt uses_paramst _splitparamsR?(turltschemetallow_fragmentsttupleR)tquerytfragmenttparams((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<00>s cCsed|kr@|jd|jd<00><00>}|dkrO|dfSn|jd<00>}|| ||dfS(Nt/R@iRi(tfindtrfind(RCti((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyRB<00>s    icCsbt|<00>}x>dD]6}|j||<00>}|dkrt||<00>}qqW|||!||fS(Ns/?#i(tlenRKtmin(RCtstarttdelimtctwdelim((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyt _splitnetloc<6F>s    c Cs<>t|<00>}|||t|<00>t|<00>f}tj|d<00>}|rI|Stt<00>tkret<00>nd}}}|jd<00>}|dkr
2014-07-09 18:15:23 +08:00
|| dkr<>|| j <00>}||d}|d dkr#t
|d<00>\}}d|kr<>d |ksd |kr#d|kr#t d
<00><00>q#n|rPd |krP|j d d<00>\}}nd |krw|j d d<00>\}}nt |||||<00>} | t|<| Sxj|| D]}
|
tkr<>Pq<50>q<>W||d} | s<>td <00>| D<><00>r
|| j <00>| }}q
n|d dkrqt
|d<00>\}}d|krGd |ks_d |krqd|krqt d
<00><00>qqn|r<>d |kr<>|j d d<00>\}}nd |kr<>|j d d<00>\}}nt |||||<00>} | 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(iR iis//R1R2sInvalid IPv6 URLt#t?css|]}|dkVqdS(t
2014-07-10 23:57:08 +08:00
0123456789N((t.0RR((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pys <genexpr><3E>sN(tboolttypeR#tgetR,RNtMAX_CACHE_SIZER%RKR3RTt
ValueErrorR+R<t scheme_charstany( RCRDREtkeytcachedR)RGRHRMtvRRtrest((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<00>sV !
2014-07-09 18:15:23 +08:00
  
  
cCsJ|\}}}}}}|r1d||f}nt|||||f<00>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
2014-07-10 23:57:08 +08:00
(the draft states that these are equivalent).s%s;%s(R(tdataRDR)RCRIRGRH((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<00>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
2014-07-09 18:15:23 +08:00
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
2014-07-10 23:57:08 +08:00
empty query; the RFC states that these are equivalent).is//iRJRR(RVRU(t uses_netloc(RdRDR)RCRGRH((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<00>s( c
Csg|s
2014-07-09 18:15:23 +08:00
|S|s|St|d|<00>\}}}}}}t|||<00>\} }
} } } }| |kst| tkrx|S| tkr<>|
r<>t| |
| | | |f<00>S|}
n| d dkr<>t| |
| | | |f<00>S| r | r |} |} | s|} nt| |
| | | |f<00>S|jd<00>d | jd<00>}|ddkr]d|d<nxd|kr||jd<00>q`Wxqd}t|<00>d}xU||kr<>||dkr<>||dd kr<>||d|d5Pn|d}q<>WPq<50>|ddgkrd|d<n2t|<00>dkrB|ddkrBdg|d)nt| |
dj|<00>| | |f<00>S(
saJoin a base URL and a possibly relative URL to form an absolute
2014-07-10 23:57:08 +08:00
interpretation of the latter.RiRJi<><69><EFBFBD><EFBFBD>t.s..ii<><69><EFBFBD><EFBFBD>(Rs..(Rt uses_relativeReRR+tremoveRNtjoin(tbaseRCREtbschemetbnetloctbpathtbparamstbqueryt bfragmentRDR)tpathRIRGRHtsegmentsRMtn((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<00>sX$$         "cCs`d|krRt|<00>\}}}}}}t|||||df<00>}||fS|dfSdS(s<>Removes any existing fragment from URL.
2014-07-09 18:15:23 +08:00
Returns a tuple of the defragmented URL and the fragment. If
the URL contained no fragments, the second element is the
empty string.
2014-07-10 23:57:08 +08:00
RURN(RR(RCtsRstptatqtfragtdefrag((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR/s
2014-07-09 18:15:23 +08:00
 
2014-07-10 23:57:08 +08:00
cCsdS(Ni((tx((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyt _is_unicode@scCs t|t<00>S(N(t
isinstancetunicode(Rz((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR{Cst0123456789ABCDEFabcdefccs?|]5}tD](}||tt||d<00><00>fVq qdS(iN(t_hexdigtchrR5(RXRvtb((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pys <genexpr>Lss([-]+)cCsOt|<00>r<>d|kr|Stj|<00>}|dg}|j}xUtdt|<00>d<00>D];}|tt||<19><00>jd<00><00>|||d<19>qZWdj |<00>S|jd<00>}t|<00>dkr<>|S|dg}|j}x^|dD]R}y$|t
2014-07-09 18:15:23 +08:00
|d <19>||d<1F>Wq<57>t k
2014-07-10 23:57:08 +08:00
r=|d<00>||<00>q<>Xq<58>Wdj |<00>S(s"unquote('abc%20def') -> 'abc def'.t%iiitlatin1R( R{t_asciireR+tappendtrangeRNtunquotetstrtdecodeRit _hextochrtKeyError(RttbitstresR<73>RMtitem((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<79>Ps.    #    
2014-07-09 18:15:23 +08:00
cCsZi}xMt|||<00>D]9\}}||krE||j|<00>q|g||<qW|S(s<>Parse a query given as a string argument.
Arguments:
qs: percent-encoded query string to be parsed
keep_blank_values: flag indicating whether blank values in
percent-encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as
blank strings. The default false value indicates that
blank values are to be ignored and treated as if they were
not included.
strict_parsing: flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored.
If true, errors raise a ValueError exception.
2014-07-10 23:57:08 +08:00
(RR<>(tqstkeep_blank_valueststrict_parsingtdicttnametvalue((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyRls  c Cs$g|jd<00>D]"}|jd<00>D] }|^q#q}g}x<>|D]<5D>}| r_| r_qEn|jdd<00>}t|<00>dkr<>|r<>td|f<16>n|rE|jd<00>q<>qEnt|d<19>s<>|rEt|djd d
2014-07-09 18:15:23 +08:00
<00><00>} t|djd d
<00><00>}
|j| |
f<00>qEqEW|S( s<>Parse a query given as a string argument.
Arguments:
qs: percent-encoded query string to be parsed
keep_blank_values: flag indicating whether blank values in
percent-encoded queries should be treated as blank strings. A
true value indicates that blanks should be retained as blank
strings. The default false value indicates that blank values
are to be ignored and treated as if they were not included.
strict_parsing: flag indicating what to do with parsing errors. If
false (the default), errors are silently ignored. If true,
errors raise a ValueError exception.
Returns a list, as G-d intended.
t&R@t=iisbad query field: %rRit+t (R+RNR]R<>R<>treplace( R<>R<>R<>ts1ts2tpairstrt
2014-07-10 23:57:08 +08:00
name_valuetnvR<76>R<>((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyR<00>s"8 ('R9tret__all__RgReRAtnon_hierarchicalt
uses_queryt uses_fragmentR^R\R#R%tobjectR&t collectionsR;R<R?tTrueRRBRTRRRRRR}t NameErrorR{RR<>R<>tcompileR<65>R<>RR(((s=e:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\urlparse.pyt<module>sb     ."" 7
2014-07-09 18:15:23 +08:00
 4