summaryrefslogtreecommitdiff
path: root/src/manage_saves.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/manage_saves.py')
-rw-r--r--src/manage_saves.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/manage_saves.py b/src/manage_saves.py
index 44ce2a3..2730a5d 100644
--- a/src/manage_saves.py
+++ b/src/manage_saves.py
@@ -1,19 +1,44 @@
from rich import print
-from theme import Theme
import json
-def save_theme(hex_colors, hex_compliments, wallpaper_location, save_location):
+import os
+
+class Theme:
+ def __init__(self, colors, comp_colors, wallpaper, name):
+ self.colors = colors
+ self.comp_colors = comp_colors
+ self.wallpaper = wallpaper
+ self.name = name
+ def toDict(self):
+ return {
+ "name" : self.name,
+ "colors" : self.colors,
+ "comp_colors": self.comp_colors,
+ "wallpaper" : self.wallpaper,
+ }
+
+
+def getAllThemes(theme_dir):
+ themes = []
+ themes_in_dir = [file for file in os.listdir(theme_dir) if os.path.isfile(os.path.join(theme_dir, file)) and file.endswith('.theme')]
+
+ for file in themes_in_dir:
+ theme_location = theme_dir + file
+ themes.append(load_theme(theme_location))
+ return themes
+
+
+def save_theme(hex_colors, hex_compliments, wallpaper_location, save_location, theme_name):
"""
Save a theme to the disk at a specified location as a json object.
"""
-
- theme = Theme(hex_colors, hex_compliments, wallpaper_location)
-
+ theme = Theme(hex_colors, hex_compliments, wallpaper_location, theme_name)
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
@@ -21,3 +46,4 @@ def load_theme(save_location):
with open(save_location, 'r') as file:
data = json.loads(file.read())
return data
+