Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/PIL/__pycache__/ImageFile.cpython-310.pyc

241 lines
19 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<EFBFBD>a<00>@sVddlmZddlZddlZddlZddlZddlZddlmZm Z m
Z
ddl m Z ddl mZddlmZdZd Zd
Z d d d ddd<10>Z d8dd<18>Zd9dd<1A>Zdd<1C>ZGdd<1E>de
<EFBFBD>ZGdd <20>d e j <0C>ZGd!d"<22>d"<22>ZGd#d$<24>d$e<19>ZGd%d&<26>d&<26>Zd:d;d(d)<29>Zd<d=d,d-<2D>Zd.d/<2F>ZGd0d1<64>d1<64>Z Gd2d3<64>d3<64>Z!Gd4d5<64>d5e!<21>Z"Gd6d7<64>d7e!<21>Z#dS)><3E>)<01> annotationsN)<03>IO<49>Any<6E>
NamedTuple<EFBFBD>)<01>Image)<01> deprecate)<01>is_pathiiFzimage buffer overrun errorzdecoding errorz unknown errorzbad configurationzout of memory error)<05><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD>error<6F>int<6E>encoder<65>bool<6F>return<72>OSErrorcCshztj<01>|<00>}Wntyt<04>|<00>}Ynw|s$|rdnd<02>d|<00><00>}|d|r*dnd<06>d<07>7}t|<02>S)Nr<00>decoderz error z when <20>writing<6E>readingz image file)r<00>core<72>getcodecstatus<75>AttributeError<6F>ERRORS<52>getr)rr<00>msg<73>r<00>O/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/PIL/ImageFile.py<70> _get_oserrorDs <02>rcCstdddd<04>t|dd<06><02>)N<> raise_oserror<6F> z<>It is only useful for translating error codes returned by a codec's decode() method, which ImageFile already does automatically.)<01>actionF<6E>r)rr)rrrrr Os <06> r cCs|dS)N<>r)<01>trrr<00> _tilesortYsr&c@s.eZdZUded<ded<ded<ded<d S)
<EFBFBD>_Tile<6C>str<74>
codec_name<EFBFBD>tuple[int, int, int, int]<5D>extentsr<00>offsetztuple[Any, ...] | str | None<6E>argsN)<04>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__annotations__rrrrr'^s
 r'csfeZdZdZd<16>fdd<04> Zddd<08>Z<05>fd d
<EFBFBD>Zdd d <0A>Zdd<0F>Zddd<11>Z ddd<13>Z
dd<15>Z <0B>Z S)<19> ImageFilez*Base class for image file format handlers.Nc s<>t<00><00><01>d|_d|_d|_ d|_d|_t|_t |<01>r)t
|d<04>|_ ||_ d|_ n ||_ ||_ d|_ z8z|<00><0E>WntttttjfyP}zt|<03>|<03>d}~ww|jrb|jddksb|jddkrhd}t|<04><01>WdStyz|j ry|j <0B><19><00>w)Nrrr<00>rbTznot identified by this driver)<1A>super<65>__init__<5F>
_min_frame<EFBFBD>custom_mimetype<70>tile<6C>readonly<6C> decoderconfig<69>MAXBLOCK<43>decodermaxblockr <00>open<65>fp<66>filename<6D> _exclusive_fp<66>_open<65>
IndexError<EFBFBD> TypeError<6F>KeyError<6F>EOFError<6F>structr<00> SyntaxError<6F>mode<64>size<7A> BaseException<6F>close)<05>selfr>r?<00>vr<00><01> __class__rrr5msJ
   <0C>
<08><02>" <06> 
<02>zImageFile.__init__r<00>
str | NonecCs,|jr|jS|jdurtj<03>|j<01><05><00>SdS<00>N)r7<00>formatr<00>MIMEr<00>upper<65>rLrrr<00>get_format_mimetype<70>s

zImageFile.get_format_mimetypecsg|_t<01><00>|<01>dSrQ)r8r4<00> __setstate__)rL<00>staterNrrrW<00>szImageFile.__setstate__<5F>NonecCs|jr|j<01><02>d|_dS)zCheck file integrityN)r@r>rKrUrrr<00>verify<66>s

zImageFile.verifyc Cs<>|jdur d}t|<01><01>tj<02>|<00>}|js|Sd|_|jo"t|j<00>dk}|o*ttd<04> }d}z|j }d}Wn t
yA|j j }Ynwz|j }d}Wn t
yV|j j}Ynw|r<>|jd\}}} }
t|
t<10>rl|
ddf}
|dkr<>t|
<EFBFBD>dkr<>|
d|jkr<>|
dtjvr<>zSddl} t|j<05><01>} | j| <0C><15>d| jd <09>|_Wd<00>n1s<>wY| |jd|
d|j<04><17>kr<>d
}t|<01><01>tj<18>|j|j|| |
<EFBFBD>|_d}|jr<>d|j_Wnt
ttfy<>d|_Ynw|<00><1E>d } |j<04>s<>|jjt d <0C>z|j!}Wn t
<EFBFBD>y d }Ynwdd<0F>t"<22>#|jdd<11><00>D<00>|_|jD]<5D>\}}} }
|| <09>t<02>$|j||
|j%<25>}zw|<0F>&|j|<08>|j'<27>rJ|<0F>(|j <0B>|<0F>)d <0A>d} nW|} z||j*<2A>}Wn t+t,j-f<02>yt}zt.<2E>riWYd}~n8d}t|<01>|<12>d}~ww|<11>s<>t.<2E>r|n%dt|<10><01>d<15>}t|<01><01>||}|<0F>)|<10>\}} |dk<00>r<>n||d<01>}<10>qMW|<0F>/<2F><00>q|<0F>/<2F>wg|_||_0|<00>1<EFBFBD>|j2<6A>r<>|j3<6A>r<>|j <0B>4<EFBFBD>d|_ |j<04>s<>t.<2E>s<>| dk<00>r<>t5| dd<16><02>tj<02>|<00>S)z"Load image data based on tile listNzcannot load this imager<00>pypy_version_inforF<>raw<61>)<01>accesszbuffer is not large enoughr <00><01>key<65>cSsg|]
\}}t|<02>d<00>qS)r
)<01>list)<03>.0<EFBFBD>_<>tilesrrr<00>
<listcomp><3E>s
<EFBFBD><06>z"ImageFile.load.<locals>.<listcomp>cSs|d|d|dfS)Nrrr]r)r8rrr<00><lambda>sz ImageFile.load.<locals>.<lambda>Tzimage file is truncatedzimage file is truncated (z bytes not processed)r#)6r8rr<00>load<61>mapr?<00>len<65>hasattr<74>sys<79> load_readrr><00>read<61> load_seek<65>seek<65>
isinstancer(rH<00> _MAPMODES<45>mmapr=<00>fileno<6E> ACCESS_READrIr<00>
map_buffer<EFBFBD>im<69>palette<74>dirty<74> ImportError<6F> load_prepare<72>sortr&<00> tile_prefix<69> itertools<6C>groupby<62> _getdecoderr:<00>setimage<67>pulls_fd<66>setfd<66>decoder<rBrFr<00>LOAD_TRUNCATED_IMAGES<45>cleanupr9<00>load_endr@<00>!_close_exclusive_fp_after_loadingrKr)rLr<00>pixel<65>use_mmapr9rnrp<00> decoder_namer+r,r-rsr><00>err_code<64>prefixr<00>b<>s<>e<>nrrrrh<00>s<>
   <02>  <02>

  <1C> <06><04>
<02>
<02>
<02><08> <04>  
<08><02><06><02>
 <04><02>
  zImageFile.loadcCsT|jr|jj|jks|jj|jkrtj<04>|j|j<02>|_|jdkr(tj<03>|<00>dSdS)N<>P)rwrHrIrr<00>newrhrUrrrr{<s
"
<04>zImageFile.load_preparecC<01>dSrQrrUrrrr<>D<00>zImageFile.load_endcCsF||jkst|d<01>r|jdus||j|jkrd}t|<02><01>|<00><05>|kS)N<> _n_framesz attempt to seek outside sequence)r6rkr<><00>n_framesrE<00>tell)rL<00>framerrrr<00> _seek_checkPs
<02>
 zImageFile._seek_check)NN)rrP<00>rrY) r.r/r0<00>__doc__r5rVrWrZrhr{r<>r<><00> __classcell__rrrNrr2js
0 
 
 r2c@s&eZdZd dd<06>Zejd dd <09><04>Zd
S) <0A> StubHandlerrw<00> StubImageFilerrYcCr<>rQr<00>rLrwrrrr=a<00>zStubHandler.open<65> Image.ImagecCr<>rQrr<>rrrrhdr<>zStubHandler.loadN)rwr<>rrY)rwr<>rr<>)r.r/r0r=<00>abc<62>abstractmethodrhrrrrr<>`s
r<>c@s,eZdZdZd dd<05>Zdd<07>Zd d d
<EFBFBD>Zd S)r<>z<>
Base class for stub image loaders.
A stub loader is an image loader that can identify files of a
certain format, but relies on external code to load the file.
rrYcC<01> d}t|<01><01>)Nz+StubImageFile subclass must implement _open<65><01>NotImplementedError<6F>rLrrrrrAqszStubImageFile._opencCsT|<00><00>}|durd|j<01>d<02>}t|<02><01>|<01>|<00>}|dusJ<00>|j|_|j|_|<03><03>S)Nzcannot find loader for this z file)<06>_loadrRrrhrO<00>__dict__)rL<00>loaderr<00>imagerrrrhus
 zStubImageFile.load<61>StubHandler | NonecCr<>)z (Hook) Find actual image loader.z+StubImageFile subclass must implement _loadr<64>r<>rrrr<><00>szStubImageFile._loadNr<4E>)rr<>)r.r/r0r<>rArhr<>rrrrr<>is

 r<>c@s^eZdZUdZdZdZded<dZdZdZ dZ
ddd <09>Z d
d <0B>Z d d <0A>Z ddd<11>Zdd<13>ZdS)<16>Parserzj
Incremental image parser. This class implements the standard
feed/close consumer interface.
NzImage.Image | Noner<65>rrrYcCs|jdus Jd<02><01>dS)z<>
(Consumer) Reset the parser. Note that you can only call this
method immediately after you've created a parser; parser
instances cannot be reused.
Nzcannot reuse parsers)<01>datarUrrr<00>reset<65>sz Parser.resetc Cs<>|jrdS|jdur||_n|j||_|jri|jdkr=tt|j<01>|j<03>}|j|d<01>|_|j||_|jdks;|js=dS|j<02>|j<01>\}}|dkr_d|_d|_|dkr]d|_t|dd<05><02>dS|j|d<01>|_dS|jrndSzt <09>
|j<01><01> }t <0B> |<05>}Wd<00>n1s<>wYWn
t y<>YdSwt|d<06>p<>t|d<07>}|s<>t|j<0F>dkr<>d|_n:|<06><10>|jd\}}} }
g|_t <0B>|j||
|j<13>|_|j<02>|j|<04>| |_|jt|j<01>kr<>|j|jd<01>|_d|_||_dS)z<>
(Consumer) Feed data to the parser.
:param data: A string buffer.
:exception OSError: If the parser failed to parse the image file.
NrrFr#rorm)<16>finishedr<64>rr,<00>minrjr<>r<>r<00>io<69>BytesIOrr=rrkr8r{r<>rHr:r<>rw) rLr<><00>skipr<70>r<>r>rw<00>flag<61>d<>o<>arrr<00>feed<65>sX 
 
   <1C><04> <02>
z Parser.feedcCs|SrQrrUrrr<00> __enter__<5F>r<>zParser.__enter__r-<00>objectcGs |<00><00>dSrQ)rK<00>rLr-rrr<00>__exit__<5F>s zParser.__exit__c Cs<>|jr|<00>d<01>d|_|_|jsd}t|<01><01>|js d}t|<01><01>|jrOt<06>|j<02><01>}z t<08> |<02>|_W|j<05>
<EFBFBD>n|j<05>
<EFBFBD>wWd<00>|jS1sJwY|jS)a
(Consumer) Close the stream.
:returns: An image object.
:exception OSError: If the parser failed to parse the image file either
because it cannot be identified or cannot be
decoded.
raNzimage was incompletezcannot parse this image) rr<>r<>r<>rr<>r<>r<>rr=rh)rLrr>rrrrK<00>s$
 
<EFBFBD><10>z Parser.closer<65>)r-r<>rrY)r.r/r0r<><00> incrementalr<6C>r1r<>rr,r<>r<>r<>r<>r<>rKrrrrr<><00>s
 
L
 r<>rYc
Cs<>|<00><00>t|d<01>s d|_|jtd<03>tt||jdd<00>}z|<01><08>}|<01> <09>t
|||||<04>Wnt t j fyM}zt
||||d|<05>WYd}~nd}~wwt|d<07>rY|<01> <09>dSdS)z<>Helper to save image based on tile list
:param im: Image object.
:param fp: File object.
:param tile: Tile list.
:param bufsize: Optional buffer size
<20> encoderconfigrr_r<00>N<>flush)rhrkr<>r|r&<00>maxr;rIrtr<><00> _encode_tilerr<><00>UnsupportedOperation)rwr>r8<00>bufsize<7A>fh<66>excrrr<00>_saves 
 <08><02>
 <04>r<EFBFBD>r8<00> list[_Tile]c Cs<>|D]c\}}}} |dkr|<01>|<08>t<01>|j|| |j<04>}
zE|
<EFBFBD>|j|<07>|
jr2|
<EFBFBD>|<01>|
<EFBFBD> <09>d} n|rJ |
<EFBFBD>
|<03>dd<00>\} } |<01> | <0C>| rHnq5n|
<EFBFBD> ||<03>} | dkr[t | dd<04>|<05>W|
<EFBFBD><0E>q|
<EFBFBD><0E>wdS)NrrTr#)rpr<00> _getencoderrHr<>r<>rw<00> pushes_fdr<64><00>encode_to_pyfd<66>encode<64>write<74>encode_to_filerr<>) rwr>r8r<>r<>r<><00> encoder_namer+r,r-r<00>errcoder<65>rrrr<>,s.


<02> <02><04>r<EFBFBD>cCs<>|dkrdS|tkr|<00>|<01>}t|<02>|krd}t|<03><01>|Sg}|}|dkr?|<00>t|t<00><02>}|s0n|<02>|<05>|t|<05>8}|dks%tdd<05>|D<00><01>|krPd}t|<03><01>d<02>|<02>S)a<>
Reads large blocks in a safe way. Unlike fp.read(n), this function
doesn't trust the user. If the requested size is larger than
SAFEBLOCK, the file is read block by block.
:param fp: File handle. Must implement a <b>read</b> method.
:param size: Number of bytes to read.
:returns: A string containing <i>size</i> bytes of data.
Raises an OSError if the file is truncated and the read cannot be completed
rrazTruncated File Readcss<00>|]}t|<01>VqdSrQ)rj)rcr<>rrr<00> <genexpr>ds<02>z_safe_read.<locals>.<genexpr>)<08> SAFEBLOCKrnrjrr<><00>append<6E>sum<75>join)r>rIr<>r<00>remaining_size<7A>blockrrr<00>
_safe_readGs* 
 
 <08>
r<>c@s eZdZd dd<04>Zd
dd<07>ZdS) <0B> PyCodecStaterrYcCsd|_d|_d|_d|_dS)Nr)<04>xsize<7A>ysize<7A>xoff<66>yoffrUrrrr5ks
zPyCodecState.__init__r*cCs |j|j|j|j|j|jfSrQ)r<>r<>r<>r<>rUrrrr+qs zPyCodecState.extentsNr<4E>)rr*)r.r/r0r5r+rrrrr<>js
r<>c@sDeZdZUded<dd<04>Zdd<06>Zdd d
<EFBFBD>Zd d <0C>Zdddd<11>Zd S)<15>PyCodeczIO[bytes] | None<6E>fdcGs(d|_t<01>|_d|_||_|<00>|<02>dSrQ)rwr<>rXr<>rH<00>init)rLrHr-rrrr5xs
zPyCodec.__init__cC<01>
||_dS)z<>
Override to perform codec specific initialization
:param args: Array of args items from the tile entry
:returns: None
N)r-r<>rrrr<><00>
z PyCodec.initrrYcCsdS)zT
Override to perform codec specific cleanup
:returns: None
NrrUrrrr<><00>szPyCodec.cleanupcCr<>)z<>
Called from ImageFile to set the Python file-like object
:param fd: A Python file-like object
:returns: None
N)r<>)rLr<>rrrr<><00>r<>z PyCodec.setfdNr+<00> tuple[int, int, int, int] | NonecCs<>||_|r |\}}}}nd\}}}}|dkr%|dkr%|jj\|j_|j_n||j_||j_|||j_|||j_|jjdksE|jjdkrKd}t|<07><01>|jj|jj|jjdksg|jj|jj|jjdkrmd}t|<07><01>dS)z<>
Called from ImageFile to set the core output image for the codec
:param im: A core image object
:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
for this tile
:returns: None
)rrrrrzSize cannot be negativerz Tile cannot extend outside imageN)rwrIrXr<>r<>r<>r<><00>
ValueError)rLrwr+<00>x0<78>y0<79>x1<78>y1rrrrr<><00>s$    <04>zPyCodec.setimager<65>rQ)r+r<>rrY) r.r/r0r1r5r<>r<>r<>r<>rrrrr<>us

 r<>c@s8eZdZdZdZeddd<06><04>Zdd
d <0B>Zdddd<10>Zd S)<15> PyDecoderz<72>
Python implementation of a format decoder. Override this class and
add the decoding logic in the :meth:`decode` method.
See :ref:`Writing Your Own File Codec in Python<file-codecs-py>`
FrrcC<01>|jSrQ)<01> _pulls_fdrUrrrr<><00><00>zPyDecoder.pulls_fd<66>buffer<65>bytes<65>tuple[int, int]cC<01> d}t|<02><01>)a=
Override to perform the decoding process.
:param buffer: A bytes object with the data to be decoded.
:returns: A tuple of ``(bytes consumed, errcode)``.
If finished with decoding return -1 for the bytes consumed.
Err codes are from :data:`.ImageFile.ERRORS`.
zunavailable in base decoderr<72>)rLr<>rrrrr<><00><00> zPyDecoder.decodeNr<4E>rYcCsz|s|j}t<01>|jd|<02>}|jdusJ<00>|<03>|j|j<05><06><00>|<03>|<01>}|ddkr/d}t|<05><01>|ddkr;d}t|<05><01>dS)a
Convenience method to set the internal image from a stream of raw data
:param data: Bytes to be set
:param rawmode: The rawmode to be used for the decoder.
If not specified, it will default to the mode of the image
:returns: None
r\Nrznot enough image datarzcannot decode image data) rHrr<>rwr<>rXr+r<>r<>)rLr<><00>rawmoder<65>r<>rrrr<00>
set_as_raw<EFBFBD>s

  <04>zPyDecoder.set_as_raw<61>rr)r<>r<>rr<>rQ)r<>r<>rrY) r.r/r0r<>r<><00>propertyr<79>r<>r<>rrrrr<><00>s 
 r<>c@s>eZdZdZdZeddd<06><04>Zdd
d <0B>Zdd d<0E>Zdd<10>Z dS)<15> PyEncoderz<72>
Python implementation of a format encoder. Override this class and
add the decoding logic in the :meth:`encode` method.
See :ref:`Writing Your Own File Codec in Python<file-codecs-py>`
FrrcCr<>rQ)<01>
_pushes_fdrUrrrr<><00>r<>zPyEncoder.pushes_fdr<64>r<00>tuple[int, int, bytes]cCr<>)a 
Override to perform the encoding process.
:param bufsize: Buffer size.
:returns: A tuple of ``(bytes encoded, errcode, bytes)``.
If finished with encoding return 1 for the error code.
Err codes are from :data:`.ImageFile.ERRORS`.
zunavailable in base encoderr<72>)rLr<>rrrrr<>r<>zPyEncoder.encoder<65>cCs@|jsdS|<00>d<02>\}}}|r|jdusJ<00>|j<02>|<03>||fS)z<>
If ``pushes_fd`` is ``True``, then this method will be used,
and ``encode()`` will only be called once.
:returns: A tuple of ``(bytes consumed, errcode)``.
Err codes are from :data:`.ImageFile.ERRORS`.
)rr rN)r<>r<>r<>r<>)rL<00>bytes_consumedr<64>r<>rrrr<> s zPyEncoder.encode_to_pyfdcCsBd}|dkr|<00>|<02>\}}}|dkr|<01>||d<02><00>|dks|S)z<>
:param fh: File handle.
:param bufsize: Buffer size.
:returns: If finished successfully, return 0.
Otherwise, return an error code. Err codes are from
:data:`.ImageFile.ERRORS`.
rN)r<>r<>)rLr<>r<>r<><00>status<75>bufrrrr<>s <08>zPyEncoder.encode_to_fileNr<4E>)r<>rrr<>)rr<>)
r.r/r0r<>r<>r<>r<>r<>r<>r<>rrrrr<><00>s 

r<>)rrrrrr)rrrr)rr<>rQ)r8r<>)$<24>
__future__rr<>r<>r~rFrl<00>typingrrr<00>r<00>
_deprecater<00>_utilr r;r<>r<>rrr r&r'r2r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>rrrr<00><module>sL    <06>

 w 
# J3