HiveNetCore.utils.myzipfile module

Read and write ZIP files.

exception HiveNetCore.utils.myzipfile.BadZipFile[源代码]

基类:Exception

HiveNetCore.utils.myzipfile.BadZipfile

BadZipFile 的别名

exception HiveNetCore.utils.myzipfile.LargeZipFile[源代码]

基类:Exception

Raised when writing a zipfile, the zipfile requires ZIP64 extensions and those extensions are disabled.

class HiveNetCore.utils.myzipfile.PyZipFile(file, mode='r', compression=0, allowZip64=True, optimize=- 1)[源代码]

基类:ZipFile

Class to create ZIP archives with Python library files and packages.

writepy(pathname, basename='', filterfunc=None)[源代码]

Add all files from “pathname” to the ZIP archive.

class HiveNetCore.utils.myzipfile.ZipFile(file, mode='r', compression=0, allowZip64=True, compresslevel=None)[源代码]

基类:object

Class with methods to open, read, write, close, list zip files.

__init__(file, mode='r', compression=0, allowZip64=True, compresslevel=None)[源代码]

Open the ZIP file with mode read ‘r’, write ‘w’, exclusive create ‘x’,

or append ‘a’.

close()[源代码]

Close the file, and for mode ‘w’, ‘x’ and ‘a’ write the ending

records.

property comment

The comment text associated with the ZIP file.

extract(member, path=None, pwd=None)[源代码]

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’.

extractall(path=None, members=None, pwd=None)[源代码]

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().

fp = None
getinfo(name)[源代码]

Return the instance of ZipInfo given ‘name’.

infolist()[源代码]

Return a list of class ZipInfo instances for files in the

archive.

namelist()[源代码]

Return a list of file names in the archive.

open(name, mode='r', pwd=None, *, force_zip64=False)[源代码]

Return file-like object for ‘name’.

printdir(file=None)[源代码]

Print a table of contents for the zip file.

read(name, pwd=None)[源代码]

Return file bytes for name.

setpassword(pwd)[源代码]

Set default password for encrypted files.

testzip()[源代码]

Read all the files and check the CRC.

write(filename, arcname=None, compress_type=None, compresslevel=None)[源代码]

Put the bytes from filename into the archive under the name

arcname.

writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None)[源代码]

Write 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.

class HiveNetCore.utils.myzipfile.ZipInfo(filename='NoName', date_time=(1980, 1, 1, 0, 0, 0))[源代码]

基类:object

Class with attributes describing each file in the ZIP archive.

CRC
FileHeader(zip64=None)[源代码]

Return the per-file header as a bytes object.

comment
compress_size
compress_type
create_system
create_version
date_time
external_attr
extra
extract_version
file_size
filename
flag_bits
classmethod from_file(filename, arcname=None)[源代码]

Construct an appropriate ZipInfo for a file on the filesystem.

header_offset
internal_attr
is_dir()[源代码]

Return True if this archive member is a directory.

orig_filename
reserved
volume
HiveNetCore.utils.myzipfile.error

BadZipFile 的别名

HiveNetCore.utils.myzipfile.is_zipfile(filename)[源代码]

Quickly 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.