equal
deleted
inserted
replaced
24 import logging |
24 import logging |
25 import os |
25 import os |
26 import pickle |
26 import pickle |
27 import pkgutil |
27 import pkgutil |
28 import sys |
28 import sys |
|
29 import types |
29 import warnings |
30 import warnings |
30 import zlib |
31 import zlib |
31 |
32 |
32 from six import PY2, binary_type, text_type |
33 from six import PY2, binary_type, text_type |
33 from six.moves import builtins |
34 from six.moves import builtins |
292 if not any(isinstance(x, cls) for x in sys.meta_path): |
293 if not any(isinstance(x, cls) for x in sys.meta_path): |
293 self = cls() |
294 self = cls() |
294 sys.meta_path.append(self) |
295 sys.meta_path.append(self) |
295 |
296 |
296 def find_module(self, fullname, path=None): |
297 def find_module(self, fullname, path=None): |
297 if fullname.startswith('cubes.'): |
298 if fullname == 'cubes': |
|
299 return self |
|
300 elif fullname.startswith('cubes.'): |
298 modname = 'cubicweb_' + fullname.split('.', 1)[1] |
301 modname = 'cubicweb_' + fullname.split('.', 1)[1] |
299 try: |
302 try: |
300 modinfo = imp.find_module(modname) |
303 modinfo = imp.find_module(modname) |
301 except ImportError: |
304 except ImportError: |
302 return None |
305 return None |
303 else: |
306 else: |
304 return pkgutil.ImpLoader(fullname, *modinfo) |
307 return pkgutil.ImpLoader(fullname, *modinfo) |
|
308 |
|
309 def load_module(self, fullname): |
|
310 if fullname != 'cubes': |
|
311 raise ImportError('No module named {0}'.format(fullname)) |
|
312 mod = sys.modules[fullname] = types.ModuleType(fullname, doc='CubicWeb cubes') |
|
313 return mod |