Cleanup: replace deprecated imp -> importlib
This commit is contained in:
@@ -267,11 +267,11 @@ def enable(module_name, default_set=True, persistent=False, handle_error=None):
|
||||
mtime_orig = getattr(mod, "__time__", 0)
|
||||
mtime_new = os.path.getmtime(mod.__file__)
|
||||
if mtime_orig != mtime_new:
|
||||
import imp
|
||||
import importlib
|
||||
print("module changed on disk:", mod.__file__, "reloading...")
|
||||
|
||||
try:
|
||||
imp.reload(mod)
|
||||
importlib.reload(mod)
|
||||
except:
|
||||
handle_error()
|
||||
del sys.modules[module_name]
|
||||
@@ -384,10 +384,10 @@ def reset_all(reload_scripts=False):
|
||||
|
||||
# first check if reload is needed before changing state.
|
||||
if reload_scripts:
|
||||
import imp
|
||||
import importlib
|
||||
mod = sys.modules.get(mod_name)
|
||||
if mod:
|
||||
imp.reload(mod)
|
||||
importlib.reload(mod)
|
||||
|
||||
if is_enabled == is_loaded:
|
||||
pass
|
||||
|
||||
@@ -185,7 +185,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
|
||||
traceback.print_exc()
|
||||
|
||||
def test_reload(mod):
|
||||
import imp
|
||||
import importlib
|
||||
# reloading this causes internal errors
|
||||
# because the classes from this module are stored internally
|
||||
# possibly to refresh internal references too but for now, best not to.
|
||||
@@ -193,7 +193,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
|
||||
return mod
|
||||
|
||||
try:
|
||||
return imp.reload(mod)
|
||||
return importlib.reload(mod)
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
# <pep8 compliant>
|
||||
|
||||
if "bpy" in locals():
|
||||
from imp import reload as _reload
|
||||
from importlib import reload
|
||||
for val in _modules_loaded.values():
|
||||
_reload(val)
|
||||
reload(val)
|
||||
del reload
|
||||
_modules = [
|
||||
"add_mesh_torus",
|
||||
"anim",
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
# <pep8-80 compliant>
|
||||
|
||||
if "bpy" in locals():
|
||||
import imp
|
||||
from importlib import reload
|
||||
if "anim_utils" in locals():
|
||||
imp.reload(anim_utils)
|
||||
reload(anim_utils)
|
||||
del reload
|
||||
|
||||
|
||||
import bpy
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
# note, properties_animviz is a helper module only.
|
||||
|
||||
if "bpy" in locals():
|
||||
from imp import reload as _reload
|
||||
from importlib import reload
|
||||
for val in _modules_loaded.values():
|
||||
_reload(val)
|
||||
reload(val)
|
||||
del reload
|
||||
_modules = [
|
||||
"properties_animviz",
|
||||
"properties_constraint",
|
||||
|
||||
Reference in New Issue
Block a user