Your IP : 18.118.164.100


Current Path : /opt/alt/python34/lib64/python3.4/xml/dom/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/xml/dom/__pycache__/expatbuilder.cpython-34.pyc

�
j f���@sdZddlmZmZmZddlmZmZmZddlm	Z	ddl
mZmZddl
mZejZejZejZejjZejjZejjZejjZej�Zi	ejdd�d	6ejdd
�d6ejdd�d
6ejdd�d6ejdd�d6ejdd�d6ejdd�d6ejdd�d6ejdd�d6ZGdd�de�Zdd�Zdd�ZGd d!�d!�ZeeefZ Gd"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(Gd0d1�d1e(e�Z)Gd2d3�d3e(e'�Z*Gd4d5�d5e+�Z,Gd6d7�d7e�Z-d8d9d:�Z.d8d;d<�Z/d8d=d>�Z0d8d?d@�Z1dAdB�Z2dS)Cz�Facility to use the Expat parser to load a minidom instance
from a string or file.

This avoids all the overhead of SAX and pulldom to gain performance.
�)�
xmlbuilder�minidom�Node)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE)�expat)�
_append_child�_set_attribute_node)�
NodeFilterNZcdataZCDATAZenumeration�ENUM�entityZENTITY�entitiesZENTITIES�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�9/opt/alt/python34/lib64/python3.4/xml/dom/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__cCs\xR|jD]G}|d|kr
|d}|ddkrBtdSt|dSq
q
WtjS)N��r�(r���r )r�
_typeinfo_mapr�_no_type)r�aname�info�trrr�getAttributeTypeJs
zElementInfo.getAttributeTypecCstjS)N)rr")r�namespaceURI�	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)z
_attr_infoz_modelztagName)
�__name__�
__module__�__qualname__�	__slots__rrrr&r)r+r,r-r.rrrrr<s
rcCs|j||�S)N)�_intern_setdefault)�builder�srrr�_internosr6cCs�d|kst�|jd�}|j}t|�dkr�|\}}}|||�}d||f}|||�}|||�}nJt|�dkr�|\}}t}|||�}}ntd|��|||�|||fS)N� �z%s:%srz4Unsupported syntax: spaces in URIs not supported: %r)�AssertionError�splitr3�lenr�
ValueError)r4�name�parts�intern�uri�	localname�prefix�qnamerrr�_parse_ns_namers	rDc@sieZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�ZdS);�ExpatBuilderzPDocument builder that uses Expat to build a ParsedXML.DOM document
    instance.NcCsw|dkrtj�}n||_|jjdk	rNt|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)zCreate a new parser object.)r�ParserCreate)rrrr�createParser�szExpatBuilder.createParsercCsh|jsa|j�|_|jjj|_d|j_d|j_d|j_|j|j�n|jS)z7Return the parser object, creating a new one if needed.T)	rKrOr?�
setdefaultr3Zbuffer_textZordered_attributesZspecified_attributes�install)rrrr�	getParser�s	zExpatBuilder.getParsercCs@tjtdd�|_|j|_|jj|_d|_dS)z6Free all data structures used during DOM construction.NF)�theDOMImplementationZcreateDocumentr�document�curNode�
_elem_info�_cdata)rrrrrL�s
zExpatBuilder.resetcCs�|j|_|j|_|j|_|j|_|jj	rK|j
|_n|j|_
|jjrr|j|_n|jjr�|j|_|j|_|j|_n|j|_|j|_|j|_|j|_|j|_ dS)z>Install the callbacks needed to build the DOM into the parser.N)!�start_doctype_decl_handler�StartDoctypeDeclHandler�first_element_handler�StartElementHandler�end_element_handler�EndElementHandler�
pi_handler�ProcessingInstructionHandlerrFr�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�parserrrrrQ�s$zExpatBuilder.installcCs�|j�}d}ylxU|jd�}|s1Pn|j|d�|rc|jjrc|j|�nd}qW|jdd�Wntk
r�YnX|j}|j�d|_|S)	zIParse a document from a file object, returning the document
        node.T�irF�Ni@)	rR�read�ParserT�documentElement�
_setup_subset�ParseEscaperLrK)r�filersZfirst_buffer�buffer�docrrr�	parseFile�s$

	
	zExpatBuilder.parseFilecCsb|j�}y!|j|d�|j|�Wntk
rAYnX|j}|j�d|_|S)z<Parse a document from a string, returning the document node.TN)rRrwryrzrTrLrK)r�stringrsr}rrr�parseString�s
	
	zExpatBuilder.parseStringcCsD|jjr@t�}|j|�|j�}||jj_ndS)z/Load the internal subset if there might be one.N)rT�doctype�InternalSubsetExtractorr��	getSubset�internalSubset)rr|�	extractor�subsetrrrry�s
	
zExpatBuilder._setup_subsetcCs�|jjj|||�}|j|_t|j|�||j_|jr�|jj|�tkr�d|j_|jj	d=d}d|j
_d|j
_n|r�|dk	r�g|j
_g|j_nd|j
_d|j
_|j|j
_ndS)Nr���)rT�implementationZcreateDocumentType�
ownerDocumentr	r�rI�
acceptNode�
FILTER_REJECT�
childNodesrKrarcr�_seq�	notationsrfr_�end_doctype_decl_handler�EndDoctypeDeclHandler)rZdoctypeName�systemId�publicId�has_internal_subsetr�rrrrX�s$!
z'ExpatBuilder.start_doctype_decl_handlercCsO|jjr|j|j_n|j|j_|jp<|jsKt	|_
ndS)N)rFrdrerKrfr^r_rVrIr�_finish_end_element)rrrrr�s
z%ExpatBuilder.end_doctype_decl_handlercCs]|jj||�}t|j|�|jrY|jj|�tkrY|jj|�ndS)N)rTZcreateProcessingInstructionr	rUrIr�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�)rUr�rW�_cdata_continue�nodeType�CDATA_SECTION_NODEZ
appendDatarTZcreateCDATASection�	TEXT_NODEr�r�Textr�r	)rr�r�r��valuerrrrks"		

		z)ExpatBuilder.character_data_handler_cdatacCs|jj}|rC|djtkrC|d}|j||_dStj�}|j||_|j|_t	|j|�dS)Nrr�r�)
rUr�r�r�r�rr�rTr�r	)rr�r�r�rrrrm&s
z#ExpatBuilder.character_data_handlerc
Cs�|r
dS|jjsdS|jj||||�}|dk	rf|jj|�}	|jj|	�n|jjjjj|�|j	r�|j	j
|�tkr�|jjjjd=ndS)Nrr�)rFrrTZ_create_entityZcreateTextNoder��appendr�r�rIr�r�)
rZ
entityNameZis_parameter_entityr��baser�r��notationNamer��childrrrr`1s!z ExpatBuilder.entity_decl_handlercCsl|jj|||�}|jjjjj|�|jrh|jj|�tkrh|jjjjd=ndS)Nrr�)	rTZ_create_notationr�r�r�r�rIr��
FILTER_ACCEPT)rr�r�r�r�r�rrrrbCs!z"ExpatBuilder.notation_decl_handlercCsZ|jj|�}t|j|�|jrV|jj|�tkrV|jj|�ndS)N)rTZ
createCommentr	rUrIr�r�r�)rr�r�rrrreIs!zExpatBuilder.comment_handlercCsd|_d|_dS)NTF)rWr�)rrrrrgOs	z(ExpatBuilder.start_cdata_section_handlercCsd|_d|_dS)NF)rWr�)rrrrriSs	z&ExpatBuilder.end_cdata_section_handlercCsdS)Nrr)r�contextr�r�r�rrrrnWsz(ExpatBuilder.external_entity_ref_handlercCsK|jdkr%|jr%t|_n|j|j�_|j||�dS)N)rIrVrr��start_element_handlerrRr[)rr=�
attributesrrrrZZsz"ExpatBuilder.first_element_handlercCs�|jj|�}t|j|�||_|r�xotdt|�d�D]R}tj||tdt	�}||d}||_
|j|_t||�qJWn||jj
k	r�|j|�ndS)Nrrr)rTZ
createElementr	rU�ranger;r�Attrrrr�r�r
rxrJ)rr=r�r��i�ar�rrrr�`s		z"ExpatBuilder.start_element_handlercCs�|jr�||jjkrdS|jj|�}|tkrJt|�n|tkrct|�ndS|j|_	|jj
|�|j�ndS)N)rIrTrx�startContainerr��Rejecter�FILTER_SKIP�Skipper�
parentNoderUr��unlink)rr�ZfiltrrrrJqs	

z"ExpatBuilder._finish_start_elementcCs&|j}|j|_|j|�dS)N)rUr�r�)rr=rUrrrr\�s	z ExpatBuilder.end_element_handlercCs�|jj|j�}|r.|j||�n|jr�||jjkrMdS|jj|�tkr�|j	j
|�|j�q�ndS)N)rV�getr�_handle_white_text_nodesrIrTrxr�r�rUr�r�)rrUr$rrrr��s	z ExpatBuilder._finish_end_elementcCs�|jjs|j�rdSg}x@|jD]5}|jtkr-|jj�r-|j|�q-q-Wx|D]}|j	|�qmWdS)N)
rFZwhitespace_in_element_contentr+r�r�r�r��stripr�r�)rr�r$�Lr�rrrr��s

z%ExpatBuilder._handle_white_text_nodescCsY|jj|�}|dkr7t||�|j|<n|jdksLt�||_dS)N)rVr�rrr9)rr=rr$rrrrq�s
z!ExpatBuilder.element_decl_handlerc	Csf|jj|�}|dkr:t|�}||j|<n|jjd|dd|d||g�dS)Nr)rVr�rrr�)r�elemr=r*�defaultZrequiredr$rrrrr�s	z!ExpatBuilder.attlist_decl_handlercCsL||j_||j_|dkrH|r9d|j_qHd|j_ndS)NrTF)rT�version�encoding�
standalone)rr�r�r�rrrrp�szExpatBuilder.xml_decl_handler) r/r0r1�__doc__rrOrRrLrQr~r�ryrXr�r^rkrmr`rbrergrirnrZr�rJr\r�r�rqrrrprrrrrE�s:
rEc@s�eZdZdZd
Zdd�Zdd�Zdd�Ziej	e
j6eje
j
6eje
j6eje
j6eje
j6eje
j6eje
j6eje
j6eje
j6eje
j6eje
j6ej e
j!6Z"d	S)rHzoWrapper around a DOMBuilderFilter which implements the checks
    to make the whatToShow filter attribute work.rGcCs
||_dS)N)rG)rrGrrrr�sz#FilterVisibilityController.__init__cCsx|j|j}|jj|@rp|jj|�}|tkrGt�n|tkrltdt	|���n|St
SdS)Nz)startContainer() returned illegal value: )�_nodetype_maskr�rG�
whatToShowr��FILTER_INTERRUPTrz�_ALLOWED_FILTER_RETURNSr<�reprr�)rr��mask�valrrrr��s	z)FilterVisibilityController.startContainercCs�|j|j}|jj|@r�|jj|�}|tkrGt�n|tkr�|j}x(|j	dd�D]}|j
|�qpWtS|tkr�t
dt|���n|StSdS)Nz%acceptNode() returned illegal value: )r�r�rGr�r�r�rzr�r�r�ZappendChildr�r�r<r�r�)rr�r�r��parentr�rrrr��s		z%FilterVisibilityController.acceptNodeN)zfilter)#r/r0r1r�r2rr�r�rZSHOW_ELEMENTrZELEMENT_NODEZSHOW_ATTRIBUTEZATTRIBUTE_NODEZ	SHOW_TEXTr�ZSHOW_CDATA_SECTIONr�ZSHOW_ENTITY_REFERENCEZENTITY_REFERENCE_NODEZSHOW_ENTITYZENTITY_NODEZSHOW_PROCESSING_INSTRUCTIONZPROCESSING_INSTRUCTION_NODEZSHOW_COMMENTZCOMMENT_NODEZ
SHOW_DOCUMENT�
DOCUMENT_NODEZSHOW_DOCUMENT_TYPEZDOCUMENT_TYPE_NODEZSHOW_DOCUMENT_FRAGMENTZDOCUMENT_FRAGMENT_NODEZ
SHOW_NOTATIONZ
NOTATION_NODEr�rrrrrH�s$











rHc@s"eZdZdZdd�ZdS)	�FilterCrutch�_builder�_level�
_old_start�_old_endcCsOd|_||_|j}|j|_|j|_|j|_|j|_dS)Nr)	r�r�rKr[r�r]r�r�r\)rr4rsrrrrs			zFilterCrutch.__init__N)z_builderz_levelz
_old_startz_old_end)r/r0r1r2rrrrrr�sr�c@s:eZdZfZdd�Zdd�Zdd�ZdS)r�cCs>tj||�|j}xdD]}t||d�q WdS)Nr_rfrlrhrjro)zProcessingInstructionHandlerzCommentHandlerzCharacterDataHandlerzStartCdataSectionHandlerzEndCdataSectionHandlerzExternalEntityRefHandler)r�rrK�setattr)rr4rsr=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�rKrQr�r[r�r])rr�rsrrrr\ szRejecter.end_element_handlerN)r/r0r1r2rr�r\rrrrr�sr�c@s.eZdZfZdd�Zdd�ZdS)r�cGsB|jj}|j|�|jj|k	r>|jd|_ndS)Nr)r�rUr�r�)rr�r�rrrr�-s
zSkipper.start_element_handlercGs`|jdkr?|j|jj_|j|jj_d|_n|jd|_|j|�dS)Nrr)r�r�r�rKr[r�r])rr�rrrr\3szSkipper.end_element_handlerN)r/r0r1r2r�r\rrrrr�*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@smeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�FragmentBuilderz�Builder which constructs document fragments given XML source
    text and a context node.

    The context node is expected to provide information about the
    namespace declarations which are in scope at the start of the
    fragment.
    NcCsM|jtkr$||_||_n|j|_||_tj||�dS)N)r�r��originalDocumentr�r�rEr)rr�rMrrrr[s		zFragmentBuilder.__init__cCstj|�d|_dS)N)rErL�fragment)rrrrrLds
zFragmentBuilder.resetcCs|j|j��S)zRParse a document fragment from a file object, returning the
        fragment node.)r�rv)rr{rrrr~hszFragmentBuilder.parseFilec		Cs�||_|j�}|jj}d}|r�|jp?|j�}|jrdd|j|jf}q�|jr�d|j}q�nd}|j�}t	|||f}y|j
|d�Wn|j��YnX|j}|j�|S)zMParse a document fragment from a string, returning the
        fragment node.ruzPUBLIC "%s" "%s"zSYSTEM "%s"r)
�_sourcerRr�r�r��_getDeclarationsr�r��_getNSattrs�_FRAGMENT_BUILDER_TEMPLATErwrLr�)	rrrsr�Zidentr�ZnsattrsrTr�rrrr�ms,			
	
zFragmentBuilder.parseStringcCs�|jjj}d}|r�x�t|jj�D]v}|jj|�}|rY|d}nd||jf}|jr�d||j|j	f}q.d||j	f}q.Wx�t|j
j�D]�}|j
j|�}|r�|d}nd||jf}|jrd||j|j	f}n5|j	r=d||j	f}nd	||jjf}|j
rrd
||j
f}n|d}q�Wn|S)z�Re-create the internal subset from the DocumentType node.

        This is only needed if we don't already have the
        internalSubset as a string.
        ruz
  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�item�nodeNamer�r�rZ
firstChildr�r�)rr�r5r�Znotationr
rrrr��s6
	
			z FragmentBuilder._getDeclarationscCsdS)Nrur)rrrrr��szFragmentBuilder._getNSattrscCs�|tkr�|j}|j}|jj|�}|j|_|jj�|_|j|_z|j|j	d�Wd||_||_d|_	XdSt
j|||||�SdS)Nrr�)�$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDrTrUrKZExternalEntityParserCreater�ZcreateDocumentFragmentr�rwr�rErn)rr�r�r�r�Zold_documentZold_cur_nodersrrrrn�s				
z+FragmentBuilder.external_entity_ref_handler)r/r0r1r�rrLr~r�r�r�rnrrrrr�Rs	$r�c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
Namespacesz7Mix-in class for builders; adds support for namespaces.cCs
g|_dS)N)�_ns_ordered_prefixes)rrrr�_initNamespaces�szNamespaces._initNamespacescCstjdd�}d|_|S)z'Create a new namespace-handling parser.Znamespace_separatorr7T)rrNZnamespace_prefixes)rrsrrrrO�s	zNamespaces.createParsercCs/tj||�|jjr+|j|_ndS)z.Insert the namespace-handlers onto the parser.N)rErQrFZnamespace_declarations�start_namespace_decl_handlerZStartNamespaceDeclHandler)rrsrrrrQ�szNamespaces.installcCs|jj||f�dS)z/Push this namespace declaration on our storage.N)r�r�)rrBr@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�=n|r)|j�|j}	|j}
x�tdt|�d�D]�}||}||d}
d|kr�t||�\}}}}tj
||||�}||	|<||
||f<n2tj
|t|t�}||	|<||
t|f<|j|_|
|_
||_qXWndS)Nr7zxmlns:�xmlnsrrr)rDrrrZElementrTr�r	rUr�r�r6rr�r
Z_ensure_attributes�_attrs�_attrsNSr�r;ZownerElement)rr=r�r@rArBrCr�r�r�r�r�r#r�rrrr��sP			
		


	z Namespaces.start_element_handlercCs�|j}d|krlt||�\}}}}|j|kr]|j|kr]|j|ks�td��n6|j|ks�td��|jtks�td��|j|_|j	|�dS)Nr7z$element stack messed up! (namespace)z&element stack messed up - bad nodeNamez*element stack messed up - bad namespaceURI)
rUrDr'r(rBr9r�rr�r�)rr=rUr@rArBrCrrrr\s			zNamespaces.end_element_handlerN)
r/r0r1r�r�rOrQr�r�r\rrrrr��s5r�c@s"eZdZdZdd�ZdS)�ExpatBuilderNSz*Document builder that supports namespaces.cCstj|�|j�dS)N)rErLr�)rrrrrL)s
zExpatBuilderNS.resetN)r/r0r1r�rLrrrrr�&sr�c@s.eZdZdZdd�Zdd�ZdS)�FragmentBuilderNSz*Fragment builder that supports namespaces.cCstj|�|j�dS)N)r�rLr�)rrrrrL1s
zFragmentBuilderNS.resetcCs�d}|j}g}x�|r�t|d�r�x�|jj�D]p\}}||kr[q=n|j|�|r{d|}nd}|r�d|||f}q=d||f}q=Wn|j}qW|S)zNReturn string of namespace attributes from this element and
        ancestors.ru�_ns_prefix_urizxmlns:r�z%s
    %s='%s'z %s='%s')r��hasattrr��itemsr�r�)r�attrsr�r�rBr@Zdeclnamerrrr�5s"		


zFragmentBuilderNS._getNSattrsN)r/r0r1r�rLr�rrrrr�.sr�c@seZdZdZdS)rzzEException raised to short-circuit parsing in InternalSubsetExtractor.N)r/r0r1r�rrrrrzSsrzc@speZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)r�zBXML processor which can rip out the internal document type subset.NcCs|jS)z'Return the internal subset as a string.)r�)rrrrr�\sz!InternalSubsetExtractor.getSubsetcCs-ytj||�Wntk
r(YnXdS)N)rEr~rz)rr{rrrr~`s
z!InternalSubsetExtractor.parseFilecCs-ytj||�Wntk
r(YnXdS)N)rEr�rz)rrrrrr�fs
z#InternalSubsetExtractor.parseStringcCs|j|_|j|_dS)N)rXrYr�r[)rrsrrrrQlszInternalSubsetExtractor.installcCsF|r9|j�}g|_|jj|_|j|_n	t��dS)N)rRr�r�ZDefaultHandlerr�r�rz)rr=r�r�r�rsrrrrXps	z2InternalSubsetExtractor.start_doctype_decl_handlercCs@dj|j�jdd�jdd�}||_t��dS)Nruz
�
�
)�joinr��replacerz)rr5rrrr�zs*	z0InternalSubsetExtractor.end_doctype_decl_handlercCs
t��dS)N)rz)rr=r�rrrr�sz-InternalSubsetExtractor.start_element_handler)r/r0r1r�r�r�r~r�rQrXr�r�rrrrr�Ws
r�Tc	Csg|rt�}n	t�}t|t�rTt|d��}|j|�}WdQXn|j|�}|S)z{Parse a document, returning the resulting Document node.

    'file' may be either a file name or an open file object.
    �rbN)r�rE�
isinstance�str�openr~)r{�
namespacesr4�fp�resultrrr�parse�s	r�cCs(|rt�}n	t�}|j|�S)zOParse a document from a string, returning the resulting
    Document node.
    )r�rEr�)rr�r4rrrr��s	r�c	Csm|rt|�}nt|�}t|t�rZt|d��}|j|�}WdQXn|j|�}|S)z�Parse a fragment of a document, given the context from which it
    was originally extracted.  context should be the parent of the
    node(s) which are in the fragment.

    'file' may be either a file name or an open file object.
    r�N)r�r�r�r�r�r~)r{r�r�r4r�r�rrr�
parseFragment�sr�cCs.|rt|�}nt|�}|j|�S)z�Parse a fragment of a document from a string, given the context
    from which it was originally extracted.  context should be the
    parent of the node(s) which are in the fragment.
    )r�r�r�)rr�r�r4rrr�parseFragmentString�sr�cCs!|jrt|�St|�SdS)z,Create a builder based on an Options object.N)r�r�rE)rMrrr�makeBuilder�s	
r�)3r�Zxml.domrrrrrrZxml.parsersrZxml.dom.minidomr	r
Zxml.dom.NodeFilterrr�r�r�ZDOMBuilderFilterr�r�r�r�ZgetDOMImplementationrSZTypeInfor!�objectrr6rDrEr�rHr�r�r�r�r�r�r�r�r��	Exceptionrzr�r�r�r�r�r�rrrr�<module>s^			3�B:u_%,

?>