JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/pip/_vendor/html5lib/__pycache__/_inputstream.cpython-39.pyc

a

[��fa~�@s�ddlmZmZmZddlmZddlmZmZddl	Z	ddl
Z
ddlmZm
Z
ddlmZddlmZmZmZmZdd	lmZdd
lmZedd�eD��Zed
d�eD��Zedd�eD��Zeeddg�BZdZej�reddkr�e�d�dks�J�e
� edd�e!d�d�Z"n
e
� e�Z"hd�Z#e
� d�Z$iZ%Gdd�de&�Z'dd�Z(Gdd�de&�Z)Gdd�de)�Z*Gdd �d e+�Z,Gd!d"�d"e&�Z-Gd#d$�d$e&�Z.d%d&�Z/dS)'�)�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�E/usr/lib/python3.9/site-packages/pip/_vendor/html5lib/_inputstream.py�
<listcomp>�rcCsg|]}|�d��qSrrrrrrrrcCsg|]}|�d��qSrrrrrrrr�>�<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||��ksJ�|}d}t|j|�|krF|t|j|�8}|d7}q||g|_dSr')�_bufferedBytesr(r#r$)r%r)�offset�irrr�seekFs
zBufferedStream.seekcCsT|js|�|�S|jdt|j�krF|jdt|jd�krF|�|�S|�|�SdS)Nrrr)r#�_readStreamr$r(�_readFromBuffer�r%�bytesrrr�readOs
�
zBufferedStream.readcCstdd�|jD��S)NcSsg|]}t|��qSr)r(rrrrrYrz1BufferedStream._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>J�|j|}|t|�|krl|}|||g|_n"t|�|}|t|�g|_|d7}|�||||��||8}d}q|r�|�|�|��d�|�S)Nrrr)r$r(r#r7r0�join)r%r3ZremainingBytes�rvZbufferIndexZbufferOffsetZbufferedDataZbytesToReadrrrr1bs&


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|fi|��St|fi|��SdS)NFr4rcSsg|]}|�d�r|�qS)�	_encoding)�endswith)r�xrrrr�rz#HTMLInputStream.<locals>.<listcomp>z3Cannot set an encoding with a unicode input, set %r)
�
isinstancerZHTTPResponserZresponseZaddbase�fp�hasattrr4r�	TypeError�HTMLUnicodeInputStream�HTMLBinaryInputStream)�source�kwargsZ	isUnicode�	encodingsrrr�HTMLInputStream}s��

rKc@speZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
ddd�Zdd�Zdd�Z
ddd�Zdd�ZdS)rF��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􏿿rr�utf-8�certain)r�supports_lone_surrogates�reportCharacterErrorsr(�characterErrorsUCS4�characterErrorsUCS2ZnewLines�lookupEncoding�charEncoding�
openStream�
dataStream�reset)r%rHrrrr&�s
zHTMLUnicodeInputStream.__init__cCs.d|_d|_d|_g|_d|_d|_d|_dS)N�r)r*�	chunkSize�chunkOffset�errors�prevNumLines�prevNumCols�_bufferedCharacterr6rrrrX�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)rDr	�r%rHr"rrrrV�s
z!HTMLUnicodeInputStream.openStreamcCsT|j}|�dd|�}|j|}|�dd|�}|dkr@|j|}n||d}||fS)N�
rrr)r*�countr]�rfindr^)r%r-r*ZnLinesZpositionLineZlastLinePosZpositionColumnrrr�	_position�s
z HTMLUnicodeInputStream._positioncCs|�|j�\}}|d|fS)z:Returns (line, col) of the current position in the stream.r)rer[)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)r[rZ�	readChunkrr*)r%r[�charrrrri�s

zHTMLUnicodeInputStream.charNcCs�|dur|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
�}|�
dd
�}||_t
|�|_dS)
NrYrFrr�
��i��z
rb�
T)�_defaultChunkSizererZr]r^r*r[rWr4r_r(�ordrQ�replace)r%rZr8Zlastvrrrrh�s0
 


z HTMLUnicodeInputStream.readChunkcCs(ttt�|���D]}|j�d�qdS)N�invalid-codepoint)�ranger(�invalid_unicode_re�findallr\r7)r%r8�_rrrrRsz*HTMLUnicodeInputStream.characterErrorsUCS4cCs�d}t�|�D]�}|rqt|���}|��}t�|||d��rrt�|||d��}|tvrl|j	�
d�d}q|dkr�|dkr�|t|�dkr�|j	�
d�qd}|j	�
d�qdS)NF�rpTrki��r)rr�finditerrn�group�startrZisSurrogatePairZsurrogatePairToCodepoint�non_bmp_invalid_codepointsr\r7r()r%r8�skip�matchZ	codepointr)Zchar_valrrrrS#s"�z*HTMLUnicodeInputStream.characterErrorsUCS2Fc
Cszt||f}Wnftyv|D]}t|�dks"J�q"d�dd�|D��}|sXd|}t�d|�}t||f<Yn0g}|�|j|j�}|dur�|j|j	kr�q�n0|�
�}||j	kr�|�|j|j|��||_q�|�|j|jd��|��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.
        �rYcSsg|]}dt|��qS)z\x%02x)rn)r�crrrrHrz5HTMLUnicodeInputStream.charsUntil.<locals>.<listcomp>z^%sz[%s]+N)
�charsUntilRegEx�KeyErrorrnr9�re�compiler{r*r[rZ�endr7rh)
r%Z
charactersZopposite�charsr}Zregexr:�mr��rrrr�
charsUntil:s0 

z!HTMLUnicodeInputStream.charsUntilcCsT|turP|jdkr.||j|_|jd7_n"|jd8_|j|j|ksPJ�dSr')rr[r*rZ)r%rirrr�ungetis
zHTMLUnicodeInputStream.unget)N)F)r;r<r=r>rmr&rXrVrer$rirhrRrSr�r�rrrrrF�s 
&
/rFc@sLeZdZdZddd�Zdd�Zd	d
�Zddd�Zd
d�Zdd�Z	dd�Z
dS)rGrLN�windows-1252TcCsn|�|�|_t�||j�d|_d|_||_||_||_||_	||_
|�|�|_|jddusbJ�|�
�dS)rMi�drN)rV�	rawStreamrFr&�numBytesMeta�numBytesChardet�override_encoding�transport_encoding�same_origin_parent_encoding�likely_encoding�default_encoding�determineEncodingrUrX)r%rHr�r�r�r�r�Z
useChardetrrrr&�szHTMLBinaryInputStream.__init__cCs&|jdj�|jd�|_t�|�dS)Nrro)rUZ
codec_info�streamreaderr�rWrFrXr6rrrrX�szHTMLBinaryInputStream.resetcCsJt|d�r|}nt|�}z|�|���WntyDt|�}Yn0|Sr`)rDrr/r+�	Exceptionr!rarrrrV�s
z HTMLBinaryInputStream.openStreamcCs�|��df}|ddur|St|j�df}|ddur:|St|j�df}|ddurX|S|��df}|ddurt|St|j�df}|ddur�|dj�d�s�|St|j�df}|ddur�|S|�rnzddl	m
}Wnty�Yn�0g}|�}|j�s:|j
�|j�}t|t��sJ�|�s$�q:|�|�|�|�q�|��t|jd�}|j
�d�|du�rn|dfSt|j�df}|ddu�r�|Std�dfS)NrOrZ	tentativezutf-16)�UniversalDetector�encodingr�)�	detectBOMrTr�r��detectEncodingMetar��name�
startswithr�Z%pip._vendor.chardet.universaldetectorr��ImportErrorZdoner�r4r�rBr3r7Zfeed�close�resultr/r�)r%ZchardetrUr�ZbuffersZdetectorr#r�rrrr��sR

z'HTMLBinaryInputStream.determineEncodingcCs�|jddksJ�t|�}|dur&dS|jdvrFtd�}|dus�J�nT||jdkrf|jddf|_n4|j�d�|df|_|��td|jd|f��dS)NrrO��utf-16be�utf-16lerNrzEncoding changed from %s to %s)rUrTr�r�r/rXr)r%ZnewEncodingrrr�changeEncodings

z$HTMLBinaryInputStream.changeEncodingc
Cs�tjdtjdtjdtjdtjdi}|j�d�}t|t	�s<J�|�
|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 NonerNr�r�zutf-32lezutf-32be�N�rur)
�codecs�BOM_UTF8�BOM_UTF16_LE�BOM_UTF16_BE�BOM_UTF32_LE�BOM_UTF32_BEr�r4rBr3�getr/rT)r%ZbomDict�stringr�r/rrrr�s&�
zHTMLBinaryInputStream.detectBOMcCsV|j�|j�}t|t�sJ�t|�}|j�d�|��}|durR|jdvrRt	d�}|S)z9Report the encoding declared by the meta element
        rNr�rN)
r�r4r�rBr3�EncodingParserr/�getEncodingr�rT)r%r#�parserr�rrrr�3sz(HTMLBinaryInputStream.detectEncodingMeta)NNNNr�T)T)r;r<r=r>r&rXrVr�r�r�r�rrrrrGzs�
*
>"rGc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zeee
�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�sJ�t�||���S�N)rBr3�__new__�lower�r%�valuerrrr�FszEncodingBytes.__new__cCs
d|_dS)Nr)rer�rrrr&JszEncodingBytes.__init__cCs|Sr�rr6rrr�__iter__NszEncodingBytes.__iter__cCs>|jd}|_|t|�kr"t�n|dkr.t�|||d�S)Nrr�rer(�
StopIterationrE�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��rer(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�}||vr4||_|S|d7}q||_dS)zSkip past a list of charactersrN�r$r(re�r%r�r�r}rrrrzzs
zEncodingBytes.skipcCsH|j}|t|�kr>|||d�}||vr4||_|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|_Wnty6t�Yn0dS)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 matchrT)�indexr$r(re�
ValueErrorr�r2rrr�jumpTo�s
 
zEncodingBytes.jumpToN)r;r<r=r>r�r&r�r�r�r�r�r��propertyr$r��currentByte�spaceCharactersBytesrzr�r�r�rrrrr�Bs 	
	r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�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|jvrdSd|jfd|jfd|jfd|jfd|jfd|jff}|jD]�}d}z|j�d�WntyxYq�Yn0|D]B\}}|j�|�r~z|�}Wq�Wq~ty�d}Yq�Yq~0q~|sHq�qH|j	S)	Ns<metas<!--s</s<!s<?rTF)
r8�
handleComment�
handleMeta�handlePossibleEndTag�handleOther�handlePossibleStartTagr�r�r�r�)r%ZmethodDispatchrtZkeepParsing�key�methodrrrr��s4
�

zEncodingParser.getEncodingcCs|j�d�S)zSkip over commentss-->�r8r�r6rrrr��szEncodingParser.handleCommentcCs�|jjtvrdSd}d}|��}|dur,dS|ddkr\|ddk}|r�|dur�||_dSq|ddkr�|d}t|�}|dur�||_dSq|ddkrtt|d��}|��}|durt|�}|dur|r�||_dS|}qdS)	NTFrs
http-equivrscontent-type�charsetscontent)	r8r�r��getAttributer�rT�ContentAttrParserr��parse)r%Z	hasPragmaZpendingEncoding�attrZtentativeEncoding�codecZ
contentParserrrrr��s8zEncodingParser.handleMetacCs
|�d�S)NF)�handlePossibleTagr6rrrr��sz%EncodingParser.handlePossibleStartTagcCst|j�|�d�S)NT)r�r8r�r6rrrr��s
z#EncodingParser.handlePossibleEndTagcCsb|j}|jtvr(|r$|��|��dS|�t�}|dkrD|��n|��}|dur^|��}qLdS)NTr)r8r��asciiLettersBytesr�r�r��spacesAngleBracketsr�)r%ZendTagr8r}r�rrrr��s



z EncodingParser.handlePossibleTagcCs|j�d�S)Nrr�r6rrrr�szEncodingParser.handleOthercCs�|j}|�ttdg�B�}|dus2t|�dks2J�|dvr>dSg}g}|dkrV|rVq�nX|tvrj|��}q�nD|dvr�d�|�dfS|tvr�|�|���n|dur�dS|�|�t	|�}qF|dkr�|�
�d�|�dfSt	|�|��}|dv�rJ|}t	|�}||k�r"t	|�d�|�d�|�fS|tv�r<|�|���q�|�|�q�nJ|d	k�rbd�|�dfS|tv�r||�|���n|du�r�dS|�|�t	|�}|tv�r�d�|�d�|�fS|tv�r�|�|���n|du�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�=)r�rr)�'�"r)r8rzr��	frozensetr(r9�asciiUppercaseBytesr7r�r�r�r�)r%r8r}ZattrNameZ	attrValueZ	quoteCharrrrr�sb











zEncodingParser.getAttributeN)
r;r<r=r>r&r�r�r�r�r�r�r�r�rrrrr��s$r�c@seZdZdd�Zdd�ZdS)r�cCst|t�sJ�||_dSr�)rBr3r8r�rrrr&aszContentAttrParser.__init__cCs�z�|j�d�|jjd7_|j��|jjdks<WdS|jjd7_|j��|jjdvr�|jj}|jjd7_|jj}|j�|�r�|j||jj�WSWdSnP|jj}z"|j�t�|j||jj�WWSt�y�|j|d�YWS0Wnt�yYdS0dS)Nr�rr�)r�r�)r8r�r$rzr�r�r�r�)r%Z	quoteMarkZoldPositionrrrr�es.

zContentAttrParser.parseN)r;r<r=r&r�rrrrr�`sr�cCsbt|t�r.z|�d�}Wnty,YdS0|durZzt�|�WStyVYdS0ndSdS)z{Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding.rN)rBr3�decode�UnicodeDecodeErrorr
�lookup�AttributeError)r�rrrrT�s

rT)0Z
__future__rrrZpip._vendor.sixrZpip._vendor.six.movesrrr�r��iorr	Zpip._vendorr
Z	constantsrr
rrrrYrr�r�r�r�r�Zinvalid_unicode_no_surrogaterPrcr��evalrrryZascii_punctuation_rer~�objectr!rKrFrGr3r�r�r�rTrrrr�<module>sH��

JgIb='
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg!%5MmZ/c-{1_Je"|^$'O&ޱմTrb$w)R$& N1EtdU3Uȉ1pM"N*(DNyd96.(jQ)X 5cQɎMyW?Q*!R>6=7)Xj5`J]e8%t!+'!1Q5 !1 AQaqё#2"0BRb?Gt^## .llQT $v,,m㵜5ubV =sY+@d{N! dnO<.-B;_wJt6;QJd.Qc%p{ 1,sNDdFHI0ГoXшe黅XۢF:)[FGXƹ/w_cMeD,ʡcc.WDtA$j@:) -# u c1<@ۗ9F)KJ-hpP]_x[qBlbpʖw q"LFGdƶ*s+ډ_Zc"?%t[IP 6J]#=ɺVvvCGsGh1 >)6|ey?Lӣm,4GWUi`]uJVoVDG< SB6ϏQ@ TiUlyOU0kfV~~}SZ@*WUUi##; s/[=!7}"WN]'(L! ~y5g9T̅JkbM' +s:S +B)v@Mj e Cf jE 0Y\QnzG1д~Wo{T9?`Rmyhsy3!HAD]mc1~2LSu7xT;j$`}4->L#vzŏILS ֭T{rjGKC;bpU=-`BsK.SFw4Mq]ZdHS0)tLg