Your IP : 18.119.109.60


Current Path : /usr/lib64/python3.8/xml/dom/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/xml/dom/__pycache__/expatbuilder.cpython-38.opt-2.pyc

U

e5d���@sddlmZmZmZddlmZmZmZddlmZddl	m
Z
mZddlm
Z
ejZejZejZejjZejjZejjZejjZe��Ze�dd�e�dd�e�dd	�e�dd
�e�dd�e�dd�e�dd
�e�dd�e�dd�d�	ZGdd�de�Zdd�Zdd�ZGdd�d�ZeeefZGdd�de�Z Gdd�de�Z!Gdd�de!�Z"Gdd �d e!�Z#d!Z$d"e$Z%Gd#d$�d$e�Z&Gd%d&�d&�Z'Gd'd(�d(e'e�Z(Gd)d*�d*e'e&�Z)Gd+d,�d,e*�Z+Gd-d.�d.e�Z,d:d0d1�Z-d;d2d3�Z.d<d4d5�Z/d=d6d7�Z0d8d9�Z1dS)>�)�
xmlbuilder�minidom�Node)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE)�expat)�
_append_child�_set_attribute_node)�
NodeFilterNZcdata�enumeration�entity�entities�idZidrefZidrefsZnmtokenZnmtokens)	ZCDATA�ENUMZENTITYZENTITIES�IDZIDREFZIDREFSZNMTOKENZNMTOKENSc@sZeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�ElementInfo��
_attr_info�_model�tagNameNcCs||_g|_||_dS�N)rrr)�selfr�model�r�,/usr/lib64/python3.8/xml/dom/expatbuilder.py�__init__?szElementInfo.__init__cCs|j|j|jfSrr�rrrr�__getstate__DszElementInfo.__getstate__cCs|\|_|_|_dSrr)r�staterrr�__setstate__GszElementInfo.__setstate__cCsN|jD]@}|d|kr|d}|ddkr6tdSt|dSqtjS)N����r�(r)r�
_typeinfo_mapr�_no_type)r�aname�info�trrr�getAttributeTypeJs
zElementInfo.getAttributeTypecCstjSr)rr%)rZnamespaceURIZ	localNamerrr�getAttributeTypeNSTszElementInfo.getAttributeTypeNScCs,|jr$|jd}|tjjtjjfkSdSdS�NrF)rrrZ
XML_CTYPE_ANYZXML_CTYPE_MIXED)r�typerrr�isElementContentWs
�zElementInfo.isElementContentcCs |jr|jdtjjkSdSdSr+)rrrZXML_CTYPE_EMPTYrrrr�isEmpty_szElementInfo.isEmptycCs,|jD] }|d|kr|ddkSqdS)Nr!r"rF)r)rr&r'rrr�isIdes
zElementInfo.isIdcCs|�||f�Sr)r/)rZeuriZenameZaurir&rrr�isIdNSkszElementInfo.isIdNS)N)
�__name__�
__module__�__qualname__�	__slots__rrr r)r*r-r.r/r0rrrrr<s

rcCs|�||�Sr)�_intern_setdefault)�builder�srrr�_internosr8cCs�|�d�}|j}t|�dkrR|\}}}|||�}d||f}|||�}|||�}n4t|�dkrz|\}}t}|||�}}ntd|��|||�|||fS)N� �z%s:%s�z4Unsupported syntax: spaces in URIs not supported: %r)�splitr5�lenr�
ValueError)r6�name�parts�intern�uri�	localname�prefix�qnamerrr�_parse_ns_namers



rFc@s�eZdZd:dd�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);�ExpatBuilderNcCsP|dkrt��}||_|jjdk	r2t|jj�|_nd|_t|_d|_|�	�dSr)
rZOptions�_options�filter�FilterVisibilityController�_filterr�_finish_start_element�_parser�reset)r�optionsrrrr�szExpatBuilder.__init__cCst��Sr)r�ParserCreaterrrr�createParser�szExpatBuilder.createParsercCsF|js@|��|_|jjj|_d|j_d|j_d|j_|�|j�|jS�NT)	rMrQrA�
setdefaultr5Zbuffer_textZordered_attributesZspecified_attributes�installrrrr�	getParser�s
zExpatBuilder.getParsercCs,t�tdd�|_|j|_|jj|_d|_dS�NF)�theDOMImplementationZcreateDocumentr�document�curNode�
_elem_info�_cdatarrrrrN�s�
zExpatBuilder.resetcCs�|j|_|j|_|j|_|j|_|jj	r0|j
|_|j|_
|jjrH|j|_|jjrj|j|_|j|_|j|_n|j|_|j|_|j|_|j|_|j|_ dSr)!�start_doctype_decl_handler�StartDoctypeDeclHandler�first_element_handler�StartElementHandler�end_element_handler�EndElementHandler�
pi_handler�ProcessingInstructionHandlerrHr�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�parserrrrrT�s$
zExpatBuilder.installcCs�|��}d}zH|�d�}|sqF|�|d�|r@|jjr@|�|�d}q|�dd�Wntk
rhYnX|j}|��d|_|S)NTi@rF�)	rU�read�ParserX�documentElement�
_setup_subset�ParseEscaperNrM)r�filerxZfirst_buffer�buffer�docrrr�	parseFile�s"

zExpatBuilder.parseFilecCsP|��}z|�|d�|�|�Wntk
r6YnX|j}|��d|_|SrR)rUr{r}r~rXrNrM)r�stringrxr�rrr�parseString�szExpatBuilder.parseStringcCs.|jjr*t�}|�|�|��}||jj_dSr)rX�doctype�InternalSubsetExtractorr��	getSubset�internalSubset)rr�Z	extractor�subsetrrrr}�s

zExpatBuilder._setup_subsetcCs�|jj�|||�}|j|_t|j|�||j_|jrj|j�|�tkrjd|j_|jj	d=d}d|j
_d|j
_|r�|dk	r�g|j
_g|j_d|j
_d|j
_|j|j
_dS�N���)rX�implementationZcreateDocumentType�
ownerDocumentr	r�rK�
acceptNode�
FILTER_REJECT�
childNodesrMrergr�_seq�	notationsrjrc�end_doctype_decl_handler�EndDoctypeDeclHandler)rZdoctypeName�systemId�publicId�has_internal_subsetr�rrrr\�s*�
z'ExpatBuilder.start_doctype_decl_handlercCs2|jjr|j|j_|j|j_|js.|js.t	|_
dSr)rHrhrirMrjrbrcrZrKr�_finish_end_elementrrrrr�s


z%ExpatBuilder.end_doctype_decl_handlercCs@|j�||�}t|j|�|jr<|j�|�tkr<|j�|�dSr)rXZcreateProcessingInstructionr	rYrKr�r��removeChild)r�target�data�noderrrrbszExpatBuilder.pi_handlercCs�|jj}|jrH|jr4|djtkr4|d�|�dS|j�|�}d|_nD|rv|djt	krv|d}|j
|}||_
dSt��}||_
|j|_
t|j|�dS)Nr�T)rYr�r[�_cdata_continue�nodeType�CDATA_SECTION_NODEZ
appendDatarXZcreateCDATASection�	TEXT_NODEr�r�Textr�r	)rr�r�r��valuerrrros$�
z)ExpatBuilder.character_data_handler_cdatacCs^|jj}|r2|djtkr2|d}|j||_dSt��}|j||_|j|_t	|j|�dSr�)
rYr�r�r�r�rr�rXr�r	)rr�r�r�rrrrq&sz#ExpatBuilder.character_data_handlerc
Cs�|rdS|jjsdS|j�||||�}|dk	rF|j�|�}	|j�|	�|jjjj�|�|j	r||j	�
|�tkr||jjjjd=dSr�)rHrrXZ_create_entityZcreateTextNoder��appendr�r�rKr�r�)
rZ
entityNameZis_parameter_entityr��baser�r��notationNamer��childrrrrd1s
�z ExpatBuilder.entity_decl_handlercCsJ|j�|||�}|jjjj�|�|jrF|j�|�tkrF|jjjjd=dSr�)	rXZ_create_notationr�r�r�r�rKr��
FILTER_ACCEPT)rr�r�r�r�r�rrrrfCsz"ExpatBuilder.notation_decl_handlercCs>|j�|�}t|j|�|jr:|j�|�tkr:|j�|�dSr)rXZ
createCommentr	rYrKr�r�r�)rr�r�rrrriIszExpatBuilder.comment_handlercCsd|_d|_dS)NTF�r[r�rrrrrkOsz(ExpatBuilder.start_cdata_section_handlercCsd|_d|_dSrVr�rrrrrmSsz&ExpatBuilder.end_cdata_section_handlercCsdS�Nr!r)r�contextr�r�r�rrrrrWsz(ExpatBuilder.external_entity_ref_handlercCs2|jdkr|jst|_|j|��_|�||�dSr)rKrZrr��start_element_handlerrUr_)rr?�
attributesrrrr^Zsz"ExpatBuilder.first_element_handlercCs�|j�|�}t|j|�||_|rptdt|�d�D]<}t�||tdt	�}||d}||_
|j|_t||�q2||jj
k	r�|�|�dS)Nrr;r!)rXZ
createElementr	rY�ranger=r�Attrrrr�r�r
r|rL)rr?r�r��i�ar�rrrr�`s�z"ExpatBuilder.start_element_handlercCsj|jrf||jjkrdS|j�|�}|tkr4t|�n|tkrFt|�ndS|j|_	|j�
|�|��dSr)rKrXr|�startContainerr��Rejecter�FILTER_SKIP�Skipper�
parentNoderYr��unlink)rr�ZfiltrrrrLqs

z"ExpatBuilder._finish_start_elementcCs|j}|j|_|�|�dSr)rYr�r�)rr?rYrrrr`�sz ExpatBuilder.end_element_handlercCs\|j�|j�}|r|�||�|jrX||jjkr4dS|j�|�tkrX|j	�
|�|��dSr)rZ�getr�_handle_white_text_nodesrKrXr|r�r�rYr�r�)rrYr'rrrr��sz ExpatBuilder._finish_end_elementcCsZ|jjs|��sdSg}|jD]"}|jtkr|j��s|�|�q|D]}|�	|�qFdSr)
rHZwhitespace_in_element_contentr-r�r�r�r��stripr�r�)rr�r'�Lr�rrrr��s�
z%ExpatBuilder._handle_white_text_nodescCs0|j�|�}|dkr&t||�|j|<n||_dSr)rZr�rr)rr?rr'rrrru�sz!ExpatBuilder.element_decl_handlerc
CsF|j�|�}|dkr&t|�}||j|<|j�d|dd|d||g�dS�Nr)rZr�rrr�)r�elemr?r,�defaultZrequiredr'rrrrv�s
�z!ExpatBuilder.attlist_decl_handlercCs2||j_||j_|dkr.|r&d|j_nd|j_dS)NrTF)rX�version�encoding�
standalone)rr�r�r�rrrrt�s
zExpatBuilder.xml_decl_handler)N)r1r2r3rrQrUrNrTr�r�r}r\r�rbrorqrdrfrirkrmrrr^r�rLr`r�r�rurvrtrrrrrG�s8

rGc@s�eZdZdZdd�Zdd�Zdd�Zeje	j
eje	jej
e	jeje	jeje	jeje	jeje	jeje	jeje	jeje	jeje	jeje	j iZ!dS)	rJ�rIcCs
||_dSrr�)rrIrrrr�sz#FilterVisibilityController.__init__cCsT|j|j}|jj|@rL|j�|�}|tkr0t�|tkrHtdt	|���|St
SdS)Nz)startContainer() returned illegal value: )�_nodetype_maskr�rI�
whatToShowr��FILTER_INTERRUPTr~�_ALLOWED_FILTER_RETURNSr>�reprr�)rr��mask�valrrrr��s
�z)FilterVisibilityController.startContainercCs�|j|j}|jj|@r||j�|�}|tkr0t�|tkr`|j}|j	dd�D]}|�
|�qLtS|tkrxt
dt|���|StSdS)Nz%acceptNode() returned illegal value: )r�r�rIr�r�r�r~r�r�r�ZappendChildr�r�r>r�r�)rr�r�r��parentr�rrrr��s 
�z%FilterVisibilityController.acceptNodeN)"r1r2r3r4rr�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�rrrrrJ�s:
�rJc@seZdZdZdd�ZdS)�FilterCrutch)�_builder�_level�
_old_start�_old_endcCs6d|_||_|j}|j|_|j|_|j|_|j|_dSr�)	r�r�rMr_r�rar�r�r`)rr6rxrrrrszFilterCrutch.__init__N)r1r2r3r4rrrrrr�sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�rcCs,t�||�|j}dD]}t||d�qdS)N)rcrjrprlrnrs)r�rrM�setattr)rr6rxr?rrrrszRejecter.__init__cGs|jd|_dSr�)r��r�argsrrrr�szRejecter.start_element_handlercGs@|jdkr0|jj}|j�|�|j|_|j|_n|jd|_dS�Nrr!)r�r�rMrTr�r_r�ra)rr�rxrrrr` s

zRejecter.end_element_handlerN)r1r2r3r4rr�r`rrrrr�sr�c@s eZdZdZdd�Zdd�ZdS)r�rcGs.|jj}|j|�|jj|k	r*|jd|_dSr�)r�rYr�r�)rr�r�rrrr�-s
zSkipper.start_element_handlercGsD|jdkr*|j|jj_|j|jj_d|_n|jd|_|j|�dSr�)r�r�r�rMr_r�rar�rrrr`3s
zSkipper.end_element_handlerN)r1r2r3r4r�r`rrrrr�*sr�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@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�FragmentBuilderNcCs6|jtkr||_||_n|j|_||_t�||�dSr)r�r��originalDocumentr�r�rGr)rr�rOrrrr[s
zFragmentBuilder.__init__cCst�|�d|_dSr)rGrN�fragmentrrrrrNds
zFragmentBuilder.resetcCs|�|���Sr)r�rz�rrrrrr�hszFragmentBuilder.parseFilec	Cs�||_|��}|jj}d}|rV|jp*|��}|jrDd|j|jf}qZ|jrZd|j}nd}|��}t	|||f}z|�
|d�Wn|���YnX|j}|��|S)NryzPUBLIC "%s" "%s"zSYSTEM "%s"r!)
�_sourcerUr�r�r��_getDeclarationsr�r��_getNSattrs�_FRAGMENT_BUILDER_TEMPLATEr{rNr�)	rr�rxr�Zidentr�ZnsattrsrXr�rrrr�ms.
�zFragmentBuilder.parseStringcCs|jjj}d}|�rt|jj�D]R}|j�|�}|r<|d}d||jf}|jrdd||j|j	f}q d||j	f}q t|j
j�D]�}|j
�|�}|r�|d}d||jf}|jr�d||j|j	f}n&|j	r�d||j	f}nd	||jjf}|j
r�d
||j
f}|d}q�|S)Nryz
  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�r�r�r�Zlength�itemZnodeNamer�r�rZ
firstChildr�r�)rr�r7r�Znotationr
rrrr��s:
��
z FragmentBuilder._getDeclarationscCsdS)Nryrrrrrr��szFragmentBuilder._getNSattrscCs~|tkrh|j}|j}|j�|�}|j|_|j��|_|j|_z|�	|jd�W5||_||_d|_XdSt
�|||||�SdS)Nr!r�)�$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDrXrYrMZExternalEntityParserCreater�ZcreateDocumentFragmentr�r�r{rGrr)rr�r�r�r�Zold_documentZold_cur_noderxrrrrr�s(�z+FragmentBuilder.external_entity_ref_handler)N)
r1r2r3rrNr�r�r�r�rrrrrrr�Rs	
	$r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
NamespacescCs
g|_dSr)�_ns_ordered_prefixesrrrr�_initNamespaces�szNamespaces._initNamespacescCstjdd�}d|_|S)Nr9)Znamespace_separatorT)rrPZnamespace_prefixesrwrrrrQ�szNamespaces.createParsercCs t�||�|jjr|j|_dSr)rGrTrHZnamespace_declarations�start_namespace_decl_handlerZStartNamespaceDeclHandlerrwrrrrT�s�zNamespaces.installcCs|j�||f�dSr)r�r�)rrDrBrrrr��sz'Namespaces.start_namespace_decl_handlercCs�d|krt||�\}}}}nt}|}d}t}t�||||�}|j|_t|j|�||_|j	r�|j	D]P\}}|r�t�
t|d|�t|d�}nt�
dtdt�}||_
|j|_t||�qb|j	dd�=|�r~|��|j}	|j}
tdt|�d�D]�}||}||d}
d|k�rDt||�\}}}}t�
||||�}||	|<||
||f<n$t�
|t|t�}||	|<||
t|f<|j|_|
|_
||_q�dS)Nr9�xmlns:�xmlnsrr;r!)rFrrrZElementrXr�r	rYr�r�r8rr�r
Z_ensure_attributes�_attrs�_attrsNSr�r=ZownerElement)rr?r�rBrCrDrEr�r�r�r�r�r&r�rrrr��s^��
�z Namespaces.start_element_handlerN)	r1r2r3r�rQrTr�r�r`rrrrr��s5r�c@seZdZdd�ZdS)�ExpatBuilderNScCst�|�|��dSr)rGrNr�rrrrrN)s
zExpatBuilderNS.resetN)r1r2r3rNrrrrr�&sr�c@seZdZdd�Zdd�ZdS)�FragmentBuilderNScCst�|�|��dSr)r�rNr�rrrrrN1s
zFragmentBuilderNS.resetcCs�d}|j}g}|r~t|d�rv|j��D]N\}}||kr8q&|�|�|rPd|}nd}|rhd|||f}q&d||f}q&|j}q|S)Nry�_ns_prefix_urir�r�z%s
    %s='%s'z %s='%s')r��hasattrr��itemsr�r�)r�attrsr�r�rDrBZdeclnamerrrr�5s"


zFragmentBuilderNS._getNSattrsN)r1r2r3rNr�rrrrr�.sr�c@seZdZdS)r~N)r1r2r3rrrrr~Ssr~c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)r�NcCs|jSr)r�rrrrr�\sz!InternalSubsetExtractor.getSubsetcCs*zt�||�Wntk
r$YnXdSr)rGr�r~r�rrrr�`sz!InternalSubsetExtractor.parseFilecCs*zt�||�Wntk
r$YnXdSr)rGr�r~)rr�rrrr�fsz#InternalSubsetExtractor.parseStringcCs|j|_|j|_dSr)r\r]r�r_rwrrrrTlszInternalSubsetExtractor.installcCs0|r&|��}g|_|jj|_|j|_nt��dSr)rUr�r�ZDefaultHandlerr�r�r~)rr?r�r�r�rxrrrr\ps

z2InternalSubsetExtractor.start_doctype_decl_handlercCs,d�|j��dd��dd�}||_t��dS)Nryz
�
�
)�joinr��replacer~)rr7rrrr�zsz0InternalSubsetExtractor.end_doctype_decl_handlercCs
t��dSr)r~)rr?r�rrrr�sz-InternalSubsetExtractor.start_element_handler)r1r2r3r�r�r�r�rTr\r�r�rrrrr�Ws
r�Tc	CsL|rt�}nt�}t|t�r>t|d��}|�|�}W5QRXn
|�|�}|S�N�rb)r�rG�
isinstance�str�openr�)r�
namespacesr6�fp�resultrrr�parse�s

r�cCs|rt�}nt�}|�|�Sr)r�rGr�)r�r�r6rrrr��sr�c	CsP|rt|�}nt|�}t|t�rBt|d��}|�|�}W5QRXn
|�|�}|Sr�)r�r�r�r�r�r�)rr�r�r6r�r�rrr�
parseFragment�s


r�cCs |rt|�}nt|�}|�|�Sr)r�r�r�)r�r�r�r6rrr�parseFragmentString�s
r�cCs|jrt|�St|�SdSr)r�r�rG)rOrrr�makeBuilder�sr�)T)T)T)T)2Zxml.domrrrrrrZxml.parsersrZxml.dom.minidomr	r
Zxml.dom.NodeFilterrr�r�r�ZDOMBuilderFilterr�r�r�r�ZgetDOMImplementationrWZTypeInfor$�objectrr8rFrGr�rJr�r�r�r�r�r�r�r�r��	Exceptionr~r�r�r�r�r�r�rrrr�<module>sd








�3C
:�	��
u_%,





?>