Compression

Compression module to create zip file to be used as artifact.

compression.compress(path, ignore_files=None)

Creates compressed zip of the files in path.

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

  • ignore_files (Optional[list[str]]) – Ignorefiles to use when creating zip file.

Yields:

Iterator[tempfile.SpooledTemporaryFile[bytes]] – Bytes of the zip file in chunks.

Raises:
  • InvalidPathException – Given path is invalid and cannot be traversed.

  • FileLimitExceededException – Compressed directory size exceeded the max limits.

Return type:

Iterator[SpooledTemporaryFile[bytes]]

compression.get_files_to_include(path, ignore_files=None)

Get a list of file paths to be included.

Parameters:
  • path (str) – Root path from where to start the traversal.

  • ignore_files (Optional[list[str]]) – Path of ignorefiles to use, defaults to .dockerignore.

Yields:

Iterator[str] – Path of files to be included.

Return type:

Iterator[str]

compression.print_file_tree(files)

Prints list of files in tree format.

Parameters:

files (list[str]) – List of file paths

Return type:

None

compression.print_zip_content(zip_file)

Prints content of the zip file to stdout.

Parameters:

zip_file (BinaryIO) – Opened zip file in binary format.

Return type:

None