Efc@sdZddlZddlZddlZddlZddlZddlZddlZddlm Z dddddd d d d d ddddddddddddddddddgZ d Z d!Z ejd"krdd#lmZmZn:ejd$kr dd#lmZmZnd%Zd&Zeaeed'Zeeed(Zd)ZyddlZWn eZnXeZd*efd+YZiZdfd,YZdefd-YZ ea!d.Z"ea#d/Z$ea%d0Z&ea'd1Z(d2fd3YZ)d4fd5YZ*d6e*fd7YZ+d8e*fd9YZ,d:e*fd;YZ-ye.Wne/k rd<Z0n Xd=Z0d>Z1d?Z2ea3d@Z4ea5dAZ6ea7dBZ8ea9dCZ:ea;dDZ<ea=ddEZ>ea?dFZ@eaAdGZBdHZCeaDdIZEdJZFeGdKeFDZHejIdLZJdMZKdNZLdOZMiZNxfeOePdPeQeRePdPD]=\ZSZTeSdQkoeTeMkreTn dRjUeSeNeTtd|}ntsVt}|ant}|dkru|j|S|j||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.7/urllib.pyRHs      cCs(tstantj||||S(N(R%Rtretrieve(R'tfilenamet reporthookR(((s/usr/lib64/python2.7/urllib.pyRZs cCs+trtjntjtjdS(N(R%tcleanupt _safe_quoterstcleartftpcache(((s/usr/lib64/python2.7/urllib.pyR_s  tContentTooShortErrorcBseZdZRS(cCstj||||_dS(N(tIOErrort__init__tcontent(tselftmessageR4((s/usr/lib64/python2.7/urllib.pyR3os(t__name__t __module__R3(((s/usr/lib64/python2.7/urllib.pyR1nscBseZdZdZdeZddZdZdZ dZ dZ ddZ ddZ dd Zdddd Zdd Zdd Zd ZerddZndZdZdZddZRS(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|dkrt}n||_|jd|_|jd|_d|jfg|_g|_t j |_ d|_ t |_ dS(Ntkey_filet cert_files User-Agent(R$RR"tgetR9R:tversiont addheaderst_URLopener__tempfilestostunlinkt_URLopener__unlinkt tempcacheR0(R5R"tx509((s/usr/lib64/python2.7/urllib.pyR3s      cCs|jdS(N(tclose(R5((s/usr/lib64/python2.7/urllib.pyt__del__scCs|jdS(N(R-(R5((s/usr/lib64/python2.7/urllib.pyRDscCsi|jrLx6|jD]+}y|j|Wqtk r=qXqW|j2n|jre|jjndS(N(R>RAtOSErrorRBR/(R5tfile((s/usr/lib64/python2.7/urllib.pyR-s    cGs|jj|dS(sdAdd a header to be used by the HTTP interface only e.g. u.addheader('Accept', 'sound/basic')N(R=tappend(R5targs((s/usr/lib64/python2.7/urllib.pyt addheaderscCstt|}t|dd}|jrn||jkrn|j|\}}t|d}t|||St|\}}|sd}n||jkr|j|}t|\}} t| \} } | |f}nd }d|} ||_ | j dd} t ||  s%| dkrQ|r>|j |||S|j||Sny9|d krst|| |St|| ||SWn2tjk r} td | ftjd nXd S( s6Use URLopener().open(file) instead of open(file, 'r').tsafes%/:=&?~#+!$,;'@()*[]|trbRGtopen_t-t_topen_local_files socket erroriN(RttoBytesRRBR&t addinfourlRR"RR$ttypetreplacethasattrtopen_unknown_proxyt open_unknowntgetattrtsocketterrorR2tsystexc_info(R5tfullurlR(R+theaderstfpturltypeR'tproxyt proxyhostthosttselectortnametmsg((s/usr/lib64/python2.7/urllib.pyR&s8     cCs(t|\}}tdd|fdS(s/Overridable interface to open unknown URL type.s url errorsunknown url typeN(RR2(R5R]R(RSR'((s/usr/lib64/python2.7/urllib.pyRWscCs,t|\}}tdd||fdS(s/Overridable interface to open unknown URL type.s url errorsinvalid proxy for %sN(RR2(R5RaR]R(RSR'((s/usr/lib64/python2.7/urllib.pyRVsc Cstt|}|jr5||jkr5|j|St|\}}|dkr| sf|dkryC|j|}|j}|jtt |d|fSWqt k rqXn|j ||}z|j} |rt |d} nddl } t|\} } t | p#d\} } t | p;d\} } t| pSd\} } tjj| d}| j|\}}|jj|tj|d} z|| f}|jdk r||j|RHtfdopentinttreadtlentwriteR1(R5R'R+R,R(RSturl1R_thdrsR^ttfpRjtgarbageRktsuffixtfdtresulttbstsizeRptblocknumtblock((s/usr/lib64/python2.7/urllib.pyR*sj            cCs=ddl}d}d}t|trit|\}}|r`t|\}}t|}n|}n|\}}t|\}}t|\} } | }d}| jdkrd}n^t| \}} |rt|\}}n|r d| || f}nt |r|}n|s0t dn|rZt|}t j |j } nd} |rt|}t j |j } nd} |j|} |dk r| jd|| jdd | jd d t|n| jd || r| jd d| n| r2| jdd| n|rK| jd|nx|jD]}| j|qUW| j|| j\}}}| j}|dkr|r|jnt dnd|kodknrt||d||S|dkr|j|||||S|j||||||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_bypassR2tbase64t b64encodetstriptHTTPt putrequestt putheaderRqR=t endheaderstgetreplytgetfileRDRRt http_error(R5R'R(Rt user_passwdt proxy_passwdRcRdtrealhostR`trestt proxy_authtauththRIterrcodeterrmsgR^R_((s/usr/lib64/python2.7/urllib.pyt open_http$sx                c Csd|}t||rwt||}|dkrO||||||} n|||||||} | rw| Sn|j|||||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(RURXR$thttp_error_default( R5R'R_RRR^R(RetmethodRy((s/usr/lib64/python2.7/urllib.pyRms  cCs#|jtd|||fdS(s>Default error handler: close the connection and raise IOError.s http errorN(RDR2(R5R'R_RRR^((s/usr/lib64/python2.7/urllib.pyR|s cCs=ddl}d}d}t|trit|\}}|r`t|\}}t|}n|}n|\}}t|\}}t|\} } | }d}| jdkrd}nIt| \}} |rt|\}}n|r d| || f}n|st dn|rEt|}t j |j } nd} |rut|}t j |j } nd} |j |dd|jd |j} |dk r| jd || jd d | jd dt|n| jd|| r| jdd| n| r2| jdd| n|rK| jd|nx|jD]}| j|qUW| j|| j\}}}| j}|dkr|r|jnt dnd|kodknrt||d||S|dkr|j|||||S|j||||||SdS(sUse HTTPS protocol.iNthttpss %s://%s%ss https errors no host giveniR9R: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$RRRRRRRR2RRRtHTTPSR9R:RRRqR=RRRRDRRR(R5R'R(RRRRcRdRR`RRRRRIRRR^R_((s/usr/lib64/python2.7/urllib.pyt open_httpss|                 cCsut|tstd n|d dkrd|dd!dkrd|dd!jdkrd|j|S|j|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(RRR2Rtopen_ftpRP(R5R'((s/usr/lib64/python2.7/urllib.pyt open_files  < cCsddl}ddl}ddl}yddlm}Wn!tk r[ddlm}nXt|\}}t|}ytj |} Wn.t k r} t | j | j | jnX| j} |jj| jdt} |j|d} |j|d| p d| | f}|s|}|d d krFd |}n#|d d kritd |ntt|d||St|\}}| rtj|ttfkr|}|d d krd |}ntt|d||St ddS(sUse local file.iN(tStringIOtusegmtis6Content-Type: %s Content-Length: %d Last-modified: %s s text/plainiRsfile://is./sAlocal file url may start with / or file:. Unknown url of type: %sRLslocal file errorsnot on local host(slocal file errorsnot on local host(t mimetypest mimetoolst email.utilst cStringIORt ImportErrorRR R?tstatRFR2terrnotstrerrorR+tst_sizetutilst formatdatetst_mtimetTruet guess_typetMessaget ValueErrorRRR&RRYt gethostbynameRR(R5R'RRtemailRRcRGt localnametstatsteR{tmodifiedtmtypeR^turlfiletport((s/usr/lib64/python2.7/urllib.pyRPsD$      !  c Cst|tstdnddl}ddl}yddlm}Wn!tk rjddlm}nXt|\}}|stdnt |\}}t |\}}|rt |\}} nd} t |}|pd}| pd} tj|}|s%ddl} | j}n t|}t|\}} t |}|jd} | d | d} } | r| d  r| d } n| r| d  rd| d t __version__R<R3RERDR-RJR&RWRVR*RRRt _have_sslRRRPRR(((s/usr/lib64/python2.7/urllib.pyRts*       &  A I  H % >cBseZdZdZdZddZdZddZddZ ddZ ddZ dd Z dd Z dd Zdd Zdd ZddZdZRS(s?Derived class with handlers for errors we can handle (perhaps).cOs2tj|||i|_d|_d|_dS(Nii (RR3t auth_cachettriestmaxtries(R5RItkwargs((s/usr/lib64/python2.7/urllib.pyR3gs  cCst||d||S(s3Default error handling -- don't raise an exception.shttp:(RR(R5R'R_RRR^((s/usr/lib64/python2.7/urllib.pyRmsc Cs|jd7_|jrm|j|jkrmt|drE|j}n |j}d|_|||dd|S|j||||||}d|_|S(s%Error 302 -- relocated (temporarily).ithttp_error_500iis)Internal Server Error: Redirect Recursion(RRRURRtredirect_internal( R5R'R_RRR^R(tmethRy((s/usr/lib64/python2.7/urllib.pythttp_error_302qs       c Csd|kr|d}nd|kr2|d}ndS|jt|jd||}|j}|jdp|jdp|jdstd||d||n|j|S( Ntlocationturit:shttp://shttps://sftp://sredirect errors) - Redirection to url '%s' is not allowed(RDRRSRt startswithR2R&( R5R'R_RRR^R(tnewurlt newurl_lower((s/usr/lib64/python2.7/urllib.pyRs         cCs|j||||||S(s*Error 301 -- also relocated (permanently).(R(R5R'R_RRR^R(((s/usr/lib64/python2.7/urllib.pythttp_error_301scCs|j||||||S(s;Error 303 -- also relocated (essentially identical to 302).(R(R5R'R_RRR^R(((s/usr/lib64/python2.7/urllib.pythttp_error_303scCsE|dkr(|j||||||S|j|||||SdS(s1Error 307 -- relocated, but turn POST into error.N(R$RR(R5R'R_RRR^R(((s/usr/lib64/python2.7/urllib.pythttp_error_307s c Cs d|kr+tj||||||n|d}ddl}|jd|} | sxtj||||||n| j\} } | jdkrtj||||||nd|jd} |dkrt|| || St|| || |SdS(s_Error 401 -- authentication required. This function supports Basic authentication only.swww-authenticateiNs![ ]*([^ ]+)[ ]+realm="([^"]*)"tbasictretry_t _basic_auth( RRtretmatchtgroupsRRSR$RX( R5R'R_RRR^R(tstuffRRtschemetrealmRe((s/usr/lib64/python2.7/urllib.pythttp_error_401s"    c Cs d|kr+tj||||||n|d}ddl}|jd|} | sxtj||||||n| j\} } | jdkrtj||||||nd|jd} |dkrt|| || St|| || |SdS(seError 407 -- proxy authentication required. This function supports Basic authentication only.sproxy-authenticateiNs![ ]*([^ ]+)[ ]+realm="([^"]*)"Rt retry_proxy_R( RRRRRRRSR$RX( R5R'R_RRR^R(RRRRRRe((s/usr/lib64/python2.7/urllib.pythttp_error_407s"    cCs t|\}}d||}|jd}t|\}} t| \} } | jdd} | | } |j| || \} } | p| sdSt| dddt| ddd| } d| | |jd<|dkr|j|S|j||SdS(Nshttp://R~t@iRKRhR(RR"Rtfindtget_user_passwdR$RR&(R5R'RR(RcRdRRaR`Rbt proxyselectorRRR((s/usr/lib64/python2.7/urllib.pytretry_proxy_http_basic_auths   .  cCs t|\}}d||}|jd}t|\}} t| \} } | jdd} | | } |j| || \} } | p| sdSt| dddt| ddd| } d| | |jd<|dkr|j|S|j||SdS(Nshttps://RRiRKRhR(RR"RRRR$RR&(R5R'RR(RcRdRRaR`RbRRRR((s/usr/lib64/python2.7/urllib.pytretry_proxy_https_basic_auths   .  c Cst|\}}|jdd}||}|j|||\}}|pS|sZdSt|dddt|ddd|}d||} |dkr|j| S|j| |SdS(NRiRKRhRshttp://(RRRR$RR&( R5R'RR(RcRdRRRR((s/usr/lib64/python2.7/urllib.pytretry_http_basic_auths  .  c Cst|\}}|jdd}||}|j|||\}}|pS|sZdSt|dddt|ddd|}d||} |dkr|j| S|j| |SdS(NRiRKRhRshttps://(RRRR$RR&( R5R'RR(RcRdRRRR((s/usr/lib64/python2.7/urllib.pytretry_https_basic_auths  .  icCs|d|j}||jkrD|r6|j|=qD|j|Sn|j||\}}|sh|r~||f|j|st__iter__tnext(R_RptreadlineRUR8R9R;R<(R5R_((s/usr/lib64/python2.7/urllib.pyR3s  cCs d|jjt||jfS(Ns<%s at %r whose fp = %r>(t __class__R7tidR_(R5((s/usr/lib64/python2.7/urllib.pyt__repr__s cCsJd|_d|_d|_d|_|jr=|jjnd|_dS(N(R$RpR=R8R9R_RD(R5((s/usr/lib64/python2.7/urllib.pyRDs     (R7R8RR3R@RD(((s/usr/lib64/python2.7/urllib.pyR7s  R+cBs eZdZdZdZRS(s*Class to add a close hook to an open file.cGs&tj||||_||_dS(N(R7R3t closehookthookargs(R5R_RARB((s/usr/lib64/python2.7/urllib.pyR3s cCs?|jr.|j|jd|_d|_ntj|dS(N(RARBR$R7RD(R5((s/usr/lib64/python2.7/urllib.pyRDs    (R7R8RR3RD(((s/usr/lib64/python2.7/urllib.pyR+s taddinfocBs eZdZdZdZRS(s.class to add an info() method to an open file.cCstj||||_dS(N(R7R3R^(R5R_R^((s/usr/lib64/python2.7/urllib.pyR3scCs|jS(N(R^(R5((s/usr/lib64/python2.7/urllib.pyRis(R7R8RR3Ri(((s/usr/lib64/python2.7/urllib.pyRCs RRcBs5eZdZddZdZdZdZRS(s9class to add info() and geturl() methods to an open file.cCs/tj||||_||_||_dS(N(R7R3R^R'tcode(R5R_R^R'RD((s/usr/lib64/python2.7/urllib.pyR3s  cCs|jS(N(R^(R5((s/usr/lib64/python2.7/urllib.pyRiscCs|jS(N(RD(R5((s/usr/lib64/python2.7/urllib.pytgetcodescCs|jS(N(R'(R5((s/usr/lib64/python2.7/urllib.pytgeturlsN(R7R8RR$R3RiRERF(((s/usr/lib64/python2.7/urllib.pyRRs    cCsdS(Ni((tx((s/usr/lib64/python2.7/urllib.pyt _is_unicodescCs t|tS(N(Rtunicode(RG((s/usr/lib64/python2.7/urllib.pyRHscCsTt|rPy|jd}WqPtk rLtdt|dqPXn|S(stoBytes(u"URL") --> 'URL'.tASCIIsURL s contains non-ASCII characters(RHtencodet UnicodeErrortrepr(R'((s/usr/lib64/python2.7/urllib.pyRQs  cCsi|j}|d dkrB|ddkrB|dd!j}n|d dkre|dj}n|S(s8unwrap('') --> 'type://host/path'.itisURL:(R(R'((s/usr/lib64/python2.7/urllib.pyR!s   cCsvtdkr*ddl}|jdantj|}|rl|jd}|j|t|dfSd|fS(s:splittype('type:opaquestring') --> 'type', 'opaquestring'.iNs ^([^/:]+):i(t _typeprogR$RtcompileRtgroupRRq(R'RRR((s/usr/lib64/python2.7/urllib.pyR*s  cCstdkr$tjdtjantj|}|r|jd}|jd}|rz|jd rzd|}n||fSd|fS(s;splithost('//host[:port]/path') --> 'host[:port]', '/path'.s//([^/#?]*)(.*)iiRN(t _hostprogR$RRQtDOTALLRRRR(R'Rt host_portRk((s/usr/lib64/python2.7/urllib.pyR8s   cCsYtdkr*ddl}|jdantj|}|rO|jddSd|fS(sJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.iNs ^(.*)@(.*)$ii(t _userprogR$RRQRRR(RcRR((s/usr/lib64/python2.7/urllib.pyRHs  cCs_tdkr0ddl}|jd|jantj|}|rU|jddS|dfS(s/splitpasswd('user:passwd') -> 'user', 'passwd'.iNs^([^:]*):(.*)$ii(t _passwdprogR$RRQtSRRR(RRR((s/usr/lib64/python2.7/urllib.pyRTs  cCsYtdkr*ddl}|jdantj|}|rO|jddS|dfS(s*splitport('host:port') --> 'host', 'port'.iNs^(.*):([0-9]+)$ii(t _portprogR$RRQRRR(RcRR((s/usr/lib64/python2.7/urllib.pyRas  cCstdkr*ddl}|jdantj|}|r|jdd\}}y"|sltdnt|}Wntk rd}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$RRQRRRRRo(RctdefportRRRtnport((s/usr/lib64/python2.7/urllib.pyRms      cCsYtdkr*ddl}|jdantj|}|rO|jddS|dfS(s/splitquery('/path?query') --> '/path', 'query'.iNs^(.*)\?([^?]*)$ii(t _queryprogR$RRQRRR(R'RR((s/usr/lib64/python2.7/urllib.pyRs  cCsYtdkr*ddl}|jdantj|}|rO|jddS|dfS(s)splittag('/path#tag') --> '/path', 'tag'.iNs^(.*)#([^#]*)$ii(t_tagprogR$RRQRRR(R'RR((s/usr/lib64/python2.7/urllib.pyR s  cCs!|jd}|d|dfS(sksplitattr('/path;attr1=value1;attr2=value2;...') -> '/path', ['attr1=value1', 'attr2=value2', ...].Rii(R(R'twords((s/usr/lib64/python2.7/urllib.pyRscCsYtdkr*ddl}|jdantj|}|rO|jddS|dfS(s-splitvalue('attr=value') --> 'attr', 'value'.iNs^([^=]*)=(.*)$ii(t _valueprogR$RRQRRR(RRR((s/usr/lib64/python2.7/urllib.pyRs  t0123456789ABCDEFabcdefccs?|]5}tD](}||tt||dfVq qdS(iN(t_hexdigtchrRo(t.0Rtb((s/usr/lib64/python2.7/urllib.pys ss([-]+)cCsOt|rd|kr|Stj|}|dg}|j}xUtdt|dD];}|tt||jd|||dqZWdj |S|jd}t|dkr|S|dg}|j}x^|dD]R}y$|t |d ||dWqt k r=|d||qXqWdj |S(s"unquote('abc%20def') -> 'abc def'.t%iiitlatin1Rh( RHt_asciireRRHtrangeRqRRtdecodeRt _hextochrtKeyError(tstbitstresRHRtitem((s/usr/lib64/python2.7/urllib.pyRs.    #     cCs|jdd}t|S(s%unquote('%7e/abc+def') -> '~/abc def't+t (RTR(Rm((s/usr/lib64/python2.7/urllib.pyR ssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-iis%{:02X}RcCs|s%|dkr!tdn|S|tf}yt|\}}Wnftk rtj}|jg|D]}||f^qn|j}t|}||ft| '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. sNone object cannot be quotedRhN( R$t TypeErrort always_safeR.Rlt _safe_maptcopytupdatet __getitem__trstripRtmap(RmRKtcachekeytquotertsafe_maptc((s/usr/lib64/python2.7/urllib.pyRs     &  RhcCs<d|kr/t||d}|jddSt||S(s9Quote the query fragment of a URL; replacing ' ' with '+'RrRq(RRT(RmRK((s/usr/lib64/python2.7/urllib.pyRs ic Cst|dr|j}nby-t|rJt|dt rJtnWn2tk rtj\}}}td|nXg}|sxc|D]E\}}tt |}tt |}|j |d|qWnx|D]\}}tt |}t|t r7t|}|j |d|qt |rst|j dd}|j |d|qyt|Wn8tk rtt |}|j |d|qXx/|D]'}|j |dtt |qWqWdj |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 objectRRJRTt&(RURRqRttupleRsR[R\RRRHRHRKR( tquerytdoseqttytvattbtlRRtelt((s/usr/lib64/python2.7/urllib.pyR s<        )cCsi}xPtjjD]?\}}|j}|r|ddkr|||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_METHODR~N(R?tenvironRRtpopR$(R"ReR((s/usr/lib64/python2.7/urllib.pytgetproxies_environmentLs  cCstjjddp'tjjdd}|dkr:dSt|\}}g|jdD]}|j^q\}x6|D].}|r{|j|s|j|r{dSq{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_proxyRhtNO_PROXYt*iRi(R?RR;RRRtendswith(RcRthostonlyRRat no_proxy_listRe((s/usr/lib64/python2.7/urllib.pytproxy_bypass_environmentes* ( $tdarwin(t_get_proxy_settingst _get_proxiesc Csddl}ddl}ddlm}t|\}}d}t}d|kri|dritSnd}x'|jdd D]} | sqn|jd| } | dk r|dkry|j |}||}Wq|j k rqqXn|| j d } | j d } | dkrMd | j d j dd } nt | d } d | } || ?| | ?krtSq||| rtSqWtS(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(tfnmatchcSsy|jd}tt|}t|dkrM|ddddgd }n|dd>|dd>B|dd>B|d BS( Nt.iiiiiiii(RRzRoRq(tipAddrtparts((s/usr/lib64/python2.7/urllib.pytip2nums Rtexclude_simplet exceptionss(\d+(?:\.\d+)*)(/\d+)?iiii ((RRYRRRRR$R;RRRZRRtcountRoR4( RcRRYRRRRtproxy_settingsthostIPRtmtbasetmask((s/usr/lib64/python2.7/urllib.pytproxy_bypass_macosx_sysconf}s@          # 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.7/urllib.pytgetproxies_macosx_sysconfscCs!trt|St|SdS(N(RRR(Rc((s/usr/lib64/python2.7/urllib.pyRs  cCstptS(N(RR(((s/usr/lib64/python2.7/urllib.pyRsc Csmi}yddl}Wntk r*|SXy!|j|jd}|j|dd}|rAt|j|dd}d|krx|jdD]Y}|jdd \}}ddl}|jd |sd ||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://%ss https://%sRsftp://%sR( t_winregRtOpenKeytHKEY_CURRENT_USERt QueryValueExRRRRtCloset WindowsErrorRRs( R"RtinternetSettingst proxyEnablet proxyServertptprotocoltaddressR((s/usr/lib64/python2.7/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.7/urllib.pyRsc Csyddl}ddl}Wntk r0dSXyK|j|jd}|j|dd}t|j|dd}Wntk rdSX| s| rdSt|\}}|g}y/t j |}||kr|j |nWnt j k rnXy/t j |} | |kr2|j | nWnt j k rInX|jd}x|D]} | dkrd|krd Sn| jdd } | jd d } | jd d} x*|D]"} |j| | |jrd SqWq`WdS(Niis;Software\Microsoft\Windows\CurrentVersion\Internet SettingsRt ProxyOverrideRsRis\.Rs.*t?(RRRRRRRRRRYRRHRZtgetfqdnRRTRR( RcRRRRt proxyOverridetrawHostRtaddrtfqdnttesttval((s/usr/lib64/python2.7/urllib.pytproxy_bypass_registrysT                cCs!trt|St|SdS(sReturn a dictionary of scheme -> proxy server URL mappings. Returns settings gathered from the environment, if specified, or the registry. N(RRR(Rc((s/usr/lib64/python2.7/urllib.pyR5s  cCsd}x$tdD]}|t|}qW|d}tj}t|}t|}tj}||kr{dGHnt|GHt|GHt|GHt||dGdGHdS(NRhiisWrong!itsec(RiRcRRRRMtround(RmRtt0tqstuqstt1((s/usr/lib64/python2.7/urllib.pyttest1Gs         cCsd|||fGHdS(Ns0Block number: %d, Block size: %d, Total size: %d((R|t blocksizet totalsize((s/usr/lib64/python2.7/urllib.pyR,Ws(hRtstringRYR?RR[RRturlparseRRt__all__RRRet nturl2pathR R t rourl2pathR$R%RRRtsslR4RRR2R1R0RRRRRRRRRRRR7R+RCRRRIt NameErrorRHRQRRPRRSRRVRRWRRYRRZRR]RR^R RR`RRbtdictRkRQRhRR RtRutziptxrangeRt bytearrayRR~tformatR.RRR RRtplatformt_scproxyRRRRRRRRRR,(((s/usr/lib64/python2.7/urllib.pyts                   _ "                 45 '  @   ;    . 4