jgdv.mixins.zipper

Classes

Zipper_m

Add methods for manipulating zip files.

Module Contents

class jgdv.mixins.zipper.Zipper_m[source]

Add methods for manipulating zip files. Can set a self.zip_root path, where added files with be relative to

_zip_get_compression_settings() <Unknown>[source]
Return type:

tuple[int, int]

zip_add_paths(fpath, *args) <Unknown>[source]
Add specific files to the zip.

Will Create the zip if it doesn’t exist

Parameters:
zip_add_str(fpath, fname, text) <Unknown>[source]

add a string of text to a zip file as a new file

Parameters:
zip_contains(zip, *names) <Unknown>[source]

test that a zip file contains multiple filenames

Parameters:
Return type:

bool

zip_create(fpath) <Unknown>[source]

Create a new zipfile. will overwrite an existing zip if ‘zip_overwrite’ is set

Parameters:

fpath (pathlib.Path)

zip_get_contents(fpath) <Unknown>[source]
Parameters:

fpath (pathlib.Path)

Return type:

list[str]

zip_globs(
fpath,
*globs,
ignore_dots=False,
) <Unknown>[source]

Add files chosen by globs to the zip, relative to the cwd

Parameters:
zip_set_root(fpath) <Unknown>[source]

set the filesystem that acts as the root for paths to be added to the zip file

Parameters:

fpath (pathlib.Path)

zip_test(*zips) <Unknown>[source]

Test the validity of zip files

Parameters:

zips (pathlib.Path)

zip_unzip_concat(
fpath,
*zips,
member=None,
header=b'\n\n#------\n\n',
footer=b'\n\n#------\n\n',
) <Unknown>[source]

Unzip a member file in a multiple zip files, append their text contents into a single file

Parameters:
zip_unzip_to(fpath, *zips, fn=None) <Unknown>[source]

extract everything or everything that returns true from fn, from all zips given into subdirs of fpath

Parameters:
_zip_compress_level: int = 4
_zip_compression: str = 'ZIP_DEFLATED'
zip_name: str = 'default'
zip_overwrite: bool = False
zip_root: jgdv.Maybe[pathlib.Path] = None