summaryrefslogtreecommitdiff
path: root/.local/share/Anki2/addons21/Background_and_gear/config.py
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2022-08-04 09:50:48 +0300
committerThanos Apollo <[email protected]>2022-08-04 09:50:48 +0300
commit4ddb7273098bee179bb77e0937e560fc0100960c (patch)
treecebc2f9412e45910408a7885ca78d7dedb77de78 /.local/share/Anki2/addons21/Background_and_gear/config.py
parente83759ae9d0513024e390810ddcb18ffdd84675e (diff)
Add anki addons
Diffstat (limited to '.local/share/Anki2/addons21/Background_and_gear/config.py')
-rw-r--r--.local/share/Anki2/addons21/Background_and_gear/config.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/.local/share/Anki2/addons21/Background_and_gear/config.py b/.local/share/Anki2/addons21/Background_and_gear/config.py
new file mode 100644
index 0000000..da450d7
--- /dev/null
+++ b/.local/share/Anki2/addons21/Background_and_gear/config.py
@@ -0,0 +1,44 @@
+import os
+
+from aqt import mw
+
+
+addon_path = os.path.dirname(__file__)
+addonfoldername = os.path.basename(addon_path)
+
+
+def gc(arg="", fail=False):
+ conf = mw.addonManager.getConfig(__name__)
+ if conf:
+ if arg:
+ return conf.get(arg, fail)
+ else:
+ return conf
+ return fail
+
+
+userOption = None
+
+def _getUserOption(refresh):
+ global userOption
+ if userOption is None or refresh:
+ userOption = mw.addonManager.getConfig(__name__)
+
+
+def getUserOption(key=None, default=None, refresh=False):
+ _getUserOption(refresh)
+ if key is None:
+ return userOption
+ if key in userOption:
+ return userOption[key]
+ else:
+ return default
+
+
+def writeConfig(configToWrite=userOption):
+ mw.addonManager.writeConfig(__name__, configToWrite)
+
+
+def getDefaultConfig():
+ addon = __name__.split(".")[0]
+ return mw.addonManager.addonConfigDefaults(addon)