Class: QgsArchive

Manages zip/unzip operations for an archive.

Class Hierarchy

Inheritance diagram of qgis.core.QgsArchive

Subclasses

QgsProjectArchive

Allows managing the zip/unzip actions on project files.

class qgis.core.QgsArchive[source]

Bases: object

addFile(self, filename: str | None)[source]

Add a new file to this archive. During a zip action, this file will be part of the resulting zipped file.

Parameters:

filename (Optional[str]) – A file to add when zipping this archive

clear(self)[source]

Clear the current content of this archive and create a new temporary directory.

dir(self) str[source]

Returns the current temporary directory.

Return type:

str

exists(self) bool[source]

Returns True if the archive exists on the filesystem, False otherwise.

Added in version 3.20.

Return type:

bool

files(self) List[str][source]

Returns the list of files within this archive

Return type:

List[str]

removeFile(self, filename: str | None) bool[source]

Remove a file from this archive and from the filesystem.

Parameters:

filename (Optional[str]) – The path of the file to remove

Return type:

bool

Returns:

True if the file has been removed from the filesystem, False otherwise

virtual unzip(self, zipFilename: str | None) bool[source]

Clear the current content of this archive and unzip. Files are unzipped in the temporary directory.

Parameters:

zipFilename (Optional[str]) – The zip file to unzip

Return type:

bool

Returns:

True if unzip action is a success, False otherwise

zip(self, zipFilename: str | None) bool[source]

Zip the content of this archive

Parameters:

zipFilename (Optional[str]) – The name of the zip to generate

Return type:

bool

Returns:

False if something goes wrong, True otherwise