The class `BitFileExtractor` allows extracting archives on the filesystem. ## List of all members ### Public Members | Return type | Name | |------------:|------| | | `__init__(self, lib: bit7z_python.Bit7zLibrary, format: bit7z_python.BitInFormat = bit7z_python.FORMAT_AUTO) -> None` | | `None` | `clear_password(self) -> None` | | `None` | `extract(self, in_archive: str, out_buffer: buffer_t, index: int = 0) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract(self, in_archive: str, callback: collections.abc.Callable, indices: collections.abc.Sequence[int] = []) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract(self, in_archive: str, out_buffer: byte_t*, size: int, index: int = 0) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract(self, in_archive: str, out_buffer: byte_t(&)[N], index: int = 0) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract(self, in_archive: str, out_dir: str, callback: collections.abc.Callable[[bit7z_python.BitArchiveItem], str]) -> None` | | `None` | `extract(self, in_archive: str, out_dir: str = '') -> None` | | `None` | `extract(self, in_archive: str, out_buffer: std::array< byte_t, N >&, index: int = 0) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract(self, in_archive: str, out_map: std::map< str, buffer_t >) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract(self, in_archive: str, out_stream: std::ostream, index: int = 0) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract_folder(self, in_archive: str, out_dir: str, folder_path: str, policy: bit7z_python.FolderPathPolicy = bit7z_python.FolderPathPolicy.Strip) -> None` | | `None` | `extract_if(self, in_archive: str, out_buffer: buffer_t, callback: collections.abc.Callable[[bit7z_python.BitArchiveItem], bit7z_python.FilterResult]) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract_if(self, in_archive: str, out_dir: str, callback: collections.abc.Callable[[bit7z_python.BitArchiveItem], bit7z_python.FilterResult]) -> None` | | `bit7z_python.BitInFormat` | `extraction_format(self) -> bit7z_python.BitInFormat` | | `None` | `extract_items(self, in_archive: str, indices: collections.abc.Sequence[int], out_dir: str = '') -> None` | | `None` | `extract_matching(self, in_archive: str, item_filter: str, out_buffer: buffer_t, policy: bit7z_python.FilterPolicy = bit7z_python.FilterPolicy.Include) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract_matching(self, in_archive: str, item_filter: str, out_dir: str = '', policy: bit7z_python.FilterPolicy = bit7z_python.FilterPolicy.Include) -> None` | | `None` | `extract_matching_regex(self, in_archive: str, regex: str, out_buffer: buffer_t, policy: bit7z_python.FilterPolicy = bit7z_python.FilterPolicy.Include) -> None` 🚫 ***NOT USABLE*** | | `None` | `extract_matching_regex(self, in_archive: str, regex: str, out_dir: str = '', policy: bit7z_python.FilterPolicy = bit7z_python.FilterPolicy.Include) -> None` | | `None` | `extract_root_folder_content(self, in_archive: str, out_dir: str) -> None` | | `None` | `extract_to(self, in_archive: str, callback: collections.abc.Callable, indices: collections.abc.Sequence[int] = []) -> None` 🚫 ***NOT USABLE*** | | `collections.abc.Callable[[str], None]` | `file_callback(self) -> collections.abc.Callable[[str], None]` | | `bit7z_python.BitInFormat` | `format(self) -> bit7z_python.BitInFormat` | | `bool` | `is_password_defined(self) -> bool` | | `bit7z_python.Bit7zLibrary` | `library(self) -> bit7z_python.Bit7zLibrary` | | `bit7z_python.OverwriteMode` | `overwrite_mode(self) -> bit7z_python.OverwriteMode` | | `str` | `password(self) -> str` | | `collections.abc.Callable[[], str]` | `password_callback(self) -> collections.abc.Callable[[], str]` | | `collections.abc.Callable[[int], bool]` | `progress_callback(self) -> collections.abc.Callable[[int], bool]` | | `collections.abc.Callable[[int, int], None]` | `ratio_callback(self) -> collections.abc.Callable[[int, int], None]` | | `bool` | `retain_directories(self) -> bool` | | `None` | `set_file_callback(self, callback: collections.abc.Callable[[str], None]) -> None` | | `None` | `set_overwrite_mode(self, mode: bit7z_python.OverwriteMode) -> None` | | `None` | `set_password(self, password: str) -> None` | | `None` | `set_password_callback(self, callback: collections.abc.Callable[[], str]) -> None` | | `None` | `set_progress_callback(self, callback: collections.abc.Callable[[int], bool]) -> None` | | `None` | `set_ratio_callback(self, callback: collections.abc.Callable[[int, int], None]) -> None` | | `None` | `set_retain_directories(self, retain: bool) -> None` | | `None` | `set_total_callback(self, callback: collections.abc.Callable[[int], None]) -> None` | | `None` | `test(self, in_archive: str, indices: collections.abc.Sequence[int] = []) -> None` | | `collections.abc.Callable[[int], None]` | `total_callback(self) -> collections.abc.Callable[[int], None]` | ## Member Function Documentation ### def __init__(self, lib: bit7z_python.Bit7zLibrary, format: bit7z_python.BitInFormat = bit7z_python.FORMAT_AUTO) -> None: ... Constructs a BitExtractor object. The Bit7zLibrary parameter is needed to have access to the functionalities of the 7z DLLs. On the contrary, the BitInFormat is required to know the format of the in_file archives. > [!NOTE] > When bit7z is compiled using the BIT7Z_AUTO_FORMAT macro define, the format argument has the default value BitFormat::Auto (automatic format detection of the in_file archive). Otherwise, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified. _Parameters_: - **lib**: the 7z library to use. - **format**: the in_file archive format. --- ### def clear_password(self) -> None: ... Clear the current password used by the handler. Calling clearPassword() will disable the encryption/decryption of archives. > [!NOTE] > This is equivalent to calling setPassword(L""). --- ### def extract(self, in_archive: str, out_buffer: buffer_t, index: int) -> None: ... > 🚫 ***NOT USABLE*** Extracts a file from the given archive to the output buffer. _Parameters_: - **in_archive**: the input archive to extract from. - **out_buffer**: the output buffer where the content of the extracted file will be put. - **index**: the index of the file to be extracted from the archive. --- ### def extract(self, in_archive: str, callback: typing.Callable, indices: list[int]) -> None: ... > 🚫 ***NOT USABLE*** Extracts the content of the given archive to the buffers provided by the given BufferCallback. _Parameters_: - **in_archive**: the input archive to be extracted. - **callback**: the function providing the buffers. - **indices**: (optional) the indices of the files in the archive that must be extracted. --- ### def extract(self, in_archive: str, out_buffer: byte_t, size: int, index: int) -> None: ... > 🚫 ***NOT USABLE*** Extracts a file to the pre-allocated output buffer. _Parameters_: - **in_archive**: the input archive to extract from. - **out_buffer**: the pre-allocated output buffer. - **size**: the size of the output buffer (it must be equal to the unpacked size of the item to be extracted). - **index**: the index of the file to be extracted. --- ### def extract(self, in_archive: str, out_buffer: byte_t(), index: int) -> None: ... > 🚫 ***NOT USABLE*** Extracts a file to the pre-allocated output buffer. _Parameters_: - **in_archive**: the input archive to extract from. - **out_buffer**: the pre-allocated output buffer. - **index**: the index of the file to be extracted. --- ### def extract(self, in_archive: str, out_dir: str, callback: typing.Callable) -> None: ... Extracts the given archive to the chosen directory, renaming the extracted items using the provided RenameCallback. > [!NOTE] > The callback receives the archive item being extracted and must return the path that the extracted item must have on the filesystem. If the path of the item must not change, simply return the item's path in the callback. If the item must not be extracted, return an empty string in the callback. _Parameters_: - **in_archive**: the input archive to be extracted. - **out_dir**: the output directory where extracted files will be put. - **callback**: the callback to be used for renaming the extracted items. --- ### def extract(self, in_archive: str, out_dir: str) -> None: ... Extracts the given archive to the chosen directory. _Parameters_: - **in_archive**: the input archive to be extracted. - **out_dir**: the output directory where extracted files will be put. --- ### def extract(self, in_archive: str, out_buffer: std::array< byte_t, N >, index: int) -> None: ... Extracts a file to the pre-allocated output buffer. _Parameters_: - **in_archive**: the input archive to extract from. - **out_buffer**: the pre-allocated output buffer. - **index**: the index of the file to be extracted. --- ### def extract(self, in_archive: str, out_map: std::map< tstring, buffer_t >) -> None: ... > 🚫 ***NOT USABLE*** Extracts the content of the given archive into a map of memory buffers, where the keys are the paths of the files (inside the archive), and the values are their decompressed contents. _Parameters_: - **in_archive**: the input archive to be extracted. - **out_map**: the output map. --- ### def extract(self, in_archive: str, out_stream: std::ostream, index: int) -> None: ... > 🚫 ***NOT USABLE*** Extracts a file from the given archive to the output stream. _Parameters_: - **in_archive**: the input archive to extract from. - **out_stream**: the (binary) stream where the content of the extracted file will be put. - **index**: the index of the file to be extracted from the archive. --- ### def extract_folder(self, in_archive: str, out_dir: str, folder_path: str, policy: bit7z_python.FolderPathPolicy) -> None: ... Extracts a folder from the archive to the chosen directory. _Parameters_: - **in_archive**: the input archive to extract from. - **out_dir**: the output directory where the extracted folder will be put. - **folder_path**: the path of the folder inside the archive to be extracted. - **policy**: (optional) the path policy to be used for extracting the folder. --- ### def extract_if(self, in_archive: str, out_buffer: buffer_t, callback: typing.Callable) -> None: ... > 🚫 ***NOT USABLE*** Extracts to the output buffer the first item satisfying the given filtering criteria. _Parameters_: - **in_archive**: the input archive to extract from. - **out_buffer**: the output buffer where the extracted file will be put. - **callback**: the filtering callback that specifies whether to extract an item or not. --- ### def extract_if(self, in_archive: str, out_dir: str, callback: typing.Callable) -> None: ... Extracts to the output directory all the items that satisfy the given filtering criteria. _Parameters_: - **in_archive**: the input archive to extract from. - **out_dir**: the output directory where extracted files will be put. - **callback**: the filtering callback that specifies whether to extract an item or not. --- ### def extraction_format(self) -> bit7z_python.BitInFormat: ... Returns the archive format used by the archive opener. --- ### def extract_items(self, in_archive: str, indices: list[int], out_dir: str) -> None: ... Extracts the specified items from the given archive to the chosen directory. _Parameters_: - **in_archive**: the input archive to extract from. - **indices**: the indices of the files in the archive that should be extracted. - **out_dir**: the output directory where the extracted files will be placed. --- ### def extract_matching(self, in_archive: str, item_filter: str, out_buffer: buffer_t, policy: bit7z_python.FilterPolicy) -> None: ... > 🚫 ***NOT USABLE*** Extracts from the archive to the output buffer the first file whose path matches the given wildcard pattern. _Parameters_: - **in_archive**: the input archive to extract from. - **item_filter**: the wildcard pattern used for matching the paths of files inside the archive. - **out_buffer**: the output buffer where to extract the file. - **policy**: the filtering policy to be applied to the matched items. --- ### def extract_matching(self, in_archive: str, item_filter: str, out_dir: str, policy: bit7z_python.FilterPolicy) -> None: ... Extracts from the archive to the output directory all the items whose paths match the given wildcard pattern. _Parameters_: - **in_archive**: the input archive to extract from. - **item_filter**: the wildcard pattern used for matching the paths of files inside the archive. - **out_dir**: the output directory where extracted files will be put. - **policy**: the filtering policy to be applied to the matched items. --- ### def extract_matching_regex(self, in_archive: str, regex: str, out_buffer: buffer_t, policy: bit7z_python.FilterPolicy) -> None: ... Extracts from the archive to the output buffer the first file whose path matches the given regex pattern. > 🚫 ***NOT USABLE*** > [!NOTE] > Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define. We have enabled this option. _Parameters_: - **in_archive**: the input archive to extract from. - **regex**: the regex used for matching the paths of files inside the archive. - **out_buffer**: the output buffer where the extracted file will be put. - **policy**: the filtering policy to be applied to the matched items. --- ### def extract_matching_regex(self, in_archive: str, regex: str, out_dir: str, policy: bit7z_python.FilterPolicy) -> None: ... Extracts from the archive to the output directory all the items whose paths match the given regex pattern. > [!NOTE] > Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define. We have enabled this option. _Parameters_: - **in_archive**: the input archive to extract from. - **regex**: the regex used for matching the paths of files inside the archive. - **out_dir**: the output directory where extracted files will be put. - **policy**: the filtering policy to be applied to the matched items. --- ### def extract_root_folder_content(self, in_archive: str, out_dir: str) -> None: ... Extracts the content of the archive's root folder to the chosen directory. The archive's root folder is the single top-level folder shared by all the items in the archive; its name is stripped from the extracted items' paths. > [!NOTE] > If the archive does not have a single root folder, a BitException is thrown. _Parameters_: - **in_archive**: the input archive to extract from. - **out_dir**: the output directory where the root folder's content will be put. --- ### def extract_to(self, in_archive: str, callback: typing.Callable, indices: list[int]) -> None: ... Extracts the raw content of the archive to the given callback. > [!NOTE] > You can set a FileCallback to check the file being extracted. _Parameters_: - **in_archive**: the input archive to be extracted. - **callback**: a function providing the extracted raw data to the user. - **indices**: (optional) the indices of the files in the archive that must be extracted. --- ### def file_callback(self) -> typing.Callable: ... Returns the current file callback. --- ### def format(self) -> bit7z_python.BitInFormat: ... Returns the archive format used by the archive opener. --- ### def is_password_defined(self) -> bool: ... Returns a boolean value indicating whether a password is defined or not. --- ### def library(self) -> bit7z_python.Bit7zLibrary: ... Returns the Bit7zLibrary object used by the handler. --- ### def overwrite_mode(self) -> bit7z_python.OverwriteMode: ... Returns the current OverwriteMode. --- ### def password(self) -> str: ... Returns the password used to open, extract, or encrypt the archive. --- ### def password_callback(self) -> typing.Callable: ... Returns the current password callback. --- ### def progress_callback(self) -> typing.Callable: ... Returns the current progress callback. --- ### def ratio_callback(self) -> typing.Callable: ... Returns the current ratio callback. --- ### def retain_directories(self) -> bool: ... Returns a boolean value indicating whether the directory structure must be preserved while extracting or compressing the archive. --- ### def set_file_callback(self, callback: typing.Callable) -> None: ... Sets the function to be called when the current file being processed changes. _Parameters_: - **callback**: the file callback to be used. --- ### def set_overwrite_mode(self, mode: bit7z_python.OverwriteMode) -> None: ... Sets how the handler should behave when it tries to output to an existing file or buffer. _Parameters_: - **mode**: the OverwriteMode to be used by the handler. --- ### def set_password(self, password: str) -> None: ... Sets up a password to be used by the archive handler. The password will be used to encrypt/decrypt archives by using the default cryptographic method of the archive format. > [!NOTE] > Calling setPassword when the input archive is not encrypted does not have any effect on the extraction process. > [!NOTE] > Calling setPassword when the output format doesn't support archive encryption (e.g., GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions, and it has no effects on compression operations). > [!NOTE] > After a password has been set, it will be used for every subsequent operation. To disable the use of the password, you need to call the clearPassword method, which is equivalent to calling setPassword(L""). _Parameters_: - **password**: the password to be used. --- ### def set_password_callback(self, callback: typing.Callable) -> None: ... Sets the function to be called when a password is needed to complete the ongoing operation. _Parameters_: - **callback**: the password callback to be used. --- ### def set_progress_callback(self, callback: typing.Callable) -> None: ... Sets the function to be called when the processed size of the ongoing operation is updated. > [!NOTE] > The completion percentage of the current operation can be obtained by calculating `static_cast((100.0 * processed_size) / total_size)`. _Parameters_: - **callback**: the progress callback to be used. --- ### def set_ratio_callback(self, callback: typing.Callable) -> None: ... Sets the function to be called when the input processed size and current output size of the ongoing operation are known. > [!NOTE] > The ratio percentage of a compression operation can be obtained by calculating `static_cast((100.0 * output_size) / input_size)`. _Parameters_: - **callback**: the ratio callback to be used. --- ### def set_retain_directories(self, retain: bool) -> None: ... Sets whether the operations' output will preserve the input's directory structure or not. _Parameters_: - **retain**: the setting for preserving or not the input directory structure --- ### def set_total_callback(self, callback: typing.Callable) -> None: ... Sets the function to be called when the total size of an operation is available. _Parameters_: - **callback**: the total callback to be used. --- ### def test(self, in_archive: str, indices: list[int]) -> None: ... Tests the given archive without extracting its content. If the archive is not valid, a BitException is thrown. _Parameters_: - **in_archive**: the input archive to be tested. - **indices**: (optional) the indices of the items to be tested in the archive. --- ### def total_callback(self) -> typing.Callable: ... Returns the current total callback. ---