� ��abc@`shddlmZmZmZddlmZddlmZmZm Z dZ ie e�e fd6e eee ddfg�B�e fd6e eee ddfe ddfg�B�e fd 6e e ddfe dd fg�e fd 6e e dd fe dd fg�efd 6Zdefd��YZdefd��YZdefd��YZdS(i(tabsolute_importtdivisiontunicode_literals(t text_typei(tscopingElementsttableInsertModeElementst namespacesuhtmlubuttonuoluululistutableuoptgroupuoptionuselecttNodecB`seeZd�Zd�Zd�Zd�Zd d�Zd�Zd�Z d�Z d�Z d �Z RS( cC`s:||_d|_d|_i|_g|_g|_dS(u6Node 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(tnametNonetparenttvaluet attributest childNodest_flags(tselfR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt__init__s     cC`sadjg|jj�D]\}}d||f^q�}|rRd|j|fSd|jSdS(Nu u%s="%s"u<%s %s>u<%s>(tjoinR titemsR(RRR t attributesStr((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt__str__*s  2cC`s d|jS(Nu<%s>(R(R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt__repr__3scC`s t�dS(u3Insert node as a child of the current node N(tNotImplementedError(Rtnode((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt appendChild6scC`s t�dS(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(Rtdatat insertBefore((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt insertText;scC`s t�dS(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(RRtrefNode((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRAscC`s t�dS(u:Remove node from the children of the current node N(R(RR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt removeChildGscC`s.x|jD]}|j|�q Wg|_dS(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(Rt newParenttchild((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pytreparentChildrenLscC`s t�dS(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((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt cloneNodeVscC`s t�dS(uFReturn true if the node has children or text, false otherwise N(R(R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt hasContent\sN( t__name__t __module__RRRRR RRRR R!R"(((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRs       tActiveFormattingElementscB`seZd�Zd�ZRS(cC`s�d}|tkrxj|ddd�D]R}|tkr<Pn|j||�r[|d7}n|dkr&|j|�Pq&q&Wntj||�dS(Nii����ii(tMarkert nodesEqualtremovetlisttappend(RRt equalCounttelement((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR*cs      cC`s0|j|jkstS|j|jks,tStS(N(t nameTupletFalseR tTrue(Rtnode1tnode2((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR'ps (R#R$R*R'(((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR%bs t TreeBuildercB`s�eZdZdZdZdZdZdZd�Z d�Z dd�Z d�Z d�Z d�Zd�Zd�Zdd �Zd �Zd �Zd �Zeee�Zd �Zd�Zdd�Zd�Zdd�Zd�Zd�Zd�ZRS(uBase 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 cC`s)|rd|_n d|_|j�dS(Nuhttp://www.w3.org/1999/xhtml(tdefaultNamespaceR treset(RtnamespaceHTMLElements((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR�s  cC`sCg|_t�|_d|_d|_t|_|j�|_ dS(N( t openElementsR%tactiveFormattingElementsR t headPointert formPointerR.tinsertFromTablet documentClasstdocument(R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR4�s      cC`s�t|d�}|s:t|t�r:td|f}q:nt|\}}x^t|j�D]M}|rv||krvtS| r�|j|kr�tS||j|kArZt SqZWdS(Nu nameTupleuhtml( thasattrt isinstanceRRtlistElementsMaptreversedR6R/R-R.(Rttargettvariantt exactNodet listElementstinvertR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pytelementInScope�scC`s'|js dSt|j�d}|j|}|tksH||jkrLdSxL|tkr�||jkr�|dkr�d}Pn|d8}|j|}qOWx�tr"|d7}|j|}|j�}|jidd6|jd6|jd6|j d6�}||j|<||jdkr�Pq�q�WdS( Niii����uStartTagutypeunameu namespaceudata( R7tlenR&R6R/R!t insertElementRt namespaceR (RtitentrytcloneR,((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt#reconstructActiveFormattingElements�s.           cC`s>|jj�}x(|jr9|tkr9|jj�}qWdS(N(R7tpopR&(RRK((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pytclearActiveFormattingElements�scC`sHxA|jddd�D])}|tkr-Pq|j|kr|SqWtS(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����(R7R&RR.(RRtitem((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt!elementInActiveFormattingElements�s  cC`s3|j|�}|jj|�|jj|�dS(N(t createElementR6R*R<R(RttokenR,((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt insertRoot�scC`sG|d}|d}|d}|j|||�}|jj|�dS(NunameupublicIdusystemId(t doctypeClassR<R(RRSRtpublicIdtsystemIdtdoctype((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt insertDoctypes    cC`s:|dkr|jd}n|j|j|d��dS(Ni����udata(R R6Rt commentClass(RRSR ((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt insertComment s cC`sB|d}|jd|j�}|j||�}|d|_|S(u.Create an element but don't insert it anywhereunameu namespaceudata(tgetR3t elementClassR (RRSRRIR,((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRRs   cC`s|jS(N(t_insertFromTable(R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt_getInsertFromTablescC`s.||_|r|j|_n |j|_dS(usSwitch the function used to insert an element from the normal one to the misnested table one and back againN(R^tinsertElementTableRHtinsertElementNormal(RR ((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt_setInsertFromTables cC`sf|d}|jd|j�}|j||�}|d|_|jdj|�|jj|�|S(Nunameu namespaceudatai����(R\R3R]R R6RR*(RRSRRIR,((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRa$s  cC`s�|j|�}|jdjtkr2|j|�S|j�\}}|dkr`|j|�n|j||�|jj |�|S(u-Create an element and insert it into the treei����N( RRR6RRRatgetTableMisnestedNodePositionR RRR*(RRSR,R R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR`.s  cC`s{|dkr|jd}n|j sE|jrU|jdjtkrU|j|�n"|j�\}}|j||�dS(uInsert text data.i����N(R R6R:RRRRc(RRR R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR>s   cC`s�d}d}d}x7|jddd�D]}|jdkr)|}Pq)q)W|r�|jrm|j}|}q�|j|jj|�d}n |jd}||fS(usGet the foster parent element, and sibling to insert before (or None) when inserting a misnested table nodeNi����utableii(R R6RR tindex(Rt lastTablet fosterParentRtelm((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRcMs    c C`sO|jdj}|td �krK||krK|jj�|j|�ndS( Ni����uddudtuliuoptionuoptgroupupurpurt(uddudtuliuoptionuoptgroupupurpurt(R6Rt frozensetRNtgenerateImpliedEndTags(RtexcludeR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRigs   cC`s|jS(uReturn the final tree(R<(R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt getDocumentqscC`s$|j�}|jdj|�|S(uReturn the final fragmenti(t fragmentClassR6R (Rtfragment((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt getFragmentus cC`s t�dS(uzSerialize the subtree of node in the format required by unit tests node - the node from which to start serializingN(R(RR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyttestSerializer|sN(R#R$t__doc__R R;R]RZRURlRR4RFRMRORQRTRYR[RRR_RbtpropertyR:RaR`RRcRiRkRnRo(((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR2zs6   .             N(t __future__RRRtpip._vendor.sixRt constantsRRRR R&RhR.tsetR/R?tobjectRR)R%R2(((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyts*! K