-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
69 lines (58 loc) · 2.18 KB
/
__init__.py
File metadata and controls
69 lines (58 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from pathlib import Path
# Add the addon directory to sys.path so that subpackage imports like
# `from core.errors import ...` resolve correctly regardless of how Blender
# namespaces the extension (e.g. bl_ext.vscode_development.Addon_Blender_Restival).
_addon_dir = str(Path(__file__).resolve().parent)
if _addon_dir not in sys.path:
sys.path.insert(0, _addon_dir)
def _purge_addon_modules() -> None:
"""Remove all addon submodule entries from sys.modules.
Called before auto_load.init() so that a Blender addon reload (F8 or
disable/enable) picks up the current source files rather than returning
stale cached modules.
"""
to_remove = [
name for name, mod in sys.modules.items()
if hasattr(mod, "__file__")
and mod.__file__ is not None
and mod.__file__.startswith(_addon_dir)
and name != __name__
]
for name in to_remove:
del sys.modules[name]
bl_info = {
"name": "Restival",
"author": "Kursad Karatas",
"description": "Embedded REST API server for querying Blender scene data",
"blender": (4, 2, 0),
"version": (0, 1, 0),
"location": "View3D > Sidebar > Restival",
"warning": "",
"category": "System",
}
try:
from . import auto_load
_AUTO_LOAD_AVAILABLE = True
except Exception: # outside Blender (unit tests)
_AUTO_LOAD_AVAILABLE = False
def register():
if _AUTO_LOAD_AVAILABLE:
_purge_addon_modules()
auto_load.init()
auto_load.register()
def unregister():
if _AUTO_LOAD_AVAILABLE:
auto_load.unregister()