2
Plain Python definition of some miscellaneous builtin functions.
6
def find_module(fullname, path):
8
meta_path = sys.meta_path
10
loader = hook.find_module(fullname, path)
13
if path != None and type(path) == str:
15
# XXX Check for frozen modules ?
19
path_hooks = sys.path_hooks
20
importer_cache = sys.path_importer_cache
23
if importer_cache.get(p,None):
24
importer = importer_cache.get(p)
26
importer_cache[p] = None
27
for hook in path_hooks:
35
importer_cache[p] = importer
37
loader = importer.find_module(fullname)
40
#no hooks match - do normal import
44
The module must have been successfully imported before."""
45
import imp, sys, errno
47
if type(module) not in (type(imp), type(errno)):
48
raise TypeError("reload() argument must be module")
50
name = module.__name__
51
if module is not sys.modules[name]:
52
raise ImportError("reload(): module %.200s not in sys.modules" % name)
54
namepath = name.split('.')
55
subname = namepath[-1]
56
parent_name = '.'.join(namepath[:-1])
61
parent = sys.modules[parent_name]
63
raise ImportError("reload(): parent %.200s not in sys.modules" %
65
path = parent.__path__
66
loader = find_module(name, path)
68
mod = loader.load_module(name)
72
f, filename, description = imp.find_module(subname, path)
74
new_module = imp.load_module(name, f, filename, description)
76
sys.modules[name] = module