Skip to content
Browse files
don't lose all the data if you write without a get
  • Loading branch information
ralsina committed Jan 6, 2016
1 parent a52f395 commit ef2fb8129af701bb8745c629a6d609fc19d006dc
Showing 1 changed file with 7 additions and 3 deletions.
@@ -51,22 +51,26 @@ def __init__(self, path):

def get(self, key):
"""Get data stored in key."""
if os.path.isfile(path):
with open(path) as inf: = json.load(inf)

def set(self, key, value):
"""Store value in key."""
self._read()[key] = value

def delete(self, key):
"""Delete key and the value it contains."""
if key in

def _read(self)
if os.path.isfile(self._path):
with open(self._path) as inf: = json.load(inf)

def _save(self):
tpath = self._path + '.tmp'
with open(tpath, 'w') as outf:

0 comments on commit ef2fb81

Please sign in to comment.