abc@`shddlmZmZmZddlmZddlmZmZm Z dZ ie ee fd6e eee ddfgBe fd6e eee ddfe ddfgBe fd 6e e ddfe dd fge fd 6e e dd fe dd fgefd 6ZdefdYZdefdYZdefdYZdS(i(tabsolute_importtdivisiontunicode_literals(t text_typei(tscopingElementsttableInsertModeElementst namespacesuhtmlubuttonuoluululistutableuoptgroupuoptionuselecttNodecB`seeZdZdZdZdZd dZdZdZ dZ dZ 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|jjD]\}}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 tdS(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 tdS(uInsert 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 tdS(uInsert 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 tdS(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(uMove 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 tdS(uReturn 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 tdS(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`seZdZdZRS(cC`sd}|tkrxj|dddD]R}|tkr<Pn|j||r[|d7}n|dkr&|j|Pq&q&Wntj||dS(Niiii(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`seZdZdZdZdZdZdZdZ dZ ddZ dZ dZ dZdZdZdd Zd Zd Zd ZeeeZd ZdZddZdZddZdZdZdZRS(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|_|jdS(Nuhttp://www.w3.org/1999/xhtml(tdefaultNamespaceR treset(RtnamespaceHTMLElements((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRs  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.pyR4s      cC`st|d}|s:t|tr:td|f}q:nt|\}}x^t|jD]M}|rv||krvtS| r|j|krtS||j|kArZt SqZWdS(Nu nameTupleuhtml( thasattrt isinstanceRRtlistElementsMaptreversedR6R/R-R.(Rttargettvariantt exactNodet listElementstinvertR((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pytelementInScopescC`s'|js dSt|jd}|j|}|tksH||jkrLdSxL|tkr||jkr|dkrd}Pn|d8}|j|}qOWxtr"|d7}|j|}|j}|jidd6|jd6|jd6|j d6}||j|<||jdkrPqqWdS( NiiiuStartTagutypeunameu namespaceudata( R7tlenR&R6R/R!t insertElementRt namespaceR (RtitentrytcloneR,((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt#reconstructActiveFormattingElementss.           cC`s>|jj}x(|jr9|tkr9|jj}qWdS(N(R7tpopR&(RRK((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pytclearActiveFormattingElementsscC`sHxA|jdddD])}|tkr-Pq|j|kr|SqWtS(uCheck 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!elementInActiveFormattingElementss  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 insertRootscC`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|ddS(Niudata(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 treeiN( 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.iN(R R6R:RRRRc(RRR R((sJ/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR>s   cC`sd}d}d}x7|jdddD]}|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 nodeNiutableii(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( Niuddudtuliuoptionuoptgroupupurpurt(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 tdS(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