##// END OF EJS Templates
use importlib.machinery when available...
MinRK -
Show More
@@ -17,12 +17,19 b' from __future__ import print_function'
17
17
18 # Stdlib imports
18 # Stdlib imports
19 import glob
19 import glob
20 import imp
21 import inspect
20 import inspect
22 import os
21 import os
23 import re
22 import re
24 import sys
23 import sys
25
24
25 try:
26 # Python 3
27 from importlib.machinery import all_suffixes
28 _suffixes = all_suffixes()
29 except ImportError:
30 from imp import get_suffixes
31 _suffixes = [ s[0] for s in get_suffixes() ]
32
26 # Third-party imports
33 # Third-party imports
27 from time import time
34 from time import time
28 from zipimport import zipimporter
35 from zipimport import zipimporter
@@ -51,7 +58,7 b' TIMEOUT_GIVEUP = 20'
51 import_re = re.compile(r'(?P<name>[a-zA-Z_][a-zA-Z0-9_]*?)'
58 import_re = re.compile(r'(?P<name>[a-zA-Z_][a-zA-Z0-9_]*?)'
52 r'(?P<package>[/\\]__init__)?'
59 r'(?P<package>[/\\]__init__)?'
53 r'(?P<suffix>%s)$' %
60 r'(?P<suffix>%s)$' %
54 r'|'.join(re.escape(s[0]) for s in imp.get_suffixes()))
61 r'|'.join(re.escape(s) for s in _suffixes))
55
62
56 # RE for the ipython %run command (python + ipython scripts)
63 # RE for the ipython %run command (python + ipython scripts)
57 magic_run_re = re.compile(r'.*(\.ipy|\.ipynb|\.py[w]?)$')
64 magic_run_re = re.compile(r'.*(\.ipy|\.ipynb|\.py[w]?)$')
General Comments 0
You need to be logged in to leave comments. Login now