From 522297aa33ca59ee0e817e43732d37eb7df235e2 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Wed, 24 Jul 2024 22:08:46 -0600 Subject: [PATCH] Mods --- cromulant/manifest.json | 2 +- cromulant/storage.py | 18 ++++++++++++++---- cromulant/utils.py | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cromulant/manifest.json b/cromulant/manifest.json index 6a24118..02da25c 100644 --- a/cromulant/manifest.json +++ b/cromulant/manifest.json @@ -1,5 +1,5 @@ { - "version": "1.6.0", + "version": "1.7.0", "title": "Cromulant", "program": "cromulant", "author": "madprops", diff --git a/cromulant/storage.py b/cromulant/storage.py index 376cdb3..dec65fe 100644 --- a/cromulant/storage.py +++ b/cromulant/storage.py @@ -8,12 +8,18 @@ from .config import Config if TYPE_CHECKING: from .ants import Ant +from .utils import Utils + class Storage: @staticmethod def get_ants() -> Any: - with Config.ants_json.open() as file: - return json.load(file) + try: + with Config.ants_json.open() as file: + return json.load(file) + except Exception as e: + Utils.print(str(e)) + return [] @staticmethod def save_ants(ants: list[Ant]) -> None: @@ -29,8 +35,12 @@ class Storage: @staticmethod def get_settings() -> Any: - with Config.settings_json.open() as file: - return json.load(file) + try: + with Config.settings_json.open() as file: + return json.load(file) + except Exception as e: + Utils.print(str(e)) + return {} @staticmethod def save_settings(settings: dict[str, Any]) -> None: diff --git a/cromulant/utils.py b/cromulant/utils.py index e6166f6..ef2e300 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -10,7 +10,6 @@ from wonderwords import RandomWord, RandomSentence # type: ignore from fontTools.ttLib import TTFont # type: ignore from .config import Config -from .storage import Storage class Utils: @@ -21,6 +20,8 @@ class Utils: @staticmethod def prepare() -> None: + from .storage import Storage + Utils.names = Storage.get_names() Utils.countries = Storage.get_countries() Utils.rand_word = RandomWord()