summaryrefslogtreecommitdiff
path: root/src/manage_saves.py
diff options
context:
space:
mode:
authorChandler J <cjustice2000@gmail.com>2024-04-12 20:54:20 -0600
committerGitHub <noreply@github.com>2024-04-12 20:54:20 -0600
commitc5937854ff01ba29da48b7b0560ef27faad00d53 (patch)
treee8fc9dc0bb690cc1976a47fe1166f4bafcafcb40 /src/manage_saves.py
parent2564189a769a5bd3de63086bb62dc3532d1b07b9 (diff)
parent8a1903bb16d9e04795c33f3eb226486d06e8a642 (diff)
Merge pull request #2 from chandlerj/saves
major changes: save states & refactoring
Diffstat (limited to 'src/manage_saves.py')
-rw-r--r--src/manage_saves.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/manage_saves.py b/src/manage_saves.py
index 1ada559..44ce2a3 100644
--- a/src/manage_saves.py
+++ b/src/manage_saves.py
@@ -1,21 +1,23 @@
-import pickle
from rich import print
-
-def save_color_palette(hex_colors, hex_compliments, save_directory):
+from theme import Theme
+import json
+def save_theme(hex_colors, hex_compliments, wallpaper_location, save_location):
+ """
+ Save a theme to the disk at a specified location as a json object.
+ """
- colors = (hex_colors, hex_compliments)
- with open(save_directory, 'wb') as file:
- pickle.dump(colors, file, pickle.HIGHEST_PROTOCOL)
-
- print('[bold green]color palette saved successfully')
+ theme = Theme(hex_colors, hex_compliments, wallpaper_location)
-def load_color_palette(save_location):
- with open(save_location, 'rb') as file:
- try:
- data = pickle.load(file)
- except:
- print('invalid arguments. -p should be followed by a color palette save')
- exit(2)
+ with open(save_location, 'w') as file:
+ json.dump(theme.toDict(), file)
+ print('[bold green]color palette saved successfully')
+
+def load_theme(save_location):
+ """
+ Load a theme from disk at a specified location
+ """
+ with open(save_location, 'r') as file:
+ data = json.loads(file.read())
return data