import logging import sys from importlib import import_module class Cu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import logging
import sys
from importlib import import_module
class CustomImporter(object):
virtual_name = 'grab.tools'
def find_module(self, name, path=None):
if name.find(self.virtual_name) == 0:
logging.error('Module `grab.tools` is deprecated. '
'Use `weblib` module.')
return self
return None
def load_module(self, name):
name = name.split('.')
if len(name) == 3:
return import_module('weblib.control', 'weblib')
else:
return import_module('weblib')
sys.meta_path.append(CustomImporter())