[Bf-extensions-cvs] [2c8e2749] master: glTF: reload scripts enhancement
Julien Duroure
noreply at git.blender.org
Fri Feb 22 10:42:56 CET 2019
Commit: 2c8e27493ff0e3687a3275ce099a2f28e1c7982d
Author: Julien Duroure
Date: Fri Feb 22 10:42:38 2019 +0100
Branches: master
https://developer.blender.org/rBA2c8e27493ff0e3687a3275ce099a2f28e1c7982d
glTF: reload scripts enhancement
===================================================================
M io_scene_gltf2/__init__.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 9e41cf03..bf2aed21 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -16,20 +16,39 @@
# Imports
#
+import importlib
import os
import time
+from pathlib import Path
+
import bpy
+from bpy.props import (StringProperty,
+ BoolProperty,
+ EnumProperty,
+ IntProperty)
+from bpy.types import Operator
from bpy_extras.io_utils import ImportHelper, ExportHelper
-from bpy.types import Operator, AddonPreferences
from .io.com.gltf2_io_debug import Log
-from bpy.props import (CollectionProperty,
- StringProperty,
- BoolProperty,
- EnumProperty,
- FloatProperty,
- IntProperty)
+
+#
+# Script reloading (if the user calls 'Reload Scripts' from Blender)
+#
+
+def reload_recursive(current_dir: Path, module_dict):
+ for path in current_dir.iterdir():
+ if "__init__" in str(path) or path.stem not in module_dict:
+ continue
+
+ if path.is_file() and path.suffix == ".py":
+ importlib.reload(module_dict[path.stem])
+ elif path.is_dir():
+ reload_recursive(path, module_dict[path.stem].__dict__)
+
+
+directory = Path(__file__).parent
+reload_recursive(directory, locals())
#
# Globals
More information about the Bf-extensions-cvs
mailing list