U
    ?hm                     @  sD   d dl mZ d dlZd dlmZmZmZmZ G dd dee ZdS )    )annotationsN)IOAnyStrGenericLiteralc                   @  s   e Zd ZdZdddddddZdd	d
dZejfddddddZdd	ddZ	ddddddZ
dd	ddZdd	ddZdS )ContainerIOzm
    A file object that provides read access to a part of an existing
    file (for example a TAR file).
    z
IO[AnyStr]intNone)fileoffsetlengthreturnc                 C  s(   || _ d| _|| _|| _| j | dS )z
        Create file object.

        :param file: Existing file.
        :param offset: Start of region, in bytes.
        :param length: Size of region, in bytes.
        r   N)fhposr   r   seek)selfr
   r   r    r   A/var/www/html/venv/lib/python3.8/site-packages/PIL/ContainerIO.py__init__   s
    zContainerIO.__init__bool)r   c                 C  s   dS )NFr   r   r   r   r   isatty-   s    zContainerIO.isattyzLiteral[(0, 1, 2)])r   moder   c                 C  s`   |dkr| j | | _ n|dkr,| j| | _ n|| _ tdt| j | j| _ | j| j| j   dS )a  
        Move file pointer.

        :param offset: Offset in bytes.
        :param mode: Starting position. Use 0 for beginning of region, 1
           for current offset, and 2 for end of region.  You cannot move
           the pointer outside the defined region.
              r   N)r   r   maxminr   r   r   )r   r   r   r   r   r   r   0   s    	zContainerIO.seekc                 C  s   | j S )ze
        Get current file pointer.

        :returns: Offset from start of region, in bytes.
        )r   r   r   r   r   tellC   s    zContainerIO.tellr   r   )nr   c                 C  sT   |rt || j| j }n| j| j }|s<d| jjkr8dS dS | j| | _| j|S )z
        Read data.

        :param n: Number of bytes to read. If omitted or zero,
            read until end of region.
        :returns: An 8-bit string.
        b     )r   r   r   r   r   read)r   r   r   r   r   r"   K   s    zContainerIO.readc                 C  sP   d| j jkrdnd}d| j jkr$dnd}| d}|s8qL|| }||kr(qLq(|S )zJ
        Read a line of text.

        :returns: An 8-bit string.
        r   r    r!      

r   )r   r   r"   )r   sZnewline_charactercr   r   r   readline\   s    
zContainerIO.readlinezlist[AnyStr]c                 C  s"   g }|   }|sq|| q|S )zZ
        Read multiple lines of text.

        :returns: A list of 8-bit strings.
        )r'   append)r   linesr%   r   r   r   	readlinesm   s    zContainerIO.readlinesN)r   )__name__
__module____qualname____doc__r   r   ioSEEK_SETr   r   r"   r'   r*   r   r   r   r   r      s   r   )	
__future__r   r/   typingr   r   r   r   r   r   r   r   r   <module>   s   