def _find_module(self, name, path, parent=None):
"""
Get a 3-tuple detailing the physical location of the Python module with
the passed name if that module is found *or* raise `ImportError`
otherwise.
This high-level method wraps the low-level `modulegraph.find_module()`
function with additional support for graph-based module caching.
Parameters
----------
name : str
Fully-qualified name of the Python module to be found.
path : list
List of the absolute paths of all directories to search for this
module *or* `None` if the default path list `self.path` is to be
searched.
parent : Node
Optional parent module of this module if this module is a submodule
of another module *or* `None` if this module is a top-level module.
Returns
----------
(file_handle, filename, metadata)
See `modulegraph._find_module()` for details.
"""
if parent is not None:
# assert path is not None
fullname = parent.identifier + '.' + name
else:
fullname = name
node = self.findNode(fullname)
if node is not None:
self.msg(3, "find_module: already included?", node)
raise ImportError(name)
if path is None:
if name in sys.builtin_module_names:
return (None, None, ("", "", imp.C_BUILTIN))
path = self.path
return self._find_module_path(fullname, name, path)
评论列表
文章目录