
Rc        
   @` sh  d  d k  l Z l Z l Z d  d k l Z d d k l Z l Z l	 Z	 d Z h e e  e f d 6e e e e	 d d f g  B e f d 6e e e e	 d d f e	 d d f g  B e f d	 6e e	 d d f e	 d d
 f g  e f d
 6e e	 d d f e	 d d f g  e f d 6Z d e f d     YZ d e f d     YZ d e f d     YZ d S(   i    (   t   absolute_importt   divisiont   unicode_literals(   t	   text_typei   (   t   scopingElementst   tableInsertModeElementst
   namespacesu   htmlu   buttonu   olu   ulu   listu   tableu   optgroupu   optionu   selectt   Nodec           B` se   e  Z d    Z d   Z d   Z d   Z d
 d  Z d   Z d   Z	 d   Z
 d   Z d	   Z RS(   c         C` s:   | |  _  d |  _ d |  _ h  |  _ g  |  _ g  |  _ d S(   u6  Node representing an item in the tree.
        name - The tag name associated with the node
        parent - The parent of the current node (or None for the document node)
        value - The value of the current node (applies to text nodes and
        comments
        attributes - a dict holding name, value pairs for attributes of the node
        childNodes - a list of child nodes of the current node. This must
        include all elements but not necessarily other node types
        _flags - A list of miscellaneous flags that can be set on the node
        N(   t   namet   Nonet   parentt   valuet
   attributest
   childNodest   _flags(   t   selfR   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   __init__   s    					c         C` sk   d i  g  } |  i i   D] \ } } | d | | f q ~  } | o d |  i | f Sd |  i Sd  S(   Nu    u   %s="%s"u   <%s %s>u   <%s>(   t   joinR   t   itemsR   (   R   t   _[1]R   R   t   attributesStr(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   __str__*   s
    6c         C` s   d |  i  S(   Nu   <%s>(   R   (   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   __repr__3   s    c         C` s
   t   d S(   u3   Insert node as a child of the current node
        N(   t   NotImplementedError(   R   t   node(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   appendChild6   s    c         C` s
   t   d S(   u   Insert data as text in the current node, positioned before the
        start of node insertBefore or to the end of the node's text.
        N(   R   (   R   t   datat   insertBefore(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt
   insertText;   s    c         C` s
   t   d S(   u   Insert node as a child of the current node, before refNode in the
        list of child nodes. Raises ValueError if refNode is not a child of
        the current nodeN(   R   (   R   R   t   refNode(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR   A   s    c         C` s
   t   d S(   u:   Remove node from the children of the current node
        N(   R   (   R   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   removeChildG   s    c         C` s.   x |  i  D] } | i |  q
 Wg  |  _  d S(   u   Move all the children of the current node to newParent.
        This is needed so that trees that don't store text as nodes move the
        text in the correct way
        N(   R   R   (   R   t	   newParentt   child(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   reparentChildrenL   s    
 c         C` s
   t   d S(   u   Return a shallow copy of the current node i.e. a node with the same
        name and attributes but with no parent or child nodes
        N(   R   (   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt	   cloneNodeV   s    c         C` s
   t   d S(   uF   Return true if the node has children or text, false otherwise
        N(   R   (   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt
   hasContent\   s    N(   t   __name__t
   __module__R   R   R   R   R	   R   R   R   R!   R"   R#   (    (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR      s   								
	t   ActiveFormattingElementsc           B` s   e  Z d    Z d   Z RS(   c         C` s   d } | t  j ot xq |  d  d  d  D]X } | t  j o Pn |  i | |  o | d 7} n | d j o |  i |  Pq' q' Wn t i |  |  d  S(   Ni    ii   i   (   t   Markert
   nodesEqualt   removet   listt   append(   R   R   t
   equalCountt   element(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR+   c   s     c         C` s4   | i  | i  j p t S| i | i j p t St S(   N(   t	   nameTuplet   FalseR   t   True(   R   t   node1t   node2(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR(   p   s
    (   R$   R%   R+   R(   (    (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR&   b   s   	t   TreeBuilderc           B` s   e  Z d  Z d Z d Z d Z d Z d Z d   Z	 d   Z
 d d  Z d   Z d   Z d   Z d   Z d   Z d d	  Z d
   Z d   Z d   Z e e e  Z d   Z d   Z d d  Z d   Z d d  Z d   Z d   Z d   Z RS(   u  Base treebuilder implementation
    documentClass - the class to use for the bottommost node of a document
    elementClass - the class to use for HTML Elements
    commentClass - the class to use for comments
    doctypeClass - the class to use for doctypes
    c         C` s+   | o d |  _  n
 d  |  _  |  i   d  S(   Nu   http://www.w3.org/1999/xhtml(   t   defaultNamespaceR	   t   reset(   R   t   namespaceHTMLElements(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR      s    	c         C` sC   g  |  _  t   |  _ d  |  _ d  |  _ t |  _ |  i   |  _	 d  S(   N(
   t   openElementsR&   t   activeFormattingElementsR	   t   headPointert   formPointerR/   t   insertFromTablet   documentClasst   document(   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR5      s    				c         C` s   t  | d  } t | \ } } xa t |  i  D]P } | i | j o | p | | j o | o t S| | i | j Ao t Sq/ Wt p t  d  S(   Nu	   nameTuple(	   t   hasattrt   listElementsMapt   reversedR7   R   R0   R.   R/   t   AssertionError(   R   t   targett   variantt	   exactNodet   listElementst   invertR   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   elementInScope   s     	c         C` s5  |  i  p d  St |  i   d } |  i  | } | t j p | |  i j o d  SxQ | t j oC | |  i j o3 | d j o d } Pn | d 8} |  i  | } qT Wx t o | d 7} |  i  | } | i   } |  i h d d 6| i d 6| i d 6| i	 d 6 } | |  i  | <| |  i  d j o Pq q Wd  S(	   Ni   i    iu   StartTagu   typeu   nameu	   namespaceu   data(
   R8   t   lenR'   R7   R0   R"   t   insertElementR   t	   namespaceR   (   R   t   it   entryt   cloneR-   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt#   reconstructActiveFormattingElements   s2    
 
 


c         C` sA   |  i  i   } x+ |  i  o  | t j o |  i  i   } q Wd  S(   N(   R8   t   popR'   (   R   RL   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   clearActiveFormattingElements   s     c         C` sL   xE |  i  d d d  D]- } | t j o Pq | i | j o | Sq Wt S(   u   Check if an element exists between the end of the active
        formatting elements and the last marker. If it does, return it, else
        return falseNi(   R8   R'   R   R/   (   R   R   t   item(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt!   elementInActiveFormattingElements   s     	c         C` s3   |  i  |  } |  i i |  |  i i |  d  S(   N(   t   createElementR7   R+   R=   R   (   R   t   tokenR-   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt
   insertRoot   s    c         C` sG   | d } | d } | d } |  i  | | |  } |  i i |  d  S(   Nu   nameu   publicIdu   systemId(   t   doctypeClassR=   R   (   R   RT   R   t   publicIdt   systemIdt   doctype(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   insertDoctype   s
    


c         C` s<   | d  j o |  i d } n | i |  i | d   d  S(   Niu   data(   R	   R7   R   t   commentClass(   R   RT   R
   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   insertComment  s    c         C` sB   | d } | i  d |  i  } |  i | |  } | d | _ | S(   u.   Create an element but don't insert it anywhereu   nameu	   namespaceu   data(   t   getR4   t   elementClassR   (   R   RT   R   RJ   R-   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyRS     s
    
c         C` s   |  i  S(   N(   t   _insertFromTable(   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   _getInsertFromTable  s    c         C` s0   | |  _  | o |  i |  _ n |  i |  _ d S(   us   Switch the function used to insert an element from the
        normal one to the misnested table one and back againN(   R_   t   insertElementTableRI   t   insertElementNormal(   R   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   _setInsertFromTable  s    	c         C` s   | d } t  | t  p t d |  | i d |  i  } |  i | |  } | d | _ |  i d i |  |  i i	 |  | S(   Nu   nameu   Element %s not unicodeu	   namespaceu   datai(
   t
   isinstanceR   RA   R]   R4   R^   R   R7   R   R+   (   R   RT   R   RJ   R-   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyRb     s    
c         C` s   |  i  |  } |  i d i t j o |  i |  S|  i   \ } } | d j o | i |  n | i | |  |  i i	 |  | S(   u-   Create an element and insert it into the treeiN(
   RS   R7   R   R   Rb   t   getTableMisnestedNodePositionR	   R   R   R+   (   R   RT   R-   R
   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyRa   (  s    c         C` s   | d j o |  i d } n |  i p! |  i o( |  i d i t j o | i |  n# |  i   \ } } | i | |  d S(   u   Insert text data.iN(   R	   R7   R;   R   R   R   Re   (   R   R   R
   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR   8  s    
c         C` s   d } d } d } x9 |  i d d d  D]! } | i d j o | } Pq) q) W| o> | i o | i } | } q |  i |  i i |  d } n |  i d } | | f S(   us   Get the foster parent element, and sibling to insert before
        (or None) when inserting a misnested table nodeNiu   tablei   i    (   R	   R7   R   R
   t   index(   R   t	   lastTablet   fosterParentR   t   elm(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyRe   G  s      	
	
c      
   C` sR   |  i  d i } | t d
  j o+ | | j o |  i  i   |  i |  n d  S(   Niu   ddu   dtu   liu   optionu   optgroupu   pu   rpu   rt(   u   ddu   dtu   liu   optionu   optgroupu   pu   rpu   rt(   R7   R   t	   frozensetRO   t   generateImpliedEndTags(   R   t   excludeR   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyRk   a  s
    c         C` s   |  i  S(   u   Return the final tree(   R=   (   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   getDocumentk  s    c         C` s$   |  i    } |  i d i |  | S(   u   Return the final fragmenti    (   t   fragmentClassR7   R!   (   R   t   fragment(    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   getFragmento  s    c         C` s
   t   d S(   uz   Serialize the subtree of node in the format required by unit tests
        node - the node from which to start serializingN(   R   (   R   R   (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   testSerializerv  s    N(   R$   R%   t   __doc__R	   R<   R^   R[   RV   Rn   R   R5   RG   RN   RP   RR   RU   RZ   R\   RS   R`   Rc   t   propertyR;   Rb   Ra   R   Re   Rk   Rm   Rp   Rq   (    (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyR3   z   s6   			.									
		
		N(   t
   __future__R    R   R   t   pip.vendor.sixR   t	   constantsR   R   R   R	   R'   Rj   R/   t   setR0   R?   t   objectR   R*   R&   R3   (    (    (    sb   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/html5lib/treebuilders/_base.pyt   <module>   s   *! K