ó
    Ö›‘hÐ%  ã                   ó¬   • S r SSKrSSKrSSKrSSKr " S S\R                  5      r " S S5      r " S S\5      r	 " S	 S
\5      r
SrS rS rSS jrg)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                   ó   • \ rS rSrSrS rSrg)ÚChunkingZipFileé   zr
A L{zipfile.ZipFile} object which, with L{readfile}, also gives you access
to a file-like object for each entry.
c                 ó¨  • U R                   S;  a  [        S5      eU R                  (       d  [        S5      eU R                  U5      nU R                  R	                  UR
                  S5        U R                  R                  [        R                  5      nUSS [        R                  :w  a  [        R                  " S5      e[        R                  " [        R                  U5      nU R                  R                  U[        R                     5      nU[        R                     (       a,  U R                  R                  U[        R                     5        UR                   S-  (       a  UR#                  S5      nOUR#                  S	5      nXRR$                  :w  a)  [        R                  " S
UR$                  < SU< S35      eUR&                  [        R(                  :X  a  [+        XR,                  5      $ UR&                  [        R.                  :X  a  [1        XR,                  5      $ [        R                  " SUR&                  U4-  5      e)z#
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         Ú\C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/python/zipstream.pyÚreadfileÚChunkingZipFile.readfile   s»  € ð �9‰9˜JÓ&ÜÐ@ÓAÐAØ�w�wÜÐTÓUÐUØ—‘˜TÓ"ˆà�‰�‰�U×(Ñ(¨!Ô,à—'‘'—,‘,œw×5Ñ5Ó6ˆØ�1�Qˆ<œ7×3Ñ3Ó3Ü×$Ò$Ð%GÓHÐHä—-’-¤× 8Ñ 8¸'ÓBˆØ—‘—‘˜W¤W×%@Ñ%@ÑAÓBˆà”7×1Ñ1×2Ø�G‰G�L‰L˜¤×!?Ñ!?Ñ@ÔAà�?‰?˜U×"àŸ™ WÓ-‰IàŸ™ WÓ-ˆIà×+Ñ+Ó+Ü×$Ó$à×&Ô&«	ð3óð ð
 ×Ñ¤'×"4Ñ"4Ó4Ü ×&9Ñ&9Ó:Ð:Ø× Ñ ¤G×$8Ñ$8Ó8Ü'¨×.AÑ.AÓBÐBä×$Ò$Ø?Ø×&Ñ&¨Ð-ñ.óð ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   Ú__static_attributes__r.   r-   r*   r   r      s   † ñõ
*r-   r   c                   óX   • \ rS rSrSrS rS rS rS rS r	\	r
S rS	 rS
 rS rS rSrg)Ú
_FileEntryéC   aá  
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                 ón   • Xl         U R                   R                  U l        X l        SU l        SU l        g)z3
Create a L{_FileEntry} from a L{ChunkingZipFile}.
r   FN)ÚchunkingZipFiler   ÚlengthÚfinishedÚclosed©r$   r9   r:   s      r*   Ú__init__Ú_FileEntry.__init__[   s0   € ð  /ÔØ×&Ñ&×)Ñ)ˆŒØŒØˆŒØˆ�r-   c                 ó   • g)z4
Returns false because zip files should not be ttys
Fr.   ©r$   s    r*   ÚisattyÚ_FileEntry.isattye   s   € ð r-   c                 ó$   • SU l         SU l        U ?g)z
Close self (file-like object)
Té   N)r<   r;   r   rA   s    r*   ÚcloseÚ_FileEntry.closek   s   € ð ˆŒØˆŒØ‰Gr-   c                 óT   ^ • Sn[        U 4S jS5       H  nX-  nUS:X  d  M    U$    U$ )z
Read a line.
r-   c                  ó&   >• T R                  S5      $ )NrE   )r   rA   s   €r*   Ú<lambda>Ú%_FileEntry.readline.<locals>.<lambda>x   s   ø€  §¡¨1¤r-   ó   
)Úiter)r$   ÚlineÚbytes   `  r*   ÚreadlineÚ_FileEntry.readlines   s9   ø€ ð ˆÜÔ-¨sÖ3ˆDØ‰LˆDØ�u�}ØØˆñ	 4ð ˆr-   c                 óH   • U R                  5       nU(       a  U$ [        5       e)zQ
Implement next as file does (like readline, except raises StopIteration
at EOF)
)rP   ÚStopIteration)r$   Únextlines     r*   Ú__next__Ú_FileEntry.__next__~   s   € ð
 —=‘=“?ˆÞØˆOÜ‹oÐr-   c                 ó   • [        U 5      $ )z!
Returns a list of all the lines
)ÚlistrA   s    r*   Ú	readlinesÚ_FileEntry.readlines‹   s   € ô �D‹zÐr-   c                 ó   • U $ ©z
Returns an iterator (so self)
r.   rA   s    r*   Ú
xreadlinesÚ_FileEntry.xreadlines‘   ó	   € ð ˆr-   c                 ó   • U $ r\   r.   rA   s    r*   Ú__iter__Ú_FileEntry.__iter__—   r_   r-   c                 ó   • U $ ©Nr.   rA   s    r*   Ú	__enter__Ú_FileEntry.__enter__�   s   € Øˆr-   c                 ó$   • U R                  5         g rd   )rF   )r$   Úexc_typeÚ	exc_valueÚ	tracebacks       r*   Ú__exit__Ú_FileEntry.__exit__    s   € Ø�
‰
�r-   )r9   r<   r;   r   r:   N)r/   r0   r1   r2   r3   r>   rB   rF   rP   rU   ÚnextrY   r]   ra   re   rk   r4   r.   r-   r*   r6   r6   C   s@   † ñò.òòò	òð €Dòòòòõr-   r6   c                   ó.   • \ rS rSrSrS rS rSS jrSrg)	r    é¤   zB
File-like object used to read an uncompressed entry in a ZipFile
c                 ó>   • [         R                  XU5        SU l        g )Nr   )r6   r>   Ú	readBytesr=   s      r*   r>   ÚZipFileEntry.__init__©   s   € Ü×Ñ˜D°6Ô:Øˆ�r-   c                 ó   • U R                   $ rd   )rq   rA   s    r*   ÚtellÚZipFileEntry.tell­   s   € Ø�~‰~Ðr-   Nc                 ó”  • Uc  U R                   U R                  -
  nUS:X  d  U R                  (       a  gU R                  R                  R                  [        XR                   U R                  -
  5      5      nU =R                  [        U5      -  sl        U R                  U R                   :X  d  [        U5      U:  a  SU l        U$ )Nr   r-   rE   )r:   rq   r;   r9   r   r   ÚminÚlen)r$   ÚnÚdatas      r*   r   ÚZipFileEntry.read°   s�   € Ø‰9Ø—‘˜dŸn™nÑ,ˆAØ�‹6�T—]—]ØØ×#Ñ#×&Ñ&×+Ñ+¬C°·;±;ÀÇÁÑ3OÓ,PÓQˆØ�Šœ#˜d›)Ñ#�Ø�>‰>˜TŸ[™[Ó(¬C°«I¸«MØˆDŒMØˆr-   )r;   rq   rd   ©	r/   r0   r1   r2   r3   r>   rt   r   r4   r.   r-   r*   r    r    ¤   s   † ñòò÷	r-   r    c                   ó.   • \ rS rSrSrS rS rSS jrSrg)	r#   é¼   z=
File-like object used to read a deflated entry in a ZipFile
c                 ó�   • [         R                  XU5        SU l        SU l        [        R
                  " S5      U l        SU l        g )Nr   iñÿÿÿr-   )r6   r>   ÚreturnedBytesrq   ÚzlibÚdecompressobjÚdecompÚbufferr=   s      r*   r>   ÚDeflatedZipFileEntry.__init__Á   s:   € Ü×Ñ˜D°6Ô:ØˆÔØˆŒÜ×(Ò(¨Ó-ˆŒØˆ�r-   c                 ó   • U R                   $ rd   )r€   rA   s    r*   rt   ÚDeflatedZipFileEntry.tellÈ   s   € Ø×!Ñ!Ð!r-   Nc                 ó<  • U R                   (       a  gUGc  U R                  /nUR                  U R                  R	                  U R
                  R                  R                  U R                  U R                  -
  5      5      5        UR                  U R                  R	                  S5      5        UR                  U R                  R                  5       5        SU l        SU l         SR                  U5      nU =R                  [        U5      -  sl        U$ [        U R                  5      U:  Ga'  U R
                  R                  R                  [        USU R                  U R                  -
  5      5      nU =R                  [        U5      -  sl	        U(       dq  U R                  U R                  R	                  S5      -   U R                  R                  5       -   nSU l         SU l        U =R                  [        U5      -  sl        U$ U =R                  U R                  R	                  U5      -  sl        [        U R                  5      U:  a  GM'  U R                  S U nU R                  US  U l        U =R                  [        U5      -  sl        U$ )Nr-   ó   ZrE   i   )r;   r„   Úappendrƒ   Ú
decompressr9   r   r   r:   rq   ÚflushÚjoinr€   rx   rw   )r$   ry   Úresultrz   s       r*   r   ÚDeflatedZipFileEntry.readË   s÷  € Ø�=�=ØØŠ9à—‘ðˆFð �M‰MØ—‘×&Ñ&Ø×(Ñ(×+Ñ+×0Ñ0°·±¸t¿~¹~Ñ1MÓNóôð
 �M‰M˜$Ÿ+™+×0Ñ0°Ó6Ô7Ø�M‰M˜$Ÿ+™+×+Ñ+Ó-Ô.ØˆDŒKØˆDŒMØ—X‘X˜fÓ%ˆFØ×Ò¤# f£+Ñ-ÕØˆMä�d—k‘kÓ" QÔ&Ø×+Ñ+×.Ñ.×3Ñ3Ü˜˜4 §¡¨t¯~©~Ñ!=Ó>ó�ð —’¤# d£)Ñ+•ÞàŸ™ d§k¡k×&<Ñ&<¸TÓ&BÑBÀTÇ[Á[×EVÑEVÓEXÑXð ð %&�D”MØ"%�D”KØ×&Ò&¬#¨f«+Ñ5Õ&Ø!�Mà—K’K 4§;¡;×#9Ñ#9¸$Ó#?Ñ?•Kô �d—k‘kÓ" QÖ&ð —[‘[  !�_ˆFØŸ+™+ a b˜/ˆDŒKØ×Ò¤# f£+Ñ-ÕØˆMr-   )r„   rƒ   r;   rq   r€   rd   r|   r.   r-   r*   r#   r#   ¼   s   † ñòò"÷&r-   r#   r   c                 ój   • Sn[        U 5      nUR                  5        H  nU[        XA5      -  nM     U$ )zf
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˜   ÷   s8   € ð
 €KÜ	˜Ó	"€BØ—‘–ˆØ” tÓ7Ñ7Šñ àÐr-   c                 ó^   • [        U R                  U5      u  p#US:”  a  US-  nU=(       d    S$ )a  
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   rE   )ÚdivmodÚ	file_size)Úzipinfor”   ÚcountÚextras       r*   r’   r’     s2   € ô ˜'×+Ñ+¨YÓ7�L€EØˆqƒyØ�‰
ˆØ�:�AÐr-   c              #   óÄ  #   • [        U S5      n[        R                  R                  U5      (       d  [        R                  " U5        [        X5      nUR                  5       nUR                  5       n[        Xg5       GHÈ  u  p‰U	R                  [        -  n
[        R                  R                  X5      nU
(       aE  [        R                  R                  U5      (       d  [        R                  " U5        US-  nUv •  M„  [        R                  R                  U5      S   n[        R                  R                  U5      (       d  [        R                  " U5        U(       d$  [        R                  R                  U5      (       d«  UR                  U5      nU	R                  S:X  a	  US-  nUv •  [        US5       nUR!                  5       U	R                  :  aK  UR#                  U5      nUR%                  U5        US-  nUv •  UR!                  5       U	R                  :  a  MK  SSS5        GM¶  U['        X“5      -  nUv •  GMË     g! , (       d  f       GMÞ  = f7f)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   rE   r   ÚwbN)r   ÚosÚpathÚexistsÚmakedirsr˜   Únamelistr‘   ÚzipÚexternal_attrÚDIR_BITr�   Úsplitr+   r›   Úopenrt   r   Úwriter’   )r“   Ú	directoryÚ	overwriter”   ÚczfÚ	remainingÚnamesÚinfosÚentryr—   ÚisdirÚfÚfdirr   ÚoutfileÚhunks                   r*   ÚunzipIterChunkyr¸     s¦  é € ô ˜( CÓ
(€CÜ�7‰7�>‰>˜)×$Ñ$Ü
�Š�IÔÜ" 8Ó7€IØ�L‰L‹N€EØ�L‰L‹N€Eä˜5×(‰ˆØ×"Ñ"¤WÑ,ˆÜ�G‰G�L‰L˜Ó*ˆÞä—7‘7—>‘> !×$Ñ$Ü—’˜A”Ø˜‰NˆIØŒOô —7‘7—=‘= Ó# AÑ&ˆDÜ—7‘7—>‘> $×'Ñ'Ü—’˜DÔ!Þ¤§¡§¡¨q× 1Ñ 1Ø—\‘\ %Ó(�Ø—>‘> QÓ&Ø ‘N�IØ#’OÜ˜!˜T”] gØŸ'™'›) d§n¡nÓ4Ø!Ÿw™w yÓ1˜ØŸ™ dÔ+Ø! Q™˜	Ø'šð	 Ÿ'™'›) d§n¡nÕ4÷ #’]ð œ_¨TÓ=Ñ=�	Ø•ò9 )÷( #—]üs   ‚F>I Ç A(IÈ*#I É
I	É	I )Ú.r   i   )r3   Úos.pathr¡   r   r   r�   ÚZipFiler   r6   r    r#   r¨   r˜   r’   r¸   r.   r-   r*   Ú<module>r¼      se   ðñ
ó
 Û Û Û ô0�g—o‘oô 0÷f^ñ ^ôB�:ô ô05˜:ô 5ðp €ò	òõ"+ r-   