mirror of
https://github.com/veops/cmdb.git
synced 2025-09-27 16:29:19 +08:00
feat(api): Replace imp with importlib
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import imp
|
import importlib.util
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import jinja2
|
import jinja2
|
||||||
@@ -198,11 +198,11 @@ class AttributeValueManager(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
path = script_f.name
|
path = script_f.name
|
||||||
dir_name, name = os.path.dirname(path), os.path.basename(path)[:-3]
|
name = os.path.basename(path)[:-3]
|
||||||
|
|
||||||
fp, path, desc = imp.find_module(name, [dir_name])
|
spec = importlib.util.spec_from_file_location(name, path)
|
||||||
|
mod = importlib.util.module_from_spec(spec)
|
||||||
mod = imp.load_module(name, fp, path, desc)
|
spec.loader.exec_module(mod)
|
||||||
|
|
||||||
if hasattr(mod, 'computed'):
|
if hasattr(mod, 'computed'):
|
||||||
return mod.computed()
|
return mod.computed()
|
||||||
|
Reference in New Issue
Block a user