ACC SHELL

Path : /usr/lib/python/
File Upload :
Current File : //usr/lib/python/urllib.pyc

oMc"@sdZddkZddkZddkZddkZddkZddklZdddddd	d
ddd
ddddddddddddddddddgZ	d Z
d!Zeid"jodd#k
lZlZngeid$jodd#klZlZn=eid%jodd#klZlZnd&Zd'Zeaeed(Zeeed)Zd*ZyddkZWn
eZnXeZd+efd,YZhZdfd-YZdefd.YZea d/Z!ea"d0Z#ea$d1Z%ea&d2Z'd3fd4YZ(d5fd6YZ)d7e)fd8YZ*d9e)fd:YZ+d;e)fd<YZ,ye-Wne.j
od=Z/nXd>Z/d?Z0d@Z1ea2dAZ3ea4dBZ5ea6dCZ7ea8dDZ9ea:dEZ;ea<ddFZ=ea>dGZ?ea@dHZAdIZBeaCdJZDeEdKeFdLDZGeGiHdMeFdLDdNZIdOZJdPZKhZLdQdRZMdSdTZNdUdVZOdWZPdXZQeiRdYjo>ddZkSlTZTlUZUd[ZVd\ZWd]ZXd^ZYnEeid$jo(d_ZZd`ZYdaZ[dbZXn
ePZYeQZXdcZ\ddZ]gdeZ^dfZ_e`dgjoe_ndS(hsOpen an arbitrary URL.

See the following document for more info on URLs:
"Names and Addresses, URIs, URLs, URNs, URCs", at
http://www.w3.org/pub/WWW/Addressing/Overview.html

See also the HTTP spec (from which the error codes are derived):
"HTTP - Hypertext Transfer Protocol", at
http://www.w3.org/pub/WWW/Protocols/

Related standards and specs:
- RFC1808: the "relative URL" spec. (authoritative status)
- RFC1738 - the "URL standard". (authoritative status)
- RFC1630 - the "URI spec". (informational status)

The object returned by URLopener().open(file) will differ per
protocol.  All you know is that is has methods read(), readline(),
readlines(), fileno(), close() and info().  The read*(), fileno()
and close() methods work like those of open files.
The info() method returns a mimetools.Message object which can be
used to query various info about the object, if available.
(mimetools.Message objects are queried with the getheader() method.)
iN(turljointurlopent	URLopenertFancyURLopenerturlretrievet
urlcleanuptquotet
quote_plustunquotetunquote_plust	urlencodeturl2pathnametpathname2urltsplittagt	localhosttthishostt	ftperrorstbasejointunwrapt	splittypet	splithostt	splitusertsplitpasswdt	splitportt
splitnportt
splitqueryt	splitattrt
splitvaluet
getproxiess1.17i
tmac(RRtnttriscoscCs
t|S(sOS-specific conversion from a relative URL of the 'file' scheme
        to a file system path; not recommended for general use.(R(tpathname((s/usr/lib/python2.6/urllib.pyR4scCs
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/lib/python2.6/urllib.pyR9scCsddkl}|ddd|dj	otd|}n!tpt}|ant}|djo|i|S|i||SdS(s=Create a file-like object for the specified URL to read from.i(twarnpy3ksMurllib.urlopen() has been removed in Python 3.0 in favor of urllib2.urlopen()t
stacklevelitproxiesN(twarningsR!tNoneRt
_urlopenertopen(turltdataR#R!topener((s/usr/lib/python2.6/urllib.pyRGs	
	

cCs*tp
tanti||||S(N(R&Rtretrieve(R(tfilenamet
reporthookR)((s/usr/lib/python2.6/urllib.pyRYs
cCstotindS(N(R&tcleanup(((s/usr/lib/python2.6/urllib.pyR^stContentTooShortErrorcBseZdZRS(cCsti||||_dS(N(tIOErrort__init__tcontent(tselftmessageR2((s/usr/lib/python2.6/urllib.pyR1ls(t__name__t
__module__R1(((s/usr/lib/python2.6/urllib.pyR/kscBseZdZdZdeZddZdZdZ	dZ
dZddZddZ
dd	Zdddd
ZddZddZd
ZeoddZndZdZdZddZRS(s,Class to open URLs.
    This is a class rather than just a subroutine because we may need
    more than one set of global protocol-specific options.
    Note -- this is a base class for those who don't want the
    automatic handling of errors type 302 (relocated) and 401
    (authorization needed).sPython-urllib/%scKs|djo
t}nt|dp
td||_|id|_|id|_d|ifg|_	g|_
ti|_
d|_t|_dS(Nthas_keysproxies must be a mappingtkey_filet	cert_files
User-Agent(R%RthasattrtAssertionErrorR#tgetR8R9tversiont
addheaderst_URLopener__tempfilestostunlinkt_URLopener__unlinkt	tempcachetftpcache(R3R#tx509((s/usr/lib/python2.6/urllib.pyR1~s

			cCs|idS(N(tclose(R3((s/usr/lib/python2.6/urllib.pyt__del__scCs|idS(N(R.(R3((s/usr/lib/python2.6/urllib.pyRFscCso|ioFx8|iD]-}y|i|Wqtj
oqXqW|i2n|io|iindS(N(R?RBtOSErrorRCtclear(R3tfile((s/usr/lib/python2.6/urllib.pyR.s

	
cGs|ii|dS(sdAdd a header to be used by the HTTP interface only
        e.g. u.addheader('Accept', 'sound/basic')N(R>tappend(R3targs((s/usr/lib/python2.6/urllib.pyt	addheaderscCstt|}t|dd}|ioC||ijo3|i|\}}t|d}t|||St|\}}|p
d}n||ijoA|i|}t|\}}	t|	\}
}|
|f}nd
}d|}||_
|idd}t||p/|o|i
|||S|i||Sny;|d
jot|||St||||SWn4tij
o%}
td|
ftid	nXd
S(s6Use URLopener().open(file) instead of open(file, 'r').tsafes%/:=&?~#+!$,;'@()*[]|trbRJtopen_t-t_ssocket erroriN(RttoBytesRRCR't
addinfourlRR#RR%ttypetreplaceR:topen_unknown_proxytopen_unknowntgetattrtsocketterrorR0tsystexc_info(R3tfullurlR)R,theaderstfpturltypeR(tproxyt	proxyhostthosttselectortnametmsg((s/usr/lib/python2.6/urllib.pyR's8


	
cCs(t|\}}tdd|fdS(s/Overridable interface to open unknown URL type.s	url errorsunknown url typeN(RR0(R3R^R)RUR(((s/usr/lib/python2.6/urllib.pyRXscCs,t|\}}tdd||fdS(s/Overridable interface to open unknown URL type.s	url errorsinvalid proxy for %sN(RR0(R3RbR^R)RUR(((s/usr/lib/python2.6/urllib.pyRWscCstt|}|io||ijo|i|St|\}}|djom|p
|djoXy<|i|}|i}~tt|d|fSWqt	j
o	}	qXn|i
||}z|i}
|ot
|d}nddk}t|\}
}t|pd\}
}t|pd\}}
t
|pd\}}
tii|d}|i|\}}|ii|ti|d}z||
f}|idj	o||i|<nd
}d}d	}d	}|o5d
|
jot|
d}n||||nxf|i|}|djoPn|t|7}|i||d7}|o||||q<q<Wd|iXWd|iX~~|d	jo*||jotd||f|n|S(stretrieve(url) returns (filename, headers) for a local object
        or (tempfilename, headers) for a remote object.RJitwbiNtiiiscontent-lengthsContent-Lengths1retrieval incomplete: got only %i out of %i bytesi (RRSRCRR%topen_local_filetinfoRRR0R'ttempfileRRR@tpathtsplitexttmkstempR?RKtfdopentinttreadtlentwriteRFR/(R3R(R,R-R)RUturl1R`thdrsRgR_ttfpRltgarbageRmtsuffixtfdtresulttbstsizeRrtblocknumtblock((s/usr/lib/python2.6/urllib.pyR+sn"	



cCs{ddk}d}d}t|toEt|\}}|o"t|\}}t|}n|}n|\}}t|\}}t|\}	}
|
}d}|	idjo
d}net|
\}}
|ot|\}}n|od|	||
f}nt	|o
|}n|p
t
dn|o%ddk}|i|i
}nd}|o%ddk}|i|i
}
nd}
|i|}|dj	o>|id||idd	|id
dt|n|id||o|id
d|n|
o|idd|
n|o|id|nx|iD]}|i|qoW|i|dj	o|i|n|i\}}}|i}|djo"|o|int
dnd|jo
djnot||d||S|djo|i|||||S|i||||||SdS(sUse HTTP protocol.iNthttps	%s://%s%ss
http errors
no host giventPOSTsContent-Types!application/x-www-form-urlencodedsContent-Lengths%dtGETsProxy-AuthorizationsBasic %st
AuthorizationtHostshttp protocol errorisgot a bad status lineii,shttp:(s
http errors
no host given(shttp protocol errorisgot a bad status lineN(thttplibR%t
isinstancetstrRRRRtlowertproxy_bypassR0tbase64t	b64encodetstriptHTTPt
putrequestt	putheaderRsR>t
endheaderstsendtgetreplytgetfileRFRTt
http_error(R3R(R)Rtuser_passwdtproxy_passwdRdRetrealhostRatrestRt
proxy_authtauththRLterrcodeterrmsgR_R`((s/usr/lib/python2.6/urllib.pyt	open_http!s~











c
Csd|}t||oct||}|djo||||||}	n|||||||}	|	o|	Sn|i|||||S(sHandle http errors.
        Derived class can override this, or provide specific handlers
        named http_error_DDD where DDD is the 3-digit error code.s
http_error_%dN(R:RYR%thttp_error_default(
R3R(R`RRR_R)RftmethodR{((s/usr/lib/python2.6/urllib.pyRls

	cCs/|i}|itd|||fdS(s>Default error handler: close the connection and raise IOError.s
http errorN(RrRFR0(R3R(R`RRR_tvoid((s/usr/lib/python2.6/urllib.pyR{s
cCsyddk}d}d}t|toEt|\}}|o"t|\}}t|}n|}n|\}}t|\}}t|\}	}
|
}d}|	idjo
d}nNt|
\}}
|ot|\}}n|od|	||
f}n|p
t	dn|o%ddk
}|i|i}nd}|o%ddk
}|i|i}
nd}
|i
|dd|id	|i}|dj	o>|id
||idd|id
dt|n|id||o|idd|n|
o|idd|
n|o|id|nx|iD]}|i|qmW|i|dj	o|i|n|i\}}}|i}|djo"|o|int	dnd|jo
djnot||d||S|djo|i|||||S|i||||||SdS(sUse HTTPS protocol.iNthttpss	%s://%s%sshttps errors
no host giveniR8R9RsContent-Types!application/x-www-form-urlencodedsContent-Lengths%dRsProxy-AuthorizationsBasic %sRRshttp protocol errorsgot a bad status lineii,shttps:(shttps errors
no host given(shttp protocol errorisgot a bad status lineN(RR%RRRRRRRR0RRRtHTTPSR8R9RRRsR>RRRRRFRTR(R3R(R)RRRRdReRRaRRRRRRLRRR_R`((s/usr/lib/python2.6/urllib.pyt
open_httpss


	
	





cCs{t|tp
td
n|d djo<|dd!djo(|dd!idjo|i|S|i|Sd	S(s/Use local file or FTP depending on form of URL.s
file errors9proxy support for file protocol currently not implementedis//it/is
localhost/N(s
file errors9proxy support for file protocol currently not implemented(RRR0Rtopen_ftpRj(R3R(((s/usr/lib/python2.6/urllib.pyt	open_files

?cCsddk}ddk}ddk}yddkl}Wn#tj
oddkl}nXt|\}}t|}yti	|}	Wn0t
j
o$}
t|
i|
i
|
inX|	i}|ii|	idt}|i|d}
|i|d|
pd||f}|p?|}|d d	jod
|}ntt|d||St|\}}|oati|ttfjo?|}|d d	jod
|}ntt|d||StddS(sUse local file.iN(tStringIOtusegmtis6Content-Type: %s
Content-Length: %d
Last-modified: %s
s
text/plainiRsfile://ROslocal file errorsnot on local host(slocal file errorsnot on local host(t	mimetypest	mimetoolstemail.utilst	cStringIORtImportErrorRRR@tstatRHR0terrnotstrerrorR,tst_sizetutilst
formatdatetst_mtimetTruet
guess_typetMessageRTR'RRZt
gethostbynameRR(R3R(RRtemailRRdRJt	localnametstatsteR}tmodifiedtmtypeR_turlfiletport((s/usr/lib/python2.6/urllib.pyRjs@$ 		"cCst|tp
tdnddk}ddk}yddkl}Wn#tj
oddkl}nXt|\}}|p
tdnt	|\}}t
|\}}|ot|\}}	nd}	t
|}t
|pd}t
|	pd}	ti|}|pddk}
|
i}n
t|}t|\}}t
|}|id}|d |d}}
|o|d	o|d
}n|o|d	od|d	<n|||di|f}t|itjoPxM|iiD]8}||jo%|i|}|i|=|iqqWnyK||ijo#t||	||||i|<n|
p
d}nd}xP|D]H}t|\}}|id
jo|djo|i}qqW|i|i|
|\}}|i d|d	}d}|o|d|7}n|dj	o|d	jo|d|7}n|i!||}t"||d|SWn4t#j
o%}td|ft$i%dnXdS(sUse FTP protocol.s	ftp errors8proxy support for ftp protocol currently not implementediN(Rs
no host givenRiRiitDtIRUtatAtitdsftp:sContent-Type: %s
sContent-Length: %d
i(s	ftp errors8proxy support for ftp protocol currently not implemented(s	ftp errors
no host given(RRRRRR(&RRR0RRRRRRRRRR%RRZRtftplibtFTP_PORTRqRtsplittjoinRsRDtMAXFTPCACHEtkeysRFt
ftpwrapperRRtuppertretrfileRRRTRR\R](R3R(RRRRdRmRtusertpasswdRtattrstdirsRJtkeytktvRUtattrtvalueR`tretrlenRR_Rg((s/usr/lib/python2.6/urllib.pyRs|





#

cCst|tp
tdnddk}yddkl}Wn#tj
oddkl}nXy|idd\}}Wntj
otdnX|p
d	}n|i	d
}|djo-d||jo||d}|| }nd
}g}|i
dtidti
ti|i
d||djoddk}	|	i|}n
t|}|i
dt||i
d
|i
|di|}||}
|i|
d}t|
||S(sUse "data" URL.s
data errors9proxy support for data protocol currently not implementediN(Rt,isbad data URLstext/plain;charset=US-ASCIIt;it=RisDate: %ss%a, %d %b %Y %T GMTsContent-type: %sRsContent-Length: %ds
(s
data errors9proxy support for data protocol currently not implemented(s
data errorsbad data URL(RRR0RRRRRt
ValueErrortrfindRKttimetstrftimetgmtimeRtdecodestringRRsRRRT(R3R(R)RRRUtsemitencodingRgRtfR_((s/usr/lib/python2.6/urllib.pyt	open_data6sB




N(R5R6t__doc__R%R?t__version__R=R1RGRFR.RMR'RXRWR+RRRt	_have_sslRRRjRR(((s/usr/lib/python2.6/urllib.pyRqs*
				$CK	J			#	>cBseZdZdZdZddZdZddZddZ	ddZ
ddZdd	Zdd
Z
ddZddZdd
ZddZdZRS(s?Derived class with handlers for errors we can handle (perhaps).cOs2ti|||h|_d|_d|_dS(Nii
(RR1t
auth_cachettriestmaxtries(R3RLtkwargs((s/usr/lib/python2.6/urllib.pyR1hs		cCst||d||S(s3Default error handling -- don't raise an exception.shttp:(RT(R3R(R`RRR_((s/usr/lib/python2.6/urllib.pyRnsc	Cs|id7_|ioY|i|ijoFt|do
|i}n
|i}d|_|||dd|S|i||||||}d|_|S(s%Error 302 -- relocated (temporarily).ithttp_error_500iis)Internal Server Error: Redirect Recursion(RRR:RRtredirect_internal(	R3R(R`RRR_R)tmethR{((s/usr/lib/python2.6/urllib.pythttp_error_302rs
				c
Csd|jo|d}n d|jo|d}ndS|i}|it|id||}|i}	|	idp|	idp
|	idp!td||d||n|i|S(	Ntlocationturit:shttp://shttps://sftp://sredirect errors) - Redirection to url '%s' is not allowed(RrRFRRURt
startswithR0R'(
R3R(R`RRR_R)tnewurlRtnewurl_lower((s/usr/lib/python2.6/urllib.pyRs"


	
cCs|i||||||S(s*Error 301 -- also relocated (permanently).(R(R3R(R`RRR_R)((s/usr/lib/python2.6/urllib.pythttp_error_301scCs|i||||||S(s;Error 303 -- also relocated (essentially identical to 302).(R(R3R(R`RRR_R)((s/usr/lib/python2.6/urllib.pythttp_error_303scCsG|djo|i||||||S|i|||||SdS(s1Error 307 -- relocated, but turn POST into error.N(R%RR(R3R(R`RRR_R)((s/usr/lib/python2.6/urllib.pythttp_error_307s
c
Csd|jo ti||||||n|d}ddk}|id|}	|	p ti||||||n|	i\}
}|
idjo ti||||||nd|id}|djot||||St|||||SdS(s_Error 401 -- authentication required.
        This function supports Basic authentication only.swww-authenticateiNs![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"tbasictretry_t_basic_auth(	RRtretmatchtgroupsRRUR%RY(
R3R(R`RRR_R)tstuffRRtschemetrealmRf((s/usr/lib/python2.6/urllib.pythttp_error_401s"


c
Csd|jo ti||||||n|d}ddk}|id|}	|	p ti||||||n|	i\}
}|
idjo ti||||||nd|id}|djot||||St|||||SdS(seError 407 -- proxy authentication required.
        This function supports Basic authentication only.sproxy-authenticateiNs![ 	]*([^ 	]+)[ 	]+realm="([^"]*)"Rtretry_proxy_R(	RRRRRRRUR%RY(
R3R(R`RRR_R)RRRRRRf((s/usr/lib/python2.6/urllib.pythttp_error_407s"


cCst|\}}d||}|id}t|\}}	t|	\}	}
|	idd}|	|}	|i|	||\}}
|p|
pdSt|dddt|
ddd|	}	d|	|
|id<|djo|i|S|i||SdS(Nshttp://Rt@iRNRiR(RR#Rtfindtget_user_passwdR%RR'(R3R(RR)RdReRRbRaRct
proxyselectorRRR((s/usr/lib/python2.6/urllib.pytretry_proxy_http_basic_auths

.
cCst|\}}d||}|id}t|\}}	t|	\}	}
|	idd}|	|}	|i|	||\}}
|p|
pdSt|dddt|
ddd|	}	d|	|
|id<|djo|i|S|i||SdS(Nshttps://RRiRNRiR(RR#RR	R
R%RR'(R3R(RR)RdReRRbRaRcRRRR((s/usr/lib/python2.6/urllib.pytretry_proxy_https_basic_auths

.
c
Cst|\}}|idd}||}|i|||\}}|p|pdSt|dddt|ddd|}d||}	|djo|i|	S|i|	|SdS(NRiRNRiRshttp://(RR	R
R%RR'(
R3R(RR)RdReRRRR((s/usr/lib/python2.6/urllib.pytretry_http_basic_auths
.
c
Cst|\}}|idd}||}|i|||\}}|p|pdSt|dddt|ddd|}d||}	|djo|i|	S|i|	|SdS(NRiRNRiRshttps://(RR	R
R%RR'(
R3R(RR)RdReRRRR((s/usr/lib/python2.6/urllib.pytretry_https_basic_auths
.
icCs|d|i}||ijo$|o|i|=qH|i|Sn|i||\}}|p|o||f|i|<n||fS(NR(RRtprompt_user_passwd(R3RdRtclear_cacheRRR((s/usr/lib/python2.6/urllib.pyR
sc	Cshddk}y@td||f}|id|||f}||fSWntj
o	HdSXdS(s#Override this in a GUI environment!iNsEnter username for %s at %s: s#Enter password for %s in %s at %s: (NN(tgetpasst	raw_inputtKeyboardInterruptR%(R3RdRRRR((s/usr/lib/python2.6/urllib.pyRs	
	N(R5R6RR1RR%RRRRRRRRR
RRR
R(((s/usr/lib/python2.6/urllib.pyRes 			

cCs$tdjotidantS(s8Return the IP address of the magic hostname 'localhost'.RN(t
_localhostR%RZR(((s/usr/lib/python2.6/urllib.pyR.s
cCs*tdjotitiantS(s*Return the IP address of the current host.N(t	_thishostR%RZRtgethostname(((s/usr/lib/python2.6/urllib.pyR6s
cCs*tdjoddk}|iantS(s1Return the set of errors raised by the FTP class.iN(t
_ftperrorsR%Rt
all_errors(R((s/usr/lib/python2.6/urllib.pyR>s

cCs}tdjolddk}yddkl}Wn#tj
oddkl}nX|i|datiintS(s)Return an empty mimetools.Message object.iN(Ri(	t
_noheadersR%RRRRRR`RF(RR((s/usr/lib/python2.6/urllib.pyt	noheadersGs
RcBsAeZdZeidZdZdZdZdZ	RS(s;Class used by open_ftp() for cache of open FTP connections.cCsD||_||_||_||_||_||_|idS(N(RRRdRRttimeouttinit(R3RRRdRRR((s/usr/lib/python2.6/urllib.pyR1Zs						cCsddk}d|_|i|_|ii|i|i|i|ii|i	|i
x!|iD]}|ii|qfWdS(Nii(
RtbusytFTPtftptconnectRdRRtloginRRRtcwd(R3Rtdir((s/usr/lib/python2.6/urllib.pyRds	
c	Csddk}|i|djod}d}nd|}d}y|ii|Wn0|ij
o!|i|ii|nXd}|o~|ovy d|}|ii|}Wq|ij
o@}t	|d	 d
jo t
d|ftidqqXn|p|iid|o|ii
}zOy|ii|Wn4|ij
o%}t
d|ftidnXWd|ii|Xd
|}nd}|ii|}nd|_t|did|i|dfS(NiRRsTYPE AisTYPE isRETR it550s	ftp errorisLIST tLISTRO(RR(RtendtransferR tvoidcmdRRR%tntransfercmdt
error_permRR0R\R]tpwdR#Rtaddclosehooktmakefile(	R3RJRURtcmdtisdirtconntreasonR+((s/usr/lib/python2.6/urllib.pyRmsH





)%	cCsF|ipdSd|_y|iiWntj
onXdS(Ni(RR tvoidrespR(R3((s/usr/lib/python2.6/urllib.pyR's
	cCs8|iy|iiWntj
onXdS(N(R'R RFR(R3((s/usr/lib/python2.6/urllib.pyRFs

(
R5R6RRZt_GLOBAL_DEFAULT_TIMEOUTR1RRR'RF(((s/usr/lib/python2.6/urllib.pyRWs				(		taddbasecBs)eZdZdZdZdZRS(s(Base class for addinfo and addclosehook.cCs||_|ii|_|ii|_t|ido|ii|_nt|ido|ii|_n
d|_t|ido9|ii|_t|ido|ii|_qndS(Nt	readlinestfilenocSsdS(N(R%(((s/usr/lib/python2.6/urllib.pyt<lambda>st__iter__tnext(R`RrtreadlineR:R5R6R8R9(R3R`((s/usr/lib/python2.6/urllib.pyR1s	cCs d|iit||ifS(Ns<%s at %r whose fp = %r>(t	__class__R5tidR`(R3((s/usr/lib/python2.6/urllib.pyt__repr__scCsLd|_d|_d|_d|_|io|iind|_dS(N(R%RrR:R5R6R`RF(R3((s/usr/lib/python2.6/urllib.pyRFs				
(R5R6RR1R=RF(((s/usr/lib/python2.6/urllib.pyR4s		R,cBs eZdZdZdZRS(s*Class to add a close hook to an open file.cGs&ti||||_||_dS(N(R4R1t	closehookthookargs(R3R`R>R?((s/usr/lib/python2.6/urllib.pyR1s	cCsAti||io&|i|id|_d|_ndS(N(R4RFR>R?R%(R3((s/usr/lib/python2.6/urllib.pyRFs


	(R5R6RR1RF(((s/usr/lib/python2.6/urllib.pyR,s	taddinfocBs eZdZdZdZRS(s.class to add an info() method to an open file.cCsti||||_dS(N(R4R1R_(R3R`R_((s/usr/lib/python2.6/urllib.pyR1scCs|iS(N(R_(R3((s/usr/lib/python2.6/urllib.pyRks(R5R6RR1Rk(((s/usr/lib/python2.6/urllib.pyR@s	RTcBs5eZdZddZdZdZdZRS(s9class to add info() and geturl() methods to an open file.cCs/ti||||_||_||_dS(N(R4R1R_R(tcode(R3R`R_R(RA((s/usr/lib/python2.6/urllib.pyR1s		cCs|iS(N(R_(R3((s/usr/lib/python2.6/urllib.pyRkscCs|iS(N(RA(R3((s/usr/lib/python2.6/urllib.pytgetcodescCs|iS(N(R((R3((s/usr/lib/python2.6/urllib.pytgeturlsN(R5R6RR%R1RkRBRC(((s/usr/lib/python2.6/urllib.pyRTs
		cCsdS(Ni((tx((s/usr/lib/python2.6/urllib.pyt_is_unicodescCs
t|tS(N(Rtunicode(RD((s/usr/lib/python2.6/urllib.pyREscCsXt|oGy|id}WqTtj
o!tdt|dqTXn|S(stoBytes(u"URL") --> 'URL'.tASCIIsURL s contains non-ASCII characters(REtencodetUnicodeErrortrepr(R(((s/usr/lib/python2.6/urllib.pyRSs
cCsn|i}|d djo(|ddjo|dd!i}n|d djo|di}n|S(s8unwrap('<URL:type://host/path>') --> 'type://host/path'.it<it>isURL:(R(R(((s/usr/lib/python2.6/urllib.pyRs"cCsztdjoddk}|idanti|}|o.|id}|i|t|dfSd|fS(s:splittype('type:opaquestring') --> 'type', 'opaquestring'.iNs
^([^/:]+):i(t	_typeprogR%RtcompileRtgroupRRs(R(RRR((s/usr/lib/python2.6/urllib.pyRs
cCs]tdjoddk}|idanti|}|o|iddSd|fS(s;splithost('//host[:port]/path') --> 'host[:port]', '/path'.iNs^//([^/?]*)(.*)$ii(t	_hostprogR%RRNRRO(R(RR((s/usr/lib/python2.6/urllib.pyR)s
cCsftdjoddk}|idanti|}|ott|iddSd|fS(sJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.iNs^(.*)@(.*)$ii(t	_userprogR%RRNRtmapRRO(RdRR((s/usr/lib/python2.6/urllib.pyR5s
cCs]tdjoddk}|idanti|}|o|iddS|dfS(s/splitpasswd('user:passwd') -> 'user', 'passwd'.iNs^([^:]*):(.*)$ii(t_passwdprogR%RRNRRO(RRR((s/usr/lib/python2.6/urllib.pyRAs
cCs]tdjoddk}|idanti|}|o|iddS|dfS(s*splitport('host:port') --> 'host', 'port'.iNs^(.*):([0-9]+)$ii(t	_portprogR%RRNRRO(RdRR((s/usr/lib/python2.6/urllib.pyRNs
cCstdjoddk}|idanti|}|oc|idd\}}y$|p
tdnt|}Wntj
o
d}nX||fS||fS(sSplit host and port, returning numeric port.
    Return given default port if no ':' found; defaults to -1.
    Return numerical port if a valid number are found after ':'.
    Return None if ':' but not a valid number.iNs^(.*):(.*)$iis	no digits(t
_nportprogR%RRNRRORRq(RdtdefportRRRtnport((s/usr/lib/python2.6/urllib.pyRZs

cCs]tdjoddk}|idanti|}|o|iddS|dfS(s/splitquery('/path?query') --> '/path', 'query'.iNs^(.*)\?([^?]*)$ii(t
_queryprogR%RRNRRO(R(RR((s/usr/lib/python2.6/urllib.pyRps
cCs]tdjoddk}|idanti|}|o|iddS|dfS(s)splittag('/path#tag') --> '/path', 'tag'.iNs^(.*)#([^#]*)$ii(t_tagprogR%RRNRRO(R(RR((s/usr/lib/python2.6/urllib.pyR
|s
cCs!|id}|d|dfS(sksplitattr('/path;attr1=value1;attr2=value2;...') ->
        '/path', ['attr1=value1', 'attr2=value2', ...].Rii(R(R(twords((s/usr/lib/python2.6/urllib.pyRscCs]tdjoddk}|idanti|}|o|iddS|dfS(s-splitvalue('attr=value') --> 'attr', 'value'.iNs^([^=]*)=(.*)$ii(t
_valueprogR%RRNRRO(RRR((s/usr/lib/python2.6/urllib.pyRs
ccs)x"|]}d|t|fVqWdS(s%02xN(tchr(t.0R((s/usr/lib/python2.6/urllib.pys	<genexpr>s	iccs)x"|]}d|t|fVqWdS(s%02XN(R\(R]R((s/usr/lib/python2.6/urllib.pys	<genexpr>s	c	Cs|id}xtdt|D]}||}yt|d |d||<Wq%tj
od|||<q%tj
o,tt|d d|d||<q%Xq%Wdi|S(s"unquote('abc%20def') -> 'abc def'.t%iiiRi(	RtxrangeRst	_hextochrtKeyErrortUnicodeDecodeErrortunichrRqR(tstresRtitem((s/usr/lib/python2.6/urllib.pyRs
.cCs|idd}t|S(s%unquote('%7e/abc+def') -> '~/abc def't+t (RVR(Rd((s/usr/lib/python2.6/urllib.pyR	ssAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-RcCs|tf}yt|}Wnrtj
of|t7}h}xBtdD]4}t|}||jo|pd|||<qHW|t|<nXt|i|}di|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.
    is%%%02XRi(talways_safet	_safemapsRatrangeR\RRt__getitem__R(RdRNtcachekeytsafe_mapRtcRe((s/usr/lib/python2.6/urllib.pyRs

&RicCs>d|jo$t||d}|iddSt||S(s9Quote the query fragment of a URL; replacing ' ' with '+'RhRg(RRV(RdRN((s/usr/lib/python2.6/urllib.pyRs
ic

Cst|do|i}nhy0t|ot|dto
tnWn4tj
o(ti\}}}td|nXg}|pTxl|D]E\}}tt	|}tt	|}|i
|d|qWnx|D]\}}tt	|}t|t	o%t|}|i
|d|qt|o1t|idd}|i
|d|qyt|}Wn:tj
o.tt	|}|i
|d|qXx/|D]'}	|i
|dtt	|	qWqWdi
|S(svEncode a sequence of two-element tuples or dictionary into a URL query string.

    If any values in the query arg are sequences and doseq is true, each
    sequence element is converted to a separate parameter.

    If the query arg is a sequence of two-element tuples, the order of the
    parameters in the output will match the order of parameters in the
    input.
    titemsis1not a valid non-string sequence or mapping objectRRGRVt&(R:RpRsRttuplet	TypeErrorR\R]RRRKRERHR(
tquerytdoseqttytvattbtlRRRDtelt((s/usr/lib/python2.6/urllib.pyR
sB"
)cCs`h}xStiiD]B\}}|i}|o#|ddjo|||d <qqW|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.

    it_proxy(R@tenvironRpR(R#RfR((s/usr/lib/python2.6/urllib.pytgetproxies_environments	cCstiiddptiidd}|djodSt|\}}xC|idD]2}|o%|i|p|i|odSq_WdS(sTest if proxies should not be used for a particular host.

    Checks the environment for a variable named no_proxy, which should
    be a list of DNS suffixes separated by commas, or '*' for all hosts.
    tno_proxyRitNO_PROXYt*iRi(R@R|R<RRtendswith(RdR~thostonlyRRf((s/usr/lib/python2.6/urllib.pytproxy_bypass_environment,s+
'	tdarwin(t_get_proxy_settingst_get_proxiesc
Csxddk}ddk}ddkl}t|\}}d}t}d|jo|dotSnd}x|iddD]}	|	pqn|id|	}
|
dj	o|djo?y|i	|}||}Wq|i
j
o
qqXn||
id	}t|
id
d	}d|}||?||?jotSq|||	otSqWt
S(
s
        Return True iff this host shouldn't be accessed using a proxy

        This function uses the MacOSX framework SystemConfiguration
        to fetch the proxy information.
        iN(tfnmatchcSs{|id}tt|}t|djo|ddddgd }n|dd>|dd>B|dd>B|d	BS(
Nt.iiiiiiii(RRRRqRs(tipAddrtparts((s/usr/lib/python2.6/urllib.pytip2numPs
Rtexclude_simplet
exceptionss(\d+(?:\.\d+)*)(/\d+)?iii ((RRZRRRRR%R<RRR[RORqtFalse(
RdRRZRRRRtproxy_settingsthostIPRtmtbasetmask((s/usr/lib/python2.6/urllib.pytproxy_bypass_macosx_sysconfCs<		
	


		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/lib/python2.6/urllib.pytgetproxies_macosx_sysconfzscCs#tot|St|SdS(N(R}RR(Rd((s/usr/lib/python2.6/urllib.pyRs
cCstptS(N(R}R(((s/usr/lib/python2.6/urllib.pyRsc	Cskh}yddk}Wntj
o|SXy|i|id}|i|dd}|ot|i|dd}d|josx|idD][}|idd	\}}ddk}|id
|pd||f}n|||<qWq=|d d
jo||d<q=d||d<d||d<n|i	Wnt
ttfj
onX|S(sxReturn a dictionary of scheme -> proxy server URL mappings.

        Win32 uses the registry to store proxies.

        iNs;Software\Microsoft\Windows\CurrentVersion\Internet SettingstProxyEnableitProxyServerRRis^([^/:]+)://s%s://%sishttp:Rs	http://%ssftp://%sR (
t_winregRtOpenKeytHKEY_CURRENT_USERtQueryValueExRRRRtClosetWindowsErrorRRs(	R#RtinternetSettingstproxyEnabletproxyServertptprotocoltaddressR((s/usr/lib/python2.6/urllib.pytgetproxies_registrys:		

cCstptS(sReturn a dictionary of scheme -> proxy server URL mappings.

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

        (R}R(((s/usr/lib/python2.6/urllib.pyRsc
CsTyddk}ddk}Wntj
odSXyK|i|id}|i|dd}t|i|dd}Wntj
odSX|p|odSt|\}}|g}y1t	i
|}||jo|i|nWnt	ij
onXy1t	i
|}	|	|jo|i|	nWnt	ij
onX|id}d}
xi|
t|joU||
djo6dd	t	it	i
t	ig||
|
d
+n|
d
7}
qqWxs|D]k}|idd}|id
d}|idd}x,|D]$}|i|||iod
Sq$WqWdS(Niis;Software\Microsoft\Windows\CurrentVersion\Internet SettingsRt
ProxyOverrideRs<local>Rs	127.0.0.1iRs\.Rs.*t?(RRRRRRRRRRZRRKR[tgetfqdnRRsRRVRR(
RdRRRRt
proxyOverridetrawHostRtaddrtfqdnRttesttval((s/usr/lib/python2.6/urllib.pytproxy_bypass_registrysf		
	

	!
cCs#tot|St|SdS(sReturn a dictionary of scheme -> proxy server URL mappings.

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

        N(R}RR(Rd((s/usr/lib/python2.6/urllib.pyRs
cCsd}x$tdD]}|t|}qW|d}ti}t|}t|}ti}||jo	dGHnt|GHt|GHt|GHt||dGdGHdS(NRiiisWrong!itsec(RkR\RRRRJtround(RdRtt0tqstuqstt1((s/usr/lib/python2.6/urllib.pyttest1s


	cCsd|||fGHdS(Ns0Block number: %d, Block size: %d, Total size: %d((R~t	blocksizet	totalsize((s/usr/lib/python2.6/urllib.pyR-!sc	Cs9|p:dddddg}ttdo|idqAnzx|D]}dG|GdGHt|dt\}}|GH|o6d
GHx%|iD]}|dG||GHqWd
GHnt|d}|i}~d
|jo(t	i
dd}|i|d
}n|GHd\}}qKWddGHWdtXdS(Ns/etc/passwdsfile:/etc/passwdsfile://localhost/etc/passwdsftp://ftp.gnu.org/pub/READMEs http://www.python.org/index.htmlRs!https://synergy.as.cmu.edu/~geek/RQi
s======RROs
Rii(s
----------s
----------(NN(
R:RRKRR%R-RR'Rrtstringt	maketranst	translateR(RLR(tfnRRR`R)ttable((s/usr/lib/python2.6/urllib.pyR's<	

	

c	Csddk}ddk}y#|i|idd\}}Wn#|ij
o}|GHdGHdSXd}xO|D]G\}}|djo|d}n|djodGHd	Gd
GHdSqnW|o&|djotnt|n2|p	dGHnx|D]}t|iGqWdS(NiitthsUse -h for helpis-ts-hs&Usage: python urllib.py [-t] [url ...]s-t runs self-test;s'otherwise, contents of urls are printed(tgetoptR\targvR[RRRRr(	RR\toptsRLRgtttoRR(((s/usr/lib/python2.6/urllib.pytmainGs4#

	
	t__main__(aRRRZR@RR\turlparseRRt__all__RRRftmacurl2pathRRt
nturl2patht
rourl2pathR%R&RRRtsslRRRR0R/RDRRRRRRRRRRRR4R,R@RTRFt	NameErrorRERSRRMRRPRRQRRSRRTRRURRXRRYR
RR[RtdictRkR`tupdateRR	RiRjRRR
R}Rtplatformt_scproxyRRRRRRRRRR-RRR5(((s/usr/lib/python2.6/urllib.pyt<module>s			
	
				N
"				
									
	"@			7	
	
	-			;
		 	


ACC SHELL 2018