a
    h                     @  sL   d dl mZ d dlZd dlmZ d dlmZmZmZ G dd dee Z	dS )    )annotationsN)Iterable)IOAnyStrNoReturnc                   @  sN  e Zd ZdZdddddddZ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Zd?dddddZd@dddddZdAdddddZdd	d d!Zdd"d#d$d%Zd&d"d'd(d)ZdBddd+d,d-Zd.d	d/d0Zd1dd2d3d4Zd.d	d5d6Zdd	d7d8Zdd	d9d:Zdd	d;d<Zdd	d=d>Zd*S )C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   =/var/www/auris/lib/python3.9/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.isattyc                 C  s   dS NTr   r   r   r   r   seekable1   s    zContainerIO.seekable)r   moder   c                 C  sb   |dkr| j | | _ n|dkr,| j| | _ n|| _ tdt| j | j| _ | j| j| j   | j S )aK  
        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.
        :returns: Offset from start of region, in bytes.
              r   )r   r   maxminr   r   r   )r   r   r   r   r   r   r   4   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   tellI   s    zContainerIO.tellc                 C  s   dS r   r   r   r   r   r   readableQ   s    zContainerIO.readabler   )nr   c                 C  s\   |dkrt || j| j }n| j| j }|dkrDd| jjv r@dS dS | j| | _| j|S )z
        Read data.

        :param n: Number of bytes to read. If omitted, zero or negative,
            read until end of region.
        :returns: An 8-bit string.
        r   b     )r   r   r   r   r   read)r   r#   r   r   r   r'   T   s    zContainerIO.readc                 C  s\   d| j jv rdnd}d| j jv r$dnd}| d}|s8qX|| }||ksXt||kr(qXq(|S )z
        Read a line of text.

        :param n: Number of bytes to read. If omitted, zero or negative,
            read until end of line.
        :returns: An 8-bit string.
        r$   r%   r&      

r   )r   r   r'   len)r   r#   sZnewline_charactercr   r   r   readlinee   s    
zContainerIO.readlinez
int | Nonezlist[AnyStr]c                 C  s0   g }|   }|sq,|| t||krq,q|S )z
        Read multiple lines of text.

        :param n: Number of lines to read. If omitted, zero, negative or None,
            read until end of region.
        :returns: A list of 8-bit strings.
        )r-   appendr*   )r   r#   linesr+   r   r   r   	readlinesx   s    
zContainerIO.readlinesc                 C  s   dS r   r   r   r   r   r   writable   s    zContainerIO.writabler   )r$   r   c                 C  s
   t  d S NNotImplementedError)r   r$   r   r   r   write   s    zContainerIO.writezIterable[AnyStr])r/   r   c                 C  s
   t  d S r2   r3   )r   r/   r   r   r   
writelines   s    zContainerIO.writelinesN)sizer   c                 C  s
   t  d S r2   r3   )r   r7   r   r   r   truncate   s    zContainerIO.truncatezContainerIO[AnyStr]c                 C  s   | S r2   r   r   r   r   r   	__enter__   s    zContainerIO.__enter__object)argsr   c                 G  s   |    d S r2   )close)r   r;   r   r   r   __exit__   s    zContainerIO.__exit__c                 C  s   | S r2   r   r   r   r   r   __iter__   s    zContainerIO.__iter__c                 C  s   |   }|sd}t||S )Nzend of region)r-   StopIteration)r   linemsgr   r   r   __next__   s
    zContainerIO.__next__c                 C  s
   | j  S r2   )r   filenor   r   r   r   rC      s    zContainerIO.filenoc                 C  s   | j   d S r2   )r   flushr   r   r   r   rD      s    zContainerIO.flushc                 C  s   | j   d S r2   )r   r<   r   r   r   r   r<      s    zContainerIO.close)r"   )r"   )r"   )N)__name__
__module____qualname____doc__r   r   r   ioSEEK_SETr   r    r!   r'   r-   r0   r1   r5   r6   r8   r9   r=   r>   rB   rC   rD   r<   r   r   r   r   r      s*   r   )

__future__r   rI   collections.abcr   typingr   r   r   r   r   r   r   r   <module>   s   