-
-
Notifications
You must be signed in to change notification settings - Fork 716
Split addonHandler module #17797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split addonHandler module #17797
Conversation
Split addon handling code into separate modules: - AddonBase.py - Base classes AddonBase and AddonError - AddonBundle.py - Bundle class for handling addon packages - AddonManifest.py - Manifest class and manifest handling This improves code organization by: - Separating concerns into logical modules - Reducing complexity of __init__.py No functional changes, only code reorganization.
Move the Addon class from addonHandler/__init__.py into its own module (addon.py) to improve code organization and readability. Also move AddonStateCategory enum and state management from addonStore/models/status.py to addonHandler/addonState.py where it more logically belongs. This is a refactoring change that: - Reduces the size of addonHandler/__init__.py by extracting Addon class - Places addon state management closer to the addon code - Improves overall code modularity and organization
Tests cover bundle initialization, validation, extraction, and creation from directories, including various error handling scenarios. Both mocked and real file tests ensure proper functionality with different file types and path formats.
@ctoth is this PR ready for review? |
@@ -0,0 +1,121 @@ | |||
# A part of NonVisual Desktop Access (NVDA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use lowerCamelCase for file names i.e. addonBundle
@@ -0,0 +1,160 @@ | |||
# A part of NonVisual Desktop Access (NVDA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use lowerCamelCase for file names i.e. addonManifest
|
||
configspec = ConfigObj( | ||
StringIO( | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we perhaps move this to a separate ini file that is read from at run time?
@@ -0,0 +1,575 @@ | |||
# A part of NonVisual Desktop Access (NVDA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this file has not been fully reviewed - however the rest of this PR has been
|
||
def __repr__(self) -> str: | ||
return f"{self.__class__.__name__} ({self.name!r} at path {self.path!r}, running={self.isRunning!r})" | ||
def getCodeAddon(obj=None, frameDist=1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add type hints
log.warning("Error loading manifest:\n%s", manifest.errors) | ||
|
||
|
||
class AddonManifest(ConfigObj): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this appears to be an API breaking change, it's missing from __all__
return minRequiredVersion <= lastTested | ||
|
||
|
||
def validate_apiVersionString(value: str) -> Tuple[int, int, int]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this appears to be an API breaking change, it's missing from __all__
return addonAPIVersion.getAPIVersionTupleFromString(value) | ||
except ValueError as e: | ||
raise ValidateError('"{}" is not a valid API Version string: {}'.format(value, e)) | ||
__all__ = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually verified that addon functionality still works correctly
Can you confirm how you tested this? did you check the diff of dir(addonHandler)
from the NVDA python console?
See test results for failed build of commit 8a56a26377 |
@ctoth - do you intend to work on this still? |
@ctoth - closing this as abandoned. Feel free to open a new PR if you wish to continue to make these changes |
Link to issue number:
N/A - Code organization improvement
Summary of the issue:
The addonHandler module was overly large with all functionality in init.py, making it difficult to maintain and understand. This PR reorganizes the code into smaller, more focused modules while preserving the same functionality, and adds tests for the AddonBundle component.
Description of user facing changes
None. This is a purely internal refactoring of the codebase with no user-facing changes.
Description of development approach
This PR splits the large
addonHandler/__init__.py
file into several logical modules:addonBase.py
- Contains base classes and common exceptionsaddon.py
- Contains the main Addon class implementationAddonBundle.py
- Contains bundle-related functionalityAddonManifest.py
- Contains manifest-related functionalityaddonState.py
- Manages the state of addons in NVDAThe PR focuses on maintaining functionality while improving code organization. The main additions are unit tests for the AddonBundle functionality, which previously lacked test coverage.
Testing strategy:
Known issues with pull request:
None
Code Review Checklist:
@coderabbitai summary