Skip to content

Commit

Permalink
feat(api): Replace imp with importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
pycook committed Feb 23, 2025
1 parent f24cb55 commit 47332ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmdb-api/api/lib/cmdb/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import unicode_literals

import imp
import importlib.util

import copy
import jinja2
Expand Down Expand Up @@ -198,11 +198,11 @@ def _compute_attr_value_from_script(script, ci_dict):

try:
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])

mod = imp.load_module(name, fp, path, desc)
spec = importlib.util.spec_from_file_location(name, path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)

if hasattr(mod, 'computed'):
return mod.computed()
Expand Down

0 comments on commit 47332ac

Please sign in to comment.