Skip to content

Commit

Permalink
fix(file_management.py): add mode parameter to Compression.zip_file()…
Browse files Browse the repository at this point in the history
… function call

fix(file_management.py): add mode parameter to Compression.compress_folder() function call
  • Loading branch information
realSAH committed Jul 5, 2023
1 parent b599530 commit f549839
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions myresources/crocodile/file_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ def zip(self, path=None, folder=None, name=None, arcname=None, inplace=False, ve
with install_n_import("py7zr").SevenZipFile(file=path, mode=mode, password=pwd) as archive: archive.writeall(path=str(slf), arcname=None)
else:
if (arcname := P(arcname or slf.name)).name != slf.name: arcname /= slf.name # arcname has to start from somewhere and end with filename
if slf.is_file(): path = Compression.zip_file(ip_path=slf, op_path=path + f".zip" if path.suffix != ".zip" else path, arcname=arcname, **kwargs)
if slf.is_file(): path = Compression.zip_file(ip_path=slf, op_path=path + f".zip" if path.suffix != ".zip" else path, arcname=arcname, mode=mode, **kwargs)
else:
root_dir, base_dir = (slf, ".") if content else (slf.split(at=str(arcname[0]))[0], arcname)
path = Compression.compress_folder(root_dir=root_dir, op_path=path, base_dir=base_dir, fmt='zip', **kwargs)
path = Compression.compress_folder(root_dir=root_dir, op_path=path, base_dir=base_dir, fmt='zip', **kwargs) # TODO: see if this supports mode
return self._return(path, inlieu=False, inplace=inplace, operation="delete", orig=orig, verbose=verbose, msg=f"ZIPPED {repr(slf)} ==> {repr(path)}")
def unzip(self, folder=None, fname=None, verbose=True, content=False, inplace=False, overwrite=False, orig=False, pwd=None, tmp=False, pattern=None, merge=False, **kwargs) -> 'P':
if tmp: return self.unzip(folder=P.tmp().joinpath("tmp_unzips").joinpath(randstr()), content=True).joinpath(self.stem)
Expand Down

0 comments on commit f549839

Please sign in to comment.