We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a52f395 commit ef2fb81Copy full SHA for ef2fb81
nikola/state.py
@@ -51,22 +51,26 @@ def __init__(self, path):
51
52
def get(self, key):
53
"""Get data stored in key."""
54
- if os.path.isfile(path):
55
- with open(path) as inf:
56
- self.data = json.load(inf)
57
return self.data.get(key)
58
59
def set(self, key, value):
60
"""Store value in key."""
+ self._read()
61
self.data[key] = value
62
self._save()
63
64
def delete(self, key):
65
"""Delete key and the value it contains."""
66
if key in self.data:
67
self.data.pop(key)
68
69
+ def _read(self)
70
+ if os.path.isfile(self._path):
71
+ with open(self._path) as inf:
72
+ self.data = json.load(inf)
73
+
74
def _save(self):
75
tpath = self._path + '.tmp'
76
with open(tpath, 'w') as outf:
0 commit comments