o
    ȷeK                     @   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   F/var/www/ideatree/venv/lib/python3.10/site-packages/boto/s3/keyfile.py__init__"   s   
zKeyFile.__init__c                 C   s   | j d u 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r<| j jdkrd S | j j| d }|dk r$td| j jdd| id | j d |d | _d S |tj	krJ|dk rItdn|tj
krU|| j7 }ntd	| z| j jdd| id W n ty } z|jd
krv W Y d }~nd }~ww || _d S )NT)fastr      zInvalid argument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   s6   





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      t d)Nz write not implemented in KeyFileNotImplementedError)r   bufr   r   r   writej      zKeyFile.writec                 C   r+   )Nz!fileno not implemented in KeyFiler,   r   r   r   r   filenom   r0   zKeyFile.filenoc                 C   r+   )Nz flush not implemented in KeyFiler,   r   r   r   r   flushp   r0   zKeyFile.flushc                 C   r+   )Nznext not implemented in KeyFiler,   r   r   r   r   nexts   r0   zKeyFile.nextc                 C   r+   )Nz#readinto not implemented in KeyFiler,   r   r   r   r   readintov   r0   zKeyFile.readintoc                 C   r+   )Nz#readline not implemented in KeyFiler,   r   r   r   r   readliney   r0   zKeyFile.readlinec                 C   r+   )Nz$readlines not implemented in KeyFiler,   r   r   r   r   	readlines|   r0   zKeyFile.readlinesc                 C   r+   )Nz#truncate not implemented in KeyFiler,   r   r   r   r   truncate   r0   zKeyFile.truncatec                 C   r+   )Nz%writelines not implemented in KeyFiler,   r   r   r   r   
writelines   r0   zKeyFile.writelinesc                 C   r+   )Nz%xreadlines not implemented in KeyFiler,   r   r   r   r   
xreadlines   r0   zKeyFile.xreadlinesN)__name__
__module____qualname__r   r   r   r!   r'   r    r   r)   r*   r/   r1   r2   r3   r4   r5   r6   r7   r8   r9   r   r   r   r   r       s$    $r   )__doc__r   boto.exceptionr   r   r   r   r   r   <module>   s   