ó
Ð²Ebc           @` s   d  d l  m Z m Z m Z d  d l m Z d  d l Z d  d l m Z d d l	 m
 Z
 d d l m Z e j d	 ƒ Z d
 „  Z e e ƒ Z d S(   i    (   t   absolute_importt   divisiont   unicode_literals(   t   OrderedDictN(   t   string_typesi   (   t   basei   (   t   moduleFactoryFactoryu   {([^}]*)}(.*)c         ` s>   |  } | j  d ƒ j ‰  d t j f ‡  f d †  ƒ  Y} t ƒ  S(   Nu   asdt
   TreeWalkerc           ` s8   e  Z d  Z ‡  f d †  Z d „  Z d „  Z d „  Z RS(   uË  Given the particular ElementTree representation, this implementation,
        to avoid using recursion, returns "nodes" as tuples with the following
        content:

        1. The current element

        2. The index of the element relative to its parent

        3. A stack of ancestor elements

        4. A flag "text", "tail" or None to indicate if the current node is a
           text node; either the text or tail of the current element (1)
        c         ` sÞ  t  | t ƒ rL | \ } } } } | d k rC t j t | | ƒ f S| } n  t | d ƒ sj | j ƒ  } n  | j d k rƒ t j f S| j d k rº t j	 | j
 | j d ƒ | j d ƒ f S| j ˆ  k rÙ t j | j
 f St  | j t ƒ s t t | j ƒ ƒ ‚ t j | j ƒ } | r-| j ƒ  \ } } n d  } | j } t ƒ  } xm t | j j ƒ  ƒ D]V \ }	 }
 t j |	 ƒ } | r¡|
 | | j d	 ƒ | j d
 ƒ f <q[|
 | d  |	 f <q[Wt j | | | t | ƒ pÖ| j
 f Sd  S(   Nu   textu   tailu   tagu   DOCUMENT_ROOTu   DOCUMENT_FRAGMENTu
   <!DOCTYPE>u   publicIdu   systemIdi   i   (   u   textu   tail(   u   DOCUMENT_ROOTu   DOCUMENT_FRAGMENT(   t
   isinstancet   tupleR   t   TEXTt   getattrt   hasattrt   getroott   tagt   DOCUMENTt   DOCTYPEt   textt   gett   COMMENTR   t   AssertionErrort   typet
   tag_regexpt   matcht   groupst   NoneR   t   listt   attribt   itemst   groupt   ELEMENTt   len(   t   selft   nodet   eltt   _t   flagR   t	   namespaceR   t   attrst   namet   value(   t   ElementTreeCommentType(    sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getNodeDetails    s8    	
'		"%c         S` s    t  | t ƒ r$ | \ } } } } n | d  g  d  f \ } } } } | d k rR d  S| j rk | | | d f St | ƒ r˜ | j | ƒ | d d | d  f Sd  Sd  S(   Nu   textu   taili    (   u   textu   tail(   R   R	   R   R   R   t   append(   R    R!   t   elementt   keyt   parentsR$   (    (    sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getFirstChildH   s    	c         S` sÏ   t  | t ƒ r$ | \ } } } } n d  S| d k rh t | ƒ ra | j | ƒ | d d | d  f Sd  Snc | j r | d k r | | | d f S| t | d ƒ d k  rÇ | d | d | d | d  f Sd  Sd  S(   Nu   texti    u   tailiÿÿÿÿi   (   R   R	   R   R   R+   t   tail(   R    R!   R,   R-   R.   R$   (    (    sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getNextSiblingY   s     c         S` s³   t  | t ƒ r$ | \ } } } } n d  S| d k rQ | s> | S| | | d  f Sn^ | j ƒ  } | sg | St | d ƒ j | ƒ d k sŒ t ‚ | t | d ƒ j | ƒ | d  f Sd  S(   Nu   textiÿÿÿÿi   (   R   R	   R   t   popR   t   countR   t   index(   R    R!   R,   R-   R.   R$   t   parent(    (    sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getParentNodem   s    %(   t   __name__t
   __module__t   __doc__R*   R/   R1   R6   (    (   R)   (    sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyR      s
   (		(   t   CommentR   R   t   NonRecursiveTreeWalkert   locals(   t   ElementTreeImplementationt   ElementTreeR   (    (   R)   sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getETreeBuilder   s    n(   t
   __future__R    R   R   t   collectionsR   t   ret   pip._vendor.sixR   t    R   t   _utilsR   t   compileR   R?   t   getETreeModule(    (    (    sC   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   <module>   s   	u