diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-02-22 12:42:38 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-02-22 12:42:38 +0300 |
commit | 2c8e27493ff0e3687a3275ce099a2f28e1c7982d (patch) | |
tree | b31bade98ea8a9a5f2bc16fc9032b70904b52d59 | |
parent | 0852abc7a99457032e3aeb3328da9d0ad48cdfa9 (diff) |
glTF: reload scripts enhancement
-rwxr-xr-x | io_scene_gltf2/__init__.py | 33 |
1 files changed, 26 insertions, 7 deletions
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 |