ó
(TQc           @@ 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 d e f d	     YZ d
 e e f d     YZ e e e e d  Z e e e e d  Z d S(   s   Defused xml.dom.expatbuilder
i    (   t   print_functiont   absolute_import(   t   ExpatBuilder(   t
   Namespacesi   (   t   DTDForbiddent   EntitiesForbiddent   ExternalReferenceForbiddens   xml.dom.expatbuildert   DefusedExpatBuilderc           B@ sP   e  Z d  Z d e e e d  Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   s   Defused document builderc         C@ s/   t  j |  |  | |  _ | |  _ | |  _ d  S(   N(   t   _ExpatBuildert   __init__t
   forbid_dtdt   forbid_entitiest   forbid_external(   t   selft   optionsR
   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR	      s    		c         C@ s   t  | | |   d  S(   N(   R   (   R   t   namet   sysidt   pubidt   has_internal_subset(    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyt   defused_start_doctype_decl   s    c         C@ s   t  | | | | | |   d  S(   N(   R   (   R   R   t   is_parameter_entityt   valuet   baseR   R   t   notation_name(    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyt   defused_entity_decl!   s    c         C@ s   t  | d  | | | |   d  S(   N(   R   t   None(   R   R   R   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyt   defused_unparsed_entity_decl%   s    c         C@ s   t  | | | |   d  S(   N(   R   (   R   t   contextR   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyt#   defused_external_entity_ref_handler*   s    c         C@ sh   t  j |  |  |  j r( |  j | _ n  |  j rL |  j | _ |  j | _	 n  |  j
 rd |  j | _ n  d  S(   N(   R   t   installR
   R   t   StartDoctypeDeclHandlerR   R   t   EntityDeclHandlerR   t   UnparsedEntityDeclHandlerR   R   t   ExternalEntityRefHandler(   R   t   parser(    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR   .   s    			N(   t   __name__t
   __module__t   __doc__R   t   Falset   TrueR	   R   R   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR      s   					t   DefusedExpatBuilderNSc           B@ s    e  Z d  Z d   Z d   Z RS(   s2   Defused document builder that supports namespaces.c         C@ s/   t  j |  |  |  j j r+ |  j | _ n  d  S(   N(   R   R   t   _optionst   namespace_declarationst   start_namespace_decl_handlert   StartNamespaceDeclHandler(   R   R"   (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR   >   s    c         C@ s   t  j |   |  j   d  S(   N(   R   t   resett   _initNamespaces(   R   (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR-   D   s    (   R#   R$   R%   R   R-   (    (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR(   ;   s   	c   	      C@ s   | r t  } n t } | d | d | d |  } t |  t  rr t |  d  } z | j |  } Wd | j   Xn | j |   } | S(   s{   Parse a document, returning the resulting Document node.

    'file' may be either a file name or an open file object.
    R
   R   R   t   rbN(   R(   R   t
   isinstancet   strt   opent	   parseFilet   close(	   t   filet
   namespacesR
   R   R   t   build_buildert   buildert   fpt   result(    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyt   parseI   s    		c         C@ s=   | r t  } n t } | d | d | d |  } | j |   S(   sO   Parse a document from a string, returning the resulting
    Document node.
    R
   R   R   (   R(   R   t   parseString(   t   stringR6   R
   R   R   R7   R8   (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyR<   b   s    		N(   R%   t
   __future__R    R   t   xml.dom.expatbuilderR   R   R   t   _Namespacest   commonR   R   R   t
   __origin__R   R(   R'   R&   R;   R<   (    (    (    s;   /usr/lib/python2.7/dist-packages/defusedxml/expatbuilder.pyt   <module>   s   (	