io_scene_gltf2: don't reload package on startup
package reloading should only ever be done on reload, also move `bl_info` to the top of the file for faster parsing and avoid importing `Path` since it's only needed for reloading.
This commit is contained in:
parent
85bda1d3f7
commit
c94604993b
|
@ -12,48 +12,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#
|
||||
# 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 .io.com.gltf2_io_debug import Log
|
||||
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
bl_info = {
|
||||
'name': 'glTF 2.0 format',
|
||||
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen',
|
||||
|
@ -65,8 +23,41 @@ bl_info = {
|
|||
'wiki_url': "https://docs.blender.org/manual/en/dev/addons/io_gltf2.html",
|
||||
'tracker_url': "https://github.com/KhronosGroup/glTF-Blender-IO/issues/",
|
||||
'support': 'OFFICIAL',
|
||||
'category': 'Import-Export'}
|
||||
'category': 'Import-Export',
|
||||
}
|
||||
|
||||
#
|
||||
# Script reloading (if the user calls 'Reload Scripts' from Blender)
|
||||
#
|
||||
|
||||
def reload_package(module_dict_main):
|
||||
import importlib
|
||||
from pathlib import Path
|
||||
def reload_package_recursive(current_dir, 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_package_recursive(path, module_dict[path.stem].__dict__)
|
||||
|
||||
reload_package_recursive(Path(__file__).parent, module_dict_main)
|
||||
|
||||
|
||||
if "bpy" in locals():
|
||||
reload_package(locals())
|
||||
|
||||
import bpy
|
||||
from bpy.props import (StringProperty,
|
||||
BoolProperty,
|
||||
EnumProperty,
|
||||
IntProperty)
|
||||
from bpy.types import Operator
|
||||
from bpy_extras.io_utils import ImportHelper, ExportHelper
|
||||
|
||||
from .io.com.gltf2_io_debug import Log
|
||||
|
||||
#
|
||||
# Functions / Classes.
|
||||
|
@ -294,6 +285,7 @@ class ExportGLTF2_Base:
|
|||
context.scene[self.scene_key] = export_props
|
||||
|
||||
def execute(self, context):
|
||||
import os
|
||||
import datetime
|
||||
from .blender.exp import gltf2_blender_export
|
||||
|
||||
|
@ -470,6 +462,7 @@ class ImportGLTF2(Operator, ImportHelper):
|
|||
return self.import_gltf2(context)
|
||||
|
||||
def import_gltf2(self, context):
|
||||
import time
|
||||
from .io.imp.gltf2_io_gltf import glTFImporter
|
||||
from .blender.imp.gltf2_blender_gltf import BlenderGlTF
|
||||
|
||||
|
@ -522,4 +515,3 @@ def unregister():
|
|||
# remove from the export / import menu
|
||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
||||
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
||||
|
||||
|
|
Loading…
Reference in New Issue