Mesh: Workaround to load 3mf files not supported by zipios library

This commit is contained in:
wmayer
2024-08-17 19:36:04 +02:00
committed by wwmayer
parent 3595c301b7
commit 8f18cfaf3a
5 changed files with 73 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ set(EXT_FILES
sketcher.py
UiTools.py
utils.py
utils_zip.py
)
foreach (it ${EXT_FILES})

View File

@@ -0,0 +1,18 @@
# (c) 2024 Werner Mayer LGPL
__author__ = "Werner Mayer"
__url__ = "https://www.freecad.org"
__doc__ = "Helper module to convert zip files"
import zipfile
def rewrite(source: str, target: str):
source_zip = zipfile.ZipFile(source, "r")
target_zip = zipfile.ZipFile(target, "w")
for name in source_zip.namelist():
target_zip.writestr(name, source_zip.open(name).read())
source_zip.close()
target_zip.close()