Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

Compress

Abstract class for compress class

Attributes
destination_file_path: strsupports_multiple_entries: bool
Functions
__init__

Initialize the compressor with the path of the archive to create.

destination_file_path : str
add_dir

Add a directory (recursively) to the archive.

dir_path : str
Path of the directory to add.
dir_name : str | None
add_dir_content

Add the content of dir_path at the archive root.

Each top-level entry inside dir_path is added under its own name, so the resulting archive does not contain dir_path itself as a wrapping folder.

dir_path : str
add_file

Add a single file to the archive.

file_path : str
Path of the file to add.
file_name : str | None
add_fs_node

Add a filesystem node (file or directory) to the archive.

Dispatches to :meth:add_dir or :meth:add_file based on the node type.

fs_node_path : str
Path of the file or directory to add.
fs_node_name : str | None
close

Finalize the archive and write it to destination_file_path.

Must be called once all entries have been added.

Return type : str
can_uncompress_file @classmethod

Return true if the file can be uncompressed by this class

file_path : str
Return type : bool
compress_dir @classmethod

Compress a folder into a tar.gz file.

dir_path : str
destination_file_path : str
Path of the tar.gz file to create
compress_dir_content @classmethod

Compress the content of a folder without creating a subfolder hierarchy. Files and folders inside dir_path will be at the root of the compressed file.

dir_path : str
Path of the folder whose content to compress
destination_file_path : str
Path of the compressed file to create
decompress @classmethod

Uncompress a tar.gz file.

file_path : str
destination_folder : str
get_supported_extensions @classmethod

Return the list of supported extensions for this compress class without '.'

Return type : set
get_all_supported_extensions @staticmethod

Return the list of all supported extensions without '.'

Return type : set
get_compress_class_by_extension @staticmethod

Return a mapping of supported extension (without leading dot) to its Compress class. Built dynamically from child classes so new compressors are picked up automatically.

multi_entry_only : bool - False
Return type : dict
is_compressed_file @staticmethod

Check if the file is a compressed file.

file_path : str
Return type : bool
sanitize_arcname @staticmethod

Validate and normalize an archive entry name to a safe relative path.

Rejects empty names, absolute paths, and any segment that would escape the archive root via ... Returned value is suitable for joining with a staging directory.

arcname : str
Return type : str
smart_decompress @staticmethod

Detect the extension of the compressed file and use the right decompress method.

file_path : str
destination_folder : str
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.