zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
U
H=®da~ã @sìddlmZmZmZddlmZddlmZmZddl    Z    ddl
Z
ddl m Z m Z ddlmZddlmZmZmZmZdd    lmZdd
lmZed d „eDƒƒZed d „eDƒƒZedd „eDƒƒZeeddgƒBZdZejreddkrøe d¡dksüt ‚e
 !edd…e"dƒd¡Z#n
e
 !e¡Z#dddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4h Z$e
 !d5¡Z%iZ&Gd6d7„d7e'ƒZ(d8d9„Z)Gd:d;„d;e'ƒZ*Gd<d=„d=e*ƒZ+Gd>d?„d?e,ƒZ-Gd@dA„dAe'ƒZ.GdBdC„dCe'ƒZ/dDdE„Z0dS)Fé)Úabsolute_importÚdivisionÚunicode_literals)Ú    text_type)Ú http_clientÚurllibN)ÚBytesIOÚStringIO)Ú webencodingsé)ÚEOFÚspaceCharactersÚ asciiLettersÚasciiUppercase)Ú_ReparseException)Ú_utilscCsg|]}| d¡‘qS©Úascii©Úencode©Ú.0Úitem©rúXD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/html5lib/_inputstream.pyÚ
<listcomp>srcCsg|]}| d¡‘qSrrrrrrrscCsg|]}| d¡‘qSrrrrrrrsó>ó<uš[- --Ÿ﷐-﷯￾￿🿾🿿𯿾𯿿𿿾𿿿ñ¿¾ñ¿¿ñŸ¿¾ñŸ¿¿ñ¯¿¾ñ¯¿¿ñ¿¿¾ñ¿¿¿ò¿¾ò¿¿òŸ¿¾òŸ¿¿ò¯¿¾ò¯¿¿ò¿¿¾ò¿¿¿ó¿¾ó¿¿óŸ¿¾óŸ¿¿ó¯¿¾ó¯¿¿ó¿¿¾ó¿¿¿ô¿¾ô¿¿]éÿÿÿÿú]z"\uD800-\uDFFF"iþÿiÿÿiþÿiÿÿiþÿiÿÿiþÿiÿÿiþÿiÿÿiþÿiÿÿiþÿiÿÿiþÿiÿÿiþÿ    iÿÿ    iþÿ
iÿÿ
iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿiÿÿiþÿiÿÿiþÿiÿÿz[    -  -/:-@\[-`{-~]c@sHeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dS)ÚBufferedStreamzÆBuffering for streams that do not have buffering of their own
 
    The buffer is implemented as a list of chunks on the assumption that
    joining many strings will be slow since it is O(n**2)
    cCs||_g|_ddg|_dS)Nrr)ÚstreamÚbufferÚposition)Úselfr!rrrÚ__init__:szBufferedStream.__init__cCs<d}|jd|jd…D]}|t|ƒ7}q||jd7}|S©Nrr )r"r#Úlen)r$ÚposÚchunkrrrÚtell?s
zBufferedStream.tellcCsT|| ¡kst‚|}d}t|j|ƒ|krF|t|j|ƒ8}|d7}q||g|_dSr&)Ú_bufferedBytesÚAssertionErrorr'r"r#)r$r(ÚoffsetÚirrrÚseekFs
zBufferedStream.seekcCsT|js| |¡S|jdt|jƒkrF|jdt|jdƒkrF| |¡S| |¡SdS)Nrr r)r"Ú _readStreamr#r'Ú_readFromBuffer©r$ÚbytesrrrÚreadOs
ÿ
zBufferedStream.readcCstdd„|jDƒƒS)NcSsg|] }t|ƒ‘qSr)r'rrrrrYsz1BufferedStream._bufferedBytes.<locals>.<listcomp>)Úsumr"©r$rrrr+XszBufferedStream._bufferedBytescCs<|j |¡}|j |¡|jdd7<t|ƒ|jd<|Sr&)r!r4r"Úappendr#r')r$r3Údatarrrr0[s
  zBufferedStream._readStreamcCsÐ|}g}|jd}|jd}|t|jƒkr²|dkr²|dks>t‚|j|}|t|ƒ|krl|}|||g|_n"t|ƒ|}|t|ƒg|_|d7}| ||||…¡||8}d}q|rÆ| | |¡¡d |¡S)Nrr ó)r#r'r"r,r7r0Újoin)r$r3ÚremainingBytesÚrvÚ bufferIndexÚ bufferOffsetÚ bufferedDataÚ bytesToReadrrrr1bs&
 
 
 zBufferedStream._readFromBufferN) Ú__name__Ú
__module__Ú __qualname__Ú__doc__r%r*r/r4r+r0r1rrrrr 3s        r cKs’t|tjƒs(t|tjjƒr.t|jtjƒr.d}n&t|dƒrJt| d¡t    ƒ}n
t|t    ƒ}|r‚dd„|Dƒ}|rvt
d|ƒ‚t |f|ŽSt |f|ŽSdS)NFr4rcSsg|]}| d¡r|‘qS)Ú    _encoding)Úendswith)rÚxrrrr‹s
z#HTMLInputStream.<locals>.<listcomp>z3Cannot set an encoding with a unicode input, set %r) Ú
isinstancerÚ HTTPResponserÚresponseÚaddbaseÚfpÚhasattrr4rÚ    TypeErrorÚHTMLUnicodeInputStreamÚHTMLBinaryInputStream)ÚsourceÚkwargsÚ    isUnicodeÚ    encodingsrrrÚHTMLInputStream}s  þ ý
 
  rUc@speZdZdZdZdd„Zdd„Zdd„Zd    d
„Zd d „Z    d d„Z
ddd„Z dd„Z dd„Z ddd„Zdd„ZdS)rOú×Provides a unicode stream of characters to the HTMLTokenizer.
 
    This class takes care of character encoding and removing or replacing
    incorrect byte-sequences and also provides column and line tracking.
 
    i(cCsZtjsd|_ntdƒdkr$|j|_n|j|_dg|_tdƒdf|_|     |¡|_
|  ¡dS)á¿Initialises the HTMLInputStream.
 
        HTMLInputStream(source, [encoding]) -> Normalized stream from source
        for use by html5lib.
 
        source can be either a file-object, local filename or a string.
 
        The optional encoding parameter must be a string that indicates
        the encoding.  If specified, that encoding will be used,
        regardless of any BOM or later declaration (such as in a meta
        element)
 
        Nuô¿¿r rúutf-8Úcertain) rÚsupports_lone_surrogatesÚreportCharacterErrorsr'ÚcharacterErrorsUCS4ÚcharacterErrorsUCS2ÚnewLinesÚlookupEncodingÚ charEncodingÚ
openStreamÚ
dataStreamÚreset)r$rQrrrr%žs 
 zHTMLUnicodeInputStream.__init__cCs.d|_d|_d|_g|_d|_d|_d|_dS)NÚr)r)Ú    chunkSizeÚ chunkOffsetÚerrorsÚ prevNumLinesÚ prevNumColsÚ_bufferedCharacterr6rrrrc¾szHTMLUnicodeInputStream.resetcCst|dƒr|}nt|ƒ}|S©zvProduces a file object from source.
 
        source can be either a file object, local filename or a string.
 
        r4)rMr    ©r$rQr!rrrraÌs
z!HTMLUnicodeInputStream.openStreamcCsT|j}| dd|¡}|j|}| dd|¡}|dkr@|j|}n ||d}||fS)NÚ
rrr )r)ÚcountrhÚrfindri)r$r-r)ÚnLinesÚ positionLineÚ lastLinePosÚpositionColumnrrrÚ    _positionÚs
  z HTMLUnicodeInputStream._positioncCs| |j¡\}}|d|fS)z:Returns (line, col) of the current position in the stream.r )rtrf)r$ÚlineÚcolrrrr#åszHTMLUnicodeInputStream.positioncCs6|j|jkr| ¡stS|j}|j|}|d|_|S)zo Read one character from the stream or queue if available. Return
            EOF when EOF is reached.
        r )rfreÚ    readChunkr r))r$rfÚcharrrrrxês 
 
zHTMLUnicodeInputStream.charNcCsê|dkr|j}| |j¡\|_|_d|_d|_d|_|j |¡}|j    rX|j    |}d|_    n|s`dSt
|ƒdkr®t |dƒ}|dks˜d|kr”dkr®nn|d|_    |dd…}|j r¾|  |¡|  d    d
¡}|  d d
¡}||_t
|ƒ|_d S) NrdrFr ré éØiÿÛz
rmú T)Ú_defaultChunkSizertrerhrir)rfrbr4rjr'Úordr[Úreplace)r$rer8Úlastvrrrrwùs0 
   
 
 
z HTMLUnicodeInputStream.readChunkcCs(ttt |¡ƒƒD]}|j d¡qdS)Núinvalid-codepoint)Úranger'Úinvalid_unicode_reÚfindallrgr7)r$r8Ú_rrrr\sz*HTMLUnicodeInputStream.characterErrorsUCS4cCs¶d}t |¡D]¢}|rqt| ¡ƒ}| ¡}t |||d…¡rrt |||d…¡}|tkrl|j     
d¡d}q|dkr |dkr |t |ƒdkr |j     
d¡qd}|j     
d¡qdS)NFér€Trziÿßr ) r‚Úfinditerr}ÚgroupÚstartrÚisSurrogatePairÚsurrogatePairToCodepointÚnon_bmp_invalid_codepointsrgr7r')r$r8ÚskipÚmatchÚ    codepointr(Úchar_valrrrr]#s"  ÿz*HTMLUnicodeInputStream.characterErrorsUCS2Fc
Cszt||f}Wnhtk
rx|D]}t|ƒdks$t‚q$d dd„|Dƒ¡}|sZd|}t d|¡}t||f<YnXg}| |j|j    ¡}|dkr¦|j    |j
krÖqøn0|  ¡}||j
krÖ|  |j|j    |…¡||_    qø|  |j|j    d…¡|  ¡s~qøq~d |¡}    |    S)zð Returns a string of characters from the stream up to but not
        including any character in 'characters' or EOF. 'characters' must be
        a container that supports the 'in' method and iteration over its
        characters.
        é€rdcSsg|]}dt|ƒ‘qS)z\x%02x)r})rÚcrrrrHsz5HTMLUnicodeInputStream.charsUntil.<locals>.<listcomp>z^%sz[%s]+N)ÚcharsUntilRegExÚKeyErrorr}r,r:ÚreÚcompilerr)rfreÚendr7rw)
r$Ú
charactersÚoppositeÚcharsr‘Úregexr<Úmr–ÚrrrrÚ
charsUntil:s0  
 
z!HTMLUnicodeInputStream.charsUntilcCsT|tk    rP|jdkr.||j|_|jd7_n"|jd8_|j|j|ksPt‚dSr&)r rfr)rer,)r$rxrrrÚungetis 
 zHTMLUnicodeInputStream.unget)N)F)rArBrCrDr|r%rcrartr#rxrwr\r]rržrrrrrO”s  
&
/rOc@sLeZdZdZddd„Zdd„Zd    d
„Zdd d „Zd d„Zdd„Z    dd„Z
dS)rPrVNú windows-1252TcCsn| |¡|_t ||j¡d|_d|_||_||_||_||_    ||_
|  |¡|_ |j ddk    sbt ‚| ¡dS)rWiédrN)raÚ    rawStreamrOr%Ú numBytesMetaÚnumBytesChardetÚoverride_encodingÚtransport_encodingÚsame_origin_parent_encodingÚlikely_encodingÚdefault_encodingÚdetermineEncodingr`r,rc)r$rQr¤r¥r¦r§r¨Ú
useChardetrrrr%‚s  zHTMLBinaryInputStream.__init__cCs&|jdj |jd¡|_t |¡dS)Nrr~)r`Ú
codec_infoÚ streamreaderr¡rbrOrcr6rrrrc¬szHTMLBinaryInputStream.resetcCsLt|dƒr|}nt|ƒ}z| | ¡¡Wntk
rFt|ƒ}YnX|Srk)rMrr/r*Ú    Exceptionr rlrrrra°s
z HTMLBinaryInputStream.openStreamcCsœ| ¡df}|ddk    r|St|jƒdf}|ddk    r:|St|jƒdf}|ddk    rX|S| ¡df}|ddk    rt|St|jƒdf}|ddk    r¢|dj d¡s¢|St|jƒdf}|ddk    rÀ|S|rpzddl    m
}Wnt k
rêYn†Xg}|ƒ}|j s<|j  |j¡}t|tƒst‚|s&q<| |¡| |¡qö| ¡t|jdƒ}|j  d¡|dk    rp|dfSt|jƒdf}|ddk    r|StdƒdfS)NrYrÚ    tentativezutf-16)ÚUniversalDetectorÚencodingrŸ)Ú    detectBOMr_r¤r¥ÚdetectEncodingMetar¦ÚnameÚ
startswithr§Ú%pip._vendor.chardet.universaldetectorr¯Ú ImportErrorÚdoner¡r4r£rHr3r,r7ÚfeedÚcloseÚresultr/r¨)r$Úchardetr`r¯ÚbuffersÚdetectorr"r°rrrr©ÃsR       
 
z'HTMLBinaryInputStream.determineEncodingcCsž|jddkst‚t|ƒ}|dkr&dS|jdkrFtdƒ}|dk    sšt‚nT||jdkrf|jddf|_n4|j d¡|df|_| ¡td|jd|fƒ‚dS)Nr rY©úutf-16beúutf-16lerXrzEncoding changed from %s to %s)r`r,r_r³r¡r/rcr)r$Ú newEncodingrrrÚchangeEncodings
 
z$HTMLBinaryInputStream.changeEncodingc
Csªtjdtjdtjdtjdtjdi}|j d¡}t|t    ƒs<t
‚|  |dd…¡}d}|s~|  |¡}d}|s~|  |dd    …¡}d    }|r–|j  |¡t |ƒS|j  d
¡dSdS) z©Attempts to detect at BOM at the start of the stream. If
        an encoding can be determined from the BOM return the name of the
        encoding otherwise return NonerXrÀr¿zutf-32lezutf-32beéNér…r)ÚcodecsÚBOM_UTF8Ú BOM_UTF16_LEÚ BOM_UTF16_BEÚ BOM_UTF32_LEÚ BOM_UTF32_BEr¡r4rHr3r,Úgetr/r_)r$ÚbomDictÚstringr°r/rrrr±s4ý 
  zHTMLBinaryInputStream.detectBOMcCsV|j |j¡}t|tƒst‚t|ƒ}|j d¡| ¡}|dk    rR|j    dkrRt
dƒ}|S)z9Report the encoding declared by the meta element
        rNr¾rX) r¡r4r¢rHr3r,ÚEncodingParserr/Ú getEncodingr³r_)r$r"Úparserr°rrrr²3s z(HTMLBinaryInputStream.detectEncodingMeta)NNNNrŸT)T) rArBrCrDr%rcrar©rÂr±r²rrrrrPzsþ
*
>"rPc@sŽeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z e e e
ƒZ dd„Ze eƒZefdd„Zdd„Zdd„Zdd„ZdS)Ú EncodingBytesz£String-like object with an associated position and various extra methods
    If the position is ever greater than the string length then an exception is
    raisedcCst|tƒst‚t || ¡¡S©N)rHr3r,Ú__new__Úlower©r$ÚvaluerrrrÓFszEncodingBytes.__new__cCs
d|_dS)Nr)rtrÕrrrr%JszEncodingBytes.__init__cCs|SrÒrr6rrrÚ__iter__NszEncodingBytes.__iter__cCs>|jd}|_|t|ƒkr"t‚n |dkr.t‚|||d…S)Nr r©rtr'Ú StopIterationrN©r$ÚprrrÚ__next__Qs  zEncodingBytes.__next__cCs| ¡SrÒ)rÜr6rrrÚnextYszEncodingBytes.nextcCsB|j}|t|ƒkrt‚n |dkr$t‚|d|_}|||d…Sr&rØrÚrrrÚprevious]s zEncodingBytes.previouscCs|jt|ƒkrt‚||_dSrÒ©rtr'rÙ)r$r#rrrÚ setPositionfszEncodingBytes.setPositioncCs*|jt|ƒkrt‚|jdkr"|jSdSdS)Nrrßr6rrrÚ getPositionks
 
zEncodingBytes.getPositioncCs||j|jd…S©Nr )r#r6rrrÚgetCurrentByteuszEncodingBytes.getCurrentBytecCsH|j}|t|ƒkr>|||d…}||kr4||_|S|d7}q||_dS)zSkip past a list of charactersr N©r#r'rt©r$r™rÛr‘rrrrŒzs 
zEncodingBytes.skipcCsH|j}|t|ƒkr>|||d…}||kr4||_|S|d7}q||_dSrârärårrrÚ    skipUntil†s 
zEncodingBytes.skipUntilcCs(| ||j¡}|r$|jt|ƒ7_|S)zÓLook for a sequence of bytes at the start of a string. If the bytes
        are found return True and advance the position to the byte after the
        match. Otherwise return False and leave the position alone)r´r#r')r$r3r<rrrÚ
matchBytes‘szEncodingBytes.matchBytescCs>z | ||j¡t|ƒd|_Wntk
r8t‚YnXdS)zLook for the next sequence of bytes matching a given sequence. If
        a match is found advance the position to the last byte of the matchr T)Úindexr#r'rtÚ
ValueErrorrÙr2rrrÚjumpTošs
 
zEncodingBytes.jumpToN)rArBrCrDrÓr%r×rÜrÝrÞràráÚpropertyr#rãÚ currentByteÚspaceCharactersBytesrŒrærçrêrrrrrÑBs     
      rÑc@sXeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z dd„Z dS)rÎz?Mini parser for detecting character encoding from meta elementscCst|ƒ|_d|_dS)z3string - the data to work on for encoding detectionN)rÑr8r°©r$r8rrrr%§s
zEncodingParser.__init__c
CsÖd|jkrdSd|jfd|jfd|jfd|jfd|jfd|jff}|jD]†}d}z|j d¡Wntk
rzYqÐYnX|D]D\}}|j |¡r€z|ƒ}WqÆWq€tk
rÂd}YqÆYq€Xq€|sHqÐqH|j    S)    Ns<metas<!--s</s<!s<?rTF)
r8Ú handleCommentÚ
handleMetaÚhandlePossibleEndTagÚ handleOtherÚhandlePossibleStartTagrêrÙrçr°)r$ÚmethodDispatchr„Ú keepParsingÚkeyÚmethodrrrrϬs4
ú
 
zEncodingParser.getEncodingcCs |j d¡S)zSkip over commentss-->©r8rêr6rrrrïÊszEncodingParser.handleCommentcCsà|jjtkrdSd}d}| ¡}|dkr,dS|ddkr\|ddk}|rÚ|dk    rÚ||_dSq|ddkrŒ|d}t|ƒ}|dk    rÚ||_dSq|ddkrtt|dƒƒ}| ¡}|dk    rt|ƒ}|dk    r|rÖ||_dS|}qdS)    NTFrs
http-equivr s content-typeócharsetscontent)    r8rìríÚ getAttributer°r_ÚContentAttrParserrÑÚparse)r$Ú    hasPragmaÚpendingEncodingÚattrÚtentativeEncodingÚcodecÚ contentParserrrrrðÎs8      zEncodingParser.handleMetacCs
| d¡S)NF)ÚhandlePossibleTagr6rrrróòsz%EncodingParser.handlePossibleStartTagcCst|jƒ| d¡S)NT)rÝr8rr6rrrrñõs
z#EncodingParser.handlePossibleEndTagcCsb|j}|jtkr(|r$| ¡| ¡dS| t¡}|dkrD| ¡n| ¡}|dk    r^| ¡}qLdS)NTr)r8rìÚasciiLettersBytesrÞròræÚspacesAngleBracketsrú)r$ÚendTagr8r‘rÿrrrrùs
 
 
 
z EncodingParser.handlePossibleTagcCs |j d¡S)Nrrør6rrrròszEncodingParser.handleOthercCsô|j}| ttdgƒB¡}|dks2t|ƒdks2t‚|dkr>dSg}g}|dkrV|rVq¸nX|tkrj| ¡}q¸nD|dkr€d |¡dfS|tkr˜| |     ¡¡n|dkr¤dS| |¡t
|ƒ}qF|dkrÖ|  ¡d |¡dfSt
|ƒ| ¡}|dkrJ|}t
|ƒ}||kr"t
|ƒd |¡d |¡fS|tkr<| |     ¡¡qô| |¡qônJ|d    krbd |¡dfS|tkr|| |     ¡¡n|dkrŠdS| |¡t
|ƒ}|t krºd |¡d |¡fS|tkrÔ| |     ¡¡n|dkrâdS| |¡q”dS)
z_Return a name,value pair for the next attribute in the stream,
        if one is found, or Noneó/Nr )rNó=)rrr9)ó'ó"r) r8rŒríÚ    frozensetr'r,r:ÚasciiUppercaseBytesr7rÔrÝrÞr)r$r8r‘ÚattrNameÚ    attrValueÚ    quoteCharrrrrúsb 
 
 
 
 
 
 
 
 
 
 
 
zEncodingParser.getAttributeN) rArBrCrDr%rÏrïrðrórñrròrúrrrrrΤs$rÎc@seZdZdd„Zdd„ZdS)rûcCst|tƒst‚||_dSrÒ)rHr3r,r8rîrrrr%aszContentAttrParser.__init__cCszü|j d¡|jjd7_|j ¡|jjdks<WdS|jjd7_|j ¡|jjdkrª|jj}|jjd7_|jj}|j |¡r¢|j||jj…WSWdSnR|jj}z"|j t¡|j||jj…WWStk
rú|j|d…YWSXWntk
rYdSXdS)Nrùr r)r
r    )r8rêr#rŒrìrærírÙ)r$Ú    quoteMarkÚ oldPositionrrrrües. 
 
   zContentAttrParser.parseN)rArBrCr%rürrrrrû`srûcCsft|tƒr0z| d¡}Wntk
r.YdSX|dk    r^z t |¡WStk
rZYdSXndSdS)z{Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding.rN)rHr3ÚdecodeÚUnicodeDecodeErrorr
ÚlookupÚAttributeError)r°rrrr_‡s
 
r_)1Ú
__future__rrrZpip._vendor.sixrÚpip._vendor.six.movesrrrÅr”Úiorr    Ú pip._vendorr
Ú    constantsr r rrrrdrr rírr rÚinvalid_unicode_no_surrogaterZrnr,r•Úevalr‚r‹Úascii_punctuation_rer’Úobjectr rUrOrPr3rÑrÎrûr_rrrrÚ<module>s€    ÿþ
 
ú
JgIb='