File tree Expand file tree Collapse file tree 1 file changed +18
-25
lines changed Expand file tree Collapse file tree 1 file changed +18
-25
lines changed Original file line number Diff line number Diff line change 31
31
32
32
logger = logging .getLogger ("openscap" )
33
33
34
- from sys import version_info
35
- if version_info >= (2 , 6 , 0 ):
36
- def _import_helper ():
37
- from os .path import dirname
38
- import imp
39
- fp = None
40
- try :
41
- fp , pathname , description = imp .find_module (
42
- '_openscap_py' , [dirname (__file__ )])
43
- except ImportError :
44
- import _openscap_py as OSCAP
45
- return OSCAP
46
- if fp is not None :
47
- try :
48
- _mod = imp .load_module (
49
- '_openscap_py' , fp , pathname , description )
50
- finally :
51
- fp .close ()
52
- return _mod
53
- OSCAP = _import_helper ()
54
- del _import_helper
55
- else :
56
- import _openscap_py as OSCAP
57
-
58
- del version_info
34
+
35
+ def _import_helper ():
36
+ from os .path import dirname
37
+ import importlib .machinery
38
+ import importlib .util
39
+ spec = importlib .machinery .PathFinder .find_spec ('_openscap_py' , [dirname (__file__ )])
40
+ if not spec :
41
+ spec = importlib .machinery .PathFinder .find_spec ('_openscap_py' )
42
+ if not spec :
43
+ raise ImportError ("Unable to import _openscap_py module, extra path: '%s'."
44
+ % dirname (__file__ ))
45
+ mod = importlib .util .module_from_spec (spec )
46
+ spec .loader .exec_module (mod )
47
+ return mod
48
+
49
+
50
+ OSCAP = _import_helper ()
51
+ del _import_helper
59
52
60
53
import os
61
54
You can’t perform that action at this time.
0 commit comments