-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from toonarmycaptain/development
Implement Database object/refactoring. Refactor application to use `Database` object in `definitions.DATABASE` for all interactions with persistence. ### Added - Implement `Database` object to handle persistence - Implement `JSONDatabase(Database)` (original/current database backend). ### Changed - Refactor all code/calls dealing with persistence to `definitions.DATABASE`. - `Student.avatar_filename` changed to `Student.avatar_id` for naming consistency between database backends. This is ***backwards incompatible***, but is a simple string replace operation in any current data files. - `JSONDatabase`'s `Registry` now checks if on-disk version of registry is correct, only writing to it if incorrect or non-existent. - Increased test coverage, more tests converted to Pytest style tests. - When clicking 'x' instead of 'save as' when a chart is displayed, UI no longer freezes, nor pops up a 'save chart as' file dialogue. ### Removed - `class_registry_functions.py`, `test_class_registry_functions.py`: functionality moved to `Registry` object in `persistence/databases/json_registry.py`. ### Depreciated - Python 3.6 support ends with this release. - Python 3.7 support will soon be removed also, in next release following release of python 3.9 - plan is to only support 2 minor releases of python at one time. - `JSONDatabase` might be removed at some point, or not support new features, although it, or the data format might be kept for utility of debugging and editing. - `data_version_conversion.py` will not be supporting conversion from older formats than current to any future versions.
- Loading branch information
Showing
61 changed files
with
4,144 additions
and
3,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
""" | ||
definitions.py - source for vars used throughout application.None | ||
ROOT_DIR - path to directory containing app_main/definitions | ||
DEFAULT_DATABASE_BACKEND - the default database backend | ||
DATABASE - the database object. | ||
DEFAULT_CHART_SAVE_DIR - default user save folder for generated charts. | ||
For state-holding object eg DATABASE, must import definitions, then use | ||
dot access to use the object: | ||
import definitions | ||
definitions.DATABASE.do_stuff() | ||
""" | ||
import os | ||
|
||
from pathlib import Path | ||
from typing import List, Optional | ||
from typing import Optional, TYPE_CHECKING | ||
|
||
# Import to get around circular import caused by type checking. Type as string. | ||
if TYPE_CHECKING: | ||
from dionysus_app.persistence.database import Database # Line skipped from coverage. | ||
|
||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) # Global root directory. | ||
|
||
REGISTRY: Optional[List] = None | ||
DEFAULT_DATABASE_BACKEND = 'JSON' | ||
# Ignore typehint error: DATABASE object needs to be initialised with a value | ||
DATABASE: 'Database' = None # type: ignore | ||
|
||
|
||
DEFAULT_CHART_SAVE_FOLDER: Optional[Path] = None # Path object. | ||
DEFAULT_CHART_SAVE_DIR: Optional[Path] = None # Path object. |
Oops, something went wrong.