Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/xml/dom/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/xml/dom/__pycache__/expatbuilder.cpython-35.opt-2.pyc



���]���@s�ddlmZmZmZddlmZmZmZddlmZddl	m
Z
mZddlm
Z
ejZejZejZejjZejjZejjZejjZej�Zdejdd�d	ejdd
�dejdd�d
ejdd�dejdd�dejdd�dejdd�dejdd�dejdd�i	ZGdd�de�Zdd�Zdd�ZGdd �d �ZeeefZGd!d"�d"e�Z Gd#d$�d$e�Z!Gd%d&�d&e!�Z"Gd'd(�d(e!�Z#d)Z$d*e$Z%Gd+d,�d,e�Z&Gd-d.�d.�Z'Gd/d0�d0e'e�Z(Gd1d2�d2e'e&�Z)Gd3d4�d4e*�Z+Gd5d6�d6e�Z,d7d8d9�Z-d7d:d;�Z.d7d<d=�Z/d7d>d?�Z0d@dA�Z1dS)B�)�
xmlbuilder�minidom�Node)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE)�expat)�
_append_child�_set_attribute_node)�
NodeFilterZCDATANZcdata�ENUM�enumerationZENTITY�entityZENTITIES�entities�ID�idZIDREFZidrefZIDREFSZidrefsZNMTOKENZnmtokenZNMTOKENSZnmtokensc@s�eZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�ZdS)�ElementInfo�
_attr_info�_model�tagNameNcCs||_g|_||_dS)N)rrr)�selfr�model�r�1/opt/alt/python35/lib64/python3.5/expatbuilder.py�__init__?s		zElementInfo.__init__cCs|j|j|jfS)N)rrr)rrrr�__getstate__DszElementInfo.__getstate__cCs|\|_|_|_dS)N)rrr)r�staterrr�__setstate__GszElementInfo.__setstate__cCsYxO|jD]D}|d|kr
|d}|ddkrBtdSt|dSq
WtjS)N��r�(r���r!)r�
_typeinfo_mapr�_no_type)r�aname�info�trrr�getAttributeTypeJs
zElementInfo.getAttributeTypecCstjS)N)rr#)rZnamespaceURIZ	localNamerrr�getAttributeTypeNSTszElementInfo.getAttributeTypeNScCs:|jr2|jd}|tjjtjjfkSdSdS)NrF)rrrZ
XML_CTYPE_ANYZXML_CTYPE_MIXED)r�typerrr�isElementContentWs
	
zElementInfo.isElementContentcCs(|jr |jdtjjkSdSdS)NrF)rrrZXML_CTYPE_EMPTY)rrrr�isEmpty_s	zElementInfo.isEmptycCs6x/|jD]$}|d|kr
|ddkSq
WdS)NrrrFr!)r)rr$r%rrr�isIdeszElementInfo.isIdcCs|j||f�S)N)r,)rZeuriZenameZaurir$rrr�isIdNSkszElementInfo.isIdNS)rrr)
�__name__�
__module__�__qualname__�	__slots__rrrr'r(r*r+r,r-rrrrr<s
rcCs|j||�S)N)�_intern_setdefault)�builder�srrr�_internosr5cCs�|jd�}|j}t|�dkry|\}}}|||�}d||f}|||�}|||�}nJt|�dkr�|\}}t}|||�}}ntd|��|||�|||fS)N� �z%s:%srz4Unsupported syntax: spaces in URIs not supported: %r)�splitr2�lenr�
ValueError)r3�name�parts�intern�uri�	localname�prefix�qnamerrr�_parse_ns_namers	rBc@sceZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�ZdS):�ExpatBuilderNcCst|dkrtj�}||_|jjdk	rKt|jj�|_nd|_t|_d|_|j	�dS)N)
rZOptions�_options�filter�FilterVisibilityController�_filterr�_finish_start_element�_parser�reset)r�optionsrrrr�s				zExpatBuilder.__init__cCs
tj�S)N)r�ParserCreate)rrrr�createParser�szExpatBuilder.createParsercCse|js^|j�|_|jjj|_d|j_d|j_d|j_|j|j�|jS)NT)	rIrMr=�
setdefaultr2Zbuffer_textZordered_attributesZspecified_attributes�install)rrrr�	getParser�s	zExpatBuilder.getParsercCs@tjtdd�|_|j|_|jj|_d|_dS)NF)�theDOMImplementationZcreateDocumentr�document�curNode�
_elem_info�_cdata)rrrrrJ�s
zExpatBuilder.resetcCs�|j|_|j|_|j|_|j|_|jj	rH|j
|_|j|_
|jjrl|j|_|jjr�|j|_|j|_|j|_n|j|_|j|_|j|_|j|_|j|_ dS)N)!�start_doctype_decl_handler�StartDoctypeDeclHandler�first_element_handler�StartElementHandler�end_element_handler�EndElementHandler�
pi_handler�ProcessingInstructionHandlerrDr�entity_decl_handler�EntityDeclHandler�notation_decl_handler�NotationDeclHandler�comments�comment_handler�CommentHandlerZcdata_sections�start_cdata_section_handler�StartCdataSectionHandler�end_cdata_section_handler�EndCdataSectionHandler�character_data_handler_cdata�CharacterDataHandler�character_data_handler�external_entity_ref_handler�ExternalEntityRefHandler�xml_decl_handlerZXmlDeclHandler�element_decl_handlerZElementDeclHandler�attlist_decl_handlerZAttlistDeclHandler)r�parserrrrrO�s$zExpatBuilder.installcCs�|j�}d}yfxO|jd�}|s.P|j|d�|r]|jjr]|j|�d}qW|jdd�Wntk
r�YnX|j}|j�d|_|S)NT�irF�i@)	rP�read�ParserR�documentElement�
_setup_subset�ParseEscaperJrI)r�filerqZfirst_buffer�buffer�docrrr�	parseFile�s$


	
	zExpatBuilder.parseFilecCsb|j�}y!|j|d�|j|�Wntk
rAYnX|j}|j�d|_|S)NT)rPrurwrxrRrJrI)r�stringrqr{rrr�parseString�s
	
	zExpatBuilder.parseStringcCsA|jjr=t�}|j|�|j�}||jj_dS)N)rR�doctype�InternalSubsetExtractorr~�	getSubset�internalSubset)rrzZ	extractor�subsetrrrrw�s
	
zExpatBuilder._setup_subsetcCs�|jjj|||�}|j|_t|j|�||j_|jr�|jj|�tkr�d|j_|jj	d=d}d|j
_d|j
_|r�|dk	r�g|j
_g|j_d|j
_d|j
_|j|j
_dS)Nr���)rR�implementationZcreateDocumentType�
ownerDocumentr	rrG�
acceptNode�
FILTER_REJECT�
childNodesrIr_rar�_seq�	notationsrdr]�end_doctype_decl_handler�EndDoctypeDeclHandler)rZdoctypeName�systemId�publicId�has_internal_subsetrrrrrV�s$!
z'ExpatBuilder.start_doctype_decl_handlercCsI|jjr|j|j_|j|j_|jp9|jsEt	|_
dS)N)rDrbrcrIrdr\r]rTrGr�_finish_end_element)rrrrr�s
z%ExpatBuilder.end_doctype_decl_handlercCsZ|jj||�}t|j|�|jrV|jj|�tkrV|jj|�dS)N)rRZcreateProcessingInstructionr	rSrGr�r��removeChild)r�target�data�noderrrr\s!zExpatBuilder.pi_handlercCs�|jj}|jrd|jrF|djtkrF|dj|�dS|jj|�}d|_n^|r�|djt	kr�|d}|j
|}||_
dStj�}||_
|j|_
t|j|�dS)NrTr�r�r�r�)rSr�rU�_cdata_continue�nodeType�CDATA_SECTION_NODEZ
appendDatarRZcreateCDATASection�	TEXT_NODEr�r�Textr�r	)rr�r�r��valuerrrris"		

		z)ExpatBuilder.character_data_handler_cdatacCs|jj}|rC|djtkrC|d}|j||_dStj�}|j||_|j|_t	|j|�dS)Nrr�r�)
rSr�r�r�r�rr�rRr�r	)rr�r�r�rrrrk&s
z#ExpatBuilder.character_data_handlerc
Cs�|r
dS|jjsdS|jj||||�}|dk	rc|jj|�}	|jj|	�|jjjjj|�|j	r�|j	j
|�tkr�|jjjjd=dS)Nrr�)rDrrRZ_create_entityZcreateTextNoder��appendrr�rGr�r�)
rZ
entityNameZis_parameter_entityr��baser�r��notationNamer��childrrrr^1s!z ExpatBuilder.entity_decl_handlercCsi|jj|||�}|jjjjj|�|jre|jj|�tkre|jjjjd=dS)Nrr�)	rRZ_create_notationrr�r�r�rGr��
FILTER_ACCEPT)rr�r�r�r�r�rrrr`Cs!z"ExpatBuilder.notation_decl_handlercCsW|jj|�}t|j|�|jrS|jj|�tkrS|jj|�dS)N)rRZ
createCommentr	rSrGr�r�r�)rr�r�rrrrcIs!zExpatBuilder.comment_handlercCsd|_d|_dS)NTF)rUr�)rrrrreOs	z(ExpatBuilder.start_cdata_section_handlercCsd|_d|_dS)NF)rUr�)rrrrrgSs	z&ExpatBuilder.end_cdata_section_handlercCsdS)Nrr)r�contextr�r�r�rrrrlWsz(ExpatBuilder.external_entity_ref_handlercCsH|jdkr"|jr"t|_|j|j�_|j||�dS)N)rGrTrr��start_element_handlerrPrY)rr;�
attributesrrrrXZs	z"ExpatBuilder.first_element_handlercCs�|jj|�}t|j|�||_|r�xltdt|�d�D]R}tj||tdt	�}||d}||_
|j|_t||�qJW||jj
k	r�|j|�dS)Nrrr)rRZ
createElementr	rS�ranger9r�Attrrrr�r�r
rvrH)rr;r�r��i�ar�rrrr�`s		z"ExpatBuilder.start_element_handlercCs�|jr�||jjkrdS|jj|�}|tkrJt|�n|tkrct|�ndS|j|_	|jj
|�|j�dS)N)rGrRrv�startContainerr��Rejecter�FILTER_SKIP�Skipper�
parentNoderSr��unlink)rr�ZfiltrrrrHqs	

z"ExpatBuilder._finish_start_elementcCs&|j}|j|_|j|�dS)N)rSr�r�)rr;rSrrrrZ�s	z ExpatBuilder.end_element_handlercCs�|jj|j�}|r+|j||�|jr|||jjkrJdS|jj|�tkr||j	j
|�|j�dS)N)rT�getr�_handle_white_text_nodesrGrRrvr�r�rSr�r�)rrSr%rrrr��s	z ExpatBuilder._finish_end_elementcCs�|jjs|j�rdSg}x=|jD]2}|jtkr-|jj�r-|j|�q-Wx|D]}|j	|�qjWdS)N)
rDZwhitespace_in_element_contentr*r�r�r�r��stripr�r�)rr�r%�Lr�rrrr��s

z%ExpatBuilder._handle_white_text_nodescCsD|jj|�}|dkr7t||�|j|<n	||_dS)N)rTr�rr)rr;rr%rrrro�sz!ExpatBuilder.element_decl_handlerc	Csc|jj|�}|dkr7t|�}||j|<|jjd|dd|d||g�dS)Nr)rTr�rrr�)r�elemr;r)�default�requiredr%rrrrp�s
	z!ExpatBuilder.attlist_decl_handlercCsI||j_||j_|dkrE|r9d|j_nd|j_dS)NrTF)rR�version�encoding�
standalone)rr�r�r�rrrrn�szExpatBuilder.xml_decl_handler)r.r/r0rrMrPrJrOr|r~rwrVr�r\rirkr^r`rcrergrlrXr�rHrZr�r�rorprnrrrrrC�s8
rCc@s�eZdZd	Zdd�Zdd�Zdd�Zeje	j
eje	jej
e	jeje	jeje	jeje	jeje	jeje	jeje	jeje	jeje	jeje	j iZ!dS)
rFrEcCs
||_dS)N)rE)rrErrrr�sz#FilterVisibilityController.__init__cCsr|j|j}|jj|@rj|jj|�}|tkrDt�|tkrftdt	|���|St
SdS)Nz)startContainer() returned illegal value: )�_nodetype_maskr�rE�
whatToShowr��FILTER_INTERRUPTrx�_ALLOWED_FILTER_RETURNSr:�reprr�)rr��mask�valrrrr��sz)FilterVisibilityController.startContainercCs�|j|j}|jj|@r�|jj|�}|tkrDt�|tkr�|j}x(|j	dd�D]}|j
|�qmWtS|tkr�t
dt|���|StSdS)Nz%acceptNode() returned illegal value: )r�r�rEr�r�r�rxr�r�r�ZappendChildr�r�r:r�r�)rr�r�r��parentr�rrrr��s	z%FilterVisibilityController.acceptNodeN)rE)"r.r/r0r1rr�r�rZELEMENT_NODErZSHOW_ELEMENTZATTRIBUTE_NODEZSHOW_ATTRIBUTEr�Z	SHOW_TEXTr�ZSHOW_CDATA_SECTIONZENTITY_REFERENCE_NODEZSHOW_ENTITY_REFERENCEZENTITY_NODEZSHOW_ENTITYZPROCESSING_INSTRUCTION_NODEZSHOW_PROCESSING_INSTRUCTIONZCOMMENT_NODEZSHOW_COMMENT�
DOCUMENT_NODEZ
SHOW_DOCUMENTZDOCUMENT_TYPE_NODEZSHOW_DOCUMENT_TYPEZDOCUMENT_FRAGMENT_NODEZSHOW_DOCUMENT_FRAGMENTZ
NOTATION_NODEZ
SHOW_NOTATIONr�rrrrrF�s 
rFc@s"eZdZdZdd�ZdS)	�FilterCrutch�_builder�_level�
_old_start�_old_endcCsOd|_||_|j}|j|_|j|_|j|_|j|_dS)Nr)	r�r�rIrYr�r[r�r�rZ)rr3rqrrrrs			zFilterCrutch.__init__N)r�r�r�r�)r.r/r0r1rrrrrr�sr�c@s:eZdZfZdd�Zdd�Zdd�ZdS)r�cCs>tj||�|j}xdD]}t||d�q WdS)Nr]rdrjrfrhrm)r]rdrjrfrhrm)r�rrI�setattr)rr3rqr;rrrrs	
zRejecter.__init__cGs|jd|_dS)Nr)r�)r�argsrrrr�szRejecter.start_element_handlercGsZ|jdkrF|jj}|jj|�|j|_|j|_n|jd|_dS)Nrr)r�r�rIrOr�rYr�r[)rr�rqrrrrZ szRejecter.end_element_handlerN)r.r/r0r1rr�rZrrrrr�sr�c@s.eZdZfZdd�Zdd�ZdS)r�cGs?|jj}|j|�|jj|k	r;|jd|_dS)Nr)r�rSr�r�)rr�r�rrrr�-s
zSkipper.start_element_handlercGs`|jdkr?|j|jj_|j|jj_d|_n|jd|_|j|�dS)Nrr)r�r�r�rIrYr�r[)rr�rrrrZ3szSkipper.end_element_handlerN)r.r/r0r1r�rZrrrrr�*sr�z8http://xml.python.org/entities/fragment-builder/internalz�<!DOCTYPE wrapper
  %%s [
  <!ENTITY fragment-builder-internal
    SYSTEM "%s">
%%s
]>
<wrapper %%s
>&fragment-builder-internal;</wrapper>c@sgeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�FragmentBuilderNcCsM|jtkr$||_||_n|j|_||_tj||�dS)N)r�r��originalDocumentr�r�rCr)rr�rKrrrr[s		zFragmentBuilder.__init__cCstj|�d|_dS)N)rCrJ�fragment)rrrrrJds
zFragmentBuilder.resetcCs|j|j��S)N)r~rt)rryrrrr|hszFragmentBuilder.parseFilec		Cs�||_|j�}|jj}d}|r}|jp?|j�}|jrdd|j|jf}q�|jr�d|j}nd}|j�}t	|||f}y|j
|d�Wn|j��YnX|j}|j�|S)NrszPUBLIC "%s" "%s"zSYSTEM "%s"r)
�_sourcerPr�rr��_getDeclarationsr�r��_getNSattrs�_FRAGMENT_BUILDER_TEMPLATErurJr�)	rr}rqr�identr�ZnsattrsrRr�rrrr~ms,			
	
zFragmentBuilder.parseStringcCs{|jjj}d}|rwx�t|jj�D]s}|jj|�}|rV|d}d||jf}|jr�d||j|j	f}q.d||j	f}q.Wx�t|j
j�D]�}|j
j|�}|r�|d}d||jf}|jrd||j|j	f}n5|j	r7d||j	f}nd	||jjf}|j
rid
||j
f}|d}q�W|S)Nrsz
  z%s<!NOTATION %sz!%s PUBLIC "%s"
             "%s">z%s SYSTEM "%s">z
%s<!ENTITY %sz %s PUBLIC "%s"
             "%s"z%s SYSTEM "%s"z%s "%s"z%s NOTATION %s�>)r�r�rr�r��length�itemZnodeNamer�r�rZ
firstChildr�r�)rrr4r�Znotationrrrrr��s6
	
			z FragmentBuilder._getDeclarationscCsdS)Nrsr)rrrrr��szFragmentBuilder._getNSattrscCs�|tkr�|j}|j}|jj|�}|j|_|jj�|_|j|_z|j|j	d�Wd||_||_d|_	XdSt
j|||||�SdS)Nrr�)�$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDrRrSrIZExternalEntityParserCreater�ZcreateDocumentFragmentr�rur�rCrl)rr�r�r�r�Zold_documentZold_cur_noderqrrrrl�s				
z+FragmentBuilder.external_entity_ref_handler)
r.r/r0rrJr|r~r�r�rlrrrrr�Rs		$r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
NamespacescCs
g|_dS)N)�_ns_ordered_prefixes)rrrr�_initNamespaces�szNamespaces._initNamespacescCstjdd�}d|_|S)NZnamespace_separatorr6T)rrLZnamespace_prefixes)rrqrrrrM�s	zNamespaces.createParsercCs,tj||�|jjr(|j|_dS)N)rCrOrDZnamespace_declarations�start_namespace_decl_handlerZStartNamespaceDeclHandler)rrqrrrrO�szNamespaces.installcCs|jj||f�dS)N)r�r�)rr@r>rrrr��sz'Namespaces.start_namespace_decl_handlercCs'd|kr*t||�\}}}}nt}|}d}t}tj||||�}|j|_t|j|�||_|j	rx|j	D]t\}}|r�tj
t|d|�t|d�}ntj
dtdt�}||_
|j|_t||�q�W|j	dd�=|r#|j�|j}	|j}
x�tdt|�d�D]�}||}||d}
d|kr�t||�\}}}}tj
||||�}||	|<||
||f<n2tj
|t|t�}||	|<||
t|f<|j|_|
|_
||_qUWdS)Nr6zxmlns:�xmlnsrrr)rBrrrZElementrRr�r	rSr�r�r5rr�r
Z_ensure_attributes�_attrs�_attrsNSr�r9ZownerElement)rr;r�r>r?r@rAr�r�r�r�r�r$r�rrrr��sP			
		


	z Namespaces.start_element_handlerN)r.r/r0r�rMrOr�r�rrrrr��s/r�c@seZdZdd�ZdS)�ExpatBuilderNScCstj|�|j�dS)N)rCrJr�)rrrrrJ)s
zExpatBuilderNS.resetN)r.r/r0rJrrrrr�&sr�c@s(eZdZdd�Zdd�ZdS)�FragmentBuilderNScCstj|�|j�dS)N)r�rJr�)rrrrrJ1s
zFragmentBuilderNS.resetcCs�d}|j}g}x�|r�t|d�r�x~|jj�D]m\}}||krXq=|j|�|rxd|}nd}|r�d|||f}q=d||f}q=W|j}qW|S)Nrs�_ns_prefix_urizxmlns:r�z%s
    %s='%s'z %s='%s')r��hasattrr��itemsr�r�)r�attrsr�r�r@r>Zdeclnamerrrr�5s"		


zFragmentBuilderNS._getNSattrsN)r.r/r0rJr�rrrrr�.sr�c@seZdZdS)rxN)r.r/r0rrrrrxSsrxc@sjeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)r�NcCs|jS)N)r�)rrrrr�\sz!InternalSubsetExtractor.getSubsetcCs-ytj||�Wntk
r(YnXdS)N)rCr|rx)rryrrrr|`s
z!InternalSubsetExtractor.parseFilecCs-ytj||�Wntk
r(YnXdS)N)rCr~rx)rr}rrrr~fs
z#InternalSubsetExtractor.parseStringcCs|j|_|j|_dS)N)rVrWr�rY)rrqrrrrOlszInternalSubsetExtractor.installcCsF|r9|j�}g|_|jj|_|j|_n	t��dS)N)rPr�r�ZDefaultHandlerr�r�rx)rr;r�r�r�rqrrrrVps	z2InternalSubsetExtractor.start_doctype_decl_handlercCs@dj|j�jdd�jdd�}||_t��dS)Nrsz
�
�
)�joinr��replacerx)rr4rrrr�zs*	z0InternalSubsetExtractor.end_doctype_decl_handlercCs
t��dS)N)rx)rr;r�rrrr�sz-InternalSubsetExtractor.start_element_handler)r.r/r0r�r�r|r~rOrVr�r�rrrrr�Ws
r�Tc	Csh|rt�}n	t�}t|t�rUt|d��}|j|�}WdQRXn|j|�}|S)N�rb)r�rC�
isinstance�str�openr|)ry�
namespacesr3�fp�resultrrr�parse�s	r�cCs(|rt�}n	t�}|j|�S)N)r�rCr~)r}r�r3rrrr~�s	r~c	Csn|rt|�}nt|�}t|t�r[t|d��}|j|�}WdQRXn|j|�}|S)Nr�)r�r�r�r�r�r|)ryr�r�r3r�r�rrr�
parseFragment�sr�cCs.|rt|�}nt|�}|j|�S)N)r�r�r~)r}r�r�r3rrr�parseFragmentString�sr�cCs!|jrt|�St|�SdS)N)r�r�rC)rKrrr�makeBuilder�s	
r�)2Zxml.domrrrrrrZxml.parsersrZxml.dom.minidomr	r
Zxml.dom.NodeFilterrr�r�r�ZDOMBuilderFilterr�r�r�r�ZgetDOMImplementationrQZTypeInfor"�objectrr5rBrCr�rFr�r�r�r�r�r�r�r�r��	Exceptionrxr�r�r~r�r�r�rrrr�<module>sZ			3�B:u_%,

Hacked By AnonymousFox1.0, Coded By AnonymousFox