B
    ,d                 @   s~   d Z ddlmZmZ ddlmZ ddlmZ ddl	m
Z
mZmZ dZG dd	 d	eZG d
d deeZdddZdddZdS )zDefused xml.dom.expatbuilder
    )print_functionabsolute_import)ExpatBuilder)
Namespaces   )DTDForbiddenEntitiesForbiddenExternalReferenceForbiddenzxml.dom.expatbuilderc               @   sB   e Zd ZdZdddZdd Zd	d
 Zdd Zdd Zdd Z	dS )DefusedExpatBuilderzDefused document builderNFTc             C   s"   t | | || _|| _|| _d S )N)_ExpatBuilder__init__
forbid_dtdforbid_entitiesforbid_external)selfoptionsr   r   r    r   d/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/defusedxml/expatbuilder.pyr      s    zDefusedExpatBuilder.__init__c             C   s   t |||d S )N)r   )r   namesysidpubidZhas_internal_subsetr   r   r   defused_start_doctype_decl   s    z.DefusedExpatBuilder.defused_start_doctype_declc             C   s   t ||||||d S )N)r   )r   r   Zis_parameter_entityvaluebaser   r   notation_namer   r   r   defused_entity_decl    s    z'DefusedExpatBuilder.defused_entity_declc             C   s   t |d ||||d S )N)r   )r   r   r   r   r   r   r   r   r   defused_unparsed_entity_decl%   s    z0DefusedExpatBuilder.defused_unparsed_entity_declc             C   s   t ||||d S )N)r	   )r   contextr   r   r   r   r   r   #defused_external_entity_ref_handler)   s    z7DefusedExpatBuilder.defused_external_entity_ref_handlerc             C   sB   t | | | jr| j|_| jr0| j|_| j|_	| j
r>| j|_d S )N)r   installr   r   ZStartDoctypeDeclHandlerr   r   ZEntityDeclHandlerr   ZUnparsedEntityDeclHandlerr   r   ZExternalEntityRefHandler)r   parserr   r   r   r   ,   s    zDefusedExpatBuilder.install)NFTT)
__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r
      s   
r
   c               @   s    e Zd ZdZdd Zdd ZdS )DefusedExpatBuilderNSz2Defused document builder that supports namespaces.c             C   s    t | | | jjr| j|_d S )N)r
   r   _optionsZnamespace_declarationsZstart_namespace_decl_handlerZStartNamespaceDeclHandler)r   r    r   r   r   r   <   s    zDefusedExpatBuilderNS.installc             C   s   t |  |   d S )N)r
   resetZ_initNamespaces)r   r   r   r   r'   A   s    
zDefusedExpatBuilderNS.resetN)r!   r"   r#   r$   r   r'   r   r   r   r   r%   9   s   r%   TFc       	      C   sZ   |r
t }nt}||||d}t| trLt| d}z||}W d|  X n
|| }|S )z{Parse a document, returning the resulting Document node.

    'file' may be either a file name or an open file object.
    )r   r   r   rbN)r%   r
   
isinstancestropen	parseFileclose)	file
namespacesr   r   r   build_builderbuilderfpresultr   r   r   parseF   s    


r4   c             C   s&   |r
t }nt}||||d}|| S )zOParse a document from a string, returning the resulting
    Document node.
    )r   r   r   )r%   r
   parseString)stringr/   r   r   r   r0   r1   r   r   r   r5   ^   s    r5   N)TFTT)TFTT)r$   
__future__r   r   Zxml.dom.expatbuilderr   r   r   Z_Namespacescommonr   r   r	   
__origin__r
   r%   r4   r5   r   r   r   r   <module>   s   '
