Lc"@sdZddkZddkZddkZddkZddkZddklZdddddd d d d d ddddddddddddddddddgZ d Z d!Z ei d"jodd#k lZlZngei d$jodd#klZlZn=ei d%jodd#klZlZnd&Zd'Zeaeed(Zeeed)Zd*ZyddkZWn eZnXeZd+efd,YZhZdfd-YZdefd.YZea d/Z!ea"d0Z#ea$d1Z%ea&d2Z'd3fd4YZ(d5fd6YZ)d7e)fd8YZ*d9e)fd:YZ+d;e)fd<YZ,ye-Wne.j od=Z/n Xd>Z/d?Z0d@Z1ea2dAZ3ea4dBZ5ea6dCZ7ea8dDZ9ea:dEZ;ea<ddFZ=ea>dGZ?ea@dHZAdIZBeaCdJZDdKZEeFdLeEDZGdMZHdNZIdOZJhZKdPdQZLdRdSZMdTdUZNdVZOdWZPeiQdXjo>ddYkRlSZSlTZTdZZUd[ZVd\ZWd]ZXnEei d$jo(d^ZYd_ZXd`ZZdaZWn eOZXePZWdbZ[dcZ\gddZ]deZ^e_dfjo e^ndS(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 splitvaluet 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/usr/lib64/python2.6/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/usr/lib64/python2.6/urllib.pyR 9scCsddkl}|ddd|dj otd|}n!tpt}|ant}|djo|i|S|i||SdS(s=Create a file-like object for the specified URL to read from.i(twarnpy3ksMurllib.urlopen() has been removed in Python 3.0 in favor of urllib2.urlopen()t stacklevelitproxiesN(twarningsR!tNoneRt _urlopenertopen(turltdataR#R!topener((s/usr/lib64/python2.6/urllib.pyRGs     cCs*tp tanti||||S(N(R&Rtretrieve(R(tfilenamet reporthookR)((s/usr/lib64/python2.6/urllib.pyRYs cCs-totintitidS(N(R&tcleanupt _safemapstcleartftpcache(((s/usr/lib64/python2.6/urllib.pyR^s tContentTooShortErrorcBseZdZRS(cCsti||||_dS(N(tIOErrort__init__tcontent(tselftmessageR5((s/usr/lib64/python2.6/urllib.pyR4ns(t__name__t __module__R4(((s/usr/lib64/python2.6/urllib.pyR2mscBseZdZdZdeZddZdZdZ dZ dZ ddZ ddZ dd Zdddd Zdd Zdd Zd ZeoddZndZdZdZddZRS(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#tgetR;R<tversiont addheaderst_URLopener__tempfilestostunlinkt_URLopener__unlinkt tempcacheR1(R6R#tx509((s/usr/lib64/python2.6/urllib.pyR4s      cCs|idS(N(tclose(R6((s/usr/lib64/python2.6/urllib.pyt__del__scCs|idS(N(R.(R6((s/usr/lib64/python2.6/urllib.pyRHscCso|ioFx8|iD]-}y|i|Wqtj oqXqW|i2n|io|iindS(N(RBREtOSErrorRFR0(R6tfile((s/usr/lib64/python2.6/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(RAtappend(R6targs((s/usr/lib64/python2.6/urllib.pyt addheaderscCstt|}t|dd}|ioC||ijo3|i|\}}t|d}t|||St|\}}|p d}n||ijoA|i|}t|\}} t| \} } | |f}nd }d|} ||_ | i dd} t || p/|o|i |||S|i||Sny;|d jot|| |St|| ||SWn4tij o%} td| ftid nXd S( s6Use URLopener().open(file) instead of open(file, 'r').tsafes%/:=&?~#+!$,;'@()*[]|trbRKtopen_t-t_s socket erroriN(RttoBytesRRFR't addinfourlRR#RR%ttypetreplaceR=topen_unknown_proxyt open_unknowntgetattrtsocketterrorR3tsystexc_info(R6tfullurlR)R,theaderstfpturltypeR(tproxyt proxyhostthosttselectortnametmsg((s/usr/lib64/python2.6/urllib.pyR's8     cCs(t|\}}tdd|fdS(s/Overridable interface to open unknown URL type.s url errorsunknown url typeN(RR3(R6R_R)RVR(((s/usr/lib64/python2.6/urllib.pyRYscCs,t|\}}tdd||fdS(s/Overridable interface to open unknown URL type.s url errorsinvalid proxy for %sN(RR3(R6RcR_R)RVR(((s/usr/lib64/python2.6/urllib.pyRXscCstt|}|io||ijo |i|St|\}}|djom| p |djoXy<|i|}|i}~tt|d|fSWqt j o } qXn|i ||}z|i} |ot |d} nddk } t|\} }t|pd\} }t |pd\}} t |pd\}} tii|d}| i|\}}|ii|ti|d} z|| f}|idj o||i||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\}}}|i}|djo"|o|int dnd|jo djnot||d||S|djo|i|||||S|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 lineii,shttp:(s http errors no host given(shttp protocol errorisgot a bad status lineN(thttplibR%t isinstancetstrRRRRtlowert proxy_bypassR3tbase64t b64encodetstriptHTTPt putrequestt putheaderRtRAt endheaderstsendtgetreplytgetfileRHRUt http_error(R6R(R)Rt user_passwdt proxy_passwdReRftrealhostRbtrestRt proxy_authtauththRMterrcodeterrmsgR`Ra((s/usr/lib64/python2.6/urllib.pyt open_http#s~                 c Csd|}t||oct||}|djo||||||} n|||||||} | o| Sn|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(R=RZR%thttp_error_default( R6R(RaRRR`R)RgtmethodR|((s/usr/lib64/python2.6/urllib.pyRns   cCs/|i}|itd|||fdS(s>Default error handler: close the connection and raise IOError.s http errorN(RsRHR3(R6R(RaRRR`tvoid((s/usr/lib64/python2.6/urllib.pyR}s  c Csyddk}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\}}}|i}|djo"|o|int dnd|jo djnot||d||S|djo|i|||||S|i||||||SdS(sUse HTTPS protocol.iNthttpss %s://%s%ss https errors no host giveniR;R<Rs Content-Types!application/x-www-form-urlencodedsContent-Lengths%dRsProxy-AuthorizationsBasic %sRRshttp protocol errorsgot a bad status lineii,shttps:(s https errors no host given(shttp protocol errorisgot a bad status lineN(RR%RRRRRRRR3RRRtHTTPSR;R<RRRtRARRRRRHRUR(R6R(R)RRRReRfRRbRRRRRRMRRR`Ra((s/usr/lib64/python2.6/urllib.pyt open_httpss                  cCs{t|tp td n|d djo<|dd!djo(|dd!idjo|i|S|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(RRR3Rtopen_ftpRk(R6R(((s/usr/lib64/python2.6/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}|p?|}|d d jod |}ntt|d ||St|\}}| oati|ttfjo?|}|d d jod |}ntt|d ||St ddS(sUse local file.iN(tStringIOtusegmtis6Content-Type: %s Content-Length: %d Last-modified: %s s text/plainiRsfile://RPslocal file errorsnot on local host(slocal file errorsnot on local host(t mimetypest mimetoolst email.utilst cStringIORt ImportErrorRR RCtstatRJR3terrnotstrerrorR,tst_sizetutilst formatdatetst_mtimetTruet guess_typetMessageRUR'RR[t gethostbynameRR(R6R(RRtemailRReRKt localnametstatsteR~tmodifiedtmtypeR`turlfiletport((s/usr/lib64/python2.6/urllib.pyRks@$     " 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 (RR4t auth_cachettriestmaxtries(R6RMtkwargs((s/usr/lib64/python2.6/urllib.pyR4js  cCst||d||S(s3Default error handling -- don't raise an exception.shttp:(RU(R6R(RaRRR`((s/usr/lib64/python2.6/urllib.pyRpsc Cs|id7_|ioY|i|ijoFt|do |i}n |i}d|_|||dd|S|i||||||}d|_|S(s%Error 302 -- relocated (temporarily).ithttp_error_500iis)Internal Server Error: Redirect Recursion(RRR=RRtredirect_internal( R6R(RaRRR`R)tmethR|((s/usr/lib64/python2.6/urllib.pythttp_error_302ts       c Csd|jo|d}n d|jo|d}ndS|i}|it|id||}|i} | idp| idp | idp!td||d||n|i|S( Ntlocationturit:shttp://shttps://sftp://sredirect errors) - Redirection to url '%s' is not allowed(RsRHRRVRt startswithR3R'( R6R(RaRRR`R)tnewurlRt newurl_lower((s/usr/lib64/python2.6/urllib.pyRs"       cCs|i||||||S(s*Error 301 -- also relocated (permanently).(R(R6R(RaRRR`R)((s/usr/lib64/python2.6/urllib.pythttp_error_301scCs|i||||||S(s;Error 303 -- also relocated (essentially identical to 302).(R(R6R(RaRRR`R)((s/usr/lib64/python2.6/urllib.pythttp_error_303scCsG|djo|i||||||S|i|||||SdS(s1Error 307 -- relocated, but turn POST into error.N(R%RR(R6R(RaRRR`R)((s/usr/lib64/python2.6/urllib.pythttp_error_307s c Csd|jo ti||||||n|d}ddk}|id|} | p ti||||||n| i\} } | idjo ti||||||nd|id} |djot|| || St|| || |SdS(s_Error 401 -- authentication required. This function supports Basic authentication only.swww-authenticateiNs![ ]*([^ ]+)[ ]+realm="([^"]*)"tbasictretry_t _basic_auth( RRtretmatchtgroupsRRVR%RZ( R6R(RaRRR`R)tstuffRRtschemetrealmRg((s/usr/lib64/python2.6/urllib.pythttp_error_401s"    c Csd|jo ti||||||n|d}ddk}|id|} | p ti||||||n| i\} } | idjo ti||||||nd|id} |djot|| || St|| || |SdS(seError 407 -- proxy authentication required. This function supports Basic authentication only.sproxy-authenticateiNs![ ]*([^ ]+)[ ]+realm="([^"]*)"Rt retry_proxy_R( RRRRRRRVR%RZ( R6R(RaRRR`R)RRRRRRg((s/usr/lib64/python2.6/urllib.pythttp_error_407s"    cCst|\}}d||}|id}t|\}} t| \} } | idd} | | } |i| || \} } | p| pdSt| dddt| ddd| } d| | |id<|djo|i|S|i||SdS(Nshttp://Rt@iRORjR(RR#Rtfindtget_user_passwdR%RR'(R6R(RR)ReRfRRcRbRdt proxyselectorRRR((s/usr/lib64/python2.6/urllib.pytretry_proxy_http_basic_auths  . cCst|\}}d||}|id}t|\}} t| \} } | idd} | | } |i| || \} } | p| pdSt| dddt| ddd| } d| | |id<|djo|i|S|i||SdS(Nshttps://RR iRORjR(RR#RR R R%RR'(R6R(RR)ReRfRRcRbRdR RRR((s/usr/lib64/python2.6/urllib.pytretry_proxy_https_basic_auths  . c Cst|\}}|idd}||}|i|||\}}|p|pdSt|dddt|ddd|}d||} |djo|i| S|i| |SdS(NR iRORjRshttp://(RR R R%RR'( R6R(RR)ReRfRRRR((s/usr/lib64/python2.6/urllib.pytretry_http_basic_auths . c Cst|\}}|idd}||}|i|||\}}|p|pdSt|dddt|ddd|}d||} |djo|i| S|i| |SdS(NR iRORjRshttps://(RR R R%RR'( R6R(RR)ReRfRRRR((s/usr/lib64/python2.6/urllib.pytretry_https_basic_auths . icCs|d|i}||ijo$|o|i|=qH|i|Sn|i||\}}|p|o||f|i|st__iter__tnext(RaRstreadlineR=R6R7R9R:(R6Ra((s/usr/lib64/python2.6/urllib.pyR4s  cCs d|iit||ifS(Ns<%s at %r whose fp = %r>(t __class__R8tidRa(R6((s/usr/lib64/python2.6/urllib.pyt__repr__s cCsLd|_d|_d|_d|_|io|iind|_dS(N(R%RsR;R6R7RaRH(R6((s/usr/lib64/python2.6/urllib.pyRHs     (R8R9RR4R>RH(((s/usr/lib64/python2.6/urllib.pyR5s  R-cBs eZdZdZdZRS(s*Class to add a close hook to an open file.cGs&ti||||_||_dS(N(R5R4t closehookthookargs(R6RaR?R@((s/usr/lib64/python2.6/urllib.pyR4s cCsAti||io&|i|id|_d|_ndS(N(R5RHR?R@R%(R6((s/usr/lib64/python2.6/urllib.pyRHs    (R8R9RR4RH(((s/usr/lib64/python2.6/urllib.pyR-s taddinfocBs eZdZdZdZRS(s.class to add an info() method to an open file.cCsti||||_dS(N(R5R4R`(R6RaR`((s/usr/lib64/python2.6/urllib.pyR4scCs|iS(N(R`(R6((s/usr/lib64/python2.6/urllib.pyRls(R8R9RR4Rl(((s/usr/lib64/python2.6/urllib.pyRAs RUcBs5eZdZddZdZdZdZRS(s9class to add info() and geturl() methods to an open file.cCs/ti||||_||_||_dS(N(R5R4R`R(tcode(R6RaR`R(RB((s/usr/lib64/python2.6/urllib.pyR4s  cCs|iS(N(R`(R6((s/usr/lib64/python2.6/urllib.pyRlscCs|iS(N(RB(R6((s/usr/lib64/python2.6/urllib.pytgetcodescCs|iS(N(R((R6((s/usr/lib64/python2.6/urllib.pytgeturlsN(R8R9RR%R4RlRCRD(((s/usr/lib64/python2.6/urllib.pyRUs    cCsdS(Ni((tx((s/usr/lib64/python2.6/urllib.pyt _is_unicodescCs t|tS(N(Rtunicode(RE((s/usr/lib64/python2.6/urllib.pyRFscCsXt|oGy|id}WqTtj o!tdt|dqTXn|S(stoBytes(u"URL") --> 'URL'.tASCIIsURL s contains non-ASCII characters(RFtencodet UnicodeErrortrepr(R(((s/usr/lib64/python2.6/urllib.pyRTs cCsn|i}|d djo(|ddjo|dd!i}n|d djo|di}n|S(s8unwrap('') --> 'type://host/path'.itisURL:(R(R(((s/usr/lib64/python2.6/urllib.pyRs  "cCsztdjoddk}|idanti|}|o.|id}|i|t|dfSd|fS(s:splittype('type:opaquestring') --> 'type', 'opaquestring'.iNs ^([^/:]+):i(t _typeprogR%RtcompileRtgroupRRt(R(RRR((s/usr/lib64/python2.6/urllib.pyRs  cCs]tdjoddk}|idanti|}|o|iddSd|fS(s;splithost('//host[:port]/path') --> 'host[:port]', '/path'.iNs^//([^/?]*)(.*)$ii(t _hostprogR%RRORRP(R(RR((s/usr/lib64/python2.6/urllib.pyR+s  cCsftdjoddk}|idanti|}|ott|iddSd|fS(sJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.iNs ^(.*)@(.*)$ii(t _userprogR%RRORtmapRRP(ReRR((s/usr/lib64/python2.6/urllib.pyR7s  cCs]tdjoddk}|idanti|}|o|iddS|dfS(s/splitpasswd('user:passwd') -> 'user', 'passwd'.iNs^([^:]*):(.*)$ii(t _passwdprogR%RRORRP(RRR((s/usr/lib64/python2.6/urllib.pyRCs  cCs]tdjoddk}|idanti|}|o|iddS|dfS(s*splitport('host:port') --> 'host', 'port'.iNs^(.*):([0-9]+)$ii(t _portprogR%RRORRP(ReRR((s/usr/lib64/python2.6/urllib.pyRPs  cCstdjoddk}|idanti|}|oc|idd\}}y$|p tdnt|}Wntj o d}nX||fS||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%RRORRPRRr(RetdefportRRRtnport((s/usr/lib64/python2.6/urllib.pyR\s     cCs]tdjoddk}|idanti|}|o|iddS|dfS(s/splitquery('/path?query') --> '/path', 'query'.iNs^(.*)\?([^?]*)$ii(t _queryprogR%RRORRP(R(RR((s/usr/lib64/python2.6/urllib.pyRrs  cCs]tdjoddk}|idanti|}|o|iddS|dfS(s)splittag('/path#tag') --> '/path', 'tag'.iNs^(.*)#([^#]*)$ii(t_tagprogR%RRORRP(R(RR((s/usr/lib64/python2.6/urllib.pyR ~s  cCs!|id}|d|dfS(sksplitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].Rii(R(R(twords((s/usr/lib64/python2.6/urllib.pyRscCs]tdjoddk}|idanti|}|o|iddS|dfS(s-splitvalue('attr=value') --> 'attr', 'value'.iNs^([^=]*)=(.*)$ii(t _valueprogR%RRORRP(RRR((s/usr/lib64/python2.6/urllib.pyRs  t0123456789ABCDEFabcdefccsGx@|]9}x0tD](}||tt||dfVqWqWdS(iN(t_hexdigtchrRr(t.0Rtb((s/usr/lib64/python2.6/urllib.pys s c Cs|id}xtdt|D]}||}yt|d |d|| 'abc def'.t%iiiRj( RtxrangeRtt _hextochrtKeyErrortUnicodeDecodeErrortunichrRrR(tstresRtitem((s/usr/lib64/python2.6/urllib.pyRs .cCs|idd}t|S(s%unquote('%7e/abc+def') -> '~/abc def't+t (RWR(Rh((s/usr/lib64/python2.6/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%%%02XRj(t always_safeR/RetrangeR_RSt __getitem__R(RhROtcachekeytsafe_mapRtcRi((s/usr/lib64/python2.6/urllib.pyRs    &RjcCs>d|jo$t||d}|iddSt||S(s9Quote the query fragment of a URL; replacing ' ' with '+'RlRk(RRW(RhRO((s/usr/lib64/python2.6/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 objectRRHRWt&(R=RsRtRttuplet TypeErrorR]R^RRRLRFRIR( tquerytdoseqttytvattbtlRRREtelt((s/usr/lib64/python2.6/urllib.pyR sB "    )cCsh}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_proxytREQUEST_METHODRN(RCtenvironRsRtpopR%(R#RgR((s/usr/lib64/python2.6/urllib.pytgetproxies_environments   cCstiiddptiidd}|djodSt|\}}xC|idD]2}|o%|i|p|i|odSq_WdS(sTest if proxies should not be used for a particular host. Checks the environment for a variable named no_proxy, which should be a list of DNS suffixes separated by commas, or '*' for all hosts. tno_proxyRjtNO_PROXYt*iRi(RCRR?RRtendswith(ReRthostonlyRRg((s/usr/lib64/python2.6/urllib.pytproxy_bypass_environment7s+ ' tdarwin(t_get_proxy_settingst _get_proxiesc Csddk}ddk}ddkl}t|\}}d}t}d|jo|dotSnd}x5|idd D]!} | pqn|id| } | dj o|djo?y|i |}||}Wq|i j o qqXn|| i d } | i d } | djo$d | i d i dd } nt | d } d | } || ?| | ?jotSq||| otSqWtS(s Return True iff this host shouldn't be accessed using a proxy This function uses the MacOSX framework SystemConfiguration to fetch the proxy information. iN(tfnmatchcSs{|id}tt|}t|djo|ddddgd }n|dd>|dd>B|dd>B|d BS( Nt.iiiiiiii(RRSRrRt(tipAddrtparts((s/usr/lib64/python2.6/urllib.pytip2num[s Rtexclude_simplet exceptionss(\d+(?:\.\d+)*)(/\d+)?iiii ((RR[RRRRR%R?RRR\RPtcountRrtFalse( ReRR[RRRRtproxy_settingsthostIPRtmtbasetmask((s/usr/lib64/python2.6/urllib.pytproxy_bypass_macosx_sysconfNsB           $   cCstS(sReturn a dictionary of scheme -> proxy server URL mappings. This function uses the MacOSX framework SystemConfiguration to fetch the proxy information. (R(((s/usr/lib64/python2.6/urllib.pytgetproxies_macosx_sysconfscCs#to t|St|SdS(N(RRR(Re((s/usr/lib64/python2.6/urllib.pyRs  cCstptS(N(RR(((s/usr/lib64/python2.6/urllib.pyRsc Csyh}yddk}Wntj o|SXy)|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:Rs http://%ss https://%sRsftp://%sR!( t_winregRtOpenKeytHKEY_CURRENT_USERt QueryValueExRRRRtCloset WindowsErrorRRv( R#RtinternetSettingst proxyEnablet proxyServertptprotocoltaddressR((s/usr/lib64/python2.6/urllib.pytgetproxies_registrys<       cCstptS(sReturn a dictionary of scheme -> proxy server URL mappings. Returns settings gathered from the environment, if specified, or the registry. (RR(((s/usr/lib64/python2.6/urllib.pyRsc CsTyddk}ddk}Wntj odSXyK|i|id}|i|dd}t|i|dd}Wntj odSX| p| odSt|\}}|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} qqWxs|D]k} | id d } | id d} | idd } x,|D]$} |i| | |iod Sq$WqWdS(Niis;Software\Microsoft\Windows\CurrentVersion\Internet SettingsRt ProxyOverrideRsRs 127.0.0.1iRs\.Rs.*t?(RRRRRRRRRR[RRLR\tgetfqdnRRtRRWRR( ReRRRRt proxyOverridetrawHostRtaddrtfqdnRttesttval((s/usr/lib64/python2.6/urllib.pytproxy_bypass_registrysf          ! cCs#to t|St|SdS(sReturn a dictionary of scheme -> proxy server URL mappings. Returns settings gathered from the environment, if specified, or the registry. N(RRR(Re((s/usr/lib64/python2.6/urllib.pyRs  cCsd}x$tdD]}|t|}qW|d}ti}t|}t|}ti}||jo dGHnt|GHt|GHt|GHt||dGdGHdS(NRjiisWrong!itsec(RnR_RRRRKtround(RhRtt0tqstuqstt1((s/usr/lib64/python2.6/urllib.pyttest1"s           cCsd|||fGHdS(Ns0Block number: %d, Block size: %d, Total size: %d((Rt blocksizet totalsize((s/usr/lib64/python2.6/urllib.pyR-2sc 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/RRi s======RRPs Rji(s ----------s ----------(NN( R=RRLRR%R-RR'Rststringt maketranst translateR(RMR(tfnRRRaR)ttable((s/usr/lib64/python2.6/urllib.pyR8s<       c Csddk}ddk}y#|i|idd\}}Wn#|ij o}|GHdGHdSXd}xO|D]G\}}|djo|d}n|djodGHd Gd GHdSqnW|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(tgetoptR]targvR\RRRRs( RR]toptsRMRhtttoRR(((s/usr/lib64/python2.6/urllib.pytmainXs4#       t__main__(`RRR[RCRR]turlparseRRt__all__RRRgt macurl2pathR R t nturl2patht rourl2pathR%R&RRRtsslRRRR3R2R1RRRRRRRRRRRR5R-RARURGt NameErrorRFRTRRNRRQRRRRRTRRURRVRRYRRZR RR\RR^tdictRdRR RmR/RRR RRtplatformt_scproxyRRRRRRRRRR-RRR8(((s/usr/lib64/python2.6/urllib.pyts                 N "             "  @   <   . ;