ZipArchive
This class provides functionality for managing and extracting ZIP archive files by extending the BaseArchive interface. It supports listing archive contents, extracting files to a specified path while preserving directory structures, and maintaining file permissions. The class handles leading directory normalization and ensures all necessary parent directories are created during the extraction process.
Attributes
| Attribute | Type | Description |
|---|---|---|
| _archive | zipfile.ZipFile | The underlying zipfile.ZipFile instance used to manage the archive's contents and metadata. |
Constructor
Signature
def ZipArchive(
file: Any
)
Parameters
| Name | Type | Description |
|---|---|---|
| file | Any | The file-like object or path to the zip archive to be opened. |
Signature
def ZipArchive(
file: str | file-like object
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| file | `str | file-like object` |
Methods
list()
@classmethod
def list(
*args: any,
**kwargs: any
) - > null
Prints a table of contents for the zip archive to sys.stdout.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Positional arguments passed directly to the underlying zipfile.printdir method |
| **kwargs | any | Keyword arguments passed directly to the underlying zipfile.printdir method |
Returns
| Type | Description |
|---|---|
null | None |
extract()
@classmethod
def extract(
to_path: str
) - > null
Extracts all members of the archive to the specified destination path while preserving file permissions and handling leading directories.
Parameters
| Name | Type | Description |
|---|---|---|
| to_path | str | The local filesystem directory where the archive contents should be extracted |
Returns
| Type | Description |
|---|---|
null | None |
close()
@classmethod
def close() - > null
Closes the underlying zip archive file handle to release system resources.
Returns
| Type | Description |
|---|---|
null | None |