diff options
| author | Chandler J <cjustice2000@gmail.com> | 2024-04-12 20:44:47 -0600 |
|---|---|---|
| committer | Chandler J <cjustice2000@gmail.com> | 2024-04-12 20:44:47 -0600 |
| commit | 95e73b141ca8f3618701ff59658ef519353cc7c0 (patch) | |
| tree | 27967d34376bc6ed624c12c758f580a712765118 /src/manage_saves.py | |
| parent | b7dc1316ab0eb51f408b2b7782571d868ad3b864 (diff) | |
major changes:
- Can now save/load themes which entails the color scheme and
wallpaper
- Can now use themes to load colors independent of background image
- refactoring to make code less bad
Diffstat (limited to 'src/manage_saves.py')
| -rw-r--r-- | src/manage_saves.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/manage_saves.py b/src/manage_saves.py index 988b9a2..f57f7b8 100644 --- a/src/manage_saves.py +++ b/src/manage_saves.py @@ -1,21 +1,21 @@ -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] + theme = Theme(hex_colors, hex_compliments, wallpaper_location) - with open(save_directory, 'wb') as file: - pickle.dump(colors, file, pickle.HIGHEST_PROTOCOL) - + with open(save_location, 'w') as file: + json.dump(theme.toDict(), file) print('[bold green]color palette saved successfully') -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) - +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 |
