-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataBASS.py
More file actions
53 lines (42 loc) · 1.34 KB
/
dataBASS.py
File metadata and controls
53 lines (42 loc) · 1.34 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import json
import ENUM
from os import path
guessNumberGame = dict()
verify = dict()
contest = dict()
questions = list()
def saveFile():
temp = {"GNG" : guessNumberGame, "VER" : verify, "CON" : contest, "Q":questions}
jsonContent = json.dumps(temp)
with open(path.join(ENUM.PATH,"data.otog"),"w",encoding="utf-8") as f:
f.write(jsonContent)
def loadFile():
global guessNumberGame,verify,contest,questions
if path.exists(path.join(ENUM.PATH,"data.otog")):
with open(path.join(ENUM.PATH,"data.otog"),"r",encoding="utf-8") as f:
jsonContent = f.read()
try:
jsonContent = json.loads(jsonContent)
except:
print("Load : Can't convert file back :(")
return
if "GNG" in jsonContent:
guessNumberGame = jsonContent["GNG"]
else:
guessNumberGame = dict()
if "VER" in jsonContent:
verify = jsonContent["VER"]
else:
verify = dict()
if "CON" in jsonContent:
contest = jsonContent["CON"]
else:
contest = dict()
if "Q" in jsonContent:
questions = jsonContent["Q"]
else:
questions = list()
else:
print("data.otog not found...")
if __name__ == "__main__":
print(guessNumberGame)