Seagull is a toolset to uncage information. To put an eye in the sky that guides us through the maze of bureaucracy and over the mountains of paperwork. To give us the wings to fly and eyes to see the truth.
This pull request introduces significant refactoring to the settings management system. The key changes are as follows:
Code Refactoring:
Merged redundant imports
Moved hardcoded paths to use os.path.join for better portability
Introduced global SETTINGS dictionary to hold settings in memory.
Added type hints for readability.
Encapsulated private methods and constants for better code organization.
Error Handling:
Created SettingsNotFoundError to handle cases where settings are not initialized properly.
Improved error handling during file operations, including JSON-specific errors.
Functionality Enhancements:
Added init_settings() method to initialize settings from JSON file.
Added _dump_settings() method to save the current state of SETTINGS to the JSON file.
Modified/renamed update_setting() and read_setting() methods to interact with global SETTINGS dictionary.
NOTE: init_settings() should only be called once, please ask for details on best usage, if unsure.
Licensing and Documentation:
Added the GPL license to top of file.
Included docstrings for all methods to explain purpose and usage.
Added a note about how we should handle settings within the project.
Issues Addressed
Resolves issue #66: Settings Refinement
How to Test:
Run the script to ensure the settings are being properly loaded and saved.
Modify a setting and verify the changes are being reflected in the JSON file.
Ensure appropriate error messages are displayed when the settings file is missing or corrupted.
Code Sample
if __name__ == "__main__":
init_settings()
print(read_settings("showtc")
update_setting("showtc", False)
print(read_settings("showtc")
Additional Notes
Future improvements could include moving the custom class into a dedicated exceptions file and integrating a logging library for better error tracking (noted in comments).
Fixed requirements.txt, should be able to simply run pip install -r requirements.txt
Updated settings usage in other files front.py and orca.py
Pull Request: Refactor Settings Management (#66)
Description
This pull request introduces significant refactoring to the settings management system. The key changes are as follows:
os.path.join
for better portabilitySETTINGS
dictionary to hold settings in memory.SettingsNotFoundError
to handle cases where settings are not initialized properly.init_settings()
method to initialize settings from JSON file._dump_settings()
method to save the current state ofSETTINGS
to the JSON file.update_setting()
andread_setting()
methods to interact with globalSETTINGS
dictionary.init_settings()
should only be called once, please ask for details on best usage, if unsure.Issues Addressed
How to Test:
Ensure appropriate error messages are displayed when the settings file is missing or corrupted.
Code Sample
Additional Notes
Future improvements could include moving the custom class into a dedicated exceptions file and integrating a logging library for better error tracking (noted in comments).
requirements.txt
, should be able to simply runpip install -r requirements.txt
front.py
andorca.py
setings
tosettings