-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuserdataclass.py
More file actions
27 lines (21 loc) · 761 Bytes
/
Copy pathuserdataclass.py
File metadata and controls
27 lines (21 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
class jsondata:
# user database file location
datafile = "data/userdata.json"
def writedata(self, dictionary):
with open(self.datafile, "w") as datafile:
json.dump(dictionary, datafile)
def getdata(self):
with open(self.datafile, "r") as datafile:
data = json.load(datafile)
return data
def getdatapath(self):
with open(self.datafile, "r") as datafile:
data = json.load(datafile)
return data['datapath']
def setdatapath(self, path):
with open(self.datafile, "r") as datafile:
data = json.load(datafile)
data['datapath'] = path
with open(self.datafile, "w") as datafile:
json.dump(data, datafile)