ó
(TQc           @   sß   d  Z  d d l Z d d l m Z e j d d k Z e j d  d k Z e j d  d k Z d	 e f d
 „  ƒ  YZ	 d e	 f d „  ƒ  YZ
 d e	 f d „  ƒ  YZ d e	 f d „  ƒ  YZ d e	 f d „  ƒ  YZ d „  Z d „  Z d S(   s1   Common constants, exceptions and helpe functions
iÿÿÿÿN(   t
   MethodTypei    i   i   i   i   t   DefusedXmlExceptionc           B   s   e  Z d  Z d „  Z RS(   s   Base exception
    c         C   s
   t  |  ƒ S(   N(   t   str(   t   self(    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   __repr__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR      s   t   DTDForbiddenc           B   s    e  Z d  Z d „  Z d „  Z RS(   s*   Document type definition is forbidden
    c         C   s2   t  t |  ƒ j ƒ  | |  _ | |  _ | |  _ d  S(   N(   t   superR   t   __init__t   namet   sysidt   pubid(   R   R   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR
      s    		c         C   s"   d } | j  |  j |  j |  j ƒ S(   Ns7   DTDForbidden(name='{}', system_id={!r}, public_id={!r})(   t   formatR   R   R   (   R   t   tpl(    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   __str__    s    (   R   R   R   R
   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR      s   	t   EntitiesForbiddenc           B   s    e  Z d  Z d „  Z d „  Z RS(   s#   Entity definition is forbidden
    c         C   sM   t  t |  ƒ j ƒ  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(	   R	   R   R
   R   t   valuet   baseR   R   t   notation_name(   R   R   R   R   R   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR
   (   s    					c         C   s"   d } | j  |  j |  j |  j ƒ S(   Ns<   EntitiesForbidden(name='{}', system_id={!r}, public_id={!r})(   R   R   R   R   (   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR   1   s    (   R   R   R   R
   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR   %   s   		t   ExternalReferenceForbiddenc           B   s    e  Z d  Z d „  Z d „  Z RS(   s1   Resolving an external reference is forbidden
    c         C   s;   t  t |  ƒ j ƒ  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R	   R   R
   t   contextR   R   R   (   R   R   R   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR
   9   s
    			c         C   s   d } | j  |  j |  j ƒ S(   Ns8   ExternalReferenceForbidden(system_id='{}', public_id={})(   R   R   R   (   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR   @   s    (   R   R   R   R
   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR   6   s   	t   NotSupportedErrorc           B   s   e  Z d  Z RS(   s#   The operation is not supported
    (   R   R   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyR   E   s   c         C   s²   |  t  j |  j k s t ‚ |  j } t | i  i  d g ƒ t  j | } t t | ƒ ƒ } xQ t |  ƒ j	 ƒ  D]= \ } } | j
 d ƒ sm | | k rš qm n  t | | | ƒ qm W| S(   Nt   *t   _(   t   syst   modulesR   t   AssertionErrort
   __origin__t
   __import__t   sett   dirt   varst   itemst
   startswitht   setattr(   t   defused_modt   stdlib_namet
   stdlib_modt   stdlib_namesR   t   obj(    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   _apply_defusingJ   s    	c            sÖ   d t t t ‡  ‡ ‡ f d † } t s- t r] ‡  f d †  ‰ d t t t ‡ ‡ f d † } nQ t rŠ d d t t t ‡  ‡ ‡ f d † } n$ d d t t t ‡  ‡ ‡ f d † } t t t ‡  ‡ f d † } | | | f S(   sd   Factory for functions needed by etree, dependent on whether
    cElementTree or ElementTree is used.c      	      s@   | d  k r3 ˆ  d ˆ ƒ  d | d | d | ƒ } n  ˆ |  | ƒ S(   Nt   targett
   forbid_dtdt   forbid_entitiest   forbid_external(   t   None(   t   sourcet   parserR,   R-   R.   (   t   DefusedXMLParsert   _TreeBuildert   _parse(    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   parse\   s    c            s\   t  ˆ  | ƒ } t r6 | j } t | |  |  j ƒ } n t | |  ƒ } t |  j | | ƒ d  S(   N(   t   getattrt   PY26t   __func__R    t	   __class__R$   t   _parser(   t	   xmlparsert   funcnamet   hooknamet   funct   method(   R2   (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   bindf   s    	c            sw   ˆ  |  | ƒ } | j  } | r1 ˆ | d d ƒ n  | rZ ˆ | d d ƒ ˆ | d d ƒ n  | rs ˆ | d d ƒ n  | S(	   Nt   defused_start_doctype_declt   StartDoctypeDeclHandlert   defused_entity_declt   EntityDeclHandlert   defused_unparsed_entity_declt   UnparsedEntityDeclHandlert#   defused_external_entity_ref_handlert   ExternalEntityRefHandler(   R:   (   R0   t   eventsR,   R-   R.   t   itR;   (   t
   _iterparseR@   (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt	   iterparseq   s    		
		
	
c      	      sm   t  } t |  d ƒ s- t |  d ƒ }  t } n  | sZ ˆ  d ˆ ƒ  d | d | d | ƒ } n  ˆ |  | | | ƒ S(   Nt   readt   rbR+   R,   R-   R.   (   t   Falset   hasattrt   opent   True(   R0   RI   R1   R,   R-   R.   t   close_source(   R2   t   _IterParseIteratorR3   (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyRL   ‚   s    	c      	      sC   | d  k r3 ˆ  d ˆ ƒ  d | d | d | ƒ } n  ˆ |  | | ƒ S(   NR+   R,   R-   R.   (   R/   (   R0   RI   R1   R,   R-   R.   (   R2   R3   RK   (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyRL      s    c      	      s;   ˆ  d ˆ ƒ  d | d | d | ƒ } | j  |  ƒ | j ƒ  S(   NR+   R,   R-   R.   (   t   feedt   close(   t   textR,   R-   R.   R1   (   R2   R3   (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt
   fromstring™   s    	N(   R/   RO   RR   R7   t   PY31t   PY3(   R2   R3   RT   R4   RK   R5   RL   RX   (    (   R2   RT   R3   RK   R4   R@   s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   _generate_etree_functionsW   s    				(   i   i   (   i   i   (   R   R   t   typesR    t   version_infoRZ   R7   RY   t
   ValueErrorR   R   R   R   R   R*   R[   (    (    (    s5   /usr/lib/python2.7/dist-packages/defusedxml/common.pyt   <module>   s   	