mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Add comment arg to make_compressed_archive
This is an optional arg that will add a comment to zip file
This commit is contained in:
parent
f3590ded0f
commit
d3b7ab048d
@ -93,10 +93,13 @@ class FileHelpers:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def make_compressed_archive(path_to_destination, path_to_zip):
|
def make_compressed_archive(path_to_destination, path_to_zip, comment=""):
|
||||||
# create a ZipFile object
|
# create a ZipFile object
|
||||||
path_to_destination += ".zip"
|
path_to_destination += ".zip"
|
||||||
with ZipFile(path_to_destination, "w", ZIP_DEFLATED) as zip_file:
|
with ZipFile(path_to_destination, "w", ZIP_DEFLATED) as zip_file:
|
||||||
|
zip_file.comment = bytes(
|
||||||
|
comment, "utf-8"
|
||||||
|
) # comments over 65535 bytes will be truncated
|
||||||
for root, _dirs, files in os.walk(path_to_zip, topdown=True):
|
for root, _dirs, files in os.walk(path_to_zip, topdown=True):
|
||||||
ziproot = path_to_zip
|
ziproot = path_to_zip
|
||||||
for file in files:
|
for file in files:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user