Class: QgsZipUtils

class qgis.core.QgsZipUtils

Bases: sip.simplewrapper

Methods

files

Returns the list of files within a zip file

isZipFile

Returns True if the file name is a zipped file ( i.e with a '.qgz' extension, False otherwise.

unzip

Unzip a zip file in an output directory.

zip

Zip the list of files in the zip file.

files(zip: str) List[str]

Returns the list of files within a zip file

New in version 3.30.

Parameters:

zip (str) –

Return type:

List[str]

isZipFile(filename: str) bool

Returns True if the file name is a zipped file ( i.e with a ‘.qgz’ extension, False otherwise.

Parameters:

filename (str) – The name of the file

Return type:

bool

Returns:

True if the file is zipped, False otherwise

unzip(zip: str, dir: str, checkConsistency: bool = True) Tuple[bool, List[str]]

Unzip a zip file in an output directory.

Parameters:
  • zip (str) – The zip filename

  • dir (str) – The output directory

  • checkConsistency (bool = True) – Perform additional stricter consistency checks on the archive, and error if they fail (since QGIS 3.30)

Return type:

Tuple[bool, List[str]]

Returns:

  • False if the zip filename does not exist, the output directory

  • files: The absolute path of unzipped files

does not exist or is not writable.

zip(zip: str, files: Iterable[str]) bool

Zip the list of files in the zip file. If the zip file already exists or is empty, an error is returned. If an input file does not exist, an error is also returned.

Parameters:
  • zip (str) – The zip filename

  • files (Iterable[str]) – The absolute path to files to embed within the zip

Return type:

bool