Class: QgsArchive

class qgis.core.QgsArchive

Bases: sip.wrapper

Class allowing to manage the zip/unzip actions

New in version 3.0.

QgsArchive() Constructor

QgsArchive(other: QgsArchive) Copy constructor

Methods

addFile

Add a new file to this archive.

clear

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

dir

Returns the current temporary directory.

exists

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

files

Returns the list of files within this archive

removeFile

Remove a file from this archive and from the filesystem.

unzip

Clear the current content of this archive and unzip.

zip

Zip the content of this archive

addFile(self, filename: str)

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

Parameters

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

clear(self)

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

dir(self) str

Returns the current temporary directory.

Return type

str

exists(self) bool

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

New in version 3.20.

Return type

bool

files(self) List[str]

Returns the list of files within this archive

Return type

List[str]

removeFile(self, filename: str) bool

Remove a file from this archive and from the filesystem.

Parameters

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

Return type

bool

Returns

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

unzip(self, zipFilename: str) bool

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

Parameters

zipFilename (str) – The zip file to unzip

Return type

bool

Returns

True if unzip action is a success, False otherwise

zip(self, zipFilename: str) bool

Zip the content of this archive

Parameters

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

Return type

bool

Returns

False if something goes wrong, True otherwise