From: Neil Date: Sat, 10 Sep 2016 20:52:01 +0000 (+0200) Subject: Add simple save method X-Git-Tag: tabakrolletjie-v1.0.0~39^2 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=dd276546e6cb28189c9e2516624ca600b906b082;p=tabakrolletjie.git Add simple save method --- 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)