python (3.12.0)

(root)/
lib/
python3.12/
urllib/
__pycache__/
request.cpython-312.pyc

̑edZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*	ddl+Z+dZ,gdZ.d	ej^dd
zZ0da1de
jdfddddddZ3d
Z4gZ5dfdZ6dZ7e	jpde	jrZ:dZ;GddZ<GddZ=dZ>GddZ?Gdde?Z@Gdde?ZAGdde?ZBdZCGd d!e?ZDGd"d#ZEGd$d%eEZFGd&d'eFZGGd(d)ZHGd*d+eHe?ZIGd,d-eHe?ZJejZLGd.d/ZMGd0d1e?eMZNGd2d3e?eMZOGd4d5e?ZPGd6d7ePZQeRejd8rGd9d:ePZTe.jd:Gd;d<e?ZVGd=d>e?ZWd?ZXd@ZYGdAdBe?ZZdCZ[GdDdEe?Z\GdFdGe\Z]GdHdIe?Z^dJZ_ejdKk(r	ddLlambZbmcZcndMZbdNZciZdGdOdPZeGdQdReeZfdagdSZhdaidTZjdakdUZldamdVZnGdWdXZodYZpdgdZZqd[Zrejd\k(rdd]ltmuZumvZvd^Zwd_Zxd`ZydaZzyejdKk(r
dbZ{dcZzddZ|deZyyepZzeqZyy#e-$rdZ,YXwxYw)ha
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, 307, and 308 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
OSError); 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 --

internals:
BaseHandler and parent
_call_chain conventions

Example usage:

import urllib.request

# set up authentication info
authinfo = urllib.request.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='geheim$parole')

proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})

# build a new opener that adds authentication and caching FTP handlers
opener = urllib.request.build_opener(proxy_support, authinfo,
                                     urllib.request.CacheFTPHandler)

# install it
urllib.request.install_opener(opener)

f = urllib.request.urlopen('https://www.python.org/')
N)URLError	HTTPErrorContentTooShortError)urlparseurlspliturljoinunwrapquoteunquote
_splittype
_splithost
_splitport
_splituser_splitpasswd
_splitattr_splitquery_splitvalue	_splittag	_to_bytesunquote_to_bytes
urlunparse)
addinfourladdclosehookTF)!RequestOpenerDirectorBaseHandlerHTTPDefaultErrorHandlerHTTPRedirectHandlerHTTPCookieProcessorProxyHandlerHTTPPasswordMgrHTTPPasswordMgrWithDefaultRealmHTTPPasswordMgrWithPriorAuthAbstractBasicAuthHandlerHTTPBasicAuthHandlerProxyBasicAuthHandlerAbstractDigestAuthHandlerHTTPDigestAuthHandlerProxyDigestAuthHandlerHTTPHandlerFileHandler
FTPHandlerCacheFTPHandlerDataHandlerUnknownHandlerHTTPErrorProcessorurlopeninstall_openerbuild_openerpathname2urlurl2pathname
getproxiesurlretrieve
urlcleanup	URLopenerFancyURLopenerz%d.%d)cafilecapath	cadefaultcontextc|s|s|rddl}|jdtd|tdtstdtjt
jj||}|jdgt|	}t|}	n3|rt|	}t|}	nt
txa}	nt}	|	j|||S)
aOpen the URL url, which can be either a string or a Request object.

    *data* must be an object specifying additional data to be sent to
    the server, or None if no such data is needed.  See Request for
    details.

    urllib.request module uses HTTP/1.1 and includes a "Connection:close"
    header in its HTTP requests.

    The optional *timeout* parameter specifies a timeout in seconds for
    blocking operations like the connection attempt (if not specified, the
    global default timeout setting will be used). This only works for HTTP,
    HTTPS and FTP connections.

    If *context* is specified, it must be a ssl.SSLContext instance describing
    the various SSL options. See HTTPSConnection for more details.

    The optional *cafile* and *capath* parameters specify a set of trusted CA
    certificates for HTTPS requests. cafile should point to a single file
    containing a bundle of CA certificates, whereas capath should point to a
    directory of hashed certificate files. More information can be found in
    ssl.SSLContext.load_verify_locations().

    The *cadefault* parameter is ignored.


    This function always returns an object which can work as a
    context manager and has the properties url, headers, and status.
    See urllib.response.addinfourl for more detail on these properties.

    For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse
    object slightly modified. In addition to the three new methods above, the
    msg attribute contains the same information as the reason attribute ---
    the reason phrase returned by the server --- instead of the response
    headers as it is specified in the documentation for HTTPResponse.

    For FTP, file, and data URLs and requests explicitly handled by legacy
    URLopener and FancyURLopener classes, this function returns a
    urllib.response.addinfourl object.

    Note that None may be returned if no handler handles the request (though
    the default installed global OpenerDirector uses UnknownHandler to ensure
    this never happens).

    In addition, if proxy settings are detected (for example, when a *_proxy
    environment variable like http_proxy is set), ProxyHandler is default
    installed and makes sure the requests are handled through the proxy.

    rNzJcafile, capath and cadefault are deprecated, use a custom context instead.r;zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r<r=zhttp/1.1r?)warningswarnDeprecationWarning
ValueError	_have_sslsslcreate_default_contextPurposeSERVER_AUTHset_alpn_protocolsHTTPSHandlerr3_openeropen)
urldatatimeoutr<r=r>r?rB
https_handleropeners
          B/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/urllib/request.pyr1r1sh9

01CQ	H
899,,S[[-D-D4:4:<	""J<0$W5
m,	$W5
m,	'>)&;;sD'**c|ayN)rM)rSs rTr2r2sGrUct|\}}tjt||5}|j	}|dk(r,|s*t
jj||fcdddS|r
t|d}n7tjd}|j}tj||5||f}	d}
d}d}d}
d	|vrt|d
}|r
||
|
||j|
x}rD|t!|z
}|j#||
dz
}
|r
||
|
||j|
x}rDdddddddk\r|krt%d||fz		S#1swY.xYw#1swY2xYw)
aW
    Retrieve a URL into a temporary location on disk.

    Requires a URL argument. If a filename is passed, it is used as
    the temporary file location. The reporthook argument should be
    a callable that accepts a block number, a read size, and the
    total file size of the URL target. The data argument should be
    valid URL encoded data.

    If a filename is passed and the URL points to a local resource,
    the result is a copy from local file to new file.

    Returns a tuple containing the path to the newly created
    data file as well as the resulting HTTPMessage object.
    fileNwbF)delete rcontent-lengthContent-Length1retrieval incomplete: got only %i out of %i bytes)r
contextlibclosingr1infoospathnormpathrNtempfileNamedTemporaryFilename_url_tempfilesappendintreadlenwriter)rOfilename
reporthookrPurl_typerffpheaderstfpresultbssizernblocknumblocks               rTr7r7s  _NHd			GC.	/!32'')vh77##D)72
!3!3x&C--U;CxxH!!(+
	3w&FBDDH7*7#3458R.772;&%&E
"		% A
xT2772;&%&	3!!3FqyTD["?Tl
"$	$M1	3	3!!3!3s+8E30AE38BE':E3'E0	,E33E<ctD]}	tj|tdd=trdayy#t$rY9wxYw)z0Clean up temporary files from urlretrieve calls.N)rkreunlinkOSErrorrM)	temp_files rTr8r8sM#		IIi 	q		s5	AAz:\d+$c|j}t|d}|dk(r|jdd}tj	d|d}|jS)zReturn request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    r`Host)full_urlr
get_header_cut_port_resublower)requestrOhosts   rTrequest_hostr)sX

CC=Drz!!&"-Ba(D::<rUceZdZdidddfdZedZejdZejdZedZejdZejd	Zd
Z	dZ
dZd
ZdZ
dZdZdZddZdZdZy)rNFc||_i|_i|_d|_||_d|_|j
D]\}}|j|||t|}||_	||_
|r||_yyrW)rruunredirected_hdrs_datarP_tunnel_hostitems
add_headerrorigin_req_hostunverifiablemethod)	selfrOrPrurrrkeyvalues	         rT__init__zRequest.__init__;s
!#
	 !--/	(JCOOC'	("*40O.( DKrUc~|jr&dj|j|jS|jS)Nz{}#{})fragmentformat	_full_urlrs rTrzRequest.full_urlMs,==>>$..$--@@~~rUct||_t|j\|_|_|j	yrW)r	rrr_parserrOs  rTrzRequest.full_urlSs/ (1$..(A%

rUc.d|_d|_d|_y)Nr)rrselectorrs rTrzRequest.full_urlZs

rUc|jSrW)rrs rTrPzRequest.data`szzrUcx||jk7r+||_|jdr|jdyyy)NContent-length)r
has_header
remove_header)rrPs  rTrPzRequest.datads=4::DJ/0""#341rUcd|_yrW)rPrs rTrPzRequest.datans		rUct|j\|_}|jtd|jzt|\|_|_|jrt|j|_yy)Nzunknown url type: %r)	rrtyperErr
rrr)rrests  rTrzRequest._parsersd$T^^4	4993dmmCDD#-d#3 	4=99		*DIrUc<|jdnd}t|d|S)z3Return a string indicating the HTTP request method.POSTGETr)rPgetattr)rdefault_methods  rT
get_methodzRequest.get_methodzs!#'99#8etX~66rUc|jSrW)rrs rTget_full_urlzRequest.get_full_urls}}rUc|jdk(r%|js|j|_||_y||_|j|_||_y)Nhttps)rrrrr)rrrs   rT	set_proxyzRequest.set_proxysF99(9(9 $		D	DI MMDM	rUc4|j|jk(SrW)rrrs rT	has_proxyzRequest.has_proxys}}

--rUc>||j|j<yrW)ru
capitalizerrvals   rTrzRequest.add_headers),S^^%&rUc>||j|j<yrW)rrrs   rTadd_unredirected_headerzRequest.add_unredirected_headers36s~~/0rUc>||jvxs||jvSrW)rurrheader_names  rTrzRequest.has_headers&t||+6t555	7rUcn|jj||jj||SrW)rugetr)rrdefaults   rTrzRequest.get_headers2||""&&{G<>	>rUct|jj|d|jj|dyrW)rupoprrs  rTrzRequest.remove_headers,d+"";5rUchi|j|j}t|jSrW)rrulistr)rhdrss  rTheader_itemszRequest.header_itemss,9$((9DLL9DJJL!!rUrW)__name__
__module____qualname__rpropertyrsetterdeleterrPrrrrrrrrrrrrUrTrr9s!%r!%E!$
__

[[55
\\+7
.-77>
6"rUrcReZdZdZdZdZdZdejfdZ	d	dZ
dZy)
rcpdtz}d|fg|_g|_i|_i|_i|_i|_y)NPython-urllib/%sz
User-agent)__version__
addheadershandlershandle_openhandle_errorprocess_responseprocess_request)rclient_versions  rTrzOpenerDirector.__init__sB+k9(.9:
 "!rUct|dstdt|zd}t|D]	}|dvr	|j	d}|d|}||dzd}|jdrW|j	d|zdz}||dzd}	t
|}|jj|i}	|	|j|<n=|dk(r|}|j}	n)|d	k(r|}|j}	n|d
k(r|}|j}	n|	j|g}
|
rtj|
|n|
j!|d}|r2tj|j"||j%|yy#t$rYwxYw)N
add_parentz%expected BaseHandler instance, got %rF)redirect_requestdo_open
proxy_open_r`errorrNresponserT)hasattr	TypeErrorrdirfind
startswithrmrErrrrr
setdefaultbisectinsortrlrr)rhandleraddedmethiprotocol	conditionjkindlookuprs           rTadd_handlerzOpenerDirector.add_handlersw-C M*+
+L#	DDD		#ABQxHQqST
I##G,NN3'!+a/AaCDzt9D**..x<.4!!(+f$))j(..i'--((r2H

h0(EG#	JMM$--1t$/"s	E33	E?>E?cyrWrrs rTclosezOpenerDirector.closerUcd|j|d}|D]}t||}||}||cSy)Nr)rr)	rchainr	meth_nameargsrrfuncrws	         rT_call_chainzOpenerDirector._call_chainsC99T2&	G7I.D4[F!
		rUNct|tr
t||}n|}|||_||_|j
}|dz}|jj|gD]}t||}||}tjd|j|j|j|j|j||}	|dz}|jj|gD]}t||}|||	}	|	S)N_requestzurllib.Request	_response)
isinstancestrrrPrQrrrrsysauditrrur_openr)
rfullurlrPrQreqrr	processorrrs
          rTrNzOpenerDirector.opensgs#'4(CC88Z'	--11(B?	I9i0Ds)C				"CLL#((CKKIYZ::c4([(	..228R@	+I9i0DC*H	+rUc|j|jdd|}|r|S|j}|j|j||dz|}|r|S|j|jdd|S)Nrdefault_openrunknownunknown_open)rrr)rr	rPrwrs     rTrzOpenerDirector._open
s!!$"2"2I"0#7M88!!$"2"2Hh")?*+.0M 0 0) .5	5rUc|dvr|jd}|d}d|z}d}|}n|j}|dz}d}|||f|z}|j|}|r|S|r|dd	fz}|j|Sy)
Nhttprrr;z
http_error_%sr`_errorrrhttp_error_default)rr)rprotordictrhttp_err	orig_argsrws        rTrzOpenerDirector.errors%%$$V,DGE'%/IHI$$D(IHeY'$.!!!4(M)%9:YFD#4##T**rUrW)rrrrrrrsocket_GLOBAL_DEFAULT_TIMEOUTrNrrrrUrTrrs3	"-%^
	"&v/M/M:
5+rUrc	ht}ttttt
ttttg	}ttjdr|jtt}|D]V}|D]O}t!|t"rt%||s |j'|2t!||s?|j'|QX|D]}|j)||D]}|j+||D]*}t!|t"r|}|j+|,|S)a*Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    HTTPSConnection)rr r/r*rrr,r+r0r.rrclientrlrLsetrr
issubclassaddremover)rrSdefault_classesskipklasscheckhs       rTr3r35s
F#^[.0C!;0B"$Ot{{-.|,5D  	 E%&eU+HHUOE5)	  &u%&!$57#$aA1MrUc"eZdZdZdZdZdZy)rc||_yrW)parent)rr)s  rTrzBaseHandler.add_parent\s	rUcyrWrrs rTrzBaseHandler.close_rrUcNt|dsy|j|jkS)N
handler_orderT)rr,)rothers  rT__lt__zBaseHandler.__lt__cs(uo.!!E$7$777rUN)rrrr,rrr.rrUrTrrYsM
8rUrceZdZdZdZdZeZy)r0zProcess HTTP error responses.ic|j|j|j}}}d|cxkrdks"n|jj	d|||||}|S)N,r)codemsgrdr)r)rrrr3r4rs      rT
http_responsez HTTPErrorProcessor.http_responsepsT"--x}}4ct!c!{{((4d<HrUN)rrr__doc__r,r5https_responserrUrTr0r0ls'M	#NrUr0ceZdZdZy)rc4t|j||||rW)rr)rr	rtr3r4rs      rTrz*HTTPDefaultErrorHandler.http_error_default~sdCr::rUN)rrrrrrUrTrr}s;rUrc4eZdZdZdZdZdZexZxZxZ	Z
dZy)r
cZ|j}|dvr|dvs"|dvr|dk(st|j|||||jdd}d}|jjD	
cic]\}	}
|	j
|vr|	|
}}	}
t|||jd	Scc}
}	w)
aReturn a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        )-./i3i4)rHEAD)r>r?r@r z%20)r^zcontent-typeT)rurr)	rrrreplacerurrrr)rr	rtr3r4runewurlmCONTENT_HEADERSkv
newheaderss            rTrz$HTTPRedirectHandler.redirect_requests
NN22qO7K&1;CLL$WbAAU+<'*{{'8'8':;tq!/9d;
;v)'*':':$(*	*;s,B'cZd|vr|d}nd|vr|d}nyt|}|jdvrt|||d|d|||js|jrt|}d|d<t
|}t|dtj	}t|j|}|j||||||}|yt|d
rp|jx}	|_|	j|d|j k\st#|	|j$k\r6t|j||j&|z||ix}	x|_|_|	j|ddz|	|<|j)|j+|j,j/||j0
S)Nlocationurirrftprz - Redirection to url 'z' is not allowed/r;z
iso-8859-1)encodingsafe
redirect_dictrr`rQ)rschemerrfnetlocrrr
stringpunctuationrrrrrRrmax_repeatsromax_redirectionsinf_msgrnrr)rNrQ)
rr	rtr3r4rurDurlpartsnewvisiteds
          rThttp_error_302z"HTTPRedirectHandler.http_error_302s Z(F
g
U^FF#
??">>ADfM

}}H~HHQKH%
\0B0BDv.
##CT3H;3(*-*;*;;Gc'FA&$*:*::G 5 55d $s 2GRAA?A@G@c'#*;!++fa014		

{{S[[99rUzoThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
N)rrrrXrYrr^http_error_301http_error_303http_error_307http_error_308rZrrUrTrrs<K *L::xIWVNV^Vn~2GrUrcft|\}}|jdsd}|}ne|jdstd|zd|vr$|jd}|jd|}n|jdd}|dk(rd}|d|}t	|\}}|t|\}}	ndx}}	|||	|fS)aReturn (scheme, user, password, host/port) given a URL or an authority.

    If a URL is supplied, it must have an authority (host:port) component.
    According to RFC 3986, having an authority component means the URL must
    have two slashes after the scheme.
    rON//zproxy URL with no authority: %r@r;r])rrrErrr)
proxyrTr_scheme	authorityhost_separatorenduserinfohostportuserpasswords
          rT_parse_proxyros"%(FHs#	""4(>FGG(?%]]3/N--^4C--Q'C"9CQsO	#I.Hh%h/hx48++rUceZdZdZddZdZy)r dNc|
t}t|dsJd||_|jD]4\}}|j	}t|d|z|||jfd6y)Nkeysproxies must be a mappingz%s_openc||||SrWr)rrfrrs    rT<lambda>z'ProxyHandler.__init__.<locals>.<lambda>sQt,rU)r6rproxiesrrsetattrr)rrxrrOs    rTrzProxyHandler.__init__sm? lGw'D)DD 	.ID#::<DD)d*$'d-
.	.rUc|j}t|\}}}}||}|jrt|jry|rb|r`t	|dt	|}	tj|	jjd}
|jdd|
zt	|}|j||||k(s|dk(ry|jj||jS)N:asciiProxy-authorizationBasic rrS)rrorproxy_bypassrbase64	b64encodeencodedecoderrr)rNrQ)rr	rfr	orig_type
proxy_typermrnrl	user_passcredss           rTrzProxyHandler.proxy_open"sHH	/;E/B,
D(H"J88SXX.H#*4=#*8#46I$$Y%5%5%78??HENN0(U2BC8$

h
+
"i7&:;;##C#==rUrW)rrrr,rrrrUrTr r sM	.>rUr c,eZdZdZdZdZddZdZy)r!ci|_yrW)passwdrs rTrzHTTPPasswordMgr.__init__@s	rUct|tr|g}|jvrij|<dD]+tfd|D}||fj||<-y)NTFc3BK|]}j|ywrW)
reduce_uri).0udefault_portrs  rT	<genexpr>z/HTTPPasswordMgr.add_password.<locals>.<genexpr>Js! ?56<0 ?s)rrrtuple)rrealmrLrmrreduced_urirs`     @rTadd_passwordzHTTPPasswordMgr.add_passwordCskc3%C#!#DKK'	=L ?:= ??K/3VnDKK{+	=rUc|jj|i}dD]M}|j||}|jD]&\}}|D]}|j	||s|cccS(Oy)NrNN)rrrr	is_suburi)	rrauthuridomainsrreduced_authuriurisauthinforLs	         rTfind_user_passwordz"HTTPPasswordMgr.find_user_passwordNsu++//%,'	(L"oog|DO")--/
(h(C~~c?;'(
(	(rUct|}|dr|d}|d}|dxsd}nd}|}d}t|\}}|r!||dddj|}	|	d	||	fz}||fS)
z@Accept authority or URI and extract only the authority and path.r`rr;rONPirz%s:%d)rrr)
rrLrpartsrTrhrfrportdports
          rTrzHTTPPasswordMgr.reduce_uriXs
81XFaI8?sDFID	*
dDLV-?!s6{
 #tUm3	$rUcr||k(ry|d|dk7ry|d}|dddk7r|dz
}|dj|S)zcCheck if test is below base in a URI tree

        Both args must be URIs in reduced form.
        TrFr`r]NrO)r)rbasetestprefixs    rTrzHTTPPasswordMgr.is_suburiosV
4<7d1ga"#;#cMFAw!!&))rUN)T)rrrrrrrrrrUrTr!r!>s	=.*rUr!ceZdZdZy)r"cptj|||\}}|||fStj|d|SrW)r!r)rrrrmrns     rTrz2HTTPPasswordMgrWithDefaultRealm.find_user_passwordsC(;;D%<CEh>!11$gFFrUN)rrrrrrUrTr"r"~sGrUr"c8eZdZfdZdfd	ZddZdZxZS)r#c2i|_t||i|yrW)
authenticatedsuperr)rrkwargs	__class__s   rTrz%HTTPPasswordMgrWithPriorAuth.__init__s
$)&)rUcv|j|||t|	d|||t|	||||yrW)update_authenticatedrr)rrrLrmris_authenticatedrs      rTrz)HTTPPasswordMgrWithPriorAuth.add_passwords@!!#'78G sD&9
UCv6rUct|tr|g}dD]*}|D]#}|j||}||j|<%,yNr)rrrr)rrLrrrrs      rTrz1HTTPPasswordMgrWithPriorAuth.update_authenticatedsUc3%C'	CL
C"ooa>2B"";/
C	CrUcdD]J}|j||}|jD]'}|j||s|j|ccSLyr)rrr)rrrrrLs     rTrz-HTTPPasswordMgrWithPriorAuth.is_authenticatedsU'	3L"oog|DO))
3>>#7--c22
3	3rU)F)rrrrrrr
__classcell__)rs@rTr#r#s*7C3rUr#cteZdZejdej
Zd	dZdZdZ	dZ
dZdZeZ
eZy)
r$z1(?:^|,)[ 	]*([^ 	,]+)[ 	]+realm=(["']?)([^"']*)\2Nc`|
t}||_|jj|_yrW)r!rr)rpassword_mgrs  rTrz!AbstractBasicAuthHandler.__init__s)*,L" KK44rUc#Kd}tjj|D]=}|j\}}}|dvrt	j
dtd||fd}?|s|r|jd}nd}|dfyyw)NF)"'zBasic Auth Realm was unquotedTrr)r$rxfinditergroupsrBrCUserWarningsplit)rheaderfound_challengemorTr
rs       rT_parse_realmz%AbstractBasicAuthHandler._parse_realms*--66v>	#B#%99; FE5J&

=)1.5/!"O	#*4. sBBc|j|}|syd}|D]J}|j|D]4\}}|jdk7r|}||j|||ccSL|t	dy)Nbasicz@AbstractBasicAuthHandler does not support the following scheme: )get_allrrretry_http_basic_authrE)	rauthreqrr	ruunsupportedrrTrs	         rThttp_error_auth_reqedz.AbstractBasicAuthHandler.http_error_auth_reqeds//'*
	HF!%!2!26!:	
H
<<>W,"(K$ 55dCGG	
H
	H" &)*
*#rUc|jj||\}}||d|}dtj|j	jdz}|j
|jd|k(ry|j|j||jj||jSy)Nr{r~r|rS)rrrrrrrauth_headerrr)rNrQ)rrr	rrmpwrawauths        rTrz.AbstractBasicAuthHandler.retry_http_basic_auths;;11%>b
>!2&Cf..szz|<CCGLLD~~d..5=''(8(8$?;;##C#==rUct|jdr%|jj|js|S|j	ds|jjd|j\}}dj
||j}tj|j}|jddj
|j|S)Nr
Authorizationz{0}:{1}zBasic {})
rrrrrrrrrstandard_b64encoderrstrip)rr	rmrcredentialsauth_strs      rThttp_requestz%AbstractBasicAuthHandler.http_requests%78{{++CLL9J~~o.;;99$MLD&#**48??AK00=DDFH''(2(9(9(..:J(K
M
rUct|jdrfd|jcxkrdkr+nn(|jj|jd|S|jj|jd|S)Nrr1r2TF)rrr3rr)rr	rs   rTr5z&AbstractBasicAuthHandler.http_response	s`4;; 23hmm)c)00tD00uErUrW)rrrrecompileIrrrrrrr5
https_requestr7rrUrTr$r$sL
1DD
B5!(*4
!M"NrUr$ceZdZdZdZy)r%rcF|j}|jd|||}|S)Nwww-authenticate)rr)rr	rtr3r4rurOrs        rThttp_error_401z#HTTPBasicAuthHandler.http_error_401s*ll--.@*-sG=rUN)rrrrrrrUrTr%r%s!KrUr%ceZdZdZdZy)r&r}cF|j}|jd|||}|SNproxy-authenticate)rr)rr	rtr3r4rurhrs        rThttp_error_407z$ProxyBasicAuthHandler.http_error_407%s-
HH	--.B*3S'CrUN)rrrrrrrUrTr&r&!s'KrUr&c>eZdZd
dZdZdZdZdZdZdZ	d	Z
y)r'Nc|
t}||_|jj|_d|_d|_d|_yNr)r!rrretriednonce_count
last_nonce)rrs  rTrz"AbstractDigestAuthHandler.__init__?s>>$&F KK44rUcd|_yr)rrs rTreset_retry_countz+AbstractDigestAuthHandler.reset_retry_countHs	rUcZ|j|d}|jdkDrt|jdd|d|xjdz
c_|rZ|j	d}|jdk(r|j
||S|jdk7rtd|zyy)	Nizdigest auth failedr`rdigestrzEAbstractDigestAuthHandler does not support the following scheme: '%s')rrrrrrretry_http_digest_authrE)rrrr	rurrTs       rTrz/AbstractDigestAuthHandler.http_error_auth_reqedKs++k40<<!CLL#/C#T+
+
LLAL]]_Q'F||~)223@@7* "?AG"HII+	rUcz|jdd\}}ttdt|}|j	||}|rtd|z}|j
j
|jd|k(ry|j|j||jj||j}|Sy)NrBr`z	Digest %srS)rparse_keqv_listfilterparse_http_listget_authorizationrurrrr)rNrQ)rr	rtoken	challengechalauth_valresps        rTrz0AbstractDigestAuthHandler.retry_http_digest_auth_s::c1-yvdOI,FGH%%c40"T)H{{t//6(B''(8(8(C;;##C#=DK
rUc|jd|dtjd}|jdt	dz}tj|j}|ddS)Nr{r|)rtimectimer_randombyteshashlibsha1	hexdigest)rnoncesbdigs     rT
get_cnoncez$AbstractDigestAuthHandler.get_cnonceksT ++UDJJLA
HHWQ/ll1o'')3BxrUc	|d}|d}|jd}|jdd}|jdd}|j|\}}	|y|jj	||j
\}
}|
y|j|j|j|}nd}|
d|d|}
|jd|j}||	||
|d||}nd|jd	vry||jk(r|xjd
z
c_nd
|_||_d|jz}|j|}|d|d|ddd||	}|	||
|}ntd|zd
|
d|d|d|jd|d}|r|d|zz
}|r|d|zz
}|d|zz
}|r|dddz
}|S#t$rYywxYw)Nrrqop	algorithmMD5opaquer{r,r`z%08xzqop '%s' is not supported.z
username="z
", realm="z
", nonce="z", uri="z
", response="rz
, opaque="%s"z
, digest="%s"z, algorithm="%s"z, qop=auth, nc=z
, cnonce=")rKeyErrorget_algorithm_implsrrrrPget_entity_digestrrrrrrr)rr	rrrrrrHKDrmrentdigA1A2respdigncvaluecnoncenoncebitrs                    rTrz+AbstractDigestAuthHandler.get_authorizationvs		MEME((5/Ce4IXXh-F((329;;11%Fb<88++CHHd;FF
+(&
;25!B% 89G
syy~
%'  A% #$ "'t///G__U+F+0'661R5QH2)G7#=>>
#'ucll")+Of,,DOf,,D"Y..HHDg		s?G	G#"G#cV|dk(rdn|dk(rdntd|zfd}|fS)Nrcftj|jdjSNr|)rmd5rrxs rTrwz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>s!'++ahhw&78BBDrUSHAcftj|jdjSr!)rrrrr#s rTrwz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>s!',,qxx'89CCErUz.Unsupported digest authentication algorithm %rc|d|S)Nr{r)r	drs  rTrwz?AbstractDigestAuthHandler.get_algorithm_impls.<locals>.<lambda>s!q!,-rU)rE)rrrrs   @rTrz-AbstractDigestAuthHandler.get_algorithm_implssGDA
%
EA,.789
9
-"urUcyrWr)rrPrs   rTrz+AbstractDigestAuthHandler.get_entity_digestsrUrW)rrrrrrrrrrrrrUrTr'r'4s,I(
	<|rUr'ceZdZdZdZdZdZy)r(zAn authentication protocol defined by RFC 2069

    Digest authentication improves on basic authentication because it
    does not transmit passwords in the clear.
    rc~t|jd}|jd|||}|j|S)Nr`r)rrrrrr	rtr3r4rurretrys        rTrz$HTTPDigestAuthHandler.http_error_401s@%a(**+=+/g? rUN)rrrr6rr,rrrUrTr(r(s"KMrUr(ceZdZdZdZdZy)r)Proxy-Authorizationr+cf|j}|jd|||}|j|Sr)rrrr-s        rTrz%ProxyDigestAuthHandler.http_error_407s6xx**+?+/g? rUN)rrrrr,rrrUrTr)r)s'KMrUr)c,eZdZddZdZdZdZdZy)AbstractHTTPHandlerNcj|||_ytjjj|_yrW)rrHTTPConnection
debuglevel_debuglevel)rr6s  rTrzAbstractHTTPHandler.__init__s&)3)?:T[[E_E_EjEjrUc||_yrW)r7)rlevels  rTset_http_debuglevelz'AbstractHTTPHandler.set_http_debuglevels
 rUctjjj|j|jSrW)rrr5_get_content_lengthrPrrrs  rTr<z'AbstractHTTPHandler._get_content_lengths2{{))==LL "	"rUc|j}|std|j|j}t|tr
d}t||j
ds|jdd|j
dsR|j
dsA|j|}||jdt	|n|jdd|}|jr&t|j\}}t|\}}	|j
ds|jd||jjD]9\}
}|
j}
|j
|
r(|j|
|;|S)	N
no host givenz\POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.zContent-type!application/x-www-form-urlencodedrTransfer-encodingchunkedr)rrrPrrrrrr<rrrr
r)rr)rrrrPr4content_lengthsel_hostrTselsel_pathrjrs            rTdo_request_zAbstractHTTPHandler.do_request_so||?++<<#<<D$$Dn$%%n5//"79&&'78#../BC!%!9!9'!B!-33,c..AC33/<$W%5%56KFC!+CHh!!&)++FH=;;11	=KD%??$D%%d+//e<	=
rUc	|j}|std||fd|ji|}|j|jt|j}|j|jjDcic]\}}||vr||c}}d|d<|jD	
cic]\}	}
|	j|
}}	}
|jr0i}d}||vr||||<||=|j|j|		|j|j|j|j ||j#d|j'}|j*r!|j*j)d	|_|j-|_|j0|_|Scc}}wcc}
}	w#t$$r}
t|
d	}
~
wwxYw#|j)xYw)
zReturn an HTTPResponse object for the request, using http_class.

        http_class must implement the HTTPConnection API from http.client.
        r?rQr
Connectionr0rurA)encode_chunkedN)rrrQset_debuglevelr7rrupdaterurtitler
set_tunnelrrrrPrr~getresponsersockrrOreasonr4)r
http_classr	http_conn_argsrr%rurGrHrjrtunnel_headersproxy_auth_hdrerrrvs               rTrzAbstractHTTPHandler.do_opens
xx?++
tCS[[CNC	))*s,,-):):)<-AG+1-	.!(6=mmoFs4::<$FFN2N(181H~.N+
LL))>LB		
$		#..*CLL#((G),8K)LN

A
66
FFLLNAF  "e-G 
$sm#
$	
GGIs7G
8GAGG(	G%G  G%%G((G;rW)rrrrr:r<rGrrrUrTr3r3sk!"
$L@rUr3c*eZdZdZej
Zy)r*cV|jtjj|SrW)rrrr5rr	s  rT	http_openzHTTPHandler.http_open\s||DKK66<<rUN)rrrr[r3rGrrrUrTr*r*Zs='22LrUr*rc2eZdZddZdZejZy)rLNc*||n#tjjj}tj|||Ctjjj}tjj|}|||_||_	yrW)
rrrr6r3r	_http_vsn_create_https_contextcheck_hostname_context)rr6r?r`http_versions     rTrzHTTPSHandler.__init__esq'1'=4;;C^C^CiCiJ((z:#{{::DD++;;LI))7&#DMrUcn|jtjj||jS)NrA)rrrrrarZs  rT
https_openzHTTPSHandler.https_openos-<< ; ;S(,

 7
7rUNNN)rrrrrdr3rGrrrUrTrLrLcs	$	7,77
rUrLc(eZdZddZdZdZeZeZy)rNcRddl}||jj}||_yr)http.cookiejar	cookiejar	CookieJar)rrirs   rTrzHTTPCookieProcessor.__init__xs$002I"rUc<|jj||SrW)riadd_cookie_headerr=s  rTrz HTTPCookieProcessor.http_request~s((1rUc>|jj|||SrW)riextract_cookies)rrrs   rTr5z!HTTPCookieProcessor.http_responses&&x9rUrW)rrrrrr5rr7rrUrTrrws#!M"NrUrceZdZdZy)r/c6|j}td|z)Nzunknown url type: %s)rr)rr	rs   rTrzUnknownHandler.unknown_opensxx-455rUN)rrrrrrUrTr/r/s6rUr/cvi}|D]1}|jdd\}}|ddk(r
|ddk(r|dd}|||<3|S)z>Parse list of key=value strings where keys are not duplicated.=r`rrr])r)lparsedeltrGrHs     rTrrsZ
Fyya 1Q43;1R5C<!BAq		
MrUcg}d}dx}}|D]H}|r||z
}d}
|r|dk(rd}|dk(rd}||z
}$|dk(r|j|d}=|dk(rd}||z
}J|r|j||Dcgc]}|jc}Scc}w)apParse 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.
    rF\Trr)rlr)r	respartescaper
curs      rTrrs
C
DFUCKDFd{CKD#:JJtD#:E-2

4%()TDJJL)))s-Bc"eZdZdZdZdZdZy)r+c|j}|dddk(rK|dddk7rC|jr7|jdk7r(|j|jvrtdy|j	|S)Nr;rdrrO	localhost-file:// scheme is supported only on localhost)rr	get_namesropen_local_file)rr	rOs   rT	file_openzFileHandler.file_opensmllr7d?s1Qx3CHHK'88t~~//NOO0'',,rUNctjf	ttjddtjtj
dzt_tjStjS#tj$r1tjdft_YtjSwxYw)Nr~r;)r+namesrrgethostbyname_exgethostnamegaierror
gethostbynamers rTrzFileHandler.get_namess$
I$)++K8;++F,>,>,@A!DE%F!
   {   ??
I%+%9%9+%F$H!   
IsAB2C
CcDddl}ddl}|j}|j}t	|}	tj|}|j}|jj|jd}	|j|d}
|jd|
xsd||	fz}|rt|\}}|rsBt||jvr'|r	d|z|z}
nd|z}
t!t#|d||
St'd#t$$r}t'|d}~wwxYw)	NrTusegmtz6Content-type: %s
Content-length: %d
Last-modified: %s

text/plainfile://rbzfile not on local host)email.utils	mimetypesrrr5restatst_sizeutils
formatdatest_mtime
guess_typemessage_from_stringr_safe_gethostbynamerrrNr~r)rr	emailrrrq	localfilestatsrymodifiedmtyperurorigurlexps               rTrzFileHandler.open_local_files$xx<< *		 GGI&E==D{{--ennT-JH((215E/e//K&,h789G'-
d1$74>>;KK'$.9G'(2G!$y$"7'JJ/00	 3-	 sC
D	DDD)rrrrrrrrrUrTr+r+s-
E!1rUr+c`	tj|S#tj$rYywxYwrW)rrr)rs rTrrs.##D))??s--ceZdZdZdZy)r,c$ddl}ddl}|j}|stdt	|\}}|
|j
}nt
|}t|\}}|rt|\}}nd}t|}|xsd}|xsd}	tj|}t|j\}	}
|	jd}t!t#t|}|dd|d}}|r
|ds|dd}	|j%||||||j&}
|xrdxsd}|
D]9}t)|\}}|j+d	k(s%|d
vs*|j-};|
j/||\}}d}|j1|j2d}|r|d|zz
}|
|dk\r|d|zz
}t5j6|}t9|||j2S#t$r}t|d}~wwxYw#|j:$r}t||d}~wwxYw)
Nrftp error: no host givenrrOr]r`rDraArrr(rzContent-type: %s
zContent-length: %d
)ftplibrrrrFTP_PORTrmrrrrrr~rrrrmapconnect_ftprQrrupperretrfilerrrrr
all_errors)rr	rrrrrmrr4rfattrsdirsrYfwrattrrrtretrlenrurrs                      rTftp_openzFTPHandler.ftp_opens)xx566%
d<??Dt9D %
d'-LD&Ft}zr2	 ''-D!.ezz#C&'#2YRdQ8D	)!!$dD#++NB<C&3D
))$/e::<6):: ;;=D	
)
++dD1KBG((6q9E/%77"w!|1G;;//8Gb'3<<881	 3-	 2  	)3-S(	)s>G1AG/G/BG/	G,G''G,/H>H

Hc	&t||||||dS)NF)
persistent)
ftpwrapper)rrmrrrrrQs       rTrzFTPHandler.connect_ftp1s$dD'%*,	,rUN)rrrrrrrUrTr,r,s
2)h,rUr,c0eZdZdZdZdZdZdZdZy)r-cJi|_i|_d|_d|_d|_y)Nr<r)cacherQsoonestdelay	max_connsrs rTrzCacheFTPHandler.__init__8s%

rUc||_yrW)r)rts  rT
setTimeoutzCacheFTPHandler.setTimeout?s	
rUc||_yrW)r)rrEs  rTsetMaxConnszCacheFTPHandler.setMaxConnsBs	rUc||||dj||f}||jvr/tj|jz|j|<nKt|||||||j|<tj|jz|j|<|j
|j|S)NrO)joinrrrrQrcheck_cache)rrmrrrrrQrs        rTrzCacheFTPHandler.connect_ftpEsD$7$** $		djj 8DLL(vtT)-w8DJJsO $		djj 8DLLzz#rUctj}|j|krht|jj	D]B\}}||ks|j
|j
|j
|=|j|=Dtt|jj|_t|j
|jk(rt|jj	D]0\}}||jk(s|j
|=|j|=ntt|jj|_yyrW)rrrrQrrrminvaluesror)rrrGrHs    rTrzCacheFTPHandler.check_cachePsIIK<<1T\\//12
(1q5JJqM'')

1
Q	
(
4 3 3 567tzz?dnn,T\\//12
1$

1
Q	

tDLL$7$7$9:;DL
-rUc|jjD]}|j|jj|jjyrW)rrrclearrQ)rconns  rTclear_cachezCacheFTPHandler.clear_cachedsGJJ%%'	DJJL	

rUN)	rrrrrrrrrrrUrTr-r-5s 	<(rUr-ceZdZdZy)r.ch|j}|jdd\}}|jdd\}}t|}|jdrt	j
|}|dd}|sd}t
jd|t|fz}ttj|||S)Nr{r`rz;base64itext/plain;charset=US-ASCIIz$Content-type: %s
Content-length: %d
)rrrendswithrdecodebytesrrrorioBytesIO)rr	rOrTrP	mediatyperus       rT	data_openzDataHandler.data_openksllyyQ'**S+	4 %i(%%d+D!#2I5I++,T
D	"-#$"**T*GS99rUN)rrrrrrUrTr.r.js:rUr.r<nt)r5r4ct|S)zOS-specific conversion from a relative URL of the 'file' scheme
        to a file system path; not recommended for general use.)rpathnames rTr5r5sx  rUct|S)zOS-specific conversion from a file system path to a relative URL
        of the 'file' scheme; not recommended for general use.)r
rs rTr4r4sXrUceZdZdZdZdezZddZdZdZ	dZ
dZdd	Zdd
Z
ddZddZd
ZddZddZdZerdZddZdZdZdZddZy)r9a,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).Nrcdd|jjiz}tj|td|
t}t
|dsJd||_|jd|_	|jd|_
d	|jfd
g|_g|_
tj|_d|_t$|_y)NzW%(class)s style of invoking requests is deprecated. Use newer urlopen functions/methodsclassr)
stacklevelrsrtkey_file	cert_filez
User-Agent)Acceptz*/*)rrrBrCrDr6rrxrrrversionr_URLopener__tempfilesrer}_URLopener__unlink	tempcacheftpcache)rrxx509r4s    rTrzURLopener.__init__s47>@W@W6XY

c-!<? lGw'D)DD,
+.($,,79JK		
!
rUc$|jyrW)rrs rT__del__zURLopener.__del__s

rUc$|jyrW)cleanuprs rTrzURLopener.closesrUc|jr2|jD]}	|j||jdd=|jr|jj	yy#t$rYYwxYwrW)rrr~rr)rrYs  rTrzURLopener.cleanupss((
MM$'

  #>>NN  "sA''	A32A3c:|jj|y)zdAdd a header to be used by the HTTP interface only
        e.g. u.addheader('Accept', 'sound/basic')N)rrl)rrs  rT	addheaderzURLopener.addheaders	
t$rUctt|}t|d}|jr9||jvr+|j|\}}t	|d}t|||St
|\}}|sd}||jvr0|j|}t
|\}}	t|	\}
}|
|f}nd}d|z}||_	|jdd}t||r|d	k(r'|r|j|||S|j||S	|t|||St||||S#tt f$rt"$r}
t#d
|
|
d}
~
wwxYw)z6Use URLopener().open(file) instead of open(file, 'r').z%/:=&?~#+!$,;'@()*[]|rQrrYNopen_-rrzsocket error)r	rr
rrNrrrxr
rrCropen_unknown_proxyopen_unknownrrrr~)rrrPrqrurturltyperOrf	proxyhostrrrjr4s              rTrNzURLopener.opensz7+,&=>>>g7 $w 7Hgh%Bb'733!'*Gdll"LL)E!+E!2GY'	2ND(/CE 	||C%tT"d.?&?..ugtDD(($77	8|*wtT*3//*wtT*3558$		8.#.C7	8sD7$D77E!
EE!c8t|\}}tdd|)/Overridable interface to open unknown URL type.	url errorzunknown url typerr~)rrrPrrOs     rTrzURLopener.open_unknowns w'	ck#5t<<rUc>t|\}}tdd|z|)rrzinvalid proxy for %sr)rrfrrPrrOs      rTrzURLopener.open_unknown_proxy	s%w'	ck#9D#@%HHrUc,tt|}|jr||jvr|j|St|\}}|R|r|dk(rK	|j	|}|j}|j
tt|d|fS|j||}	|j}	|r
t|d}
nt|\}}t|xsd\}}t|xsd\}}t|xsd\}}tjj|d}
t!j"|
\}}|j$j'|tj(|d}
	||	f}|j||j|<d}d}d}d}d|	vrt+|	d	}|r
|||||j-|x}rD|t/|z
}|
j1||dz
}|r
|||||j-|x}rD|
j
	|j
|dk\r||krt3d
||fz||S#t$rYwxYw#|
j
wxYw#|j
wxYw)ztretrieve(url) returns (filename, headers) for a local object
        or (tempfilename, headers) for a remote object.rYr`rZrr\r]rr^r_ra)r	rrrrrdrr5r
r~rNrrrerfsplitextrhmkstemprrlfdopenrmrnrorpr)rrOrqrrrPrurl1rtrrurvgarbagerfsuffixfdrwrxryrnrzr{s                     rTretrievezURLopener.retrievesYs^$>>cT^^3>>#&&_
dTTV^
))$/wwy
#Jt$4Q$78$>>YYsD
!"	ggiG8T* *3
 *4:2 6
 +DJB 7
g *4:2 6
g))$/2!)!1!1&!9X  ''1iiD)
!7*>>-*0DNN3'#w.w'789DxT2!wwr{*e*CJ&DIIe$MH!"8R6 "wwr{*e*		HHJ19&C, &(
(
[

F		HHJs9A	I3CJBI,J	I)(I),I>>JJcd}d}t|tr,t|\}}|rt|\}}t	|}|}nq|\}}t|\}}t|\}	}
|
}d}|	j
dk7rd}n6t|
\}}
|rt|\}}|r	|	d||
}t|r|}|stdd|r>t	|}tj|jjd}nd}|r>t	|}tj|jjd}nd}||}
i}|rd|z|d<|rd|z|d	<|r||d
<d|d<|jD]
\}}|||<|d
|d<|
jd|||n|
jd||	|
j}d|j(cxkrdkr(nn%t+||j,d|z|j(S|j/||j0|j(|j2|j,|S#t j"j$$rt'dwxYw)aMake an HTTP connection using connection_class.

        This is an internal method that should be called from
        open_http() or open_https().

        Arguments:
        - connection_factory should take a host name and return an
          HTTPConnection instance.
        - url is the url to retrieval or a host, relative-path pair.
        - data is payload for a POST request or None.
        Nrz://z
http errorr?r|zBasic %sr0rrrrIr@zContent-TyperrrJz$http protocol error: bad status liner1r2http:)rrr
rrrrrr~rrrrrrrPrr
BadStatusLinerstatusrr4
http_errorrtrR)rconnection_factoryrOrPuser_passwdproxy_passwdrrrealhostrr
proxy_authr	http_connrurrrs                  rT_open_generic_httpzURLopener._open_generic_httpMsc3'_ND($.t$4!Tt}H ND(!+D!1L$&x0MGTCK}}&(!+D!1$,6x,@)K.5xFH)#D7<AA"<0L)),*=*=*?@GGPJJ!+.K##K$6$6$89@@IDD&t,	-7*-DG)*(2T(9GO$&GFO
!(!__	$MFE#GFO	$&IGN#fhg>eXw?	C ,,.H(//'C'hgm&oo/
/??X[[(,,F
F{{((	CABB	Cs8I)I,cX|jtjj||S)zUse HTTP protocol.)rrrr5rrOrPs   rT	open_httpzURLopener.open_https!&&t{{'A'A3MMrUcd|z}t||r,t||}|
||||||}	n
|||||||}	|	r|	S|j|||||S)zHandle http errors.

        Derived class can override this, or provide specific handlers
        named http_error_DDD where DDD is the 3-digit error code.z
http_error_%d)rrr)
rrOrterrcodeerrmsgrurPrjrrws
          rTr
zURLopener.http_errorso(4T4(F|R&'BR&'4Hf}&&sBIIrUc@|jt||||d)z>Default error handler: close the connection and raise OSError.N)rrrrOrtrrrus      rTrzURLopener.http_error_defaults

Wfgt<<rUcr|js|jr}tjjj
}tjj
|}|j|j|j|j
d|_nd}tjj	||S)NTrA)	rrrrrr^r_load_cert_chainpost_handshake_auth)rrrbr?s    rT_https_connectionzURLopener._https_connections}}#{{::DD++;;LI''

F..:26G/;;..tW.EErUc<|j|j||S)zUse HTTPS protocol.)rrrs   rT
open_httpszURLopener.open_httpss**4+A+A3MMrUct|tstd|dddk(r)|dddk7r!|ddjdk7rt	d	|j|S)
z/Use local file or FTP depending on form of URL.zEfile error: proxy support for file protocol currently not implementedNr;rdrrOz
localhost/r)rrrrrErrs  rT	open_filezURLopener.open_filesb#s#bccr7d?s1Qx33q9??3D3TLMM'',,rUcddl}ddl}t|\}}t|}	t	j
|}|j}	|jj|jd}
|j|d}|jd|xsd|	|
fz}|s&|}
|dddk(rd	|z}
t!t#|d
||
St%|\}}|sht'j(|t+ft-zvr=|}
|dddk(rd	|z}
n|dddk(rt/d
|zt!t#|d
||
Std#t$r%}t|j|jd}~wwxYw)zUse local file.rNTrz6Content-Type: %s
Content-Length: %d
Last-modified: %s
rr`rOrrr;z./zAlocal file url may start with / or file:. Unknown url of type: %sz#local file error: not on local host)rrr
r5rerr~rstrerrorrqrrrrrrrrNrrrr~thishostrE)rrOrrrrY	localnamereryrrruurlfilers               rTrzURLopener.open_local_files_
d &		3GGI&E}};;))%..)F$$S)!,+%++G

"lD(3
45GBQx3#d*d9d3WgFF%
d##D)y{nxz.IJGBQx3#d*bqT! !dgj!jkkd9d3WgFF<==-	31::qzz22	3sE	E4 E//E4c8t|tstdddl}t	|\}}|stdt|\}}t
|\}}|rt|\}}nd}t|}t|xsd}t|xsd}tj|}|sddl}|j}nt|}t|\}}	t|}|jd}
|
dd|
d}}
|
r
|
ds|
dd}
|
r
|
dsd|
d<|||dj!|
f}t#|j$t&kDrLt)|j$D]4}
|
|k7s	|j$|
}|j$|
=|j+6	||j$vrt-|||||
|j$|<|sd	}nd
}|	D]9}t/|\}}|j1dk(s%|dvs*|j3};|j$|j5||\}}|j7d
|zd}d}|r|d|zz
}|
|dk\r|d|zz
}t9j:|}t=||d
|zS#t?$r}td||d}~wwxYw)zUse FTP protocol.zCftp error: proxy support for ftp protocol currently not implementedrNrrrOr]r`rrrrzftp:zContent-Type: %s
zContent-Length: %d
ftp error: ) rrrrr
rrrrrrrrrmrrrrorMAXFTPCACHErrrrrrrrrrr	ftperrors)rrOrrrfrrmrrrrrYrrGrHrrrrtrrrurs                       rTopen_ftpzURLopener.open_ftps#s#`aa_
d8$>??%
d%
dT 2vft}tzr"2&##D)??Dt9D &et}zz##2YRdQQRQ3aD$.t}}+$--(
8

a(A

a(GGI	

	9$--'tVT4>

c"$
))$/e::<6):: ;;=D	
)
!MM#.77dCMR((#6q9EG/%77"w!|1G;;//8Gb'6C<88{	9[./S8	9s&AI8(I8-B
I88
JJJc
Tt|tstd	|jdd\}}|sd}|j
d}|dk\rd	||d
vr||dzd
}|d
|}nd}g}|jdtjd
tjtjz|jd|z|dk(r4tj|jdjd}nt|}|jdt!|z|jd|j|dj#|}t%j&|}t)j*|}t-|||S#t$r
tddwxYw)zUse "data" URL.zEdata error: proxy support for data protocol currently not implementedrr`z
data errorzbad data URLr;rrrNrzDate: %sz%a, %d %b %Y %H:%M:%S GMTzContent-type: %srr|zlatin-1zContent-Length: %d
)rrrrrEr~rfindrlrstrftimegmtimerrrrrrorrrrStringIOr)	rrOrPrsemirPr4rufs	         rT	open_datazURLopener.open_data7s#s#bcc	899S!,LT40Dzz#19DK/DFG}H;DH

:dmm,G,0KK		,DFF	G

%,-x%%dkk'&:;BB9MD4=D

'#d)34

2

4iin++C0KK!Wc**5	8,77	8sFF'rWre)rrrr6rrrrrrrrrNrrrrrr
rrFrrr"rr-r7rrUrTr9r9sK ;.G!4#%"8H=
I:|ZFxNJ =
	F	N->@89t'+rUr9ceZdZdZdZdZddZdZddZddZ	dd	Z
dd
Z		ddZ		ddZ
dd
ZddZddZddZddZdZy)r:z?Derived class with handlers for errors we can handle (perhaps).c`tj|g|i|i|_d|_d|_y)Nrr<)r9r
auth_cachetriesmaxtries)rrrs   rTrzFancyURLopener.__init__ds/41$1&1

rUc$t||d|z|S)z3Default error handling -- don't raise an exception.r)rrs      rTrz!FancyURLopener.http_error_defaultjs"gw}g>>rUNc>|xjdz
c_	|jrQ|j|jk\r8t|dr
|j}n|j}|||dd|d|_S|j||||||}|d|_S#d|_wxYw)z%Error 302 -- relocated (temporarily).r`http_error_500r'z)Internal Server Error: Redirect Recursionr)r;r<rr?rredirect_internal)	rrOrtrrrurPrrws	         rTr^zFancyURLopener.http_error_302ns

a

	}}t}}!<4!12..D22DCSG#%DJ	++CWf,3T;FDJDJsAB4B	Bcd|vr|d}nd|vr|d}ny|jt|jdz|z|}t|}|jdvrt|||d|zz|||j
|S)NrKrLr{rMz( Redirection to url '%s' is not allowed.)rrrrrTrrN)	rrOrtrrrurPrDr[s	         rTr@z FancyURLopener.redirect_internals Z(F
g
U^F

S3.7F#??">>FG"FOP#R)
)
yy  rUc.|j||||||S)z*Error 301 -- also relocated (permanently).r^rrOrtrrrurPs       rTr_zFancyURLopener.http_error_301""3GVWdKKrUc.|j||||||S)z;Error 303 -- also relocated (essentially identical to 302).rCrDs       rTr`zFancyURLopener.http_error_303rErUc\||j||||||S|j|||||S)z1Error 307 -- relocated, but turn POST into error.)r^rrDs       rTrazFancyURLopener.http_error_307;<&&sB$OO**3GVWMMrUc\||j||||||S|j|||||S)z1Error 308 -- relocated, but turn POST into error.)r_rrDs       rTrbzFancyURLopener.http_error_308rHrUcd|vrtj|||||||d}tjd|}	|	stj|||||||	j	\}
}|
jdk7rtj|||||||stj||||||d|jzdz}|t||||St|||||S)z_Error 401 -- authentication required.
        This function supports Basic authentication only.r![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"rretry__basic_authr9rrmatchrrrr
rrOrtrrrurPr.stuffrOrTrrjs
             rTrzFancyURLopener.http_error_401sW,((sB)0&'
C*+?G((sB)0&'
C
<<>W$((sB)0&'
C((sB
$))#m3<%74%c511%74%c5$77rUcd|vrtj|||||||d}tjd|}	|	stj|||||||	j	\}
}|
jdk7rtj|||||||stj||||||d|jzdz}|t||||St|||||S)zeError 407 -- proxy authentication required.
        This function supports Basic authentication only.rrKrretry_proxy_rMrNrPs
             rTrzFancyURLopener.http_error_407s w.((sB)0&'
C,-?G((sB)0&'
C
<<>W$((sB)0&'
C((sB
		)M9<%74%c511%74%c5$77rUct|\}}d|z|z}|jd}t|\}}	t|	\}	}
|	jddz}|	|d}	|j	|	||\}}
|s|
syt|ddt|
dd|	}	d|	z|
z|jd<||j
|S|j
||S)Nhttp://rrer`rrr{r
rxrrget_user_passwdr
rNrrOrrPrrrDrfrr
proxyselectorrrmrs              rTretry_proxy_http_basic_authz*FancyURLopener.retry_proxy_http_basic_auths#ChT!H,V$'.#-i#8 	=NN3!#abM	++Iua@f"'2"6"'R"8)E	(94}DV<99V$$99VT**rUct|\}}d|z|z}|jd}t|\}}	t|	\}	}
|	jddz}|	|d}	|j	|	||\}}
|s|
syt|ddt|
dd|	}	d|	z|
z|jd<||j
|S|j
||S)Nhttps://rrer`rrr{rVrXs              rTretry_proxy_https_basic_authz+FancyURLopener.retry_proxy_https_basic_auths#Chd"X-W%'.#-i#8 	=NN3!#abM	++Iua@f"'2"6"'R"8)E	 *Y 6 FW<99V$$99VT**rUc t|\}}|jddz}||d}|j|||\}}|s|syt|ddt|dd|}d|z|z}	||j	|	S|j	|	|S)Nrer`rrr{rUr
rrWr
rN
rrOrrPrrrrmrrDs
          rTrz$FancyURLopener.retry_http_basic_auth	s#ChIIcNQABx++D%;f"4b1"63T;T!H,<99V$$99VT**rUc t|\}}|jddz}||d}|j|||\}}|s|syt|ddt|dd|}d|z|z}	||j	|	S|j	|	|S)Nrer`rrr{r\r_r`s
          rTretry_https_basic_authz%FancyURLopener.retry_https_basic_auth	s#ChIIcNQABx++D%;f"4b1"63T;d"X-<99V$$99VT**rUc|dz|jz}||jvr|r|j|=n|j|S|j||\}}|s|r||f|j|<||fS)Nre)rr:prompt_user_passwd)rrrrrrmrs       rTrWzFancyURLopener.get_user_passwd$	svckDJJL($//!OOC(s++..tU;f64.4??3/V|rUc	ddl}	td|d|d}|jd|d|d|d}||fS#t$r
tYywxYw)	z#Override this in a GUI environment!rNzEnter username for z at z: zEnter password for z in r)getpassinputKeyboardInterruptprint)rrrrfrmrs      rTrdz!FancyURLopener.prompt_user_passwd/	sT	E4HID__ud&$%F< 	G	s07A
A
rW)NF)r)rrrr6rrr^r@r_r`rarbrrrZr]rrbrWrdrrUrTr:r:asmI?$!8LLNNFJ82FJ82+$+$++	
rUr:cDttjdatS)z8Return the IP address of the magic hostname 'localhost'.r~)
_localhostrrrrUrTr~r~?	s ))+6
rUct:	ttjtjdatStS#tj
$r)ttjddaYtSwxYw)z,Return the IP addresses of the current host.r;r~)	_thishostrrrrrrrUrTr%r%G	sw	Gf55f6H6H6JKANOI9	Gf55kB1EFI	Gs3A4BBc:tddl}|jatS)z1Return the set of errors raised by the FTP class.Nr)
_ftperrorsrr)rs rTr,r,R	s&&
rUcDttjdatS)z%Return an empty email Message object.r)
_noheadersrrrrUrT	noheadersrr[	s ..r2
rUc@eZdZdZ		d
dZdZdZdZdZdZ	d	Z
y)rz;Class used by open_ftp() for cache of open FTP connections.Nc||_||_||_||_||_||_d|_||_	|jy#|jxYwr)
rmrrrrrQrefcount	keepaliveinitr)rrmrrrrrQrs        rTrzftpwrapper.__init__h	s[				
#	IIK	JJLsAAcddl}d|_|j|_|jj	|j
|j|j|jj|j|jdj|j}|jj|y)NrrO)rbusyFTPrNconnectrrrQloginrmrrrcwd)rr_targets   rTrwzftpwrapper.initx	sw	::<DIIt||<tyy$++.((499%WrUc8ddl}|j|dvrd}d}nd|z}d}	|jj|d}|r&|s$	d|z}|jj
|\}}|s|jjd|rY|jj}			|jj|	|jj|	d|z}nd}|jj
|\}}d|_t|jd
|j}
|xj dz
c_|j#|
fS#|j$r/|j|jj|YTwxYw#|j$r+}t|dddk7rtd	||Yd}~cd}~wwxYw#|j$r}td
|z|d}~wwxYw#|jj|	wxYw)Nr)r(rzTYPE Ar`zTYPE zRETR r550r*z
ftp error: %rzLIST LISTr)rendtransferrNvoidcmdrrwntransfercmd
error_permrrpwdr}ryrmakefile
file_closerur)rrYrrcmdisdirrrrRrftpobjs           rTrzftpwrapper.retrfile	s:XsqudNcAE	"HHS!
Gn $ 5 5c :
gHHX&hhlln&MT*HHLL%n HH11#6MD'	dmmD14??C




  G  	"IIKHHS!	"$$
Gv;r?e+"[#9:F,
G",,M&'?@fLMHHLL%sME#F&G:FFG( GGG9%G44G99G<<Hc|jsyd|_	|jjy#t$rYywxYwr)ryrNvoidrespr,rs rTrzftpwrapper.endtransfer	s<yy		HH{		s1
AAcRd|_|jdkr|jyy)NFr)rvru
real_closers rTrzftpwrapper.close	s$==AOOrUc|j|xjdzc_|jdkr|js|jyyy)Nr`r)rrurvrrs rTrzftpwrapper.file_close	s@


==AdnnOO'5rUc|j	|jjy#t$rYywxYwrW)rrNrr,rs rTrzftpwrapper.real_close	s5	HHNN{		s-
==)NT)rrrr6rrwrrrrrrrUrTrre	s/E?C  *!X
rUrci}g}tjjD]s}t|dkDs|ddk(s|ddj	dk(s2tj|}|ddj	}|j|||f|so|||<udtjvr|j
dd|D])\}}}|ddd	k(s|r|||<|j
|d+|S)
aReturn a dictionary of scheme -> proxy server URL mappings.

    Scan the environment for variables named <scheme>_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.
    rirNrfREQUEST_METHODr_proxy)reenvironrsrorrlr)rxenvironmentrjr
proxy_names     rTgetproxies_environmentr	sGK

!,t9q=T"X_bc1Bg1MJJt$Ecr*JeZ89&+
#,2::%FD!#..eZ9 &+
#J-
.NrUc|
t}	|d}|dk(ry|j}t|\}}|j	dD]k}|j}|s|j
d}|j}||k(s||k(ryd|z}|j|s|j|skyy#t$rYywxYw)zTest if proxies should not be used for a particular host.

    Checks the proxy dict for the value of no_proxy, which should
    be a list of comma separated DNS suffixes, or '*' for all hosts.

    noF*Tr.)rrrrrrlstripr)rrxno_proxyhostonlyrrjs      rTproxy_bypass_environmentr	s(*4=3::<D%NHds#	zz|;;s#D::<D444<:D  &$--*=	)sB77	CCcddlm}t|\}}d}d|vr|dryd}|jdd	D]}|stjd
|}||	tj|}||}||jd}	|jd}
|
'd
|jdjddzz}
nt|
dd}
|
dks|
dkDrd|
z
}
||
z	|	|
z	k(sy|||syy#t$rYwxYw)aj
    Return True iff this host shouldn't be accessed using a proxy

    This function uses the MacOSX framework SystemConfiguration
    to fetch the proxy information.

    proxy_settings come from _scproxy._get_proxy_settings or get mocked ie:
    { 'exclude_simple': bool,
      'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.1', '10.0/16']
    }
    r)fnmatchc|jd}ttt|}t	|dk7r
|gdzdd}|ddz|ddzz|dd	zz|d
zS)Nrr;)rrrrrr`rr;rr)rrrrmro)ipAddrrs  rTip2numz,_proxy_bypass_macosx_sysconf.<locals>.ip2num#
smS!Se_%u:?\)2A.EaB58r>2eAh!mDuQxOOrUrexclude_simpleTN
exceptionsrz(\d+(?:\.\d+)*)(/\d+)?r`r;r F)rrrrrOrrr~groupcountrm)rproxy_settingsrrrrhostIPrrErmasks           rT_proxy_bypass_macosx_sysconfr
s9 %NHdP$*+
F##L"5hHH.6=~#11(;F#F^F!''!*%D771:D|AGGAJ,,S1A5648}ax4"99D$DDL1
T5
!=@-sC??	D
Ddarwin)_get_proxy_settings_get_proxiesc.t}t||SrW)rr)rrs  rTproxy_bypass_macosx_sysconfrW
s,.+D.AArUctS)zReturn a dictionary of scheme -> proxy server URL mappings.

        This function uses the MacOSX framework SystemConfiguration
        to fetch the proxy information.
        )rrrUrTgetproxies_macosx_sysconfr[
s~rUcHt}|rt||St|S)zReturn True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or from the MacOSX framework SystemConfiguration.

        )rrrrrxs  rTrre
s')*+D'::.t44rUc.txs
tSrW)rrrrUrTr6r6r
s%'F+D+FFrUci}	ddl}	|j|jd}|j	|dd}|rt|j	|dd}d|vrd|vrdj
|}|jdD]F}|jdd	\}}tjd
|s|dvrd|z}n
|d
k(rd|z}|||<H|jd
rJtjdd|d
}|jdxs||d<|jdxs||d<|j|S#t$r|cYSwxYw#tttf$rY|SwxYw)zxReturn a dictionary of scheme -> proxy server URL mappings.

        Win32 uses the registry to store proxies.

        rN;Software\Microsoft\Windows\CurrentVersion\Internet SettingsProxyEnableProxyServerrrr/zhttp={0};https={0};ftp={0}r`z
(?:[^/:]+)://)rrrNrUsockszsocks://z	^socks://z	socks4://rr)winregImportErrorOpenKeyHKEY_CURRENT_USERQueryValueExrrrrrOrrCloser~rEr)rxrinternetSettingsproxyEnableproxyServerpraddresss        rTgetproxies_registryrw
s	"	%~~f.F.FN P --.>/<>>?AK!&"5"56F7D#FFG#IJk)c.D">"E"Ek"RK$**3/
0A()Q%Hg88OW=#'??&/'&9G%0&07&:G(/GH%
0;;w' ff\;@PQG&-kk&&9&DWGFO'.{{7';'FwGG$""$M	N	BY/	
	s#D:D/E:EEE#"E#c.txs
tS)zReturn a dictionary of scheme -> proxy server URL mappings.

        Returns settings gathered from the environment, if specified,
        or the registry.

        )rrrrUrTr6r6
s&'@+>+@@rUc	ddl}	|j|jd}|j	|dd}t|j	|dd}|r|syt|\}}|g}	tj|}||k7r|j|	tj|}||k7r|j||jd}|D]r}	|	dk(rd|vry|	jdd	}	|	jd
d}	|	jdd}	|D]*}
tj|	|
tj s)yty#t$rYywxYw#t$rYywxYw#t$rYwxYw#t$rYwxYw)
Nrrr
ProxyOverrider/z<local>rr`z\.rz.*?)rrrrrrr~rrrrlgetfqdnrrCrrOr)rrrr
proxyOverriderawHostraddrfqdnrrs           rTproxy_bypass_registryr
s			%~~f.F.FN P --.>/<>>?AK 3 34D5D!FFG!IJM
-"4(
y	''0DwD!	>>'*DwD!&++C0
!		Dy g%<<U+D<<U+D<<T*D
88D#rtt,
		[								sGE
AE-+E++E:
	EE	E('E(+	E76E7:	FFcHt}|rt||St|S)zReturn True, if host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.

        )rrrrs  rTrr
s')*+D'::(..rUrerW)}r6rrrrhttp.clientrrrerrrVrrrhrbrBurllib.errorrrrurllib.parserrrr	r
rrr
rrrrrrrrrrurllib.responserrrGrFr__all__version_inforrMrr1r2rkr7r8rASCIIrrrrr3rr0rrror r!r"r#r$r%r&urandomrr'r(r)r3r*rrrLrlrr/rrr+rr,r-r.r+rj
nturl2pathr5r4rr9r:rkr~rmr%ror,rqrrrrrrplatform_scproxyrrrrrr6rrrrUrT<module>rsCf
			


CB"""""
5I$((!,,
F$B$BM+45$M+^:xrzz(BHH- k"k"ZI+I+^"H88&##";k;n2+n2b,B)>;)>V=*=*@GoG3#B3>k#k#^3[4k zzOOdK)B$
[*C
s+sl3%34;;)*8*8$NN>"#+#$6[6
)*V11+11f7,7,r3j3j:+:B77d?55!
++DXYXz

	

aaH#J J>B<<8:B5GWW_/bA0d/(J+LGTIs:KKK