• Home
  • Raw
  • Download

Lines Matching +full:module +full:- +full:importer

2 :mod:`imputil` --- Import utilities
5 .. module:: imputil
10 The :mod:`imputil` module has been removed in Python 3.
15 This module provides a very handy and useful mechanism for custom
16 :keyword:`import` hooks. Compared to the older :mod:`ihooks` module,
17 :mod:`imputil` takes a dramatically simpler and more straight-forward
38 .. class:: Importer()
42 .. method:: Importer.import_top(name)
44 Import a top-level module.
46 .. method:: Importer.get_code(parent, modname, fqname)
48 Find and retrieve the code for the given module.
50 *parent* specifies a parent module to define a context for importing.
53 *modname* specifies a single module (not dotted) within the parent.
55 *fqname* specifies the fully-qualified module name. This is a
56 (potentially) dotted name from the "root" of the module namespace
61 This method should return ``None``, or a 3-tuple.
63 * If the module was not found, then ``None`` should be returned.
65 * The first item of the 2- or 3-tuple should be the integer 0 or 1,
66 specifying whether the module that was found is a package or not.
68 * The second item is the code object for the module (it will be
69 executed within the new module's namespace). This item can also
70 be a fully-loaded module object (e.g. loaded from a shared lib).
73 inserted into new module before the code object is executed. This
74 is provided in case the module's code expects certain values (such
75 as where the module was found). When the second item is a module
76 object, then these names/values will be inserted *after* the module
82 Emulate the import mechanism for built-in and frozen modules. This is a
83 sub-class of the :class:`Importer` class.
101 .. _examples-imputil:
104 --------
106 This is a re-implementation of hierarchical module import.
109 -- all you need to do to enable it is "import knee".
111 (The name is a pun on the clunkier predecessor of this module, "ni".)
163 raise ImportError("No module named " + qname)
174 raise ImportError("No module named " + mname)
192 raise ImportError("No module named " + subname)
214 def reload_hook(module):
215 name = module.__name__
233 module: knee
235 Also see the :mod:`importers` module (which can be found