Data Integrator (Python API)
|
Import hook module finder. More...
Public Member Functions | |
def | find_module (s, fullName, path=None) |
Only loads real Python source code modules. More... | |
Import hook module finder.
The import hook mechanism has been introduced with Python 2.3a1 and is described in detail in PEP 302. This module makes use of import hooks in a simplified matter, as it will only import Python modules in their pure source code, that is, file like @c spam.py, but not files like @c spam.pyc, @c spam.pyo, or @c spam.so. For a given (dotted, but not relative) module name, we search for the corresponding Python .py source file in all directories of the search path, @c sys.path, ignoring if we are asked to search specific directories only. If the file is found and readable, its information will be transferred to a common.ImportHook.CLoader object, which in turn is returned. If the file has not been found, @c None will be returned, as required by the import hook API. We underline here that this mechanism is by no means a replacement of the Python import scheme, but an extension. In addition to its default import handling, Python will use this code here first. If we indicate that we have not found anything, Python will try its default ways to import the requested module. But one needs to be aware that this hook is always called, for each import.
def common.ImportHook.CImporter.find_module | ( | s, | |
fullName, | |||
path = None |
|||
) |
Only loads real Python source code modules.
No packages, no shared objects, no byte compiled files are loaded here. This could be a bit of a performance decrease, as .pyc/.pyo files are not handled here. @param Dotted (but not relative) module name. @param path @c List of directory names to search or @c None, which indicates we should search all paths in @c sys.path. In case of duplicated package names, we are given the first path encountered. In order to successfully resolve the import statement, we need to scan all paths in @c sys.paths. @return @c None, we have not found anything; common.ImportHook.CLoader object, we have found the Python file.