
    F\h,\                       S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKr SSKr\R                  r SSKr SSKr/ SQr " S S\5      r " S S\5      r\=rrSrS	rS	rSrS
rSrSrSrSrSr Sr!Sr"Sr#Sr$\RJ                  " \#5      r&Sr'Sr(Sr)Sr*Sr+Sr,Sr-Sr.S
r/Sr0Sr1Sr2\RJ                  " \15      r3Sr4Sr5Sr6Sr7Sr8Sr9Sr:Sr;S
r<Sr=Sr>Sr?Sr@SrASrBS rCS!rDS"rES#rFSrGSrHS
rIS$rJS%rKS&rLS'rMS(rN\RJ                  " \M5      rOSrPSrQSrRSrSSrTSrUSrVSrWS
rXSrYSrZSr[S)r\S*r]\RJ                  " \\5      r^S+r_S,r`\RJ                  " \_5      raSrbSrcSrdSreSrfSrgSrhSriS
rjSrkS-rl " S. S/\m5      rnS0 roS1 rpS2 rqS3 rrS4 rs " S5 S65      rtSquS7 rvS8 rw " S9 S:5      rx " S; S<5      ry0 SS=_SS>_SS?_SS?_SS?_SS?_SS@_SSA_S
SB_SSC_SS@_SSD_SSE_S#SF_SGSH_SISJ_SKSL_rzSM r{S^SN jr|SO r} " SP SQ5      r~ " SR SS5      r " ST SU\GR                   5      r " SV SW\GR                   5      r " SX SY5      r " SZ S[\5      rS^S\ jrSS]KJrJr  g! \ a    Sr\R                  r GNf = f! \ a    Sr GN&f = f! \ a    Sr GN0f = f)_zP
Read and write ZIP files.

XXX references to utf-8 need further investigation.
    N)
BadZipFile
BadZipfileerror
ZIP_STOREDZIP_DEFLATED	ZIP_BZIP2ZIP_LZMA
is_zipfileZipInfoZipFile	PyZipFileLargeZipFilePathc                       \ rS rSrSrg)r   '    N)__name__
__module____qualname____firstlineno____static_attributes__r       '/usr/lib/python3.13/zipfile/__init__.pyr   r   '   s    r   r   c                       \ rS rSrSrSrg)r   +   zi
Raised when writing a zipfile, the zipfile requires ZIP64 extensions
and those extensions are disabled.
r   N)r   r   r   r   __doc__r   r   r   r   r   r   +   s    r   r   i              -   .   ?   s   <4s4H2LHs   PK                     	   z<4s4B4HL2L5H2Ls   PK
                         @   i   z<4s2B4HL2L2Hs   PKz<4sLQLs   PKz
<4sQ2H2L4Qs   PKiPKc                      ^  \ rS rSr\R
                  " S5      rS	U 4S jjrS	S jr\	S 5       r
\	S 5       r\	S 5       rSrU =r$ )
_Extra   <HHc                 "   > [         TU ]  X5      $ N)super__new__)clsvalid	__class__s      r   r=   _Extra.__new__   s    ws((r   c                     X l         g r;   r@   )selfr?   r@   s      r   __init___Extra.__init__   s    r   c                      U R                   R                  US S 5      u  p#U " US SU-    U5      USU-   S  4$ ! [        R                   a    S nSn N1f = f)Nr(   r   )FIELD_STRUCTunpackstructr   )r>   rawxidxlens       r   read_one_Extra.read_one   sl    	((//BQ8IC 3w$<%s1T67|33 || 	CD	s    9 AAc              #   z   #    [        U5      nU(       a%  [        R                  U5      u  p2Uv   U(       a  M$  g g 7fr;   )
memoryviewr7   rO   )r>   datarestextras       r   split_Extra.split   s0      $ //$/KEK ds   5;;c                 X   ^ SR                  U4S jU R                  U5       5       5      $ )z'Remove Extra fields with specified IDs.r   c              3   L   >#    U  H  nUR                   T;  d  M  Uv   M     g 7fr;   rD   ).0exxidss     r   	<genexpr>_Extra.strip.<locals>.<genexpr>   s&      
%uuD  B%s   $	$)joinrV   )r>   rS   r\   s     `r   strip_Extra.strip   s+     xx 
iio
 
 	
r   rD   r;   )r   r   r   r   rK   StructrI   r=   rF   classmethodrO   rV   r`   r   __classcell__rA   s   @r   r7   r7      sW    =='L) 4 4   
 
r   r7   c                 J     [        U 5      (       a  g g! [         a     gf = f)NTF)_EndRecDataOSErrorfps    r   _check_zipfilerk      s4    r??    s    
""c                     Sn [        U S5      (       a  [        U S9nU$ [        U S5       n[        U5      nSSS5        U$ ! , (       d  f       U$ = f! [         a     U$ f = f)zQuickly see if a file is a ZIP file by checking the magic number.

The filename argument may be a file or file-like object too.
Freadri   rbN)hasattrrk   openrh   )filenameresultrj   s      r   r
   r
      sx    
 F8V$$#x0F M	 h%'+ & M	 &% M  Ms2   A A AA 
AA A 
A"!A"c           
          U R                  U[        -
  S5        U R                  [        5      n[	        U5      [        :w  a  U$ [
        R                  " [        U5      u  pEpgU[        :w  a  U$ US:w  d  US:  a  [        S5      eU R                  U[        -
  [        -
  S5        U R                  [        5      n[	        U5      [        :w  a  U$ [
        R                  " [        U5      u
  pHpppnnU[        :w  a  U$ XB[        '   X[        '   X[        '   X[         '   X["        '   X[$        '   UU[&        '   U$ ! [         a    Us $ f = f)zE
Read the ZIP64 end-of-archive records and use that to update endrec
r&   r   r%   z3zipfiles that span multiple disks are not supported)seeksizeEndCentDir64Locatorrh   rm   lenrK   rJ   structEndArchive64LocatorstringEndArchive64Locatorr   sizeEndCentDir64structEndArchive64stringEndArchive64_ECD_SIGNATURE_ECD_DISK_NUMBER_ECD_DISK_START_ECD_ENTRIES_THIS_DISK_ECD_ENTRIES_TOTAL	_ECD_SIZE_ECD_OFFSET)fpinoffsetendrecrS   sigdisknoreloffdisksszcreate_versionread_versiondisk_numdisk_dirdircount	dircount2dirsize	diroffsets                    r   _EndRecData64r      sF   		&22A6 99,-D
4y++!'/H$!OC
''{eaiNOO 	IIf..1AA1E99%&D
4y$$ 	($/0C^8Wi
   !>'&?%-!"!*9#F;ME   s   D9 9EEc                    U R                  SS5        U R                  5       n U R                  [        * S5        U R	                  [        5      n[        U5      [        :X  aw  USS [        :X  aj  USS S:X  aa  [        R                  " [        U5      n[        U5      nUR                  S5        UR                  U[        -
  5        [        U [        * U5      $ [        U[        -
  [        -
  S5      nU R                  US5        U R	                  [        [        -   5      nUR                  [        5      nUS:  a  X%U[        -    n[        U5      [        :w  a  g[        [        R                  " [        U5      5      nU[            nX%[        -   U[        -   U-    nUR                  U5        UR                  XE-   5        [        XU-   U-
  U5      $ g! [         a     gf = f)zReturn data from the "End of Central Directory" record, or None.

The data is a list of the nine items in the ZIP "End of central dir"
record followed by a tenth item, the file seek offset of this record.r   r&   Nr(   s     r   )rt   tellsizeEndCentDirrh   rm   rv   stringEndArchiverK   rJ   structEndArchivelistappendr   maxZIP_MAX_COMMENTrfind_ECD_COMMENT_SIZE)	r   filesizerS   r   maxCommentStartstartrecDatacommentSizecomments	            r   rg   rg   '  s    	IIaOyy{H
		>/1% 99^$DD	^#Qq	%%RS	[ /6F| 	ch/0 TN?F;; (_4~EqIOIIoq!99_~56DJJ'(EzU>12w<>)fmm$4g>?./^+E.,@,LMgo-. TU#:X#E#% 	% W  s   G 
G"!G"c                    U R                  [        S5      5      nUS:  a  U SU n [        R                  S:w  a4  [        R                  U ;   a   U R	                  [        R                  S5      n [        R
                  (       aH  [        R
                  S:w  a4  [        R
                  U ;   a   U R	                  [        R
                  S5      n U $ )zvTerminate the file name at the first null byte and
ensure paths always use forward slashes as the directory separator.r   /)findchrossepreplacealtsep)rq   	null_bytes     r   _sanitize_filenamer   c  s     c!f%IA~Ai( 
vv}8+##BFFC0	yyRYY#%"))x*?##BIIs3Or   c                       \ rS rSrSrSrSS jr\S 5       r\R                  S 5       rS r
SS	 jrS
 rS r\SSS.S jj5       rS rSrg)r   iv  z>Class with attributes describing each file in the ZIP archive.)orig_filenamerq   	date_timecompress_typecompress_levelr   rU   create_systemr   extract_versionreserved	flag_bitsvolumeinternal_attrexternal_attrheader_offsetCRCcompress_size	file_size	_raw_time_end_offsetc                    Xl         [        U5      nXl        X l        US   S:  a  [	        S5      e[
        U l        S U l        SU l        SU l	        [        R                  S:X  a  SU l        OSU l        [        U l        [        U l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        S U l        g )Nr     z+ZIP does not support timestamps before 1980r   win32r'   )r   r   rq   r   
ValueErrorr   r   r   r   rU   sysplatformr   DEFAULT_VERSIONr   r   r   r   r   r   r   r   r   r   )rE   rq   r   s      r   rF   ZipInfo.__init__  s    % &h/ "Q<$JKK ("
<<7"!"D "#D-.r   c                     U R                   $ r;   r   rE   s    r   _compresslevelZipInfo._compresslevel  s    """r   c                     Xl         g r;   r   )rE   values     r   r   r     s    #r   c                 \   SU R                   R                  < SU R                  < 3/nU R                  [        :w  a<  UR                  S[        R                  U R                  U R                  5      -  5        U R                  S-	  nU R                  S-  nU(       a(  UR                  S[        R                  " U5      -  5        U(       a  UR                  SU-  5        U R                  5       nU(       a  U R                  (       a  UR                  SU R                  -  5        U(       a  U R                  (       aL  U R                  [        :w  d  U R                  U R                  :w  a  UR                  S	U R                  -  5        UR                  S
5        SR                  U5      $ )N<z
 filename= compress_type=%sr1   r   z filemode=%rz external_attr=%#xz file_size=%rz compress_size=%r> )rA   r   rq   r   r   r   compressor_namesgetr   statfilemodeis_dirr   r   r_   )rE   rr   hiloisdirs        r   __repr__ZipInfo.__repr__  s;   '+~~'>'>NO+MM-*..t/A/A/3/A/ACC D 2%&(MM.4==+<<=MM.34MM/DNN:;$,,:-^^t111MM-0B0BBCcwwvr   Nc                    U R                   nUS   S-
  S-  US   S-  -  US   -  nUS   S-  US	   S-  -  US   S-  -  nU R                  [        -  (       a  S=n=pgO$U R                  nU R                  nU R
                  nU R                  nSn	Uc  U[        :  =(       d	    U[        :  nU(       a?  S
n
U[        R                  " U
S[        R                  " U
5      S	-
  Xv5      -   nSnSn[        n	U R                  [        :X  a  [        [        U	5      n	O$U R                  [         :X  a  [        ["        U	5      n	[        XR$                  5      U l        [        XR&                  5      U l        U R)                  5       u  p[        R                  " [*        [,        U R$                  U R.                  UU R                  XCUXg[1        U5      [1        U5      5      nX-   U-   $ )zReturn the per-file header as a bytes object.

When the optional zip64 arg is None rather than a bool, we will
decide based upon the file_size and compress_size, if known,
False otherwise.
r   r   r,   r%   r)   r&   r'   r.   r(   z<HHQQ    )r   r   _MASK_USE_DATA_DESCRIPTORr   r   r   rU   ZIP64_LIMITrK   packcalcsizeZIP64_VERSIONr   r   r   BZIP2_VERSIONr	   LZMA_VERSIONr   r   _encodeFilenameFlagsstructFileHeaderstringFileHeaderr   rv   )rE   zip64dtdosdatedostimer   r   r   rU   min_versionfmtrq   r   headers                 r   
FileHeaderZipInfo.FileHeader  s    ^^a54<A%1
2RU:Q%2+1
*beqj9>>55.//C/-)((C ..MI

= +J}{/JECFKK()6??3+?+A9] ]E"I&M'K*m[9K8+lK8K";0D0DE!+/B/BC"779-/?!114==)!//3* ]CJ	8
  5((r   c                      U R                   R                  S5      U R                  4$ ! [         a1    U R                   R                  S5      U R                  [        -  4s $ f = f)Nasciiutf-8)rq   encoder   UnicodeEncodeError_MASK_UTF_FILENAMEr   s    r   r   ZipInfo._encodeFilenameFlags  s[    	V==''0$..@@! 	V==''0$..CU2UUU	Vs   &) 8A$#A$c                    U R                   n[        R                  n[        U5      S:  Ga:  U" SUS S 5      u  pEUS-   [        U5      :  a  [	        SXE4-  5      eUS:X  a  USUS-    n U R
                  S;   a  SnU" SUS S 5      u  U l        USS  nU R                  S	:X  a  S
nU" SUS S 5      u  U l        USS  nU R                  S	:X  a  SnU" SUS S 5      u  U l        OhUS:X  ab  USUS-    n U" SUS S 5      u  pUS:X  aE  X:X  a@  USS  R                  S5      n
U
(       a  [        U
5      U l        OSS KnUR                  SSS9  X%S-   S  n[        U5      S:  a  GM9  g g ! [        R                   a    [	        SW S35      S ef = f! [        R                   a  n[	        S5      UeS nAf[         a  n[	        S5      UeS nAff = f)Nr(   r9   z"Corrupt extra field %04x (size=%d)r%   )l    r   z	File sizez<Qr   r   zCompress sizezHeader offsetzCorrupt zip64 extra field. z not found.iup  z<BLr)   r   r   z'Empty unicode path extra field (0x7075)r&   
stacklevelz)Corrupt unicode path extra field (0x7075)z>Corrupt unicode path extra field (0x7075): invalid utf-8 bytes)rU   rK   rJ   rv   r   r   r   r   r   decoder   rq   warningswarnUnicodeDecodeError)rE   filename_crcrU   rJ   tplnrS   field
up_versionup_name_crcup_unicode_namer   es                r   _decodeExtraZipInfo._decodeExtra  s   

%jAoE5!9-FB!tc%j  !E!PQQV|Qr!t}F~~)MM +*0tBQx*@#ABx))[8 /.4T48.D+*#ABx))[8 /.4T48.D+* vQr!t}n.4UD!H.E+J!Q;+F*.qr(//'*B*,>,ODM+$MM*S`aMb Q$%LEO %jAoo& || F$'B(-wk&; <AEFF || Y$%PQWXX) n$%eflmmns8   +A9E( 4AF 9F (%FG$F00G=G		GTstrict_timestampsc                d   [        U[        R                  5      (       a  [        R                  " U5      n[        R                  " U5      n[        R
                  " UR                  5      n[        R                  " UR                  5      nUSS nU(       d  US   S:  a  SnOU(       d  US   S:  a  SnUc  Un[        R                  R                  [        R                  R                  U5      S   5      nUS   [        R                  [        R                  4;   a.  USS nUS   [        R                  [        R                  4;   a  M.  U(       a  US	-  nU " X'5      nUR                  S
-  S-  Ul        U(       a  SUl        U=R                  S-  sl        U$ UR"                  Ul        U$ )a7  Construct an appropriate ZipInfo for a file on the filesystem.

filename should be the path to a file or directory on the filesystem.

arcname is the name which it will have within the archive (by default,
this will be the same as filename, but without a drive letter and with
leading path separators removed).
r   r*   r   r   r%   r%   r   r   r   ;  )r  r         ;   r  Nr%   r   r   r1   )
isinstancer   PathLikefspathr   S_ISDIRst_modetime	localtimest_mtimepathnormpath
splitdriver   r   r   r   st_size)	r>   rq   arcnamer  str   mtimer   zinfos	            r   	from_fileZipInfo.from_file8  sW    h,,yy*HWWXRZZ(r{{+!AJ	 Yq\D%8-I"y|d':2I?G''""277#5#5g#>q#ABajRVVRYY//abkG ajRVVRYY//sNGG'!zzF2r9EO4'  !jjEOr   c                    U R                   R                  S5      (       a  g[        R                  R                  (       aM  U R                   R                  [        R                  R
                  [        R                  R                  45      $ g)z2Return True if this archive member is a directory.r   TF)rq   endswithr   r  r   r   r   s    r   r   ZipInfo.is_dir^  sT    ==!!#&&
 77>>==))277;;*GHHr   )r   r   r   r   r   r   r   r   r   rU   r   r   rq   r   r   r   r   r   r   )NoNamer  r;   )r   r   r   r   r   	__slots__rF   propertyr   setterr   r   r   r  rc   r%  r   r   r   r   r   r   r   v  sx    HI0  L # # $ $,.)`V+!Z #D # #J
r   r   c                 \    [        S5       H  nU S-  (       a
  U S-	  S-  n M  U S-  n M     U $ )Nr   r%   l    q[ )range)crcjs     r   _gen_crcr2  p  s5    1X7!8z)CAIC	 
 Jr   c                    ^^^^^^ SmSmSm[         c"  [        [        [        [	        S5      5      5      q [         mU4S jmUUUU4S jmU  H  nT" U5        M     UU4S jnU$ )NixV4igE#ixV4   c                 $   > US-	  TX-  S-     -  $ )z(Compute the CRC32 primitive on one byte.r      r   )chr0  crctables     r   crc32_ZipDecrypter.<locals>.crc32  s    qHch$%6777r   c                 \   > T" U T5      mTTS-  -   S-  mTS-  S-   S-  mT" TS-	  T5      mg )Nr6  r   ir%      r   )cr9  key0key1key2s    r   update_keys"_ZipDecrypter.<locals>.update_keys  sE    Q~t$
2y 1$
2TRZ&r   c                    > [        5       nUR                  nU  H(  nTS-  nX4US-  -  S-	  S-  -  nT" U5        U" U5        M*     [        U5      $ )zDecrypt a bytes object.r&   r%   r   r6  )	bytearrayr   bytes)rS   rr   r   r=  kr@  rA  s        r   	decrypter _ZipDecrypter.<locals>.decrypter  sZ    AqA!9"d**AN1I	 
 V}r   )	_crctabler   mapr2  r/  )	pwdprG  r9  r8  r>  r?  r@  rA  s	      @@@@@@r   _ZipDecrypterrM    sc    DDD XuSz23	H8' ' A 	 r   c                   ,    \ rS rSrS rS rS rS rSrg)LZMACompressori  c                     S U l         g r;   _compr   s    r   rF   LZMACompressor.__init__  s	    
r   c                 0   [         R                  " S[         R                  05      n[         R                  " [         R                  [         R
                  " [         R                  U5      /S9U l        [        R                  " SSS[        U5      5      U-   $ )Nr@   filtersz<BBHr,   r(   )
lzma_encode_filter_propertiesFILTER_LZMA1rO  
FORMAT_RAW_decode_filter_propertiesrR  rK   r   rv   )rE   propss     r   _initLZMACompressor._init  sq    ..d6G6G/HI((**4+<+<eDC
 
 {{61aU4u<<r   c                     U R                   c,  U R                  5       U R                   R                  U5      -   $ U R                   R                  U5      $ r;   )rR  r]  compressrE   rS   s     r   r`  LZMACompressor.compress  sA    ::::<$**"5"5d";;;zz""4((r   c                     U R                   c+  U R                  5       U R                   R                  5       -   $ U R                   R                  5       $ r;   )rR  r]  flushr   s    r   rd  LZMACompressor.flush  s=    ::::<$**"2"2"444zz!!r   rQ  N)	r   r   r   r   rF   r]  r`  rd  r   r   r   r   rO  rO    s    =)
"r   rO  c                        \ rS rSrS rS rSrg)LZMADecompressori  c                 .    S U l         SU l        SU l        g )Nr   F_decomp_unconsumedeofr   s    r   rF   LZMADecompressor.__init__  s    r   c           
      P   U R                   c  U =R                  U-  sl        [        U R                  5      S::  a  g[        R                  " SU R                  SS 5      u  n[        U R                  5      SU-   ::  a  g[
        R                  " [
        R                  [
        R                  " [
        R                  U R                  SSU-    5      /S9U l         U R                  SU-   S  nU ?U R                   R                  U5      nU R                   R                  U l        U$ )Nr(   r   z<Hr&   rU  )rj  rk  rv   rK   rJ   rW  rg  rZ  r[  rY  
decompressrl  )rE   rS   psizerr   s       r   ro  LZMADecompressor.decompress  s    <<$4##$)]]4)9)9!A)>?FE4##$E	100..t/@/@/3/?/?!e)/LNK DL ##AIJ/D ((.<<##r   ri  N)r   r   r   r   rF   ro  r   r   r   r   rg  rg    s    
r   rg  storeshrinkreduceimplodetokenizedeflate	deflate64bzip2rW  terse   lz77a   wavpackb   ppmdc                     U [         :X  a  g U [        :X  a  [        (       d  [        S5      eg U [        :X  a  [
        (       d  [        S5      eg U [        :X  a  [        (       d  [        S5      eg [        S5      e)Nz.Compression requires the (missing) zlib modulez-Compression requires the (missing) bz2 modulez.Compression requires the (missing) lzma modulez(That compression method is not supported)	r   r   zlibRuntimeErrorr   bz2r	   rW  NotImplementedError)compressions    r   _check_compressionr    s    j 		$t@B B  
		!s?A A  
	 t@B B  ""LMMr   c                 j   U [         :X  a]  Ub&  [        R                  " U[        R                  S5      $ [        R                  " [        R                  [        R                  S5      $ U [
        :X  a.  Ub  [        R                  " U5      $ [        R                  " 5       $ U [        :X  a
  [        5       $ g )N)
r   r  compressobjDEFLATEDZ_DEFAULT_COMPRESSIONr   r  BZ2Compressorr	   rO  )r   compresslevels     r   _get_compressorr     s    $$##M4==#FF : :DMM3OO	)	#$$$]33  ""	(	"r   c                 H   [        U 5        U [        :X  a  g U [        :X  a  [        R                  " S5      $ U [
        :X  a  [        R                  " 5       $ U [        :X  a
  [        5       $ [        R                  U 5      nU(       a  [        SX4-  5      e[        SU 4-  5      e)Nr  zcompression type %d (%s)zcompression type %d)r  r   r   r  decompressobjr   r  BZ2Decompressorr	   rg  r   r   r  )r   descrs     r   _get_decompressorr    s    }%
"	,	&!!#&&	)	#""$$	(	"!! $$]3%&@MCY&YZZ%&;}>N&NOOr   c                   :    \ rS rSrS rS rS	S jrS
S jrS rSr	g)_SharedFilei"  c                 b    Xl         X l        X0l        X@l        XPl        UR
                  U l        g r;   )_file_pos_close_lock_writingseekable)rE   fileposcloselockwritings         r   rF   _SharedFile.__init__#  s&    
	
r   c                     U R                   $ r;   )r  r   s    r   r   _SharedFile.tell+  s    yyr   c                    U R                      U R                  5       (       a  [        S5      eU[        R                  :X  a)  U R
                  R                  U R                  U-   5        OU R
                  R                  X5        U R
                  R                  5       U l        U R                  sS S S 5        $ ! , (       d  f       g = f)Nz}Can't reposition in the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)	r  r  r   r   SEEK_CURr  rt   r  r   )rE   r   whences      r   rt   _SharedFile.seek.  s    ZZ}}  "J K K $

		F 23

/

)DI99 ZZs   B#B::
Cc                 R   U R                      U R                  5       (       a  [        S5      eU R                  R	                  U R
                  5        U R                  R                  U5      nU R                  R                  5       U l        UsS S S 5        $ ! , (       d  f       g = f)NyCan't read from the ZIP file while there is an open writing handle on it. Close the writing handle before trying to read.)r  r  r   r  rt   r  rm   r   rE   nrS   s      r   rm   _SharedFile.read;  sp    ZZ}}  "J K K JJOODII&::??1%D

)DI ZZs   BB
B&c                 h    U R                   b%  U R                   nS U l         U R                  U5        g g r;   )r  r  )rE   fileobjs     r   r  _SharedFile.closeF  s-    ::!jjGDJKK  "r   )r  r  r  r  r  r  N)r   )
r   r   r   r   rF   r   rt   rm   r  r   r   r   r   r  r  "  s    &	!r   r  c                   2    \ rS rSrS rS rS rS rS rSr	g)		_TellableiM  c                     Xl         SU l        g Nr   rj   r   rE   rj   s     r   rF   _Tellable.__init__N  s    r   c                 f    U R                   R                  U5      nU =R                  U-  sl        U$ r;   )rj   writer   )rE   rS   r  s      r   r  _Tellable.writeR  s'    GGMM$qr   c                     U R                   $ r;   )r   r   s    r   r   _Tellable.tellW  s    {{r   c                 8    U R                   R                  5         g r;   )rj   rd  r   s    r   rd  _Tellable.flushZ      r   c                 8    U R                   R                  5         g r;   )rj   r  r   s    r   r  _Tellable.close]  r  r   r  N)
r   r   r   r   rF   r  r   rd  r  r   r   r   r   r  r  M  s    
r   r  c                      ^  \ rS rSrSrSrSrSr  SS jrS r	S r
SS	 jrSS
 jrS rSS jrS rS rS rS rU 4S jrS r\R,                  4S jrS rSrU =r$ )
ZipExtFileia  zOFile-like object for reading an archive member.
Is returned by ZipFile.open().
i   @i   i   c                    Xl         X@l        XPl        UR                  U l        UR
                  U l        UR                  U l        [        U R                  5      U l
        SU l        SU l        SU l        S U l        X l        UR                   U l        [%        US5      (       a"  UR&                  U l        [+        S5      U l        OS U l        SU l         UR1                  5       (       a`  UR3                  5       U l        UR
                  U l        UR                  U l        U R,                  U l        U R(                  U l        SU l        S U l         U(       ak  URB                  [D        -  (       a  URF                  S-	  S-  nOUR&                  S-	  S-  nU RI                  5       nXv:w  a  [K        S	URL                  -  5      eg g ! [>         a     Nf = f)
NFr   r   r   Tr   r6  r<  zBad password for file %r)'_fileobj_pwd_close_fileobjr   _compress_typer   _compress_leftr   _leftr  _decompressor_eof_readbuffer_offsetnewlinesmoderq   namero   r   _expected_crcr9  _running_crc	_seekabler  r   _orig_compress_start_orig_compress_size_orig_file_size_orig_start_crc	_orig_crcAttributeError
_decrypterr   r   r   _init_decrypterr  r   )rE   r  r  zipinforK  close_fileobj
check_bytehs           r   rF   ZipExtFile.__init__o  s   	+%33%33&&
.t/B/BC		$$	7E""!(D %c
D!%D		!!,3LLN)+2+@+@('.'8'8$'+'8'8$!%!3!3!%   #<<%//14<
 &kkR/47
$$&A"#=@U@U#UVV  	  		s   A5G 
GGc                     [        U R                  5      U l        U R                  R	                  S5      nU =R
                  S-  sl        U R                  U5      S   $ )Nr   r.   )rM  r  r  r  rm   r  )rE   r   s     r   r  ZipExtFile._init_decrypter  sM    '		2 ##B'r!v&r**r   c                    SU R                   R                  < SU R                   R                  < 3/nU R                  (       dp  UR	                  SU R
                  < 35        U R                  [        :w  a<  UR	                  S[        R                  U R                  U R                  5      -  5        OUR	                  S5        UR	                  S5        SR                  U5      $ )Nr   .z name=r   	 [closed]r   r   )rA   r   r   closedr   r  r  r   r   r   r_   rE   rr   s     r   r   ZipExtFile.__repr__  s    "nn77"nn99; <{{MM		34""j01.2243F3F373F3FHH I MM+&cwwvr   c                     US:  aP  U R                   R                  SU R                  5      S-   nUS:  a!  U R                   U R                  U nX l        U$ [        R                  R                  X5      $ )zbRead and return a line from the stream.

If limit is specified, at most limit bytes will be read.
r      
r%   )r  r   r  ioBufferedIOBasereadline)rE   limitilines       r   r  ZipExtFile.readline  sj     19  %%eT\\:Q>A1u''a8   ))$66r   c                 z   U[        U R                  5      U R                  -
  :  ap  U R                  U5      n[        U5      U R                  :  a(  X R                  U R                  S -   U l        SU l        OU =R                  [        U5      -  sl        U R                  U R                  U R                  S-    $ )z6Returns buffered bytes without advancing the position.Nr   i   )rv   r  r  rm   )rE   r  chunks      r   peekZipExtFile.peek  s    s4##$t||33IIaLE5zDLL(#(+;+;DLLM+J#J  E
* dllS.@AAr   c                 <    U R                   (       a  [        S5      eg)NI/O operation on closed file.T)r  r   r   s    r   readableZipExtFile.readable  s    ;;<==r   c                 "   U R                   (       a  [        S5      eUb  US:  aj  U R                  U R                  S nSU l        SU l        U R                  (       d0  X R                  U R                  5      -  nU R                  (       d  M0  U$ XR                  -   nU[        U R                  5      :  a!  U R                  U R                  U nX0l        U$ U[        U R                  5      -
  nU R                  U R                  S nSU l        SU l        US:  ar  U R                  (       da  U R                  U5      nU[        U5      :  a  X@l        Xl        X$SU -  n U$ X$-  nU[        U5      -  nUS:  a  U R                  (       d  Ma  U$ )z~Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and returned until EOF is reached.
zread from closed file.Nr   r   )r  r   r  r  r  _read1MAX_Nrv   )rE   r  bufendrS   s        r   rm   ZipExtFile.read  sa    ;;5669A""4<<=1C"DDLii{{4::.. iiiJ,,T%%&&""4<<4CLJ#d&&''t||}-!eDII;;q>D3t9}#'  BQx 
 KCTNA !eDIII 
r   c                     U R                   c  g [        XR                  5      U l        U R                  (       a3  U R                  U R                   :w  a  [	        SU R
                  -  5      eg g )NzBad CRC-32 for file %r)r  r9  r  r  r   r  )rE   newdatas     r   _update_crcZipExtFile._update_crc  s[    %!'+<+<=99**d.@.@@5		ABB A9r   c                    Ub  US:  av  U R                   U R                  S nSU l         SU l        U R                  (       d<  U R                  U R                  5      nU(       a  X#-  n U$ U R                  (       d  M<  U$ XR                  -   nU[        U R                   5      :  a!  U R                   U R                  U nX@l        U$ U[        U R                   5      -
  nU R                   U R                  S nSU l         SU l        US:  ah  U R                  (       dW  U R                  U5      nU[        U5      :  a  X0l         Xl        X#SU -  n U$ U(       a  X#-  n U$ U R                  (       d  MW  U$ )z7Read up to n bytes with at most one read() system call.Nr   r   )r  r  r  r  r   rv   )rE   r  r  rS   r  s        r   read1ZipExtFile.read1  sX    9A""4<<=1C"DDLii{{4::.KCJ iii
 J,,T%%&&""4<<4CLJ#d&&''t||}-q5ii{{1~s4y='+$#$L8OC 
 KC
 iii 
r   c                 *   U R                   (       d  US::  a  gU R                  [        :X  aE  U R                  R                  nU[        U5      :  a  X R                  U[        U5      -
  5      -  nOU R                  U5      nU R                  [        :X  a  U R                  S:*  U l         GOU R                  [        :X  a  [        XR                  5      nU R                  R                  X!5      nU R                  R                  =(       d1    U R                  S:*  =(       a    U R                  R                  (       + U l         U R                   (       a  X R                  R                  5       -  nOLU R                  R                  U5      nU R                  R                  =(       d    U R                  S:*  U l         US U R                   nU =R                  [        U5      -  sl        U R                  S::  a  SU l         U R                  U5        U$ )Nr   r   T)r  r  r   r  unconsumed_tailrv   _read2r   r  r   MIN_READ_SIZEro  rl  rd  r  r  r  s      r   r  ZipExtFile._read10  s    99Q ,.%%55D3t9}AD	M22;;q>D*,++q0DI  L0A))*A%%009D++// @,,1 @!//??? I yy**0022%%006D**..J$2E2E2JDIKTZZ 

c$i
::?DIr   c                 D   U R                   S::  a  g[        XR                  5      n[        XR                   5      nU R                  R                  U5      nU =R                   [        U5      -  sl         U(       d  [        eU R                  b  U R                  U5      nU$ )Nr   r   )	r  r   r  minr  rm   rv   EOFErrorr  r  s      r   r  ZipExtFile._read2T  s    !#%%&&&'}}!!!$s4y(N??&??4(Dr   c                    >  U R                   (       a  U R                  R                  5         [        TU ]	  5         g ! [        TU ]	  5         f = fr;   )r  r  r  r<   )rE   rA   s    r   r  ZipExtFile.closed  s4    	""##%GMOEGMOs	   += Ac                 R    U R                   (       a  [        S5      eU R                  $ Nr  )r  r   r  r   s    r   r  ZipExtFile.seekablek  s    ;;<==~~r   c                    U R                   (       a  [        S5      eU R                  (       d  [        R                  " S5      eU R                  5       nU[        R                  :X  a  UnOHU[        R                  :X  a  X1-   nO/U[        R                  :X  a  U R                  U-   nO[        S5      eX@R                  :  a  U R                  nUS:  a  SnXC-
  nXPR                  -   nUS:  a#  U[        U R                  5      :  a
  X`l        SnGOU R                  [        :X  a  U R                   c  US:w  a  S U l        U[        U R                  5      U R                  -
  -  nU R$                  R'                  U[        R                  5        U =R(                  U-  sl        U =R*                  U-  sl        U R(                  S:*  U l        SnSU l        SU l        OUS:  a  U R$                  R'                  U R.                  5        U R0                  U l        U R4                  U l        U R6                  U l        U R                  U l        SU l        SU l        [9        U R                  5      U l        SU l        UnU R                   b  U R=                  5         US:  a3  [?        U R@                  U5      nU RC                  U5        XW-  nUS:  a  M3  U R                  5       $ )Nzseek on closed file.!underlying stream is not seekablezCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)r   r   F)"r  r   r  r  UnsupportedOperationr   r   SEEK_SETr  SEEK_ENDr  r  rv   r  r  r   r  r  r  rt   r  r  r  r  r  r  r  r  r  r  r  r  MAX_SEEK_READrm   )rE   r   r  curr_posnew_posread_offsetbuff_offsetread_lens           r   rt   ZipExtFile.seekp  sg   ;;344~~))*MNN99;R[[ Gr{{"'Gr{{"**V3G C D D )))**GQ;G(!LL0!c$2B2B.C C&LK  J.4??3J{^_O_!%D3t//04<<??KMM{BKK8JJ+%J;.

aDIK"DDL1_MMt889 $ 4 4D!%D"&":":D--DJ"DDL!243F3F!GDDI!K*$$&Ao4--{;HIIh#K Ao
 yy{r   c                    U R                   (       a  [        S5      eU R                  (       d  [        R                  " S5      eU R
                  U R                  -
  [        U R                  5      -
  U R                  -   nU$ )Nztell on closed file.r  )
r  r   r  r  r  r  r  rv   r  r  )rE   fileposs     r   r   ZipExtFile.tell  s`    ;;344~~))*MNN&&3c$:J:J6KKdllZr   )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  )NFr  r%   )r   r   r   r   r   r   r  r  rF   r  r   r  r  r  rm   r  r	  r  r  r  r  r   r  rt   r   r   rd   re   s   @r   r  r  a  s    
 E M M37$1Wh	+7 B
!FC#J"H 
 #%++ ?B r   r  c                   j   ^  \ rS rSrS r\S 5       r\S 5       r\S 5       rS r	S r
U 4S jrS	rU =r$ )
_ZipWriteFilei  c                     X l         X0l        Xl        [        UR                  UR
                  5      U l        SU l        SU l        SU l	        g r  )
_zinfo_zip64_zipfiler  r   r   _compressor
_file_size_compress_size_crc)rE   zfr$  r   s       r   rF   _ZipWriteFile.__init__  sF    *5+>+>+0+?+?A	r   c                 .    U R                   R                  $ r;   )r.  rj   r   s    r   r  _ZipWriteFile._fileobj  s    }}r   c                 .    U R                   R                  $ r;   )r,  rq   r   s    r   r  _ZipWriteFile.name  s    {{###r   c                     g)Nwbr   r   s    r   r  _ZipWriteFile.mode  s    r   c                     g)NTr   r   s    r   writable_ZipWriteFile.writable  s    r   c                    U R                   (       a  [        S5      e[        U[        [        45      (       a  [        U5      nO[        U5      nUR                  nU =R                  U-  sl        [        XR                  5      U l
        U R                  (       a9  U R                  R                  U5      nU =R                  [        U5      -  sl        U R                  R                  U5        U$ r  )r  r   r  rE  rD  rv   rR   nbytesr0  r9  r2  r/  r`  r1  r  r  )rE   rS   r@  s      r   r  _ZipWriteFile.write  s    ;;<== dUI.//YFd#D[[F6!$		*	##,,T2D3t9,D!r   c           	        > U R                   (       a  g  [        TU ]	  5         U R                  (       ao  U R                  R	                  5       nU =R
                  [        U5      -  sl        U R                  R                  U5        U R
                  U R                  l
        OU R                  U R                  l
        U R                  U R                  l        U R                  U R                  l        U R                  (       d>  U R                  [         :  a  [#        S5      eU R
                  [         :  a  [#        S5      eU R                  R$                  [&        -  (       a  U R                  (       a  SOSnU R                  R                  [(        R*                  " U[,        U R                  R                  U R                  R                  U R                  R                  5      5        U R                  R/                  5       U R0                  l        OU R                  R/                  5       U R0                  l        U R                  R5                  U R                  R6                  5        U R                  R                  U R                  R9                  U R                  5      5        U R                  R5                  U R0                  R2                  5        U R0                  R:                  R=                  U R                  5        U R                  U R0                  R>                  U R                  R@                  '   SU R0                  l!        g ! SU R0                  l!        f = f)Nz*File size too large, try using force_zip64z0Compressed size too large, try using force_zip64z<LLQQz<LLLLF)"r  r<   r  r/  rd  r1  rv   r  r  r,  r   r0  r2  r   r   r-  r   r  r   r   rK   r   _DD_SIGNATUREr   r.  	start_dirrt   r   r   filelistr   
NameToInforq   r  )rE   r  r   rA   s      r   r  _ZipWriteFile.close  s+   ;;(	+GMO&&,,.##s3x/###C(,0,?,?),0OO)"iiDKKO$(OODKK!;;??[0&'STT&&4&'YZZ {{$$'@@!%g'##FKK]DKKOOKK--t{{/D/D%F G*.--*<*<*>' +/--*<*<*>'""4;;#<#<=##DKK$:$:4;;$GH""4==#:#:; MM""))$++6=A[[DMM$$T[[%9%9:%*DMM"UDMM"s   L-M M')r1  r/  r2  r0  r,  r-  r.  )r   r   r   r   rF   r,  r  r  r  r=  r  r  r   rd   re   s   @r   r*  r*    sX         $ $  &++ ++r   r*  c                   B   \ rS rSrSrSrSrS\SS4SSS.S jjrS r	S	 r
S
 rS rS rS rS&S jrS rS rS r\S 5       r\R*                  S 5       rS&S jrS'SS.S jjrS(S jrS)S jrS*S jr\S 5       rS rS r  S*S jr S)S jr S+S  jr!S! r"S" r#S# r$S$ r%S%r&g),r   i  a$  Class with methods to open, read, write, close, list zip files.

z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True,
            compresslevel=None)

file: Either the path to the file, or a file-like object.
      If it is a path, the file will be opened and closed by ZipFile.
mode: The mode can be either read 'r', write 'w', exclusive create 'x',
      or append 'a'.
compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib),
             ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma).
allowZip64: if True ZipFile will create files with ZIP64 extensions when
            needed, otherwise it will raise an exception when this would
            be necessary.
compresslevel: None (default for the given compression type) or an integer
               specifying the level to pass to the compressor.
               When using ZIP_STORED or ZIP_LZMA this keyword has no effect.
               When using ZIP_DEFLATED integers 0 through 9 are accepted.
               When using ZIP_BZIP2 integers 1 through 9 are accepted.

NrT)r  metadata_encodingc                
   US;  a  [        S5      e[        U5        X@l        SU l        SU l        0 U l        / U l        X0l        XPl        X l	        SU l
        SU l        X`l        Xpl        U R                  (       a  US:w  a  [        S5      e[        U[        R                   5      (       a  [        R"                  " U5      n[        U[$        5      (       a9  SU l        Xl        S	S
SSS
SSS.nX   n	  [*        R,                  " X5      U l        OSU l        Xl        [3        USS5      U l        SU l        [6        R8                  " 5       U l        SU l        SU l         US:X  a  U RA                  5         gUS;   aN  SU l         U R.                  RC                  5       U l"         U R.                  RG                  U RD                  5        gUS:X  a7   U RA                  5         U R.                  RG                  U RD                  5        g[        S5      e! [0         a    X;   a  X   n	 GM7  e f = f! [H        [0        4 a
    SU l         gf = f! [H        [0        4 a+    [K        U R.                  5      U l        SU l"        SU l         gf = f! [L         aE    U R.                  RG                  SS5        SU l        U R.                  RC                  5       U l"         gf = f!   U R.                  n
SU l        U RO                  U
5        e = f)zUOpen the ZIP file with mode read 'r', write 'w', exclusive create 'x',
or append 'a'.)rI  wxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'Fr   Nr   rI  z5metadata_encoding is only supported for reading filesrn   w+bx+br+br:  xb)rI  rL  rM  rN  rQ  rO  rP  Tr%   r  )rL  rM  rN  r&   z"Mode must be 'r', 'w', 'x', or 'a')(r   r  _allowZip64
_didModifydebugrF  rE  r  r  r  rK  _comment_strict_timestampsrJ  r  r   r  r  str_filePassedrq   r  rp   rj   rh   getattr_fileRefCnt	threadingRLockr  r  r  _RealGetContentsr   rD  rt   r  r  r   _fpclose)rE   r  r  r  
allowZip64r  r  rJ  modeDictr   rj   s              r   rF   ZipFile.__init__0  s    ++JKK;'%
&*	"3!2 !!dckGI I dBKK((99T?DdC   D M"U%$T$@H~H ggd5DG  DG#D&$7DM__&
'	s{%%'# #'/%)WW\\^DN/T^^4 4))+GGLL0 !!EFFc  +#+#5 	@ +G4 /)./ '0 +'0DG%&DN%*DN+  " 4GGLLA& '+DO%)WW\\^DN4	BDGMM"s   4H K 6K I $%H. 
K 5J	 K H+)H+.IK IK 8JK JK 	AKK KK 'Lc                     U $ r;   r   r   s    r   	__enter__ZipFile.__enter__  s    r   c                 $    U R                  5         g r;   r  )rE   typer   	tracebacks       r   __exit__ZipFile.__exit__  s    

r   c                    SU R                   R                  < SU R                   R                  < 3/nU R                  bz  U R                  (       a  UR                  SU R                  -  5        O+U R                  b  UR                  SU R                  -  5        UR                  SU R                  -  5        OUR                  S5        UR                  S5        SR                  U5      $ )	Nr   r  z file=%rz filename=%rz mode=%rr  r   r   )	rA   r   r   rj   rY  r   rq   r  r_   r  s     r   r   ZipFile.__repr__  s    "nn77"nn99; <77j47723*nt}}<=MM*tyy01MM+&cwwvr   c                 H   U R                   n [        U5      nU(       d  [        S5      eU R                  S:  a  [        U5        U[           nU[           nU[           U l	        U[           U-
  U-
  nU[           [        :X  a  U[        [        -   -  nU R                  S:  a  XT-   n[        SXFU5        XE-   U l        U R                  S:  a  [        S5      eUR!                  U R                  S5        UR#                  U5      n[$        R&                  " U5      nSnX:  Ga  UR#                  [(        5      n	[+        U	5      [(        :w  a  [        S5      e[,        R.                  " [0        U	5      n	U	[2           [4        :w  a  [        S5      eU R                  S:  a  [        U	5        UR#                  U	[6           5      n
[9        U
5      nU	[:           nU[<        -  (       a  U
R?                  S	5      n
O$U
R?                  U R@                  =(       d    S
5      n
[C        U
5      nUR#                  U	[D           5      Ul#        UR#                  U	[H           5      Ul%        U	[L           Ul'        U	SS u  Ul(        Ul)        Ul*        Ul+        Ul,        Ul-        pUl.        Ul/        Ul0        URT                  [b        :  a  [e        SURT                  S-  -  5      eU	SS u  Ul3        Ul4        Ul5        Xl6        US-	  S-   US-	  S-  US-  US-	  US-	  S-  US-  S-  4Ul7        URq                  U5        URN                  U-   Ul'        U Rr                  Ru                  U5        XRv                  URx                  '   U[(        -   U	[6           -   U	[D           -   U	[H           -   nU R                  S:  a  [        SU5        X:  a  GM  U R                  n[{        [}        U Rr                  S S95       H  nUUl?        URN                  nM     g! [         a    [        S5      ef = f)z/Read in the table of contents for the ZIP file.zFile is not a zip filer%   r&   zgiven, inferred, offsetr   z Bad offset for central directoryzTruncated central directoryz&Bad magic number for central directoryr   cp437r   zzip file version %.1fr-   r0   r3   r,   r   r)   r  r.   r$   totalc                     U R                   $ r;   )r   )r$  s    r   <lambda>*ZipFile._RealGetContents.<locals>.<lambda>  s
    u7J7Jr   )keyN)@rj   rg   rh   r   rU  printr   r   _ECD_COMMENTrV  _ECD_LOCATIONr|   r{   ry   ru   rD  rt   rm   r  BytesIOsizeCentralDirrv   rK   rJ   structCentralDir_CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHr9  _CD_FLAG_BITSr   r   rJ  r   _CD_EXTRA_FIELD_LENGTHrU   _CD_COMMENT_LENGTHr   _CD_LOCAL_HEADER_OFFSETr   r   r   r   r   r   r   r   r   r   MAX_EXTRACT_VERSIONr  r   r   r   r   r   r  rE  r   rF  rq   reversedsortedr   )rE   rj   r   size_cd	offset_cdconcatinferredrS   rp  centdirrq   orig_filename_crcflagsrM  td
end_offsetr$  s                     r   r^  ZipFile._RealGetContents  s   WW	7 _F 566::>&M#;'	|, &09<.!%77'*AABF::>)H+Y&I"+>>A?@@
"wwwZZoggn-G7|~- !>??mm$4g>G}%)99 !IJJzzA~gwww':;<H %hM*E))#??73 $??4+A+A+LWM!Aggg&<=>AG(: ;<AI%&=>AO 5<AbM2Qq0A1:[!/1UAOQ[  #66)*A+,+<+<r+A+C D D9@B6AHaoqKT4K!Q$QtVrEAqD$;41?AKNN,-oo6AOMM  #*+OOAJJ' ^+g6I.JJ567123E zzA~gu%[ o^ ^^
fT]])JL ME *E,,JMW  	7566	7s   P P!c                 X    U R                    Vs/ s H  oR                  PM     sn$ s  snf )z+Return a list of file names in the archive.)rE  rq   ra  s     r   namelistZipFile.namelist  s     *.--8-$-888s   'c                     U R                   $ )zBReturn a list of class ZipInfo instances for files in the
archive.)rE  r   s    r   infolistZipFile.infolist       }}r   c                     [        SS-  US9  U R                   H8  nSUR                  SS -  n[        SUR                  X2R                  4-  US9  M:     g)z+Print a table of contents for the zip file.z%-46s %19s %12s)z	File NamezModified    Sizer  z%d-%02d-%02d %02d:%02d:%02dNr*   z%-46s %s %12d)ru  rE  r   rq   r   )rE   r  r$  dates       r   printdirZipFile.printdir  sX    "GG	]]E05??2A3FFD/U^^T??$KK #r   c                 8   SnU R                    HX  n U R                  UR                  S5       nUR                  U5      (       a   UR                  U5      (       a  M  SSS5        MZ     g! , (       d  f       Ml  = f! [         a    UR                  s s  $ f = f)zRead all the files and check the CRC.

Return None if all files could be read successfully, or the name
of the offending file otherwise.i   rI  N)rE  rp   rq   rm   r   )rE   
chunk_sizer$  fs       r   testzipZipFile.testzip  s    
 
]]E& YYu~~s3q&&,, &&,, 43	 # 43  &~~%&s.   A>.A,A>,
A;	6A>;A>>BBc                 ^    U R                   R                  U5      nUc  [        SU-  5      eU$ )z,Return the instance of ZipInfo given 'name'.z(There is no item named %r in the archive)rF  r   KeyError)rE   r  infos      r   getinfoZipFile.getinfo  s9    ""4(<:TAC C r   c                     U(       a6  [        U[        5      (       d!  [        S[        U5      R                  -  5      eU(       a  Xl        gSU l        g)z)Set default password for encrypted files.pwd: expected bytes, got %sN)r  rE  	TypeErrorrh  r   rK  )rE   rK  s     r   setpasswordZipFile.setpassword$  s;    z#u--9DI<N<NNOOHDHr   c                     U R                   $ )z.The comment text associated with the ZIP file.)rV  r   s    r   r   ZipFile.comment-  r  r   c                     [        U[        5      (       d!  [        S[        U5      R                  -  5      e[        U5      [        :  a$  SS KnUR                  S[        -  SS9  US [         nXl	        SU l
        g )Nzcomment: expected bytes, got %sr   z3Archive comment is too long; truncating to %d bytesr&   r   T)r  rE  r  rh  r   rv   r   r   r  rV  rT  )rE   r   r   s      r   r   r  2  sq    '5))=W@V@VVWWw</)MMO+,89  ;./Gr   c                 ~    U R                  USU5       nUR                  5       sSSS5        $ ! , (       d  f       g= f)zMReturn file bytes for name. 'pwd' is the password to decrypt
encrypted files.rI  N)rp   rm   )rE   r  rK  rj   s       r   rm   ZipFile.read?  s+     YYtS#&"779 '&&s   .
<Fforce_zip64c                  ^  US;  a  [        S5      eU(       a  US:X  a  [        S5      eT R                  (       d  [        S5      e[        U[        5      (       a  UnOEUS:X  a.  [        U5      nT R                  Ul        T R                  Ul        OT R                  U5      nUS:X  a  T R                  XTS9$ T R                  (       a  [        S5      eT =R                  S-  sl        [        T R                  UR                  T R                  T R                  U 4S	 j5      n UR!                  ["        5      n[%        U5      ["        :w  a  ['        S
5      e[(        R*                  " [,        U5      nU[.           [0        :w  a  ['        S5      eUR!                  U[2           5      nU[4           (       a  UR7                  U[4           SS9  UR8                  [:        -  (       a  [=        S5      eUR8                  [>        -  (       a  [=        S5      eU[@           [B        -  (       a  URE                  S5      n	O$URE                  T RF                  =(       d    S5      n	XRH                  :w  a  ['        SURH                  < SU< S35      eURJ                  b  URM                  5       URN                  -   URJ                  :  az  URJ                  UR                  :X  aF  SSK(n
U
RS                  SURH                  < S3[T        RV                  RY                  [Z        5      4S9  O['        SURH                  < S35      eUR8                  [\        -  nU(       af  U(       d  T R^                  nU(       a6  [        U[`        5      (       d!  [c        S[e        U5      Rf                  -  5      eU(       d  [i        SU-  5      eOSn[k        XbS-   XSS5      $ !   URm                  5         e = f)a%  Return file-like object for 'name'.

name is a string for the file name within the ZIP file, or a ZipInfo
object.

mode should be 'r' to read a file already in the ZIP file, or 'w' to
write to a file newly added to the archive.

pwd is the password to decrypt files (only used for reading).

When writing, if the file size is not known in advance but may exceed
2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large
files.  If the size is known in advance, it is best to pass a ZipInfo
instance for name, with zinfo.file_size set.
>   rI  rL  zopen() requires mode "r" or "w"rL  z'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedr  r  r%   c                     > T R                   $ r;   )r  r   s   r   rr  ZipFile.open.<locals>.<lambda>t  s	    $--r   zTruncated file headerz Bad magic number for file header)r  z$compressed patched data (flag bit 5)zstrong encryption (flag bit 6)r   ro  zFile name in directory z and header z differ.Nr   zOverlapped entries: z (possible zip bomb))skip_file_prefixesr  z6File %r is encrypted, password required for extractionbT)7r   rj   r  r   r  r   r  r   r  _open_to_writer  r[  r  r   r_  r  rm   sizeFileHeaderrv   r   rK   rJ   r   _FH_SIGNATUREr   _FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHrt   r   _MASK_COMPRESSED_PATCHr  _MASK_STRONG_ENCRYPTION_FH_GENERAL_PURPOSE_FLAG_BITSr   r   rJ  r   r   r   r   r   r  r   r  dirname__file___MASK_ENCRYPTEDrK  rE  r  rh  r   r  r  r  )rE   r  r  rK  r  r$  zef_filefheaderfname	fname_strr   is_encrypteds   `           r   rp   ZipFile.openE  sk     z!>??DCKFGGwwDF F dG$$ES[DME"&"2"2E#'#5#5E  LL&E3;&&u&FF== F G G
 	Atww(;(;#}}djj:OQ=	mmN3G7|~- !899mm$4g>G}%)99 !CDDMM'*=">?E-.g&<=aH!77)*PQQ!88)*JKK458JJ!LL1	!LL)?)?)J7K	/// **E34 4 !!-%"5"558I8II$$(;(;;#MM.u/B/B.E F. /,.GGOOH,E+G " I
 %.u/B/B.E F. /0 0
 !??_<L((Cz#u55#$ADIDVDV$VWW& (ACG(H I I  hs
EEE	NNs   &J(O O"c                 `   U(       a  U R                   (       d  [        S5      eU R                  (       a  [        S5      eSUl        SUl        SUl        UR                  [        :X  a  U=R
                  [        -  sl        U R                  (       d  U=R
                  [        -  sl        UR                  (       d  SUl        U=(       d    UR                  S-  [        :  nU R                   (       d  U(       a  [        S5      eU R                  (       a%  U R                  R!                  U R"                  5        U R                  R%                  5       Ul        U R)                  U5        SU l        U R                  R-                  UR/                  U5      5        SU l        [1        XU5      $ )NzHforce_zip64 is True, but allowZip64 was False when opening the ZIP file.zzCan't write to the ZIP file while there is another write handle open on it. Close the first handle before opening another.r     g?z'Filesize would require ZIP64 extensionsT)rS  r   r  r   r   r   r   r	   _MASK_COMPRESS_OPTION_1r  r   r   r   r   r   rj   rt   rD  r   r   _writecheckrT  r  r   r*  )rE   r$  r  r   s       r   r  ZipFile._open_to_write  s;   t//   == N O O
  	(*OO66O~~OO88O"""-E E$ 6 DEHII>>GGLL("ggllne&&u-.T%00r   c                     Uc  [         R                  " 5       nO[         R                  " U5      nU R                  XU5      $ )a8  Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a ZipInfo object. You can
specify a different directory using `path'. You can specify the
password to decrypt the file using 'pwd'.
)r   getcwdr  _extract_member)rE   memberr  rK  s       r   extractZipFile.extract  s4     <99;D99T?D##F#66r   c                     Uc  U R                  5       nUc  [        R                  " 5       nO[        R                  " U5      nU H  nU R	                  XAU5        M     g)a  Extract all members from the archive to the current working
directory. `path' specifies a different directory to extract to.
`members' is optional and must be a subset of the list returned
by namelist(). You can specify the password to decrypt all files
using 'pwd'.
N)r  r   r  r  r  )rE   r  membersrK  r  s        r   
extractallZipFile.extractall  sK     ?mmoG<99;D99T?DG  4 r   c                    U R                   nU(       d*  Sn[        R                  US[        U5      -  5      nX0l         UR	                  U5      nS UR                  U5       5       nUR                  S U 5       5      nU$ )z;Replace bad characters and remove trailing dots from parts.z:<>|"?*_c              3   B   #    U  H  oR                  S 5      v   M     g7f)z .N)rstriprZ   rM  s     r   r]   1ZipFile._sanitize_windows_name.<locals>.<genexpr>  s     B+Aa88D>>+As   c              3   6   #    U  H  o(       d  M  Uv   M     g 7fr;   r   r  s     r   r]   r  
  s     7'QQqq's   
	)!_windows_illegal_name_trans_tablerX  	maketransrv   	translaterV   r_   )r>   r!  pathseptableillegals        r   _sanitize_windows_nameZipFile._sanitize_windows_name  sr     55GMM'3W+=>E491##E*B7==+AB,,7'77r   c                   ^ [        U[        5      (       d  U R                  U5      nUR                  R	                  S[
        R                  R                  5      n[
        R                  R                  (       aB  UR	                  [
        R                  R                  [
        R                  R                  5      n[
        R                  R                  U5      S   nS[
        R                  R                  [
        R                  R                  4m[
        R                  R                  R                  U4S jUR                  [
        R                  R                  5       5       5      n[
        R                  R                  S:X  a*  U R                  U[
        R                  R                  5      nU(       d   UR                  5       (       d  [!        S5      e[
        R                  R                  X$5      n[
        R                  R#                  U5      n[
        R                  R%                  U5      nU(       a9  [
        R                  R'                  U5      (       d  [
        R(                  " USS9  UR                  5       (       a?  [
        R                  R+                  U5      (       d   [
        R,                  " U5        U$ U$ U R1                  XS	9 n[1        US
5       n[2        R4                  " Xg5        SSS5        SSS5        U$ ! [.         a)    [
        R                  R+                  U5      (       d  e  U$ f = f! , (       d  f       NN= f! , (       d  f       U$ = f)zOExtract the ZipInfo object 'member' to a physical
file on the path targetpath.
r   r%   r   c              3   8   >#    U  H  nUT;  d  M  Uv   M     g 7fr;   r   )rZ   rM  invalid_path_partss     r   r]   *ZipFile._extract_member.<locals>.<genexpr>  s$      #C.H&'/A&A $%1.Hs   
	\zEmpty filename.T)exist_ok)rK  r:  N)r  r   r  rq   r   r   r  r   r   r  curdirpardirr_   rV   r  r   r   r  r  existsmakedirsr   mkdirFileExistsErrorrp   shutilcopyfileobj)	rE   r  
targetpathrK  r!  	upperdirssourcetargetr  s	           @r   r  ZipFile._extract_member  s?    &'**\\&)F //))#rww{{;77>>oobggnnbggkkBG ''$$W-a0 "''.."''..A''++"" #CgmmBGGKK.H #C C77;;$11'277;;GGv}}.//WW\\*6
WW%%j1
 GGOOJ/	RWW^^I66KK	D1==??77==,,HHZ( :YYvY'6*d#vv. $ (  ' 77==44 5 $# (' s6   4L M*M	M/MM	
M	M
M)c                    UR                   U R                  ;   a!  SSKnUR                  SUR                   -  SS9  U R                  S;  a  [        S5      eU R                  (       d  [        S5      e[        UR                  5        U R                  (       de  Sn[        U R                  5      [        :  a  S	nO-UR                  [        :  a  S
nOUR                  [        :  a  SnU(       a  [!        US-   5      egg)z6Check for errors before writing a file to the archive.r   NzDuplicate name: %rr'   r   rL  rM  rN  z&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedFiles countFilesizezZipfile size would require ZIP64 extensions)rq   rF  r   r  r  r   rj   r  r   rS  rv   rE  ZIP_FILECOUNT_LIMITr   r   r   r   )rE   r$  r   requires_zip64s       r   r  ZipFile._writecheck>  s    >>T__,MM.?AMN99O+EFFwwFH H5../!N4==!%88!.;.!+$${2!/">#D$E F F   r   c                 V   U R                   (       d  [        S5      eU R                  (       a  [        S5      e[        R	                  XU R
                  S9nUR                  5       (       a   SUl        SUl        U R                  U5        gUb  X5l
        OU R                  Ul
        Ub  XEl        OU R                  Ul        [        US5       o`R                  US5       n[        R                   " XgS5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)	zDPut the bytes from filename into the archive under the name
arcname.7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsr  r   Nrn   rL  i    )rj   r   r  r   r%  rW  r   r   r   r  r   r  r   r  rp   r  r  )rE   rq   r!  r   r  r$  srcdests           r   r  ZipFile.writeU  s     wwIK K==P  !!(484K4K " M <<>>"#EEIJJu(&3#&*&6&6#('4$'+'9'9$h%iis.Ct""3f5 /D%%.C.C%%s$   D D	8D	
D	D
D(c                 *   [        U[        5      (       a  UR                  S5      n[        U[        5      (       d  [        U[        R
                  " [        R                  " 5       5      SS S9nU R                  Ul        U R                  Ul	        UR                  R                  S5      (       a  SUl        U=R                  S-  sl        O
SUl        OUnU R                  (       d  [        S	5      eU R                  (       a  [        S
5      eUb  X5l        Ub  XEl	        [!        U5      Ul        U R$                     U R'                  USS9 nUR)                  U5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zWrite a file into the archive.  The contents is 'data', which
may be either a 'str' or a 'bytes' instance; if it is a 'str',
it is encoded as UTF-8 first.
'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive.r   Nr*   )rq   r   r   i  Ar1   r  r  z?Can't write to ZIP archive while an open writing handle exists.rL  )r  )r  rX  r   r   r  r  r  r   r  r   rq   r(  r   rj   r   r  rv   r   r  rp   r  )rE   zinfo_or_arcnamerS   r   r  r$  r  s          r   writestrZipFile.writestrv  s@    dC  ;;w'D*G44%5&*nnTYY[&A"1&EGE"&"2"2E#'#5#5E ~~&&s++&3###t+#&1#$EwwIK K==Q  $"/$#0 d)ZZ5s+t

4  , Z++ Zs$   ?FE3"F3
F	=F
Fc                    [        U[        5      (       a#  UnUR                  5       (       d  [        S5      eO[        U[        5      (       ac  UnUR                  S5      (       d  US-  n[        U5      nSUl        SUl        SU-  S-  S-  Ul        SUl	        U=R                  S-  sl        O[        S5      eU R                     U R                  (       a%  U R                  R                  U R                  5        U R                  R!                  5       Ul        UR$                  [&        :X  a  U=R(                  [*        -  sl        U R-                  U5        SU l        U R0                  R3                  U5        X0R4                  UR6                  '   U R                  R9                  UR;                  S	5      5        U R                  R!                  5       U l        S
S
S
5        g
! , (       d  f       g
= f)z+Creates a directory inside the zip archive.z/The given ZipInfo does not describe a directoryr   r   i @  r   r1   zExpected type str or ZipInfoTFN)r  r   r   r   rX  r(  r   r   r   r   r  r  r  rj   rt   rD  r   r   r   r	   r   r  r  rT  rE  r   rF  rq   r  r   )rE   zinfo_or_directory_namer  r$  directory_names        r   r  ZipFile.mkdir  sp   -w77+E<<>> !RSS "/554N!**3//#%N+E"#EEI$+dNf#<"CEEO4':;;ZZ~~T^^,"&'',,.E""h.#::U#"DOMM  '.3OOENN+GGMM%**512!WW\\^DN ZZs   DG((
G6c                 $    U R                  5         g)z2Call the "close()" method in case the user forgot.Nrg  r   s    r   __del__ZipFile.__del__  s    

r   c                    U R                   c  gU R                  (       a  [        S5      e U R                  S;   al  U R                  (       a[  U R
                     U R                  (       a%  U R                   R                  U R                  5        U R                  5         SSS5        U R                   nSU l         U R                  U5        g! , (       d  f       N3= f! U R                   nSU l         U R                  U5        f = f)zGClose the file, and for mode 'w', 'x' and 'a' write the ending
records.NzvCan't close the ZIP file while there is an open writing handle on it. Close the writing handle before closing the zip.r  )rj   r  r   r  rT  r  r  rt   rD  _write_end_recordr_  r  s     r   r  ZipFile.close  s     77?== P Q Q		yyO+ZZ~~T^^4**,  
 BDGMM"  Z
 BDGMM"s$   -C AC C 
CC &Dc                 	   U R                    GH  nUR                  nUS   S-
  S-  US   S-  -  US   -  nUS   S-  US	   S-  -  US   S-  -  n/ nUR                  [        :  d  UR                  [        :  a;  UR                  UR                  5        UR                  UR                  5        S
nS
nOUR                  nUR                  nUR                  [        :  a  UR                  UR                  5        S
nOUR                  nUR                  n	Sn
U(       aS  [        R                  U	S5      n	[        R                  " SS[        U5      -  -   SS[        U5      -  /UQ76 U	-   n	[        n
UR                  [        :X  a  [!        ["        U
5      n
O$UR                  [$        :X  a  [!        [&        U
5      n
[!        XR(                  5      n[!        XR*                  5      nUR-                  5       u  p[        R                  " [.        [0        UUR2                  XR4                  XR                  XCUR6                  Xv[        U5      [        U	5      [        UR8                  5      SUR:                  UR<                  U5      nU R>                  RA                  U5        U R>                  RA                  U5        U R>                  RA                  U	5        U R>                  RA                  UR8                  5        GM     U R>                  RC                  5       n[        U R                   5      nUU RD                  -
  nU RD                  nS nU[F        :  a  SnOU[        :  a  SnOU[        :  a  SnU(       a  U RH                  (       d  [K        US-   5      e[        R                  " [L        [N        SSSSSUUUU5      nU R>                  RA                  U5        [        R                  " [P        [R        SUS5      nU R>                  RA                  U5        [U        US5      n[U        US
5      n[U        US
5      n[        R                  " [V        [X        SSUUUU[        U RZ                  5      5	      nU R>                  RA                  U5        U R>                  RA                  U RZ                  5        U R\                  S:X  a  U R>                  R_                  5         U R>                  Ra                  5         g )Nr   r   r,   r%   r)   r&   r'   r.   r(   r   r(  r9   Qr   r  zCentral directory offsetzCentral directory sizer  ,   r"   r   rN  )1rE  r   r   r   r   r   r   rU   r7   r`   rK   r   rv   r   r   r   r   r   r	   r   r   r   r   rz  r|  r   r   r   r   r   r   rj   r  r   rD  r  rS  r   rz   r{   rw   rx   r  r   r   rV  r  truncaterd  )rE   r$  r   r   r   rU   r   r   r   
extra_datar   r   r   rq   r   r  pos2centDirCountcentDirSizecentDirOffsetr   zip64endreczip64locrecr   s                           r   r  ZipFile._write_end_record  s   ]]EB!ut|)BqEQJ6A>GerkBqEQJ."Q%1*=GE,%%3U__-U001&	 *!OO	 % 3 3""[0U001 * % 3 3JK#\\*d;
#[[CE
N*qU|-&+-/9:
 ,""i/!-=$$0!,<!+/D/DEO .B.BCN"'"<"<">Hkk"2"2N"'"5"5"+-@-@'"'))]"%h-Z#emmBT"#U%8%8%:M:M"/1G GGMM'"GGMM(#GGMM*%GGMM%--(g #j ww||~4==)T^^+--*N[(7N;&5N##">#D$E F F ++"$6BAq,],K GGMM+& ++))1dA7K GGMM+&|V4Lk:6Kz:M-/?<(-T]]9KM 	fdmm$99GGr   c                     U R                   S:  d   eU =R                   S-  sl         U R                   (       d#  U R                  (       d  UR                  5         g g g )Nr   r%   )r[  rY  r  r  s     r   r_  ZipFile._fpclose:  sI    !###A(8(8HHJ )9r   )rF  rS  rV  rT  rY  r[  r  r  rW  r  r  r  rU  rE  rq   rj   rJ  r  rK  rD  r;   )rI  N)F)NN)NNN)i  )'r   r   r   r   r   rj   r  r   rF   rd  rj  r   r^  r  r  r  r  r  r  r,  r   r-  rm   rp   r  r  r  rc   r  r  r  r  r	  r  r  r  r  r_  r   r   r   r   r   r     s
   , 
B(,%"%:$#^:>RV^@S-j9
&    ^^
 
mE m^(1T75$  /bF. '+046D 48'!R!,F,\|r   r   c                   :    \ rS rSrSrS\SS4S jrSS jrS	 rS
r	g)r   iA  zDClass to create ZIP archives with Python library files and packages.rI  Tr  c                 :    [         R                  XX#US9  XPl        g )N)r  r  r`  )r   rF   	_optimize)rE   r  r  r  r`  optimizes         r   rF   PyZipFile.__init__D  s!    $$. 	 	0!r   Nc                    [         R                  " U5      nU(       aZ  U" U5      (       dM  U R                  (       a;  [         R                  R	                  U5      (       a  SOSn[        U< SU< S35        g[         R                  R                  U5      u  pV[         R                  R	                  U5      (       Ga:  [         R                  R                  US5      n[         R                  R                  U5      (       Ga  U(       a
  U< SU< 3nOUnU R                  (       a  [        SUS	U5        U R                  US
S U5      u  pU R                  (       a  [        SU	5        U R                  X5        [        [         R                  " U5      5      n
U
R                  S5        U
 GH@  n[         R                  R                  X5      n[         R                  R                  U5      u  p[         R                  R	                  U5      (       aV  [         R                  R                  [         R                  R                  US5      5      (       a  U R                  XUS9  M  M  US:X  d  M  U(       a.  U" U5      (       d!  U R                  (       a  [        SU-  5        M  U R                  US
S U5      u  pU R                  (       a  [        SU	5        U R                  X5        GMC     gU R                  (       a  [        SU5        [        [         R                  " U5      5       H  n[         R                  R                  X5      n[         R                  R                  U5      u  pUS:X  d  MK  U(       a.  U" U5      (       d!  U R                  (       a  [        SU-  5        M  U R                  US
S U5      u  pU R                  (       a  [        SU	5        U R                  X5        M     gUSS S:w  a  [!        S5      eU R                  US
S U5      u  pU R                  (       a  [        SU	5        U R                  X5        g)aN  Add all files from "pathname" to the ZIP archive.

If pathname is a package directory, search the directory and
all package subdirectories recursively for all *.py and enter
the modules into the archive.  If pathname is a plain
directory, listdir *.py and enter all modules.  Else, pathname
must be a Python *.py file and the module will be put into the
archive.  Added modules are always module.pyc.
This method will compile the module.py into module.pyc if
necessary.
If filterfunc(pathname) is given, it is called with every argument.
When it is False, the file or directory is skipped.
r  r   z skipped by filterfuncNz__init__.pyr   zAdding package inasr   Adding)
filterfunc.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"zAdding file)r   r  rU  r  r   ru  rV   r_   isfile_get_codenamer  r  listdirremovesplitextwritepyr  )rE   pathnamebasenamer-  labeldirr  initnamer  r!  dirlistrq   r  rootexts                  r   r4  PyZipFile.writepyJ  s    99X&j22zz"$''--"9"9vuhGHGGMM(+	77==""ww||Hm<Hww~~h''*2D9H#H::-xxH!%!3!3HQrNH!M::(G,

5* H!56}- 'H77<<;D " 0 0 :IDww}}T**77>>"'',,t]*KLL LL4> ) @ M %j.>.>#zz %&E&L M$)-););D2J<D*F::!(G4

52# !(( ::7B &rzz('; <H77<<;D " 0 0 :IDe|%j.>.>#zz %&E&L M$)-););D2J<D*F::!(G4

52 != }%"DF F!//2INEzzmW-JJu&r   c                 :  ^  SU 4S jjnUS-   nUS-   n[         R                  R                  USS9n[         R                  R                  USS9n[         R                  R                  USS9nT R                  S:X  Ga  [        R
                  R                  U5      (       aG  [        R                  " U5      R                  [        R                  " U5      R                  :  a  U=pGO~[        R
                  R                  U5      (       aH  [        R                  " U5      R                  [        R                  " U5      R                  :  a  Un
Un	GO[        R
                  R                  U5      (       aH  [        R                  " U5      R                  [        R                  " U5      R                  :  a  Un
Un	GO[        R
                  R                  U5      (       aH  [        R                  " U5      R                  [        R                  " U5      R                  :  a  Un
Un	GO:U" U5      (       aG  [        R                  R                  S	:X  a  Un
O#[        R                  R                  S:X  a  Un
OUn
Un	OU=pOT R                  S	:X  a  Un
Un	ONUn	T R                  S:X  a  Un
O9T R                  S:X  a  Un
O&S
R                  T R                  5      n[        U5      e[        R
                  R                  U
5      (       aB  [        R                  " U
5      R                  [        R                  " U5      R                  :  d  U" UT R                  S9(       d  U=p[        R
                  R                  U	5      S   nU(       a	  U< SU< 3nX4$ )zReturn (filename, archivename) for the path.

Given a module name path, return the correct file path and
archive name, compiling if necessary.  For example, given
/python/lib/string, return (/python/lib/string.pyc, string).
r  c                    > SS K nTR                  (       a  [        SU 5         UR                  U SUS9  g! UR                   a  n[        UR
                  5         S nAgS nAff = f)Nr   	CompilingT)doraiser&  F)
py_compilerU  ru  compilePyCompileErrormsg)r  r&  rB  errrE   s       r   _compile)PyZipFile._get_codename.<locals>._compile  s\    zzk4(""4"I  ,, cggs   6 A%A  A%r.  z.pycr   )optimizationr%   r&   r   z"invalid value for 'optimize': {!r})r&  r   r  )	importlibutilcache_from_sourcer%  r   r  r/  r   r  r   r  r&  formatr   rV   )rE   r5  r6  rG  file_pyfile_pycpycache_opt0pycache_opt1pycache_opt2r!  r  rE  archivenames   `            r   r0  PyZipFile._get_codename  s   		 e#f$ ~~77b7Q ~~77a7P ~~77a7P>>Rx((''(#,,0@0I0II"**%''....'','00BGGG4D4M4MM %"''....'','00BGGG4D4M4MM %"''....'','00BGGG4D4M4MM %" G$$yy))Q. ,++q0 , ,&G&--EG ~~"$"">>Q&(E^^q((E>EEdnnUC$S/)GGNN5))GGEN++rwww/?/H/HH$..A&--EggmmG,Q/%-{;K##r   )r%  )r   N)
r   r   r   r   r   r   rF   r4  r0  r   r   r   r   r   r   A  s!    N"%: 2"P'dP$r   r   c                   ^ SS K nSnUR                  US9nUR                  SS9nUR                  SSSS	S
9  UR                  SSSSSS9  UR                  SSSSSS9  UR                  SSSSS
9  UR                  SSSS
9  UR	                  U 5      n U R
                  nU R                  b]  U R                  n[        USUS9 nUR                  5       nS S S 5        W(       a  [        SR                  U5      5        [        S5        g U R                  b1  U R                  n[        USUS9 nUR                  5         S S S 5        g U R                  b4  U R                  u  pi[        USUS9 nUR                  U	5        S S S 5        g U R                  Gb  U(       a.  [        S [         R"                  S!9  [         R$                  " S"5        U R                  R'                  S5      n
U R                  nU4S# jm[        U
S$5       nU H  n[(        R*                  R-                  U5      nU(       d<  [(        R*                  R-                  [(        R*                  R/                  U5      5      nUS%[(        R0                  [(        R2                  4;   a  S%nT" X|U5        M     S S S 5        g g ! , (       d  f       GN= f! , (       d  f       g = f! , (       d  f       g = f! , (       d  f       g = f)&Nr   z3A simple command-line interface for zipfile module.)descriptionT)requiredz-lz--list	<zipfile>zShow listing of a zipfile)metavarhelpz-ez	--extractr&   )rX  z<output_dir>zExtract zipfile into target dir)nargsrY  rZ  z-cz--create+)z<name>z<file>zCreate zipfile from sourcesz-tz--testzTest if a zipfile is validz--metadata-encodingz
<encoding>z2Specify encoding of member names for -l, -e and -trI  )rJ  z.The following enclosed file is corrupted: {!r}zDone testingz/Non-conforming encodings not supported with -c.r  r%   c           	        > [         R                  R                  U5      (       a  U R                  X[        5        g [         R                  R                  U5      (       a  U(       a  U R                  X5        [        [         R                  " U5      5       HG  nT" U [         R                  R                  X5      [         R                  R                  X#5      5        MI     g g r;   )	r   r  r/  r  r   r   r  r1  r_   )r3  r  zippathnmaddToZips       r   r`  main.<locals>.addToZip 	  s    ww~~d##5t$$HHT+ D!12BRWW\\$3RWW\\'5NP 3 %r   rL  r   )argparseArgumentParseradd_mutually_exclusive_groupadd_argument
parse_argsrJ  testr   r  ru  rM  r   r  r  r  creater   stderrexitpopr   r  r6  r  r  r  )argsrb  rV  parsergroupencodingr  r3  badfiler  zip_namefilesr  r^  r`  s                 @r   mainrs    s   GK$$$=F///>E	tX{7  9	t[<=  ? 
tZs39  ; 
tX{8  :
-|Q  ST"D%%HyyiiS#:bjjlG ;BII'RSn		iiS#:bKKM ;: 
	!llS#:bMM&! ;: 
	 Czz#HHQK;;??1%	P Xs#r''**40 gg..rwwt/DEGr299bii88 G7+  $#) 
!! ;: ;:
 ;:. $#s1   J),J;,KBK)
J8;
K	
K
K+)r   CompleteDirsr;   )r   binasciiimportlib.utilrJ  r  r   r  r   rK   r   r\  r  r  r9  ImportErrorr  rW  __all__	Exceptionr   r   r   r   r   r  r   r   r   r   r	   r   r   r   r   r  r   r   r   r   r|   r}   r~   r   r   r   r   r   rv  rw  rz  r|  ry  r{  _CD_CREATE_VERSION_CD_CREATE_SYSTEM_CD_EXTRACT_VERSION_CD_EXTRACT_SYSTEMr~  _CD_COMPRESS_TYPE_CD_TIME_CD_DATE_CD_CRC_CD_COMPRESSED_SIZE_CD_UNCOMPRESSED_SIZEr}  r  r  _CD_DISK_NUMBER_START_CD_INTERNAL_FILE_ATTRIBUTES_CD_EXTERNAL_FILE_ATTRIBUTESr  r  r  r   r  r  r   r   r   r  r  _FH_EXTRACT_VERSION_FH_EXTRACT_SYSTEMr  _FH_COMPRESSION_METHOD_FH_LAST_MOD_TIME_FH_LAST_MOD_DATE_FH_CRC_FH_COMPRESSED_SIZE_FH_UNCOMPRESSED_SIZEr  r  rw   rx   ru   rz   r{   ry   _CD64_SIGNATURE_CD64_DIRECTORY_RECSIZE_CD64_CREATE_VERSION_CD64_EXTRACT_VERSION_CD64_DISK_NUMBER_CD64_DISK_NUMBER_START_CD64_NUMBER_ENTRIES_THIS_DISK_CD64_NUMBER_ENTRIES_TOTAL_CD64_DIRECTORY_SIZE_CD64_OFFSET_START_CENTDIRrC  rE  r7   rk   r
   r   rg   r   r   rI  r2  rM  rO  rg  r   r  r  r  r  r  r  r  r*  r   r   rs  _pathr   rt  r   r   r   <module>r     s  
   	 	    
  JJE

	 	9    
 #  
	      !12   	   $   !12      
      ! !     
 #      
   "   !12   !    
     % )  //*CD  " " ??#56      !"    !
U !
H (V:x&r rr 	 #L" ". 8wx x x	
 x x y z y { 	      	!" # (N& P$(! (!V (V"" Vr
X+B%% X+xh hVk$ k$\C,L CI  DNNE  
C
  Ds4   I I I+ III('I(+I76I7