nvda
9b538f4d - Improve flexibility of appModules discovery by allowing to map arbitrary appModule to a given executable. (#13366)

Commit
4 years ago
Improve flexibility of appModules discovery by allowing to map arbitrary appModule to a given executable. (#13366) Related to #13364 Summary of the issue: Currently when NVDA tries to load an appModule for a given program it just looks for a Python module of the same name as the program's executable. This has its limitations in particular: Some names are incompatible with the Python's import system (for example see App module handler: handle executable names with dots as part of the file name #5323 where we resorted to replacing dots with underscores before attempting the import). When a single apModule should be used for a multiple executable's we need as many appModules as there are executable's (this also often causes linter failures as these alias modules just star imports everything from the main module). Even if the given module name does not contain symbols which are incompatible with importlib they may contain characters which are invalid in ordinary import statements (for one example see Fix crashes in 64-bit builds of Notepad++ 8.3 and later #13364 where the apModule is called "notepad++"). Since "+" is invalid in Python's import statement add-on developers cannot import this module from nvdaBuiltin which means that it cannot be extended in an add-on. Description of how this pull request fixes the issue: This PR introduces a mapping of executable names to appModules which is consulted before the given module is imported. It also adds a convenience functions for add-on developers which can be used to register or unregister a specific module for a given program. All alias apModules currently present in the source are marked as deprecated and application's for which they were loaded are mapped to the right appModule using the new map. Since we cannot remove the old alias app modules care has been taken not to use them - they' re kept only for add-ons developers.
Author
Parents
Loading