pybit7z package¶
Copyright (c) 2024 l.feng. All rights reserved.
pybit7z: A wrapper based on bit7z.
- class pybit7z.Bit7zLibrary¶
Bases:
pybind11_object
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
- set_large_page_mode(self: pybit7z._core.Bit7zLibrary) None ¶
Enable large page mode for 7zip library. This can improve performance on some systems.
- class pybit7z.BitAbstractArchiveCreator¶
Bases:
BitAbstractArchiveHandler
Abstract class representing a generic archive creator.
- compression_format(self: pybit7z._core.BitAbstractArchiveCreator) pybit7z._core.BitInOutFormat ¶
the format used for creating/updating an archive.
- compression_method(self: pybit7z._core.BitAbstractArchiveCreator) pybit7z._core.BitCompressionMethod ¶
the compression method used for creating/updating an archive.
- crypt_headers(self: pybit7z._core.BitAbstractArchiveCreator) bool ¶
whether the creator crypts also the headers of archives or not.
- dictionary_size(self: pybit7z._core.BitAbstractArchiveCreator) int ¶
the dictionary size used for creating/updating an archive.
- set_compression_level(self: pybit7z._core.BitAbstractArchiveCreator, level: pybit7z._core.BitCompressionLevel) None ¶
Sets the compression level to be used when creating/updating an archive.
- Parameters:
level – the compression level desired.
- set_compression_method(self: pybit7z._core.BitAbstractArchiveCreator, method: pybit7z._core.BitCompressionMethod) None ¶
Sets the compression method to be used when creating/updating an archive.
- Parameters:
method – the compression method desired.
- set_dictionary_size(self: pybit7z._core.BitAbstractArchiveCreator, dictionary_size: int) None ¶
Sets the dictionary size to be used when creating/updating an archive.
- Parameters:
dictionary_size – the dictionary size desired.
- set_password(*args, **kwargs)¶
Overloaded function.
set_password(self: pybit7z._core.BitAbstractArchiveCreator, password: str) -> None
Sets up a password for the output archives.
When setting a password, the produced archives will be encrypted using the default cryptographic method of the output format. The option “crypt headers” remains unchanged, in contrast with what happens when calling the set_password(tstring, bool) method.
- Parameters:
password – the password to be used when creating/updating archives.
Note
Calling set_password 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). 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 (inherited from BitAbstractArchiveHandler), which is equivalent to set_password(“”).
set_password(self: pybit7z._core.BitAbstractArchiveCreator, password: str, crypt_headers: bool) -> None
Sets up a password for the output archive.
When setting a password, the produced archive will be encrypted using the default cryptographic method of the output format. If the format is 7z, and the option “cryptHeaders” is set to true, the headers of the archive will be encrypted, resulting in a password request every time the output file will be opened.
- Parameters:
password – the password to be used when creating/updating archives.
crypt_headers – if true, the headers of the output archives will be encrypted (valid only when using the 7z format).
Note
Calling set_password 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). Calling set_password with “cryptHeaders” set to true does not have effects on formats different from 7z. 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 (inherited from BitAbstractArchiveHandler), which is equivalent to set_password(“”).
- set_solid_mode(self: pybit7z._core.BitAbstractArchiveCreator, solid_mode: bool) None ¶
Sets whether the archive creator uses solid compression or not.
- Parameters:
solid_mode – the solid mode desired.
Note
Setting the solid compression mode to true has effect only when using the 7z format with multiple input files.
- set_store_symbolic_links(self: pybit7z._core.BitAbstractArchiveCreator, store_symbolic_links: bool) None ¶
Sets whether the creator will store symbolic links as links in the output archive.
- Parameters:
store_symbolic_links – if true, symbolic links will be stored as links.
- set_threads_count(self: pybit7z._core.BitAbstractArchiveCreator, threads_count: int) None ¶
Sets the number of threads to be used when creating/updating an archive.
- Parameters:
threads_count – the number of threads desired.
- set_update_mode(self: pybit7z._core.BitAbstractArchiveCreator, mode: pybit7z._core.UpdateMode) None ¶
Sets whether and how the creator can update existing archives or not.
- Parameters:
mode – the desired update mode.
Note
If set to UpdateMode::None, a subsequent compression operation may throw an exception if it targets an existing archive.
- set_volume_size(self: pybit7z._core.BitAbstractArchiveCreator, volume_size: int) None ¶
Sets the volumeSize (in bytes) of the output archive volumes.
- Parameters:
volume_size – The dimension of a volume.
Note
This setting has effects only when the destination archive is on the filesystem.
- set_word_size(self: pybit7z._core.BitAbstractArchiveCreator, word_size: int) None ¶
Sets the word size to be used when creating/updating an archive.
- Parameters:
word_size – the word size desired.
- solid_mode(self: pybit7z._core.BitAbstractArchiveCreator) bool ¶
whether the archive creator uses solid compression or not.
- store_symbolic_links(self: pybit7z._core.BitAbstractArchiveCreator) bool ¶
whether the archive creator stores symbolic links as links in the output archive.
- threads_count(self: pybit7z._core.BitAbstractArchiveCreator) int ¶
the number of threads used when creating/updating an archive (a 0 value means that it will use the 7-zip default value).
- update_mode(self: pybit7z._core.BitAbstractArchiveCreator) pybit7z._core.UpdateMode ¶
the update mode used when updating existing archives.
- volume_size(self: pybit7z._core.BitAbstractArchiveCreator) int ¶
the volume size (in bytes) used when creating multi-volume archives (a 0 value means that all files are going in a single archive).
- word_size(self: pybit7z._core.BitAbstractArchiveCreator) int ¶
the word size used for creating/updating an archive.
- class pybit7z.BitAbstractArchiveHandler¶
Bases:
pybind11_object
Abstract class representing a generic archive handler.
- clear_password(self: pybit7z._core.BitAbstractArchiveHandler) None ¶
Clear the current password used by the handler.
Calling clear_password() will disable the encryption/decryption of archives.
Note
This is equivalent to calling set_password(“”).
- file_callback(self: pybit7z._core.BitAbstractArchiveHandler) Callable[[str], None] ¶
the current file callback.
- format(self: pybit7z._core.BitAbstractArchiveHandler) pybit7z._core.BitInFormat ¶
the format used by the handler for extracting or compressing.
- is_password_defined(self: pybit7z._core.BitAbstractArchiveHandler) bool ¶
a boolean value indicating whether a password is defined or not.
- overwrite_mode(self: pybit7z._core.BitAbstractArchiveHandler) pybit7z._core.OverwriteMode ¶
the overwrite mode.
- password(self: pybit7z._core.BitAbstractArchiveHandler) str ¶
the password used to open, extract, or encrypt the archive.
- password_callback(self: pybit7z._core.BitAbstractArchiveHandler) Callable[[], str] ¶
the current password callback.
- progress_callback(self: pybit7z._core.BitAbstractArchiveHandler) Callable[[int], bool] ¶
the current progress callback.
- ratio_callback(self: pybit7z._core.BitAbstractArchiveHandler) Callable[[int, int], None] ¶
the current ratio callback.
- retainDirectories(self: pybit7z._core.BitAbstractArchiveHandler) bool ¶
a boolean value indicating whether the directory structure must be preserved while extracting or compressing the archive.
- set_file_callback(self: pybit7z._core.BitAbstractArchiveHandler, callback: Callable[[str], None]) None ¶
Sets the function to be called when the current file being processed changes.
- Parameters:
callback – the file callback to be used.
- set_overwrite_mode(self: pybit7z._core.BitAbstractArchiveHandler, mode: pybit7z._core.OverwriteMode) None ¶
Sets how the handler should behave when it tries to output to an existing file or buffer. :param mode: the OverwriteMode to be used by the handler.
- set_password(self: pybit7z._core.BitAbstractArchiveHandler, 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.
- Parameters:
password – the password to be used.
Note
Calling this set_password when the input archive is not encrypted does not have any effect on the extraction process. Calling this set_password 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). 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 clear_password method, which is equivalent to calling set_password(L””).
- set_password_callback(self: pybit7z._core.BitAbstractArchiveHandler, callback: Callable[[], str]) 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.
- set_progress_callback(self: pybit7z._core.BitAbstractArchiveHandler, callback: Callable[[int], bool]) None ¶
Sets the function to be called when the processed size of the ongoing operation is updated.
- Parameters:
callback – the progress callback to be used.
Note
The completion percentage of the current operation can be obtained by calculating int((100.0 * processed_size) / total_size).
- set_ratio_callback(self: pybit7z._core.BitAbstractArchiveHandler, callback: Callable[[int, int], None]) None ¶
Sets the function to be called when the input processed size and current output size of the ongoing operation are known.
- Parameters:
callback – the ratio callback to be used.
Note
The ratio percentage of a compression operation can be obtained by calculating int((100.0 * output_size) / input_size).
- set_retain_directories(self: pybit7z._core.BitAbstractArchiveHandler, 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
- set_total_callback(self: pybit7z._core.BitAbstractArchiveHandler, callback: Callable[[int], None]) None ¶
Sets the function to be called when the total size of an operation is available.
- Parameters:
callback – the total callback to be used.
- total_callback(self: pybit7z._core.BitAbstractArchiveHandler) Callable[[int], None] ¶
the current total callback.
- class pybit7z.BitAbstractArchiveOpener¶
Bases:
BitAbstractArchiveHandler
- extraction_format(self: pybit7z._core.BitAbstractArchiveOpener) pybit7z._core.BitInFormat ¶
the archive format used by the archive opener.
- class pybit7z.BitArchiveEditor¶
Bases:
BitArchiveWriter
- apply_changes(self: pybit7z._core.BitArchiveEditor) None ¶
Applies the requested changes (i.e., rename/update/delete operations) to the input archive.
- delete_item(*args, **kwargs)¶
Overloaded function.
delete_item(self: pybit7z._core.BitArchiveEditor, index: int, policy: pybit7z._core.DeletePolicy = DeletePolicy.ItemOnly) -> None
Marks as deleted the item at the given index.
- Parameters:
index – the index of the item to be deleted.
policy – the policy to be used when deleting items. Default to DeletePolicy.ItemOnly.
- Exceptions:
BitException if the index is invalid.
Note
By default, if the item is a folder, only its metadata is deleted, not the files within it. If instead the policy is set to DeletePolicy::RecurseDirs, then the items within the folder will also be deleted.
delete_item(self: pybit7z._core.BitArchiveEditor, item_path: str, policy: pybit7z._core.DeletePolicy = DeletePolicy.ItemOnly) -> None
Marks as deleted the archive’s item(s) with the specified path.
- Parameters:
item_path – the path (in the archive) of the item to be deleted.
policy – the policy to be used when deleting items. Default to DeletePolicy.ItemOnly.
- Exceptions:
BitException if the specified path is empty or invalid, or if no matching item could be found.
Note
By default, if the marked item is a folder, only its metadata will be deleted, not the files within it. To delete the folder contents as well, set the policy to DeletePolicy::RecurseDirs. The specified path must not begin with a path separator. A path with a trailing separator will _only_ be considered if the policy is DeletePolicy::RecurseDirs, and will only match folders; with DeletePolicy::ItemOnly, no item will match a path with a trailing separator. Generally, archives may contain multiple items with the same paths. If this is the case, all matching items will be marked as deleted according to the specified policy.
- rename_item(*args, **kwargs)¶
Overloaded function.
rename_item(self: pybit7z._core.BitArchiveEditor, index: int, new_path: str) -> None
Requests to change the path of the item at the specified index with the given one.
- Parameters:
index – the index of the item to be renamed.
new_path – the new path of the item.
rename_item(self: pybit7z._core.BitArchiveEditor, old_path: str, new_path: str) -> None
Requests to change the path of the item from oldPath to the newPath.
- Parameters:
old_path – the current path of the item to be renamed.
new_path – the new path of the item.
- set_update_mode(self: pybit7z._core.BitArchiveEditor, update_mode: pybit7z._core.UpdateMode) None ¶
Sets how the editor performs the update of the items in the archive.
- Parameters:
mode – the desired update mode (either UpdateMode::Append or UpdateMode::Overwrite).
Note
BitArchiveEditor doesn’t support UpdateMode::Nothing.
- update_item(*args, **kwargs)¶
Overloaded function.
update_item(self: pybit7z._core.BitArchiveEditor, index: int, in_file: str) -> None
Requests to update the content of the item at the specified index with the data from the given file.
- Parameters:
index – the index of the item to be updated.
in_file – the path of the file to be used for the update.
update_item(self: pybit7z._core.BitArchiveEditor, index: int, input_buffer: bytes) -> None
Requests to update the content of the item at the specified index with the data from the given buffer.
- Parameters:
index – the index of the item to be updated.
input_buffer – the buffer containing the new data for the item.
update_item(self: pybit7z._core.BitArchiveEditor, item_path: str, in_file: str) -> None
Requests to update the content of the item at the specified path with the data from the given file.
- Parameters:
item_path – the path of the item to be updated.
in_file – the path of the file to be used for the update.
update_item(self: pybit7z._core.BitArchiveEditor, item_path: str, input_buffer: bytes) -> None
Requests to update the content of the item at the specified path with the data from the given buffer.
- Parameters:
item_path – the path of the item to be updated.
input_buffer – the buffer containing the new data for the item.
- class pybit7z.BitArchiveItem¶
Bases:
BitGenericItem
The BitArchiveItem class represents a generic item inside an archive.
- attributes(self: pybit7z._core.BitArchiveItem) int ¶
the item attributes.
- crc(self: pybit7z._core.BitArchiveItem) int ¶
the CRC of the item.
- creation_time(self: pybit7z._core.BitArchiveItem) datetime.datetime ¶
- extension(self: pybit7z._core.BitArchiveItem) str ¶
the extension of the item, if available or if it can be inferred from the name; otherwise it returns an empty string (e.g., when the item is a folder).
- index(self: pybit7z._core.BitArchiveItem) int ¶
the index of the item in the archive.
- is_encrypted(self: pybit7z._core.BitArchiveItem) bool ¶
true if and only if the item is encrypted.
- last_access_time(self: pybit7z._core.BitArchiveItem) datetime.datetime ¶
- last_write_time(self: pybit7z._core.BitArchiveItem) datetime.datetime ¶
- native_path(self: pybit7z._core.BitArchiveItem) str ¶
the path of the item in the archive, if available or inferable from the name, or an empty string otherwise.
- pack_size(self: pybit7z._core.BitArchiveItem) int ¶
the compressed size of the item.
- class pybit7z.BitArchiveItemInfo¶
Bases:
BitArchiveItem
The BitArchiveItemInfo class represents an archived item and that stores all its properties for later use.
- item_properties(self: pybit7z._core.BitArchiveItemInfo) dict[pybit7z._core.BitProperty, pybit7z._core.BitPropVariant] ¶
a map of all the available (i.e., non-empty) item properties and their respective values.
- item_property(self: pybit7z._core.BitArchiveItemInfo, arg0: pybit7z._core.BitProperty) pybit7z._core.BitPropVariant ¶
Gets the specified item property.
- Parameters:
property_id (bit7z::BitProperty) – The ID of the property to get.
- Returns:
the value of the item property, if available, or an empty BitPropVariant.
- Return type:
- class pybit7z.BitArchiveItemOffset¶
Bases:
BitArchiveItem
The BitArchiveItemOffset class represents an archived item but doesn’t store its properties.
- item_property(self: pybit7z._core.BitArchiveItemOffset, arg0: pybit7z._core.BitProperty) pybit7z._core.BitPropVariant ¶
Gets the specified item property.
- Parameters:
property_id (bit7z::BitProperty) – The ID of the property to get.
- Returns:
the value of the item property, if available, or an empty BitPropVariant.
- Return type:
- class pybit7z.BitArchiveReader¶
Bases:
BitAbstractArchiveOpener
,BitInputArchive
- archive_properties(self: pybit7z._core.BitArchiveReader) dict[pybit7z._core.BitProperty, pybit7z._core.BitPropVariant] ¶
a map of all the available (i.e., non-empty) archive properties and their respective values.
- files_count(self: pybit7z._core.BitArchiveReader) int ¶
the number of files in the archive.
- folders_count(self: pybit7z._core.BitArchiveReader) int ¶
the number of folders in the archive.
- has_encrypted_items(self: pybit7z._core.BitArchiveReader) bool ¶
true if and only if the archive has at least one encrypted item.
- is_encrypted(self: pybit7z._core.BitArchiveReader) bool ¶
true if and only if the archive has only encrypted items.
- static is_header_encrypted(*args, **kwargs)¶
Overloaded function.
is_header_encrypted(library: pybit7z._core.Bit7zLibrary, in_archive: str, format: pybit7z._core.BitInFormat = FormatAuto) -> bool
Checks if the given archive is header-encrypted or not.
- Parameters:
library – the library used for decompression.
in_archive – the path to the archive to be checked.
format – the format of the input archive. Default is FormatAuto.
is_header_encrypted(library: pybit7z._core.Bit7zLibrary, in_archive: bytes, format: pybit7z._core.BitInFormat = FormatAuto) -> bool
Checks if the given memory buffer archive is header-encrypted or not.
- Parameters:
library – the library used for decompression.
in_archive – the input buffer containing the archive to be checked.
format – the format of the input archive. Default is FormatAuto.
- is_multi_volume(self: pybit7z._core.BitArchiveReader) bool ¶
true if and only if the archive is composed by multiple volumes.
- is_solid(self: pybit7z._core.BitArchiveReader) bool ¶
true if and only if the archive was created using solid compression.
- items(self: pybit7z._core.BitArchiveReader) list[pybit7z._core.BitArchiveItemInfo] ¶
the list of all the archive items as BitArchiveItem objects.
- pack_size(self: pybit7z._core.BitArchiveReader) int ¶
the total compressed size of the archive content.
- size(self: pybit7z._core.BitArchiveReader) int ¶
the total uncompressed size of the archive content.
- volumes_count(self: pybit7z._core.BitArchiveReader) int ¶
the number of volumes in the archive.
- class pybit7z.BitArchiveWriter¶
- class pybit7z.BitCompressionLevel¶
Bases:
pybind11_object
Compression level for 7zip library
Members:
Nothing
Fastest
Fast
Normal
Max
Ultra
- Fast = <BitCompressionLevel.Fast: 3>¶
- Fastest = <BitCompressionLevel.Fastest: 1>¶
- Max = <BitCompressionLevel.Max: 7>¶
- Normal = <BitCompressionLevel.Normal: 5>¶
- Nothing = <BitCompressionLevel.Nothing: 0>¶
- Ultra = <BitCompressionLevel.Ultra: 9>¶
- property name¶
- property value¶
- class pybit7z.BitCompressionMethod¶
Bases:
pybind11_object
Compression method by bit7z when creating archives.
Members:
Copy
Deflate
Deflate64
BZip2
Lzma
Lzma2
Ppmd
- BZip2 = <BitCompressionMethod.BZip2: 3>¶
- Copy = <BitCompressionMethod.Copy: 0>¶
- Deflate = <BitCompressionMethod.Deflate: 1>¶
- Deflate64 = <BitCompressionMethod.Deflate64: 2>¶
- Lzma = <BitCompressionMethod.Lzma: 4>¶
- Lzma2 = <BitCompressionMethod.Lzma2: 5>¶
- Ppmd = <BitCompressionMethod.Ppmd: 6>¶
- property name¶
- property value¶
- class pybit7z.BitFileCompressor¶
Bases:
BitStringCompressor
- compress(*args, **kwargs)¶
Overloaded function.
compress(self: pybit7z._core.BitFileCompressor, in_files: list[str], out_archive: str) -> None
Compresses the given files or directories.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem.
- Parameters:
in_files – the input files to be compressed.
out_archive – the path (relative or absolute) to the output archive file.
compress(self: pybit7z._core.BitFileCompressor, in_files: dict[str, str], out_archive: str) -> None
Compresses the given files or directories using the specified aliases.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem. Each pair in the map must follow the following format: {“path to file in the filesystem”, “alias path in the archive”}.
- Parameters:
in_files – a map of paths and corresponding aliases.
out_archive – the path (relative or absolute) to the output archive file.
- compress_directory(self: pybit7z._core.BitFileCompressor, in_dir: str, out_archive: str) None ¶
Compresses an entire directory.
- Parameters:
in_dir – the path (relative or absolute) to the input directory.
out_archive – the path (relative or absolute) to the output archive file.
Note
This method is equivalent to compress_files with filter set to “”.
- compress_directory_contents(self: pybit7z._core.BitFileCompressor, in_dir: str, out_archive: str, recursive: bool = True, filter_pattern: str = '*') None ¶
Compresses the contents of a directory.
- Parameters:
in_dir – the path (relative or absolute) to the input directory.
out_archive – the path (relative or absolute) to the output archive file.
recursive – (optional) if true, it searches files inside the sub-folders of in_dir.
filter_pattern – the wildcard pattern to filter the files to be compressed (optional).
Note
Unlike compress_files, this method includes also the metadata of the sub-folders.
- compress_files(*args, **kwargs)¶
Overloaded function.
compress_files(self: pybit7z._core.BitFileCompressor, in_files: list[str], out_archive: str) -> None
Compresses a group of files.
- Parameters:
in_files – the input files to be compressed.
out_archive – the path (relative or absolute) to the output archive file.
Note
Any path to a directory or to a not-existing file will be ignored!
compress_files(self: pybit7z._core.BitFileCompressor, in_dir: str, out_archive: str, recursive: bool = True, filter_pattern: str = ‘*’) -> None
Compresses all the files in the given directory.
- Parameters:
in_dir – the path (relative or absolute) to the input directory.
out_archive – the path (relative or absolute) to the output archive file.
recursive – (optional) if true, it searches files inside the sub-folders of in_dir.
filter_pattern – the wildcard pattern to filter the files to be compressed (optional).
- pybit7z.BitFileExtractor¶
alias of
BitStringExtractor
- class pybit7z.BitGenericItem¶
Bases:
pybind11_object
The BitGenericItem interface class represents a generic item (either inside or outside an archive).
- attributes(self: pybit7z._core.BitGenericItem) int ¶
the item attributes.
- is_dir(self: pybit7z._core.BitGenericItem) bool ¶
true if and only if the item is a directory (i.e., it has the property BitProperty::IsDir)
- name(self: pybit7z._core.BitGenericItem) str ¶
the name of the item, if available or inferable from the path, or an empty string otherwise.
- path(self: pybit7z._core.BitGenericItem) str ¶
the path of the item.
- size(self: pybit7z._core.BitGenericItem) int ¶
the uncompressed size of the item.
- class pybit7z.BitInFormat¶
Bases:
pybind11_object
The BitInFormat class specifies an extractable archive format.
- value(self: pybit7z._core.BitInFormat) int ¶
the value of the format in the 7z SDK.
- class pybit7z.BitInOutFormat¶
Bases:
BitInFormat
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
- default_method(self: pybit7z._core.BitInOutFormat) pybit7z._core.BitCompressionMethod ¶
the default method used for compressing the archive format.
- extension(self: pybit7z._core.BitInOutFormat) str ¶
the default file extension of the archive format.
- features(self: pybit7z._core.BitInOutFormat) pybit7z._core.FormatFeatures ¶
the bitset of the features supported by the format.
- has_feature(self: pybit7z._core.BitInOutFormat, arg0: pybit7z._core.FormatFeatures) bool ¶
Checks if the format has a specific feature (see FormatFeatures enum) :param feature: the feature to check :type feature: FormatFeatures
- Returns:
a boolean value indicating whether the format has the given feature.
- Return type:
- class pybit7z.BitInputArchive¶
Bases:
pybind11_object
- archive_path(self: pybit7z._core.BitInputArchive) str ¶
the path to the archive (the empty string for buffer/stream archives).
- archive_property(self: pybit7z._core.BitInputArchive, arg0: pybit7z._core.BitProperty) pybit7z._core.BitPropVariant ¶
Gets the specified archive property.
- Parameters:
property – the property to be retrieved.
- Returns:
the current value of the archive property or an empty BitPropVariant if no value is specified.
- contains(self: pybit7z._core.BitInputArchive, path: str) bool ¶
Find if there is an item in the archive that has the given path.
- Parameters:
path – the path of the file or folder to be checked.
- Returns:
true if and only if the archive contains the specified file or folder.
- detected_format(self: pybit7z._core.BitInputArchive) pybit7z._core.BitInFormat ¶
the detected format of the file.
- extract_to(*args, **kwargs)¶
Overloaded function.
extract_to(self: pybit7z._core.BitInputArchive, path: str) -> None
Extracts the archive to the chosen directory.
- Parameters:
outDir – the output directory where the extracted files will be put.
extract_to(self: pybit7z._core.BitInputArchive, out_dir: str, indices: list[int]) -> None
Extracts the specified items to the chosen directory.
- Parameters:
out_dir – the output directory where the extracted files will be put.
indices – the array of indices of the files in the archive that must be extracted.
extract_to(self: pybit7z._core.BitInputArchive, index: int) -> bytes
Extracts a file to the output buffer.
- Parameters:
index – the index of the file to be extracted.
extract_to(self: pybit7z._core.BitInputArchive) -> dict[str, bytes]
Extracts the content of the archive to a map of memory buffers, where the keys are the paths of the files (inside the archive), and the values are their decompressed contents.
- is_item_encrypted(self: pybit7z._core.BitInputArchive, index: int) bool ¶
Whether the item at the given index is encrypted.
- Parameters:
index – the index of an item in the archive.
- Returns:
true if and only if the item at the given index is encrypted.
- is_item_folder(self: pybit7z._core.BitInputArchive, index: int) bool ¶
Whether the item at the given index is a folder. :param index: the index of an item in the archive.
- Returns:
true if and only if the item at the given index is a folder.
- item_at(self: pybit7z._core.BitInputArchive, index: int) pybit7z._core.BitArchiveItemOffset ¶
Retrieve the item at the given index.
- Parameters:
index – the index of the item to be retrieved.
- Returns:
the item at the given index within the archive.
- item_property(self: pybit7z._core.BitInputArchive, index: int, property: pybit7z._core.BitProperty) pybit7z._core.BitPropVariant ¶
Gets the specified item property.
- Parameters:
index – the index of the item to retrieve the property from.
property – the property to be retrieved.
- Returns:
the current value of the item property or an empty BitPropVariant if no value is specified.
- items_count(self: pybit7z._core.BitInputArchive) int ¶
the number of items in the archive.
- test(self: pybit7z._core.BitInputArchive) None ¶
Tests the archive without extracting its content.
If the archive is not valid, a BitException is thrown!
- test_item(self: pybit7z._core.BitInputArchive, index: int) None ¶
Tests the item at the given index inside the archive without extracting it.
If the archive is not valid, or there’s no item at the given index, a BitException is thrown!
- use_format_property(self: pybit7z._core.BitInputArchive, name: str, property: pybit7z._core.BitPropVariant) None ¶
Use the given format property to read the archive. See <https://github.com/rikyoz/bit7z/issues/248> for more information.
- Parameters:
name – the name of the property.
property – the property value.
- class pybit7z.BitMemCompressor¶
Bases:
BitAbstractArchiveCreator
- compress_file(*args, **kwargs)¶
Overloaded function.
compress_file(self: pybit7z._core.BitMemCompressor, input: bytes, out_file: str, input_name: str = ‘’) -> None
Compresses the given memory buffer to the chosen archive.
- Parameters:
input – the input memory buffer to be compressed.
out_file – the path (relative or absolute) to the output archive file.
input_name – (optional) the name to give to the compressed file inside the output archive.
compress_file(self: pybit7z._core.BitMemCompressor, input: bytes, input_name: str = ‘’) -> bytes
Compresses the given memory buffer to a memory buffer.
- Parameters:
input – the input memory buffer to be compressed.
input_name – (optional) the name to give to the compressed file inside the output archive.
- class pybit7z.BitMemExtractor¶
Bases:
BitAbstractArchiveOpener
- extract(*args, **kwargs)¶
Overloaded function.
extract(self: pybit7z._core.BitMemExtractor, in_archive: bytes, out_dir: str) -> None
Extracts the given archive to the chosen directory.
- Parameters:
in_archive – the input archive to be extracted.
out_dir – the directory where to extract the files.
extract(self: pybit7z._core.BitMemExtractor, in_archive: bytes, index: int) -> bytes
Extracts the specified item from the given archive to a memory buffer.
extract(self: pybit7z._core.BitMemExtractor, in_archive: bytes) -> dict[str, bytes]
Extracts all the items from the given archive to a dictionary of memory buffers.
- extract_items(self: pybit7z._core.BitMemExtractor, in_archive: bytes, 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.
- extract_matching(*args, **kwargs)¶
Overloaded function.
extract_matching(self: pybit7z._core.BitMemExtractor, in_archive: bytes, pattern: str, out_dir: str = ‘’, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> None
Extracts the files in the archive that match the given wildcard pattern to the chosen directory.
- Parameters:
in_archive – the input archive to be extracted.
pattern – the wildcard pattern to be used for matching the files.
out_dir – the directory where to extract the matching files.
policy – the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
extract_matching(self: pybit7z._core.BitMemExtractor, in_archive: bytes, pattern: str, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> bytes
Extracts to the output buffer the first file in the archive matching the given wildcard pattern. :param in_archive: the input archive to extract from. :param pattern: the wildcard pattern to be used for matching the files. :param policy: the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
- extract_matching_regex(*args, **kwargs)¶
Overloaded function.
extract_matching_regex(self: pybit7z._core.BitMemExtractor, in_archive: bytes, regex: str, out_dir: str = ‘’, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> None
Extracts the files in the archive that match the given regex pattern to the chosen directory.
- Parameters:
in_archive – the input archive to extract from.
regex – the regex pattern to be used for matching the files.
out_dir – the output directory where the extracted files will be placed.
policy – the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
extract_matching_regex(self: pybit7z._core.BitMemExtractor, in_archive: bytes, regex: str, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> bytes
Extracts to the output buffer the first file in the archive matching the given regex pattern.
- test(self: pybit7z._core.BitMemExtractor, in_archive: bytes) 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.
- class pybit7z.BitOutputArchive¶
Bases:
pybind11_object
- add_directory(self: pybit7z._core.BitOutputArchive, in_dir: str) None ¶
Adds the given directory path and all its content.
- Parameters:
in_dir – the path of the directory to be added to the archive.
- add_directory_contents(*args, **kwargs)¶
Overloaded function.
add_directory_contents(self: pybit7z._core.BitOutputArchive, in_dir: str, filter: str, recursive: bool) -> None
Adds the contents of the given directory path.
This function iterates through the specified directory and adds its contents based on the provided wildcard filter. Optionally, the operation can be recursive, meaning it will include subdirectories and their contents.
- Parameters:
in_dir – the directory where to search for files to be added to the output archive.
filter – the wildcard filter to be used for searching the files.
recursive – recursively search the files in the given directory and all of its subdirectories.
add_directory_contents(self: pybit7z._core.BitOutputArchive, in_dir: str, filter: str = ‘*’, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include, recursive: bool = True) -> None
Adds the contents of the given directory path.
This function iterates through the specified directory and adds its contents based on the provided wildcard filter and policy. Optionally, the operation can be recursive, meaning it will include subdirectories and their contents.
- Parameters:
in_dir – the directory where to search for files to be added to the output archive.
filter – the wildcard filter to be used for searching the files.
recursive – recursively search the files in the given directory and all of its subdirectories.
policy – the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
- add_file(*args, **kwargs)¶
Overloaded function.
add_file(self: pybit7z._core.BitOutputArchive, in_file: str, name: str = ‘’) -> None
Adds the given file path, with an optional user-defined path to be used in the output archive.
- Parameters:
in_file – the path to the filesystem file to be added to the output archive.
name – (optional) user-defined path to be used inside the output archive.
Note
If a directory path is given, a BitException is thrown.
add_file(self: pybit7z._core.BitOutputArchive, input: bytes, name: str) -> None
Adds the given memory buffer, with an optional user-defined path to be used in the output archive.
- Parameters:
input – the memory buffer to be added to the output archive.
name – user-defined path to be used inside the output archive.
- add_files(*args, **kwargs)¶
Overloaded function.
add_files(self: pybit7z._core.BitOutputArchive, in_files: list[str]) -> None
Adds all the files in the given vector of filesystem paths.
- Parameters:
in_files – the paths to be added to the archive.
Note
Paths to directories are ignored.
add_files(self: pybit7z._core.BitOutputArchive, in_dir: str, filter: str, recursive: bool) -> None
Adds all the files inside the given directory path that match the given wildcard filter.
- Parameters:
in_dir – the directory where to search for files to be added to the output archive.
filter – (optional) the filter pattern to be used to select the files to be added.
recursive – (optional) if true, the directory will be searched recursively.
Note
If a file path is given, a BitException is thrown.
add_files(self: pybit7z._core.BitOutputArchive, in_dir: str, filter: str = ‘*’, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include, recursive: bool = True) -> None
Adds all the files inside the given directory path that match the given wildcard filter, with the specified filter policy.
- Parameters:
in_dir – the directory where to search for files to be added to the output archive.
filter – (optional) the wildcard filter to be used for searching the files.
recursive – (optional) recursively search the files in the given directory and all of its subdirectories.
policy – (optional) the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
- add_items(*args, **kwargs)¶
Overloaded function.
add_items(self: pybit7z._core.BitOutputArchive, paths: list[str]) -> None
Adds all the items that can be found by indexing the given vector of filesystem paths.
- Parameters:
paths – the paths to be added to the archive.
add_items(self: pybit7z._core.BitOutputArchive, files: dict[str, str]) -> None
Adds all the items that can be found by indexing the keys of the given map of filesystem paths; the corresponding mapped values are the user-defined paths wanted inside the output archive.
- Parameters:
files – the map of file paths and their contents to be added to the archive.
- compress_to(*args, **kwargs)¶
Overloaded function.
compress_to(self: pybit7z._core.BitOutputArchive, out_file: str) -> None
Compresses all the items added to this object to the specified archive file path.
- Parameters:
out_file – the output archive file path.
Note
If this object was created by passing an input archive file path, and this latter is the same as the out_file path parameter, the file will be updated.
compress_to(self: pybit7z._core.BitOutputArchive) -> bytes
Compresses all the items added to this object to the specified buffer.
- items_count(self: pybit7z._core.BitOutputArchive) int ¶
the number of items in the archive.
- class pybit7z.BitPropVariant¶
Bases:
pybind11_object
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful getters.
- clear(self: pybit7z._core.BitPropVariant) None ¶
Clears the variant.
- get_bool(self: pybit7z._core.BitPropVariant) bool ¶
- get_file_time(self: pybit7z._core.BitPropVariant) datetime.datetime ¶
- get_int64(self: pybit7z._core.BitPropVariant) int ¶
- get_native_string(self: pybit7z._core.BitPropVariant) str ¶
- get_string(self: pybit7z._core.BitPropVariant) str ¶
- get_uint64(self: pybit7z._core.BitPropVariant) int ¶
- is_bool(self: pybit7z._core.BitPropVariant) bool ¶
- is_file_time(self: pybit7z._core.BitPropVariant) bool ¶
- is_int16(self: pybit7z._core.BitPropVariant) bool ¶
- is_int32(self: pybit7z._core.BitPropVariant) bool ¶
- is_int64(self: pybit7z._core.BitPropVariant) bool ¶
- is_int8(self: pybit7z._core.BitPropVariant) bool ¶
- is_string(self: pybit7z._core.BitPropVariant) bool ¶
- is_uint16(self: pybit7z._core.BitPropVariant) bool ¶
- is_uint32(self: pybit7z._core.BitPropVariant) bool ¶
- is_uint64(self: pybit7z._core.BitPropVariant) bool ¶
- is_uint8(self: pybit7z._core.BitPropVariant) bool ¶
- type(self: pybit7z._core.BitPropVariant) pybit7z._core.BitPropVariantType ¶
Returns the type of the variant.
- class pybit7z.BitPropVariantType¶
Bases:
pybind11_object
The BitPropVariantType enum represents the possible types that a BitPropVariant can store.
Members:
Empty
Bool
String
UInt8
UInt16
UInt32
UInt64
Int8
Int16
Int32
Int64
FileTime
- Bool = <BitPropVariantType.Bool: 1>¶
- Empty = <BitPropVariantType.Empty: 0>¶
- FileTime = <BitPropVariantType.FileTime: 11>¶
- Int16 = <BitPropVariantType.Int16: 8>¶
- Int32 = <BitPropVariantType.Int32: 9>¶
- Int64 = <BitPropVariantType.Int64: 10>¶
- Int8 = <BitPropVariantType.Int8: 7>¶
- String = <BitPropVariantType.String: 2>¶
- UInt16 = <BitPropVariantType.UInt16: 4>¶
- UInt32 = <BitPropVariantType.UInt32: 5>¶
- UInt64 = <BitPropVariantType.UInt64: 6>¶
- UInt8 = <BitPropVariantType.UInt8: 3>¶
- property name¶
- property value¶
- class pybit7z.BitProperty¶
Bases:
pybind11_object
The BitProperty enum represents the archive/item properties that 7-zip can read or write.
Members:
NoProperty
MainSubfile
HandlerItemIndex
Path
Name
Extension
IsDir
Size
PackSize
Attrib
CTime
ATime
MTime
Solid
Commented
Encrypted
SplitBefore
SplitAfter
DictionarySize
CRC
Type
IsAnti
Method
HostOS
FileSystem
User
Group
Block
Comment
Position
Prefix
NumSubDirs
NumSubFiles
UnpackVer
Volume
IsVolume
Offset
Links
NumBlocks
NumVolumes
TimeType
Bit64
BigEndian
Cpu
PhySize
HeadersSize
Checksum
Characters
Va
Id
ShortName
CreatorApp
SectorSize
PosixAttrib
SymLink
Error
TotalSize
FreeSpace
ClusterSize
VolumeName
LocalName
Provider
NtSecure
IsAltStream
IsAux
IsDeleted
IsTree
Sha1
Sha256
ErrorType
NumErrors
ErrorFlags
WarningFlags
Warning
NumStreams
NumAltStreams
AltStreamsSize
VirtualSize
UnpackSize
TotalPhySize
VolumeIndex
SubType
ShortComment
CodePage
IsNotArcType
PhySizeCantBeDetected
ZerosTailIsAllowed
TailSize
EmbeddedStubSize
NtReparse
HardLink
INode
StreamId
ReadOnly
OutName
CopyLink
- ATime = <BitProperty.ATime: 11>¶
- AltStreamsSize = <BitProperty.AltStreamsSize: 76>¶
- Attrib = <BitProperty.Attrib: 9>¶
- BigEndian = <BitProperty.BigEndian: 42>¶
- Bit64 = <BitProperty.Bit64: 41>¶
- Block = <BitProperty.Block: 27>¶
- CRC = <BitProperty.CRC: 19>¶
- CTime = <BitProperty.CTime: 10>¶
- Characters = <BitProperty.Characters: 47>¶
- Checksum = <BitProperty.Checksum: 46>¶
- ClusterSize = <BitProperty.ClusterSize: 58>¶
- CodePage = <BitProperty.CodePage: 83>¶
- Comment = <BitProperty.Comment: 28>¶
- Commented = <BitProperty.Commented: 14>¶
- CopyLink = <BitProperty.CopyLink: 95>¶
- Cpu = <BitProperty.Cpu: 43>¶
- CreatorApp = <BitProperty.CreatorApp: 51>¶
- DictionarySize = <BitProperty.DictionarySize: 18>¶
- EmbeddedStubSize = <BitProperty.EmbeddedStubSize: 88>¶
- Encrypted = <BitProperty.Encrypted: 15>¶
- Error = <BitProperty.Error: 55>¶
- ErrorFlags = <BitProperty.ErrorFlags: 71>¶
- ErrorType = <BitProperty.ErrorType: 69>¶
- Extension = <BitProperty.Extension: 5>¶
- FileSystem = <BitProperty.FileSystem: 24>¶
- FreeSpace = <BitProperty.FreeSpace: 57>¶
- Group = <BitProperty.Group: 26>¶
- HandlerItemIndex = <BitProperty.HandlerItemIndex: 2>¶
- HardLink = <BitProperty.HardLink: 90>¶
- HeadersSize = <BitProperty.HeadersSize: 45>¶
- HostOS = <BitProperty.HostOS: 23>¶
- INode = <BitProperty.INode: 91>¶
- Id = <BitProperty.Id: 49>¶
- IsAltStream = <BitProperty.IsAltStream: 63>¶
- IsAnti = <BitProperty.IsAnti: 21>¶
- IsAux = <BitProperty.IsAux: 64>¶
- IsDeleted = <BitProperty.IsDeleted: 65>¶
- IsDir = <BitProperty.IsDir: 6>¶
- IsNotArcType = <BitProperty.IsNotArcType: 84>¶
- IsTree = <BitProperty.IsTree: 66>¶
- IsVolume = <BitProperty.IsVolume: 35>¶
- Links = <BitProperty.Links: 37>¶
- LocalName = <BitProperty.LocalName: 60>¶
- MTime = <BitProperty.MTime: 12>¶
- MainSubfile = <BitProperty.MainSubfile: 1>¶
- Method = <BitProperty.Method: 22>¶
- Name = <BitProperty.Name: 4>¶
- NoProperty = <BitProperty.NoProperty: 0>¶
- NtReparse = <BitProperty.NtReparse: 89>¶
- NtSecure = <BitProperty.NtSecure: 62>¶
- NumAltStreams = <BitProperty.NumAltStreams: 75>¶
- NumBlocks = <BitProperty.NumBlocks: 38>¶
- NumErrors = <BitProperty.NumErrors: 70>¶
- NumStreams = <BitProperty.NumStreams: 74>¶
- NumSubDirs = <BitProperty.NumSubDirs: 31>¶
- NumSubFiles = <BitProperty.NumSubFiles: 32>¶
- NumVolumes = <BitProperty.NumVolumes: 39>¶
- Offset = <BitProperty.Offset: 36>¶
- OutName = <BitProperty.OutName: 94>¶
- PackSize = <BitProperty.PackSize: 8>¶
- Path = <BitProperty.Path: 3>¶
- PhySize = <BitProperty.PhySize: 44>¶
- PhySizeCantBeDetected = <BitProperty.PhySizeCantBeDetected: 85>¶
- Position = <BitProperty.Position: 29>¶
- PosixAttrib = <BitProperty.PosixAttrib: 53>¶
- Prefix = <BitProperty.Prefix: 30>¶
- Provider = <BitProperty.Provider: 61>¶
- ReadOnly = <BitProperty.ReadOnly: 93>¶
- SectorSize = <BitProperty.SectorSize: 52>¶
- Sha1 = <BitProperty.Sha1: 67>¶
- Sha256 = <BitProperty.Sha256: 68>¶
- ShortComment = <BitProperty.ShortComment: 82>¶
- ShortName = <BitProperty.ShortName: 50>¶
- Size = <BitProperty.Size: 7>¶
- Solid = <BitProperty.Solid: 13>¶
- SplitAfter = <BitProperty.SplitAfter: 17>¶
- SplitBefore = <BitProperty.SplitBefore: 16>¶
- StreamId = <BitProperty.StreamId: 92>¶
- SubType = <BitProperty.SubType: 81>¶
- SymLink = <BitProperty.SymLink: 54>¶
- TailSize = <BitProperty.TailSize: 87>¶
- TimeType = <BitProperty.TimeType: 40>¶
- TotalPhySize = <BitProperty.TotalPhySize: 79>¶
- TotalSize = <BitProperty.TotalSize: 56>¶
- Type = <BitProperty.Type: 20>¶
- UnpackSize = <BitProperty.UnpackSize: 78>¶
- UnpackVer = <BitProperty.UnpackVer: 33>¶
- User = <BitProperty.User: 25>¶
- Va = <BitProperty.Va: 48>¶
- VirtualSize = <BitProperty.VirtualSize: 77>¶
- Volume = <BitProperty.Volume: 34>¶
- VolumeIndex = <BitProperty.VolumeIndex: 80>¶
- VolumeName = <BitProperty.VolumeName: 59>¶
- Warning = <BitProperty.Warning: 73>¶
- WarningFlags = <BitProperty.WarningFlags: 72>¶
- ZerosTailIsAllowed = <BitProperty.ZerosTailIsAllowed: 86>¶
- property name¶
- property value¶
- class pybit7z.BitStringCompressor¶
Bases:
BitAbstractArchiveCreator
- compress_file(*args, **kwargs)¶
Overloaded function.
compress_file(self: pybit7z._core.BitStringCompressor, in_file: str, out_file: str, input_name: str = ‘’) -> None
Compresses the given file to the chosen archive.
- Parameters:
in_file – the input file to be compressed.
out_file – the path (relative or absolute) to the output archive file.
input_name – the name of the input file in the archive (optional).
compress_file(self: pybit7z._core.BitStringCompressor, in_file: str, input_name: str = ‘’) -> bytes
Compresses the given file to a memory buffer.
- Parameters:
in_file – the input file to be compressed.
input_name – the name of the input file in the archive (optional).
- class pybit7z.BitStringExtractor¶
Bases:
BitAbstractArchiveOpener
- extract(*args, **kwargs)¶
Overloaded function.
extract(self: pybit7z._core.BitStringExtractor, in_archive: str, out_dir: str) -> None
Extracts the given archive to the chosen directory.
extract(self: pybit7z._core.BitStringExtractor, in_archive: str, index: int) -> bytes
Extracts the specified item from the given archive to a memory buffer.
extract(self: pybit7z._core.BitStringExtractor, in_archive: str) -> dict[str, bytes]
Extracts all the items from the given archive to a dictionary of memory buffers.
- extract_items(self: pybit7z._core.BitStringExtractor, 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.
- extract_matching(*args, **kwargs)¶
Overloaded function.
extract_matching(self: pybit7z._core.BitStringExtractor, in_archive: str, pattern: str, out_dir: str = ‘’, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> None
Extracts the files in the archive that match the given wildcard pattern to the chosen directory. :param in_archive: the input archive to be extracted. :param pattern: the wildcard pattern to be used for matching the files. :param out_dir: the directory where to extract the matching files. :param policy: the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
extract_matching(self: pybit7z._core.BitStringExtractor, in_archive: str, pattern: str, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> bytes
Extracts to the output buffer the first file in the archive matching the given wildcard pattern.
- Parameters:
in_archive – the input archive to extract from.
pattern – the wildcard pattern to be used for matching the files.
policy – the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
- extract_matching_regex(*args, **kwargs)¶
Overloaded function.
extract_matching_regex(self: pybit7z._core.BitStringExtractor, in_archive: str, regex: str, out_dir: str, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> None
Extracts the files in the archive that match the given regex pattern to the chosen directory.
- Parameters:
in_archive – the input archive to extract from.
regex – the regex pattern to be used for matching the files.
out_dir – the output directory where the extracted files will be placed.
policy – the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
extract_matching_regex(self: pybit7z._core.BitStringExtractor, in_archive: str, regex: str, policy: pybit7z._core.FilterPolicy = FilterPolicy.Include) -> bytes
Extracts to the output buffer the first file in the archive matching the given regex pattern.
- Parameters:
in_archive – the input archive to extract from.
regex – the regex pattern to be used for matching the files.
policy – the filtering policy to be applied to the matched items. Default is FilterPolicy.Include.
- test(self: pybit7z._core.BitStringExtractor, in_archive: str) 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.
- class pybit7z.DeletePolicy¶
Bases:
pybind11_object
Delete policy for archive items.
Members:
ItemOnly
RecurseDirs
- ItemOnly = <DeletePolicy.ItemOnly: 0>¶
- RecurseDirs = <DeletePolicy.RecurseDirs: 1>¶
- property name¶
- property value¶
- class pybit7z.FilterPolicy¶
Bases:
pybind11_object
Members:
Include : Extract/compress the items that match the pattern.
Exclude : Do not extract/compress the items that match the pattern.
- Exclude = <FilterPolicy.Exclude: 1>¶
- Include = <FilterPolicy.Include: 0>¶
- property name¶
- property value¶
- class pybit7z.FormatFeatures¶
Bases:
pybind11_object
Features of a format supported by bit7z
Members:
MultipleFiles : Archive supports multiple files.
SolidArchive : Archive supports solid mode.
CompressionLevel : Archive supports compression level.
Encryption : Archive supports encryption.
HeaderEncryption : Archive supports encrypted headers.
MultipleMethods : Archive supports multiple compression methods.
- CompressionLevel = <FormatFeatures.CompressionLevel: 4>¶
- Encryption = <FormatFeatures.Encryption: 8>¶
- HeaderEncryption = <FormatFeatures.HeaderEncryption: 16>¶
- MultipleFiles = <FormatFeatures.MultipleFiles: 1>¶
- MultipleMethods = <FormatFeatures.MultipleMethods: 32>¶
- SolidArchive = <FormatFeatures.SolidArchive: 2>¶
- property name¶
- property value¶
- class pybit7z.OverwriteMode¶
Bases:
pybind11_object
Enumeration representing how a handler should deal when an output file already exists.
Members:
Nothing : The handler will throw an exception if the output file or buffer already exists.
Overwrite : The handler will overwrite the old file or buffer with the new one.
Skip : The handler will skip writing to the output file or buffer.
- Nothing = <OverwriteMode.Nothing: 0>¶
- Overwrite = <OverwriteMode.Overwrite: 1>¶
- Skip = <OverwriteMode.Skip: 2>¶
- property name¶
- property value¶
- class pybit7z.UpdateMode¶
Bases:
pybind11_object
Members:
Nothing
Append
Update
- Append = <UpdateMode.Append: 1>¶
- Nothing = <UpdateMode.Nothing: 0>¶
- Update = <UpdateMode.Update: 2>¶
- property name¶
- property value¶
- pybit7z.default_lib7zip()[source]¶
Get the default lib7zip library path under the package directory.
- Return type:
- Returns:
The default lib7zip library path.
- pybit7z.lib7zip_context(path='', larg_page_mode=True)[source]¶
A context manager to create a Bit7zLibrary instance.
- Parameters:
- Yields:
A Bit7zLibrary instance.
- Raises:
FileNotFoundError – If the lib7zip library is not found.
- Return type: