a
    hbòfa~  ã                   @   s°  d dl mZmZmZ d dlmZ d dlmZmZ d dl	Z	d dl
Z
d dlmZmZ d dlmZ ddlmZmZmZmZ dd	lmZ dd
lmZ edd„ eD ƒƒZedd„ eD ƒƒZedd„ eD ƒƒZeeddgƒB ZdZej�red dkrøe d¡dksüJ ‚e
  edd… e!dƒ d ¡Z"n
e
  e¡Z"h d£Z#e
  d¡Z$i Z%G dd„ de&ƒZ'dd„ Z(G dd„ de&ƒZ)G dd„ de)ƒZ*G dd „ d e+ƒZ,G d!d"„ d"e&ƒZ-G d#d$„ d$e&ƒZ.d%d&„ Z/dS )'é    )Úabsolute_importÚdivisionÚunicode_literals)Ú	text_type)Úhttp_clientÚurllibN)ÚBytesIOÚStringIO)Úwebencodingsé   )ÚEOFÚspaceCharactersÚasciiLettersÚasciiUppercase)Ú_ReparseException)Ú_utilsc                 C   s   g | ]}|  d ¡‘qS ©Úascii©Úencode©Ú.0Úitem© r   ú^/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pip/_vendor/html5lib/_inputstream.pyÚ
<listcomp>   ó    r   c                 C   s   g | ]}|  d ¡‘qS r   r   r   r   r   r   r      r   c                 C   s   g | ]}|  d ¡‘qS r   r   r   r   r   r   r      r   ó   >ó   <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                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )Ú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)
    c                 C   s   || _ g | _ddg| _d S )Nr   r   )ÚstreamÚbufferÚposition)Úselfr"   r   r   r   Ú__init__:   s    zBufferedStream.__init__c                 C   s<   d}| j d | jd … D ]}|t|ƒ7 }q|| jd 7 }|S ©Nr   r   )r#   r$   Úlen)r%   ÚposÚchunkr   r   r   Útell?   s
    zBufferedStream.tellc                 C   sT   ||   ¡ ksJ ‚|}d}t| j| ƒ|k rF|t| j| ƒ8 }|d7 }q||g| _d S r'   )Ú_bufferedBytesr(   r#   r$   )r%   r)   ÚoffsetÚir   r   r   ÚseekF   s    
zBufferedStream.seekc                 C   sT   | j s|  |¡S | jd t| j ƒkrF| jd t| j d ƒkrF|  |¡S |  |¡S d S )Nr   r   r   )r#   Ú_readStreamr$   r(   Ú_readFromBuffer©r%   Úbytesr   r   r   ÚreadO   s    
ÿ
zBufferedStream.readc                 C   s   t dd„ | jD ƒƒS )Nc                 S   s   g | ]}t |ƒ‘qS r   )r(   r   r   r   r   r   Y   r   z1BufferedStream._bufferedBytes.<locals>.<listcomp>)Úsumr#   ©r%   r   r   r   r,   X   s    zBufferedStream._bufferedBytesc                 C   s<   | j  |¡}| j |¡ | jd  d7  < t|ƒ| jd< |S r'   )r"   r4   r#   Úappendr$   r(   )r%   r3   Údatar   r   r   r0   [   s
    zBufferedStream._readStreamc                 C   sÐ   |}g }| j d }| j d }|t| jƒk r²|dkr²|dks>J ‚| j| }|t|ƒ| krl|}||| g| _ n"t|ƒ| }|t|ƒg| _ |d7 }| |||| … ¡ ||8 }d}q|rÆ| |  |¡¡ d |¡S )Nr   r   r   )r$   r(   r#   r7   r0   Újoin)r%   r3   ÚremainingBytesÚrvÚbufferIndexÚbufferOffsetÚbufferedDataÚbytesToReadr   r   r   r1   b   s&    


zBufferedStream._readFromBufferN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r+   r/   r4   r,   r0   r1   r   r   r   r   r!   3   s   		r!   c                 K   sš   t | tjƒs(t | tjjƒr.t | jtjƒr.d}n&t| dƒrJt |  d¡t	ƒ}n
t | t	ƒ}|r†dd„ |D ƒ}|rvt
d| ƒ‚t| fi |¤ŽS t| fi |¤ŽS d S )NFr4   r   c                 S   s   g | ]}|  d ¡r|‘qS )Ú	_encoding)Úendswith)r   Úxr   r   r   r   ‹   r   z#HTMLInputStream.<locals>.<listcomp>z3Cannot set an encoding with a unicode input, set %r)Ú
isinstancer   ÚHTTPResponser   ÚresponseÚaddbaseÚfpÚhasattrr4   r   Ú	TypeErrorÚHTMLUnicodeInputStreamÚHTMLBinaryInputStream)ÚsourceÚkwargsÚ	isUnicodeÚ	encodingsr   r   r   ÚHTMLInputStream}   s    þý

rT   c                   @   sp   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
ddd„Zdd„ Zdd„ Zddd„Zdd„ ZdS )rN   ú×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 (  c                 C   sZ   t jsd| _ntdƒdkr$| j| _n| j| _dg| _tdƒdf| _|  	|¡| _
|  ¡  dS )á¿  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%   rP   r   r   r   r&   ž   s    
zHTMLUnicodeInputStream.__init__c                 C   s.   d| _ d| _d| _g | _d| _d| _d | _d S )NÚ r   )r*   Ú	chunkSizeÚchunkOffsetÚerrorsÚprevNumLinesÚprevNumColsÚ_bufferedCharacterr6   r   r   r   rb   ¾   s    zHTMLUnicodeInputStream.resetc                 C   s   t |dƒr|}nt|ƒ}|S ©zvProduces a file object from source.

        source can be either a file object, local filename or a string.

        r4   )rL   r	   ©r%   rP   r"   r   r   r   r`   Ì   s    
z!HTMLUnicodeInputStream.openStreamc                 C   sT   | j }| dd|¡}| j| }| dd|¡}|dkr@| j| }n||d  }||fS )NÚ
r   r   r   )r*   Úcountrg   Úrfindrh   )r%   r-   r*   ÚnLinesÚpositionLineÚlastLinePosÚpositionColumnr   r   r   Ú	_positionÚ   s    
z HTMLUnicodeInputStream._positionc                 C   s   |   | j¡\}}|d |fS )z:Returns (line, col) of the current position in the stream.r   )rs   re   )r%   ÚlineÚcolr   r   r   r$   å   s    zHTMLUnicodeInputStream.positionc                 C   s6   | j | jkr|  ¡ stS | j }| j| }|d | _ |S )zo Read one character from the stream or queue if available. Return
            EOF when EOF is reached.
        r   )re   rd   Ú	readChunkr   r*   )r%   re   Úcharr   r   r   rw   ê   s    

zHTMLUnicodeInputStream.charNc                 C   sê   |d u r| j }|  | j¡\| _| _d| _d| _d| _| j |¡}| j	rX| j	| }d | _	n|s`dS t
|ƒdkr®t|d ƒ}|dks˜d|  kr”dkr®n n|d | _	|d d… }| jr¾|  |¡ | d	d
¡}| dd
¡}|| _t
|ƒ| _dS )Nrc   r   Fr   r   é   é Ø  iÿÛ  z
rl   úT)Ú_defaultChunkSizers   rd   rg   rh   r*   re   ra   r4   ri   r(   ÚordrZ   Úreplace)r%   rd   r8   Úlastvr   r   r   rv   ù   s0    
 


z HTMLUnicodeInputStream.readChunkc                 C   s(   t tt |¡ƒƒD ]}| j d¡ qd S )Núinvalid-codepoint)Úranger(   Úinvalid_unicode_reÚfindallrf   r7   )r%   r8   Ú_r   r   r   r[     s    z*HTMLUnicodeInputStream.characterErrorsUCS4c                 C   s¶   d}t  |¡D ]¢}|rqt| ¡ ƒ}| ¡ }t |||d … ¡rrt |||d … ¡}|tv rl| j	 
d¡ d}q|dkr |dkr |t|ƒd kr | j	 
d¡ qd}| j	 
d¡ qd S )NFé   r   Try   iÿß  r   )r�   Úfinditerr|   ÚgroupÚstartr   ÚisSurrogatePairÚsurrogatePairToCodepointÚnon_bmp_invalid_codepointsrf   r7   r(   )r%   r8   ÚskipÚmatchÚ	codepointr)   Úchar_valr   r   r   r\   #  s"    ÿz*HTMLUnicodeInputStream.characterErrorsUCS2Fc           
      C   s  zt ||f }W nf tyv   |D ]}t|ƒdk s"J ‚q"d dd„ |D ƒ¡}|sXd| }t d| ¡ }t ||f< Y n0 g }| | j| j¡}|du r¤| j| j	krÔqön0| 
¡ }|| j	krÔ| | 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.
        é€   rc   c                 S   s   g | ]}d t |ƒ ‘qS )z\x%02x)r|   )r   Úcr   r   r   r   H  r   z5HTMLUnicodeInputStream.charsUntil.<locals>.<listcomp>z^%sz[%s]+N)ÚcharsUntilRegExÚKeyErrorr|   r9   ÚreÚcompilerŒ   r*   re   rd   Úendr7   rv   )
r%   Ú
charactersÚoppositeÚcharsr�   Úregexr;   Úmr•   Úrr   r   r   Ú
charsUntil:  s0     

z!HTMLUnicodeInputStream.charsUntilc                 C   sT   |t urP| jdkr.|| j | _|  jd7  _n"|  jd8  _| j| j |ksPJ ‚d S r'   )r   re   r*   rd   )r%   rw   r   r   r   Úungeti  s    
zHTMLUnicodeInputStream.unget)N)F)r@   rA   rB   rC   r{   r&   rb   r`   rs   r$   rw   rv   r[   r\   rœ   r�   r   r   r   r   rN   ”   s    
&
/rN   c                   @   sL   e Zd ZdZddd„Zdd„ Zd	d
„ Zddd„Zdd„ Zdd„ Z	dd„ Z
dS )rO   rU   Núwindows-1252Tc                 C   sn   |   |¡| _t | | j¡ d| _d| _|| _|| _|| _|| _	|| _
|  |¡| _| jd dusbJ ‚|  ¡  dS )rV   i   éd   r   N)r`   Ú	rawStreamrN   r&   ÚnumBytesMetaÚnumBytesChardetÚoverride_encodingÚtransport_encodingÚsame_origin_parent_encodingÚlikely_encodingÚdefault_encodingÚdetermineEncodingr_   rb   )r%   rP   r£   r¤   r¥   r¦   r§   Ú
useChardetr   r   r   r&   ‚  s    zHTMLBinaryInputStream.__init__c                 C   s&   | j d j | jd¡| _t | ¡ d S )Nr   r}   )r_   Ú
codec_infoÚstreamreaderr    ra   rN   rb   r6   r   r   r   rb   ¬  s    zHTMLBinaryInputStream.resetc                 C   sJ   t |dƒr|}nt|ƒ}z| | ¡ ¡ W n tyD   t|ƒ}Y n0 |S rj   )rL   r   r/   r+   Ú	Exceptionr!   rk   r   r   r   r`   °  s    
z HTMLBinaryInputStream.openStreamc                 C   sš  |   ¡ df}|d d ur|S t| jƒdf}|d d ur:|S t| jƒdf}|d d urX|S |  ¡ df}|d d urt|S t| jƒdf}|d d ur¢|d j d¡s¢|S t| jƒdf}|d d urÀ|S |�rnzddl	m
} W n tyè   Y n†0 g }|ƒ }|j�s:| j | j¡}t|tƒ�sJ ‚|�s$�q:| |¡ | |¡ qô| ¡  t|jd ƒ}| j d¡ |d u�rn|dfS t| jƒdf}|d d u�rŽ|S tdƒdfS )NrX   r   Ú	tentativezutf-16)ÚUniversalDetectorÚencodingrž   )Ú	detectBOMr^   r£   r¤   ÚdetectEncodingMetar¥   ÚnameÚ
startswithr¦   Ú%pip._vendor.chardet.universaldetectorr®   ÚImportErrorÚdoner    r4   r¢   rG   r3   r7   ÚfeedÚcloseÚresultr/   r§   )r%   Úchardetr_   r®   ÚbuffersÚdetectorr#   r¯   r   r   r   r¨   Ã  sR    

z'HTMLBinaryInputStream.determineEncodingc                 C   sž   | j d dksJ ‚t|ƒ}|d u r&d S |jdv rFtdƒ}|d usšJ ‚nT|| j d krf| j d df| _ n4| j d¡ |df| _ |  ¡  td| j d |f ƒ‚d S )Nr   rX   ©úutf-16beúutf-16lerW   r   zEncoding changed from %s to %s)r_   r^   r²   r    r/   rb   r   )r%   ÚnewEncodingr   r   r   ÚchangeEncoding  s    

z$HTMLBinaryInputStream.changeEncodingc              
   C   sª   t jdt jdt jdt jdt jdi}| j d¡}t|t	ƒs<J ‚| 
|dd… ¡}d}|s~| 
|¡}d}|s~| 
|dd	… ¡}d	}|r–| j |¡ t|ƒS | j d
¡ dS dS )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 NonerW   r¿   r¾   zutf-32lezutf-32beé   Né   r„   r   )ÚcodecsÚBOM_UTF8ÚBOM_UTF16_LEÚBOM_UTF16_BEÚBOM_UTF32_LEÚBOM_UTF32_BEr    r4   rG   r3   Úgetr/   r^   )r%   ÚbomDictÚstringr¯   r/   r   r   r   r°     s&    ý
zHTMLBinaryInputStream.detectBOMc                 C   sV   | j  | j¡}t|tƒsJ ‚t|ƒ}| j  d¡ | ¡ }|durR|jdv rRt	dƒ}|S )z9Report the encoding declared by the meta element
        r   Nr½   rW   )
r    r4   r¡   rG   r3   ÚEncodingParserr/   ÚgetEncodingr²   r^   )r%   r#   Úparserr¯   r   r   r   r±   3  s    z(HTMLBinaryInputStream.detectEncodingMeta)NNNNrž   T)T)r@   rA   rB   rC   r&   rb   r`   r¨   rÁ   r°   r±   r   r   r   r   rO   z  s      þ
*
>"rO   c                   @   sŽ   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zeee
ƒZdd„ ZeeƒZefdd„Zdd„ Zdd„ Zdd„ ZdS )Ú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
    raisedc                 C   s   t |tƒsJ ‚t | | ¡ ¡S ©N)rG   r3   Ú__new__Úlower©r%   Úvaluer   r   r   rÒ   F  s    zEncodingBytes.__new__c                 C   s
   d| _ d S )Nr   )rs   rÔ   r   r   r   r&   J  s    zEncodingBytes.__init__c                 C   s   | S rÑ   r   r6   r   r   r   Ú__iter__N  s    zEncodingBytes.__iter__c                 C   s>   | j d  }| _ |t| ƒkr"t‚n|dk r.t‚| ||d … S )Nr   r   ©rs   r(   ÚStopIterationrM   ©r%   Úpr   r   r   Ú__next__Q  s    zEncodingBytes.__next__c                 C   s   |   ¡ S rÑ   )rÛ   r6   r   r   r   ÚnextY  s    zEncodingBytes.nextc                 C   sB   | j }|t| ƒkrt‚n|dk r$t‚|d  | _ }| ||d … S r'   r×   rÙ   r   r   r   Úprevious]  s    zEncodingBytes.previousc                 C   s   | j t| ƒkrt‚|| _ d S rÑ   ©rs   r(   rØ   )r%   r$   r   r   r   ÚsetPositionf  s    zEncodingBytes.setPositionc                 C   s*   | j t| ƒkrt‚| j dkr"| j S d S d S )Nr   rÞ   r6   r   r   r   ÚgetPositionk  s
    
zEncodingBytes.getPositionc                 C   s   | | j | j d … S ©Nr   )r$   r6   r   r   r   ÚgetCurrentByteu  s    zEncodingBytes.getCurrentBytec                 C   sH   | j }|t| ƒk r>| ||d … }||vr4|| _|S |d7 }q|| _dS )zSkip past a list of charactersr   N©r$   r(   rs   ©r%   r˜   rÚ   r�   r   r   r   r‹   z  s    
zEncodingBytes.skipc                 C   sH   | j }|t| ƒk r>| ||d … }||v r4|| _|S |d7 }q|| _d S rá   rã   rä   r   r   r   Ú	skipUntil†  s    
zEncodingBytes.skipUntilc                 C   s(   |   || j¡}|r$|  jt|ƒ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%   r3   r;   r   r   r   Ú
matchBytes‘  s    zEncodingBytes.matchBytesc                 C   s<   z |   || j¡t|ƒ d | _W n ty6   t‚Y n0 dS )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(   rs   Ú
ValueErrorrØ   r2   r   r   r   ÚjumpToš  s
     
zEncodingBytes.jumpToN)r@   rA   rB   rC   rÒ   r&   rÖ   rÛ   rÜ   rÝ   rß   rà   Úpropertyr$   râ   ÚcurrentByteÚspaceCharactersBytesr‹   rå   ræ   ré   r   r   r   r   rÐ   B  s    	
	rÐ   c                   @   sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )rÍ   z?Mini parser for detecting character encoding from meta elementsc                 C   s   t |ƒ| _d| _dS )z3string - the data to work on for encoding detectionN)rÐ   r8   r¯   ©r%   r8   r   r   r   r&   §  s    
zEncodingParser.__init__c              
   C   sÒ   d| j vrd S d| jfd| jfd| jfd| jfd| jfd| jff}| j D ]‚}d}z| j  d¡ W n tyx   Y  qÌY n0 |D ]B\}}| j  |¡r~z|ƒ }W  qÂW q~ ty¾   d}Y  qÂY q~0 q~|sH qÌqH| j	S )	Ns   <metas   <!--s   </s   <!s   <?r   TF)
r8   ÚhandleCommentÚ
handleMetaÚhandlePossibleEndTagÚhandleOtherÚhandlePossibleStartTagré   rØ   ræ   r¯   )r%   ÚmethodDispatchrƒ   ÚkeepParsingÚkeyÚmethodr   r   r   rÎ   ¬  s4    
ú

zEncodingParser.getEncodingc                 C   s   | j  d¡S )zSkip over commentss   -->©r8   ré   r6   r   r   r   rî   Ê  s    zEncodingParser.handleCommentc                 C   sà   | j jtvrdS d}d }|  ¡ }|d u r,dS |d dkr\|d dk}|rÚ|d urÚ|| _dS q|d dkrŒ|d }t|ƒ}|d urÚ|| _dS q|d dkrtt|d ƒƒ}| ¡ }|d urt|ƒ}|d ur|rÖ|| _dS |}qd S )	NTFr   s
   http-equivr   s   content-typeó   charsets   content)	r8   rë   rì   ÚgetAttributer¯   r^   ÚContentAttrParserrÐ   Úparse)r%   Ú	hasPragmaÚpendingEncodingÚattrÚtentativeEncodingÚcodecÚcontentParserr   r   r   rï   Î  s8    zEncodingParser.handleMetac                 C   s
   |   d¡S )NF)ÚhandlePossibleTagr6   r   r   r   rò   ò  s    z%EncodingParser.handlePossibleStartTagc                 C   s   t | jƒ |  d¡S )NT)rÜ   r8   r  r6   r   r   r   rð   õ  s    
z#EncodingParser.handlePossibleEndTagc                 C   sb   | j }|jtvr(|r$| ¡  |  ¡  dS | t¡}|dkrD| ¡  n|  ¡ }|d ur^|  ¡ }qLdS )NTr   )r8   rë   ÚasciiLettersBytesrÝ   rñ   rå   ÚspacesAngleBracketsrù   )r%   ÚendTagr8   r�   rþ   r   r   r   r  ù  s    



z EncodingParser.handlePossibleTagc                 C   s   | j  d¡S )Nr   r÷   r6   r   r   r   rñ     s    zEncodingParser.handleOtherc                 C   sô  | j }| ttdgƒB ¡}|du s2t|ƒdks2J ‚|dv r>dS g }g }|dkrV|rVq¸nX|tv rj| ¡ }q¸nD|dv r€d |¡dfS |tv r˜| | ¡ ¡ n|du r¤dS | |¡ t	|ƒ}qF|dkrÖ| 
¡  d |¡dfS t	|ƒ | ¡ }|dv �rJ|}t	|ƒ}||k�r"t	|ƒ d |¡d |¡fS |tv �r<| | ¡ ¡ qô| |¡ qônJ|d	k�rbd |¡dfS |tv �r|| | ¡ ¡ n|du �rŠdS | |¡ t	|ƒ}|tv �rºd |¡d |¡fS |tv �rÔ| | ¡ ¡ n|du �râdS | |¡ �q”dS )
z_Return a name,value pair for the next attribute in the stream,
        if one is found, or Noneó   /Nr   )r   Nó   =)r  r   r   )ó   'ó   "r   )r8   r‹   rì   Ú	frozensetr(   r9   ÚasciiUppercaseBytesr7   rÓ   rÜ   rÝ   r  )r%   r8   r�   ÚattrNameÚ	attrValueÚ	quoteCharr   r   r   rù     sb    











zEncodingParser.getAttributeN)r@   rA   rB   rC   r&   rÎ   rî   rï   rò   rð   r  rñ   rù   r   r   r   r   rÍ   ¤  s   $rÍ   c                   @   s   e Zd Zdd„ Zdd„ ZdS )rú   c                 C   s   t |tƒsJ ‚|| _d S rÑ   )rG   r3   r8   rí   r   r   r   r&   a  s    zContentAttrParser.__init__c                 C   s  � zú| j  d¡ | j  jd7  _| j  ¡  | j jdks<W d S | j  jd7  _| j  ¡  | j jdv rª| j j}| j  jd7  _| j j}| j  |¡r¢| j || j j… W S W d S nP| j j}z"| j  t¡ | j || j j… W W S  t� yø   | j |d …  Y W S 0 W n t�y   Y d S 0 d S )Nrø   r   r  )r	  r  )r8   ré   r$   r‹   rë   rå   rì   rØ   )r%   Ú	quoteMarkÚoldPositionr   r   r   rû   e  s.    

zContentAttrParser.parseN)r@   rA   rB   r&   rû   r   r   r   r   rú   `  s   rú   c                 C   sb   t | tƒr.z|  d¡} W n ty,   Y dS 0 | durZzt | ¡W S  tyV   Y dS 0 ndS dS )z{Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding.r   N)rG   r3   ÚdecodeÚUnicodeDecodeErrorr
   ÚlookupÚAttributeError)r¯   r   r   r   r^   ‡  s    

r^   )0Ú
__future__r   r   r   Úpip._vendor.sixr   Úpip._vendor.six.movesr   r   rÄ   r“   Úior   r	   Úpip._vendorr
   Ú	constantsr   r   r   r   r   rc   r   r
  rì   r  r  r  Úinvalid_unicode_no_surrogaterY   rm   r”   Úevalr�   rŠ   Úascii_punctuation_rer‘   Úobjectr!   rT   rN   rO   r3   rÐ   rÍ   rú   r^   r   r   r   r   Ú<module>   sH   ÿþ

J g Ib ='