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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
U
H=®d4ã    @s ddlmZmZmZddlmZddlmZmZm    Z    ddddd    d
d d d g    Z
ej Z ej ZejZejZejZejZdZd e    ¡Z    Gdd „d eƒZGdd „d eƒZdS)é)Úabsolute_importÚdivisionÚunicode_literals)ÚNodeé)Ú
namespacesÚ voidElementsÚspaceCharactersÚDOCUMENTÚDOCTYPEÚTEXTÚELEMENTÚCOMMENTÚENTITYÚUNKNOWNÚ
TreeWalkerÚNonRecursiveTreeWalkerz <#UNKNOWN#>Úc@sleZdZdZdd„Zdd„Zdd„Zdd    d
„Zd d „Zd d„Z    dd„Z
dd„Z ddd„Z dd„Z dd„ZdS)rz}Walks a tree yielding tokens
 
    Tokens are dicts that all have a ``type`` field specifying the type of the
    token.
 
    cCs
||_dS)zCCreates a TreeWalker
 
        :arg tree: the tree to walk
 
        N)Útree)Úselfr©rú\D:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/html5lib/treewalkers/base.pyÚ__init__szTreeWalker.__init__cCst‚dS©N©ÚNotImplementedError)rrrrÚ__iter__#szTreeWalker.__iter__cCs
d|dœS)z†Generates an error token with the given message
 
        :arg msg: the error message
 
        :returns: SerializeError token
 
        ÚSerializeError©ÚtypeÚdatar)rÚmsgrrrÚerror&szTreeWalker.errorFccs$d|||dœV|r | d¡VdS)arGenerates an EmptyTag token
 
        :arg namespace: the namespace of the token--can be ``None``
 
        :arg name: the name of the element
 
        :arg attrs: the attributes of the element as a dict
 
        :arg hasChildren: whether or not to yield a SerializationError because
            this tag shouldn't have children
 
        :returns: EmptyTag token
 
        ÚEmptyTag©rÚnameÚ    namespacer zVoid element has childrenN©r")rr&r%ÚattrsÚ hasChildrenrrrÚemptyTag0s þzTreeWalker.emptyTagcCsd|||dœS)zôGenerates a StartTag token
 
        :arg namespace: the namespace of the token--can be ``None``
 
        :arg name: the name of the element
 
        :arg attrs: the attributes of the element as a dict
 
        :returns: StartTag token
 
        ÚStartTagr$r)rr&r%r(rrrÚstartTagEs
ýzTreeWalker.startTagcCs d||dœS)z´Generates an EndTag token
 
        :arg namespace: the namespace of the token--can be ``None``
 
        :arg name: the name of the element
 
        :returns: EndTag token
 
        ÚEndTag)rr%r&r)rr&r%rrrÚendTagVs
þzTreeWalker.endTagccsx|}| t¡}|dt|ƒt|ƒ…}|r6d|dœV|}| t¡}|t|ƒd…}|rdd|dœV|rtd|dœVdS)atGenerates SpaceCharacters and Characters tokens
 
        Depending on what's in the data, this generates one or more
        ``SpaceCharacters`` and ``Characters`` tokens.
 
        For example:
 
            >>> from html5lib.treewalkers.base import TreeWalker
            >>> # Give it an empty tree just so it instantiates
            >>> walker = TreeWalker([])
            >>> list(walker.text(''))
            []
            >>> list(walker.text('  '))
            [{u'data': '  ', u'type': u'SpaceCharacters'}]
            >>> list(walker.text(' abc '))  # doctest: +NORMALIZE_WHITESPACE
            [{u'data': ' ', u'type': u'SpaceCharacters'},
            {u'data': u'abc', u'type': u'Characters'},
            {u'data': u' ', u'type': u'SpaceCharacters'}]
 
        :arg data: the text data
 
        :returns: one or more ``SpaceCharacters`` and ``Characters`` tokens
 
        NÚSpaceCharactersrÚ
Characters)Úlstripr    ÚlenÚrstrip)rr ZmiddleÚleftÚrightrrrÚtextds
 
 zTreeWalker.textcCs
d|dœS)zdGenerates a Comment token
 
        :arg data: the comment
 
        :returns: Comment token
 
        ÚCommentrr)rr rrrÚcommentŠszTreeWalker.commentNcCsd|||dœS)zŒGenerates a Doctype token
 
        :arg name:
 
        :arg publicId:
 
        :arg systemId:
 
        :returns: the Doctype token
 
        ÚDoctype)rr%ÚpublicIdÚsystemIdr)rr%r:r;rrrÚdoctype”s
ýzTreeWalker.doctypecCs
d|dœS)zjGenerates an Entity token
 
        :arg name: the entity name
 
        :returns: an Entity token
 
        ÚEntity)rr%r)rr%rrrÚentity¥szTreeWalker.entitycCs| d|¡S)zHandles unknown node typeszUnknown node type: r')rZnodeTyperrrÚunknown¯szTreeWalker.unknown)F)NN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr"r*r,r.r6r8r<r>r?rrrrrs
 
&
 
 
c@s4eZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd S) rcCst‚dSrr©rÚnoderrrÚgetNodeDetailsµsz%NonRecursiveTreeWalker.getNodeDetailscCst‚dSrrrDrrrÚ getFirstChild¸sz$NonRecursiveTreeWalker.getFirstChildcCst‚dSrrrDrrrÚgetNextSibling»sz%NonRecursiveTreeWalker.getNextSiblingcCst‚dSrrrDrrrÚ getParentNode¾sz$NonRecursiveTreeWalker.getParentNodec csò|j}|dk    rî| |¡}|d|dd…}}d}|tkrJ|j|ŽVnÖ|tkrj|j|ŽD]
}|Vq\n¶|tkrÊ|\}}}}|rŽ|tdkr¸|tkr¸|     ||||¡D]
}|Vq¦d}n| 
|||¡VnV|t krä|  |d¡Vn<|t kr| |d¡Vn |tkrd}n| |d¡V|r2| |¡}    nd}    |    dk    rF|    }q|dk    r| |¡}|d|dd…}}|tkr°|\}}}}|r˜|tdks¢|tkr°| ||¡V|j|krÂd}q| |¡}
|
dk    rÞ|
}qn
| |¡}qFqdS)NréFÚhtmlT)rrFr r<r r6r rrr*r,rr8rr>r
r?rGr.rHrI) rÚ currentNodeÚdetailsrr)Útokenr&r%Ú
attributesZ
firstChildZ nextSiblingrrrrÁs\
 
 
 
ÿ
 
 
 
 
 
 
zNonRecursiveTreeWalker.__iter__N)r@rArBrFrGrHrIrrrrrr´s
N)Ú
__future__rrrÚxml.domrÚ    constantsrrr    Ú__all__Z DOCUMENT_NODEr
ZDOCUMENT_TYPE_NODEr Z    TEXT_NODEr Z ELEMENT_NODEr Z COMMENT_NODErZ ENTITY_NODErrÚjoinÚobjectrrrrrrÚ<module>s" ÿ
!