diff options
Diffstat (limited to 'src/manage_saves.py')
| -rw-r--r-- | src/manage_saves.py | 32 |
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 |
