dweet fix again

This commit is contained in:
Senad Uka
2016-06-08 10:01:55 +02:00
parent e0e0f0d24c
commit 533135013b
49 changed files with 2885 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
import json
import os.path
class File(object):
"Holds controller state in the file"
def __init__(self, filename=None):
self.filename = filename
def present(self):
os.path.isfile(self.filename)
def load(self):
if self.filename is None:
raise ClassNotReadyException("Filename not set!")
with open(self.filename) as input_file:
self.data = json.load(input_file)
def save(self):
if self.filename is None:
raise ClassNotReadyException("Filename not set!")
if self.data is None:
raise ClassNotReadyException("Data not loaded!")
with open(self.filename, 'w') as out_file:
json.dump(self.data, out_file)