Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/xmllib.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZddlZddlZddlZejded�[dZdefd��YZdZ	d	Z
d
ZdZej
d�Zej
d
�Zej
d�Zej
ded�Zej
ded�Zej
d�Zej
e	d�Zej
d�Zej
e	dede
de
ded�Zej
de�Zej
e
d�Zej
dedejdej�Zej
d �Zej
e
d!�Zej
d"ed#�Zej
e�Zej
d$�Zej
d%�Z d&ed'Z!d(Z"d)e	e"d*d'e	e!d+Z#ej
d,e	ded-e	e#d.e
�Z$ej
d/e	d0e
de
d1ed'd2e	d3e
de
d4e	d5e
de
d6e
d7�Z%ej
d8ed'e
�Z&ej
e
d7�Z'ej
d9�Z(ej
d:�Z)ej
d;�Z*ej+d<d=�Z,d>Z-ej
e-d�Z.ej
d?e-d@e-dA�Z/ej
dBe-dC�Z0dDfdE��YZ1dFe1fdG��YZ2e3dH�Z4e5dIkr�e4�ndS(Js8A parser for XML, using the derived class as static DTD.i�Ns4The xmllib module is obsolete.  Use xml.sax instead.is0.3tErrorcBseZRS((t__name__t
__module__(((s/sys/lib/python2.7/xmllib.pyRss[ 	
]+s[ 	
]*s[a-zA-Z_:][-a-zA-Z0-9._:]*s(?:'[^']*'|"[^"]*")s[^	
 -~��[]&<]t&s&(s(|#[0-9]+|#x[0-9a-fA-F]+)[^-a-zA-Z0-9._:]s
&(?P<name>s)[^-a-zA-Z0-9._:]s2&#(?P<char>[0-9]+[^0-9]|x[0-9a-fA-F]+[^0-9a-fA-F])t$s
s	(?P<name>s)(t=s
(?P<value>s |[-a-zA-Z0-9.:+*%?!\(\)_#=~]+))?t<s(?P<slash>/?)>s
<(?P<tagname>s)(?P<attrs>(?:s)*)s</t>s
(?:[^>'"]|s)*>s<!\[CDATA\[s\]\]>s(?P<%s>t)sV(?P<%s>"[-'\(\)+,./:=?;!*#@$_%% 

a-zA-Z0-9]*"|'[-\(\)+,./:=?;!*#@$_%% 

a-zA-Z0-9]*')s(?:SYSTEM|PUBLICtpubidtsyslits	<!DOCTYPEs)(?:s)?s<\?xmltversions(?P<version>s(?:tencodingsF(?P<encoding>'[A-Za-z][-A-Za-z0-9._]*'|"[A-Za-z][-A-Za-z0-9._]*"))?(?:t
standalones+(?P<standalone>'(?:yes|no)'|"(?:yes|no)"))?s\?>s<\?(?P<proc>s<!--s-->s--s 
	s    s[a-zA-Z_][-a-zA-Z0-9._]*s(?:(?P<prefix>s):)?(?P<local>s)$sxmlns(?::(?P<ncname>s))?$t	XMLParsercBs�eZiZiZdZdZdZdZdZd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd	�Zd
�Zdd�Zd�Zd
�Zd�Zd�Zd�Zid2d6d2d6d2d6Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$idd 6d!d"6d#d$6d%d&6d'd(6Z%d)�Z&d*�Z'd+�Z(d,�Z)d-�Z*d.�Z+d/�Z,d0�Z-d1�Z.RS(3iicKs�d|_d|kr%|d|_nd|krA|d|_nd|kr]|d|_nd|kry|d|_nd|kr�|d|_n|j�dS(Nitaccept_unquoted_attributestaccept_missing_endtag_nametmap_casetaccept_utf8ttranslate_attribute_references(t_XMLParser__fixedt&_XMLParser__accept_unquoted_attributest&_XMLParser__accept_missing_endtag_namet_XMLParser__map_caset_XMLParser__accept_utf8t*_XMLParser__translate_attribute_referencestreset(tselftkw((s/sys/lib/python2.7/xmllib.pyt__init__gs	cCs6d|_i|_|j|j�|j|j�dS(Ni(Rtelementst_XMLParser__fixdictt__dict__t_XMLParser__fixclasst	__class__(R((s/sys/lib/python2.7/xmllib.pyt
__fixelementsus		cCs5|j|j�x|jD]}|j|�qWdS(N(RR t	__bases__R!(Rtkltk((s/sys/lib/python2.7/xmllib.pyt
__fixclass{scCs�x�|j�D]�}|d dkrv|d}|jj|d�\}}|dkr�t||�|f|j|<q�q
|d dkr
|d}|jj|d�\}}|dkr�|t||�f|j|<q�q
q
WdS(Nitstart_itend_(NN(NN(tkeysRtgettNonetgetattr(Rtdicttkeyttagtstarttend((s/sys/lib/python2.7/xmllib.pyt	__fixdict�s
"
cCs�d|_g|_d|_d|_d|_d|_d|_d|_d|_	idd6|_
|jtjkr�|j
�ndS(Ntiitxml(trawdatatstackt
nomoretagstliteraltlinenot_XMLParser__at_startR,t_XMLParser__seen_doctypet_XMLParser__seen_starttagt_XMLParser__use_namespacest_XMLParser__namespacesRRt_XMLParser__fixelements(R((s/sys/lib/python2.7/xmllib.pyR�s									cCsd|_|_dS(Ni(R8R9(R((s/sys/lib/python2.7/xmllib.pyt
setnomoretags�scGs
d|_dS(Ni(R9(Rtargs((s/sys/lib/python2.7/xmllib.pyt
setliteral�scCs!|j||_|jd�dS(Ni(R6tgoahead(Rtdata((s/sys/lib/python2.7/xmllib.pytfeed�scCs,|jd�|jr(d|_|`ndS(Nii(RDRR(R((s/sys/lib/python2.7/xmllib.pytclose�s
		cCs|js
|Sd}x�j||�}|dkr8|S|jd�}tj||�}|dkr�|jd�|d}qn|jd�}|j	d�}d}|ddkr)|ddkr�
t|dd��}nt
t|d��}||ddkr�|jd	�|d}q�n�|r�||jkrT|j|}d}q�||ddkr�|jd�|d}qq�|jd
|�d|d}n1||ddkr�|jd�|d}qn|| |||}|r�}q|t
|�}qdS(Nis	bogus `&'it#txiit;s `;' missing after char references"reference to unknown entity `&%s;'R(RtamptsearchR,R1treftmatchtsyntax_errorR2tgrouptchrtintt
entitydefstlen(RREtalltitrestststrtrescan((s/sys/lib/python2.7/xmllib.pyttranslate_references�sR	



	



	cCs4i}x'|jD]\}}}|j|�qW|S(N(R7tupdate(Rtnsdicttttdtnst((s/sys/lib/python2.7/xmllib.pytgetnamespace�sc
Cs�|j}d}t|�}x�||kr�|dkrBd|_n|jr�|||!}|j|�|j|jd�|_|}Pntj||�}|r�|j	d�}n|}||kr�|||!}|jr�j|�dkr�j
d�nd|_|jr7t
j|�dkr7|j
d�n|jr`tj|�r`|j
d�n|j|�|j|jd�|_n|}||kr�Pn||dkr�j||�r^|jr
||}|j|�|j|jd�|_|d}qn|j|�}|dkr)Pnd|_|j|||!jd�|_|}qntj||�r�|j|�}|dkr�Pn|j|||!jd�|_|}qntj||�ra|jr||}|j|�|j|jd�|_|d}qn|j|�}|dkr5Pn|j|||!jd�|_|}qntj||�r�|j|�}|dkr�Pn|j|||!jd�|_|}qntj||�}|r�|js�j
d�n|jd	d
d�\}	}
}|	dd!d
kr/td��n|
rE|
dd!}
n|r[|dd!}n|j|
|�|jd�}qnt j||�}|r�j!|�}|dkr�Pn|j|||!jd�|_|}qnt"j||�}|r�|jrD||}|j|�|j|jd�|_|d}qn|j#r]|j
d�n|jrv|j
d�n|j$|�}|dkr�Pn|jd�|_#|j%r�|j#j&�|_#n|j|||!jd�|_|}qq�n�||dkr�jr4||}|j|�|d}qnt'j||�}|dk	r�jd�}||ddkr�|j
d�|d}n|js�|j
d�n|j(|jd�d �|j|jd�jd�|_qnt)j||�}|dk	r�|jd�}||ddkrE|j
d�|d}n|jd�}|j%rl|j&�}n||j*kr�||j	d� |j*||||_}t|�}|j	d�}n
|j+|�|j|jd�jd�|_qq�n�||dkr�|jr>||}|j|�|d}qn||dkrRPnt,j||�rt|j
d�n|j||�|d}qntd��PqW|dkr�d|_n|rX	||krX	||}|j
d|�|jr	tj|�r	|j
d�n|j|�|j|jd�|_||d|_|j-|�S|||_|r�|js�|j
d�n|jr�|j
d�x(|jr�|j.|jdd�q�Wq�ndS(Nis
sillegal data at start of filesdata not in contentsillegal character in contentRis,<?xml?> declaration not at start of documentRRR
i�s1.0sonly XML version 1.0 supportedsmultiple DOCTYPE elementss$DOCTYPE not at beginning of documenttnameRRJs`;' missing in charreftchars`;' missing in entityreft]isbogus `]]>'sneither < nor & ??s
bogus `%s'sno elements in filesmissing end tags(/R6RTR;R8thandle_dataR:tcounttinterestingRLR1tspaceRNR,ROR7RtillegaltstarttagopenR9tparse_starttagR=t
endtagopentparse_endtagtcommentopent
parse_commentt	cdataopentparse_cdatatxmldeclRPRt
handle_xmlR2tprocopent
parse_proctdoctypeR<t
parse_doctypeRtlowertcharrefthandle_charreft	entityrefRStunknown_entityreft
cdatacloseRDt
finish_endtag(
RR2R6RVtnRERWtjR&RRR
Rb((s/sys/lib/python2.7/xmllib.pyRD�sp		


	
	


	  	


  		 	


			 		




	"

	-
"		







		
cCs|j}|||d!dkr/td��ntj||d�}|dkrUdStj||d|jd��r�|jd�n||jd�ddkr�|jd	�n|jr�j||d|jd��r�jd
�n|j
||d|jd�!�|jd�S(Nis<!--s!unexpected call to handle_commenti�is`--' inside commentit-s"comment cannot end in three dashessillegal character in comment(R6RtcommentcloseRLR,t
doubledashR1RORRithandle_commentR2(RRVR6RW((s/sys/lib/python2.7/xmllib.pyRo�s	"
"!c
Cs�|j}t|�}|jd�}|jr<|j�}n|jdd�\}}|dk	r�|dd!}dj|j��}n|dk	r�|dd!}n|jd�}}||kr�dS||dkrd}	|d}d}
}x*||kr||}|r$|d	kr$|
}
n�
rA|d
krA|}n�|s
|
rPn�|	dkr�|dkr�t	j
||d�}|dkr�dS|j|||||d|!�|jd�S|dkr�|	d}	n5|d
kr
|	d}	|	dkr
|jd�q
n|d}q�t
j
||�}|dkr=dSt	j
||�dkre|jd�n|j|||d�|jd�S(NRbR	R
ii�t it[t"t'RdRRsbogus `>' in DOCTYPEsgarbage in DOCTYPE(R6RTRPRRxR,tjointsplitR2t
endbracketRNthandle_doctypeROtendbracketfind(
RRWR6RRbR	R
R�R&tleveltdqtsqtc((s/sys/lib/python2.7/xmllib.pyRw�s\		





!


cCs�|j}|||d!dkr/td��ntj||d�}|dkrUdS|jr�tj||d|jd��r�|jd�n|j	s�|jd�n|j
||d|jd�!�|jd�S(Ni	s	<![CDATA[sunexpected call to parse_cdatai�isillegal character in CDATAsCDATA not in content(R6RR}RLR,RRiR1ROR7thandle_cdataR2(RRVR6RW((s/sys/lib/python2.7/xmllib.pyRq�s	
"	!tnstsrctprefixcCse|j}tj||�}|dkr+dS|jd�}|jrmtj||d|�rm|jd�ntj	||d�}|dkr�t
d��n|jd�}|jd�}|j
r�|j�}n|dkr|jd�d|_|js|jr|jd�n|j|||�\}}	}|	rL|jd	�nx7|j�D])}
|
|jkrY|jd
|
�qYqYWd|ks�d|kr�|jd
�n|jd�}tj	|�dkr�jd�|jd�S||jkr|jd�n|d|j|<n9|j�dkrA|jd�n|j||||!�|jd�S(Ni�iis+illegal character in processing instructionsunexpected call to parse_procs
xml:namespaces#old-fashioned namespace declarations.xml:namespace declaration too late in documents2namespace declaration inside namespace declarations+unknown attribute `%s' in xml:namespace tagR�R�s)xml:namespace without required attributess"xml:namespace illegal prefix valuesxml:namespace prefix not uniqueR5s*illegal processing instruction target name(R6t	proccloseRLR,R1RRiROttagfindRNRR2RPRRxR>R<R=tparse_attributesR*t$_XMLParser__xml_namespace_attributesR+tncnameR?thandle_proc(RRVR6R2R�RWR&Rbtattrdictt	namespacetattrnameR�((s/sys/lib/python2.7/xmllib.pyRu�sL	#	
	

cCs�|j}i}i}x�||kr�j||�}|dkrFPn|jdd�\}}	|jrv|j�}n|jd�}|	dkr�|jd|�|}	nu|	d dko�|	dkns�d dko�	dknr|	dd!}	n|j	s |jd	|�nt
j|�}|dk	r�|jd
�}
|	pSd||
p_d<|jst|j
�d|_qqnd|	kr�|jd
�n||kr�|jd|�n|	jt�}	|j|	�||<qW|||fS(NRbtvalueis%no value specified for attribute `%s'iR�i�R�sattribute `%s' value not quotedR�R4Rs`<' illegal in attribute valuesattribute `%s' specified twice(R6tattrfindRNR,RPRRxR2RORtxmlnsR>RTR7t	translatet	attrtransR[(RR0RVR�R6R�R�RWR�t	attrvalueR�((s/sys/lib/python2.7/xmllib.pyR�*sB			$$		cCs�|j}tj||d�}|dkr/dStj||�}|dksk|jd�|jd�kr�|jd�|jd�S|jd�}}|jr�|j	�}}n|j
r�jr�|jkr�jd�n|j
r	|jr	|jd�n|j
d�\}}|j|||�\}	}
}|jj||
|f�|jrptj|�}nd}|dk	rk|jd	d
�\}}|dkr�d}nd}
x3|jD](\}}}||kr�||}
q�q�W|
dkr|dkr|jj|�}
n|
dk	r5|
d|}n|dkrR|d
|}n||
|f|jd<ni}x|	j�D]}|||<q~W|jr�i}x|	j�D]\}}|}tj|�}|dk	r�|jd	d
�\}}|jr|j	�}n|dk	r�d}x3|jD](\}}}||kr'||}q'q'W|dkrt|jj|�}n|dk	r�|d|}q�|d
|}q�n|||<|||<q�W|}	n|jj|�}|dk	rjx>|	j�D]0}||kr�jd|||f�q�WxB|j�D]1\}}|dk	r2||	kr2||	|<q2q2Wn|jj|d�d}|j||	|�|jd�dkr�|j|�n|jd�S(Nii�isgarbage in starttagttagnamesstarttag does not match DOCTYPEsmultiple elements on top leveltattrsR�tlocalR4R�t:s"unknown attribute `%s' in tag `%s'tslasht/(NN(R6R�RNR,t
starttagmatchR2RORPRRxR=R<R7tspanR�tappendR>tqnameR?R+R*titemst
attributesRtfinish_starttagR~(RRVR6R2R0tnstagR�R&R�R�R]RWR�R�R^R_R`tattrnamemapR/t	nattrdicttvaltokeytaprefixtansR�tmethod((s/sys/lib/python2.7/xmllib.pyRkOs�	*

					
	"cCsh|j}tj||d�}|dkr/dStj||d�}|dkr�|jrs|j||�|dS|js�|jd�n|j	dd}|d}n||j
d�}|jr�|j�}n|jr|j	s�|j	ddkr|j||�|dSn|j
d�}tj||�dkrN|jd�n|j|�|j
d�S(Nii�isno name specified in end tagisgarbage in end tag(R6R�RNR,R�R9ReRROR7RPRRxR2R�R~(RRVR6R2RWR0R&((s/sys/lib/python2.7/xmllib.pyRm�s2			
		!
cCs6|dk	r"|j|||�n|j||�dS(N(R,thandle_starttagtunknown_starttag(RR�R�R�((s/sys/lib/python2.7/xmllib.pyR��scCs�d|_|sO|jd�t|j�d}|dkr�|j|�dSncd}x=tt|j��D]&}||j|dkrk|}qkqkW|dkr�|jd�dSx�t|j�|kr�|t|j�dkr|jd|jdd�n|jdd}|jj|d�d}|dk	rK|j	||�n
|j|�|j
t|j�kr|d|_
n|jd=q�WdS(	Nisname-less end tagii�sunopened end tagsmissing close tag for %si(NN(R9RORTR7tunknown_endtagtrangeRR+R,t
handle_endtagR>(RR0tfoundRVR�R�((s/sys/lib/python2.7/xmllib.pyR~�s2	




cCsdS(N((RRR
((s/sys/lib/python2.7/xmllib.pyRs�scCsdS(N((RR0R	R
RE((s/sys/lib/python2.7/xmllib.pyR��scCs||�dS(N((RR0R�R�((s/sys/lib/python2.7/xmllib.pyR��scCs|�dS(N((RR0R�((s/sys/lib/python2.7/xmllib.pyR��scCs�y6|ddkr)t|dd�}nt|�}Wntk
rW|j|�dSXd|koodkns�|j|�dS|jt|��dS(NiRIiii�(RRt
ValueErrortunknown_charrefReRQ(RRbR((s/sys/lib/python2.7/xmllib.pyRz�s


s&#60;tlts&#62;tgts&#38;RKs&#34;tquots&#39;taposcCsdS(N((RRE((s/sys/lib/python2.7/xmllib.pyRe
scCsdS(N((RRE((s/sys/lib/python2.7/xmllib.pyR�scCsdS(N((RRE((s/sys/lib/python2.7/xmllib.pyR�scCsdS(N((RRbRE((s/sys/lib/python2.7/xmllib.pyR�scCstd|j|f��dS(NsSyntax error at line %d: %s(RR:(Rtmessage((s/sys/lib/python2.7/xmllib.pyROscCsdS(N((RR0R�((s/sys/lib/python2.7/xmllib.pyR�scCsdS(N((RR0((s/sys/lib/python2.7/xmllib.pyR�scCsdS(N((RRM((s/sys/lib/python2.7/xmllib.pyR� scCs|jd|�dS(Ns"reference to unknown entity `&%s;'(RO(RRb((s/sys/lib/python2.7/xmllib.pyR|!sN(/RRR�RRRRRRRR@R!RRRARCRFRGR[RaRDRoRwRqR,R�RuR�RkRmR�R~RsR�R�R�RzRSReR�R�R�ROR�R�R�R|(((s/sys/lib/python2.7/xmllib.pyR[s`									2			�	0		-	%	R								

								t
TestXMLParsercBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(cKsd|_tj||�dS(NR4(ttestdataRR(RR((s/sys/lib/python2.7/xmllib.pyR's	cCs|j�dG|GdG|GHdS(Nsxml: encoding =sstandalone =(tflush(RRR
((s/sys/lib/python2.7/xmllib.pyRs+s
cCs!|j�dG|Gt|�GHdS(NsDOCTYPE:(R�trepr(RR0R	R
RE((s/sys/lib/python2.7/xmllib.pyR�/s
cCs<|j||_tt|j��dkr8|j�ndS(NiF(R�RTR�R�(RRE((s/sys/lib/python2.7/xmllib.pyRe3scCs.|j}|r*d|_dGt|�GHndS(NR4sdata:(R�R�(RRE((s/sys/lib/python2.7/xmllib.pyR�8s		cCs|j�dGt|�GHdS(Nscdata:(R�R�(RRE((s/sys/lib/python2.7/xmllib.pyR�>s
cCs!|j�dG|Gt|�GHdS(Nsprocessing:(R�R�(RRbRE((s/sys/lib/python2.7/xmllib.pyR�Bs
cCsN|j�t|�}t|�dkrA|d d|d}ndG|GHdS(NiDi s...i��comment:(R�R�RT(RREtr((s/sys/lib/python2.7/xmllib.pyR�Fs

cCsd|jG|GHdS(Nserror at line %d:(R:(RR�((s/sys/lib/python2.7/xmllib.pyROMscCsb|j�|s d|dGHn>d|Gx.|j�D] \}}|dd|dGq5WdGHdS(Nsstart tag: <RRR�(R�R�(RR0R�RbR�((s/sys/lib/python2.7/xmllib.pyR�Ps
cCs|j�d|dGHdS(Nsend tag: </R(R�(RR0((s/sys/lib/python2.7/xmllib.pyR�Zs
cCs|j�d|dGHdS(Ns*** unknown entity ref: &RJ(R�(RRM((s/sys/lib/python2.7/xmllib.pyR|^s
cCs|j�d|dGHdS(Ns*** unknown char ref: &#RJ(R�(RRM((s/sys/lib/python2.7/xmllib.pyR�bs
cCstj|�|j�dS(N(RRGR�(R((s/sys/lib/python2.7/xmllib.pyRGfs
(RRRRsR�ReR�R�R�R�ROR�R�R|R�RG(((s/sys/lib/python2.7/xmllib.pyR�%s										
			cCsddl}ddl}ddlm}|s>|jd}n|j|d�\}}t}d}x>|D]6\}}|dkr�t}qi|dkrid}qiqiW|r�|d}	nd}	|	d	kr�|j}
nCyt|	d
�}
Wn-tk
r}|	GdG|GH|j	d�nX|
j
�}|
|jk	r?|
j�n|�}
|�}yL|rt|
j|�|
j�n(x|D]}|
j|�q{W|
j�WnDt
k
r�}|�}|GH|r�d||GHn|j	d�nX|�}|rd||GHndS(
Ni�(ttimeitstis-ss-tstest.xmlR�R�R�stotal time: %g(tsystgetoptR�targvR�RtstdintopentIOErrortexittreadRGRFR(RBR�R�R�toptstklasstdo_timetotatfiletftmsgRERItt0R�tt1((s/sys/lib/python2.7/xmllib.pyttestjsV	



		


		t__main__(6t__doc__tretstringtwarningstwarntDeprecationWarningRtRuntimeErrorRt_St_opSt_Namet_QStrtcompileRiRgRKRMR{RyRhtnewlineR�RjtstarttagendtpatternR�RlR�R�R�RpR}t_SystemLiteralt_PublicLiteralt_ExternalIdRvRrRtR�RnR�R�t	maketransR�t_NCNameR�R�R�RR�R,R�R(((s/sys/lib/python2.7/xmllib.pyt<module>st	
-
")e
��E7

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].