a :jg@sLddlmZddlZddlmZddlmZmZmZGdddeeZ dS)) annotationsN)Iterable)IOAnyStrNoReturnc@sNeZdZdZdddddddZdd d d Zdd d d ZejfddddddZ dd ddZ dd ddZ d?dddddZ d@dddddZ dAdddddZdd d d!Zdd"d#d$d%Zd&d"d'd(d)ZdBddd+d,d-Zd.d d/d0Zd1dd2d3d4Zd.d d5d6Zdd d7d8Zdd d9d:Zdd d;d<Zdd d=d>Zd*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]intNone)fileoffsetlengthreturncCs(||_d|_||_||_|j|dS)z Create file object. :param file: Existing file. :param offset: Start of region, in bytes. :param length: Size of region, in bytes. rN)fhposr r seek)selfr r r r9/usr/local/lib/python3.9/site-packages/PIL/ContainerIO.py__init__s zContainerIO.__init__bool)r cCsdSNFrrrrrisatty.szContainerIO.isattycCsdSNTrrrrrseekable1szContainerIO.seekable)r moder cCsb|dkr|j||_n|dkr,|j||_n||_tdt|j|j|_|j|j|j|jS)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)rr maxminrrr )rr rrrrr4s zContainerIO.seekcCs|jS)ze Get current file pointer. :returns: Offset from start of region, in bytes. )rrrrrtellIszContainerIO.tellcCsdSrrrrrrreadableQszContainerIO.readabler)nr cCs\|dkrt||j|j}n |j|j}|dkrDd|jjvr@dSdS|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. rb)rr rrrread)rr#rrrr'Ts  zContainerIO.readcCs\d|jjvrdnd}d|jjvr$dnd}|d}|s8qX||}||ksXt||kr(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)rrr'len)rr#sZnewline_charactercrrrreadlinees zContainerIO.readlinez int | Nonez list[AnyStr]cCs0g}|}|sq,||t||krq,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*)rr#linesr+rrr readlinesxs  zContainerIO.readlinescCsdSrrrrrrwritableszContainerIO.writabler)r$r cCs tdSNNotImplementedError)rr$rrrwriteszContainerIO.writezIterable[AnyStr])r/r cCs tdSr2r3)rr/rrr writelinesszContainerIO.writelinesN)sizer cCs tdSr2r3)rr7rrrtruncateszContainerIO.truncatezContainerIO[AnyStr]cCs|Sr2rrrrr __enter__szContainerIO.__enter__object)argsr cGs |dSr2)close)rr;rrr__exit__szContainerIO.__exit__cCs|Sr2rrrrr__iter__szContainerIO.__iter__cCs|}|sd}t||S)Nz end of region)r- StopIteration)rlinemsgrrr__next__s zContainerIO.__next__cCs |jSr2)rfilenorrrrrCszContainerIO.filenocCs|jdSr2)rflushrrrrrDszContainerIO.flushcCs|jdSr2)rr<rrrrr<szContainerIO.close)r")r")r")N)__name__ __module__ __qualname____doc__rrrioSEEK_SETrr r!r'r-r0r1r5r6r8r9r=r>rBrCrDr<rrrrrs*r) __future__rrIcollections.abcrtypingrrrrrrrrs