Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-27 01:41:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-27 01:43:13 +0300
commitc94604993b3e0bfbc733861e890aff18513e02b4 (patch)
treeda9d3905b34c92f0e03545f50fc2a3e3fe68a397
parent85bda1d3f7d20766561ef73c864a4a6872d93a23 (diff)
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.
-rwxr-xr-xio_scene_gltf2/__init__.py78
1 files changed, 35 insertions, 43 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index bf2aed21..a67b62f6 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -12,14 +12,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+bl_info = {
+ 'name': 'glTF 2.0 format',
+ 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen',
+ "version": (0, 0, 1),
+ 'blender': (2, 80, 0),
+ 'location': 'File > Import-Export',
+ 'description': 'Import-Export as glTF 2.0',
+ 'warning': '',
+ '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',
+}
+
#
-# Imports
+# Script reloading (if the user calls 'Reload Scripts' from Blender)
#
-import importlib
-import os
-import time
-from pathlib import Path
+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,
@@ -31,43 +59,6 @@ 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',
- "version": (0, 0, 1),
- 'blender': (2, 80, 0),
- 'location': 'File > Import-Export',
- 'description': 'Import-Export as glTF 2.0',
- 'warning': '',
- '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'}
-
-
#
# 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)
-