IPWorks ZIP 2020 Python Edition

Questions / Feedback?

ZipStream Class

Properties   Methods   Events   Configuration Settings   Errors  

The ZipStream class is used to perform compression or decompression.

Syntax

class ipworkszip.ZipStream

Remarks

The ZipStream class provides a way to compress and decompress streamed data.

Data may be operated on in multiple ways as discussed below. The stream_format property specifies the algorithm to us. Possible values are:

  • Deflate
  • Zlib
  • Gzip

CompressBlock and DecompressBlock

The compress_block and decompress_block methods operate on blocks (chunks) of data. The methods may be used to compress and decompress data as it becomes available.

Note that when using blocks of data the output_data property is not applicable. Instead data is made available through the on_compressed_data and on_decompressed_data events.

If all data is available ahead of time compress_data and decompress_data may be called instead.

Compress Data

Set input_data to the current block to be compressed. Next call compress_block to compress the current block. Note that compress_block takes a LastBlock parameter. If the block of data is the final block to be compressed set this to True. For all other blocks set this to False.

During compression the on_compressed_data event will fire with the compressed data. Note that this event may not fire for every call to compress_block due to the way the compression algorithm operates. For example:


zipstream.InputDataB = MyDecompressedData;
zipstream.CompressBlock();
Data is accumulated inside the on_compressed_data event:
private static void Zipstream_OnCompressedData(object sender, ZipstreamCompressedDataEventArgs e)
{
  DoSomethingWith(e.DataB);
}

Note that output_data is not applicable when compressing block data.

Decompress Data

Set input_data to the current block to be decompressed. Next call decompress_block to decompress the current block.

During decompression the on_decompressed_data event will fire with the decompressed data. Note that this event may not fire for every call to decompress_block due to the way the decompression algorithm operates. For example:


zipstream.InputDataB = MyCompressedData;
zipstream.DecompressBlock();
Data is accumulated inside the on_decompressed_data event:
private static void Zipstream_OnDecompressedData(object sender, ZipstreamDecompressedDataEventArgs e)
{
  DoSomethingWith(e.DataB);
}

Note that output_data is not applicable when decompressing block data.

CompressData and DecompressData

The compress_data and decompress_data methods operate on the complete blob of data. The entire compressed or decompressed data must be set to input_data before calling either method.

To compress and decompress data in blocks (chunks) see compress_block and decompress_block.

Compress Data

Set input_data to the decompressed data. This should be the entire data to be compressed. Next call compress_data. After compression output_data will hold the compressed data. For example:


zipstream.InputDataB = MyDecompressedData;
zipstream.CompressData();
MyCompressedData = zipstream.OutputDataB;

In addition to output_data, the compressed data may also be accumulated within the on_compressed_data event.

Decompress Data

Set input_data to the compressed data. This should be the entire data to be decompressed. Next call decompress_data. After decompression output_data will hold the decompressed data. For example:


zipstream.InputDataB = MyCompressedData;
zipstream.DecompressData();
MyDecompressedData = zipstream.OutputDataB;

In addition to output_data, the compressed data may also be accumulated within the on_decompressed_data event.

Property List


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

compression_levelThe compression level to use.
input_dataSpecifies the data to compress or decompress.
output_dataThe output data after compression or decompression.
stream_formatThe stream format to use.

Method List


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

compress_blockCompresses a block of data.
compress_dataCompresses the specified data.
configSets or retrieves a configuration setting.
decompress_blockDecompresses a block of data.
decompress_dataDecompresses the specified data.
resetResets the class.

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_compressed_dataThis event fires with compressed data.
on_decompressed_dataThis event fires with decompressed data.
on_errorInformation about errors during data delivery.

Configuration Settings


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

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) 2021 /n software inc. - All rights reserved.
IPWorks ZIP 2020 Python Edition - Version 20.0 [Build 7720]