Package pyamf :: Package util :: Module imports :: Class ModuleFinder |
[hide private]
[frames] | no frames]

# Class ModuleFinder

source code

This is a special module finder object that executes a collection of callables when a specific module has been imported. An instance of this is placed in `sys.meta_path`, which is consulted before `sys.modules` - allowing us to provide this functionality.

See Also: when_imported

Since: 0.5

Instance Methods | [hide private]
find_module(self, name, path) Called when an import is made. | source code
load_module(self, name) If we get this far, then there are hooks waiting to be called on import of this module. | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__init__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### find_module(self, name, path) | source code
Called when an import is made. If there are hooks waiting for this module to be imported then we stop the normal import process and manually load the module. Parameters: `name` - The name of the module being imported. @param path The root path of the module (if a package). We ignore this. Returns: If we want to hook this module, we return a `loader` interface (which is this instance again). If not we return `None` to allow the standard import process to continue.

### load_module(self, name) | source code
If we get this far, then there are hooks waiting to be called on import of this module. We manually load the module and then run the hooks. Parameters: `name` - The name of the module to import.