o
    üÞ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                   @  sæ   e Zd ZdZdAd	d
„ZdBdd„ZdBdd„ZejfdCdd„Z	dDdd„Z
dBdd„ZdEdFdd„ZdEdFdd„ZdEdGd d!„ZdBd"d#„ZdHd&d'„ZdId*d+„ZdJdKd.d/„ZdLd1d2„ZdMd5d6„ZdLd7d8„ZdNd9d:„ZdDd;d<„ZdOd=d>„ZdOd?d@„Zd,S )PÚContainerIOzm
    A file object that provides read access to a part of an existing
    file (for example a TAR file).
    Úfileú
IO[AnyStr]ÚoffsetÚintÚlengthÚreturnÚNonec                 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   úO/var/www/html/premium_crap/venv/lib/python3.10/site-packages/PIL/ContainerIO.pyÚ__init__   s
   zContainerIO.__init__Úboolc                 C  ó   dS ©NFr   ©r   r   r   r   Úisatty.   ó   zContainerIO.isattyc                 C  r   ©NTr   r   r   r   r   Úseekable1   r   zContainerIO.seekableÚmodec                 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  r   r   r   r   r   r   r   ÚreadableQ   r   zContainerIO.readableéÿÿÿÿÚnr   c                 C  s\   |dkrt || j| j ƒ}n| j| j }|dkr"d| 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  sb   d| j jv rdnd}d| j jv rdnd}	 |  d¡}|s	 |S || }||ks-t|ƒ|kr0	 |S q)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)   ó   
Ú
Tr   )r   r   r*   Úlen)r   r&   ÚsÚnewline_characterÚcr   r   r   Úreadlinee   s   
ýùzContainerIO.readlineú
int | Noneúlist[AnyStr]c                 C  s6   g }	 |   ¡ }|s	 |S | |¡ t|ƒ|kr	 |S q)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.
        )r1   Úappendr-   )r   r&   Úlinesr.   r   r   r   Ú	readlinesx   s   
ýùzContainerIO.readlinesc                 C  r   r   r   r   r   r   r   ÚwritableŠ   r   zContainerIO.writabler'   r   c                 C  ó   t ƒ ‚©N©ÚNotImplementedError)r   r'   r   r   r   Úwrite�   ó   zContainerIO.writer5   úIterable[AnyStr]c                 C  r8   r9   r:   )r   r5   r   r   r   Ú
writelines�   r=   zContainerIO.writelinesNÚsizec                 C  r8   r9   r:   )r   r@   r   r   r   Útruncate“   r=   zContainerIO.truncateúContainerIO[AnyStr]c                 C  ó   | S r9   r   r   r   r   r   Ú	__enter__–   r   zContainerIO.__enter__ÚargsÚobjectc                 G  s   |   ¡  d S r9   )Úclose)r   rE   r   r   r   Ú__exit__™   s   zContainerIO.__exit__c                 C  rC   r9   r   r   r   r   r   Ú__iter__œ   r   zContainerIO.__iter__c                 C  s   |   ¡ }|sd}t|ƒ‚|S )Nzend of region)r1   ÚStopIteration)r   ÚlineÚmsgr   r   r   Ú__next__Ÿ   s
   zContainerIO.__next__c                 C  s
   | j  ¡ S r9   )r   Úfilenor   r   r   r   rN   ¦   s   
zContainerIO.filenoc                 C  ó   | j  ¡  d S r9   )r   Úflushr   r   r   r   rP   ©   ó   zContainerIO.flushc                 C  rO   r9   )r   rG   r   r   r   r   rG   ¬   rQ   zContainerIO.close)r   r	   r
   r   r   r   r   r   )r   r   )r
   r   r   r   r   r   )r   r   )r%   )r&   r   r   r   )r&   r2   r   r3   )r'   r   r   r   )r5   r>   r   r   r9   )r@   r2   r   r   )r   rB   )rE   rF   r   r   )r   r   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚioÚSEEK_SETr   r#   r$   r*   r1   r6   r7   r<   r?   rA   rD   rH   rI   rM   rN   rP   rG   r   r   r   r   r      s,    













r   )
Ú
__future__r   rV   Úcollections.abcr   Útypingr   r   r   r   r   r   r   r   Ú<module>   s
   