U
    3dK                     @   s*   d Z ddlZddlmZ G dd dZdS )z
Wrapper class to expose a Key being read via a partial implementaiton of the
Python file interface. The only functions supported are those needed for seeking
in a Key open for reading.
    N)StorageResponseErrorc                   @   s   e Zd Zdd Zdd Zejf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d Zdd Zdd Zdd Zdd  Zd!d" Zd#S )$KeyFilec                 C   sF   || _ | j   d| _d| _d| _d| _d| _d| _d| _|j	| _	d S )Nr   FrzUndefined in KeyFile)
key	open_readlocationclosed	softspacemodeencodingerrorsnewlinesname)selfr    r   3/tmp/pip-unpacked-wheel-d7dsrkjd/boto/s3/keyfile.py__init__"   s    
zKeyFile.__init__c                 C   s   | j d krtd| j S )NzI/O operation on closed file)r   
ValueErrorr   r   r   r   tell.   s    
zKeyFile.tellc              
   C   s
  | j jdd |tjkrx| j jdkr(d S | j j| d }|dk rHtd| j jdd| id | j d |d | _d S |tj	kr|dk rtdn"|tj
kr|| j7 }ntd	| z| j jdd| id W n. tk
r } z|jd
kr W 5 d }~X Y nX || _d S )NT)fastr      zInvalid argumentZRangez	bytes=%d-)headersz(Invalid whence param (%d) passed to seeki  )r   closeosSEEK_ENDsizeIOErrorr   readr   SEEK_SETSEEK_CURr   status)r   poswhenceer   r   r   seek3   s.    





zKeyFile.seekc                 C   s   |  j |7  _ | j|S N)r   r   r   )r   r   r   r   r   r   W   s    zKeyFile.readc                 C   s   | j   d | _d| _d S )NT)r   r   r   r	   r   r   r   r   r   [   s    
zKeyFile.closec                 C   s   dS )NFr   r   r   r   r   isatty`   s    zKeyFile.isattyc                 C   s   | j S r'   )r   r   r   r   r   getkeye   s    zKeyFile.getkeyc                 C   s   t dd S )Nz write not implemented in KeyFileNotImplementedError)r   bufr   r   r   writej   s    zKeyFile.writec                 C   s   t dd S )Nz!fileno not implemented in KeyFiler*   r   r   r   r   filenom   s    zKeyFile.filenoc                 C   s   t dd S )Nz flush not implemented in KeyFiler*   r   r   r   r   flushp   s    zKeyFile.flushc                 C   s   t dd S )Nznext not implemented in KeyFiler*   r   r   r   r   nexts   s    zKeyFile.nextc                 C   s   t dd S )Nz#readinto not implemented in KeyFiler*   r   r   r   r   readintov   s    zKeyFile.readintoc                 C   s   t dd S )Nz#readline not implemented in KeyFiler*   r   r   r   r   readliney   s    zKeyFile.readlinec                 C   s   t dd S )Nz$readlines not implemented in KeyFiler*   r   r   r   r   	readlines|   s    zKeyFile.readlinesc                 C   s   t dd S )Nz#truncate not implemented in KeyFiler*   r   r   r   r   truncate   s    zKeyFile.truncatec                 C   s   t dd S )Nz%writelines not implemented in KeyFiler*   r   r   r   r   
writelines   s    zKeyFile.writelinesc                 C   s   t dd S )Nz%xreadlines not implemented in KeyFiler*   r   r   r   r   
xreadlines   s    zKeyFile.xreadlinesN)__name__
__module____qualname__r   r   r   r    r&   r   r   r(   r)   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r   r   r   r       s"   $r   )__doc__r   Zboto.exceptionr   r   r   r   r   r   <module>   s   