^Rc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZyddlmZWn!ek rddlmZnXddlmZmZmZmZmZmZmZmZmZmZmZmZmZm Z ddlm!Z!m"Z"m#Z#m$Z$e j%d Z&da(de j)dZ*dZ+d e,fd YZ-d e-efd YZ.ej/d Z0dZ1ddDdYZ2ddEdYZ3dZ4ddFdYZ5de5fdYZ6de5fdYZ7de5fdYZ8dZ9de5fdYZ:ddGd YZ;d!e;fd"YZ<d#dHd$YZ=d%e=e5fd&YZ>d'e=e5fd(YZ?d)Z@d*dId+YZAd,e5eAfd-YZBd.e5eAfd/YZCd0e5fd1YZDd2eDfd3YZEeFed4rd5eDfd6YZGnd7e5fd8YZHd9e5fd:YZId;ZJd<ZKd=ZLd>e5fd?YZMd@e5fdAYZNdBeNfdCYZOdS(Js! An extensible library for opening URLs using a variety of protocols The simplest way to use this module is to call the urlopen function, which accepts a string containing a URL or a Request object (described below). It opens the URL and returns the results as file-like object; the returned object has some extra methods described below. The OpenerDirector manages a collection of Handler objects that do all the actual work. Each Handler implements a particular protocol or option. The OpenerDirector is a composite object that invokes the Handlers needed to open the requested URL. For example, the HTTPHandler performs HTTP GET and POST requests and deals with non-error returns. The HTTPRedirectHandler automatically deals with HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler deals with digest authentication. urlopen(url, data=None) -- Basic usage is the same as original urllib. pass the url and optionally data to post to an HTTP URL, and get a file-like object back. One difference is that you can also pass a Request instance instead of URL. Raises a URLError (subclass of IOError); for HTTP errors, raises an HTTPError, which can also be treated as a valid response. build_opener -- Function that creates a new OpenerDirector instance. Will install the default handlers. Accepts one or more Handlers as arguments, either instances or Handler classes that it will instantiate. If one of the argument is a subclass of the default handler, the argument will be installed instead of the default. install_opener -- Installs a new opener as the default opener. objects of interest: OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages the Handler classes, while dealing with requests and responses. Request -- An object that encapsulates the state of a request. The state can be as simple as the URL. It can also include extra HTTP headers, e.g. a User-Agent. BaseHandler -- exceptions: URLError -- A subclass of IOError, individual protocols have their own specific subclass. HTTPError -- Also a valid HTTP response, so you can treat an HTTP error as an exceptional event or valid response. internals: BaseHandler and parent _call_chain conventions Example usage: import urllib2 # set up authentication info authinfo = urllib2.HTTPBasicAuthHandler() authinfo.add_password(realm='PDQ Application', uri='https://mahler:8092/site-updates.py', user='klem', passwd='geheim$parole') proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"}) # build a new opener that adds authentication and caching FTP handlers opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler) # install it urllib2.install_opener(opener) f = urllib2.urlopen('http://www.python.org/') iN(tStringIO(tunwraptunquotet splittypet splithosttquotet addinfourlt splitporttsplittagttoBytest splitattrt ftpwrappert splitusert splitpasswdt splitvalue(t localhostt url2pathnamet getproxiest proxy_bypassicCs+tdkrtantj|||S(N(t_openertNonet build_openertopen(turltdatattimeout((s/usr/lib/python2.7/urllib2.pyturlopen{s  cCs |adS(N(R(topener((s/usr/lib/python2.7/urllib2.pytinstall_openerstURLErrorcBseZdZdZRS(cCs|f|_||_dS(N(targstreason(tselfR((s/usr/lib/python2.7/urllib2.pyt__init__s cCs d|jS(Ns(R(R ((s/usr/lib/python2.7/urllib2.pyt__str__s(t__name__t __module__R!R"(((s/usr/lib/python2.7/urllib2.pyRs t HTTPErrorcBsAeZdZejZdZdZedZdZ RS(sBRaised when HTTP error occurs, but also acts like non-error returncCsV||_||_||_||_||_|dk rR|j||||ndS(N(tcodetmsgthdrstfptfilenameRt_HTTPError__super_init(R RR&R'R(R)((s/usr/lib/python2.7/urllib2.pyR!s      cCsd|j|jfS(NsHTTP Error %s: %s(R&R'(R ((s/usr/lib/python2.7/urllib2.pyR"scCs|jS(N(R'(R ((s/usr/lib/python2.7/urllib2.pyRscCs|jS(N(R((R ((s/usr/lib/python2.7/urllib2.pytinfos( R#R$t__doc__RR!R+R"tpropertyRR,(((s/usr/lib/python2.7/urllib2.pyR%s   s:\d+$cCs_|j}tj|d}|dkr@|jdd}ntjd|d}|jS(sReturn request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison. ittHost(t get_full_urlturlparset get_headert _cut_port_retsubtlower(trequestRthost((s/usr/lib/python2.7/urllib2.pyt request_hosts   tRequestcBseZdidedZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZddZdZRS(cCst||_t|j\|_|_d|_d|_d|_d|_||_ i|_ x*|j D]\}}|j ||qmWi|_ |dkrt|}n||_||_dS(N(Rt_Request__originalRt_Request__fragmentRttypeR8tportt _tunnel_hostRtheaderstitemst add_headertunredirected_hdrsR9torigin_req_hostt unverifiable(R RRR@RDREtkeytvalue((s/usr/lib/python2.7/urllib2.pyR!s         cCs^|d dkrQ|d}ttd|rQt|d|t||Snt|dS(Ni t _Request__r_tget_(thasattrR:tgetattrtAttributeError(R tattrtname((s/usr/lib/python2.7/urllib2.pyt __getattr__s  cCs|jrdSdSdS(NtPOSTtGET(thas_data(R ((s/usr/lib/python2.7/urllib2.pyt get_methods cCs ||_dS(N(R(R R((s/usr/lib/python2.7/urllib2.pytadd_datascCs |jdk S(N(RR(R ((s/usr/lib/python2.7/urllib2.pyRRscCs|jS(N(R(R ((s/usr/lib/python2.7/urllib2.pytget_datascCs(|jrd|j|jfS|jSdS(Ns%s#%s(R<R;(R ((s/usr/lib/python2.7/urllib2.pyR1s cCsV|jdkrOt|j\|_|_|jdkrOtd|jqOn|jS(Nsunknown url type: %s(R=RRR;t_Request__r_typet ValueError(R ((s/usr/lib/python2.7/urllib2.pytget_types cCsR|jdkrKt|j\|_|_|jrKt|j|_qKn|jS(N(R8RRRVt_Request__r_hostR(R ((s/usr/lib/python2.7/urllib2.pytget_hosts  cCs|jS(N(RY(R ((s/usr/lib/python2.7/urllib2.pyt get_selector scCsJ|jdkr(|j r(|j|_n||_|j|_||_dS(Nthttps(R=R?R8R;RY(R R8R=((s/usr/lib/python2.7/urllib2.pyt set_proxys   cCs|j|jkS(N(RYR;(R ((s/usr/lib/python2.7/urllib2.pyt has_proxyscCs|jS(N(RD(R ((s/usr/lib/python2.7/urllib2.pytget_origin_req_hostscCs|jS(N(RE(R ((s/usr/lib/python2.7/urllib2.pytis_unverifiablescCs||j|j1s R@RDREN(i-i.i/i3(sGETR(i-i.i/( RStreplaceRR@RAR:R_RR%R1( R RR)R&R'R@tnewurltmt newheaders((s/usr/lib/python2.7/urllib2.pyRvs   c Csd|kr"|jdd}n&d|krD|jdd}ndStj|}|jsyt|}d|d>> _parse_proxy('file:/ftp.example.com/') Traceback (most recent call last): ValueError: proxy URL with no authority: 'file:/ftp.example.com/' The first three items of the returned tuple may be None. Examples of authority parsing: >>> _parse_proxy('proxy.example.com') (None, None, None, 'proxy.example.com') >>> _parse_proxy('proxy.example.com:3128') (None, None, None, 'proxy.example.com:3128') The authority component may optionally include userinfo (assumed to be username:password): >>> _parse_proxy('joe:password@proxy.example.com') (None, 'joe', 'password', 'proxy.example.com') >>> _parse_proxy('joe:password@proxy.example.com:3128') (None, 'joe', 'password', 'proxy.example.com:3128') Same examples, but with URLs instead: >>> _parse_proxy('http://proxy.example.com/') ('http', None, None, 'proxy.example.com') >>> _parse_proxy('http://proxy.example.com:3128/') ('http', None, None, 'proxy.example.com:3128') >>> _parse_proxy('http://joe:password@proxy.example.com/') ('http', 'joe', 'password', 'proxy.example.com') >>> _parse_proxy('http://joe:password@proxy.example.com:3128') ('http', 'joe', 'password', 'proxy.example.com:3128') Everything after the authority is ignored: >>> _parse_proxy('ftp://joe:password@proxy.example.com/rubbish:3128') ('ftp', 'joe', 'password', 'proxy.example.com') Test for no trailing '/' case: >>> _parse_proxy('http://joe:password@proxy.example.com') ('http', 'joe', 'password', 'proxy.example.com') Rs//sproxy URL with no authority: %riiN(RRRRWR~R R ( tproxytschemetr_schemet authoritytendtuserinfothostporttusertpassword((s/usr/lib/python2.7/urllib2.pyt _parse_proxy~s2      RcBs#eZdZddZdZRS(idcCs|dkrt}nt|ds3td||_x=|jD]/\}}t|d||||jdqIWdS(Nthas_keysproxies must be a mappings%s_opencSs||||S(N((trRR=R((s/usr/lib/python2.7/urllib2.pyts(RRRJtAssertionErrortproxiesRAtsetattrRx(R RR=R((s/usr/lib/python2.7/urllib2.pyR!s    c Cs|j}t|\}}}}|dkr9|}n|j|jr_t|jr_dS|r|rdt|t|f} tj| j } |j dd| nt|}|j ||||ks|dkrdS|j j |d|jSdS(Ns%s:%ssProxy-authorizationsBasic R\R(RXRRRZR8RRtbase64t b64encodetstripRBR]RRR( R RRR=t orig_typet proxy_typeRRRt user_passtcreds((s/usr/lib/python2.7/urllib2.pyRxs       N(R#R$RRR!Rx(((s/usr/lib/python2.7/urllib2.pyRs tHTTPPasswordMgrcBs8eZdZdZdZedZdZRS(cCs i|_dS(N(tpasswd(R ((s/usr/lib/python2.7/urllib2.pyR!scCst|tr|g}n||jkr:i|j|tdport((s/usr/lib/python2.7/urllib2.pyR s        cCsi||krtS|d|dkr(tStj|d|df}t|t|dkretStS(scCheck if test is below base in a URI tree Both args must be URIs in reduced form. ii(RRkt posixpatht commonprefixR(R tbasettesttcommon((s/usr/lib/python2.7/urllib2.pyR $s (R#R$R!RRRRR (((s/usr/lib/python2.7/urllib2.pyRs   tHTTPPasswordMgrWithDefaultRealmcBseZdZRS(cCsDtj|||\}}|dk r1||fStj|d|S(N(RRR(R RR RR((s/usr/lib/python2.7/urllib2.pyR5s    (R#R$R(((s/usr/lib/python2.7/urllib2.pyR3stAbstractBasicAuthHandlercBsDeZejdejZddZdZdZ dZ RS(s1(?:.*,)*[ ]*([^ ]+)[ ]+realm=(["']?)([^"']*)\2cCs=|dkrt}n||_|jj|_d|_dS(Ni(RRRRtretried(R t password_mgr((s/usr/lib/python2.7/urllib2.pyR!Ks    cCs d|_dS(Ni(R(R ((s/usr/lib/python2.7/urllib2.pytreset_retry_countRsc Cs|j|d}|jdkrBt|jdd|dn|jd7_|rtjj|}|r|j\}}}|d krt j dt dn|j d kr|j |||} | r| jdkrd |_n| SqndS( Niisbasic auth failedit"t'sBasic Auth Realm was unquoteditbasici(RR(RfRRR%R1Rtrxtsearchtgroupstwarningstwarnt UserWarningR6tretry_http_basic_authR&( R tauthreqR8RR@tmoRRRR{((s/usr/lib/python2.7/urllib2.pythttp_error_auth_reqedUs"    cCs|jj||\}}|dk rd||f}dtj|j}|jj|jd|krrdS|j |j||j j |d|j SdSdS(Ns%s:%ssBasic %sR( RRRRRRR@Rft auth_headerRcRRR(R R8RRRtpwtrawtauth((s/usr/lib/python2.7/urllib2.pyR&os N( R#R$tretcompiletIR RR!RR)R&(((s/usr/lib/python2.7/urllib2.pyR=s      tHTTPBasicAuthHandlercBseZdZdZRS(t AuthorizationcCs2|j}|jd|||}|j|S(Nswww-authenticate(R1R)R(R RR)R&R'R@RR{((s/usr/lib/python2.7/urllib2.pythttp_error_401s    (R#R$R*R3(((s/usr/lib/python2.7/urllib2.pyR1|stProxyBasicAuthHandlercBseZdZdZRS(sProxy-authorizationcCs2|j}|jd|||}|j|S(Nsproxy-authenticate(RZR)R(R RR)R&R'R@RR{((s/usr/lib/python2.7/urllib2.pythttp_error_407s    (R#R$R*R5(((s/usr/lib/python2.7/urllib2.pyR4scCs}tjjdr;td}|j|}|j|Sgt|D]}ttj dd^qH}dj |SdS(sReturn n random bytes.s /dev/urandomiiR/N( tosRtexistsRRRtrangetchrtrandomt randrangetjoin(tntftsRtL((s/usr/lib/python2.7/urllib2.pyt randombytess  1tAbstractDigestAuthHandlercBsSeZddZdZdZdZdZdZdZ dZ RS( cCsO|dkrt}n||_|jj|_d|_d|_d|_dS(Ni(RRRRRt nonce_countt last_nonce(R R((s/usr/lib/python2.7/urllib2.pyR!s     cCs d|_dS(Ni(R(R ((s/usr/lib/python2.7/urllib2.pyRscCs|j|d}|jdkrBt|jdd|dn|jd7_|r|jd}|jdkr|j||SndS(Niisdigest auth failediitdigest(RfRRR%R1tsplitR6tretry_http_digest_auth(R R*R8RR@R'R((s/usr/lib/python2.7/urllib2.pyR)scCs|jdd\}}tt|}|j||}|rd|}|jj|jd|krndS|j|j||j j |d|j }|SdS(NRis Digest %sR( RFtparse_keqv_listtparse_http_listtget_authorizationR@RfR*RRcRRR(R RR-ttokent challengetchaltauth_valtresp((s/usr/lib/python2.7/urllib2.pyRGs cCs<tjd|j|tjtdfj}|d S(Ns %s:%s:%s:%sii(thashlibtsha1RCttimetctimeRAt hexdigest(R tnoncetdig((s/usr/lib/python2.7/urllib2.pyt get_cnoncescCsdyK|d}|d}|jd}|jdd}|jdd}Wntk r_dSX|j|\}} |dkrdS|jj||j\} } | dkrdS|jr|j|j |} nd} d| || f} d|j |j f}|d kr||j kr?|j d 7_ nd |_ ||_ d |j }|j|}d ||||||f}| || |}nD|dkr| || d|||f}ntd |d| |||j |f}|r|d|7}n| r5|d| 7}n|d|7}|r`|d||f7}n|S(NRRUtqopt algorithmtMD5topaques%s:%s:%ss%s:%sR-is%08xs%s:%s:%s:%s:%ssqop '%s' is not supported.s>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"s , opaque="%s"s , digest="%s"s, algorithm="%s"s, qop=auth, nc=%s, cnonce="%s"(RfRtKeyErrortget_algorithm_implsRRR1RRtget_entity_digestRURSR[RDRCRWR(R RRMRRURXRYR[tHtKDRR+tentdigtA1tA2tncvaluetcnoncetnoncebittrespdigR((s/usr/lib/python2.7/urllib2.pyRJsV    !        ( csU|j}|dkr$dn|dkr<dnfd}|fS(NRZcSstj|jS(N(RPtmd5RT(tx((s/usr/lib/python2.7/urllib2.pyR&stSHAcSstj|jS(N(RPRQRT(Ri((s/usr/lib/python2.7/urllib2.pyR(scsd||fS(Ns%s:%s((R?td(R_(s/usr/lib/python2.7/urllib2.pyR*s(tupper(R RYR`((R_s/usr/lib/python2.7/urllib2.pyR]!s     cCsdS(N(R(R RRM((s/usr/lib/python2.7/urllib2.pyR^-sN( R#R$RR!RR)RGRWRJR]R^(((s/usr/lib/python2.7/urllib2.pyRBs   = tHTTPDigestAuthHandlercBs#eZdZdZdZdZRS(sAn authentication protocol defined by RFC 2069 Digest authentication improves on basic authentication because it does not transmit passwords in the clear. R2icCs?tj|jd}|jd|||}|j|S(Niswww-authenticate(R2R1R)R(R RR)R&R'R@R8tretry((s/usr/lib/python2.7/urllib2.pyR3<s   (R#R$R-R*RR3(((s/usr/lib/python2.7/urllib2.pyRm2stProxyDigestAuthHandlercBseZdZdZdZRS(sProxy-AuthorizationicCs2|j}|jd|||}|j|S(Nsproxy-authenticate(RZR)R(R RR)R&R'R@R8Rn((s/usr/lib/python2.7/urllib2.pyR5Is    (R#R$R*RR5(((s/usr/lib/python2.7/urllib2.pyRoDstAbstractHTTPHandlercBs/eZddZdZdZdZRS(icCs ||_dS(N(t _debuglevel(R t debuglevel((s/usr/lib/python2.7/urllib2.pyR!RscCs ||_dS(N(Rq(R tlevel((s/usr/lib/python2.7/urllib2.pytset_http_debuglevelUsc Cs:|j}|s!tdn|jr|j}|jds[|jddn|jds|jddt|qn|}|jrt|j \}}t |\}}n|jds|jd|nxH|j j D]:\}} |j }|j|s|j|| qqW|S(Ns no host givens Content-types!application/x-www-form-urlencodedsContent-lengths%dR0(RZRRRRUReRcRR^RR[RRRnRa( R R7R8Rtsel_hostRtseltsel_pathRNRG((s/usr/lib/python2.7/urllib2.pyt do_request_Xs.      c s|j}|s!tdn||d|j}|j|jt|jjtfd|jj Ddds Rt Connectioncss'|]\}}|j|fVqdS(N(ttitle(RRNRb((s/usr/lib/python2.7/urllib2.pys ssProxy-AuthorizationR@t buffering(RZRRtset_debuglevelRqRRCRiR@RAR?t set_tunnelR7RSR[RRRzRt getresponseRR|Rtrecvt _fileobjectRR'R1tstatusR&R( R t http_classRR8Rttunnel_headerstproxy_auth_hdrterrRR)RO((R@s/usr/lib/python2.7/urllib2.pyRwus@ ,    )     (R#R$R!RtRxRw(((s/usr/lib/python2.7/urllib2.pyRpPs   RcBseZdZejZRS(cCs|jtj|S(N(RwRtHTTPConnection(R R((s/usr/lib/python2.7/urllib2.pyt http_opens(R#R$RRpRxt http_request(((s/usr/lib/python2.7/urllib2.pyRs RRcBseZdZejZRS(cCs|jtj|S(N(RwRtHTTPSConnection(R R((s/usr/lib/python2.7/urllib2.pyt https_opens(R#R$RRpRxt https_request(((s/usr/lib/python2.7/urllib2.pyRs tHTTPCookieProcessorcBs2eZddZdZdZeZeZRS(cCs4ddl}|dkr'|j}n||_dS(Ni(t cookielibRt CookieJart cookiejar(R RR((s/usr/lib/python2.7/urllib2.pyR!s  cCs|jj||S(N(Rtadd_cookie_header(R R7((s/usr/lib/python2.7/urllib2.pyRscCs|jj|||S(N(Rtextract_cookies(R R7R{((s/usr/lib/python2.7/urllib2.pyRsN(R#R$RR!RRRR(((s/usr/lib/python2.7/urllib2.pyRs    RcBseZdZRS(cCs |j}td|dS(Nsunknown url type: %s(RXR(R RR=((s/usr/lib/python2.7/urllib2.pyRs (R#R$R(((s/usr/lib/python2.7/urllib2.pyRscCsmi}x`|D]X}|jdd\}}|ddkr[|ddkr[|dd!}n|||Parse list of key=value strings where keys are not duplicated.t=iiRi(RF(tltparsedteltRR((s/usr/lib/python2.7/urllib2.pyRHs  cCsg}d}t}}x|D]}|r?||7}t}qn|r|dkr]t}qn|dkrrt}n||7}qn|dkr|j|d}qn|dkrt}n||7}qW|r|j|ng|D]}|j^qS(spParse lists as described by RFC 2068 Section 2. In particular, parse comma-separated lists where the elements of the list may include quoted-strings. A quoted-string could contain a comma. A non-quoted string could have quotes in the middle. Neither commas nor quotes count if they are escaped. Only double-quotes count, not single-quotes. R/s\Rt,(RkRRR(R?trestparttescapeRtcur((s/usr/lib/python2.7/urllib2.pyRIs4            cCs-ytj|SWntjk r(dSXdS(N(Rt gethostbynametgaierrorR(R8((s/usr/lib/python2.7/urllib2.pyt_safe_gethostbynamesRcBs)eZdZdZdZdZRS(cCsq|j}|d dkr`|dd!dkr`|jr`|jdkr`d|_|jj|S|j|SdS(Nis//iRRtftp(R[R8R=RRtopen_local_file(R RR((s/usr/lib/python2.7/urllib2.pyt file_open s  , cCs|tjdkruy7ttjddtjtjdt_Wqutjk rqtjdft_quXntjS(NRi( RtnamesRRRtgethostbyname_ext gethostnameRR(R ((s/usr/lib/python2.7/urllib2.pyt get_names+s$cCs[ddl}ddl}|j}|j}t|}ytj|}|j}|jj |j dt } |j |d} t jtd| pd|| f} |rt|\}} n| s| r(t||jkr(|rd||} n d|} tt|d| | SWntk rJ}t|nXtddS( Nitusegmtis6Content-type: %s Content-length: %d Last-modified: %s s text/plainsfile://trbsfile not on local host(t email.utilst mimetypesRZR[RR6tstattst_sizetutilst formatdatetst_mtimeRt guess_typet mimetoolstMessageRRRRRRtOSErrorR(R RtemailRR8R*t localfiletstatstsizetmodifiedtmtypeR@R>torigurlR'((s/usr/lib/python2.7/urllib2.pyR6s0        N(R#R$RRRRR(((s/usr/lib/python2.7/urllib2.pyRs  RcBseZdZdZRS(cCsddl}ddl}|j}|s9tdnt|\}}|dkrc|j}n t|}t|\}}|rt |\}}nd}t |}|pd}|pd}yt j |}Wn"t j k r}t|nXt|j\} } | jd} tt | } | d | d} } | rg| d rg| d} ny/|j||||| |j} | rdpd}xM| D]E}t|\}}|jd kr|dkr|j}qqW| j| |\}}d}|j|jd}|r;|d|7}n|dk rd|dkrd|d|7}nt|}tj|}t|||jSWn0|jk r}td|tj dnXdS(Nisftp error: no host givenR/RiiR0tDR=tatARRksContent-type: %s sContent-length: %d s ftp error: %si(RRRR0RkR(!tftplibRRZRRRtFTP_PORTRR R RRRRzR R[RFtmapt connect_ftpRRR6RltretrfileRR1RRRRt all_errorstsystexc_info(R RRRR8R>RRR'RtattrstdirstfiletfwR=RMRGR)tretrlenR@Rtsf((s/usr/lib/python2.7/urllib2.pytftp_openSs\          !   c Cs%t||||||dt}|S(Nt persistent(R Rk(R RRR8R>RRR((s/usr/lib/python2.7/urllib2.pyRs (R#R$RR(((s/usr/lib/python2.7/urllib2.pyRRs 5tCacheFTPHandlercBs>eZdZdZdZdZdZdZRS(cCs1i|_i|_d|_d|_d|_dS(Nii<i(tcacheRtsoonesttdelayt max_conns(R ((s/usr/lib/python2.7/urllib2.pyR!s     cCs ||_dS(N(R(R tt((s/usr/lib/python2.7/urllib2.pyt setTimeoutscCs ||_dS(N(R(R R((s/usr/lib/python2.7/urllib2.pyt setMaxConnsscCs|||dj||f}||jkrJtj|j|j|RRRF((s/usr/lib/python2.7/urllib2.pyRs" cCstj}|j|krrxT|jjD]@\}}||kr+|j|j|j|=|j|=q+q+Wnt|jj|_t|j|j krxD|jjD]3\}}||jkr|j|=|j|=PqqWt|jj|_ndS(N( RRRRRARRtmintvaluesRR(R RRR((s/usr/lib/python2.7/urllib2.pyRs     cCsBx!|jjD]}|jqW|jj|jjdS(N(RRRtclearR(R tconn((s/usr/lib/python2.7/urllib2.pyt clear_caches (R#R$R!RRRRR(((s/usr/lib/python2.7/urllib2.pyRs     (((((((PR-RRPRRR6RR:R.RRRRR2RR#t cStringIORt ImportErrorturllibRRRRRRRRR R R R R RRRRRtversionRmRRRRRtIOErrorRR%R/R4R9R:RlRRRRRRRRRRR1R4RARBRmRoRpRRJRRRRHRIRRRR(((s/usr/lib/python2.7/urllib2.pytLst               ^"    r 'i H-@ ?   m + 4<