:tocdepth: 3 :py:mod:`gws.lib.zipx` ====================== .. py:module:: gws.lib.zipx .. autoapi-nested-parse:: Zipfile wrappers. **Source code:** :source:`gws.lib.zipx` Package Contents ---------------- .. py:exception:: Error Bases: :py:obj:`gws.Error` GWS error. .. py:function:: unzip_bytes(source: bytes, target_dir: str, flat: bool = False) -> int Unpack a zip archive in memory into a directory. :param source: Path to the zip archive. :param target_dir: Path to the target directory. :param flat: If ``True`` omit path and consider only base name of files in the zip archive, else complete paths are considered of files in the zip archive. Default is ``False``. :returns: The amount of unzipped files. .. py:function:: unzip_bytes_to_dict(source: bytes, flat: bool = False) -> dict Unpack a zip archive in memory into a dict. :param source: Path to zip archive. :param flat: If ``True`` then the dictionary contains the base names of the unzipped files, else it contains the whole path. Default is ``False``. :returns: A dictionary containing all the file paths or base names. .. py:function:: unzip_path(path: str, target_dir: str, flat: bool = False) -> int Unpack a zip archive into a directory. :param path: Path to the zip archive. :param target_dir: Path to the target directory. :param flat: If ``True`` omit path and consider only base name of files in the zip archive, else complete paths are considered of files in the zip archive. Default is ``False``. :returns: The amount of unzipped files. .. py:function:: unzip_path_to_dict(path: str, flat: bool = False) -> dict Unpack a zip archive into a dict. :param path: Path to the zip archive. :param flat: If ``True`` then the dictionary contains the base names of the unzipped files, else it contains the whole path. Default is ``False``. :returns: A dictionary containing all the file paths or base names. .. py:function:: zip_to_bytes(*sources, flat: bool = False) -> bytes Create a zip archive in memory. :param sources: Paths or dicts to zip. :param flat: If ``True`` only base names will be returned, else the whole paths will be returned. Default is ``False``. :returns: The names of the file paths encoded in bytes. .. py:function:: zip_to_path(path: str, *sources, flat: bool = False) -> int Create a zip archive in a file. :param path: Path to the zip archive. :param sources: Paths or dicts to zip. :param flat: If ``True`` base names are being kept in zip archive, else whole paths are being kept in zip archive. Default is ``False`` :returns: The amount of files in the zip archive.