ó
Ð²Ebc           @` sú   d  d l  m Z m Z m Z d  d l m Z d  d l m Z d  d l m	 Z	 d d l
 m Z d d l m Z d d	 l m Z d
 „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d S(   i    (   t   absolute_importt   divisiont   unicode_literals(   t	   text_type(   t   OrderedDict(   t   etreei   (   t
   tag_regexpi   (   t   base(   t	   _ihatexmlc         C` s7   |  d  k r d  St |  t ƒ r# |  S|  j d d ƒ Sd  S(   Nu   asciiu   strict(   t   Nonet
   isinstanceR   t   decode(   t   s(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt
   ensure_str   s
    t   Rootc           B` s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C` s  | |  _  g  |  _ yV | j j rg |  j j t |  t | j j ƒ t | j j ƒ t | j j	 ƒ ƒ ƒ n  Wn t
 k
 r{ n Xy | j ƒ  } Wn t
 k
 r¥ | } n Xx" | j ƒ  d  k	 rÊ | j ƒ  } q© Wx, | d  k	 rù |  j j | ƒ | j ƒ  } qÎ Wd  |  _ d  |  _ d  S(   N(   t   elementtreet   childrent   docinfot   internalDTDt   appendt   DoctypeR   t	   root_namet	   public_idt
   system_urlt   AttributeErrort   getroott   getpreviousR	   t   getnextt   textt   tail(   t   selft   ett   node(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __init__   s*    		
	c         C` s   |  j  | S(   N(   R   (   R   t   key(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __getitem__3   s    c         C` s   d  S(   N(   R	   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR   6   s    c         C` s   d S(   Ni   (    (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __len__9   s    (   t   __name__t
   __module__R!   R#   R   R$   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR      s   			R   c           B` s   e  Z d  „  Z d „  Z RS(   c         C` s:   | |  _  | |  _ | |  _ | |  _ d  |  _ d  |  _ d  S(   N(   t	   root_nodet   nameR   t	   system_idR	   R   R   (   R   R'   R(   R   R)   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR!   >   s    					c         C` s   |  j  j d S(   Ni   (   R'   R   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR   G   s    (   R%   R&   R!   R   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR   =   s   		t   FragmentRootc           B` s   e  Z d  „  Z d „  Z RS(   c         C` s9   g  | D] } t  |  | ƒ ^ q |  _ d  |  _ |  _ d  S(   N(   t   FragmentWrapperR   R	   R   R   (   R   R   t   child(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR!   L   s    %c         C` s   d  S(   N(   R	   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR   P   s    (   R%   R&   R!   R   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR*   K   s   	R+   c           B` sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C` s|   | |  _  | |  _ t |  j d ƒ r< t |  j j ƒ |  _ n	 d  |  _ t |  j d ƒ ro t |  j j ƒ |  _ n	 d  |  _ d  S(   Nu   textu   tail(   R'   t   objt   hasattrR   R   R	   R   (   R   t   fragment_rootR-   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR!   U   s    			c         C` s   t  |  j | ƒ S(   N(   t   getattrR-   (   R   R(   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __getattr__a   s    c         C` sE   |  j  j } | j |  ƒ } | t | ƒ d k  r= | | d Sd  Sd  S(   Ni   (   R'   R   t   indext   lenR	   (   R   t   siblingst   idx(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR   d   s
    c         C` s   |  j  | S(   N(   R-   (   R   R"   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR#   l   s    c         C` s   t  |  j ƒ S(   N(   t   boolR-   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __bool__o   s    c         C` s   d  S(   N(   R	   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt	   getparentr   s    c         C` s   t  |  j ƒ S(   N(   t   strR-   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __str__u   s    c         C` s   t  |  j ƒ S(   N(   R9   R-   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   __unicode__x   s    c         C` s   t  |  j ƒ S(   N(   R3   R-   (   R   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR$   {   s    (   R%   R&   R!   R1   R   R#   R7   R8   R:   R;   R$   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR+   T   s   								t
   TreeWalkerc           B` s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C` sk   t  | t ƒ r- t | ƒ |  _ t | ƒ } n t ƒ  |  _ t | ƒ } t j j |  | ƒ t	 j
 ƒ  |  _ d  S(   N(   R
   t   listt   sett   fragmentChildrenR*   R   R   t   NonRecursiveTreeWalkerR!   R   t   InfosetFiltert   filter(   R   t   tree(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR!   €   s    c   	      C` s7  t  | t ƒ rS | \ } } | d	 k s7 t d | ƒ ‚ t j t t | | ƒ ƒ f St  | t ƒ rl t j f St  | t	 ƒ r— t j
 | j | j | j f St  | t ƒ rÌ t | d ƒ rÌ t j t | j ƒ f S| j t j k rô t j t | j ƒ f S| j t j k r#t j t | j ƒ d d !f St j t | j ƒ ƒ } | rV| j ƒ  \ } } n d  } t | j ƒ } t ƒ  } x… t | j j ƒ  ƒ D]n \ } } t | ƒ } t | ƒ } t j | ƒ } | rè| | | j  d ƒ | j  d ƒ f <qŠ| | d  | f <qŠWt j! | |  j" j# | ƒ | t$ | ƒ d k p/| j f Sd  S(
   Nu   textu   tailu%   Text nodes are text or tail, found %su   tagi   iÿÿÿÿi   i    (   u   textu   tail(%   R
   t   tuplet   AssertionErrorR   t   TEXTR   R0   R   t   DOCUMENTR   t   DOCTYPER(   R   R)   R+   R.   R-   t   tagR   t   Commentt   COMMENTR   t   Entityt   ENTITYR   t   matcht   groupsR	   R   R=   t   attribt   itemst   groupt   ELEMENTRB   t   fromXmlNameR3   (	   R   R    R"   RN   t	   namespaceRI   t   attrsR(   t   value(    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   getNodeDetails‹   s:    
	"%c         C` s\   t  | t ƒ s t d ƒ ‚ t | ƒ s= | j s= t d ƒ ‚ | j rP | d f S| d Sd  S(   Nu   Text nodes have no childrenu   Node has no childrenu   texti    (   R
   RD   RE   R3   R   (   R   R    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   getFirstChild´   s
    !	
c         C` sˆ   t  | t ƒ rk | \ } } | d k s7 t d | ƒ ‚ | d k r^ t | ƒ rW | d Sd  Sqk | j ƒ  Sn  | j r~ | d f S| j ƒ  S(   Nu   textu   tailu%   Text nodes are text or tail, found %si    (   u   textu   tail(   R
   RD   RE   R3   R	   R   R   (   R   R    R"   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   getNextSibling½   s    c         C` sg   t  | t ƒ rJ | \ } } | d k s7 t d | ƒ ‚ | d k r] | Sn | |  j k r] d  S| j ƒ  S(   Nu   textu   tailu%   Text nodes are text or tail, found %s(   u   textu   tail(   R
   RD   RE   R?   R	   R8   (   R   R    R"   (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   getParentNodeÍ   s    (   R%   R&   R!   RX   RY   RZ   R[   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyR<      s
   		)			N(   t
   __future__R    R   R   t   pip._vendor.sixR   t   collectionsR   t   lxmlR   t   treebuilders.etreeR   t    R   R   R   t   objectR   R   R*   R+   R@   R<   (    (    (    sH   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/treewalkers/etree_lxml.pyt   <module>   s   		&	+