Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyo


t_c@`s\ddlmZmZmZddlmZddlmZmZm	Z	dZieee
fd6eee	ddfhBe
fd6eee	ddfe	ddfhBe
fd	6ee	ddfe	dd
fge
fd
6ee	ddfe	ddfgefd
6ZdefdYZdefdYZdefdYZdS(i(tabsolute_importtdivisiontunicode_literals(t	text_typei(tscopingElementsttableInsertModeElementst
namespacesuhtmlubuttonuoluululistutableuoptgroupuoptionuselecttNodecB`skeZdZdZdZdZdZddZdZ	dZ
dZd	Zd
Z
RS(uRepresents an item in the treecC`s:||_d|_d|_i|_g|_g|_dS(uRCreates a Node

        :arg name: The tag name associated with the node

        N(tnametNonetparenttvaluet
attributest
childNodest_flags(tselfR((sW/opt/alt/python35/lib/python3.5/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(RRRt
attributesStr((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt__str__-s
	2cC`sd|jS(Nu<%s>(R(R((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt__repr__6scC`s
tdS(u[Insert node as a child of the current node

        :arg node: the node to insert

        N(tNotImplementedError(Rtnode((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pytappendChild9scC`s
tdS(uBInsert data as text in the current node, positioned before the
        start of node insertBefore or to the end of the node's text.

        :arg data: the data to insert

        :arg insertBefore: True if you want to insert the text before the node
            and False if you want to insert it after the node

        N(R(RtdatatinsertBefore((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt
insertTextAs
cC`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 node

        :arg node: the node to insert

        :arg refNode: the child node to insert the node before

        N(R(RRtrefNode((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRMs
cC`s
tdS(uhRemove node from the children of the current node

        :arg node: the child node to remove

        N(R(RR((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pytremoveChildYscC`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

        :arg newParent: the node to move all this node's children to

        N(R
R(Rt	newParenttchild((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pytreparentChildrenas	cC`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((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt	cloneNodenscC`s
tdS(uFReturn true if the node has children or text, false otherwise
        N(R(R((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt
hasContenttsN(t__name__t
__module__t__doc__RRRRR	RRRR R!R"(((sW/opt/alt/python35/lib/python3.5/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((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR+{s

cC`s0|j|jkstS|j|jks,tStS(N(t	nameTupletFalseRtTrue(Rtnode1tnode2((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR(s
(R#R$R+R((((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR&zs	
tTreeBuildercB`seZdZdZdZdZdZdZdZ	dZ
ddZdZdZ
dZdZdZdd	Zd
ZdZd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(umCreate a TreeBuilder

        :arg namespaceHTMLElements: whether or not to namespace HTML elements

        uhttp://www.w3.org/1999/xhtmlN(tdefaultNamespaceR	treset(RtnamespaceHTMLElements((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRs	cC`sCg|_t|_d|_d|_t|_|j|_	dS(N(
topenElementsR&tactiveFormattingElementsR	theadPointertformPointerR/tinsertFromTablet
documentClasstdocument(R((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR5s				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
isinstanceRRtlistElementsMaptreversedR7R0R.R/(Rttargettvariantt	exactNodetlistElementstinvertR((sW/opt/alt/python35/lib/python3.5/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(
R8tlenR'R7R0R!t
insertElementRt	namespaceR(RtitentrytcloneR-((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt#reconstructActiveFormattingElementss.	

	




cC`s>|jj}x(|jr9|tkr9|jj}qWdS(N(R8tpopR'(RRL((sW/opt/alt/python35/lib/python3.5/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(R8R'RR/(RRtitem((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt!elementInActiveFormattingElements
scC`s3|j|}|jj||jj|dS(N(t
createElementR7R+R=R(RttokenR-((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt
insertRootscC`sG|d}|d}|d}|j|||}|jj|dS(NunameupublicIdusystemId(tdoctypeClassR=R(RRTRtpublicIdtsystemIdtdoctype((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt
insertDoctype s



cC`s:|dkr|jd}n|j|j|ddS(Niudata(R	R7RtcommentClass(RRTR
((sW/opt/alt/python35/lib/python3.5/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(tgetR4telementClassR(RRTRRJR-((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRS-s


cC`s|jS(N(t_insertFromTable(R((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt_getInsertFromTable5scC`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_tinsertElementTableRItinsertElementNormal(RR((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt_setInsertFromTable8s	cC`sf|d}|jd|j}|j||}|d|_|jdj||jj||S(Nunameu	namespaceudatai(R]R4R^RR7RR+(RRTRRJR-((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRbCs

cC`s|j|}|jdjtkr2|j|S|j\}}|dkr`|j|n|j|||jj	||S(u-Create an element and insert it into the treeiN(
RSR7RRRbtgetTableMisnestedNodePositionR	RRR+(RRTR-R
R((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRaMs
cC`s{|dkr|jd}n|jsE|jrU|jdjtkrU|j|n"|j\}}|j||dS(uInsert text data.iN(R	R7R;RRRRd(RRR
R((sW/opt/alt/python35/lib/python3.5/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	R7RR
tindex(Rt	lastTabletfosterParentRtelm((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRdls			
c
C`sO|jdj}|td
krK||krK|jj|j|ndS(Niuddudtuliuoptionuoptgroupupurpurt(uddudtuliuoptionuoptgroupupurpurt(R7Rt	frozensetROtgenerateImpliedEndTags(RtexcludeR((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyRjs

cC`s|jS(uReturn the final tree(R=(R((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pytgetDocumentscC`s$|j}|jdj||S(uReturn the final fragmenti(t
fragmentClassR7R (Rtfragment((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pytgetFragmentscC`s
tdS(uSerialize the subtree of node in the format required by unit tests

        :arg node: the node from which to start serializing

        N(R(RR((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyttestSerializersN(R#R$R%R	R<R^R[RVRmRR5RGRNRPRRRURZR\RSR`RctpropertyR;RbRaRRdRjRlRoRp(((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyR3s6			.									
		
		N(t
__future__RRRtpip._vendor.sixRt	constantsRRRR	R'RiR/R0R@tobjectRR*R&R3(((sW/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/treebuilders/base.pyt<module>s$ c
Back to Directory File Manager