CompressionsHelper Module

Utilities for extracting and handling compressed archive formats.

class HMB.CompressionsHelper.CompressionsHelper[source]

Bases: object

CompressionsHelper: Convenience wrappers to extract various archive formats.

- ExtractFileUsingTarfile(path, destination)
- ExtractFileUsingZipfile(path, destination)
- ExtractFileUsing7zfile(path, destination)
- ExtractFileUsingRarfile(path, destination)
- ExtractFileUsingUnrar(path, destination)
- ExtractFileUsingUnzip(path, destination)
ExtractFileUsingTarfile(path, destination)[source]

Extract a tar/ tar.gz / tar.bz2 archive using the standard library tarfile.

Parameters:
  • path (str) – Path to the archive file.

  • destination (str) – Directory to extract files into. Will be created if missing.

ExtractFileUsingZipfile(path, destination)[source]

Extract a ZIP archive using the standard library zipfile.

Parameters:
  • path (str) – Path to the .zip file.

  • destination (str) – Directory to extract files into. Will be created if missing.

ExtractFileUsing7zfile(path, destination)[source]

Extract a 7-zip (.7z) archive using the optional py7zr package. If py7zr is not installed an ImportError will be raised.

Parameters:
  • path (str) – Path to the .7z file.

  • destination (str) – Directory to extract files into. Will be created if missing.

ExtractFileUsingRarfile(path, destination)[source]

Extract a RAR archive using the optional rarfile package. If rarfile is not installed an ImportError will be raised.

Parameters:
  • path (str) – Path to the .rar file.

  • destination (str) – Directory to extract files into. Will be created if missing.

ExtractFileUsingUnrar(path, destination)[source]

Extract a RAR archive using the optional unrar package (alternate to rarfile). If unrar is not installed an ImportError will be raised.

Parameters:
  • path (str) – Path to the .rar file.

  • destination (str) – Directory to extract files into. Will be created if missing.

ExtractFileUsingUnzip(path, destination)[source]

Extract an archive with a third-party unzip package if available. This is provided for environments that prefer a non-stdlib unzip utility. If the unzip package is not installed an ImportError will be raised.

Parameters:
  • path (str) – Path to the archive file.

  • destination (str) – Directory to extract files into. Will be created if missing.