§
    ÈtºfÐ%  ã                   óº   — d Z ddlZddlZddlZddlZ G d„ dej        ¦  «        Z G d„ d¦  «        Z G d„ de¦  «        Z	 G d	„ d
e¦  «        Z
dZd„ Zd„ Zdd„ZdS )zŸ
An incremental approach to unzipping files.  This allows you to unzip a little
bit of a file at a time, which means you can report progress as a file unzips.
é    Nc                   ó   — e Zd ZdZd„ ZdS )ÚChunkingZipFilez~
    A L{zipfile.ZipFile} object which, with L{readfile}, also gives you access
    to a file-like object for each entry.
    c                 ó  — | j         dvrt          d¦  «        ‚| j        st          d¦  «        ‚|                      |¦  «        }| j                             |j        d¦  «         | j                             t          j        ¦  «        }|dd…         t          j	        k    rt          j
        d¦  «        ‚t          j        t          j        |¦  «        }| j                             |t          j                 ¦  «        }|t          j                 r*| j                             |t          j                 ¦  «         |j        dz  r|                     d¦  «        }n|                     d	¦  «        }||j        k    r t          j
        d
|j        ›d|›d�¦  «        ‚|j        t          j        k    rt+          | |j        ¦  «        S |j        t          j        k    rt1          | |j        ¦  «        S t          j
        d|j        |fz  ¦  «        ‚)z3
        Return file-like object for name.
        )ÚrÚazread() requires mode "r" or "a"z3Attempt to read ZIP archive that was already closedr   é   z Bad magic number for file headeri   zutf-8Úcp437zFile name in directory "z" and header "z	" differ.z-Unsupported compression method %d for file %s)ÚmodeÚRuntimeErrorÚfpÚgetinfoÚseekÚheader_offsetÚreadÚzipfileÚsizeFileHeaderÚstringFileHeaderÚ
BadZipFileÚstructÚunpackÚstructFileHeaderÚ_FH_FILENAME_LENGTHÚ_FH_EXTRA_FIELD_LENGTHÚ	flag_bitsÚdecodeÚorig_filenameÚcompress_typeÚ
ZIP_STOREDÚZipFileEntryÚcompress_sizeÚZIP_DEFLATEDÚDeflatedZipFileEntry)ÚselfÚnameÚzinfoÚfheaderÚfnameÚ	fname_strs         úW/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/zipstream.pyÚreadfilezChunkingZipFile.readfile   sà  € ð Œ9˜JÐ&Ð&ÝÐ@ÑAÔAÐAØŒwð 	VÝÐTÑUÔUÐUØ—’˜TÑ"Ô"ˆàŒ�Š�UÔ(¨!Ñ,Ô,Ð,à”'—,’,�wÔ5Ñ6Ô6ˆØ�1�Q�3Œ<�7Ô3Ò3Ð3ÝÔ$Ð%GÑHÔHÐHå”-¥Ô 8¸'ÑBÔBˆØ”—’˜W¥WÔ%@ÔAÑBÔBˆà•7Ô1Ô2ð 	BØŒG�LŠL˜¥Ô!?Ô@ÑAÔAÐAàŒ?˜UÑ"ð 	.àŸš WÑ-Ô-ˆIˆIàŸš WÑ-Ô-ˆIà˜Ô+Ò+Ð+ÝÔ$Ð$àÔ&Ð&Ð&¨	¨	¨	ð3ñô ð ð
 Ô¥'Ô"4Ò4Ð4Ý  eÔ&9Ñ:Ô:Ð:ØÔ ¥GÔ$8Ò8Ð8Ý'¨¨eÔ.AÑBÔBÐBåÔ$Ø?ØÔ&¨Ð-ñ.ñô ð ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r*   © r+   r)   r   r      s-   € € € € € ðð ð
*ð *ð *ð *ð *r+   r   c                   óR   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZeZ	d„ Z
d„ Zd	„ Zd
„ Zd„ ZdS )Ú
_FileEntrya!  
    Abstract superclass of both compressed and uncompressed variants of
    file-like objects within a zip archive.

    @ivar chunkingZipFile: a chunking zip file.
    @type chunkingZipFile: L{ChunkingZipFile}

    @ivar length: The number of bytes within the zip file that represent this
    file.  (This is the size on disk, not the number of decompressed bytes
    which will result from reading it.)

    @ivar fp: the underlying file object (that contains pkzip data).  Do not
    touch this, please.  It will quite likely move or go away.

    @ivar closed: File-like 'closed' attribute; True before this file has been
    closed, False after.
    @type closed: L{bool}

    @ivar finished: An older, broken synonym for 'closed'.  Do not touch this,
    please.
    @type finished: L{int}
    c                 ó`   — || _         | j         j        | _        || _        d| _        d| _        dS )zC
        Create a L{_FileEntry} from a L{ChunkingZipFile}.
        r   FN)ÚchunkingZipFiler   ÚlengthÚfinishedÚclosed©r#   r4   r5   s      r)   Ú__init__z_FileEntry.__init__[   s2   € ð  /ˆÔØÔ&Ô)ˆŒØˆŒØˆŒØˆŒˆˆr+   c                 ó   — dS )zD
        Returns false because zip files should not be ttys
        Fr0   ©r#   s    r)   Úisattyz_FileEntry.isattye   s	   € ð ˆur+   c                 ó&   — d| _         d| _        | `dS )z/
        Close self (file-like object)
        Té   N)r7   r6   r   r;   s    r)   Úclosez_FileEntry.closek   s   € ð ˆŒØˆŒØˆGˆGˆGr+   c                 óR   ‡ — d}t          ˆ fd„d¦  «        D ]}||z  }|dk    r nŒ|S )z
        Read a line.
        r+   c                  ó.   •— ‰                       d¦  «        S )Nr>   )r   r;   s   €r)   ú<lambda>z%_FileEntry.readline.<locals>.<lambda>x   s   ø€  §¢¨1¡¤€ r+   ó   
)Úiter)r#   ÚlineÚbytes   `  r)   Úreadlinez_FileEntry.readlines   sN   ø€ ð ˆÝÐ-Ð-Ð-Ð-¨sÑ3Ô3ð 	ð 	ˆDØ�D‰LˆDØ�uŠ}ˆ}Ø�ð àˆr+   c                 óN   — |                       ¦   «         }|r|S t          ¦   «         ‚)zi
        Implement next as file does (like readline, except raises StopIteration
        at EOF)
        )rG   ÚStopIteration)r#   Únextlines     r)   Ú__next__z_FileEntry.__next__~   s(   € ð
 —=’=‘?”?ˆØð 	ØˆOÝ‰oŒoÐr+   c                 ó    — t          | ¦  «        S )z1
        Returns a list of all the lines
        )Úlistr;   s    r)   Ú	readlinesz_FileEntry.readlines‹   s   € õ �D‰zŒzÐr+   c                 ó   — | S ©z/
        Returns an iterator (so self)
        r0   r;   s    r)   Ú
xreadlinesz_FileEntry.xreadlines‘   ó	   € ð ˆr+   c                 ó   — | S rP   r0   r;   s    r)   Ú__iter__z_FileEntry.__iter__—   rR   r+   c                 ó   — | S ©Nr0   r;   s    r)   Ú	__enter__z_FileEntry.__enter__�   s   € Øˆr+   c                 ó.   — |                       ¦   «          d S rV   )r?   )r#   Úexc_typeÚ	exc_valueÚ	tracebacks       r)   Ú__exit__z_FileEntry.__exit__    s   € Ø�
Š
‰Œˆˆˆr+   N)r,   r-   r.   r/   r9   r<   r?   rG   rK   ÚnextrN   rQ   rT   rW   r\   r0   r+   r)   r2   r2   C   s»   € € € € € ðð ð.ð ð ðð ð ðð ð ð	ð 	ð 	ðð ð ð €Dðð ð ðð ð ðð ð ðð ð ðð ð ð ð r+   r2   c                   ó&   — e Zd ZdZd„ Zd„ Zdd„ZdS )r   zJ
    File-like object used to read an uncompressed entry in a ZipFile
    c                 óL   — t                                | ||¦  «         d| _        d S )Nr   )r2   r9   Ú	readBytesr8   s      r)   r9   zZipFileEntry.__init__©   s%   € Ý×Ò˜D /°6Ñ:Ô:Ð:ØˆŒˆˆr+   c                 ó   — | j         S rV   )r`   r;   s    r)   ÚtellzZipFileEntry.tell­   s
   € ØŒ~Ðr+   Nc                 óH  — |€| j         | j        z
  }|dk    s| j        rdS | j        j                             t          || j         | j        z
  ¦  «        ¦  «        }| xj        t          |¦  «        z  c_        | j        | j         k    st          |¦  «        |k     rd| _        |S )Nr   r+   r>   )r5   r`   r6   r4   r   r   ÚminÚlen)r#   ÚnÚdatas      r)   r   zZipFileEntry.read°   s”   € Øˆ9Ø”˜dœnÑ,ˆAØ�Š6ˆ6�T”]ˆ6Ø�3ØÔ#Ô&×+Ò+­C°°4´;ÀÄÑ3OÑ,PÔ,PÑQÔQˆØˆŒ�#˜d™)œ)Ñ#ˆŒØŒ>˜Tœ[Ò(Ð(­C°©I¬I¸ªM¨MØˆDŒMØˆr+   rV   ©r,   r-   r.   r/   r9   rb   r   r0   r+   r)   r   r   ¤   sP   € € € € € ðð ðð ð ðð ð ð	ð 	ð 	ð 	ð 	ð 	r+   r   c                   ó&   — e Zd ZdZd„ Zd„ Zdd„ZdS )r"   zE
    File-like object used to read a deflated entry in a ZipFile
    c                 óš   — t                                | ||¦  «         d| _        d| _        t	          j        d¦  «        | _        d| _        d S )Nr   iñÿÿÿr+   )r2   r9   ÚreturnedBytesr`   ÚzlibÚdecompressobjÚdecompÚbufferr8   s      r)   r9   zDeflatedZipFileEntry.__init__Á   sF   € Ý×Ò˜D /°6Ñ:Ô:Ð:ØˆÔØˆŒÝÔ(¨Ñ-Ô-ˆŒØˆŒˆˆr+   c                 ó   — | j         S rV   )rk   r;   s    r)   rb   zDeflatedZipFileEntry.tellÈ   s   € ØÔ!Ð!r+   Nc                 óÊ  — | j         rdS |€ú| j        g}|                     | j                             | j        j                             | j        | j	        z
  ¦  «        ¦  «        ¦  «         |                     | j                             d¦  «        ¦  «         |                     | j         
                    ¦   «         ¦  «         d| _        d| _         d                     |¦  «        }| xj        t          |¦  «        z  c_        |S t          | j        ¦  «        |k     �r| j        j                             t          |d| j        | j	        z
  ¦  «        ¦  «        }| xj	        t          |¦  «        z  c_	        |si| j        | j                             d¦  «        z   | j         
                    ¦   «         z   }d| _         d| _        | xj        t          |¦  «        z  c_        |S | xj        | j                             |¦  «        z  c_        t          | j        ¦  «        |k     �°| j        d |…         }| j        |d …         | _        | xj        t          |¦  «        z  c_        |S )Nr+   ó   Zr>   i   )r6   ro   Úappendrn   Ú
decompressr4   r   r   r5   r`   ÚflushÚjoinrk   re   rd   )r#   rf   Úresultrg   s       r)   r   zDeflatedZipFileEntry.readË   s3  € ØŒ=ð 	Ø�3Øˆ9à”ðˆFð �MŠMØ”×&Ò&ØÔ(Ô+×0Ò0°´¸t¼~Ñ1MÑNÔNñô ñô ð ð
 �MŠM˜$œ+×0Ò0°Ñ6Ô6Ñ7Ô7Ð7Ø�MŠM˜$œ+×+Ò+Ñ-Ô-Ñ.Ô.Ð.ØˆDŒKØˆDŒMØ—X’X˜fÑ%Ô%ˆFØÐÔ¥# f¡+¤+Ñ-ÐÔØˆMå�d”kÑ"Ô" QÒ&Ñ&ØÔ+Ô.×3Ò3Ý˜˜4 ¤¨t¬~Ñ!=Ñ>Ô>ñô �ð �”¥# d¡)¤)Ñ+�”Øð 	@àœ d¤k×&<Ò&<¸TÑ&BÔ&BÑBÀTÄ[×EVÒEVÑEXÔEXÑXð ð %&�D”MØ"%�D”KØÐ&Ô&­#¨f©+¬+Ñ5Ð&Ô&Ø!�Mà�K”K 4¤;×#9Ò#9¸$Ñ#?Ô#?Ñ?�K”Kõ �d”kÑ"Ô" QÒ&Ñ&ð ”[  ! ”_ˆFØœ+ a b bœ/ˆDŒKØÐÔ¥# f¡+¤+Ñ-ÐÔØˆMr+   rV   rh   r0   r+   r)   r"   r"   ¼   sP   € € € € € ðð ðð ð ð"ð "ð "ð&ð &ð &ð &ð &ð &r+   r"   é   c                 ó|   — d}t          | ¦  «        }|                     ¦   «         D ]}|t          ||¦  «        z  }Œ|S )zr
    Predict the number of chunks that will be extracted from the entire
    zipfile, given chunksize blocks.
    r   )r   ÚinfolistÚcountFileChunks)ÚfilenameÚ	chunksizeÚtotalchunksÚzfÚinfos        r)   ÚcountZipFileChunksr�   ÷   sI   € ð
 €KÝ	˜Ñ	"Ô	"€BØ—’‘”ð 8ð 8ˆØ• t¨YÑ7Ô7Ñ7ˆˆØÐr+   c                 óP   — t          | j        |¦  «        \  }}|dk    r|dz  }|pdS )a9  
    Count the number of chunks that will result from the given C{ZipInfo}.

    @param zipinfo: a C{zipfile.ZipInfo} instance describing an entry in a zip
    archive to be counted.

    @return: the number of chunks present in the zip file.  (Even an empty file
    counts as one chunk.)
    @rtype: L{int}
    r   r>   )ÚdivmodÚ	file_size)Úzipinfor}   ÚcountÚextras       r)   r{   r{     s6   € õ ˜'Ô+¨YÑ7Ô7�L€Eˆ5Øˆq‚y€yØ�‰
ˆØˆ:�AÐr+   ú.é   c              #   ó¬  K  — t          | d¦  «        }t          j                             |¦  «        st          j        |¦  «         t          | |¦  «        }|                     ¦   «         }|                     ¦   «         }t          ||¦  «        D �]Ä\  }}	|	j	        t          z  }
t          j                             ||¦  «        }|
r=t          j                             |¦  «        st          j        |¦  «         |dz  }|V — Œtt          j                             |¦  «        d         }t          j                             |¦  «        st          j        |¦  «         |st          j                             |¦  «        sÀ|                     |¦  «        }|	j        dk    r	|dz  }|V — t          |d¦  «        5 }|                     ¦   «         |	j        k     rP|                     |¦  «        }|                     |¦  «         |dz  }|V — |                     ¦   «         |	j        k     °Pddd¦  «         n# 1 swxY w Y   �Œ­|t'          |	|¦  «        z  }|V — �ŒÆdS )zï
    Return a generator for the zipfile.  This implementation will yield after
    every chunksize uncompressed bytes, or at the end of a file, whichever
    comes first.

    The value it yields is the number of chunks left to unzip.
    r   r>   r   ÚwbN)r   ÚosÚpathÚexistsÚmakedirsr�   Únamelistrz   ÚzipÚexternal_attrÚDIR_BITrv   Úsplitr*   r„   Úopenrb   r   Úwriter{   )r|   Ú	directoryÚ	overwriter}   ÚczfÚ	remainingÚnamesÚinfosÚentryr€   ÚisdirÚfÚfdirr   ÚoutfileÚhunks                   r)   ÚunzipIterChunkyr£     s^  è è € õ ˜( CÑ
(Ô
(€CÝŒ7�>Š>˜)Ñ$Ô$ð Ý
Œ�IÑÔÐÝ" 8¨YÑ7Ô7€IØ�LŠL‰NŒN€EØ�LŠL‰NŒN€Eå˜5 %Ñ(Ô(ð  ñ  ‰ˆˆtØÔ"¥WÑ,ˆÝŒG�LŠL˜ EÑ*Ô*ˆØð 	 å”7—>’> !Ñ$Ô$ð Ý”˜A‘”�Ø˜‰NˆIØˆOˆOˆOˆOõ ”7—=’= Ñ#Ô# AÔ&ˆDÝ”7—>’> $Ñ'Ô'ð "Ý”˜DÑ!Ô!Ð!Øð  ¥¤§¢¨qÑ 1Ô 1ð  Ø—\’\ %Ñ(Ô(�Ø”> QÒ&Ð&Ø ‘N�IØ#�O�O�OÝ˜!˜T‘]”]ð ( gØŸ'š'™)œ) d¤nÒ4Ð4Ø!Ÿwšw yÑ1Ô1˜ØŸš dÑ+Ô+Ð+Ø! Q™˜	Ø'˜˜˜ð	 Ÿ'š'™)œ) d¤nÒ4Ð4ð(ð (ð (ñ (ô (ð (ð (ð (ð (ð (ð (øøøð (ð (ð (ð (ùð �_¨T°9Ñ=Ô=Ñ=�	Ø���‘ð9 ð  s   Æ4A.H.È.H2	È5H2	)rˆ   r   r‰   )r/   Úos.pathrŒ   r   r   rl   ÚZipFiler   r2   r   r"   r“   r�   r{   r£   r0   r+   r)   ú<module>r¦      s+  ðð
ð ð
 €€€Ø €€€Ø €€€Ø €€€ð0ð 0ð 0ð 0ð 0�g”oñ 0ô 0ð 0ðf^ð ^ð ^ð ^ð ^ñ ^ô ^ð ^ðBð ð ð ð �:ñ ô ð ð05ð 5ð 5ð 5ð 5˜:ñ 5ô 5ð 5ðp €ð	ð 	ð 	ðð ð ð"+ ð + ð + ð + ð + ð + r+   