IPWorks ZIP 2020 Python Edition

Questions / Feedback?

Zip Class

Properties   Methods   Events   Configuration Settings   Errors  

The Zip class implements a PKZip-compatible Zip compressor and decompressor.

Syntax

class ipworkszip.Zip

Remarks

The class uses the Deflate algorithm specified in RFC 1951 for compression, and produces and reads output compatible with PKZip, WinZip, etc.

To create a new archive, first set the archive_file property to the name of the archive to be created. Then, specify the files to be compressed either by invoking include_files, or by adding a new object to the files collection and setting the values of the file_decompressed_name and file_compressed_name. fields. Finally, call the compress method to create the archive.

To decompress an existing archive, set archive_file to the name of the archive to be decompressed. The extract_to_path property may be set, and then calling the extract_all method will decompress all files in the archive to this path.

For finer control, the scan method should be used to read the file information stored in the archive. This will fill out the information in the files collection. The values of file_decompressed_name may then be changed if desired. Finally, extract_all may be used to decompress the entire archive, or extract may be used for finer control.

Data may be streamed out by setting WriteToProgressEvent to true. Then, the on_progress event may be trapped to retrieve the data.

Example (Creating an Archive)


ZipControl.ArchiveFile = "c:\test.zip"
ZipControl.RecurseSubdirectories = true
ZipControl.IncludeFiles("c:\foo\*")
ZipControl.Compress()

Example (Extracting from an Archive)


ZipControl.ArchiveFile = "c:\temp.zip"
ZipControl.ExtractToPath = "c:\extracted\"
ZipControl.ExtractAll()

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

archive_fileThe name of the zip, gzip, tar, or jar archive.
compression_levelThe compression level to use.
compression_methodThe compression method to use.
encryption_algorithmThe algorithm used to encrypt files written to the archive.
excluded_filesA list of files to exclude.
extract_to_pathA base path to decompress to.
file_countThe number of records in the File arrays.
file_attributesThe attributes of the files to be compressed or decompressed.
file_commentSpecifies a comment for the entry in the zip file.
file_compressed_dateThe date and time of the entry, as stored within the archive.
file_compressed_nameThe file name of the current file, as stored inside of the archive.
file_compressed_sizeThe size of the compressed data, as compressed within the archive.
file_compression_levelThe compression level to use for the file.
file_crcThe CRC value for the specified file found in the archive.
file_decompressed_nameThe name of the file in the archive, as stored on the file system, outside the archive.
file_decompressed_sizeThe size of the file, as decompressed outside the archive.
file_encryption_algorithmThe algorithm used to encrypt the specified file written to the archive.
file_hashThe computed hash for the specified File.
file_input_dataWhen This property is set, the class will read in the data from This property instead of reading from the file contained in the DecompressedName property.
file_passwordThis property specifies the case-sensitive password used to encrypt or decrypt the current file.
file_password_requiredThis property describes whether or not the current file has been encrypted or not and requires a password to decompress.
overwrite_filesWhether or not to overwrite files.
passwordA password for the zip archive.
recurse_subdirectoriesWhether or not to recurse into subdirectories.
zip_commentThe comment for the entire zip file.
zip_data(Decompression only) The zip file contents as a byte array.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

abortAborts the current operation.
append_filesAdds specified files to an existing archive.
compressCreates the compressed archive.
configSets or retrieves a configuration setting.
deleteDeletes one or more files from an existing archive.
extractExtracts a single file, directory, or group of files, from the archive.
extract_allExtracts all files from the compressed archive.
include_filesSpecifies that the indicated files should be added to the archive.
resetResets the class.
scanScans the compressed archive.
updateWill update certain files in an archive.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_begin_fileFired before each file is processed.
on_end_fileFired after each file is processed.
on_errorInformation about non-fatal errors.
on_overwriteFired whenever a file exists and may be overwritten.
on_passwordFired when a file is encrypted, and the file's password is incorrect.
on_progressFired as progress is made.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

AESGenerateUniqueKeysWhether to generate unique keys for each file encrypted.
CheckForFileLocksIf true, the class requests an exclusive lock during initialization.
CompressionMethodUsed to set the method of compression.
EnableStreamingEncryptionWhether to allow streaming and encryption simultaneously.
ExcludedAttributesAttributes of files to be excluded.
ExtractFilesOnlyWhether to only extract the files contained within the archive.
FileHashAlgorithmThe algorithm to use when computing the file hash.
ForceZip64FormatWhether to explicitly compress a Zip64 format archive.
MarkAsTextWhether to mark files as text files.
OverwriteReadonlyFilesWhether to overwrite readonly files.
PreserveModifiedTimeWhether or not to preserve the original modified time on extracted files.
RecalculateCRCWhether to recalculate the CRC.
VerifyPasswordCheck whether the specified Password can decrypt the archive without extracting files.
WriteToProgressEventWhether or not to write data to the Progress Event.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks ZIP 2020 Python Edition - Version 20.0 [Build 8300]