From dd276546e6cb28189c9e2516624ca600b906b082 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 10 Sep 2016 22:52:01 +0200 Subject: [PATCH] Add simple save method --- tabakrolletjie/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tabakrolletjie/utils.py b/tabakrolletjie/utils.py index 6f9e133..19364c2 100644 --- a/tabakrolletjie/utils.py +++ b/tabakrolletjie/utils.py @@ -6,6 +6,7 @@ import pygame.surface import pygame.locals as pgl import os import sys +import json from .constants import DEBUG from .loader import loader @@ -92,3 +93,12 @@ def get_save_file_name(): def save_file_exists(): savefile = get_save_file_name() return os.path.isfile(savefile) + + +def write_save_file(json_data): + save_dir = save_location() + if not os.path.exists(save_dir): + os.makedirs(save_dir) + savefile = get_save_file_name() + with open(savefile, 'wb') as f: + json.dump(json_data, f, indent=3) -- 2.34.1