From 6dcdffeea79c76436fccaad5b382af709af8c121 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 5 Apr 2024 10:12:17 +0200 Subject: Updated the code the be in the right place for the data model --- src/match_up/__init__.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/match_up/__init__.py') diff --git a/src/match_up/__init__.py b/src/match_up/__init__.py index c9c3d0b..2b1e42b 100644 --- a/src/match_up/__init__.py +++ b/src/match_up/__init__.py @@ -1,25 +1,25 @@ from pathlib import PurePath -from time import sleep -from match_up.model import PlayerDatabase -from match_up.tests import generate_test_database, remove_test_database +from match_up.model import PlaySession +from match_up.tests import ( + TEST_DATABASE_LOCATION, + generate_test_database, + activate_random_players, +) +DATABASE_LOCATION = "storage.json" -class PlaySession: - def __init__(self, database_location: PurePath): - self.data = PlayerDatabase(database_location) - def end(self): - self.data.close() - - def __del__(self): - self.end() +class Application: + def __init__(self, debug=False): + if debug: + database_location = TEST_DATABASE_LOCATION + else: + database_location = DATABASE_LOCATION + self.session = PlaySession(PurePath(database_location)) def main(): generate_test_database() - s = PlaySession(PurePath("test_storage.json")) - for player in s.data.get_players(): - print(player) - sleep(2) - s.end() - remove_test_database() + activate_random_players() + a = Application(debug=True) + print(a.session) -- cgit v1.3.1