| | |
- DynLoadSuffixImporter
- ImportManager
- Importer
-
- BuiltinImporter
- _FilesystemImporter
class BuiltinImporter(Importer) |
| |
######################################################################
#
# Emulate the import mechanism for builtin and frozen modules |
| |
Methods defined here:
- get_code(self, parent, modname, fqname)
Data and non-method functions defined here:
- __doc__ = None
- __module__ = 'imputil'
Methods inherited from Importer:
- _do_import(self, parent, parts, fromlist)
- Attempt to import the module relative to parent.
This method is used when the import context specifies that <self>
imported the parent module.
- _finish_import(self, top, parts, fromlist)
- ######################################################################
#
# PRIVATE METHODS
- _import_fromlist(self, package, fromlist)
- Import any sub-modules in the "from" list.
- _import_one(self, parent, modname, fqname)
- Import a single module.
- _load_tail(self, m, parts)
- Import the rest of the modules, down from the top-level module.
Returns the last module in the dotted list of modules.
- _process_result(self, (ispkg, code, values), fqname)
- import_top(self, name)
- Import a top-level module.
|
class ImportManager |
| |
Manage the import process. |
| |
Methods defined here:
- __init__(self, fs_imp=None)
- _determine_import_context(self, globals)
- Returns the context in which a module should be imported.
The context could be a loaded (package) module and the imported module
will be looked for within that package. The context could also be None,
meaning there is no context -- the module should be looked for as a
"top-level" module.
- _import_hook(self, fqname, globals=None, locals=None, fromlist=None)
- Python calls this hook to locate and import a module.
- _import_top_module(self, name)
- _reload_hook(self, module)
- Python calls this hook to reload a module.
- add_suffix(self, suffix, importFunc)
- install(self, namespace={'ArithmeticError': <class exceptions.ArithmeticError>, 'AssertionError': <class exceptions.AssertionError>, 'AttributeError': <class exceptions.AttributeError>, 'DeprecationWarning': <class exceptions.DeprecationWarning>, 'EOFError': <class exceptions.EOFError>, 'Ellipsis': Ellipsis, 'EnvironmentError': <class exceptions.EnvironmentError>, 'Exception': <class exceptions.Exception>, 'FloatingPointError': <class exceptions.FloatingPointError>, 'IOError': <class exceptions.IOError>, ...})
- Install this ImportManager into the specified namespace.
- uninstall(self)
- Restore the previous import mechanism.
Data and non-method functions defined here:
- __doc__ = 'Manage the import process.'
- __module__ = 'imputil'
- clsFilesystemImporter = None
|
class Importer |
| |
Base class for replacing standard import functions. |
| |
Methods defined here:
- _do_import(self, parent, parts, fromlist)
- Attempt to import the module relative to parent.
This method is used when the import context specifies that <self>
imported the parent module.
- _finish_import(self, top, parts, fromlist)
- ######################################################################
#
# PRIVATE METHODS
- _import_fromlist(self, package, fromlist)
- Import any sub-modules in the "from" list.
- _import_one(self, parent, modname, fqname)
- Import a single module.
- _load_tail(self, m, parts)
- Import the rest of the modules, down from the top-level module.
Returns the last module in the dotted list of modules.
- _process_result(self, (ispkg, code, values), fqname)
- get_code(self, parent, modname, fqname)
- Find and retrieve the code for the given module.
parent specifies a parent module to define a context for importing. It
may be None, indicating no particular context for the search.
modname specifies a single module (not dotted) within the parent.
fqname specifies the fully-qualified module name. This is a
(potentially) dotted name from the "root" of the module namespace
down to the modname.
If there is no parent, then modname==fqname.
This method should return None, or a 3-tuple.
* If the module was not found, then None should be returned.
* The first item of the 2- or 3-tuple should be the integer 0 or 1,
specifying whether the module that was found is a package or not.
* The second item is the code object for the module (it will be
executed within the new module's namespace). This item can also
be a fully-loaded module object (e.g. loaded from a shared lib).
* The third item is a dictionary of name/value pairs that will be
inserted into new module before the code object is executed. This
is provided in case the module's code expects certain values (such
as where the module was found). When the second item is a module
object, then these names/values will be inserted *after* the module
has been loaded/initialized.
- import_top(self, name)
- Import a top-level module.
Data and non-method functions defined here:
- __doc__ = 'Base class for replacing standard import functions.'
- __module__ = 'imputil'
|
class _FilesystemImporter(Importer) |
| |
######################################################################
#
# Internal importer used for importing from the filesystem |
| |
Methods defined here:
- __init__(self)
- _import_pathname(self, pathname, fqname)
- add_suffix(self, suffix, importFunc)
- get_code(self, parent, modname, fqname)
- import_from_dir(self, dir, fqname)
Data and non-method functions defined here:
- __doc__ = None
- __module__ = 'imputil'
Methods inherited from Importer:
- _do_import(self, parent, parts, fromlist)
- Attempt to import the module relative to parent.
This method is used when the import context specifies that <self>
imported the parent module.
- _finish_import(self, top, parts, fromlist)
- ######################################################################
#
# PRIVATE METHODS
- _import_fromlist(self, package, fromlist)
- Import any sub-modules in the "from" list.
- _import_one(self, parent, modname, fqname)
- Import a single module.
- _load_tail(self, m, parts)
- Import the rest of the modules, down from the top-level module.
Returns the last module in the dotted list of modules.
- _process_result(self, (ispkg, code, values), fqname)
- import_top(self, name)
- Import a top-level module.
| |