1 | | A more generic solution would be to use an import hook. As a reminder an import hook is called only if the normal import machinery has failed to locate a module and would otherwise throw an !ImportError. The import hook can look at what module was being requested, determine if that module is provided on the Toolshed, and if it is inform the user that they need to install a particular bundle to carry out their requested operation, bring up the bundle's Toolshed page in the help browser, and raise !CancelOperation to stop the current code execution. If the module isn't provided by the Toolshed, just carry on and raise ImportError. |
| 1 | A more generic solution would be to use an import hook. As a reminder an import hook is called only if the normal import machinery has failed to locate a module and would otherwise throw an !ImportError. The import hook can look at what module was being requested, determine if that module is provided on the Toolshed, and if it is inform the user that they need to install a particular bundle to carry out their requested operation, bring up the bundle's Toolshed page in the help browser, and raise !CancelOperation to stop the current code execution. If the module isn't provided by the Toolshed, just carry on and raise !ImportError. |