ó
^†êWc           @` sÖ   d  d l  m Z m Z m Z y d  d l m Z Wn? e k
 rq y d  d l m Z Wqr e k
 rm e Z qr Xn Xd  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	   text_typei   (   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   COMMENTt   string_typest   AssertionErrort   typet
   tag_regexpt   matcht   groupst   NoneR   t   listt   attribt   itemst   groupt   ELEMENTt   len(   t   selft   nodet   eltt   keyt   parentst   flagR   t	   namespaceR   t   attrst   namet   value(   t   ElementTreeCommentType(    sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   elementR$   R%   R&   (    (    sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getFirstChildO   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&   (    (    sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getNextSibling`   s     c         S` sŽ   t  | t ƒ r$ | \ } } } } n d  S| d k rQ | s> | S| | | d  f Sn9 | j ƒ  } | sg | S| t | d ƒ j | ƒ | d  f Sd  S(   Nu   textiÿÿÿÿ(   R   R	   R   t   popR   t   index(   R!   R"   R.   R$   R%   R&   t   parent(    (    sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getParentNodet   s    (   t   __name__t
   __module__t   __doc__R,   R/   R1   R5   (    (   R+   (    sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/html5lib/treewalkers/etree.pyR      s
   (		(   t   CommentR   R   t   NonRecursiveTreeWalkert   locals(   t   ElementTreeImplementationt   ElementTreeR   (    (   R+   sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   getETreeBuilder   s    m(   t
   __future__R    R   R   t   collectionsR   t   ImportErrort   ordereddictt   dictt   ret   pip._vendor.sixR   t    R   t   utilsR   t   compileR   R>   t   getETreeModule(    (    (    sw   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/html5lib/treewalkers/etree.pyt   <module>   s   	s