-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
41 lines (34 loc) · 1.04 KB
/
data.py
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
# data provider (store variables, hardcode things and functions to get and set data)
from os.path import isfile
import pickle
import entity
from pubsub import pub
# Credentials
OAUTH_TOKEN=None
# Lists
MappackJson=None
TournamentJson=None
# data (singletons)
Sources=entity.Sources()
Jobs=entity.Jobs()
Settings=entity.Settings()
# Database of integers of ids
osudb_beatmap_ids=set()
osudb_beatmapset_ids=set()
# User toggles
cancel_jobs_toggle=False
def save_data():
with open("osu-assistant.data", 'wb') as f:
pickle.dump((OAUTH_TOKEN, Sources, Settings), f)
def load_data():
global OAUTH_TOKEN, Sources, Settings
if isfile("osu-assistant.data"):
try:
with open("osu-assistant.data", 'rb') as f:
OAUTH_TOKEN, Sources, Settings = pickle.load(f)
pub.sendMessage("update.sources")
except:
pub.sendMessage("show.dialog", msg="osu assistant data file is corrupted, please delete the osu-assistant.data file")
return True
else:
return False # first time