
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \Ü  ã               @   s:   d Z ddlZejZG dd„ dejƒZG dd„ dejƒZdS )z7Internal classes used by the gzip, lzma and bz2 modulesé    Nc               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú
BaseStreamzMode-checking helper functions.c             C   s   | j rtdƒ‚d S )NzI/O operation on closed file)ÚclosedÚ
ValueError)Úself© r   ú$/usr/lib64/python3.6/_compression.pyÚ_check_not_closed   s    zBaseStream._check_not_closedc             C   s   | j ƒ stjdƒ‚d S )NzFile not open for reading)ÚreadableÚioÚUnsupportedOperation)r   r   r   r   Ú_check_can_read   s    zBaseStream._check_can_readc             C   s   | j ƒ stjdƒ‚d S )NzFile not open for writing)Úwritabler
   r   )r   r   r   r   Ú_check_can_write   s    zBaseStream._check_can_writec             C   s(   | j ƒ stjdƒ‚| jƒ s$tjdƒ‚d S )Nz3Seeking is only supported on files open for readingz3The underlying file object does not support seeking)r	   r
   r   Úseekable)r   r   r   r   Ú_check_can_seek   s    
zBaseStream._check_can_seekN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   	   s
   r   c                   sl   e Zd ZdZdd„ Zf fdd„Z‡ fdd„Zdd	„ Zd
d„ Zddd„Z	dd„ Z
ejfdd„Zdd„ Z‡  ZS )ÚDecompressReaderz5Adapts the decompressor API to a RawIOBase reader APIc             C   s   dS )NTr   )r   r   r   r   r	   $   s    zDecompressReader.readablec             K   s>   || _ d| _d| _d| _|| _|| _| jf | jŽ| _|| _d S )NFr   é   éÿÿÿÿ)Ú_fpÚ_eofÚ_posÚ_sizeÚ_decomp_factoryÚ_decomp_argsÚ_decompressorÚ_trailing_error)r   ÚfpZdecomp_factoryZtrailing_errorZdecomp_argsr   r   r   Ú__init__'   s    zDecompressReader.__init__c                s   d | _ tƒ jƒ S )N)r   ÚsuperÚclose)r   )Ú	__class__r   r   r#   ;   s    zDecompressReader.closec             C   s
   | j jƒ S )N)r   r   )r   r   r   r   r   ?   s    zDecompressReader.seekablec             C   sP   t |ƒ�:}|jdƒ�$}| jt|ƒƒ}||d t|ƒ…< W d Q R X W d Q R X t|ƒS )NÚB)Ú
memoryviewÚcastÚreadÚlen)r   ÚbZviewZ	byte_viewÚdatar   r   r   ÚreadintoB   s    $zDecompressReader.readintor   c             C   sð   |dk r| j ƒ S | s| jr dS d }xž| jjr†| jjp@| jjtƒ}|sHP | jf | j	Ž| _y| jj
||ƒ}W qº | jk
r‚   P Y qºX n4| jjr¨| jjtƒ}|s¬tdƒ‚nd}| jj
||ƒ}|r&P q&W |sÚd| _| j| _dS |  jt|ƒ7  _|S )Nr   ó    zACompressed file ended before the end-of-stream marker was reachedT)Úreadallr   r   ÚeofZunused_datar   r(   ÚBUFFER_SIZEr   r   Z
decompressr   Zneeds_inputÚEOFErrorr   r   r)   )r   Úsizer+   Zrawblockr   r   r   r(   H   s>    


zDecompressReader.readc             C   s,   | j jdƒ d| _d| _| jf | jŽ| _d S )Nr   F)r   Úseekr   r   r   r   r   )r   r   r   r   Ú_rewindr   s    zDecompressReader._rewindc             C   s¸   |t jkrnV|t jkr"| j| }n@|t jkrT| jdk rHx| jt jƒrFq8W | j| }ntdj	|ƒƒ‚|| jk rv| j
ƒ  n
|| j8 }x0|dkr°| jtt j|ƒƒ}|s¢P |t|ƒ8 }q‚W | jS )Nr   zInvalid value for whence: {})r
   ÚSEEK_SETÚSEEK_CURr   ÚSEEK_ENDr   r(   ÚDEFAULT_BUFFER_SIZEr   Úformatr4   Úminr)   )r   ÚoffsetÚwhencer+   r   r   r   r3   x   s&    







zDecompressReader.seekc             C   s   | j S )z!Return the current file position.)r   )r   r   r   r   Útell–   s    zDecompressReader.tellr   )r   )r   r   r   r   r	   r!   r#   r   r,   r(   r4   r
   r5   r3   r=   Ú__classcell__r   r   )r$   r   r   !   s   
*r   )r   r
   r8   r0   ÚBufferedIOBaser   Ú	RawIOBaser   r   r   r   r   Ú<module>   s   