zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
U
H=®då8ã@sòddlmZmZmZddlmZddlmZmZm    Z    dZ
e eƒdfe ee    ddfhBƒdfe ee    dd    fe    dd
fhBƒdfe e    ddfe    dd fgƒdfe e    dd fe    dd fgƒdfdœZ Gdd„de ƒZGdd„deƒZGdd„de ƒZdS)é)Úabsolute_importÚdivisionÚunicode_literals)Ú    text_typeé)ÚscopingElementsÚtableInsertModeElementsÚ
namespacesNFÚhtmlÚbuttonÚolÚulÚtableÚoptgroupÚoptionT)Nr ÚlistrÚselectc@sbeZdZdZdd„Zdd„Zdd„Zdd    „Zdd d „Zd d„Z    dd„Z
dd„Z dd„Z dd„Z d
S)ÚNodezRepresents an item in the treecCs(||_d|_d|_i|_g|_g|_dS)zRCreates a Node
 
        :arg name: The tag name associated with the node
 
        N)ÚnameÚparentÚvalueÚ
attributesÚ
childNodesÚ_flags)Úselfr©rú]D:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/html5lib/treebuilders/base.pyÚ__init__s z Node.__init__cCs:d dd„|j ¡Dƒ¡}|r,d|j|fSd|jSdS)Nú cSsg|]\}}d||f‘qS)z%s="%s"r)Ú.0rrrrrÚ
<listcomp>.sÿz Node.__str__.<locals>.<listcomp>z<%s %s>ú<%s>)ÚjoinrÚitemsr)rÚ attributesStrrrrÚ__str__-s 
þz Node.__str__cCs
d|jS)Nr!)r©rrrrÚ__repr__6sz Node.__repr__cCst‚dS)z[Insert node as a child of the current node
 
        :arg node: the node to insert
 
        N©ÚNotImplementedError©rÚnoderrrÚ appendChild9szNode.appendChildNcCst‚dS)aBInsert 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
 
        Nr()rÚdataÚ insertBeforerrrÚ
insertTextAs
zNode.insertTextcCst‚dS)aInsert 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
 
        Nr()rr+ÚrefNoderrrr.Ms
zNode.insertBeforecCst‚dS)zhRemove node from the children of the current node
 
        :arg node: the child node to remove
 
        Nr(r*rrrÚ removeChildYszNode.removeChildcCs |jD]}| |¡qg|_dS)zô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
 
        :arg newParent: the node to move all this node's children to
 
        N)rr,)rÚ    newParentÚchildrrrÚreparentChildrenas    
 zNode.reparentChildrencCst‚dS)zŠ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
        Nr(r&rrrÚ    cloneNodenszNode.cloneNodecCst‚dS)zFReturn true if the node has children or text, false otherwise
        Nr(r&rrrÚ
hasContenttszNode.hasContent)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rr%r'r,r/r.r1r4r5r6rrrrrs    
  rc@seZdZdd„Zdd„ZdS)ÚActiveFormattingElementscCsfd}|tkrV|ddd…D]:}|tkr*qV| ||¡r>|d7}|dkr| |¡qVqt ||¡dS)Nréÿÿÿÿéé)ÚMarkerÚ
nodesEqualÚremoverÚappend)rr+Ú
equalCountÚelementrrrrB{s 
zActiveFormattingElements.appendcCs$|j|jksdS|j|jks dSdS)NFT)Ú    nameTupler)rÚnode1Únode2rrrr@ˆs
  z#ActiveFormattingElements.nodesEqualN)r7r8r9rBr@rrrrr;zs r;c@sÖeZdZdZdZdZdZdZdZdd„Z    dd„Z
d+dd„Z d    d
„Z d d „Z d d„Zdd„Zdd„Zd,dd„Zdd„Zdd„Zdd„ZeeeƒZdd„Zdd„Zd-dd „Zd!d"„Zd.d#d$„Zd%d&„Zd'd(„Zd)d*„ZdS)/Ú TreeBuilderaBase 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
 
    NcCs|r d|_nd|_| ¡dS)zmCreate a TreeBuilder
 
        :arg namespaceHTMLElements: whether or not to namespace HTML elements
 
        zhttp://www.w3.org/1999/xhtmlN)ÚdefaultNamespaceÚreset)rÚnamespaceHTMLElementsrrrr¬szTreeBuilder.__init__cCs.g|_tƒ|_d|_d|_d|_| ¡|_dS)NF)Ú openElementsr;ÚactiveFormattingElementsÚ headPointerÚ formPointerÚinsertFromTableÚ documentClassÚdocumentr&rrrrJ¸s zTreeBuilder.resetcCs”t|dƒ}|s2t|tƒr$td|f}t|tƒs2t‚t|\}}t|jƒD]>}|r^||kr^dS|sr|j    |krrdS||j    |kArHdSqHdst‚dS)NrEr
TF)
ÚhasattrÚ
isinstancerr    ÚtupleÚAssertionErrorÚlistElementsMapÚreversedrLrE)rÚtargetÚvariantÚ    exactNodeÚ listElementsÚinvertr+rrrÚelementInScopeÄs
 
   zTreeBuilder.elementInScopecCsÀ|js
dSt|jƒd}|j|}|tks4||jkr8dS|tkrl||jkrl|dkrXd}ql|d8}|j|}q8|d7}|j|}| ¡}| d|j|j|jdœ¡}||j|<||jdkrlq¼qldS)Nr=rr<ÚStartTag)ÚtyperÚ    namespacer-)    rMÚlenr?rLr5Ú insertElementrrar)rÚiÚentryÚclonerDrrrÚ#reconstructActiveFormattingElementsÚs.
 
ý
z/TreeBuilder.reconstructActiveFormattingElementscCs(|j ¡}|jr$|tkr$|j ¡}q
dS©N)rMÚpopr?)rrerrrÚclearActiveFormattingElementss
z)TreeBuilder.clearActiveFormattingElementscCs:|jddd…D]$}|tkr"q6q|j|kr|SqdS)zšCheck if an element exists between the end of the active
        formatting elements and the last marker. If it does, return it, else
        return falseNr<F)rMr?r)rrÚitemrrrÚ!elementInActiveFormattingElements s 
 
z-TreeBuilder.elementInActiveFormattingElementscCs&| |¡}|j |¡|j |¡dSrh)Ú createElementrLrBrRr,)rÚtokenrDrrrÚ
insertRoots
 zTreeBuilder.insertRootcCs6|d}|d}|d}| |||¡}|j |¡dS)NrÚpublicIdÚsystemId)Ú doctypeClassrRr,)rrnrrprqÚdoctyperrrÚ insertDoctype s
zTreeBuilder.insertDoctypecCs*|dkr|jd}| | |d¡¡dS)Nr<r-)rLr,Ú commentClass)rrnrrrrÚ insertComment(s
zTreeBuilder.insertCommentcCs0|d}| d|j¡}| ||¡}|d|_|S)z.Create an element but don't insert it anywhererrar-)ÚgetrIÚ elementClassr©rrnrrarDrrrrm-s
 
zTreeBuilder.createElementcCs|jSrh)Ú_insertFromTabler&rrrÚ_getInsertFromTable5szTreeBuilder._getInsertFromTablecCs ||_|r|j|_n|j|_dS)zsSwitch the function used to insert an element from the
        normal one to the misnested table one and back againN)rzÚinsertElementTablercÚinsertElementNormal)rrrrrÚ_setInsertFromTable8s
zTreeBuilder._setInsertFromTablecCsb|d}t|tƒstd|ƒ‚| d|j¡}| ||¡}|d|_|jd |¡|j     |¡|S)NrzElement %s not unicoderar-r<)
rTrrVrwrIrxrrLr,rBryrrrr}Cs 
 zTreeBuilder.insertElementNormalcCs`| |¡}|jdjtkr$| |¡S| ¡\}}|dkrD| |¡n | ||¡|j |¡|S)z-Create an element and insert it into the treer<N)    rmrLrrr}ÚgetTableMisnestedNodePositionr,r.rB)rrnrDrr.rrrr|Ms
 
    zTreeBuilder.insertElementTablecCsV|dkr|jd}|jr.|jr:|jdjtkr:| |¡n| ¡\}}| ||¡dS)zInsert text data.Nr<)rLrPrrr/r)rr-rr.rrrr/]s
 
ÿÿ  zTreeBuilder.insertTextcCstd}d}d}|jddd…D]}|jdkr|}q4q|rb|jrJ|j}|}ql|j|j |¡d}n
|jd}||fS)zsGet the foster parent element, and sibling to insert before
        (or None) when inserting a misnested table nodeNr<rr=r)rLrrÚindex)rÚ    lastTableÚ fosterParentr.Úelmrrrrls 
ÿ
z)TreeBuilder.getTableMisnestedNodePositioncCs8|jdj}|tdƒkr4||kr4|j ¡| |¡dS)Nr<)ÚddÚdtÚlirrÚpÚrpÚrt)rLrÚ    frozensetriÚgenerateImpliedEndTags)rÚexcluderrrrr‹†s   ÿ
z"TreeBuilder.generateImpliedEndTagscCs|jS)zReturn the final tree)rRr&rrrÚ getDocumentszTreeBuilder.getDocumentcCs| ¡}|jd |¡|S)zReturn the final fragmentr)Ú fragmentClassrLr4)rÚfragmentrrrÚ getFragment”szTreeBuilder.getFragmentcCst‚dS)z‰Serialize the subtree of node in the format required by unit tests
 
        :arg node: the node from which to start serializing
 
        Nr(r*rrrÚtestSerializer›szTreeBuilder.testSerializer)N)N)N)N)r7r8r9r:rQrxrurrrŽrrJr^rgrjrlrortrvrmr{r~ÚpropertyrPr}r|r/rr‹rrr‘rrrrrH’s6  
.
    
 
 
 
 
rH)Ú
__future__rrrZpip._vendor.sixrÚ    constantsrrr    r?rŠrWÚobjectrrr;rHrrrrÚ<module>s0 
 
ÿÿ 
ÿÿ 
ÿÿù c