• File: zipfile.cpython-38.opt-2.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python38/lib64/python3.8/__pycache__/zipfile.cpython-38.opt-2.pyc
  • Date Modified: 10/26/2026 8:15 PM
  • File size: 49.65 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
U

j
a@s
ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZzddlZejZWnek
rdZejZYnXzddlZWnek
rdZYnXzddlZWnek
rdZYnXdddddddd	d
ddd
dg
ZGdddeZGdd
d
eZeZZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'e
(e&Z)dZ*dZ+dZ,dZ-dZ.d Z/d!Z0d"Z1dZ2d#Z3d$Z4d%Z5e
(e4Z6dZ7dZ8dZ9dZ:dZ;d Z<d!Z=d"Z>dZ?d#Z@d&ZAd'ZBdZCd(ZDdZEd)ZFd*ZGd+ZHd,ZId-ZJd.ZKe
(eJZLdZMdZNdZOdZPdZQd ZRd!ZSd"ZTdZUd#ZVd&ZWd'ZXd/ZYd0ZZe
(eYZ[d1Z\d2Z]e
(e\Z^dZ_dZ`dZadZbdZcd Zdd!Zed"ZfdZgd#Zhd3Zie
jd4Zkd5d6Zld7d8Zmd9d	Znd:d;Zod<d=ZpGd>d
d
eqZrdasd?d@ZtdAdBZuGdCdDdDZvGdEdFdFZwdGdHdIdIdIdIdJdKdLdMdJdNdOdPdQdRdSdTZxdUdVZydsdWdXZzdYdZZ{Gd[d\d\Z|Gd]d^d^Z}Gd_d`d`ej~ZGdadbdbej~ZGdcddZGddddeZdedfZdgdhZejZdidjZGdkdldleZGdmdndneZGdoddZdtdpdqZedrkredS)uN
BadZipFile
BadZipfileerror
ZIP_STOREDZIP_DEFLATED	ZIP_BZIP2ZIP_LZMA
is_zipfileZipInfoZipFile	PyZipFileLargeZipFilePathc@seZdZdS)rN__name__
__module____qualname__rr,/opt/alt/python38/lib64/python3.8/zipfile.pyr+sc@seZdZdS)r
Nrrrrrr
/si-.?s<4s4H2LHsPK	z<4s4B4HL2L5H2LsPK

z<4s2B4HL2L2HsPKz<4sLQLsPKz
<4sQ2H2L4QsPKiPK<HHc
Cstj}d}g}d}}|dt|krz||||d\}}|d|}	||krt||krl|||||	}d}|	}q|s|Sd|S)NFrr T)_EXTRA_FIELD_STRUCTunpacklenappendjoin)
extraZxidsr/ZmodifiedbufferstartiZxidZxlenjrrr_strip_extras r8cCs,zt|rWdSWntk
r&YnXdS)NTF)_EndRecDataOSErrorfprrr_check_zipfiles
r=c	CsZd}z8t|drt|d}nt|d}t|}W5QRXWnttfk
rTYnX|S)NFreadr;rb)hasattrr=openr:r)filenameresultr<rrrr	s
c
Cs|t8}|dkr|S|||t}t|tkr<tdtt|\}}}}|tkr\|S|dksl|dkrtt	d|t
8}||krt	d||||}|t
}t|t
krtd|ts||kr||d}|t
}t|t
krtd|tst	dtt
|\
}}	}
}}}
}}}}|||ksN|	dt
|krVt	d||t<||t<|
|t<||t<||t<||t<||t<|||t<|S)	NrzUnknown I/O errorrz3zipfiles that span multiple disks are not supportedz.Corrupt zip64 end of central directory locatorz/Zip64 end of central directory record not foundrz-Corrupt zip64 end of central directory record)sizeEndCentDir64Locatorseekr>r0r:structr/structEndArchive64LocatorstringEndArchive64LocatorrsizeEndCentDir64
startswithstringEndArchive64structEndArchive64_ECD_SIGNATURE_ECD_DISK_NUMBER_ECD_DISK_START_ECD_ENTRIES_THIS_DISK_ECD_ENTRIES_TOTAL	_ECD_SIZE_ECD_OFFSET
_ECD_LOCATION)fpinoffsetendrecdataZsigZdisknoZreloffZdisksZextraszZszcreate_versionZread_versionZdisk_numZdisk_dirZdircountZ	dircount2ZdirsizeZ	diroffsetrrr
_EndRecData64s^






rZc	Csf|dd|}z|tdWntk
r<YdSX|}t|tkr|ddtkr|dddkrtt	|}t
|}|d||tt||t|St
|dtd}||d|}|t}|dkrb|||t}t|tkr
dSt
tt	|}|t}||t|t|}|||||t||||SdS)Nrrr sr-i)rEtellsizeEndCentDirr:r>r0stringEndArchiverFr/structEndArchivelistr1rZmaxrfind_ECD_COMMENT_SIZE)	rUZfilesizerXrWZmaxCommentStartr5ZrecDataZcommentSizecommentrrrr9s@



r9c@sXeZdZdZdddZddZdd	d
ZddZd
dZe	dddddZ
ddZdS)r
)
orig_filenamerB	date_time
compress_type_compresslevelrdr3
create_systemrYextract_versionreserved	flag_bitsvolume
internal_attr
external_attr
header_offsetCRC
compress_size	file_size	_raw_time_end_offsetNoNamerrrrrcCs||_|td}|dkr(|d|}tjdkrJtj|krJ|tjd}||_||_|ddkrjtdt	|_
d|_d|_d|_
tjdkrd|_nd|_t|_t|_d|_d|_d|_d|_d|_d|_dS)Nr/rxz+ZIP does not support timestamps before 1980r-Zwin32r)refindchrossepreplacerBrf
ValueErrorrrgrhrdr3sysplatformriDEFAULT_VERSIONrYrjrkrlrmrnroru)selfrBrfZ	null_byterrr__init__is2
zZipInfo.__init__cCsd|jj|jfg}|jtkr8|dt|j|j|jd?}|jd@}|rd|dt	
||rv|d||}|r|jr|d|j|r|j
r|jtks|j|j
kr|d|j
|d	d
|S)Nz<%s filename=%r compress_type=%sr)rz filemode=%rz external_attr=%#xz
 file_size=%rz compress_size=%r>)	__class__rrBrgrr1compressor_namesgetrostatfilemodeis_dirrsrrr2)rrChiloisdirrrr__repr__s0






zZipInfo.__repr__NcCs||j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}|jd
@rfd}}}n|j}|j}|j}|j}d}	|dkr|tkp|tk}|rd}
|t|
dt	|
d	||}|tks|tkr|st
dd
}d
}t}	|jt
krtt|	}	n|jtkrtt|	}	t|	|j|_t|	|j|_|\}}ttt|j|j||j|||||t|t|
}
|
||S)Nrrxr$rr!rrr&r rz<HHQQz'Filesize would require ZIP64 extensions)rfrlrqrrrsr3ZIP64_LIMITrFpackcalcsizer

ZIP64_VERSIONrgrra
BZIP2_VERSIONrLZMA_VERSIONrjrY_encodeFilenameFlagsstructFileHeaderstringFileHeaderrkr0)rzip64dtdosdatedostimerqrrrsr3min_versionfmtrBrlheaderrrr
FileHeaders^$$

zZipInfo.FileHeadercCsDz|jd|jfWStk
r>|jd|jdBfYSXdS)Nasciiutf-8)rBencoderlUnicodeEncodeErrorrrrrrszZipInfo._encodeFilenameFlagscCs|j}tj}t|dkr|d|dd\}}|dt|krPtd||f|dkrp|dkrv|d|dd}nV|dkr|d	|dd
}n:|dkr|d|dd
}n|dkrd}ntd||fd}|jdkrt||krtd|||_|d7}|jdkr6t||kr$td|||_|d7}|jdkrpt||krXtd|j}|||_|d7}||dd}qdS)Nr r,z"Corrupt extra field %04x (size=%d)rz<QQQr)z<QQrrz<Qrrr)lrz/Corrupt zip64 extra field. File size not found.rz3Corrupt zip64 extra field. Compress size not found.z3Corrupt zip64 extra field. Header offset not found.)r3rFr/r0rrsrrrp)rr3r/tpZlnZcountsidxoldrrr_decodeExtrasP



zZipInfo._decodeExtraTstrict_timestampsc	Cst|tjrt|}t|}t|j}t|j	}|dd}|sZ|ddkrZd}n|sn|ddkrnd}|dkrz|}tj
tj
|d}|dtj
tjfkr|dd}q|r|d7}|||}|jd	@d
>|_|rd|_|jd
O_n|j|_|S)Nrr"rxrw;)rr;rrryrr))
isinstancer|PathLikefspathrS_ISDIRst_modetime	localtimest_mtimepathnormpath
splitdriver}altseprorsst_size)	clsrBarcnamerstrmtimerfzinforrr	from_files0



zZipInfo.from_filecCs|jddkS)NryrBrrrrr7szZipInfo.is_dir)rvrw)N)N)rrr	__slots__rrrrrclassmethodrrrrrrr
Ns
,
.2%cCs0tdD]"}|d@r"|d?dA}q|dL}q|S)Nrrl q[)range)crcr7rrr_gen_crcAs

rcsldddtdkr&ttttdatfddfdd|D]}|qLfd	d
}|S)NixV4igE#ixV4cs|d?||Ad@AS)Nrr)Zchr)crctablerrcrc32[sz_ZipDecrypter.<locals>.crc32cs<|d@d@ddd@d?dS)Nrrirrr)c)rkey0key1key2rrupdate_keys_s
z"_ZipDecrypter.<locals>.update_keyscsNt}|j}|D]4}dB}|||dAd?d@N}|||qt|S)Nrrrr)	bytearrayr1bytes)rXrCr1rk)rrrr	decrypteris
z _ZipDecrypter.<locals>.decrypter)	_crctabler`maprr)pwdprr)rrrrrrr
_ZipDecrypterQs
rc@s,eZdZddZddZddZddZd	S)
LZMACompressorcCs
d|_dSN)_comprrrrryszLZMACompressor.__init__cCsFtdtji}tjtjttj|gd|_tdddt	||S)Nidfiltersz<BBHr$r )
lzmaZ_encode_filter_propertiesFILTER_LZMA1r
FORMAT_RAW_decode_filter_propertiesrrFrr0)rZpropsrrr_init|s

zLZMACompressor._initcCs*|jdkr||j|S|j|Sr)rrcompress)rrXrrrrs
zLZMACompressor.compresscCs&|jdkr||jS|jSr)rrflushrrrrrs
zLZMACompressor.flushN)rrrrrrrrrrrrwsrc@s*eZdZddZeddZd	ddZdS)
LZMADecompressorcCsd|_d|_d|_dS)Nr-F)_decomp_unconsumedeofrrrrrszLZMADecompressor.__init__cCs|jdkrdS|jjSNT)rneeds_inputrrrrrs
zLZMADecompressor.needs_inputrc	Cs|jdkr|j|7_t|jdkr*dStd|jdd\}t|jd|krXdStjtjttj	|jdd|gd|_|jd|d}|`|j
||}|jj|_|S)Nr r-z<Hrr)rrr0rFr/rrrrr
decompressr)rrXZ
max_lengthZpsizerCrrrrs"


zLZMADecompressor.decompressN)r)rrrrpropertyrrrrrrrs
rZstoreZshrinkreduceZimplodetokenizeZdeflateZ	deflate64Zbzip2rZterseZlz77ZwavpackZppmd)rrrrr r!r"r#rr$r%rrr+abcCsX|tkr
nJ|tkr tsTtdn4|tkr6tsTtdn|tkrLtsTtdntddS)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)	rrzlibRuntimeErrorrbz2rrNotImplementedError)compressionrrr_check_compressions$rcCsj|tkr2|dk	r t|tjdSttjtjdS|tkrT|dk	rLt|StS|tkrbt	SdSdS)N)
rrZcompressobjZDEFLATEDZZ_DEFAULT_COMPRESSIONrrZ
BZ2Compressorrr)rg
compresslevelrrr_get_compressors
rcCsvt||tkrdS|tkr&tdS|tkr6tS|tkrDt	St
|}|rdtd||fntd|fdS)Nrzcompression type %d (%s)zcompression type %d)
rrrrZ
decompressobjrrZBZ2Decompressorrrrrr)rgZdescrrrr_get_decompressors

rc@s0eZdZddZdddZd
ddZd	d
ZdS)_SharedFilecCs2||_||_||_||_||_|j|_|j|_dSr)_file_pos_close_lock_writingseekabler\)rfileposcloselockZwritingrrrrsz_SharedFile.__init__rc
CsN|j>|rtd|j|||j|_|jW5QRSQRXdS)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
rrrrEr\r)rrVwhencerrrrEsz_SharedFile.seekrc
CsX|jH|rtd|j|j|j|}|j|_|W5QRSQRXdS)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
rrrrErr>r\rnrXrrrr>sz_SharedFile.readcCs$|jdk	r |j}d|_||dSr)rr	)rfileobjrrrrs
z_SharedFile.closeN)r)r)rrrrrEr>rrrrrrs	


rc@s4eZdZddZddZddZddZd	d
ZdS)	_TellablecCs||_d|_dSNr)r<rVrr<rrrr#sz_Tellable.__init__cCs|j|}|j|7_|Sr)r<writerV)rrXrrrrr'sz_Tellable.writecCs|jSr)rVrrrrr\,sz_Tellable.tellcCs|jdSr)r<rrrrrr/sz_Tellable.flushcCs|jdSr)r<rrrrrr2sz_Tellable.closeN)rrrrrr\rrrrrrr"s
rcseZdZdZdZdZd'ddZdd	Zd
dZd(d
dZ	d)ddZ
ddZd*ddZddZ
ddZddZddZfddZd d!Zd+d#d$Zd%d&ZZS),
ZipExtFilei@iiNFcCs(||_||_||_|j|_|j|_|j|_t	|j|_
d|_d|_d|_
d|_||_|j|_t|drz|j|_td|_nd|_d|_z4|r||_|j|_|j|_|j|_d|_Wntk
rYnXd|_|r$|j d@r|j!d?d@}n|jd?d@}|"}||kr$t#d	|j$dS)
NFr-rrqTrrrzBad password for file %r)%_fileobj_pwd_close_fileobjrg_compress_typerr_compress_leftrs_leftr
_decompressor_eof_readbuffer_offsetnewlinesmoderBnamer@rq
_expected_crcr_running_crc	_seekablerr\_orig_compress_start_orig_compress_size_orig_file_size_orig_start_crcAttributeError
_decrypterrlrt_init_decrypterrre)rrr&zipinforZ
close_fileobjZ
check_bytehrrrrDsF




zZipExtFile.__init__cCs4t|j|_|jd}|jd8_||dS)Nrr&)rrr0rr>r)rrrrrr1wszZipExtFile._init_decryptercCsvd|jj|jjfg}|jsX|d|j|jf|jtkrb|dt	
|j|jn
|d|dd|S)N<%s.%sz name=%r mode=%rr	 [closed]rr)rrrclosedr1r'r&rrrrr2rrCrrrrs


zZipExtFile.__repr__rcCsL|dkr>|jd|jd}|dkr>|j|j|}||_|Stj||S)Nr
r)r#rzr$ioBufferedIOBasereadline)rlimitr6linerrrr;szZipExtFile.readlinercCsr|t|j|jkr\||}t||jkrJ||j|jd|_d|_n|jt|8_|j|j|jdS)Nri)r0r#r$r>)rrchunkrrrpeeks
zZipExtFile.peekcCsdSrrrrrrreadableszZipExtFile.readablecCs|dks|dkrH|j|jd}d|_d|_|jsD|||j7}q,|S||j}|t|jkrz|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkr|js||}|t|kr||_||_||d|7}q||7}|t|8}q|SNrr-r#r$r"_read1MAX_Nr0)rrbufendrXrrrr>s4

zZipExtFile.readcCs@|jdkrdSt||j|_|jr<|j|jkr<td|jdS)NzBad CRC-32 for file %r)r(rr)r"rr')rnewdatarrr_update_crcs

zZipExtFile._update_crccCs|dks|dkrR|j|jd}d|_d|_|jsN||j}|r,||7}qNq,|S||j}|t|jkr|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkr|js||}|t|kr||_||_||d|7}q|r||7}qq|SrArB)rrrErXrFrrrread1s>


zZipExtFile.read1cCs|js|dkrdS|jtkrH|jj}|t|kr||||t|7}n4|jtkr^||}nt|jddrx||}nd}|jtkr|j	dk|_n|jtkrt
||j}|j||}|jj
p|j	dko|jj|_|jr||j7}ndz|j|t
||j}Wn"tk
r(|j|}YnX|jj
pL|j	dkoLt|jdd|_|d|j}|jt|8_|jdkrd|_|||S)Nrr-rT)r"rrr!Zunconsumed_tailr0_read2rgetattrrra
MIN_READ_SIZErrr	TypeErrorr rHrrrrrCsH






zZipExtFile._read1cCsd|jdkrdSt||j}t||j}|j|}|jt|8_|sLt|jdk	r`||}|SrA)	rrarLminrr>r0EOFErrorr0rrrrrJ4s


zZipExtFile._read2cs&z|jr|jW5tXdSr)superrrrrrrrrDszZipExtFile.closecCs|jSr)r*rrrrrKszZipExtFile.seekablercCs>|jstd|}|dkr&|}n.|dkr8||}n|dkrL|j|}ntd||jkrd|j}|dkrpd}||}||j}|dkr|t|jkr||_d}nf|dkr
|j	
|j|j|_
|j|_|j|_d|_d|_t|j|_d|_|}|jdk	r
||dkr6t|j|}||||8}q
|S)N!underlying stream is not seekablerrrzCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)r-F)r*r9UnsupportedOperationr\r-rr$r0r#rrEr+r.r)r,rr rrr!r"r0r1rN
MAX_SEEK_READr>)rrVrZcurr_posZnew_posZread_offsetZbuff_offsetZread_lenrrrrENsH






zZipExtFile.seekcCs0|jstd|j|jt|j|j}|S)NrR)r*r9rSr-r r0r#r$)rZfileposrrrr\~s
zZipExtFile.tell)NF)r)r)r)r)rrrrDrLrTrr1rr;r?r@r>rHrIrCrJrrrEr\
__classcell__rrrQrr6s(
3



!
%4
0rcs@eZdZddZeddZddZddZfd	d
ZZ	S)
_ZipWriteFilecCs8||_||_||_t|j|j|_d|_d|_d|_	dSr)
_zinfo_zip64_zipfilerrgrh_compressor
_file_size_compress_size_crc)rzfrrrrrrsz_ZipWriteFile.__init__cCs|jjSr)rYr<rrrrrsz_ZipWriteFile._fileobjcCsdSrrrrrrwritablesz_ZipWriteFile.writablecCsf|jrtdt|}|j|7_t||j|_|jrV|j|}|jt|7_|j	
||S)NzI/O operation on closed file.)r6rr0r[rr]rZrr\rr)rrXnbytesrrrrsz_ZipWriteFile.writec	sb|jr
dSzFt|jrR|j}|jt|7_|j	
||j|j_n
|j
|j_|j|j_|j
|j_|jjd@r|jrdnd}|j	
t|t|jj|jj|jj|j	|j_nn|js|j
tkrtd|jtkrtd|j	|j_|j	|jj|j	
|j|j|j	|jj|jj|j|j|jj|jj <W5d|j_XdS)NFrz<LLQQz<LLLLz+File size unexpectedly exceeded ZIP64 limitz1Compressed size unexpectedly exceeded ZIP64 limit)!r6rYrrPrrZrr\r0rrrWrrr[r]rqrsrlrXrFr
_DD_SIGNATUREr\	start_dirrrrErprfilelistr1
NameToInforB)rrErrQrrrsF






z_ZipWriteFile.close)
rrrrrrr_rrrUrrrQrrVs

rVc@s eZdZdZdZdeddfddddZddZd	d
ZddZ	d
dZ
ddZddZd<ddZ
ddZddZddZeddZejddZd=ddZd>d d!d"d#Zd?d$d%Zd@d&d'ZdAd(d)Zed*d+Zd,d-Zd.d/ZdBd0d1ZdCd2d3Zd4d5Zd6d7Z d8d9Z!d:d;Z"dS)DrNrTrc
	CsP|dkrtdt|||_d|_d|_i|_g|_||_||_||_	d|_
d|_||_t
|tjrpt|}t
|trd|_||_dddd	dd
dd}||}zt|||_Wqtk
r||kr||}YqYqXqqnd
|_||_t|dd|_d
|_t|_d|_d|_z|dkr4|n|dkrd|_z|j |_!Wn2t"tfk
rt#|j|_d|_!d|_Yn6Xz|j$|j!Wn t"tfk
rd|_YnXnf|dkrz||j$|j!Wn6t%k
r|j$ddd|_|j |_!YnXntdWn$|j}	d|_|&|	YnXdS)N)rewxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'Frr-r?w+bx+br+bwbZxb)rerfrgrhrkrirjrr'Tre)rfrgrhrz"Mode must be 'r', 'w', 'x', or 'a')'rr_allowZip64
_didModifydebugrdrcrrr&r_comment_strict_timestampsrr|rrstr_filePassedrBr9rAr<r:rK_fileRefCnt	threadingRLockr
r*r_RealGetContentsr\rbr/rrEr_fpclose)
rr
r&r
allowZip64rrZmodeDictrr<rrrrs







zZipFile.__init__cCs|Srrrrrr	__enter__GszZipFile.__enter__cCs|dSrr)rtypevalue	tracebackrrr__exit__JszZipFile.__exit__cCsd|jj|jjfg}|jdk	rd|jr8|d|jn|jdk	rR|d|j|d|jn
|d|dd|S)Nr4z file=%rz filename=%rz mode=%rr5rr)	rrrr<rsr1rBr&r2r7rrrrMs



zZipFile.__repr__cCs|j}zt|}Wntk
r.tdYnX|s<td|jdkrNt||t}|t}|t|_	|t
||}|jdkr||}td||||||_||jd|
|}t|}d}||kr|
t}	t|	tkrtdtt|	}	|	ttkrtd|jdkr&t|	|
|	t}
|	d}|d	@rR|
d
}
n
|
d}
t|
}|
|	t|_|
|	t|_|	t|_|	dd\|_ |_!|_"|_#|_$|_%}
}|_&|_'|_(|j"t)krt*d
|j"d|	dd\|_+|_,|_-|
|_.|d?d|d?d@|d@|
d?|
d?d@|
d@df|_/|0|j||_|j12|||j3|j4<|t|	t|	t|	t}|jdkrtd|q|j}t5|j1ddddD]}||_6|j}qdS)NzFile is not a zip filerrzgiven, inferred, offsetrzTruncated central directoryz&Bad magic number for central directoryr!rrcp437rzzip file version %.1fr%r(r+r$rxrr&rtotalcSs|jSr)rp)rrrr<lambda>r-z*ZipFile._RealGetContents.<locals>.<lambda>T)keyreverse)7r<r9r:rroprintrRrS_ECD_COMMENTrprTrbrEr>r9BytesIOsizeCentralDirr0rFr/structCentralDir
_CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHdecoder
_CD_EXTRA_FIELD_LENGTHr3_CD_COMMENT_LENGTHrd_CD_LOCAL_HEADER_OFFSETrprYrirjrkrlrgrqrrrsMAX_EXTRACT_VERSIONrrmrnrortrfrrcr1rdrBsortedru)rr<rWZsize_cdZ	offset_cdconcatZinferredrXrcentdirrBflagsrgtdZ
end_offsetrrrrrw[s















zZipFile._RealGetContentscCsdd|jDS)NcSsg|]
}|jqSrr).0rXrrr
<listcomp>sz$ZipFile.namelist.<locals>.<listcomp>rcrrrrnamelistszZipFile.namelistcCs|jSrrrrrrinfolistszZipFile.infolistcCsLtdd|d|jD]0}d|jdd}td|j||jf|dqdS)Nz%-46s %19s %12s)z	File NamezModified    ZSizer
z%d-%02d-%02d %02d:%02d:%02dr"z
%-46s %s %12d)rrcrfrBrs)rr
rdaterrrprintdirs
zZipFile.printdirc
Cs^d}|jD]N}z*||jd}||r,q W5QRXWq
tk
rV|jYSXq
dS)Nire)rcrArBr>r)rZ
chunk_sizerfrrrtestzips

zZipFile.testzipcCs$|j|}|dkr td||S)Nz(There is no item named %r in the archive)rdrKeyError)rr'inforrrgetinfoszZipFile.getinfocCs6|r t|ts tdt|j|r,||_nd|_dS)Npwd: expected bytes, got %s)rrrMr|rr)rrrrrsetpasswords
zZipFile.setpasswordcCs|jSr)rprrrrrdszZipFile.commentcCs^t|tstdt|jt|tkrNddl}|jdtdd|dt}||_	d|_
dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesr
stacklevelT)rrrMr|rr0ZIP_MAX_COMMENTwarningswarnrprn)rrdrrrrrds
c
Cs.||d|}|W5QRSQRXdSNrerAr>)rr'rr<rrrr>szZipFile.readFforce_zip64csJ|dkrtd|r0t|ts0tdt|j|rD|dkrDtdjsRtdt|trb|}n,|dkrt|}j|_	j
|_n
|}|dkrj
||dSjrtdjd	7_tj|jjjfd
d}zL|t}t|tkrtdtt|}|ttkr&td
||t}|trL||t|jd@r`t d|jd@rtt d|t!d@r|"d}	n
|"d}	|	|j#krtd|j#|f|j$dk	r|%|j&|j$krtd|j#d|jd	@}
|
r|sj'}|st(d|nd}t)||||dWS|*YnXdS)N>rerfzopen() requires mode "r" or "w"rrfz'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedrrrcsjSr)rrrrrr%r-zZipFile.open.<locals>.<lambda>zTruncated file headerz Bad magic number for file header z$compressed patched data (flag bit 5)@zstrong encryption (flag bit 6)rrrz/File name in directory %r and header %r differ.zOverlapped entries: z (possible zip bomb)z6File %r is encrypted, password required for extractionT)+rrrrMr|rr<r
rrgrrhr_open_to_writerrtrrprxr
r>sizeFileHeaderr0rrFr/r
_FH_SIGNATUREr_FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHrlr_FH_GENERAL_PURPOSE_FLAG_BITSrrerur\rrrrrr)rr'r&rrrZzef_fileZfheaderfnameZ	fname_strZis_encryptedrrrrAs








zZipFile.opencCs|r|jstd|jr tdt|ds0d|_d|_d|_d|_|jt	krZ|jdO_|j
sn|jdO_|jszd|_|jo|p|jdtk}|j
r|j
|j|j
|_||d	|_|j
||d	|_t|||S)
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.rsrrrg?T)rmrrr@rsrrrqrlrgrr*rorr<rErbr\rp_writecheckrnrrrV)rrrrrrrrZs8



zZipFile._open_to_writecCs*|dkrt}n
t|}||||Sr)r|getcwdr_extract_member)rmemberrrrrrextracts

zZipFile.extractcCsH|dkr|}|dkr"t}n
t|}|D]}||||q0dSr)rr|rrr)rrmembersrr2rrr
extractalls

zZipFile.extractallcCs^|j}|s(d}t|dt|}||_||}dd||D}|dd|D}|S)Nz:<>|"?*_css|]}|dVqdS).N)rstriprrgrrr	<genexpr>sz1ZipFile._sanitize_windows_name.<locals>.<genexpr>css|]}|r|VqdSrrrrrrrs)!_windows_illegal_name_trans_tablerr	maketransr0	translatesplitr2)rrpathseptableZillegalrrr_sanitize_windows_names
zZipFile._sanitize_windows_namec
sLt|ts||}|jdtjj}tjjrB|tjjtjj}tj	|d}dtjj
tjjftjjfdd|
tjjD}tjjdkr||tjj}tj||}tj|}tj|}|rtj|st||rtj|st||S|j||d(}t|d}t||W5QRXW5QRX|S)	Nryrrc3s|]}|kr|VqdSrrrZinvalid_path_partsrrrsz*ZipFile._extract_member.<locals>.<genexpr>\)rrl)rr
rrBr~r|rr}rrcurdirpardirr2rrrdirnameexistsmakedirsrrmkdirrAshutilcopyfileobj)rrZ
targetpathrrZ	upperdirssourcetargetrrrrs2

&


 zZipFile._extract_membercCs|j|jkr(ddl}|jd|jdd|jdkr:td|jsHtdt|j|j	sd}t
|jtkrpd}n|j
tkrd	}n|jtkrd
}|rt|ddS)NrzDuplicate name: %rrrrfrgrhz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closedFiles countZFilesizezZipfile size would require ZIP64 extensions)rBrdrrr&rr<rrgrmr0rcZIP_FILECOUNT_LIMITrsrrpr
)rrrrequires_zip64rrrrs,



zZipFile._writecheckc
CsP|jstd|jrtdtj|||jd}|rDd|_d|_n0|dk	rT||_	n|j
|_	|dk	rl||_n|j|_|r|j
|jr|j|j|j|_|j	tkr|jdO_||d|_|j|||j|j<|j|d|j|_W5QRXn<t|d,}||d	}t||d
W5QRXW5QRXdS)N7Attempt to write to ZIP archive that was already closedz>Can't write to ZIP archive while an open writing handle existsrrrTFr?rfi ) r<rrr
rrqrrrrqrgrrhrr
r*rErbr\rprrlrrnrcr1rdrBrrrArr)rrBrrgrrsrcdestrrrrsF


z
ZipFile.writec
Cst|tr|d}t|tsxt|ttddd}|j|_|j|_	|j
ddkrpd|_|jdO_q|d|_n|}|jst
d	|jrt
d
|dk	r||_|dk	r||_	t||_|j*|j|dd}||W5QRXW5QRXdS)
Nrr")rBrfrryiAr)rrz?Can't write to ZIP archive while an open writing handle exists.rf)r&)rrrrr
rrrrgrrhrBror<rrr0rsr
rAr)rZzinfo_or_arcnamerXrgrrrrrrwritestr$s:



zZipFile.writestrcCs|dSrr{rrrr__del__MszZipFile.__del__c	Cs||jdkrdS|jrtdzB|jdkr\|jr\|j"|jrJ|j|j	|
W5QRXW5|j}d|_||XdS)NzvCan't close the ZIP file while there is an open writing handle on it. Close the writing handle before closing the zip.r)r<rrrxr&rnr
r*rErb_write_end_recordrrrrrQs
z
ZipFile.closecCs|jD]D}|j}|ddd>|dd>B|dB}|dd>|d	d>B|ddB}g}|jtksr|jtkr||j||jd
}d
}n|j}|j}|jtkr||jd
}n|j}|j}	d}
|rt|	d}	t	j
dd
t|ddt|f||	}	t}
|j
tkr$tt|
}
n|j
tkr:tt|
}
t|
|j}t|
|j}zZ|\}
}t	
tt||j||j||j
|||j||t|
t|	t|jd|j|j|}Wnltk
rttt||j||j|j |j
|||j||t|j!t|	t|jd|j|j|ft"j#dYnX|j$%||j$%|
|j$%|	|j$%|jq|j$&}t|j}||j'}|j'}d}|t(krd}n|tkrd}n|tkrd}|r(|j)st*|dt	
t+t,t-ddddd||||}|j$%|t	
t.t/d|d}|j$%|t0|d}t0|d
}t0|d
}t	
t1t2dd||||t|j3	}|j$%||j$%|j3|j4dkrx|j$5|j$6dS)Nrrxr$rr!rrr&r r)rr,QrrrzCentral directory offsetzCentral directory sizerrrrrh)7rcrfrsrrrr1rpr3r8rFrr0rrgrrarrrrjrYrrrrirkrqrdrnroDeprecationWarningrrlrBrstderrr<rr\rbrrmr
rLrKrIrGrHrNr_r^rpr&truncater)rrrrrr3rsrrrpZ
extra_datarrjrYrBrlrZpos2ZcentDirCountZcentDirSizeZ
centDirOffsetrZzip64endrecZzip64locrecrWrrrrgs$$














zZipFile._write_end_recordcCs&|jd8_|js"|js"|dSNr)rtrsrrrrrrxszZipFile._fpclose)N)N)reN)F)NN)NNN)NNN)NN)#rrrr<rrrrzrrrwrrrrrrrrdsetterr>rArrrrrrrrrrrrrxrrrrrsRZQ
	
		


f
+


*
2
)hc@s0eZdZdeddfddZddd	Zd
dZdS)
rreTrcCstj|||||d||_dS)N)r&rry)rr	_optimize)rr
r&rryoptimizerrrrszPyZipFile.__init__rNcCst|}|rD||sD|jr@tj|r,dnd}td||fdStj|\}}tj|rhtj|d}tj|r|rd||f}n|}|jrtd|d||	|dd	|\}}	|jrtd
|	|
||	tt|}
|

d|
D]}tj||}tj|\}
}tj|rRtjtj|dr|j|||dq|dkr|r~||s~|jrtd
|q|	|dd	|\}}	|jrtd
|	|
||	qn|jrtd|tt|D]}tj||}tj|\}
}|dkr|r,||s,|jrtd
|q|	|dd	|\}}	|jrVtd
|	|
||	qnP|d	ddkrtd|	|dd	|\}}	|jrtd|	|
||	dS)Nrr
z%s %r skipped by filterfuncz__init__.py%s/%szAdding package inasrZAdding)
filterfunc.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"zAdding file)r|rrorrrrr2isfile
_get_codenamerrlistdirremovesplitextwritepyr)rpathnamebasenamerZlabeldirr'ZinitnamerrZdirlistrBrrootZextrrrrs







zPyZipFile.writepyc
sdfdd	}|d}|d}tjj|dd}tjj|dd}tjj|d	d}jdkr\tj|rt|jt|jkr|}	}
ntj|rt|jt|jkr|}
|}	ntj|rt|jt|jkr|}
|}	nvtj|rt|jt|jkr|}
|}	nD||rRt	j
jd
kr4|}
nt	j
jdkrH|}
n|}
|}	n|}
}	njd
krr|}
|}	n<|}	jdkr|}
n&jd	kr|}
ndj}t
|tj|
rt|
jt|jks||jds|}
}	tj|	d}|rd
||f}|
|fS)Nrc
sfddl}jrtd|z|j|d|dWn4|jk
r`}zt|jWYdSd}~XYnXdS)NrZ	CompilingT)doraiserF)
py_compilerorcompilePyCompileErrormsg)r
rrerrrrr_compile8s

z)PyZipFile._get_codename.<locals>._compilerz.pycr)optimizationrrrz"invalid value for 'optimize': {!r})rr)r)	importlibutilcache_from_sourcerr|rrrrrrrformatrr)
rrrrZfile_pyZfile_pycZpycache_opt0Zpycache_opt1Zpycache_opt2rrrZarchivenamerrrr1sj


zPyZipFile._get_codename)rN)rrrrrrrrrrrrs

RcCstt|ddSr)	itertoolsislice	_ancestry)rrrr_parentssr
ccs2|tj}|tjr.|Vt|\}}qdSr)r	posixpathr}r)rtailrrrr	sr	cCstt|j|Sr)rfilterfalseset__contains__)ZminuendZ
subtrahendrrr_differencesrcsDeZdZeddZfddZddZddZed	d
Z	Z
S)CompleteDirscCs.tjtt|}dd|D}tt||S)Ncss|]}|tjVqdSr)rr})rrrrrrsz-CompleteDirs._implied_dirs.<locals>.<genexpr>)rchain
from_iterablerr
_deduper)namesparentsZas_dirsrrr
_implied_dirsszCompleteDirs._implied_dirscs tt|}|t||Sr)rPrrr`r)rrrQrrrszCompleteDirs.namelistcCst|Sr)rrrrrr	_name_setszCompleteDirs._name_setcCs,|}|d}||ko||k}|r(|S|SNry)r)rr'rrZ	dir_matchrrrresolve_dirszCompleteDirs.resolve_dircCsNt|tr|St|ts ||Sd|jkr.t}||}t|t||Sr)rrrr&__new__varsupdate)rrresrrrmakes



zCompleteDirs.make)rrrstaticmethodrrrrrrrUrrrQrrs

rcs(eZdZfddZfddZZS)
FastLookupc
s:tt|jW5QRSQRXtt||_|jSr)
contextlibsuppressr/Z_FastLookup__namesrPr!rrrQrrrszFastLookup.namelistc
s:tt|jW5QRSQRXtt||_|jSr)r"r#r/Z_FastLookup__lookuprPr!rrrQrrrszFastLookup._name_set)rrrrrrUrrrQrr!sr!c@seZdZdZd"ddZeddZeddZd	d
ZddZ	d
dZ
ddZddZddZ
ddZddZddZddZddZeZedd Zd!S)#rz>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})rcCst||_||_dSr)r!rrat)rrr$rrrrE	sz
Path.__init__cCst|jj|jSr)	functoolspartialrrAr$rrrrrAI	sz	Path.opencCst|jdSr)rrr$rrrrrr'M	sz	Path.namec
Os6|$}tj|f||W5QRSQRXdSr)rAr9
TextIOWrapperr>)rargskwargsstrmrrr	read_textQ	s
zPath.read_textc
Cs(|}|W5QRSQRXdSrr)rr*rrr
read_bytesU	s
zPath.read_bytescCst|jd|jdkSr)rrr$r)rrrrr	_is_childY	szPath._is_childcCst|j|Sr)rr)rr$rrr_next\	sz
Path._nextcCs|jp|jdSr)r$endswithrrrrr_	szPath.is_dircCs
|Sr)rrrrris_fileb	szPath.is_filecCs|j|jkSr)r$rrrrrrre	szPath.existscCs.|stdt|j|j}t|j|S)NzCan't listdir a file)rrrr.rrfilterr-)rZsubsrrriterdirh	szPath.iterdircCst|jj|jSr)rr2rrBr$rrrr__str__n	szPath.__str__cCs|jj|dS)Nr)_Path__reprrrrrrrq	sz
Path.__repr__cCs t|j|}||j|Sr)rr2r$r.rr)raddnextrrrjoinpatht	sz
Path.joinpathcCs(t|jd}|r|d7}||Sr)rrr$rr.)rZ	parent_atrrrparentz	szPath.parentN)r)rrrr4rrrAr'r+r,r-r.rr0rr2r3rr7__truediv__r8rrrrr	s(A


c
	sddl}d}|j|d}|jdd}|jdddd	d
|jddd
ddd|jdddddd|jddddd
||}|jdk	r|j}t|d}|}W5QRX|rtd	|tdn|j
dk	r|j
}t|d}|W5QRXn|jdk	r,|j\}}t|d}|
|W5QRXn|jdk	r|jd}	|j}
fddt|	d\}|
D]P}tj|}|stjtj|}|dtjtjfkrd}|||qfW5QRXdS) Nrz3A simple command-line interface for zipfile module.)descriptionT)Zrequiredz-lz--list	<zipfile>zShow listing of a zipfile)metavarhelpz-ez	--extractr)r;z<output_dir>zExtract zipfile into target dir)nargsr<r=z-cz--create+)z<name>z<file>zCreate zipfile from sourcesz-tz--testzTest if a zipfile is validrez.The following enclosed file is corrupted: {!r}zDone testingcsptj|r|||tnPtj|rl|r8|||tt|D]$}|tj||tj||qFdSr)	r|rrrrrrrr2)r^rzippathZnmaddToZiprrrB	szmain.<locals>.addToZiprfr)argparseArgumentParserZadd_mutually_exclusive_groupadd_argument
parse_argsZtestrrrrr`rrrZcreatepopr|rrrrr)
r(rCr:parsergrouprr^ZbadfilerZzip_namefilesrr@rrArmain	s\








rK__main__)N)N)Zbinasciir%importlib.utilrr9rr|rrrrFrrurr"rrImportErrorrr__all__	Exceptionrr
rrrrrrrrrrrrrrr_r^rr]rMrNrOrPrQrRrSrcrrTrrrrZ_CD_CREATE_VERSIONZ_CD_CREATE_SYSTEMZ_CD_EXTRACT_VERSIONZ_CD_EXTRACT_SYSTEMZ
_CD_FLAG_BITSZ_CD_COMPRESS_TYPEZ_CD_TIMEZ_CD_DATEZ_CD_CRCZ_CD_COMPRESSED_SIZEZ_CD_UNCOMPRESSED_SIZErrrZ_CD_DISK_NUMBER_STARTZ_CD_INTERNAL_FILE_ATTRIBUTESZ_CD_EXTERNAL_FILE_ATTRIBUTESrrrrrZ_FH_EXTRACT_VERSIONZ_FH_EXTRACT_SYSTEMrZ_FH_COMPRESSION_METHODZ_FH_LAST_MOD_TIMEZ_FH_LAST_MOD_DATEZ_FH_CRCZ_FH_COMPRESSED_SIZEZ_FH_UNCOMPRESSED_SIZErrrGrHrDrLrKrIZ_CD64_SIGNATUREZ_CD64_DIRECTORY_RECSIZEZ_CD64_CREATE_VERSIONZ_CD64_EXTRACT_VERSIONZ_CD64_DISK_NUMBERZ_CD64_DISK_NUMBER_STARTZ_CD64_NUMBER_ENTRIES_THIS_DISKZ_CD64_NUMBER_ENTRIES_TOTALZ_CD64_DIRECTORY_SIZEZ_CD64_OFFSET_START_CENTDIRraZStructr.r8r=r	rZr9objectr
rrrrrrrrrrrr:rrVrrr
r	dictfromkeysrrrr!rrKrrrrr<module>sj









<<s&&
&QN	/2
=