Your IP : 18.222.162.0


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/urllib.pyo

�
�mec@s�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z
dddddd	d
ddd
ddddddddddddddddddgZd Zd!Z
ejd"kr�dd#lmZmZn:ejd$kr dd#lmZmZnd%�Zd&�Zeaeed'�Zeeed(�Zd)�ZyddlZWn
eZnXeZd*efd+��YZiZdfd,��YZdefd-��YZ ea!d.�Z"ea#d/�Z$ea%d0�Z&ea'd1�Z(d2fd3��YZ)d4fd5��YZ*d6e*fd7��YZ+d8e*fd9��YZ,d:e*fd;��YZ-ye.Wne/k
r�d<�Z0n
Xd=�Z0d>�Z1d?�Z2ea3d@�Z4ea5dA�Z6ea7dB�Z8ea9dC�Z:ea;dD�Z<ea=ddE�Z>ea?dF�Z@eaAdG�ZBdH�ZCeaDdI�ZEdJZFeGdK�eFD��ZHejIdL�ZJdM�ZKdN�ZLdOZMiZNxfeOePdP�eQeRePdP����D]=\ZSZTeSdQko�eTeMkr�eTndRjUeS�eNeT<q�WiZVdSdT�ZWdUdV�ZXdWdX�ZYdY�ZZdZ�Z[ej\d[kr~dd\l]m^Z^m_Z_d]�Z`d^�Zad_�Zbd`�ZcnBejd"kr�da�Zddb�Zcdc�Zedd�ZbneZZce[Zbde�Zfdf�ZgdS(gs�Open 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.)
i����N(turljointurlopent	URLopenertFancyURLopenerturlretrievet
urlcleanuptquotet
quote_plustunquotetunquote_plust	urlencodeturl2pathnametpathname2urltsplittagt	localhosttthishostt	ftperrorstbasejointunwrapt	splittypet	splithostt	splitusertsplitpasswdt	splitportt
splitnportt
splitqueryt	splitattrt
splitvaluet
getproxiess1.17i
tnt(RRtriscoscCs
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.7/urllib.pyR5scCs
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.7/urllib.pyR:scCs�ddlm}|ddd�|dk	r>td|�}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(tst�antj||||�S(N(R%Rtretrieve(R'tfilenamet
reporthookR(((s/usr/lib64/python2.7/urllib.pyRZscCs+trtj�ntj�tj�dS(N(R%tcleanupt
_safe_quoterstcleartftpcache(((s/usr/lib64/python2.7/urllib.pyR_s

tContentTooShortErrorcBseZd�ZRS(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.pyR1nscBs�eZdZdZdeZdd�Zd�Zd�Z	d�Z
d�Zdd�Zdd�Z
dd	�Zdddd
�Zdd�Zdd�Zd
�Zer�dd�Znd�Zd�Zd�Zdd�ZRS(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.pyR3�s			cCs|j�dS(N(tclose(R5((s/usr/lib64/python2.7/urllib.pyt__del__�scCs|j�dS(N(R-(R5((s/usr/lib64/python2.7/urllib.pyRD�scCsi|jrLx6|jD]+}y|j|�Wqtk
r=qXqW|j2n|jre|jj�ndS(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	addheader�scCs�tt|��}t|dd�}|jrn||jkrn|j|\}}t|d�}t|||�St|�\}}|s�d}n||jkr�|j|}t|�\}}	t|	�\}
}|
|f}nd}d|}||_
|jdd�}t||�s%|dkrQ|r>|j
|||�S|j||�Sny9|dkrst||�|�St||�||�SWn2tjk
r�}
td	|
ftj�d
�nXdS(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|f�dS(s/Overridable interface to open unknown URL type.s	url errorsunknown url typeN(RR2(R5R]R(RSR'((s/usr/lib64/python2.7/urllib.pyRW�scCs,t|�\}}tdd||f�dS(s/Overridable interface to open unknown URL type.s	url errorsinvalid proxy for %sN(RR2(R5RaR]R(RSR'((s/usr/lib64/python2.7/urllib.pyRV�sc
Cs�tt|��}|jr5||jkr5|j|St|�\}}|dkr�|sf|dkr�yC|j|�}|j�}|j�tt	|�d�|fSWq�t
k
r�q�Xn|j||�}z�|j�}	|r�t|d�}
n�ddl}t|�\}}
t	|
p#d�\}}
t
|
p;d�\}
}t|
pSd�\}
}tjj|
�d}|j|�\}}|jj|�tj|d�}
z�||	f}|jdk	r�||j|<nd
}d}d	}d	}d
|	krt|	d�}n|r*||||�nxb|j|�}|dkrLPn|t|�7}|
j|�|d7}|r-||||�q-q-Wd|
j�XWd|j�X|d	kr�||kr�td||f|��n|S(stretrieve(url) returns (filename, headers) for a local object
        or (tempfilename, headers) for a remote object.RGitwbi����Ntiiiscontent-lengthsContent-Lengths1retrieval incomplete: got only %i out of %i bytesi (RRQRBRR$RPtinfoRDRRR2R&ttempfileRRR?tpathtsplitexttmkstempR>RHtfdopentinttreadtlentwriteR1(R5R'R+R,R(RSturl1R_thdrsR^ttfpRjtgarbageRktsuffixtfdtresulttbstsizeRptblocknumtblock((s/usr/lib64/python2.7/urllib.pyR*�sj



cCs=ddl}d}d}t|t�rit|�\}}|r`t|�\}}t|�}n|}n�|\}}t|�\}}t|�\}	}
|
}d}|	j�dkr�d}n^t|
�\}}
|r�t|�\}}n|r	d|	||
f}nt	|�r|}n|s0t
d�n|rZt|�}tj|�j
�}nd}|r�t|�}tj|�j
�}nd}|j|�}
|dk	r�|
jd|�|
jdd	�|
jd
dt|��n|
jd|�|r|
jd
d|�n|r2|
jdd|�n|rK|
jd|�nx|jD]}|
j|�qUW|
j|�|
j�\}}}|
j�}|dkr�|r�|j�nt
d�nd|ko�dknr�t||d||�S|dkr|j|||||�S|j||||||�SdS(sUse HTTP protocol.i����Nthttps	%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 linei�i,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(R�tuser_passwdtproxy_passwdRcRdtrealhostR`trestt
proxy_authtauththRIterrcodeterrmsgR^R_((s/usr/lib64/python2.7/urllib.pyt	open_http$sx			

	c
Cs�d|}t||�rwt||�}|dkrO||||||�}	n|||||||�}	|	rw|	Sn|j|||||�S(s�Handle 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_R�R�R^R(RetmethodRy((s/usr/lib64/python2.7/urllib.pyR�ms
cCs#|j�td|||f�dS(s>Default error handler: close the connection and raise IOError.s
http errorN(RDR2(R5R'R_R�R�R^((s/usr/lib64/python2.7/urllib.pyR�|s
cCs=ddl}d}d}t|t�rit|�\}}|r`t|�\}}t|�}n|}n�|\}}t|�\}}t|�\}	}
|
}d}|	j�dkr�d}nIt|
�\}}
|r�t|�\}}n|r	d|	||
f}n|st	d�n|rEt|�}t
j|�j�}nd}|rut|�}t
j|�j�}nd}|j
|dd|jd	|j�}
|dk	r�|
jd
|�|
jdd�|
jd
dt|��n|
jd|�|r|
jdd|�n|r2|
jdd|�n|rK|
jd|�nx|jD]}|
j|�qUW|
j|�|
j�\}}}|
j�}|dkr�|r�|j�nt	d�nd|ko�dknr�t||d||�S|dkr|j|||||�S|j||||||�SdS(sUse HTTPS protocol.i����Nthttpss	%s://%s%sshttps errors
no host giveniR9R:RsContent-Types!application/x-www-form-urlencodedsContent-Lengths%dR�sProxy-AuthorizationsBasic %sR�R�shttp protocol errorsgot a bad status linei�i,shttps:(shttps errors
no host given(shttp protocol errorisgot a bad status lineN(R�R$R�R�RRRRR�R2R�R�R�tHTTPSR9R:R�R�RqR=R�R�R�RDRRR�(R5R'R(R�R�R�RcRdR�R`R�R�R�R�RIR�R�R^R_((s/usr/lib64/python2.7/urllib.pyt
open_https�s|				

	cCsut|t�std
�n|d dkrd|dd!dkrd|dd!j�dkrd|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(R�R�R2R�topen_ftpRP(R5R'((s/usr/lib64/python2.7/urllib.pyt	open_file�s
<
cCsddl}ddl}ddl}yddlm}Wn!tk
r[ddlm}nXt|�\}}t|�}ytj	|�}	Wn.t
k
r�}
t|
j|
j
|
j��nX|	j}|jj|	jdt�}|j|�d}
|j|d|
p
d||f��}|s�|}|d d	krFd
|}n#|d dkritd
|��ntt|d�||�St|�\}}|r�tj|�t�t�fkr�|}|d d	kr�d
|}ntt|d�||�Std�dS(sUse local file.i����N(tStringIOtusegmtis6Content-Type: %s
Content-Length: %d
Last-modified: %s
s
text/plainiR�sfile://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	mimetoolstemail.utilst	cStringIOR�tImportErrorRRR?tstatRFR2terrnotstrerrorR+tst_sizetutilst
formatdatetst_mtimetTruet
guess_typetMessaget
ValueErrorRRR&RRYt
gethostbynameRR(R5R'R�R�temailR�RcRGt	localnametstatsteR{tmodifiedtmtypeR^turlfiletport((s/usr/lib64/python2.7/urllib.pyRP�sD$
		

!

c
Cs�t|t�std�nddl}ddl}yddlm}Wn!tk
rjddlm}nXt|�\}}|s�td�nt	|�\}}t
|�\}}|r�t|�\}}	nd}	t
|�}|p�d}|	p�d}	tj|�}|s%ddl}
|
j}nt|�}t|�\}}t
|�}|jd�}|d |d}}
|r�|d	r�|d
}n|r�|d	r�d|d	<n|||dj|�f}t|j�tkr,xJ|jj�D]6}||kr�|j|}|j|=|j�q�q�Wny?||jkr`t||	|||�|j|<n|
sod}nd}xM|D]E}t|�\}}|j�d
kr||dkr||j�}q|q|W|j|j|
|�\}}|j d|�d	}d}|r|d|7}n|dk	rA|d	krA|d|7}n|j!||��}t"||d|�SWn2t#�k
r�}td|ft$j%�d�nXdS(sUse FTP protocol.s	ftp errors8proxy support for ftp protocol currently not implementedi����N(R�s
no host givenRhR�iitDtIRStatAtitdsftp:sContent-Type: %s
sContent-Length: %d
i(s	ftp errors8proxy support for ftp protocol currently not implemented(s	ftp errors
no host given(R�R�R�R�R�R�(&R�R�R2R�R�R�R�R�RRRRR$RRYR�tftplibtFTP_PORTRoRtsplittjoinRqR0tMAXFTPCACHEtkeysRDt
ftpwrapperRR�tuppertretrfileR�R�RRRR[R\(R5R'R�R�R�RcRkR�tusertpasswdR�tattrstdirsRGtkeytktvRStattrtvalueR_tretrlenR�R^Rf((s/usr/lib64/python2.7/urllib.pyR��sx




"	
cCs�t|t�std�nddl}yddlm}Wn!tk
r^ddlm}nXy|jdd�\}}Wntk
r�td�nX|s�d	}n|j	d
�}|dkr�d||kr�||d}|| }nd
}g}|j
dtjdtj
tj����|j
d|�|dkrTtj|�}nt|�}|j
dt|��|j
d
�|j
|�dj|�}||�}	|j|	d�}
t|	|
|�S(sUse "data" URL.s
data errors9proxy support for data protocol currently not implementedi����N(R�t,isbad data URLstext/plain;charset=US-ASCIIt;it=RhsDate: %ss%a, %d %b %Y %H:%M:%S GMTsContent-type: %sR�sContent-Length: %ds
(s
data errors9proxy support for data protocol currently not implemented(s
data errorsbad data URL(R�R�R2R�R�R�R�R�R�trfindRHttimetstrftimetgmtimeR�tdecodestringRRqR�R�RR(R5R'R(R�R�RStsemitencodingRftfR^((s/usr/lib64/python2.7/urllib.pyt	open_data6s@


	


N(R7R8t__doc__R$R>t__version__R<R3RERDR-RJR&RWRVR*R�R�R�t	_have_sslR�R�RPR�R�(((s/usr/lib64/python2.7/urllib.pyRts*
				&AI	H			%	>cBs�eZdZd�Zd�Zdd�Zd�Zdd�Zdd�Z	dd�Z
dd�Zdd	�Zdd
�Z
dd�Zdd�Zdd
�Zdd�Zd�ZRS(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_R�R�R^((s/usr/lib64/python2.7/urllib.pyR�msc	Cs�|jd7_|jrm|j|jkrmt|d�rE|j}n	|j}d|_|||dd|�S|j||||||�}d|_|S(s%Error 302 -- relocated (temporarily).ithttp_error_500ii�s)Internal Server Error: Redirect Recursion(R�R�RUR�R�tredirect_internal(	R5R'R_R�R�R^R(tmethRy((s/usr/lib64/python2.7/urllib.pythttp_error_302qs		
		c	Cs�d|kr|d}nd|kr2|d}ndS|j�t|jd||�}|j�}|jd�p�|jd�p�|jd�s�td||d||��n|j|�S(	Ntlocationturit:shttp://shttps://sftp://sredirect errors) - Redirection to url '%s' is not allowed(RDRRSR�t
startswithR2R&(	R5R'R_R�R�R^R(tnewurltnewurl_lower((s/usr/lib64/python2.7/urllib.pyR��s 


	cCs|j||||||�S(s*Error 301 -- also relocated (permanently).(R�(R5R'R_R�R�R^R(((s/usr/lib64/python2.7/urllib.pythttp_error_301�scCs|j||||||�S(s;Error 303 -- also relocated (essentially identical to 302).(R�(R5R'R_R�R�R^R(((s/usr/lib64/python2.7/urllib.pythttp_error_303�scCsE|dkr(|j||||||�S|j|||||�SdS(s1Error 307 -- relocated, but turn POST into error.N(R$R�R�(R5R'R_R�R�R^R(((s/usr/lib64/python2.7/urllib.pythttp_error_307�sc
Csd|kr+tj||||||�n|d}ddl}|jd|�}	|	sxtj||||||�n|	j�\}
}|
j�dkr�tj||||||�nd|jd}|dkr�t||�||�St||�|||�SdS(s_Error 401 -- authentication required.
        This function supports Basic authentication only.swww-authenticatei����Ns![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"tbasictretry_t_basic_auth(	RR�tretmatchtgroupsR�RSR$RX(
R5R'R_R�R�R^R(tstuffR�R�tschemetrealmRe((s/usr/lib64/python2.7/urllib.pythttp_error_401�s"
c
Csd|kr+tj||||||�n|d}ddl}|jd|�}	|	sxtj||||||�n|	j�\}
}|
j�dkr�tj||||||�nd|jd}|dkr�t||�||�St||�|||�SdS(seError 407 -- proxy authentication required.
        This function supports Basic authentication only.sproxy-authenticatei����Ns![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"R�tretry_proxy_R�(	RR�R�R�R�R�RSR$RX(
R5R'R_R�R�R^R(R�R�R�R�RRe((s/usr/lib64/python2.7/urllib.pythttp_error_407�s"
cCs	t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|}	|j|	||�\}}
|p�|
s�dSt|dd�dt|
dd�d|	}	d|	|
|jd<|dkr�|j|�S|j||�SdS(Nshttp://R~t@iRKRhR�(RR"Rtfindtget_user_passwdR$RR&(R5R'RR(RcRdR�RaR`Rbt
proxyselectorR�R�R�((s/usr/lib64/python2.7/urllib.pytretry_proxy_http_basic_auth�s

.
cCs	t|�\}}d||}|jd}t|�\}}	t|	�\}	}
|	jd�d}|	|}	|j|	||�\}}
|p�|
s�dSt|dd�dt|
dd�d|	}	d|	|
|jd<|dkr�|j|�S|j||�SdS(Nshttps://R�RiRKRhR�(RR"RRRR$RR&(R5R'RR(RcRdR�RaR`RbRR�R�R�((s/usr/lib64/python2.7/urllib.pytretry_proxy_https_basic_auth�s

.
c
Cs�t|�\}}|jd�d}||}|j|||�\}}|pS|sZdSt|dd�dt|dd�d|}d||}	|dkr�|j|	�S|j|	|�SdS(NRiRKRhR�shttp://(RRRR$RR&(
R5R'RR(RcRdR�R�R�R�((s/usr/lib64/python2.7/urllib.pytretry_http_basic_auth�s
.
c
Cs�t|�\}}|jd�d}||}|j|||�\}}|pS|sZdSt|dd�dt|dd�d|}d||}	|dkr�|j|	�S|j|	|�SdS(NRiRKRhR�shttps://(RRRR$RR&(
R5R'RR(RcRdR�R�R�R�((s/usr/lib64/python2.7/urllib.pytretry_https_basic_auths
.
icCs�|d|j�}||jkrD|r6|j|=qD|j|Sn|j||�\}}|sh|r~||f|j|<n||fS(NR(R�R�tprompt_user_passwd(R5RcRtclear_cacheR�R�R�((s/usr/lib64/python2.7/urllib.pyRs
cCsfddl}y@td||f�}|jd|||f�}||fSWntk
raHdSXdS(s#Override this in a GUI environment!i����NsEnter username for %s at %s: s#Enter password for %s in %s at %s: (NN(tgetpasst	raw_inputtKeyboardInterruptR$(R5RcRRR�R�((s/usr/lib64/python2.7/urllib.pyRs	
	
N(R7R8R�R3R�R$R�R�R�R�R�RRRR	R
RRR(((s/usr/lib64/python2.7/urllib.pyRds 			

cCs"tdkrtjd�antS(s8Return the IP address of the magic hostname 'localhost'.RN(t
_localhostR$RYR�(((s/usr/lib64/python2.7/urllib.pyR,scCs(tdkr$tjtj��antS(s*Return the IP address of the current host.N(t	_thishostR$RYR�tgethostname(((s/usr/lib64/python2.7/urllib.pyR4scCs(tdkr$ddl}|jantS(s1Return the set of errors raised by the FTP class.i����N(t
_ftperrorsR$R�t
all_errors(R�((s/usr/lib64/python2.7/urllib.pyR<scCsytdkruddl}yddlm}Wn!tk
rOddlm}nX|j|�d�atjj�ntS(s)Return an empty mimetools.Message object.i����N(R�i(	t
_noheadersR$R�R�R�R�R�R_RD(R�R�((s/usr/lib64/python2.7/urllib.pyt	noheadersEs
R�cBsVeZdZejed�Zd�Zd�Zd�Z	d�Z
d�Zd�ZRS(s;Class used by open_ftp() for cache of open FTP connections.cCsV||_||_||_||_||_||_d|_||_|j�dS(Ni(	R�R�RcR�R�ttimeouttrefcountt	keepalivetinit(R5R�R�RcR�R�Rt
persistent((s/usr/lib64/python2.7/urllib.pyR3Xs								cCs�ddl}d|_|j�|_|jj|j|j|j�|jj|j	|j
�x!|jD]}|jj|�qfWdS(Ni����i(
R�tbusytFTPtftptconnectRcR�RtloginR�R�R�tcwd(R5R�tdir((s/usr/lib64/python2.7/urllib.pyRes	cCsddl}|j�|dkr1d}d}nd|}d}y|jj|�Wn.|jk
r�|j�|jj|�nXd}|r|ry&d|}|jj|�\}}Wq|jk
r}t	|�d	 d
kr
t
d|ftj�d�q
qXn|s�|jjd�|r�|jj
�}	zMy|jj|�Wn2|jk
r�}t
d|ftj�d�nXWd|jj|	�Xd
|}nd}|jj|�\}}nd|_t|jd�|j�}
|jd7_|j�|
|fS(Ni����R�R�sTYPE AisTYPE isRETR it550s	ftp errorisLIST tLISTRL(R�R�(R�tendtransferRtvoidcmdRRR$tntransfercmdt
error_permR�R2R[R\tpwdR"Rtaddclosehooktmakefilet
file_closeRRD(R5RGRSR�tcmdtisdirtconnR�treasonR*tftpobj((s/usr/lib64/python2.7/urllib.pyR�nsL
	



&$
	
cCsB|js
dSd|_y|jj�Wnt�k
r=nXdS(Ni(RRtvoidrespR(R5((s/usr/lib64/python2.7/urllib.pyR&�s		cCs)t|_|jdkr%|j�ndS(Ni(tFalseRRt
real_close(R5((s/usr/lib64/python2.7/urllib.pyRD�s	cCsC|j�|jd8_|jdkr?|jr?|j�ndS(Nii(R&RRR5(R5((s/usr/lib64/python2.7/urllib.pyR-�s
cCs6|j�y|jj�Wnt�k
r1nXdS(N(R&RRDR(R5((s/usr/lib64/python2.7/urllib.pyR5�s

(
R7R8R�RYt_GLOBAL_DEFAULT_TIMEOUTR�R3RR�R&RDR-R5(((s/usr/lib64/python2.7/urllib.pyR�Us			+				taddbasecBs)eZdZd�Zd�Zd�ZRS(s(Base class for addinfo and addclosehook.cCs�||_|jj|_|jj|_t|jd�rK|jj|_nt|jd�ro|jj|_nd�|_t|jd�r�|jj|_t|jd�r�|jj|_q�ndS(Nt	readlinestfilenocSsdS(N(R$(((s/usr/lib64/python2.7/urllib.pyt<lambda>�st__iter__tnext(R_RptreadlineRUR8R9R;R<(R5R_((s/usr/lib64/python2.7/urllib.pyR3�s	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=|jj�nd|_dS(N(R$RpR=R8R9R_RD(R5((s/usr/lib64/python2.7/urllib.pyRD�s					(R7R8R�R3R@RD(((s/usr/lib64/python2.7/urllib.pyR7�s		R+cBs eZdZd�Zd�ZRS(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.pyR3�s	cCs?|jr.|j|j�d|_d|_ntj|�dS(N(RARBR$R7RD(R5((s/usr/lib64/python2.7/urllib.pyRD�s
		(R7R8R�R3RD(((s/usr/lib64/python2.7/urllib.pyR+�s	taddinfocBs eZdZd�Zd�ZRS(s.class to add an info() method to an open file.cCstj||�||_dS(N(R7R3R^(R5R_R^((s/usr/lib64/python2.7/urllib.pyR3�scCs|jS(N(R^(R5((s/usr/lib64/python2.7/urllib.pyRi�s(R7R8R�R3Ri(((s/usr/lib64/python2.7/urllib.pyRC�s	RRcBs5eZdZdd�Zd�Zd�Zd�ZRS(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.pyR3�s		cCs|jS(N(R^(R5((s/usr/lib64/python2.7/urllib.pyRi�scCs|jS(N(RD(R5((s/usr/lib64/python2.7/urllib.pytgetcode�scCs|jS(N(R'(R5((s/usr/lib64/python2.7/urllib.pytgeturl�sN(R7R8R�R$R3RiRERF(((s/usr/lib64/python2.7/urllib.pyRR�s
		cCsdS(Ni((tx((s/usr/lib64/python2.7/urllib.pyt_is_unicodescCs
t|t�S(N(R�tunicode(RG((s/usr/lib64/python2.7/urllib.pyRHscCsTt|�rPy|jd�}WqPtk
rLtdt|�d��qPXn|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('<URL:type://host/path>') --> 'type://host/path'.it<i����t>isURL:(R�(R'((s/usr/lib64/python2.7/urllib.pyR!s cCsvtdkr*ddl}|jd�antj|�}|rl|jd�}|j�|t|�dfSd|fS(s:splittype('type:opaquestring') --> 'type', 'opaquestring'.i����Ns
^([^/:]+):i(t	_typeprogR$R�tcompileR�tgroupR�Rq(R'R�R�R�((s/usr/lib64/python2.7/urllib.pyR*scCs�tdkr$tjdtj�antj|�}|r�|jd�}|jd�}|rz|jd�rzd|}n||fSd|fS(s;splithost('//host[:port]/path') --> 'host[:port]', '/path'.s//([^/#?]*)(.*)iiR�N(t	_hostprogR$R�RQtDOTALLR�RRR�(R'R�t	host_portRk((s/usr/lib64/python2.7/urllib.pyR8s

cCsYtdkr*ddl}|jd�antj|�}|rO|jdd�Sd|fS(sJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.i����Ns^(.*)@(.*)$ii(t	_userprogR$R�RQR�RR(RcR�R�((s/usr/lib64/python2.7/urllib.pyRHscCs_tdkr0ddl}|jd|j�antj|�}|rU|jdd�S|dfS(s/splitpasswd('user:passwd') -> 'user', 'passwd'.i����Ns^([^:]*):(.*)$ii(t_passwdprogR$R�RQtSR�RR(R�R�R�((s/usr/lib64/python2.7/urllib.pyRTscCsYtdkr*ddl}|jd�antj|�}|rO|jdd�S|dfS(s*splitport('host:port') --> 'host', 'port'.i����Ns^(.*):([0-9]+)$ii(t	_portprogR$R�RQR�RR(RcR�R�((s/usr/lib64/python2.7/urllib.pyRascCs�tdkr*ddl}|jd�antj|�}|r�|jdd�\}}y"|sltd�nt|�}Wntk
r�d}nX||fS||fS(s�Split 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.i����Ns^(.*):(.*)$iis	no digits(t
_nportprogR$R�RQR�RRR�Ro(RctdefportR�R�R�tnport((s/usr/lib64/python2.7/urllib.pyRms


cCsYtdkr*ddl}|jd�antj|�}|rO|jdd�S|dfS(s/splitquery('/path?query') --> '/path', 'query'.i����Ns^(.*)\?([^?]*)$ii(t
_queryprogR$R�RQR�RR(R'R�R�((s/usr/lib64/python2.7/urllib.pyR�scCsYtdkr*ddl}|jd�antj|�}|rO|jdd�S|dfS(s)splittag('/path#tag') --> '/path', 'tag'.i����Ns^(.*)#([^#]*)$ii(t_tagprogR$R�RQR�RR(R'R�R�((s/usr/lib64/python2.7/urllib.pyR
�scCs!|jd�}|d|dfS(sksplitattr('/path;attr1=value1;attr2=value2;...') ->
        '/path', ['attr1=value1', 'attr2=value2', ...].R�ii(R�(R'twords((s/usr/lib64/python2.7/urllib.pyR�scCsYtdkr*ddl}|jd�antj|�}|rO|jdd�S|dfS(s-splitvalue('attr=value') --> 'attr', 'value'.i����Ns^([^=]*)=(.*)$ii(t
_valueprogR$R�RQR�RR(R�R�R�((s/usr/lib64/python2.7/urllib.pyR�st0123456789ABCDEFabcdefccs?|]5}tD](}||tt||d��fVq
qdS(iN(t_hexdigtchrRo(t.0R�tb((s/usr/lib64/python2.7/urllib.pys	<genexpr>�ss([-]+)cCsOt|�r�d|kr|Stj|�}|dg}|j}xUtdt|�d�D];}|tt||��jd��|||d�qZWdj	|�S|jd�}t|�dkr�|S|dg}|j}x^|dD]R}y$|t
|d �||d�Wq�tk
r=|d�||�q�Xq�Wdj	|�S(s"unquote('abc%20def') -> 'abc def'.t%iiitlatin1Rh(RHt_asciireR�RHtrangeRqRR�tdecodeR�t	_hextochrtKeyError(tstbitstresRHR�titem((s/usr/lib64/python2.7/urllib.pyR�s.
	#

	

cCs|jdd�}t|�S(s%unquote('%7e/abc+def') -> '~/abc def't+t (RTR(Rm((s/usr/lib64/python2.7/urllib.pyR	�ssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-ii�s%{:02X}R�cCs�|s%|dkr!td��n|S|tf}yt|\}}Wnftk
r�tj�}|jg|D]}||f^qn�|j}t|}||ft|<nX|j	|�s�|Sdj
t||��S(squote('abc def') -> '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	TypeErrortalways_safeR.Rlt	_safe_maptcopytupdatet__getitem__trstripR�tmap(RmRKtcachekeytquotertsafe_maptc((s/usr/lib64/python2.7/urllib.pyR�s 
&	
RhcCs<d|kr/t||d�}|jdd�St||�S(s9Quote the query fragment of a URL; replacing ' ' with '+'RrRq(RRT(RmRK((s/usr/lib64/python2.7/urllib.pyRsic	Cs�t|d�r|j�}nby-t|�rJt|dt�rJt�nWn2tk
rtj�\}}}td|�nXg}|s�xc|D]E\}}tt	|��}tt	|��}|j
|d|�q�Wnx|D]\}}tt	|��}t|t	�r7t|�}|j
|d|�q�t|�rst|jdd��}|j
|d|�q�yt|�Wn8tk
r�tt	|��}|j
|d|�q�Xx/|D]'}|j
|dtt	|���q�Wq�Wdj
|�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 objectR�RJRTt&(RURRqR�ttupleRsR[R\RR�RHRHRKR�(	tquerytdoseqttytvattbtlR�R�telt((s/usr/lib64/python2.7/urllib.pyR
s< 



)cCsi}xPtjj�D]?\}}|j�}|r|ddkr|||d <qqWdtjkr{|jdd�n|S(sReturn 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.

    i����t_proxytREQUEST_METHODR~N(R?tenvironRR�tpopR$(R"ReR�((s/usr/lib64/python2.7/urllib.pytgetproxies_environmentLs
cCs�tjjdd�p'tjjdd�}|dkr:dSt|�\}}g|jd�D]}|j�^q\}x6|D].}|r{|j|�s�|j|�r{dSq{WdS(s�Test 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*iR�i(R?R�R;RR�R�tendswith(RcR�thostonlyR�Rat
no_proxy_listRe((s/usr/lib64/python2.7/urllib.pytproxy_bypass_environmentes*(
$tdarwin(t_get_proxy_settingst_get_proxiesc
Cs�ddl}ddl}ddlm}t|�\}}d�}t�}d|kri|dritSnd}x'|jdd
�D]}	|	s�q�n|jd|	�}
|
dk	r�|dkr�y|j	|�}||�}Wq�|j
k
r�q�q�Xn||
jd	��}|
jd
�}|dkrMd|
jd	�jd�d	}nt
|d	�}d|}||?||?kr�tSq�|||	�r�tSq�WtS(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.
        i����N(tfnmatchcSsy|jd�}tt|�}t|�dkrM|ddddgd }n|dd>|dd>B|dd>B|d	BS(
Nt.iiiiiiii(R�RzRoRq(tipAddrtparts((s/usr/lib64/python2.7/urllib.pytip2num�s
R�texclude_simplet
exceptionss(\d+(?:\.\d+)*)(/\d+)?iiii ((R�RYR�RR�R�R$R;R�R�RZRRtcountRoR4(
RcR�RYR�R�R�R�tproxy_settingsthostIPR�tmtbasetmask((s/usr/lib64/python2.7/urllib.pytproxy_bypass_macosx_sysconf}s@		

#
cCst�S(s�Return 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_sysconf�scCs!t�rt|�St|�SdS(N(R�R�R�(Rc((s/usr/lib64/python2.7/urllib.pyR��s	
cCst�pt�S(N(R�R�(((s/usr/lib64/python2.7/urllib.pyR�sc	Csmi}yddl}Wntk
r*|SXy!|j|jd�}|j|d�d}|rAt|j|d�d�}d|kr�x�|jd�D]Y}|jdd	�\}}ddl}|jd
|�s�d||f}n|||<q�WqA|d d
kr||d<qAd||d<d||d<d||d<n|j	�Wnt
ttfk
rhnX|S(sxReturn a dictionary of scheme -> proxy server URL mappings.

        Win32 uses the registry to store proxies.

        i����Ns;Software\Microsoft\Windows\CurrentVersion\Internet SettingstProxyEnableitProxyServerR�R�is^([^/:]+)://s%s://%sishttp:R~s	http://%ss
https://%sR�sftp://%sR(
t_winregR�tOpenKeytHKEY_CURRENT_USERtQueryValueExR�R�R�R�tClosetWindowsErrorR�Rs(	R"R�tinternetSettingstproxyEnabletproxyServertptprotocoltaddressR�((s/usr/lib64/python2.7/urllib.pytgetproxies_registry�s:
		

cCst�pt�S(s�Return a dictionary of scheme -> proxy server URL mappings.

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

        (R�R�(((s/usr/lib64/python2.7/urllib.pyR�scCs�yddl}ddl}Wntk
r0dSXyK|j|jd�}|j|d�d}t|j|d�d�}Wntk
r�dSX|s�|r�dSt|�\}}|g}y/t	j
|�}||kr�|j|�nWnt	jk
rnXy/t	j
|�}	|	|kr2|j|	�nWnt	jk
rInX|jd�}x�|D]�}
|
dkr�d|kr�d	Sn|
jdd
�}
|
jdd�}
|
jd
d�}
x*|D]"}|j|
||j�r�d	Sq�Wq`WdS(Ni����is;Software\Microsoft\Windows\CurrentVersion\Internet SettingsR�t
ProxyOverrideR�s<local>R�is\.R�s.*t?(R�R�R�R�R�R�R�R�RRYR�RHRZtgetfqdnR�RTR�R�(RcR�R�R�R�t
proxyOverridetrawHostR�taddrtfqdnttesttval((s/usr/lib64/python2.7/urllib.pytproxy_bypass_registrysT
		

	

cCs!t�rt|�St|�SdS(s�Return a dictionary of scheme -> proxy server URL mappings.

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

        N(R�R�R�(Rc((s/usr/lib64/python2.7/urllib.pyR�5s	
cCs�d}x$td�D]}|t|�}qW|d}tj�}t|�}t|�}tj�}||kr{dGHnt|�GHt|�GHt|�GHt||d�GdGHdS(NRhiisWrong!itsec(RiRcR�RRRMtround(RmR�tt0tqstuqstt1((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(hR�tstringRYR?R�R[R�R�turlparseRRt__all__R�R�Ret
nturl2pathRRt
rourl2pathR$R%RRRtsslR4R�R�R2R1R0RRRRRRRRRRR�R7R+RCRRRIt	NameErrorRHRQRRPRRSRRVRRWRRYRRZRR]RR^R
RR`RRbtdictRkRQRhRR	RtRutziptxrangeR�t	bytearrayR�R~tformatR.RRR
R�R�tplatformt_scproxyR�R�R�R�R�RR�R�R�R,(((s/usr/lib64/python2.7/urllib.pyt<module>s�			
	
���				_
"

				
									
		45'@			;			.			4