/snap/core22/2437/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc289770644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc423120644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc135730644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc706740644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc170000644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /snap/core22/2437/usr/lib/python3.10/__pycache__/zipfile.cpython-310.pyc (61845B)
o p̦ib@sLdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZz ddlZejZWneyUdZejZYnwzddlZWn eygdZYnwzddlZWn eyydZYnwgdZGdddeZGdddeZeZZdZd Zd ZdZd Z d Z!d Z"d Z#dZ$dZ%dZ&dZ'dZ(dZ)e *e(Z+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3d Z4dZ5dZ6dZ7e *e6Z8dZ9dZ:dZ;dZdZ?dZ@d ZAdZBdZCdZDd ZEdZFd ZGd ZHd!ZId"ZJd#ZKd$ZLd%ZMe *eLZNdZOdZPdZQdZRdZSdZTdZUdZVd ZWdZXdZYdZZd&Z[d'Z\e *e[Z]d(Z^d)Z_e *e^Z`dZadZbdZcdZddZedZfdZgdZhd ZidZjd*Zke ld+Zmd,d-Znd.d/Zod0d1Zpd2d3Zqd4d5ZrGd6d7d7esZtdaud8d9Zvd:d;ZwGdd?d?Zyidd@ddAddBddBddBddBddCddDd dEddFddCd dGd dHd#dIdJdKdLdMdNdOZzdPdQZ{dsdRdSZ|dTdUZ}GdVdWdWZ~GdXdYdYZGdZd[d[ejZGd\d]d]ejZGd^d_d_ZGd`dadaeZdbdcZdddeZejZ dfdgZGdhdidieZGdjdkdkeZdsdldmZGdndodoZdsdpdqZedrkr$edSdS)tzP Read and write ZIP files. XXX references to utf-8 need further investigation. N) BadZipFile BadZipfileerror ZIP_STORED ZIP_DEFLATED ZIP_BZIP2ZIP_LZMA is_zipfileZipInfoZipFile PyZipFile LargeZipFilePathc@s eZdZdS)rN)__name__ __module__ __qualname__rr/usr/lib/python3.10/zipfile.pyr,src@seZdZdZdS)r zu Raised when writing a zipfile, the zipfile requires ZIP64 extensions and those extensions are disabled. N)rrr__doc__rrrrr 0sr i -.?s<4s4H2LHsPK z<4s4B4HL2L5H2LsPK z <4s2B4HL2L2HsPKz<4sLQLsPKz <4sQ2H2L4QsPKiPKr)filenameresultr@rrrr s    r c Cs|t8}|dkr |S|||t}t|tkrtdtt|\}}}}|tkr.|S|dks6|dkr:t d|t 8}||krFt d||||}|t }t|t kr^td| t s}||kr}||d}|t }t|t kr}td| t st dtt |\ }} } } } } }}}}|||ks| dt |krt d||t<| |t<| |t<||t<||t<||t<||t<|||t<|S) zM Read the ZIP64 end-of-archive records and use that to update endrec rzUnknown 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)sizeEndCentDir64LocatorseekrBr0r>structr/structEndArchive64LocatorstringEndArchive64LocatorrsizeEndCentDir64 startswithstringEndArchive64structEndArchive64_ECD_SIGNATURE_ECD_DISK_NUMBER_ECD_DISK_START_ECD_ENTRIES_THIS_DISK_ECD_ENTRIES_TOTAL _ECD_SIZE _ECD_OFFSET _ECD_LOCATION)fpinoffsetendrecdatasigdisknoreloffdisksextraszszcreate_version read_versiondisk_numdisk_dirdircount dircount2dirsize diroffsetrrr _EndRecData64sV             rkc Cs`|dd|}z |t dWn tyYdSw|}t|tkrV|ddtkrV|dddkrVtt |}t |}| d| |tt ||t|St |dtd}||d|}|t}|dkr|||t}t|tkrdSt tt |}|t}||t|t|}| || ||t ||||SdS) 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.rrNr sr-i)rItellsizeEndCentDirr>rBr0stringEndArchiverJr/structEndArchivelistr1rkmaxrfind_ECD_COMMENT_SIZE) rYfilesizer\r[maxCommentStartr7recData commentSizecommentrrrr=s>         r=c@s\eZdZdZdZdddZddZdd d Zd d ZddZ e dddddZ ddZ d S)r z>Class with attributes describing each file in the ZIP archive.) orig_filenamerF date_time compress_type_compresslevelryr3 create_systemrcextract_versionreserved flag_bitsvolume internal_attr external_attr header_offsetCRC compress_size file_size _raw_time _end_offsetNoNamerrrrrcCs||_|td}|dkr|d|}tjdkr%tj|vr%|tjd}||_||_|ddkr5tdt |_ d|_ d|_ d|_ tjdkrJd|_nd|_t|_t|_d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr/rz+ZIP does not support timestamps before 1980r-win32r)rzfindchrossepreplacerFr{ ValueErrorrr|r}ryr3sysplatformr~DEFAULT_VERSIONrcrrrrrrrrr)selfrFr{ null_byterrr__init__ls6    zZipInfo.__init__cCsd|jj|jfg}|jtkr|dt|j|j|jd?}|jd@}|r2|dt ||r;|d|| }|rD|j rL|d|j |rQ|j rd|jtks\|j |j krd|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__rrFr|rr1compressor_namesgetrstatfilemodeis_dirrrr2)rrGhiloisdirrrr__repr__s,         zZipInfo.__repr__NcCsx|j}|ddd>|dd>B|dB}|dd>|d d>B|ddB}|jd @r3d}}}n |j}|j}|j}|j}d} |d urM|tkpL|tk}|rad } |t| dt | d ||}|tksi|tkru|sot d d}d}t } |j t krtt| } n |j tkrtt| } t| |j|_t| |j|_|\} } ttt|j|j| |j |||||t| t| } | | |S)z-Return the per-file header as a bytes object.rrr$rr!rrr&r rNzz |jd|jfWSty|jd|jdBfYSw)Nasciiutf-8)rFencoderUnicodeEncodeErrorrrrrrs  zZipInfo._encodeFilenameFlagscCs6|j}tj}t|dkr|d|dd\}}|dt|kr'td||f|dkr|d|d}zD|jdvrLd}|d|dd\|_|dd}|jd krdd }|d|dd\|_|dd}|jd krvd }|d|dd\|_Wntjytd |d dw||dd}t|dks dSdS)Nr r,z"Corrupt extra field %04x (size=%d)r)lrz File sizez|_|rd|_|jd O_|S|j|_|S) a_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). rr"rr;)rr;rNrrrr)) isinstancerPathLikefspathrS_ISDIRst_modetime localtimest_mtimepathnormpath splitdriveraltseprrst_size) clsrFarcnamerstrmtimer{zinforrr from_files4       zZipInfo.from_filecCs|jddkS)z2Return True if this archive member is a directory.rrFrrrrr%szZipInfo.is_dir)rrN) rrrr __slots__rrrrr classmethodrrrrrrr Qs , . %r cCs0tdD]}|d@r|d?dA}q|dL}q|S)Nrrl q[)range)crcr;rrr_gen_crc/s  rcsldddtdurttttdatfddfdd|D]}|q&fd d }|S) NixV4igE#ixV4cs|d?||Ad@AS)z(Compute the CRC32 primitive on one byte.rr)chr)crctablerrcrc32Isz_ZipDecrypter..crc32cs<|d@d@ddd@d?dS)Nrrirr)c)rkey0key1key2rr update_keysMs z"_ZipDecrypter..update_keyscsNt}|j}|D]}dB}|||dAd?d@N}|||qt|S)zDecrypt a bytes object.rrrr) bytearrayr1bytes)r\rGr1rk)rrrr decrypterWs z _ZipDecrypter..decrypter) _crctablerqmaprr)pwdprr)rrrrrrr _ZipDecrypter?s   rc@s,eZdZddZddZddZddZd S) LZMACompressorcCs d|_dSr)_comprrrrrgs zLZMACompressor.__init__cCsFtdtji}tjtjttj|gd|_tdddt ||S)Nidfiltersz     zZipExtFile.readcCsD|jdurdSt||j|_|jr|j|jkr td|jdSdS)NzBad CRC-32 for file %r)rWrrXrQrrV)rnewdatarrr _update_crcs zZipExtFile._update_crccCs|dus|dkr-|j|jd}d|_d|_|js+||j}|r(||7} |S|jr|S||j}|t|jkrF|j|j|}||_|S|t|j}|j|jd}d|_d|_|dkr|js||}|t|kr~||_||_||d|7} |S|r||7} |S|jrb|S)z7Read up to n bytes with at most one read() system call.Nrr-)rRrSrQrsrtr0)rr?rur\rvrrrread1sH     zZipExtFile.read1cCs |js|dkr dS|jtkr$|jj}|t|kr#|||t|7}n||}|jtkr5|jdk|_n<|jtkrat ||j }|j ||}|jj pT|jdkoT|jj |_|jr`||j 7}n|j |}|jj po|jdk|_|d|j}|jt|8_|jdkrd|_|||S)Nrr-T)rQrMrrPunconsumed_tailr0_read2rrNrr MIN_READ_SIZEr r rrOrxr>rrrrss8          zZipExtFile._read1cCsd|jdkrdSt||j}t||j}|j|}|jt|8_|s&t|jdur0||}|S)Nrr-) rNrrr|minrJrBr0EOFErrorr_r>rrrr{s      zZipExtFile._read2cs>z|jr|jWtdSWtdStwr)rLrJr7superrrrrr7s  zZipExtFile.closecCs|jrtd|jSNrq)rgrrYrrrrr4&szZipExtFile.seekablercCsJ|jrtd|jstd|}|dkr|}n|dkr#||}n|dkr-|j|}ntd||jkr9|j}|dkr?d}||}||j}|dkrY|t|j krY||_d}n1|dkr|j |j |j |_|j|_|j|_d|_ d|_t|j|_d|_|}|jdur||dkrt|j|}||||8}|dks|S) Nzseek on closed file.!underlying stream is not seekablerrrzCwhence must be os.SEEK_SET (0), os.SEEK_CUR (1), or os.SEEK_END (2)r-F)rgrrYrjUnsupportedOperationrmr\rSr0rRrJrIrZr]rXr[rNrOr-rMrPrQr_r`r} MAX_SEEK_READrB)rrZr<curr_posnew_pos read_offset buff_offsetread_lenrrrrI+sN         zZipExtFile.seekcCs>|jrtd|jstd|j|jt|j|j }|S)Nztell on closed file.r) rgrrYrjrr\rOr0rRrS)rfileposrrrrm]s  zZipExtFile.tell)NFrBrrA)rrrrrtr|rrr`rrlrprrrBrxryrsr{r7r4rIrm __classcell__rrrrrIs, 3   # %$  2rIcs@eZdZddZeddZddZddZfd d ZZ S) _ZipWriteFilecCs8||_||_||_t|j|j|_d|_d|_d|_ dSrD) _zinfo_zip64_zipfiler)r|r} _compressor _file_size_compress_size_crc)rzfrrrrrrgs z_ZipWriteFile.__init__cCs|jjSr)rr@rrrrrJqsz_ZipWriteFile._fileobjcCsdS)NTrrrrrwritableuz_ZipWriteFile.writablecCs|jrtdt|ttfrt|}nt|}|j}|j|7_t ||j |_ |j r:|j |}|j t|7_ |j||Sr)rgrrrrr0 memoryviewnbytesrrrrrrrJrF)rr\rrrrrFxs   z_ZipWriteFile.writec sf|jrdSzt|jr(|j}|jt|7_|j||j|j _ n|j |j _ |j |j _ |j |j _|j jd@r_|jrBdnd}|jt|t|j j |j j |j j|j|j_n7|jst|j tkrktd|jtkrttd|j|j_|j|j j|j|j |j|j|jj|jj|j |j |jj|j j<Wd|j_ dSd|j_ w)Nrzd!d"d#d$Zd?d%d&Zd@d'd(ZdAd)d*Zed+d,Zd-d.Zd/d0Z  dAd1d2Z d@d3d4Zd5d6Z d7d8Z!d9d:Z"d;d<Z#dS)Br ai 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. NrTrc Cs@|dvrtdt|||_d|_d|_i|_g|_||_||_||_ d|_ d|_ ||_ t |tjr8t|}t |trpd|_||_ddd d dd d d }||} z t|||_Wntym||vrl||}YqQw n d|_||_t|dd|_d|_t|_d|_d|_z|dkr|WdS|dvrd|_z|j |_!Wnt"tfyt#|j|_d|_!d|_YWdSwz |j$|j!WWdSt"tfyd|_YWdSw|dkr z||j$|j!WWdSt%y |j$ddd|_|j |_!YWdSwtd|j} d|_|&| )z]Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', or append 'a'.)rwxaz+ZipFile requires mode 'r', 'w', 'x', or 'a'FrNr-rCw+bx+br+bwbxb)rrrrrrrTrrVr)rrrrz"Mode must be 'r', 'w', 'x', or 'a')'rr" _allowZip64 _didModifydebugrrr!r(rUr_comment_strict_timestampsrrrrstr _filePassedrFrjrEr@r>getattr _fileRefCnt threadingRLockr2rYr3_RealGetContentsrmrr^rCrIr_fpclose) rr5rUr! allowZip64r(rmodeDictrr@rrrrs         zZipFile.__init__cCs|Srrrrrr __enter__/rzZipFile.__enter__cCs |dSrr7)rtypevalue tracebackrrr__exit__2 zZipFile.__exit__cCsd|jj|jjfg}|jdur2|jr|d|jn |jdur)|d|j|d|jn|d|dd|S)Nrez file=%rz filename=%rz mode=%rrfrr) rrrr@rr1rFrUr2rhrrrr5s     zZipFile.__repr__c Cs|j}zt|}Wn tytdw|std|jdkr$t||t}|t}|t|_ |t ||}|jdkrI||}td||||||_ |j dkrWtd| |j d| |}t|}d}||krS| t} t| tkr~tdtt| } | ttkrtd|jdkrt| | | t} | d } | d @r| 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}|jdkrOtd|||kso|j }t5|j1ddddD] }||_6|j}q`dS)z/Read in the table of contents for the ZIP file.zFile is not a zip filerrzgiven, inferred, offsetrz Bad offset for central directoryzTruncated central directoryz&Bad magic number for central directoryr!rrcp437rzzip file version %.1fr%r(r+r$rrr&rtotalcSr:r)r)rrrrz*ZipFile._RealGetContents..T)keyreverseN)7r@r=r>rrprintrVrW _ECD_COMMENTrrXrrIrBrjBytesIOsizeCentralDirr0rJr/structCentralDir _CD_SIGNATUREstringCentralDir_CD_FILENAME_LENGTHdecoder _CD_EXTRA_FIELD_LENGTHr3_CD_COMMENT_LENGTHry_CD_LOCAL_HEADER_OFFSETrrcr~rrrr|rrrMAX_EXTRACT_VERSIONr rrrrr{rrr1rrFsortedr)rr@r[size_cd offset_cdconcatinferredr\rcentdirrFflagsrtd end_offsetrrrrrCs                           /  zZipFile._RealGetContentscCsdd|jDS)z+Return a list of file names in the archive.cSsg|]}|jqSrr).0r\rrr sz$ZipFile.namelist..rrrrrnamelistszZipFile.namelistcCr:)zJReturn a list of class ZipInfo instances for files in the archive.rrrrrinfolistzZipFile.infolistcCsLtdd|d|jD]}d|jdd}td|j||jf|dq dS)z+Print a table of contents for the zip file.z%-46s %19s %12s)z File Namez Modified Size)r5z%d-%02d-%02d %02d:%02d:%02dNr"z %-46s %s %12d)rrr{rFr)rr5rdaterrrprintdirs zZipFile.printdirc Csxd}|jD]4}z$||jd}||r ||sWdn1s%wYWqty9|jYSwdS)z%Read all the files and check the CRC.irN)rrErFrBr)r chunk_sizerfrrrtestzips    zZipFile.testzipcCs$|j|}|durtd||S)z,Return the instance of ZipInfo given 'name'.Nz(There is no item named %r in the archive)rrKeyError)rrVinforrrgetinfos zZipFile.getinfocCs8|rt|tstdt|j|r||_dSd|_dS)z)Set default password for encrypted files.pwd: expected bytes, got %sN)rr TypeErrorrrr)rrrrr setpasswords   zZipFile.setpasswordcCr:)z.The comment text associated with the ZIP file.)rrrrrryrzZipFile.commentcCs^t|tstdt|jt|tkr'ddl}|jdtdd|dt}||_ d|_ dS)Nzcomment: expected bytes, got %srz3Archive comment is too long; truncating to %d bytesr stacklevelT) rrrrrr0ZIP_MAX_COMMENTwarningswarnrr)rryrrrrrys    cCs:||d| }|WdS1swYdS)zReturn file bytes for name.rNrErB)rrVrr@rrrrBs$z ZipFile.readF force_zip64c s*|dvrtd|rt|tstdt|j|r"|dkr"tdjs)tdt|tr1|}n|dkrBt|}j|_ j |_ n |}|dkrRj ||dSjrYtdjd 7_tj|jjjfd d }z|t}t|tkrtd tt|}|ttkrtd ||t}|tr||t|jd@rt d|jd@rt d|t!d@r|"d} n|"d} | |j#krtd|j#|f|j$dur|%|j&|j$krtd|j#d|jd @} | r|sj'}|st(d|nd}t)||||dWS|*)auReturn 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. >rrzopen() requires mode "r" or "w"rrz'pwd is only supported for reading filesz2Attempt to use ZIP archive that was already closedrr=rcsjSr)r3rrrrrrzZipFile.open..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.NzOverlapped entries: z (possible zip bomb)z6File %r is encrypted, password required for extractionT)+rrrrrrr@r r!r|r(r}r_open_to_writer3rr.rrr2rBsizeFileHeaderr0rrJr/r _FH_SIGNATUREr_FH_FILENAME_LENGTH_FH_EXTRA_FIELD_LENGTHrr _FH_GENERAL_PURPOSE_FLAG_BITSrrzrrmrrrrIr7) rrVrUrrrzef_filefheaderfname fname_str is_encryptedrrrrEs                 z ZipFile.opencCs|r |js td|jrtdd|_d|_d|_|jtkr%|jdO_|js/|jdO_|j s5d|_ |jo@|p@|j dt k}|jrK|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.rrrg?T)rrr3rrrr|rrYrrrr@rIrrmr _writecheckrrFrr)rrrrrrrrDs4     zZipFile._open_to_writecCs*|dur t}nt|}||||S)a#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'. N)rgetcwdr_extract_member)rmemberrrrrrextractms  zZipFile.extractcCsH|dur|}|durt}nt|}|D] }||||qdS)zExtract 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(). N)rrrrr)rrmembersrrarrr extractallzs  zZipFile.extractallcCs^|j}|sd}t|dt|}||_||}dd||D}|dd|D}|S)z;Replace bad characters and remove trailing dots from parts.z:<>|"?*_css|]}|dVqdS).N)rstriprrrrr z1ZipFile._sanitize_windows_name..css|]}|r|VqdSrrr rrrrs)!_windows_illegal_name_trans_tabler maketransr0 translatesplitr2)rrpathseptableillegalrrr_sanitize_windows_names zZipFile._sanitize_windows_namec st|ts ||}|jdtjj}tjjr!|tjjtjj}tj |d}dtjj tjj ftjj fdd| tjjD}tjjdkrS||tjj}tj ||}tj|}tj|}|rstj|sst||rtj|st||S|j||d,}t|d}t||Wd n1swYWd |SWd |S1swY|S) zbExtract the ZipInfo object 'member' to a physical file on the path targetpath. rrrc3s|] }|vr|VqdSrrr invalid_path_partsrrrs z*ZipFile._extract_member..\rrN)rr rrFrrrrrrcurdirpardirr2rrrdirnameexistsmakedirsrrmkdirrEshutil copyfileobj)rr targetpathrr upperdirssourcetargetrrrrs<  &      ( zZipFile._extract_membercCs|j|jvrddl}|jd|jdd|jdvrtd|js$tdt|j|j sOd}t |j t kr8d }n|j tkr@d }n|jtkrGd }|rQt|d dSdS) z6Check for errors before writing a file to the archive.rNzDuplicate name: %rrrrrrz&write() requires mode 'w', 'x', or 'a'z4Attempt to write ZIP archive that was already closed Files countFilesizez Zipfile size would require ZIP64 extensions)rFrrrrUrr@r"r|rr0rZIP_FILECOUNT_LIMITrrrr )rrrrequires_zip64rrrrs0     zZipFile._writecheckc Cs|jstd|jrtdtj|||jd}|r"d|_d|_n|dur*||_ n|j |_ |dur6||_ n|j |_ |r|j H|jrL|j|j|j|_|j tkr^|jdO_||d|_|j|||j|j<|j|d|j|_WddS1swYdSt|d .}||d }t||d Wdn1swYWddSWddS1swYdS) zLPut 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 existsrrNrTFrCri ) r@rr3r rrrrrr|r!r}r(r2rYrIrrmrrrrrrr1rrFrFrrEr"r#)rrFrr|r(rsrcdestrrrrFsJ     "Pz ZipFile.writec Cs2t|tr |d}t|ts|dd>B|dB}|dd>|d d>B|ddB}g}|jtks8|jtkrI||j||jd }d }n|j}|j}|jtkr]||jd }n|j}|j} d} |rt| d } t j d d t |ddt |g|R| } t } |j tkrtt| } n |j tkrtt| } t| |j} t| |j} |\} }t tt| |j| |j||j |||j||t | t | t |jd|j|j|}|j||j| |j| |j|jq|j }t |j}||j!}|j!}d}|t"krd}n|tkrd}n|tkrd}|rX|j#s#t$|dt t%t&t'ddddd|||| }|j|t t(t)d|d}|j|t*|d}t*|d }t*|d }t t+t,dd||||t |j- }|j||j|j-|j.dkr|j/|j0dS)Nrrr$rr!rrr&r rrr,Qrr)zCentral directory offsetzCentral directory sizer+rrrr)1rr{rrrr1rr3r<rJrr0rr|rrrrrrrrcrrrr~rrryrrr@rFrmrr,rr rPrOrMrKrLr}rprorrUtruncater)rrrrrr3rrr extra_datarrrcrFrrpos2 centDirCount centDirSize centDirOffsetr- zip64endrec zip64locrecr[rrrr4Os $$                                    zZipFile._write_end_recordcCs<|jdksJ|jd8_|js|js|dSdSdS)Nrr)rrr7rErrrrs   zZipFile._fpcloser)rN)F)NN)NNN)$rrrrr@rrrrrrrrrrrrrrrysetterrBrErrr rrrrrFr2r3r7r4rrrrrr sR ZS        f )  * 2 ) ^r c@s4eZdZdZdeddfddZd d d Zd d ZdS)r zDClass to create ZIP archives with Python library files and packages.rTrcCstj|||||d||_dS)N)rUr!r)r r _optimize)rr5rUr!roptimizerrrrs  zPyZipFile.__init__rNcCst|}|r"||s"|jr tj|rdnd}td||fdStj|\}}tj|r-tj|d}tj|r|rGd||f}n|}|jrStd|d|| |d d |\}} |jrgtd | | || t t |} | d| D]Y} tj|| } tj| \} }tj| rtjtj| dr|j| ||d q{|d kr|r|| s|jrtd| q{| | d d |\}} |jrtd | | || q{dS|jrtd|t t |D]D} tj|| } tj| \} }|d kr*|r|| s|jrtd| q| | d d |\}} |jr$td | | || qdS|d dd kr:td| |d d |\}} |jrOtd| | || dS)aAdd 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. rr5z%s %r skipped by filterfuncNz __init__.py%s/%szAdding package inasrAdding) filterfunc.pyzfile %r skipped by filterfunczAdding files from directoryz.Files added with writepy() must end with ".py"z Adding file)rrrrrrrr2isfile _get_codenamerFrlistdirremovesplitextwritepyr)rpathnamebasenamerElabeldirrVinitnamerrdirlistrFrrootextrrrrLs                 zPyZipFile.writepyc sdfdd }|d}|d}tjj|dd}tjj|dd}tjj|d d}jdkrtj|rCt|jt|jkrC|} } ntj|rZt|jt|jkrZ|} |} ntj|rqt|jt|jkrq|} |} nztj|rt|jt|jkr|} |} nc||rt j j d kr|} n t j j dkr|} n|} |} nH|} } nCjd kr|} |} n|} jdkr|} njd kr|} n d j} t | tj| rt| jt|jks||jd s|} } tj| d} |rd || f} | | fS)aReturn (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). rc sbddl}jr td|z |j|d|dWdS|jy0}z t|jWYd}~dSd}~ww)Nr CompilingT)doraiser@F) py_compilerrcompilePyCompileErrormsg)r5r@rWerrrrr_compiles  z)PyZipFile._get_codename.._compilerFz.pycr) optimizationrrrz"invalid value for 'optimize': {!r})r@rANrB) importlibutilcache_from_sourcer?rrrGrrrrr@formatrr) rrMrNr\file_pyfile_pyc pycache_opt0 pycache_opt1 pycache_opt2rrrZ archivenamerrrrHs`                zPyZipFile._get_codename)rN)rrrrrrrLrHrrrrr s  Rr cCstt|ddS)a2 Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [] rN) itertoolsislice _ancestry)rrrr_parentsbsrkccsB|tj}|tjr|Vt|\}}|tjs dSdS)a Given a path with elements separated by posixpath.sep, generate all elements of that path. >>> list(_ancestry('b/d')) ['b/d', 'b'] >>> list(_ancestry('/b/d/')) ['/b/d', '/b'] >>> list(_ancestry('b/d/f/')) ['b/d/f', 'b/d', 'b'] >>> list(_ancestry('b')) ['b'] >>> list(_ancestry('')) [] Multiple separators are treated like a single. >>> list(_ancestry('//b//d///f//')) ['//b//d///f', '//b//d', '//b'] N)r  posixpathrr)rtailrrrrjus   rjcCstt|j|S)zZ Return items in minuend not in subtrahend, retaining order with O(1) lookup. )rh filterfalseset __contains__)minuend subtrahendrrr _differencesrscsTeZdZdZeddZfddZddZdd Zfd d Z e d d Z Z S) CompleteDirszk A ZipFile subclass that ensures that implied directories are always included in the namelist. cCs.tjtt|}dd|D}tt||S)Ncss|]}|tjVqdSr)rlr)rrrrrrrz-CompleteDirs._implied_dirs..)rhchain from_iterablerrk_dedupers)namesparentsas_dirsrrr _implied_dirsszCompleteDirs._implied_dirscs tt|}|t||Sr)rrtrrqr{)rrxrrrrszCompleteDirs.namelistcCs t|Sr)rorrrrr _name_setrzCompleteDirs._name_setcCs,|}|d}||vo||v}|r|S|S)zx If the name represents a directory, return that name as a directory (with the trailing slash). r)r|)rrVrxr dir_matchrrr resolve_dirs zCompleteDirs.resolve_dircsDzt|WSty!|dr||vrt|dYSw)z6 Supplement getinfo for implied dirs. rr)rrrendswithr|r )rrVrrrrs zCompleteDirs.getinfocCs8t|tr|St|ts||Sd|jvrt}||_|S)zl Given a source (filename or zipfile), return an appropriate CompleteDirs subclass. r)rrtr rUr)rr&rrrmakes   zCompleteDirs.make) rrrr staticmethodr{rr|r~rrrrrrrrrts    rtcs,eZdZdZfddZfddZZS) FastLookupzV ZipFile subclass to ensure implicit dirs exist and are resolved rapidly. cFtt |jWdS1swYtt||_|jSr) contextlibsuppressr^_FastLookup__namesrrrrrrrr  zFastLookup.namelistcrr)rrr^_FastLookup__lookuprrr|rrrrr|rzFastLookup._name_set)rrrrrr|rrrrrrs rcOst|d||fS)Nr)rj text_encoding)encodingargskwargsrrr_extract_text_encodingsrc@seZdZdZdZd'ddZd(ddd d Zed d Zed dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$ZeZed%d&ZdS))ru, A pathlib-compatible interface for zip files. Consider a zip file with this structure:: . ├── a.txt └── b ├── c.txt └── d └── e.txt >>> data = io.BytesIO() >>> zf = ZipFile(data, 'w') >>> zf.writestr('a.txt', 'content of a') >>> zf.writestr('b/c.txt', 'content of c') >>> zf.writestr('b/d/e.txt', 'content of e') >>> zf.filename = 'mem/abcde.zip' Path accepts the zipfile object itself or a filename >>> root = Path(zf) From there, several path operations are available. Directory iteration (including the zip file itself): >>> a, b = root.iterdir() >>> a Path('mem/abcde.zip', 'a.txt') >>> b Path('mem/abcde.zip', 'b/') name property: >>> b.name 'b' join with divide operator: >>> c = b / 'c.txt' >>> c Path('mem/abcde.zip', 'b/c.txt') >>> c.name 'c.txt' Read text: >>> c.read_text() 'content of c' existence: >>> c.exists() True >>> (b / 'missing.txt').exists() False Coercion to string: >>> import os >>> str(c).replace(os.sep, posixpath.sep) 'mem/abcde.zip/b/c.txt' At the root, ``name``, ``filename``, and ``parent`` resolve to the zipfile. Note these attributes are not valid and will raise a ``ValueError`` if the zipfile has no filename. >>> root.name 'abcde.zip' >>> str(root.filename).replace(os.sep, posixpath.sep) 'mem/abcde.zip' >>> str(root.parent) 'mem' z>{self.__class__.__name__}({self.root.filename!r}, {self.at!r})rcCst||_||_dS)aX Construct a Path from a ZipFile or filename. Note: When the source is an existing ZipFile object, its type (__class__) will be mutated to a specialized type. If the caller wishes to retain the original type, the caller should either create a separate ZipFile object or pass a filename. N)rrrSat)rrSrrrrr@ s z Path.__init__rNrcOs|rt||d}|s|dkrt||jj|j||d}d|vr0|s*|r.td|St|i|\}}}t j ||g|Ri|S)z Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper(). rrrbz*encoding args invalid for binary operation) rIsADirectoryErrorrFileNotFoundErrorrSrErrrrj TextIOWrapper)rrUrrrzip_modestreamrrrrrEM sz Path.opencCst|jjp |jjSr)pathlibrrrVrFrrrrrVa z Path.namecCst|jj|jSr)rrrSrFjoinpathrrrrrrFe rz Path.filenamecOsZt|i|\}}}|jd|g|Ri| }|WdS1s&wYdS)Nr)rrErB)rrrrstrmrrr read_texti s$zPath.read_textcCs6|d }|WdS1swYdS)NrCr)rrrrr read_bytesn s $zPath.read_bytescCst|jd|jdkSNr)rlrrr )rrrrr _is_childr szPath._is_childcCs||j|Sr)rrS)rrrrr_nextu rHz Path._nextcCs|j p |jdSr)rrrrrrrx sz Path.is_dircCs|o| Sr)rrrrrris_file{ z Path.is_filecCs|j|jvSr)rrSr|rrrrr~ sz Path.existscCs.|stdt|j|j}t|j|S)NzCan't listdir a file)rrrrrSrfilterr)rsubsrrriterdir s z Path.iterdircCst|jj|jSr)rlr2rSrFrrrrr__str__ rz Path.__str__cCs|jj|dS)Nr) _Path__reprrarrrrr rHz Path.__repr__cGs&tj|jg|R}||j|Sr)rlr2rrrSr~)rothernextrrrr sz Path.joinpathcCs6|js|jjSt|jd}|r|d7}||Sr)rrFparentrlrr r)r parent_atrrrr s  z Path.parent)r)r)rrrrrrrErrVrFrrrrrrrrrrr __truediv__rrrrrrs.M    rc s ddl}d}|j|d}|jdd}|jdddd d |jd d d ddd|jdddddd|jddddd ||}|jdurm|j}t|d }|}Wdn1sYwY|rgtd |tddS|j dur|j }t|d }| WddS1swYdS|j dur|j \}}t|d}| |WddS1swYdS|jdur|jd} |j} fddt| d1}| D]%} tj| } | stjtj| } | dtjtjfvrd} || | qWddS1swYdSdS) Nrz3A simple command-line interface for zipfile module.) descriptionT)requiredz-lz--list zShow listing of a zipfile)metavarhelpz-ez --extractr)rz zExtract zipfile into target dir)nargsrrz-cz--create+)zzzCreate zipfile from sourcesz-tz--testzTest if a zipfile is validrz.The following enclosed file is corrupted: {!r}z Done testingcsvtj|r|||tdStj|r7|r|||tt|D]}|tj||tj||q$dSdSr) rrrGrFrrrrIr2)rrzippathnmaddToZiprrr s   zmain..addToZiprr)argparseArgumentParseradd_mutually_exclusive_group add_argument parse_argstestr rrrarqrrr createpoprrrNrrr) rrrparsergroupr/rbadfilerzip_namefilesrrrrrmain sh              "    "     $r__main__r)rbinasciiimportlib.utilr^rjrhrrlrer"rrJrrrrrrr ImportErrorrr__all__ Exceptionrr rrrr,rrrrrrrrrrrprorrnrQrRrSrTrUrVrWrtrrXrrrr_CD_CREATE_VERSION_CD_CREATE_SYSTEM_CD_EXTRACT_VERSION_CD_EXTRACT_SYSTEM _CD_FLAG_BITS_CD_COMPRESS_TYPE_CD_TIME_CD_DATE_CD_CRC_CD_COMPRESSED_SIZE_CD_UNCOMPRESSED_SIZErrr_CD_DISK_NUMBER_START_CD_INTERNAL_FILE_ATTRIBUTES_CD_EXTERNAL_FILE_ATTRIBUTESrrrrr_FH_EXTRACT_VERSION_FH_EXTRACT_SYSTEMr_FH_COMPRESSION_METHOD_FH_LAST_MOD_TIME_FH_LAST_MOD_DATE_FH_CRC_FH_COMPRESSED_SIZE_FH_UNCOMPRESSED_SIZErrrKrLrHrPrOrM_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_CENTDIRrStructr.r<rAr rkr=objectr rrrrrrr"r)r-r.rCrkrIrr r rkrjdictfromkeysrwrsrtrrrrrrrrrs              <<^&      (KU~/<  . =