include.base.import_hook module¶
-
class
include.base.import_hook.BaseIncludeLoader(module_prefix)¶ Bases:
objectImport hook to load Python modules from an arbitrary location
Parameters: module_prefix (str) – prefix for modules to import Base class for import hooks to non-standard code sources. Implements the general structure for encoded sources: a module source translates to an artificial module path of the form
<module_prefix>.<encoded_name>. Themodule_prefixidentifies the code source type (and import hook) while theencoded_namecontains all required information to retrieve the code.For example, a
module_prefixofinclude.type.filescould identify a source file type, and anencoded_nameofSLASHtmpSLASHfooDOTpypoint to the path/tmp/foo.py. The resulting module would appear asinclude.type.files.SLASHtmpSLASHfooDOTpy.Note that
module_prefixmust point to a valid package, not a module. It will be actually imported by the regular import machinery, and can be used to bootstrap hooks.The
encoded_nameis a free form field. The base class provides means to escape invalid and reserved symbols (/and.), but subclasses are free to use them if it is suitable for them. Hooks should useencoded_nameto store a URI (or similar) to retrieve source code. As per Python rules, including a dot (.) in theencoded_namerequires the hook to import each portion separately.-
find_module(fullname, path=None)¶ Find the appropriate loader for module
nameParameters:
-
load_module(name)¶ Load and return a module
Always returns the corresponding module. If the module is already loaded, the existing module is returned.
-
module2uri(module_name)¶ Convert an encoded module name to an unencoded source uri
-
module_prefix¶
-
uri2module(uri)¶ Convert an unencoded source uri to an encoded module name
-