misc: use importlib to load (auquotidien) extension module (#46991)
This commit is contained in:
parent
c97a3e4fc2
commit
4051a3e013
|
@ -24,7 +24,7 @@ from django.utils.six.moves import cPickle
|
|||
from django.utils.six.moves.urllib import parse as urllib
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
import imp
|
||||
import importlib
|
||||
import inspect
|
||||
import os
|
||||
import fcntl
|
||||
|
@ -706,13 +706,12 @@ class QommonPublisher(Publisher, object):
|
|||
if not filename.endswith('.py'):
|
||||
continue
|
||||
modulename = filename[:-3]
|
||||
fp, pathname, description = imp.find_module(modulename, [extra_dir])
|
||||
spec = importlib.util.spec_from_file_location(modulename, os.path.join(extra_dir, filename))
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
try:
|
||||
imp.load_module(modulename, fp, pathname, description)
|
||||
spec.loader.exec_module(module)
|
||||
except Exception as e:
|
||||
print('failed to load extra module: %s (%s)' % (modulename, e), file=sys.stderr)
|
||||
if fp:
|
||||
fp.close()
|
||||
|
||||
translation_domains = None
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue