B
    u9a              ,   @   s  d dl Z d dlZyd dlT W n. ek
rJ Z zede W ddZ[X Y nX dddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/g,Zd0Zd1 ZZ	d2 Z
Zd3Zd4Zejd5kre	 ZZeZne ZZeZe	ZeZeZeZG d6d deZG d7d dZG d8d deZG d9d: 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G d@d dZ G dAd dZ!d[dEdZ"d\dFdZ#dGd Z$dHd Z%dId  Z&dJd! Z'dKd" Z(dLd# Z)d]dMd&Z*d^dNd'Z+dOdP Z,dQdR Z-y4e.dCZ/e.dSZ0e.dTZ1e.dUZ2e.dVZ3e.dWZ4W n. e5k
r\   dZ/dZ0dZ1dZ2dZ3dZ4Y nX d Z6e6rpd dl7Z7e8dXkre#ej9dYdZe_9e#ej:dZdYe_:dS )_    N)*z%Failed to load the builtin codecs: %sregisterlookupopenEncodedFileBOMBOM_BEBOM_LEBOM32_BEBOM32_LEBOM64_BEBOM64_LEBOM_UTF8	BOM_UTF16BOM_UTF16_LEBOM_UTF16_BE	BOM_UTF32BOM_UTF32_LEBOM_UTF32_BE	CodecInfoCodecIncrementalEncoderIncrementalDecoderStreamReaderStreamWriterStreamReaderWriterStreamRecoder
getencoder
getdecodergetincrementalencodergetincrementaldecoder	getreader	getwriterencodedecode
iterencode
iterdecodestrict_errorsignore_errorsreplace_errorsxmlcharrefreplace_errorsbackslashreplace_errorsnamereplace_errorsregister_errorlookup_errors   ﻿s   s   s     s     littlec               @   s(   e Zd ZdZdddddZdd ZdS )	r   TN)_is_text_encodingc      
      C   sP   t | ||||f}	||	_||	_||	_||	_||	_||	_||	_|d k	rL||	_	|	S )N)
tuple__new__namer#   r$   incrementalencoderincrementaldecoderstreamwriterstreamreaderr0   )
clsr#   r$   r7   r6   r4   r5   r3   r0   self r:   /usr/lib/python3.7/codecs.pyr2   ^   s    zCodecInfo.__new__c             C   s   d| j j| j j| jt| f S )Nz%<%s.%s object for encoding %s at %#x>)	__class__
__module____qualname__r3   id)r9   r:   r:   r;   __repr__m   s    zCodecInfo.__repr__)NNNNN)__name__r=   r>   r0   r2   r@   r:   r:   r:   r;   r   S   s
   	 c               @   s    e Zd ZdddZdddZdS )	r   strictc             C   s   t d S )N)NotImplementedError)r9   inputerrorsr:   r:   r;   r#      s    zCodec.encodec             C   s   t d S )N)rC   )r9   rD   rE   r:   r:   r;   r$      s    zCodec.decodeN)rB   )rB   )rA   r=   r>   r#   r$   r:   r:   r:   r;   r   r   s   
c               @   s8   e Zd ZdddZdddZdd Zd	d
 Zdd ZdS )r   rB   c             C   s   || _ d| _d S )N )rE   buffer)r9   rE   r:   r:   r;   __init__   s    zIncrementalEncoder.__init__Fc             C   s   t d S )N)rC   )r9   rD   finalr:   r:   r;   r#      s    zIncrementalEncoder.encodec             C   s   d S )Nr:   )r9   r:   r:   r;   reset   s    zIncrementalEncoder.resetc             C   s   dS )Nr   r:   )r9   r:   r:   r;   getstate   s    zIncrementalEncoder.getstatec             C   s   d S )Nr:   )r9   stater:   r:   r;   setstate   s    zIncrementalEncoder.setstateN)rB   )F)rA   r=   r>   rH   r#   rJ   rK   rM   r:   r:   r:   r;   r      s
   

c               @   s@   e Zd ZdddZdd ZdddZd	d
 Zdd Zdd ZdS )BufferedIncrementalEncoderrB   c             C   s   t | | d| _d S )NrF   )r   rH   rG   )r9   rE   r:   r:   r;   rH      s    z#BufferedIncrementalEncoder.__init__c             C   s   t d S )N)rC   )r9   rD   rE   rI   r:   r:   r;   _buffer_encode   s    z)BufferedIncrementalEncoder._buffer_encodeFc             C   s0   | j | }| || j|\}}||d  | _ |S )N)rG   rO   rE   )r9   rD   rI   dataresultconsumedr:   r:   r;   r#      s    
z!BufferedIncrementalEncoder.encodec             C   s   t |  d| _d S )NrF   )r   rJ   rG   )r9   r:   r:   r;   rJ      s    
z BufferedIncrementalEncoder.resetc             C   s
   | j pdS )Nr   )rG   )r9   r:   r:   r;   rK      s    z#BufferedIncrementalEncoder.getstatec             C   s   |pd| _ d S )NrF   )rG   )r9   rL   r:   r:   r;   rM      s    z#BufferedIncrementalEncoder.setstateN)rB   )F)	rA   r=   r>   rH   rO   r#   rJ   rK   rM   r:   r:   r:   r;   rN      s   

rN   c               @   s8   e Zd ZdddZdddZdd Zd	d
 Zdd ZdS )r   rB   c             C   s
   || _ d S )N)rE   )r9   rE   r:   r:   r;   rH     s    zIncrementalDecoder.__init__Fc             C   s   t d S )N)rC   )r9   rD   rI   r:   r:   r;   r$     s    zIncrementalDecoder.decodec             C   s   d S )Nr:   )r9   r:   r:   r;   rJ     s    zIncrementalDecoder.resetc             C   s   dS )N)    r   r:   )r9   r:   r:   r;   rK     s    zIncrementalDecoder.getstatec             C   s   d S )Nr:   )r9   rL   r:   r:   r;   rM   '  s    zIncrementalDecoder.setstateN)rB   )F)rA   r=   r>   rH   r$   rJ   rK   rM   r:   r:   r:   r;   r      s
   


c               @   s@   e Zd ZdddZdd ZdddZd	d
 Zdd Zdd ZdS )BufferedIncrementalDecoderrB   c             C   s   t | | d| _d S )NrS   )r   rH   rG   )r9   rE   r:   r:   r;   rH   5  s    z#BufferedIncrementalDecoder.__init__c             C   s   t d S )N)rC   )r9   rD   rE   rI   r:   r:   r;   _buffer_decode:  s    z)BufferedIncrementalDecoder._buffer_decodeFc             C   s0   | j | }| || j|\}}||d  | _ |S )N)rG   rU   rE   )r9   rD   rI   rP   rQ   rR   r:   r:   r;   r$   ?  s    
z!BufferedIncrementalDecoder.decodec             C   s   t |  d| _d S )NrS   )r   rJ   rG   )r9   r:   r:   r;   rJ   G  s    
z BufferedIncrementalDecoder.resetc             C   s
   | j dfS )Nr   )rG   )r9   r:   r:   r;   rK   K  s    z#BufferedIncrementalDecoder.getstatec             C   s   |d | _ d S )Nr   )rG   )r9   rL   r:   r:   r;   rM   O  s    z#BufferedIncrementalDecoder.setstateN)rB   )F)	rA   r=   r>   rH   rU   r$   rJ   rK   rM   r:   r:   r:   r;   rT   /  s   

rT   c               @   sT   e Zd ZdddZdd Zdd Zdd	 ZdddZefddZ	dd Z
dd ZdS )r   rB   c             C   s   || _ || _d S )N)streamrE   )r9   rV   rE   r:   r:   r;   rH   \  s    zStreamWriter.__init__c             C   s"   |  || j\}}| j| d S )N)r#   rE   rV   write)r9   objectrP   rR   r:   r:   r;   rW   u  s    zStreamWriter.writec             C   s   |  d| d S )NrF   )rW   join)r9   listr:   r:   r;   
writelines|  s    zStreamWriter.writelinesc             C   s   d S )Nr:   )r9   r:   r:   r;   rJ     s    
zStreamWriter.resetr   c             C   s*   | j || |dkr&|dkr&|   d S )Nr   )rV   seekrJ   )r9   offsetwhencer:   r:   r;   r\     s    zStreamWriter.seekc             C   s   || j |S )N)rV   )r9   r3   getattrr:   r:   r;   __getattr__  s    zStreamWriter.__getattr__c             C   s   | S )Nr:   )r9   r:   r:   r;   	__enter__  s    zStreamWriter.__enter__c             C   s   | j   d S )N)rV   close)r9   typevaluetbr:   r:   r;   __exit__  s    zStreamWriter.__exit__N)rB   )r   )rA   r=   r>   rH   rW   r[   rJ   r\   r_   r`   ra   rf   r:   r:   r:   r;   r   Z  s   

c               @   s   e Zd ZeZdddZd ddZd!dd	Zd"ddZd#ddZ	dd Z
d$ddZdd Zdd ZefddZdd Zdd Zd
S )%r   rB   c             C   s.   || _ || _d| _|  | _| j| _d | _d S )NrS   )rV   rE   
bytebuffercharbuffertype_empty_charbuffer
charbuffer
linebuffer)r9   rV   rE   r:   r:   r;   rH     s    
zStreamReader.__init__c             C   s   t d S )N)rC   )r9   rD   rE   r:   r:   r;   r$     s    zStreamReader.decodeFc          
   C   sL  | j r| j| j | _d | _ |dk r(|}x|dkrBt| j|krBP |dk rV| j }n| j|}| j| }|srP y| || j	\}}W n` t
k
r } zB|r| |d |j | j	\}}|jdd}	t|	dkr؂ n W d d }~X Y nX ||d  | _|  j|7  _|s*P q*W |dk r*| j}
| j| _n| jd | }
| j|d  | _|
S )Nr   T)keepends   )rk   ri   rY   rj   lenrV   readrg   r$   rE   UnicodeDecodeErrorstart
splitlines)r9   sizechars	firstlinenewdatarP   newcharsdecodedbytesexclinesrQ   r:   r:   r;   rp     sD    


zStreamReader.readNTc       	      C   s  | j rP| j d }| j d= t| j dkr8| j d | _d | _ |sL|jddd }|S |pVd}| j}xn| j|dd}|rt|tr|dst|t	r|d	r|| jddd
7 }||7 }|jdd}|rt|dkr:|d }|d= t|dkr|d  | j7  < || _ d | _n|d | j | _|s8|jddd }P |d }|d jddd }||kr| j
|dd  | j | _|r|}n|}P |r|d k	r|r|s|jddd }P |dk rb|d9 }qbW |S )Nr   rn   F)rm   H   T)rv      )rt   ru   rl   i@     )rk   ro   rj   rs   ri   rp   
isinstancestrendswithbytesrY   )	r9   rt   rm   linereadsizerP   r{   line0withendline0withoutendr:   r:   r;   readline  s^    


zStreamReader.readlinec             C   s   |   }||S )N)rp   rs   )r9   sizehintrm   rP   r:   r:   r;   	readlines^  s    zStreamReader.readlinesc             C   s   d| _ | j| _d | _d S )NrS   )rg   ri   rj   rk   )r9   r:   r:   r;   rJ   m  s    	zStreamReader.resetr   c             C   s   | j || |   d S )N)rV   r\   rJ   )r9   r]   r^   r:   r:   r;   r\   z  s    zStreamReader.seekc             C   s   |   }|r|S td S )N)r   StopIteration)r9   r   r:   r:   r;   __next__  s    zStreamReader.__next__c             C   s   | S )Nr:   )r9   r:   r:   r;   __iter__  s    zStreamReader.__iter__c             C   s   || j |S )N)rV   )r9   r3   r_   r:   r:   r;   r`     s    zStreamReader.__getattr__c             C   s   | S )Nr:   )r9   r:   r:   r;   ra     s    zStreamReader.__enter__c             C   s   | j   d S )N)rV   rb   )r9   rc   rd   re   r:   r:   r;   rf     s    zStreamReader.__exit__)rB   )rB   )rl   rl   F)NT)NT)r   )rA   r=   r>   r   rh   rH   r$   rp   r   r   rJ   r\   r   r   r_   r`   ra   rf   r:   r:   r:   r;   r     s   


P
K

c               @   s   e Zd ZdZd ddZd!ddZd"d	d
Zd#ddZdd Zdd Z	dd Z
dd Zdd Zd$ddZefddZdd Zdd ZdS )%r   unknownrB   c             C   s(   || _ |||| _|||| _|| _d S )N)rV   readerwriterrE   )r9   rV   ReaderWriterrE   r:   r:   r;   rH     s    zStreamReaderWriter.__init__rl   c             C   s   | j |S )N)r   rp   )r9   rt   r:   r:   r;   rp     s    zStreamReaderWriter.readNc             C   s   | j |S )N)r   r   )r9   rt   r:   r:   r;   r     s    zStreamReaderWriter.readlinec             C   s   | j |S )N)r   r   )r9   r   r:   r:   r;   r     s    zStreamReaderWriter.readlinesc             C   s
   t | jS )N)nextr   )r9   r:   r:   r;   r     s    zStreamReaderWriter.__next__c             C   s   | S )Nr:   )r9   r:   r:   r;   r     s    zStreamReaderWriter.__iter__c             C   s   | j |S )N)r   rW   )r9   rP   r:   r:   r;   rW     s    zStreamReaderWriter.writec             C   s   | j |S )N)r   r[   )r9   rZ   r:   r:   r;   r[     s    zStreamReaderWriter.writelinesc             C   s   | j   | j  d S )N)r   rJ   r   )r9   r:   r:   r;   rJ     s    
zStreamReaderWriter.resetr   c             C   s6   | j || | j  |dkr2|dkr2| j  d S )Nr   )rV   r\   r   rJ   r   )r9   r]   r^   r:   r:   r;   r\     s    
zStreamReaderWriter.seekc             C   s   || j |S )N)rV   )r9   r3   r_   r:   r:   r;   r`     s    zStreamReaderWriter.__getattr__c             C   s   | S )Nr:   )r9   r:   r:   r;   ra     s    zStreamReaderWriter.__enter__c             C   s   | j   d S )N)rV   rb   )r9   rc   rd   re   r:   r:   r;   rf     s    zStreamReaderWriter.__exit__)rB   )rl   )N)N)r   )rA   r=   r>   encodingrH   rp   r   r   r   r   rW   r[   rJ   r\   r_   r`   ra   rf   r:   r:   r:   r;   r     s   




c               @   s   e Zd ZdZdZd ddZd!ddZd"d	d
Zd#ddZdd Z	dd Z
dd Zdd Zdd Zd$ddZefddZdd Zdd ZdS )%r   r   rB   c             C   s4   || _ || _|| _|||| _|||| _|| _d S )N)rV   r#   r$   r   r   rE   )r9   rV   r#   r$   r   r   rE   r:   r:   r;   rH     s    zStreamRecoder.__init__rl   c             C   s"   | j |}| || j\}}|S )N)r   rp   r#   rE   )r9   rt   rP   bytesencodedr:   r:   r;   rp   #  s    zStreamRecoder.readNc             C   s6   |d kr| j  }n| j |}| || j\}}|S )N)r   r   r#   rE   )r9   rt   rP   r   r:   r:   r;   r   )  s
    zStreamRecoder.readlinec             C   s(   | j  }| || j\}}|jddS )NT)rm   )r   rp   r#   rE   rs   )r9   r   rP   r   r:   r:   r;   r   2  s    
zStreamRecoder.readlinesc             C   s    t | j}| || j\}}|S )N)r   r   r#   rE   )r9   rP   r   r:   r:   r;   r   8  s    
zStreamRecoder.__next__c             C   s   | S )Nr:   )r9   r:   r:   r;   r   ?  s    zStreamRecoder.__iter__c             C   s   |  || j\}}| j|S )N)r$   rE   r   rW   )r9   rP   bytesdecodedr:   r:   r;   rW   B  s    zStreamRecoder.writec             C   s(   d |}| || j\}}| j|S )NrS   )rY   r$   rE   r   rW   )r9   rZ   rP   r   r:   r:   r;   r[   G  s    
zStreamRecoder.writelinesc             C   s   | j   | j  d S )N)r   rJ   r   )r9   r:   r:   r;   rJ   M  s    
zStreamRecoder.resetr   c             C   s    | j || | j|| d S )N)r   r\   r   )r9   r]   r^   r:   r:   r;   r\   R  s    zStreamRecoder.seekc             C   s   || j |S )N)rV   )r9   r3   r_   r:   r:   r;   r`   X  s    zStreamRecoder.__getattr__c             C   s   | S )Nr:   )r9   r:   r:   r;   ra   _  s    zStreamRecoder.__enter__c             C   s   | j   d S )N)rV   rb   )r9   rc   rd   re   r:   r:   r;   rf   b  s    zStreamRecoder.__exit__)rB   )rl   )N)N)r   )rA   r=   r>   data_encodingfile_encodingrH   rp   r   r   r   r   rW   r[   rJ   r\   r_   r`   ra   rf   r:   r:   r:   r;   r     s   


	

rrB   rn   c             C   sV   |d k	rd|kr|d }t | ||}|d kr2|S t|}t||j|j|}||_|S )Nb)builtinsr   r   r   r7   r6   r   )filenamemoder   rE   	bufferingfileinfosrwr:   r:   r;   r   g  s    c             C   sF   |d kr|}t |}t |}t| |j|j|j|j|}||_||_|S )N)r   r   r#   r$   r7   r6   r   r   )r   r   r   rE   	data_info	file_infosrr:   r:   r;   r     s    c             C   s
   t | jS )N)r   r#   )r   r:   r:   r;   r     s    c             C   s
   t | jS )N)r   r$   )r   r:   r:   r;   r     s    c             C   s   t | j}|d krt| |S )N)r   r4   LookupError)r   encoderr:   r:   r;   r     s    	
c             C   s   t | j}|d krt| |S )N)r   r5   r   )r   decoderr:   r:   r;   r      s    	
c             C   s
   t | jS )N)r   r7   )r   r:   r:   r;   r!     s    c             C   s
   t | jS )N)r   r6   )r   r:   r:   r;   r"     s    c             k   sL   t ||f|}x | D ]}||}|r|V  qW |dd}|rH|V  d S )NrF   T)r   r#   )iteratorr   rE   kwargsr   rD   outputr:   r:   r;   r%     s    	


c             k   sL   t ||f|}x | D ]}||}|r|V  qW |dd}|rH|V  d S )NrS   T)r    r$   )r   r   rE   r   r   rD   r   r:   r:   r;   r&     s    	


c             C   s   dd | D S )Nc             S   s   i | ]
}||qS r:   r:   ).0ir:   r:   r;   
<dictcomp>)  s    z&make_identity_dict.<locals>.<dictcomp>r:   )rngr:   r:   r;   make_identity_dict!  s    r   c             C   s8   i }x.|   D ]"\}}||kr(|||< qd ||< qW |S )N)items)decoding_mapmkvr:   r:   r;   make_encoding_map+  s    
r   ignorereplacexmlcharrefreplacebackslashreplacenamereplace__main__zlatin-1zutf-8)r   NrB   rn   )NrB   )rB   )rB   );r   sys_codecsImportErrorZwhySystemError__all__r   r	   r   r   r   r   r   	byteorderr   r   r   r   r
   r   r   r1   r   r   rX   r   rN   r   rT   r   r   r   r   r   r   r   r   r   r    r!   r"   r%   r&   r   r   r.   r'   r(   r)   r*   r+   r,   r   _false	encodingsrA   stdoutstdinr:   r:   r:   r;   <module>
   s   

B("1+I zWt
*
&








