
bc           @   s  d  d l  Z d  d l Z d  d l Z y e j e j g Z Wn e k
 rY e j g Z n Xd Z d Z	 d Z
 d Z d Z d Z d Z d	 Z d
 e j j f d     YZ d d d     YZ d d d     YZ d e f d     YZ d Z d d d  Z d d  Z d S(   iNt   START_ELEMENTt   END_ELEMENTt   COMMENTt   START_DOCUMENTt   END_DOCUMENTt   PROCESSING_INSTRUCTIONt   IGNORABLE_WHITESPACEt
   CHARACTERSt   PullDOMc           B   s   e  Z d Z d Z d d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   d d l  m } | |  _ d  d  g |  _ |  j |  _ g  |  _ |  j j |  _ y |  j j	 |  _	 Wn t
 k
 rr n Xi d | 6g |  _ |  j d |  _ g  |  _ d  S(   Ni(   t   XML_NAMESPACEt   xml(   t   xml.domR	   t   documentFactoryt   Nonet
   firstEventt	   lastEventt   elementStackt   appendt   pusht   popt   AttributeErrort   _ns_contextst   _current_contextt   pending_events(   t   selfR   R	   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   __init__   s    		c         C   s   |  j  d } |  j  d =| S(   Ni(   R   (   R   t   result(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR   '   s    
c         C   s   | |  _  d  S(   N(   t   _locator(   R   t   locator(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   setDocumentLocator,   s    c         C   sg   t  |  d  s g  |  _ n  |  j j | p- d | f  |  j j |  j j    | pY d  |  j | <d  S(   Nt   _xmlns_attrst   xmlns(   t   hasattrR   R   R   R   t   copyR   (   R   t   prefixt   uri(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   startPrefixMapping/   s
    c         C   s   |  j  j   |  _ d  S(   N(   R   R   R   (   R   R"   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   endPrefixMapping6   s    c         C   s;  d } t  |  d d   } | d  k	 rZ x' | D] \ } } | | j | | f <q+ Wg  |  _ n  | \ } }	 | r | d  k r |  j | }
 |
 r |
 d |	 } q |	 } n  |  j r |  j j | |  } q|  j | |  } n0 |  j r |  j j |	  } n |  j d  |	  } x | j	   D] \ } } | \ } } | | k r| d k rQ| } n
 d | } |  j j
 | |  } | j |  nt | r|  j | }
 |
 r|
 d | } n | } |  j j
 | |  } | j |  n |  j j |  } | j |  | | _ qWt | f d  g |  j d <|  j d |  _ |  j |  d  S(   Ns   http://www.w3.org/2000/xmlns/R   t   :R   s   xmlns:i   (   t   getattrR   t   _attrsR   R   t   documentt   createElementNSt   buildDocumentt   createElementt   itemst   createAttributeNSt   setAttributeNodeNSt   createAttributet   setAttributeNodet   valueR    R   R   (   R   t   namet   tagNamet   attrst	   xmlns_urit   xmlns_attrst   anameR2   R#   t	   localnameR"   t   nodet   a_urit   a_localnamet   qnamet   attr(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   startElementNS9   sP    				
c         C   s3   t  |  j   f d  g |  j d <|  j d |  _ d  S(   Ni   (   R   R   R   R   (   R   R3   R4   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   endElementNSr   s    c         C   s   |  j  r |  j  j |  } n |  j d  |  } xB | j   D]4 \ } } |  j  j |  } | | _ | j |  q= Wt | f d  g |  j	 d <|  j	 d |  _	 |  j
 |  d  S(   Ni   (   R)   R,   R+   R   R-   R0   R2   R1   R    R   R   (   R   R3   R5   R:   R8   R2   R>   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   startElementv   s    		c         C   s3   t  |  j   f d  g |  j d <|  j d |  _ d  S(   Ni   (   R   R   R   R   (   R   R3   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt
   endElement   s    c         C   sm   |  j  rG |  j  j |  } t | f d  g |  j d <|  j d |  _ n" t | f d  g } |  j j |  d  S(   Ni   (   R)   t   createCommentR   R   R   R   R   (   R   t   sR:   t   event(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   comment   s    	c         C   ss   |  j  rJ |  j  j | |  } t | f d  g |  j d <|  j d |  _ n% t | | f d  g } |  j j |  d  S(   Ni   (   R)   t   createProcessingInstructionR   R   R   R   R   (   R   t   targett   dataR:   RE   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   processingInstruction   s    	c         C   s?   |  j  j |  } t | f d  g |  j d <|  j d |  _ d  S(   Ni   (   R)   t   createTextNodeR   R   R   (   R   t   charsR:   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   ignorableWhitespace   s    c         C   s?   |  j  j |  } t | f d  g |  j d <|  j d |  _ d  S(   Ni   (   R)   RK   R   R   R   (   R   RL   R:   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt
   characters   s    c         C   s7   |  j  d  k r3 d d  l } | j j j j |  _  n  d  S(   Ni(   R   R   t   xml.dom.minidomt   domt   minidomt   Documentt   implementation(   R   R
   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   startDocument   s    c   	      C   s8  |  j  j | | d   } | |  _ t | f d  g |  j d <|  j d |  _ |  j |  x |  j D] } | d d t k r | d \ } } } |  j j	 | |  } t | f | d <nX | d d t
 k r |  j j | d d  } t
 | f | d <n t d | d d   | |  j d <| |  _ qa Wd  |  _ | j S(   Ni   i    s   Unknown pending event (   R   t   createDocumentR   R)   R   R   R   R   R   RG   R   RC   t   AssertionErrort
   firstChild(	   R   R#   t   tagnameR:   t   et   _RH   RI   t   n(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR+      s$    		c         C   s*   t  |  j f d  g |  j d <|  j   d  S(   Ni   (   R   R)   R   R   R   (   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   endDocument   s    c         C   s   d |  _ d S(   s.   clear(): Explicitly release parsing structuresN(   R   R)   (   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   clear   s    N(   t   __name__t
   __module__R   R   R)   R   R   R   R$   R%   R?   R@   RA   RB   RF   RJ   RM   RN   RT   R+   R\   R]   (    (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR      s&   					9												t   ErrorHandlerc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s	   | GHd  S(   N(    (   R   t	   exception(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   warning   s    c         C   s
   |  d  S(   N(    (   R   Ra   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   error   s    c         C   s
   |  d  S(   N(    (   R   Ra   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt
   fatalError   s    (   R^   R_   Rb   Rc   Rd   (    (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR`      s   		t   DOMEventStreamc           B   sb   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   c         C   sJ   | |  _  | |  _ | |  _ t |  j d  s< |  j |  _ n  |  j   d  S(   Nt   feed(   t   streamt   parsert   bufsizeR    t   _slurpt   getEventt   reset(   R   Rg   Rh   Ri   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR      s    			c         C   s?   t    |  _ |  j j t j j j d  |  j j |  j  d  S(   Ni   (	   R   t   pulldomRh   t
   setFeatureR
   t   saxt   handlert   feature_namespacest   setContentHandler(   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRl      s    c         C   s    |  j    } | r | St  d  S(   N(   Rk   t
   IndexError(   R   t   post   rc(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   __getitem__   s    c         C   s    |  j    } | r | St  d  S(   N(   Rk   t   StopIteration(   R   Ru   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   next   s    c         C   s   |  S(   N(    (   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   __iter__   s    c         C   s   |  j    } | g } x | r | \ } } | | k r: d  S| t k rZ | d j |  n  | t k rv | j |  n | t k r | d =n  |  j    } q Wd  S(   Ni(   Rk   R   t   appendChildR    R   (   R   R:   RE   t   parentst   tokent   cur_node(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt
   expandNode   s    		
c         C   s   |  j  j d s% |  j  j |  j  _ n  xP |  j  j d sw |  j j |  j  } | sd |  j j   d  S|  j j	 |  q( W|  j  j d d } |  j  j d d |  j  j d <| S(   Ni   i    (
   Rm   R   R   Rg   t   readRi   Rh   t   closeR   Rf   (   R   t   bufRu   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRk      s    c         C   s)   |  j  j |  j  |  j |  _ |  j   S(   s    Fallback replacement for getEvent() using the
            standard SAX2 interface, which means we slurp the
            SAX events into memory (no performance gain, but
            we are compatible to all SAX parsers).
        (   Rh   t   parseRg   t   _emitRk   (   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRj     s    c         C   s6   |  j  j d d } |  j  j d d |  j  j d <| S(   sn    Fallback replacement for getEvent() that emits
            the events that _slurp() read previously.
        i   i    (   Rm   R   (   R   Ru   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR     s    c         C   s)   |  j  j   |  `  d |  _ d |  _ d S(   s+   clear(): Explicitly release parsing objectsN(   Rm   R]   R   Rh   Rg   (   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR]      s    	(   R^   R_   R   Rl   Rv   Rx   Ry   R~   Rk   Rj   R   R]   (    (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRe      s   								
	t   SAX2DOMc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   sA   t  j |  | | |  |  j d } |  j d } | j |  d  S(   Nii(   R   R?   R   Rz   (   R   R3   R4   R5   t   curNodet
   parentNode(    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR?   )  s    c         C   s>   t  j |  | |  |  j d } |  j d } | j |  d  S(   Nii(   R   RA   R   Rz   (   R   R3   R5   R   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRA   /  s    c         C   sB   t  j |  | |  |  j d d } |  j d } | j |  d  S(   Ni    i   i(   R   RJ   R   R   Rz   (   R   RH   RI   R:   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRJ   5  s    c         C   s?   t  j |  |  |  j d d } |  j d } | j |  d  S(   Ni    i   i(   R   RM   R   R   Rz   (   R   RL   R:   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRM   ;  s    c         C   s?   t  j |  |  |  j d d } |  j d } | j |  d  S(   Ni    i   i(   R   RN   R   R   Rz   (   R   RL   R:   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyRN   A  s    (   R^   R_   R?   RA   RJ   RM   RN   (    (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR   '  s
   				i   i   i   c         C   sd   | d  k r t } n  t |   t k r6 t |   } n |  } | sT t j j   } n  t | | |  S(   N(	   R   t   default_bufsizet   typet   _StringTypest   openR
   Ro   t   make_parserRe   (   t   stream_or_stringRh   Ri   Rg   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyR   J  s    	c         C   sx   y d d l  m } Wn! t k
 r7 d d l m } n Xt |   } | |   } | sh t j j   } n  t | | |  S(   Ni(   t   StringIO(   t	   cStringIOR   t   ImportErrort   lenR
   Ro   R   Re   (   t   stringRh   R   Ri   R   (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   parseStringU  s    (    (    i @  i?  (   t   xml.saxR
   t   xml.sax.handlert   typest
   StringTypet   UnicodeTypeR   R   R    R   R   R   R   R   R   R   Ro   t   ContentHandlerR   R`   Re   R   R   R   R   R   (    (    (    s%   /usr/lib/python2.7/xml/dom/pulldom.pyt   <module>   s*   U!