replacing imp (deprecated) with importlib
This commit is contained in:
parent
5569c9d8e1
commit
634339eac6
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import imp
|
import importlib
|
||||||
import errno
|
import errno
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import socket
|
import socket
|
||||||
|
@ -73,8 +73,9 @@ def from_file(file_path, silent=False):
|
||||||
:param file_path:
|
:param file_path:
|
||||||
:param silent:
|
:param silent:
|
||||||
"""
|
"""
|
||||||
d = imp.new_module("config")
|
module_spec = importlib.util.spec_from_file_location("config", file_path)
|
||||||
d.__file__ = file_path
|
d = importlib.util.module_from_spec(module_spec)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(file_path) as config_file:
|
with open(file_path) as config_file:
|
||||||
exec( # nosec: config file safe
|
exec( # nosec: config file safe
|
||||||
|
|
Loading…
Reference in New Issue