save bytes content to a zip file then convert html to markdown
Type
Default
Details
output_folder
zip_bytes_content
bytes
None
bytes or bytearray
existing_zip_file_path
str
None
location of an existing zip file
is_unpack_archive
bool
True
Exported source
class UTIL_UpsertFolder_Error(dmde.DomoError):def__init__(self, message):super().__init__(message)def export_zip_binary_contents(output_folder, zip_bytes_content): output_folder = change_extension(output_folder, ".zip") upsert_folder(output_folder)withopen(output_folder, 'wb+') as f: f.write(zip_bytes_content)returnf"successfully downloaded to {output_folder}"def download_zip( output_folder, zip_bytes_content: bytes=None, # bytes or bytearray existing_zip_file_path: str=None, # location of an existing zip file is_unpack_archive: bool=True):"""save bytes content to a zip file then convert html to markdown""" output_folder = output_folder if output_folder.endswith("/") else output_folder +'/'ifnot is_unpack_archive:if zip_bytes_content:return export_zip_binary_contents(output_folder=output_folder, zip_bytes_content=zip_bytes_content)if os.path.exists(existing_zip_file_path): output_zip = os.path.join(output_folder,'archive.zip') shutil.copy(output_zip)returnf"zip available at {existing_zip_file_path}"zip=None upsert_folder(output_folder)if zip_bytes_content:zip= zipfile.ZipFile(io.BytesIO(zip_bytes_content), "r")if existing_zip_file_path:zip= zipfile.ZipFile(existing_zip_file_path)ifnotzip:raise UTIL_UpsertFolder_Error("unable to generate zip file pass zip_bytes_content or zip_file_path" )zip.extractall(output_folder)zip.close()return os.listdir(output_folder)