-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
configuration.py
164 lines (125 loc) · 4.14 KB
/
configuration.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
from aqt import mw
tag = mw.addonManager.addonFromModule(__name__)
EASY_DATES = "easy_dates"
DAYS_TO_RESCHEDULE = "days_to_reschedule"
AUTO_RESCHEDULE_AFTER_SYNC = "auto_reschedule_after_sync"
AUTO_DISPERSE_AFTER_SYNC = "auto_disperse_after_sync"
AUTO_DISPERSE_WHEN_REVIEW = "auto_disperse_when_review"
AUTO_DISPERSE_AFTER_RESCHEDULE = "auto_disperse_after_reschedule"
MATURE_IVL = "mature_ivl"
RESCHEDULE_THRESHOLD = "reschedule_threshold"
DEBUG_NOTIFY = "debug_notify"
FSRS_STATS = "fsrs_stats"
DISPLAY_MEMORY_STATE = "display_memory_state"
HAS_RATED = "has_rated"
HAS_SPONSORED = "has_sponsored"
SHOW_STEPS_STATS = "show_steps_stats"
def load_config():
return mw.addonManager.getConfig(tag)
def save_config(data):
mw.addonManager.writeConfig(tag, data)
def run_on_configuration_change(function):
mw.addonManager.setConfigUpdatedAction(__name__, lambda *_: function())
class Config:
def load(self):
self.data = load_config()
def save(self):
save_config(self.data)
@property
def easy_dates(self) -> list[str]:
return self.data[EASY_DATES]
@easy_dates.setter
def easy_dates(self, value):
self.data[EASY_DATES] = value
self.save()
@property
def days_to_reschedule(self):
return self.data[DAYS_TO_RESCHEDULE]
@days_to_reschedule.setter
def days_to_reschedule(self, value):
self.data[DAYS_TO_RESCHEDULE] = value
self.save()
@property
def auto_reschedule_after_sync(self):
return self.data[AUTO_RESCHEDULE_AFTER_SYNC]
@auto_reschedule_after_sync.setter
def auto_reschedule_after_sync(self, value):
self.data[AUTO_RESCHEDULE_AFTER_SYNC] = value
self.save()
@property
def auto_disperse_after_sync(self):
return self.data[AUTO_DISPERSE_AFTER_SYNC]
@auto_disperse_after_sync.setter
def auto_disperse_after_sync(self, value):
self.data[AUTO_DISPERSE_AFTER_SYNC] = value
self.save()
@property
def auto_disperse_when_review(self):
return self.data[AUTO_DISPERSE_WHEN_REVIEW]
@auto_disperse_when_review.setter
def auto_disperse_when_review(self, value):
self.data[AUTO_DISPERSE_WHEN_REVIEW] = value
self.save()
@property
def auto_disperse_after_reschedule(self):
return self.data[AUTO_DISPERSE_AFTER_RESCHEDULE]
@auto_disperse_after_reschedule.setter
def auto_disperse_after_reschedule(self, value):
self.data[AUTO_DISPERSE_AFTER_RESCHEDULE] = value
self.save()
@property
def mature_ivl(self):
return self.data[MATURE_IVL]
@mature_ivl.setter
def mature_ivl(self, value):
self.data[MATURE_IVL] = value
self.save()
@property
def reschedule_threshold(self):
return self.data[RESCHEDULE_THRESHOLD]
@reschedule_threshold.setter
def reschedule_threshold(self, value):
self.data[RESCHEDULE_THRESHOLD] = value
self.save()
@property
def debug_notify(self):
return self.data[DEBUG_NOTIFY]
@debug_notify.setter
def debug_notify(self, value):
self.data[DEBUG_NOTIFY] = value
self.save()
@property
def fsrs_stats(self):
return self.data[FSRS_STATS]
@fsrs_stats.setter
def fsrs_stats(self, value):
self.data[FSRS_STATS] = value
self.save()
@property
def display_memory_state(self):
return self.data[DISPLAY_MEMORY_STATE]
@display_memory_state.setter
def display_memory_state(self, value):
self.data[DISPLAY_MEMORY_STATE] = value
self.save()
@property
def has_rated(self):
return self.data[HAS_RATED]
@has_rated.setter
def has_rated(self, value):
self.data[HAS_RATED] = value
self.save()
@property
def has_sponsored(self):
return self.data[HAS_SPONSORED]
@has_sponsored.setter
def has_sponsored(self, value):
self.data[HAS_SPONSORED] = value
self.save()
@property
def show_steps_stats(self):
return self.data[SHOW_STEPS_STATS]
@show_steps_stats.setter
def show_steps_stats(self, value):
self.data[SHOW_STEPS_STATS] = value
self.save()