
                         r    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKr " S S\R                  5      r	g)	z8FilePart implementation for representing part of a file.    )absolute_import)print_function)division)unicode_literalsNc                       \ rS rSrSrS rS rS rS rSS jr	\
R                  4S jrS	 rSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg
)FilePart   zSubclass of the file API for representing part of a file.

This class behaves as a contiguous subset of a given file (e.g., this object
will behave as though the desired part of the file was written to another
file, and the second file was opened).
c                     [        US5      U l        X0l        X l        U R                  U R                  -   U l        U R                  R                  U R                  5        g)a*  Initializes the FilePart.

Args:
  filename: The name of the existing file, of which this object represents
            a part.
  offset: The position (in bytes) in the original file that corresponds to
          the first byte of the FilePart.
  length: The total number of bytes in the FilePart.
rbN)open_fplength_start_endseek)selffilenameoffsetr   s       "platform/gsutil/gslib/file_part.py__init__FilePart.__init__#   sD     Hd#DHKKdkk)DIHHMM$++    c                     g N r   s    r   	__enter__FilePart.__enter__3   s    r   c                 $    U R                  5         g r   )close)r   typevalue	tracebacks       r   __exit__FilePart.__exit__7   s    JJLr   c                 P    U R                   R                  5       U R                  -
  $ r   )r   tellr   r   s    r   r'   FilePart.tell:   s    88==?T[[((r   c                     US:  a  U R                   n[        XR                  U R                  R	                  5       -
  5      nU R                  R                  [        SU5      5      $ )Nr   )r   minr   r   r'   readmaxr   sizes     r   r+   FilePart.read=   sH    ax[[dtYY01D88==Q&&r   c                 &   U[         R                  :X  a'  U R                  R                  XR                  -   5      $ U[         R
                  :X  a  U R                  R                  X5      $ U R                  R                  U R                  U-   5      $ r   )osSEEK_ENDr   r   r   SEEK_CURr   )r   r   whences      r   r   FilePart.seekC   sc    XX]]6II-..	2;;	XX]]6**XX]]4;;/00r   c                 8    U R                   R                  5         g r   )r   r    r   s    r   r    FilePart.closeK   s    HHNNr   Nc                     [        S5      e)Nz%flush is not implemented in FilePart.NotImplementedErrorr-   s     r   flushFilePart.flushN       
E
FFr   c                     [        S5      e)Nz&fileno is not implemented in FilePart.r9   r-   s     r   filenoFilePart.filenoQ       
F
GGr   c                     [        S5      e)Nz&isatty is not implemented in FilePart.r9   r-   s     r   isattyFilePart.isattyT   rA   r   c                     [        S5      e)Nz$next is not implemented in FilePart.r9   r-   s     r   nextFilePart.nextW   s    
D
EEr   c                     [        S5      e)Nz(readline is not implemented in FilePart.r9   r-   s     r   readlineFilePart.readlineZ       
H
IIr   c                     [        S5      e)Nz)readlines is not implemented in FilePart.r9   r-   s     r   	readlinesFilePart.readlines]   s    
I
JJr   c                     [        S5      e)Nz*xreadlines is not implemented in FilePart.r9   r-   s     r   
xreadlinesFilePart.xreadlines`       
J
KKr   c                     [        S5      e)Nz(truncate is not implemented in FilePart.r9   r-   s     r   truncateFilePart.truncatec   rK   r   c                     [        S5      e)Nz%write is not implemented in FilePart.r9   r-   s     r   writeFilePart.writef   r=   r   c                     [        S5      e)Nz*writelines is not implemented in FilePart.r9   r-   s     r   
writelinesFilePart.writelinesi   rR   r   )r   r   r   r   )r   )__name__
__module____qualname____firstlineno____doc__r   r   r$   r'   r+   r1   SEEK_SETr   r    r;   r?   rC   rF   rI   rM   rP   rT   rW   rZ   __static_attributes__r   r   r   r   r      so     	)' !# 1GHHFJKLJGLr   r   )
ra   
__future__r   r   r   r   r1   ioIOBaser   r   r   r   <module>rg      s0    ? & %  ' 	 	PLryy PLr   