lJc#@svdZddkZddkZddkZddkZddkZddklZdddddd d d d d ddddddddddddddddddd gZ d!Z d"Z ei d#jodd$k lZlZngei d%jodd$klZlZn=ei d&jodd$klZlZnd'Zd(Zeaeed)Zeeed*Zd+Zd,efd-YZhZdfd.YZdefd/YZead0Zead1Zea d2Z!ea"d3Z#d4fd5YZ$d6fd7YZ%d8e%fd9YZ&d:e%fd;YZ'd<e%fd=YZ(ye)Wne*j od>Z+n Xd?Z+d@Z,dAZ-ea.dBZ/ea0dCZ1ea2dDZ3ea4dEZ5ea6dFZ7ea8ddGZ9ea:dHZ;ea<dIZ=dJZ>ea?dKZ@dLZAeBdMeCdNDZDeDiEdOeCdNDdPZFdQZGdRZHhZIdSdTZJdUdVZKdWdXZLdYZMeiNdZjod[ZOd\ZPd]ZQn?ei d%jod^ZRd_ZQd`ZPneMZQdaZPdbZSdcZTgddZUdeZVeWdfjo eVndS(gsOpen an arbitrary URL. See the following document for more info on URLs: "Names and Addresses, URIs, URLs, URNs, URCs", at http://www.w3.org/pub/WWW/Addressing/Overview.html See also the HTTP spec (from which the error codes are derived): "HTTP - Hypertext Transfer Protocol", at http://www.w3.org/pub/WWW/Protocols/ Related standards and specs: - RFC1808: the "relative URL" spec. (authoritative status) - RFC1738 - the "URL standard". (authoritative status) - RFC1630 - the "URI spec". (informational status) The object returned by URLopener().open(file) will differ per protocol. All you know is that is has methods read(), readline(), readlines(), fileno(), close() and info(). The read*(), fileno() and close() methods work like those of open files. The info() method returns a mimetools.Message object which can be used to query various info about the object, if available. (mimetools.Message objects are queried with the getheader() method.) iN(turljointurlopent URLopenertFancyURLopenert urlretrievet urlcleanuptquotet quote_plustunquotet unquote_plust urlencodet url2pathnamet pathname2urltsplittagt localhosttthishostt ftperrorstbasejointunwrapt splittypet splithostt splitusert splitpasswdt splitportt splitnportt splitqueryt splitattrt splitvaluetsplitgophertypet getproxiess1.17i tmac(R R tnttriscoscCs t|S(sOS-specific conversion from a relative URL of the 'file' scheme to a file system path; not recommended for general use.(R(tpathname((s/sys/lib/python/urllib.pyR 4scCs t|S(sOS-specific conversion from a file system path to a relative URL of the 'file' scheme; not recommended for general use.(R(R!((s/sys/lib/python/urllib.pyR 9scCsr|dj otd|}n!tpt}|ant}|djo|i|Sn|i||SdS(s.urlopen(url [, data]) -> open file-like objecttproxiesN(tNoneRt _urlopenertopen(turltdataR"topener((s/sys/lib/python/urllib.pyRGs    cCs*tp tanti||||S(N(R$Rtretrieve(R&tfilenamet reporthookR'((s/sys/lib/python/urllib.pyRUs cCstotindS(N(R$tcleanup(((s/sys/lib/python/urllib.pyRZstContentTooShortErrorcBseZdZRS(cCsti||||_dS(N(tIOErrort__init__tcontent(tselftmessageR0((s/sys/lib/python/urllib.pyR/`s(t__name__t __module__R/(((s/sys/lib/python/urllib.pyR-_scBseZdZdZdeZddZdZdZ dZ dZ ddZ ddZ dd Zdddd Zdd Zdd Zd ZeedoddZndZdZdZdZddZRS(s,Class to open URLs. This is a class rather than just a subroutine because we may need more than one set of global protocol-specific options. Note -- this is a base class for those who don't want the automatic handling of errors type 302 (relocated) and 401 (authorization needed).sPython-urllib/%scKs|djo t}nt|dp td||_|id|_|id|_d|ifg|_ g|_ t i |_ d|_t|_dS(Nthas_keysproxies must be a mappingtkey_filet cert_files User-Agent(R#RthasattrtAssertionErrorR"tgetR6R7tversiont addheaderst_URLopener__tempfilestostunlinkt_URLopener__unlinkt tempcachetftpcache(R1R"tx509((s/sys/lib/python/urllib.pyR/rs      cCs|idS(N(tclose(R1((s/sys/lib/python/urllib.pyt__del__scCs|idS(N(R,(R1((s/sys/lib/python/urllib.pyRDscCso|ioFx8|iD]-}y|i|Wqtj oqXqW|i2n|io|iindS(N(R=R@tOSErrorRAtclear(R1tfile((s/sys/lib/python/urllib.pyR,s     cGs|ii|dS(sdAdd a header to be used by the HTTP interface only e.g. u.addheader('Accept', 'sound/basic')N(R<tappend(R1targs((s/sys/lib/python/urllib.pyt addheaderscCstt|}|ioF||ijo6|i|\}}t|d}t|||Snt|\}}|p d}n||ijoA|i|}t|\}} t| \} } | |f}nd}d|} ||_ | i dd} t || p2|o|i |||SqC|i ||Sny>|djot|| |Snt|| ||SWn4tij o%} td| ftidnXdS( s6Use URLopener().open(file) instead of open(file, 'r').trbRHtopen_t-t_s socket erroriN(RttoBytesRAR%t addinfourlRR"RR#ttypetreplaceR8topen_unknown_proxyt open_unknowntgetattrtsocketterrorR.tsystexc_info(R1tfullurlR'R*theaderstfpturltypeR&tproxyt proxyhostthosttselectortnametmsg((s/sys/lib/python/urllib.pyR%s6     cCs(t|\}}tdd|fdS(s/Overridable interface to open unknown URL type.s url errorsunknown url typeN(RR.(R1R[R'RRR&((s/sys/lib/python/urllib.pyRUscCs,t|\}}tdd||fdS(s/Overridable interface to open unknown URL type.s url errorsinvalid proxy for %sN(RR.(R1R_R[R'RRR&((s/sys/lib/python/urllib.pyRTscCstt|}|io||ijo|i|Snt|\}}|djom| p |djoXy<|i|}|i}~tt|d|fSWqt j o } qXn|i ||}|i} |ot |d} nddk } t|\} }t|pd\} }t |pd\}} t |pd\}} tii|d}| i|\}}|ii|ti|d} || f}|idj o||i|tpathtsplitexttmkstempR=RItfdopentinttreadtlentwriteRDR-(R1R&R*R+R'RRturl1R]thdrsRdR\ttfpRitgarbageRjtsuffixtfdtresulttbstsizeRotblocknumtblock((s/sys/lib/python/urllib.pyR)sj"           c CsXddk}d}d}t|toEt|\}}|o"t|\}}t|}n|}n|\}}t|\}}t|\} } | }d}| idjo d}net| \}} |ot|\}}n|od| || f}nt |o |}n|p t dn|o%ddk } | i |i } nd} |o%ddk } | i |i } nd} |i|}|dj o>|id||idd |id d t|n|id || o|id d| n| o|idd| n|o|id|nx|iD]}|i|qoW|i|dj o|i|n|i\}}}|djo t dn|i}|djot||d|SnG|djo|i|||||Sn|i||||||SdS(sUse HTTP protocol.iNthttps %s://%s%ss http errors no host giventPOSTs Content-Types!application/x-www-form-urlencodedsContent-Lengths%dtGETsProxy-AuthorizationsBasic %st AuthorizationtHostshttp protocol errorisgot a bad status lineishttp:(s http errors no host given(shttp protocol errorisgot a bad status lineN(thttplibR#t isinstancetstrRRRRtlowert proxy_bypassR.tbase64t b64encodetstriptHTTPt putrequestt putheaderRpR<t endheaderstsendtgetreplytgetfileRQt http_error(R1R&R'Rt user_passwdt proxy_passwdRaRbtrealhostR^trestRt proxy_authtauththRJterrcodeterrmsgR\R]((s/sys/lib/python/urllib.pyt open_httpsp                 c Csd|}t||oft||}|djo||||||} n|||||||} | o| Sqn|i|||||S(sHandle http errors. Derived class can override this, or provide specific handlers named http_error_DDD where DDD is the 3-digit error code.s http_error_%dN(R8RVR#thttp_error_default( R1R&R]RRR\R'RctmethodRx((s/sys/lib/python/urllib.pyRVs  cCs/|i}|itd|||fdS(s>Default error handler: close the connection and raise IOError.s http errorN(RoRDR.(R1R&R]RRR\tvoid((s/sys/lib/python/urllib.pyRes  tsslc CsVddk}d}d}t|toEt|\}}|o"t|\}}t|}n|}n|\}}t|\}}t|\} } | }d}| idjo d}nNt| \}} |ot|\}}n|od| || f}n|p t dn|o%ddk } | i |i } nd} |o%ddk } | i |i } nd} |i |dd|id |i}|dj o>|id ||id d |id dt|n|id|| o|idd| n| o|idd| n|o|id|nx|iD]}|i|qmW|i|dj o|i|n|i\}}}|djo t dn|i}|djot||d|SnG|djo|i|||||Sn|i||||||SdS(sUse HTTPS protocol.iNthttpss %s://%s%ss https errors no host giveniR6R7R~s Content-Types!application/x-www-form-urlencodedsContent-Lengths%dRsProxy-AuthorizationsBasic %sRRshttp protocol errorsgot a bad status lineishttps:(s https errors no host given(shttp protocol errorisgot a bad status lineN(RR#RRRRRRRR.RRRtHTTPSR6R7RRRpR<RRRRRQR(R1R&R'RRRRaRbRR^RRRRRRJRRR\R]((s/sys/lib/python/urllib.pyt open_httpslst                  cCst|tp tdnddk}t|\}}|p tdnt|}t|\}}t|\}}t|}|o%t|}|i|||}n|i ||}t |t d|S( sUse Gopher protocol.s gopher errors;proxy support for gopher protocol currently not implementediNs no host givensgopher:(s gopher errors;proxy support for gopher protocol currently not implemented(s gopher errors no host given( RRR.t gopherlibRRRRt send_queryt send_selectorRQt noheaders(R1R&RRaRbRRtqueryR]((s/sys/lib/python/urllib.pyt open_gophers     cCs~t|tp td n|d djo?|dd!djo+|dd!idjo|i|Sn|i|Sd S( s/Use local file or FTP depending on form of URL.s file errors9proxy support for file protocol currently not implementedis//it/i s localhost/N(s file errors9proxy support for file protocol currently not implemented(RRR.Rtopen_ftpRg(R1R&((s/sys/lib/python/urllib.pyt open_files  ?cCsddk}ddk}ddk}yddkl}Wn#tj oddkl}nXt|\}}t|}yti |} Wn0t j o$} t | i | i | inX| i} |ii| idt} |i|d} |i|d| pd| | f}|pB|}|d d jod |}ntt|d ||Snt|\}}| odti|ttfjoB|}|d d jod |}ntt|d ||Snt ddS(sUse local file.iN(tStringIOtusegmtis6Content-Type: %s Content-Length: %d Last-modified: %s s text/plainiRsfile://RLslocal file errorsnot on local host(slocal file errorsnot on local host(t mimetypest mimetoolst email.Utilst cStringIORt ImportErrorRR R>tstatRFR.terrnotstrerrorR*tst_sizetUtilst formatdatetst_mtimetTruet guess_typetMessageRQR%RRWt gethostbynameRR(R1R&RRtemailRRaRHt localnametstatsteRztmodifiedtmtypeR\turlfiletport((s/sys/lib/python/urllib.pyRgs@$    "cCst|tp tdnddk}ddk}yddkl}Wn#tj oddkl}nXt|\}}|p tdnt |\}}t |\}}|ot |\}} nd} t |}t |pd}t | pd} ti|}|pddk} | i}n t|}t|\}} t |}|id} | d | d} } | o| d  o| d } n| o| d  od| d cBseZdZdZdZddZdZddZddZ ddZ ddZ dd Z dd Z dd Zdd Zdd ZddZdZRS(s?Derived class with handlers for errors we can handle (perhaps).cOs2ti|||h|_d|_d|_dS(Nii (RR/t auth_cachettriestmaxtries(R1RJtkwargs((s/sys/lib/python/urllib.pyR/`s  cCst||d|S(s3Default error handling -- don't raise an exception.shttp:(RQ(R1R&R]RRR\((s/sys/lib/python/urllib.pyRfsc Cs|id7_|io\|i|ijoIt|do |i}n |i}d|_|||dd|Sn|i||||||}d|_|S(s%Error 302 -- relocated (temporarily).ithttp_error_500iis)Internal Server Error: Redirect Recursion(RRR8RRtredirect_internal( R1R&R]RRR\R'tmethRx((s/sys/lib/python/urllib.pythttp_error_302js      c Cswd|jo|d}n d|jo|d}ndS|i}|it|id||}|i|S(Ntlocationturit:(RoRDRRRR%( R1R&R]RRR\R'tnewurlR((s/sys/lib/python/urllib.pyRzs    cCs|i||||||S(s*Error 301 -- also relocated (permanently).(R(R1R&R]RRR\R'((s/sys/lib/python/urllib.pythttp_error_301scCs|i||||||S(s;Error 303 -- also relocated (essentially identical to 302).(R(R1R&R]RRR\R'((s/sys/lib/python/urllib.pythttp_error_303scCsJ|djo |i||||||Sn|i|||||SdS(s1Error 307 -- relocated, but turn POST into error.N(R#RR(R1R&R]RRR\R'((s/sys/lib/python/urllib.pythttp_error_307s  c Csd|jo ti||||||n|d}ddk}|id|} | p ti||||||n| i\} } | idjo ti||||||nd|id} |djot|| || Snt|| || |SdS(s_Error 401 -- authentication required. This function supports Basic authentication only.swww-authenticateiNs![ ]*([^ ]+)[ ]+realm="([^"]*)"tbasictretry_t _basic_auth( RRtretmatchtgroupsRRRR#RV( R1R&R]RRR\R'tstuffRRtschemetrealmRc((s/sys/lib/python/urllib.pythttp_error_401s"    c Csd|jo ti||||||n|d}ddk}|id|} | p ti||||||n| i\} } | idjo ti||||||nd|id} |djot|| || Snt|| || |SdS(seError 407 -- proxy authentication required. This function supports Basic authentication only.sproxy-authenticateiNs![ ]*([^ ]+)[ ]+realm="([^"]*)"Rt retry_proxy_R( RRRRRRRRR#RV( R1R&R]RRR\R'RRRRRRc((s/sys/lib/python/urllib.pythttp_error_407s"    cCst|\}}d||}|id}t|\}} t| \} } | idd} | | } |i| || \} } | p| pdSnt| dddt| ddd| } d| | |id<|djo|i|Sn|i||SdS(Nshttp://R}t@itsafeRfR(RR"Rtfindtget_user_passwdR#RR%(R1R&RR'RaRbRR_R^R`t proxyselectorRRR((s/sys/lib/python/urllib.pytretry_proxy_http_basic_auths  . cCst|\}}d||}|id}t|\}} t| \} } | idd} | | } |i| || \} } | p| pdSnt| dddt| ddd| } d| | |id<|djo|i|Sn|i||SdS(Nshttps://RR iR RfR(RR"RR R R#RR%(R1R&RR'RaRbRR_R^R`R RRR((s/sys/lib/python/urllib.pytretry_proxy_https_basic_auths  . c Cst|\}}|idd}||}|i|||\}}|p|pdSnt|dddt|ddd|}d||} |djo|i| Sn|i| |SdS(NR iR RfRshttp://(RR R R#RR%( R1R&RR'RaRbRRRR((s/sys/lib/python/urllib.pytretry_http_basic_auths . c Cst|\}}|idd}||}|i|||\}}|p|pdSnt|dddt|ddd|}d||} |djo|i| Sn|i| |SdS(NR iR RfRshttps://(RR R R#RR%( R1R&RR'RaRbRRRR((s/sys/lib/python/urllib.pytretry_https_basic_auths . icCs|d|i}||ijo$|o|i|=qH|i|Sn|i||\}}|p|o||f|i|st__iter__tnext(R]RotreadlineR8R3R4R6R7(R1R]((s/sys/lib/python/urllib.pyR/s & cCs d|iit||ifS(Ns<%s at %r whose fp = %r>(t __class__R3tidR](R1((s/sys/lib/python/urllib.pyt__repr__s cCsLd|_d|_d|_d|_|io|iind|_dS(N(R#RoR8R3R4R]RD(R1((s/sys/lib/python/urllib.pyRDs     (R3R4RR/R;RD(((s/sys/lib/python/urllib.pyR2s  R+cBs eZdZdZdZRS(s*Class to add a close hook to an open file.cGs&ti||||_||_dS(N(R2R/t closehookthookargs(R1R]R<R=((s/sys/lib/python/urllib.pyR/s cCsAti||io&|i|id|_d|_ndS(N(R2RDR<R=R#(R1((s/sys/lib/python/urllib.pyRDs    (R3R4RR/RD(((s/sys/lib/python/urllib.pyR+s taddinfocBs eZdZdZdZRS(s.class to add an info() method to an open file.cCsti||||_dS(N(R2R/R\(R1R]R\((s/sys/lib/python/urllib.pyR/scCs|iS(N(R\(R1((s/sys/lib/python/urllib.pyRhs(R3R4RR/Rh(((s/sys/lib/python/urllib.pyR>s RQcBs)eZdZdZdZdZRS(s9class to add info() and geturl() methods to an open file.cCs&ti||||_||_dS(N(R2R/R\R&(R1R]R\R&((s/sys/lib/python/urllib.pyR/s cCs|iS(N(R\(R1((s/sys/lib/python/urllib.pyRhscCs|iS(N(R&(R1((s/sys/lib/python/urllib.pytgeturls(R3R4RR/RhR?(((s/sys/lib/python/urllib.pyRQs  cCsdS(Ni((tx((s/sys/lib/python/urllib.pyt _is_unicodescCs t|tS(N(Rtunicode(R@((s/sys/lib/python/urllib.pyRAscCsXt|oGy|id}WqTtj o!tdt|dqTXn|S(stoBytes(u"URL") --> 'URL'.tASCIIsURL s contains non-ASCII characters(RAtencodet UnicodeErrortrepr(R&((s/sys/lib/python/urllib.pyRPs cCsn|i}|d djo(|ddjo|dd!i}n|d djo|di}n|S(s8unwrap('') --> 'type://host/path'.itisURL:(R(R&((s/sys/lib/python/urllib.pyRs  "%cCs}tdjoddk}|idanti|}|o1|id}|i|t|dfSnd|fS(s:splittype('type:opaquestring') --> 'type', 'opaquestring'.iNs ^([^/:]+):i(t _typeprogR#RtcompileRtgroupRRp(R&RRR((s/sys/lib/python/urllib.pyRs  "cCs`tdjoddk}|idanti|}|o|iddSnd|fS(s;splithost('//host[:port]/path') --> 'host[:port]', '/path'.iNs^//([^/?]*)(.*)$ii(t _hostprogR#RRJRRK(R&RR((s/sys/lib/python/urllib.pyRs   cCsitdjoddk}|idanti|}|ott|iddSnd|fS(sJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.iNs ^(.*)@(.*)$ii(t _userprogR#RRJRtmapRRK(RaRR((s/sys/lib/python/urllib.pyRs   $cCs`tdjoddk}|idanti|}|o|iddSn|dfS(s/splitpasswd('user:passwd') -> 'user', 'passwd'.iNs^([^:]*):(.*)$ii(t _passwdprogR#RRJRRK(RRR((s/sys/lib/python/urllib.pyRs   cCs`tdjoddk}|idanti|}|o|iddSn|dfS(s*splitport('host:port') --> 'host', 'port'.iNs^(.*):([0-9]+)$ii(t _portprogR#RRJRRK(RaRR((s/sys/lib/python/urllib.pyR+s   cCstdjoddk}|idanti|}|of|idd\}}y$|p tdnt|}Wntj o d}nX||fSn||fS(sSplit host and port, returning numeric port. Return given default port if no ':' found; defaults to -1. Return numerical port if a valid number are found after ':'. Return None if ':' but not a valid number.iNs ^(.*):(.*)$iis no digits(t _nportprogR#RRJRRKRRn(RatdefportRRRtnport((s/sys/lib/python/urllib.pyR7s   cCs`tdjoddk}|idanti|}|o|iddSn|dfS(s/splitquery('/path?query') --> '/path', 'query'.iNs^(.*)\?([^?]*)$ii(t _queryprogR#RRJRRK(R&RR((s/sys/lib/python/urllib.pyRMs   cCs`tdjoddk}|idanti|}|o|iddSn|dfS(s)splittag('/path#tag') --> '/path', 'tag'.iNs^(.*)#([^#]*)$ii(t_tagprogR#RRJRRK(R&RR((s/sys/lib/python/urllib.pyR Ys   cCs!|id}|d|dfS(sksplitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].Rii(R(R&twords((s/sys/lib/python/urllib.pyRdscCs`tdjoddk}|idanti|}|o|iddSn|dfS(s-splitvalue('attr=value') --> 'attr', 'value'.iNs^([^=]*)=(.*)$ii(t _valueprogR#RRJRRK(RRR((s/sys/lib/python/urllib.pyRks   cCs?|d djo$|dd!o|d|dfSnd|fS(s2splitgophertype('/Xselector') --> 'X', 'selector'.iRiN(R#(Rb((s/sys/lib/python/urllib.pyRvsccs)x"|]}d|t|fVqWdS(s%02xN(tchr(t.0R((s/sys/lib/python/urllib.pys |siccs)x"|]}d|t|fVqWdS(s%02XN(RX(RYR((s/sys/lib/python/urllib.pys }sc Cs|id}xtdt|D]}||}yt|d |d|| 'abc def'.t%iiiRf( RtxrangeRpt _hextochrtKeyErrortUnicodeDecodeErrortunichrRnR(tstresRtitem((s/sys/lib/python/urllib.pyRs .cCs|idd}t|S(s%unquote('%7e/abc+def') -> '~/abc def't+t (RSR(R`((s/sys/lib/python/urllib.pyR ssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-RcCs|tf}yt|}Wnrtj of|t7}h}xBtdD]4}t|}||jo|pd||| 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. is%%%02XRf(t always_safet _safemapsR]trangeRXRNt __getitem__R(R`R tcachekeytsafe_mapRtcRa((s/sys/lib/python/urllib.pyRs    &RfcCsAd|jo't||d}|iddSnt||S(s9Quote the query fragment of a URL; replacing ' ' with '+'RdRc(RRS(R`R ((s/sys/lib/python/urllib.pyRs ic Cst|do|i}nhy0t|ot|dt o tnWn4tj o(ti\}}}td|nXg}|pTxl|D]E\}}tt |}tt |}|i |d|qWnx|D]\}}tt |}t|t o%t|}|i |d|qt |o1t|i dd}|i |d|qyt|}Wn:tj o.tt |}|i |d|qXx/|D]'} |i |dtt | qWqWdi |S(svEncode a sequence of two-element tuples or dictionary into a URL query string. If any values in the query arg are sequences and doseq is true, each sequence element is converted to a separate parameter. If the query arg is a sequence of two-element tuples, the order of the parameters in the output will match the order of parameters in the input. titemsis1not a valid non-string sequence or mapping objectRRCRSt&(R8RlRpRttuplet TypeErrorRYRZRRRIRARDR( RtdoseqttytvattbtlRRR@telt((s/sys/lib/python/urllib.pyR sB "    )cCs`h}xStiiD]B\}}|i}|o#|ddjo|||d proxy server URL mappings. Scan the environment for variables named _proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. it_proxy(R>tenvironRlR(R"RcR((s/sys/lib/python/urllib.pytgetproxies_environments   tdarwinc Csyddk}Wntj o hSnXy|i}Wn|ij o hSnXh}d|joD|do9y|d}Wn|ij oqXd||d proxy server URL mappings. By convention the mac uses Internet Config to store proxies. An HTTP proxy, for instance, is stored under the HttpProxy key. iNt UseHTTPProxyt HTTPProxyHosts http://%sR}(ticRtICRX(R|tconfigR"R((s/sys/lib/python/urllib.pytgetproxies_internetconfigs   cCsdS(Ni((R@((s/sys/lib/python/urllib.pyR.scCstptS(N(RxR(((s/sys/lib/python/urllib.pyR1sc Csnh}yddk}Wntj o |SnXy|i|id}|i|dd}|ot|i|dd}d|josx|idD][}|idd \}}ddk}|id |pd ||f}n||| proxy server URL mappings. Win32 uses the registry to store proxies. iNs;Software\Microsoft\Windows\CurrentVersion\Internet Settingst ProxyEnableit ProxyServerRRis ^([^/:]+)://s%s://%sishttp:R}s http://%ssftp://%sR ( t_winregRtOpenKeytHKEY_CURRENT_USERt QueryValueExRRRRtCloset WindowsErrorRRo( R"RtinternetSettingst proxyEnablet proxyServertptprotocoltaddressR((s/sys/lib/python/urllib.pytgetproxies_registry5s:        cCstptS(sReturn a dictionary of scheme -> proxy server URL mappings. Returns settings gathered from the environment, if specified, or the registry. (RxR(((s/sys/lib/python/urllib.pyRbsc Cs`yddk}ddk}Wntj o dSnXyK|i|id}|i|dd}t|i|dd}Wntj o dSnX| p| odSnt|\}}|g}y1t i |}||jo|i |nWnt i j onXy1t i |} | |jo|i | nWnt i j onX|id}d} xi| t|joU|| djo6dd t it i t ig|| | d +n| d 7} qzWxv|D]n} | id d } | id d} | idd } x/|D]'} |i| | |iod Sq-q-WqWdS(Niis;Software\Microsoft\Windows\CurrentVersion\Internet SettingsRt ProxyOverrideRsRs 127.0.0.1it.s\.t*s.*t?(RRRRRRRRRRWRRIRXtgetfqdnRRpRRSRR( RaRRRRt proxyOverridetrawHostRtaddrtfqdnRttesttval((s/sys/lib/python/urllib.pyRksd            !cCsdS(Ni((Ra((s/sys/lib/python/urllib.pyRscCsd}x$tdD]}|t|}qW|d}ti}t|}t|}ti}||jo dGHnt|GHt|GHt|GHt||dGdGHdS(NRfiisWrong!itsec(RgRXRRRRFtround(R`Rtt0tqstuqstt1((s/sys/lib/python/urllib.pyttest1s           cCsd|||fGHdS(Ns0Block number: %d, Block size: %d, Total size: %d((R{t blocksizet totalsize((s/sys/lib/python/urllib.pyR+sc Cs9|p:dddddg}ttdo|idqAnzx|D]}dG|GdGHt|dt\}}|GH|o6d GHx%|iD]}|d G||GHqWd GHnt|d }|i}~d |jo(t i dd}|i |d }n|GHd\}}qKWddGHWdt XdS(Ns /etc/passwdsfile:/etc/passwdsfile://localhost/etc/passwdsftp://ftp.gnu.org/pub/READMEs http://www.python.org/index.htmlRs!https://synergy.as.cmu.edu/~geek/RNi s======RRLs Rfi(s ----------s ----------(NN( R8RRIRR#R+RR%Rotstringt maketranst translateR(RJR&tfnRRR]R'ttable((s/sys/lib/python/urllib.pyRs:       c Cs!ddk}ddk}y#|i|idd\}}Wn&|ij o}|GHdGHdSnXd}xR|D]J\}}|djo|d}n|djodGHd Gd GHdSqqqqW|o&|djo tnt|n2|p dGHnx|D]}t|iGqWdS( NiitthsUse -h for helpis-ts-hs&Usage: python urllib.py [-t] [url ...]s-t runs self-test;s'otherwise, contents of urls are printed(tgetoptRYtargvRXRRRRo( RRYtoptsRJRdtttoRR&((s/sys/lib/python/urllib.pytmains4#        t__main__(XRRRWR>RRYturlparseRRt__all__RRRct macurl2pathR R t nturl2patht rourl2pathR#R$RRRR.R-RBRRRRRRRRRRRR2R+R>RQRBt NameErrorRARPRRIRRLRRMRRORRPRRQRRTRRUR RRWRRtdictRgR\tupdateRR ReRfRRR RxtplatformRRRRRR+RRR3(((s/sys/lib/python/urllib.pyss                B              "  @     - =    !