ó r2Wc@`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((sK/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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt__str__*s  2cC`s d|jS(Nu<%s>(R(R((sK/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((sK/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((sK/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((sK/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((sK/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((sK/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((sK/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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt hasContent\sN( t__name__t __module__RRRRR RRRR R!R"(((sK/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((sK/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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyR'ps (R#R$R*R'(((sK/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((sK/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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyR4˜s      cC`sŒt|dƒ}t|\}}xZt|jƒD]I}|j|krK| s]||kra|ratS||j|kAr/tSq/Wtsˆt‚dS(Nu nameTuple( thasattrtlistElementsMaptreversedR6RR/R-R.tAssertionError(Rttargettvariantt exactNodet listElementstinvertR((sK/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,((sK/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((sK/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((sK/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,((sK/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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt insertDoctypeûs    cC`s:|dkr|jd}n|j|j|dƒƒdS(Niÿÿÿÿudata(R R6Rt commentClass(RRSR ((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt insertComments cC`sB|d}|jd|jƒ}|j||ƒ}|d|_|S(u.Create an element but don't insert it anywhereunameu namespaceudata(tgetR3t elementClassR (RRSRRIR,((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyRRs   cC`s|jS(N(t_insertFromTable(R((sK/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 ((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt_setInsertFromTables cC`s…|d}t|tƒs)td|ƒ‚|jd|jƒ}|j||ƒ}|d|_|jdj|ƒ|jj |ƒ|S(NunameuElement %s not unicodeu namespaceudataiÿÿÿÿ( t isinstanceRR@R\R3R]R R6RR*(RRSRRIR,((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyRas  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((sK/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:RRRRd(RRR R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyR8s   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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyRdGs    c C`sO|jdj}|td ƒkrK||krK|jjƒ|j|ƒndS( Niÿÿÿÿuddudtuliuoptionuoptgroupupurpurt(uddudtuliuoptionuoptgroupupurpurt(R6Rt frozensetRNtgenerateImpliedEndTags(RtexcludeR((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyRjas   cC`s|jS(uReturn the final tree(R<(R((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt getDocumentkscC`s$|jƒ}|jdj|ƒ|S(uReturn the final fragmenti(t fragmentClassR6R (Rtfragment((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyt getFragmentos 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((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyttestSerializervsN(R#R$t__doc__R R;R]RZRURmRR4RFRMRORQRTRYR[RRR_RbtpropertyR:RaR`RRdRjRlRoRp(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyR2zs6   .             N(t __future__RRRtpip._vendor.sixRt constantsRRRR R&RiR.tsetR/R>tobjectRR)R%R2(((sK/usr/lib/python2.7/site-packages/pip/_vendor/html5lib/treebuilders/_base.pyts*! K