K iTddlmZddlZddlmZddlmZmZmZGddeeZ y)) annotationsN)Iterable)IOAnyStrNoReturnceZdZdZddZddZddZejfddZ ddZ ddZ dddZ ddd Z ddd Zdd Zdd Zdd Zd d!dZd"dZd#dZd"dZd$dZddZd%dZd%dZy)& ContainerIOzm A file object that provides read access to a part of an existing file (for example a TAR file). cr||_d|_||_||_|jj |y)z Create file object. :param file: Existing file. :param offset: Start of region, in bytes. :param length: Size of region, in bytes. rN)fhposoffsetlengthseek)selffiler rs U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/PIL/ContainerIO.py__init__zContainerIO.__init__s0#    VcyNFrs risattyzContainerIO.isatty.rcyNTrrs rseekablezContainerIO.seekable1rcR|dk(r|j|z|_n!|dk(r|j|z|_n||_tdt|j|j|_|jj |j |jz|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)r rmaxminr rr )rr modes rrzContainerIO.seek4s| 19xx&(DH QY{{V+DHDHq#dhh 45  T[[488+,xxrc|jS)ze Get current file pointer. :returns: Offset from start of region, in bytes. )r rs rtellzContainerIO.tellIs xxrcyrrrs rreadablezContainerIO.readableQrrc&|dkDr$t||j|jz }n|j|jz }|dkrd|jjvrdSdS|j|z|_|jj |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. rbr)r#rr r r$read)rns rr,zContainerIO.readTsx q5At{{TXX-.A dhh&A 6-3 52 588a<ww||Arcd|jjvrdnd}d|jjvrdnd} |jd}|s |S||z}||k(st||k(r |S2)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*rr+  r )r r$r,len)rr-snewline_charactercs rreadlinezContainerIO.readlineesy$'',,.CB%(DGGLL%8Ed ! AAA%%Q1rcxg} |j}|s |S|j|t||k(r |S8)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. )r5appendr1)rr-linesr2s r readlineszContainerIO.readlinesxsI A  LLO5zQ rcyrrrs rwritablezContainerIO.writablerrctNNotImplementedError)rr*s rwritezContainerIO.write !##rctr=r>)rr8s r writelineszContainerIO.writelinesrArNctr=r>)rsizes rtruncatezContainerIO.truncaterArc|Sr=rrs r __enter__zContainerIO.__enter__ rc$|jyr=)close)rargss r__exit__zContainerIO.__exit__s  rc|Sr=rrs r__iter__zContainerIO.__iter__rIrcD|j}|s d}t||S)Nz end of region)r5 StopIteration)rlinemsgs r__next__zContainerIO.__next__s%}}!C$ $ rc6|jjSr=)r filenors rrVzContainerIO.filenosww~~rc8|jjyr=)r flushrs rrXzContainerIO.flush  rc8|jjyr=)r rKrs rrKzContainerIO.closerYr)rz IO[AnyStr]r intrr[returnNone)r\bool)r r[r$r[r\r[)r\r[))r-r[r\r)r- int | Noner\z list[AnyStr])r*rr\r)r8zIterable[AnyStr]r\rr=)rEr`r\r[)r\zContainerIO[AnyStr])rLobjectr\r])r\r)r\r])__name__ __module__ __qualname____doc__rrrioSEEK_SETrr&r(r,r5r9r;r@rCrFrHrMrOrTrVrXrKrrrr r st "-/KK*"&$$$$ rr ) __future__rrfcollections.abcrtypingrrrr rrrrks( # $''V"V*Vr