zulip_bots: Import imp.load_source for Python < 3.5.
This commit is contained in:
parent
ea105ffec5
commit
3e1d9b17a4
|
@ -10,8 +10,6 @@ from types import ModuleType
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from os.path import basename, splitext
|
from os.path import basename, splitext
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from zulip_bots.lib import run_message_handler_for_bot
|
from zulip_bots.lib import run_message_handler_for_bot
|
||||||
from zulip_bots.provision import provision_bot
|
from zulip_bots.provision import provision_bot
|
||||||
|
|
||||||
|
@ -21,7 +19,9 @@ def import_module_from_source(path, name=None):
|
||||||
if not name:
|
if not name:
|
||||||
name = splitext(basename(path))[0]
|
name = splitext(basename(path))[0]
|
||||||
|
|
||||||
if six.PY2:
|
# importlib.util.module_from_spec is supported from Python3.5
|
||||||
|
py_version = sys.version_info
|
||||||
|
if py_version.major < 3 or (py_version.major == 3 and py_version.minor < 5):
|
||||||
import imp
|
import imp
|
||||||
module = imp.load_source(name, path)
|
module = imp.load_source(name, path)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue