ACC SHELL

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

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}n||_|id|_|id|_d|ifg|_g|_t	i
|_d|_t
|_
dS(Ntkey_filet	cert_files
User-Agent(R%RR#tgetR7R8tversiont
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.pyRCscCso|ioFx8|iD]-}y|i|Wqtj
oqXqW|i2n|io|iindS(N(R<R?tOSErrorR@tclear(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%/:=&?~#+!$,;'@()*[]|trbRGtopen_t-t_ssocket erroriN(RttoBytesRR@R't
addinfourlRR#RR%ttypetreplacethasattrtopen_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)RRR(((s/usr/lib/python2.6/urllib.pyRVscCs,t|\}}tdd||fdS(s/Overridable interface to open unknown URL type.s	url errorsinvalid proxy for %sN(RR0(R3R`R\R)RRR(((s/usr/lib/python2.6/urllib.pyRUscCstt|}|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.RGitwbiNtiiiscontent-lengthsContent-Lengths1retrieval incomplete: got only %i out of %i bytesi (RRPR@RR%topen_local_filetinfoRRR0R'ttempfileRRR=tpathtsplitexttmkstempR<RHtfdopentinttreadtlentwriteRCR/(R3R(R,R-R)RRturl1R^thdrsReR]ttfpRjtgarbageRktsuffixtfdtresulttbstsizeRptblocknumtblock((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	putheaderRqR;t
endheaderstsendtgetreplytgetfileRCRQt
http_error(R3R(R)Rtuser_passwdtproxy_passwdRbRctrealhostR_trestRt
proxy_authtauththRIterrcodeterrmsgR]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(RTRWR%thttp_error_default(
R3R(R^RRR]R)RdtmethodRy((s/usr/lib/python2.6/urllib.pyRls

	cCs/|i}|itd|||fdS(s>Default error handler: close the connection and raise IOError.s
http errorN(RpRCR0(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 giveniR7R8Rs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%RRRRRRRR0RRRtHTTPSR7R8RRRqR;RRRRRCRQR(R3R(R)RRRRbRcRR_RRRRRRIRRR]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_ftpRh(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://RLslocal file errorsnot on local host(slocal file errorsnot on local host(t	mimetypest	mimetoolstemail.utilst	cStringIORtImportErrorRRR=tstatRER0terrnotstrerrorR,tst_sizetutilst
formatdatetst_mtimetTruet
guess_typetMessageRQR'RRXt
gethostbynameRR(R3R(RRtemailRRbRGt	localnametstatsteR{tmodifiedtmtypeR]turlfiletport((s/usr/lib/python2.6/urllib.pyRhs@$ 		"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 givenRgRiitDtIRRtatAtitdsftp: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%RRXRtftplibtFTP_PORTRoRtsplittjoinRqRAtMAXFTPCACHEtkeysRCt
ftpwrapperRRtuppertretrfileRRRQRRZR[(R3R(RRRRbRkRtusertpasswdRtattrstdirsRGtkeytktvRRtattrtvalueR^tretrlenRR]Re((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=RgsDate: %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
ValueErrortrfindRHttimetstrftimetgmtimeRtdecodestringRRqRRRQ(R3R(R)RRRRtsemitencodingReRtfR]((s/usr/lib/python2.6/urllib.pyt	open_data6sB




N(R5R6t__doc__R%R<t__version__R:R1RDRCR.RJR'RVRUR+RRRt	_have_sslRRRhRR(((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(R3RItkwargs((s/usr/lib/python2.6/urllib.pyR1hs		cCst||d||S(s3Default error handling -- don't raise an exception.shttp:(RQ(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(RRRTRRtredirect_internal(	R3R(R^RRR]R)tmethRy((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(RpRCRRRRt
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(	RRtretmatchtgroupsRRRR%RW(
R3R(R^RRR]R)tstuffRRtschemetrealmRd((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(	RRRRRRRRR%RW(
R3R(R^RRR]R)RRRRRRd((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://R~t@iRKRgR(RR#Rtfindtget_user_passwdR%RR'(R3R(RR)RbRcRR`R_Rat
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://RRiRKRgR(RR#RRRR%RR'(R3R(RR)RbRcRR`R_RaR	RRR((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(NRiRKRgRshttp://(RRRR%RR'(
R3R(RR)RbRcRRRR((s/usr/lib/python2.6/urllib.pytretry_http_basic_auths
.
c
Cst|\}}|idd}||}|i|||\}}|p|pdSt|dddt|ddd|}d||}	|djo|i|	S|i|	|SdS(NRiRKRgRshttps://(RRRR%RR'(
R3R(RR)RbRcRRRR((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(R3RbRtclear_cacheRRR((s/usr/lib/python2.6/urllib.pyRsc	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%(R3RbRRRR((s/usr/lib/python2.6/urllib.pyRs	
	N(R5R6RR1RR%RRRRRRRR
RRR
RR(((s/usr/lib/python2.6/urllib.pyRes 			

cCs$tdjotidantS(s8Return the IP address of the magic hostname 'localhost'.RN(t
_localhostR%RXR(((s/usr/lib/python2.6/urllib.pyR.s
cCs*tdjotitiantS(s*Return the IP address of the current host.N(t	_thishostR%RXRtgethostname(((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^RC(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(RRRbRRttimeouttinit(R3RRRbRRR((s/usr/lib/python2.6/urllib.pyR1Zs						cCsddk}d|_|i|_|ii|i|i|i|ii|i	|i
x!|iD]}|ii|qfWdS(Nii(
RtbusytFTPtftptconnectRbRRtloginRRRtcwd(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 tLISTRL(RR(RtendtransferRtvoidcmdRRR%tntransfercmdt
error_permRR0RZR[tpwdR!Rtaddclosehooktmakefile(	R3RGRRRtcmdtisdirtconntreasonR)((s/usr/lib/python2.6/urllib.pyRmsH





)%	cCsF|ipdSd|_y|iiWntj
onXdS(Ni(RRtvoidrespR(R3((s/usr/lib/python2.6/urllib.pyR%s
	cCs8|iy|iiWntj
onXdS(N(R%RRCR(R3((s/usr/lib/python2.6/urllib.pyRCs

(
R5R6RRXt_GLOBAL_DEFAULT_TIMEOUTR1RRR%RC(((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^RptreadlineRTR3R4R6R7(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%RpR8R3R4R^RC(R3((s/usr/lib/python2.6/urllib.pyRCs				
(R5R6RR1R;RC(((s/usr/lib/python2.6/urllib.pyR2s		R*cBs eZdZdZdZRS(s*Class to add a close hook to an open file.cGs&ti||||_||_dS(N(R2R1t	closehookthookargs(R3R^R<R=((s/usr/lib/python2.6/urllib.pyR1s	cCsAti||io&|i|id|_d|_ndS(N(R2RCR<R=R%(R3((s/usr/lib/python2.6/urllib.pyRCs


	(R5R6RR1RC(((s/usr/lib/python2.6/urllib.pyR*s	taddinfocBs eZdZdZdZRS(s.class to add an info() method to an open file.cCsti||||_dS(N(R2R1R](R3R^R]((s/usr/lib/python2.6/urllib.pyR1scCs|iS(N(R](R3((s/usr/lib/python2.6/urllib.pyRis(R5R6RR1Ri(((s/usr/lib/python2.6/urllib.pyR>s	RQcBs5eZdZddZdZdZdZRS(s9class to add info() and geturl() methods to an open file.cCs/ti||||_||_||_dS(N(R2R1R]R(tcode(R3R^R]R(R?((s/usr/lib/python2.6/urllib.pyR1s		cCs|iS(N(R](R3((s/usr/lib/python2.6/urllib.pyRiscCs|iS(N(R?(R3((s/usr/lib/python2.6/urllib.pytgetcodescCs|iS(N(R((R3((s/usr/lib/python2.6/urllib.pytgeturlsN(R5R6RR%R1RiR@RA(((s/usr/lib/python2.6/urllib.pyRQs
		cCsdS(Ni((tx((s/usr/lib/python2.6/urllib.pyt_is_unicodescCs
t|tS(N(Rtunicode(RB((s/usr/lib/python2.6/urllib.pyRCscCsXt|oGy|id}WqTtj
o!tdt|dqTXn|S(stoBytes(u"URL") --> 'URL'.tASCIIsURL s contains non-ASCII characters(RCtencodetUnicodeErrortrepr(R(((s/usr/lib/python2.6/urllib.pyRPs
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%RtcompileRtgroupRRq(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%RRLRRM(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%RRLRtmapRRM(RbRR((s/usr/lib/python2.6/urllib.pyR5s
cCs]tdjoddk}|idanti|}|o|iddS|dfS(s/splitpasswd('user:passwd') -> 'user', 'passwd'.iNs^([^:]*):(.*)$ii(t_passwdprogR%RRLRRM(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%RRLRRM(RbRR((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%RRLRRMRRo(RbtdefportRRRtnport((s/usr/lib/python2.6/urllib.pyRZs

cCs]tdjoddk}|idanti|}|o|iddS|dfS(s/splitquery('/path?query') --> '/path', 'query'.iNs^(.*)\?([^?]*)$ii(t
_queryprogR%RRLRRM(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%RRLRRM(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%RRLRRM(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(RZ(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%iiiRg(	RtxrangeRqt	_hextochrtKeyErrortUnicodeDecodeErrortunichrRoR(tstresRtitem((s/usr/lib/python2.6/urllib.pyRs
.cCs|idd}t|S(s%unquote('%7e/abc+def') -> '~/abc def't+t (RSR(Rb((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%%%02XRg(talways_safet	_safemapsR_trangeRZRPt__getitem__R(RbRKtcachekeytsafe_mapRtcRc((s/usr/lib/python2.6/urllib.pyRs

&RgcCs>d|jo$t||d}|iddSt||S(s9Quote the query fragment of a URL; replacing ' ' with '+'RfRe(RRS(RbRK((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 objectRRERSt&(RTRnRqRttuplet	TypeErrorRZR[RRRHRCRFR(
tquerytdoseqttytvattbtlRRRBtelt((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=tenvironRnR(R#RdR((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_proxyRgtNO_PROXYt*iRi(R=RzR9RRtendswith(RbR|thostonlyRRd((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(RRPRoRq(tipAddrtparts((s/usr/lib/python2.6/urllib.pytip2numPs
Rtexclude_simplet
exceptionss(\d+(?:\.\d+)*)(/\d+)?iii ((RRXRRRRR%R9RRRYRMRotFalse(
RbRRXRRRRtproxy_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(Rb((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:R~s	http://%ssftp://%sR(
t_winregRtOpenKeytHKEY_CURRENT_USERtQueryValueExRRRRtClosetWindowsErrorRRq(	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\.R~s.*t?(RRRRRRRRRRXRRHRYtgetfqdnRRqRRSRR(
RbRRRRt
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(Rb((s/usr/lib/python2.6/urllib.pyRs
cCsd}x$tdD]}|t|}qW|d}ti}t|}t|}ti}||jo	dGHnt|GHt|GHt|GHt||dGdGHdS(NRgiisWrong!itsec(RiRZRRRRHtround(RbRtt0tqstuqstt1((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/RNi
s======RRLs
Rgi(s
----------s
----------(NN(
RTRRHRR%R-RR'Rptstringt	maketranst	translateR(RIR(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(tgetoptRZtargvRYRRRRp(	RRZtoptsRIRetttoRR(((s/usr/lib/python2.6/urllib.pytmainGs4#

	
	t__main__(aRRRXR=RRZturlparseRRt__all__RRRdtmacurl2pathRRt
nturl2patht
rourl2pathR%R&RRRtsslRRRR0R/RARRRRRRRRRRRR2R*R>RQRDt	NameErrorRCRPRRKRRNRRORRQRRRRRSRRVRRWR
RRYRtdictRiR^tupdateRR	RgRhRRR
R{Rtplatformt_scproxyRRRRRRRRRR-RRR5(((s/usr/lib/python2.6/urllib.pyt<module>s			
	
				N
"				
									
	"@			7	
	
	-			;
		 	


ACC SHELL 2018