Add helpers

This commit is contained in:
Alex Yatskov 2021-07-18 10:31:47 -07:00
parent 4e41429165
commit 6a68046fee

View File

@ -84,3 +84,48 @@ def setting(key):
return aqt.mw.addonManager.getConfig(__name__).get(key, defaults[key]) return aqt.mw.addonManager.getConfig(__name__).get(key, defaults[key])
except: except:
raise Exception('setting {} not found'.format(key)) raise Exception('setting {} not found'.format(key))
#
# Anki Helpers
#
def window(self):
return aqt.mw
def reviewer():
return window().reviewer
def collection(self):
return window().col
def decks(self):
return collection().decks
def scheduler(self):
return collection().sched
def database(self):
return collection().db
def media(self):
return collection().media
def deckNames():
return decks().allNames()
class EditScope:
def __enter__(self):
window().requireReset()
def __exit__(self):
window().maybeReset()