diff --git a/src/cloze_overlapper/config.py b/src/cloze_overlapper/config.py index 37f704a..0a35fae 100644 --- a/src/cloze_overlapper/config.py +++ b/src/cloze_overlapper/config.py @@ -37,7 +37,7 @@ print_function, unicode_literals) from aqt import mw -from anki.utils import stripHTML +from anki.utils import strip_html from .libaddon.anki.configmanager import ConfigManager @@ -48,7 +48,7 @@ def parseNoteSettings(html): """Return note settings. Fall back to defaults if necessary.""" options, settings, opts, sets = None, None, None, None dflt_set, dflt_opt = config["synced"]["dflts"], config["synced"]["dflto"] - field = stripHTML(html) + field = strip_html(html) lines = field.replace(" ", "").split("|") if not lines: diff --git a/src/cloze_overlapper/editor.py b/src/cloze_overlapper/editor.py index ff25bff..cd72a60 100644 --- a/src/cloze_overlapper/editor.py +++ b/src/cloze_overlapper/editor.py @@ -187,12 +187,12 @@ def refreshEditor(editor): def onInsertCloze(self, _old): """Handles cloze-wraps when the add-on model is active""" - if not checkModel(self.note.model(), fields=False, notify=False): + if not checkModel(self.note.note_type(), fields=False, notify=False): return _old(self) # find the highest existing cloze highest = 0 for name, val in self.note.items(): - m = re.findall("\[\[oc(\d+)::", val) + m = re.findall(r"\[\[oc(\d+)::", val) if m: highest = max(highest, sorted([int(x) for x in m])[-1]) # reuse last? @@ -206,7 +206,7 @@ def onInsertCloze(self, _old): @editorSaveThen def onInsertMultipleClozes(self): """Wraps each line in a separate cloze""" - model = self.note.model() + model = self.note.note_type() # check that the model is set up for cloze deletion if not re.search('{{(.*:)*cloze:', model['tmpls'][0]['qfmt']): if self.addMode: @@ -218,10 +218,10 @@ def onInsertMultipleClozes(self): to a cloze type first, via Edit>Change Note Type.""") return if checkModel(model, fields=False, notify=False): - cloze_re = "\[\[oc(\d+)::" + cloze_re = r"\[\[oc(\d+)::" wrap_pre, wrap_post = "[[oc", "]]" else: - cloze_re = "\{\{c(\d+)::" + cloze_re = r"\{\{c(\d+)::" wrap_pre, wrap_post = "{{c", "}}" # find the highest existing cloze highest = 0 @@ -242,7 +242,7 @@ def onInsertMultipleClozes(self): @editorSaveThen def onRemoveClozes(self): """Remove cloze markers and hints from selected text""" - if checkModel(self.note.model(), fields=False, notify=False): + if checkModel(self.note.note_type(), fields=False, notify=False): cloze_re = r"\[\[oc(\d+)::(.*?)(::(.*?))?\]\]" else: cloze_re = r"\{\{c(\d+)::(.*?)(::(.*?))?\}\}" @@ -252,10 +252,10 @@ def onRemoveClozes(self): @editorSaveThen def onOlOptionsButton(self): """Invoke note-specific options dialog""" - if not checkModel(self.note.model()): + if not checkModel(self.note.note_type()): return False options = OlcOptionsNote(self.parentWindow) - options.exec_() + options.exec() @editorSaveThen diff --git a/src/cloze_overlapper/libaddon/platform.py b/src/cloze_overlapper/libaddon/platform.py index a48aec2..5dc014a 100644 --- a/src/cloze_overlapper/libaddon/platform.py +++ b/src/cloze_overlapper/libaddon/platform.py @@ -41,7 +41,7 @@ from aqt import mw from anki import version as anki_version -from anki.utils import isMac, isWin +from anki.utils import is_mac, is_win __all__ = ["PYTHON3", "ANKI20", "SYS_ENCODING", "MODULE_ADDON", "MODULE_LIBADDON", "DIRECTORY_ADDONS", "JSPY_BRIDGE", @@ -66,9 +66,9 @@ PATH_ADDON = os.path.join(DIRECTORY_ADDONS, MODULE_ADDON) PATH_USERFILES = os.path.join(PATH_ADDON, "user_files") -if isMac: +if is_mac: PLATFORM = "mac" -elif isWin: +elif is_win: PLATFORM = "win" else: PLATFORM = "lin" diff --git a/src/cloze_overlapper/overlapper.py b/src/cloze_overlapper/overlapper.py index f4a522d..bd4d350 100644 --- a/src/cloze_overlapper/overlapper.py +++ b/src/cloze_overlapper/overlapper.py @@ -59,7 +59,7 @@ class ClozeOverlapper(object): def __init__(self, note, markup=False, silent=False, parent=None): self.note = note - self.model = self.note.model() + self.model = self.note.note_type() self.flds = config["synced"]["flds"] self.markup = markup self.silent = silent diff --git a/src/cloze_overlapper/sched.py b/src/cloze_overlapper/sched.py index 81dc47a..8b769b8 100644 --- a/src/cloze_overlapper/sched.py +++ b/src/cloze_overlapper/sched.py @@ -46,7 +46,7 @@ from anki.schedv2 import Scheduler as SchedulerV2 SCHEDULERS = (SchedulerV1, SchedulerV2) -from anki.utils import ids2str, intTime +from anki.utils import ids2str, int_time from anki.hooks import wrap from aqt import mw @@ -104,7 +104,7 @@ def myBurySiblings(self, card, _old): self.col.db.execute( "update cards set queue=-2,mod=?,usn=? where id in " + ids2str(toBury), - intTime(), self.col.usn()) + int_time(), self.col.usn()) self.col.log(toBury) elif mw.col.schedVer() == 2: self.buryCards(toBury, manual=False) diff --git a/src/cloze_overlapper/template.py b/src/cloze_overlapper/template.py index 321a6bd..900c8a4 100644 --- a/src/cloze_overlapper/template.py +++ b/src/cloze_overlapper/template.py @@ -407,7 +407,7 @@ def addModel(col): def updateTemplate(col): """Update add-on card templates""" print("Updating %s card template".format(OLC_MODEL)) - model = col.models.byName(OLC_MODEL) + model = col.models.by_name(OLC_MODEL) template = model['tmpls'][0] template['qfmt'] = card_front template['afmt'] = card_back @@ -417,6 +417,6 @@ def updateTemplate(col): def initializeModels(): - model = mw.col.models.byName(OLC_MODEL) + model = mw.col.models.by_name(OLC_MODEL) if not model: model = addModel(mw.col)