From 6c8593f82d5ca9d04a04f9fd4d25cea6bdead66f Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Mon, 4 Mar 2024 13:00:36 +0100 Subject: [PATCH] feat(tools): added boilerplate for internal tools * clean zip file generator for blender add-on releases * wip for example gltf file generator --- tools/internal_generate_example_gltf_files.py | 15 ++++++++++ tools/internal_generate_release_zips.py | 28 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tools/internal_generate_example_gltf_files.py create mode 100644 tools/internal_generate_release_zips.py diff --git a/tools/internal_generate_example_gltf_files.py b/tools/internal_generate_example_gltf_files.py new file mode 100644 index 0000000..13e70e2 --- /dev/null +++ b/tools/internal_generate_example_gltf_files.py @@ -0,0 +1,15 @@ +import bpy + +def generate_example_gltf_files(example_path): + auto_export_operator = bpy.ops.export_scenes.auto_gltf + stored_settings = bpy.data.texts[".gltf_auto_export_settings"] + print("export settings", stored_settings) + """auto_export_operator( + direct_mode=True, + export_output_folder="./models", + export_scene_settings=True, + export_blueprints=True, + export_legacy_mode=False, + export_animations=True + )""" + #clear && /home/ckaos/.local/bin/pytest --blender-executable /home/ckaos/tools/blender/blender-4.0.2-linux-x64/blender tests \ No newline at end of file diff --git a/tools/internal_generate_release_zips.py b/tools/internal_generate_release_zips.py new file mode 100644 index 0000000..b73bd71 --- /dev/null +++ b/tools/internal_generate_release_zips.py @@ -0,0 +1,28 @@ +import os +import zipfile + +ignore_list = ['.pytest_cache', '__pycache__'] + +def zipdir(path, ziph): + # ziph is zipfile handle + for root, dirs, files in os.walk(path): + # filter out invalid paths + root_path = os.path.normpath(root) + root_path = root_path.split(os.sep) + add_file = True + for sub_path in root_path: + if sub_path in ignore_list: + add_file = False + break + + if add_file: + for file in files: + ziph.write(os.path.join(root, file), + os.path.relpath(os.path.join(root, file), + os.path.join(path, '..'))) + +with zipfile.ZipFile("bevy_components.zip", mode="w") as archive: + zipdir('./bevy_components', archive) + +with zipfile.ZipFile("gltf_auto_export.zip", mode="w") as archive: + zipdir('./gltf_auto_export', archive) \ No newline at end of file