-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
37 lines (27 loc) · 957 Bytes
/
config.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
from .player import Player
from aqt import mw
import datetime
config = mw.addonManager.getConfig(__name__)
def save_config_prop(prop, value):
config[prop] = value
mw.addonManager.writeConfig(__name__, config)
def get_config_prop(prop):
if prop in config:
return config[prop]
return None
def load_config_state():
resolved_config = {}
if "player" in config:
resolved_config["player"] = config["player"]
else:
resolved_config["player"] = Player().toJSON()
if "last_daily_check" in config and config["last_daily_check"] is not None:
resolved_config["last_daily_check"] = datetime.datetime.strptime(
config["last_daily_check"], "%Y-%m-%d")
else:
resolved_config["last_daily_check"] = None
if "first_loot" in config:
resolved_config["first_loot"] = config["first_loot"]
else:
resolved_config["first_loot"] = False
return resolved_config