mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Monkeytype pylib/anki/stdmodels.py
This commit is contained in:
parent
ad90af3c37
commit
b83e44b688
1 changed files with 9 additions and 8 deletions
|
@ -1,8 +1,9 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from typing import Any, Callable, List, Tuple, Union
|
from typing import Any, Callable, List, Optional, Tuple, Union
|
||||||
|
|
||||||
|
from anki.collection import _Collection
|
||||||
from anki.consts import MODEL_CLOZE
|
from anki.consts import MODEL_CLOZE
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from anki.models import NoteType
|
from anki.models import NoteType
|
||||||
|
@ -13,7 +14,7 @@ models: List[Tuple[Union[Callable[[], str], str], Callable[[Any], NoteType]]] =
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
def _newBasicModel(col, name=None) -> NoteType:
|
def _newBasicModel(col: _Collection, name: Optional[str] = None) -> NoteType:
|
||||||
mm = col.models
|
mm = col.models
|
||||||
m = mm.new(name or _("Basic"))
|
m = mm.new(name or _("Basic"))
|
||||||
fm = mm.newField(_("Front"))
|
fm = mm.newField(_("Front"))
|
||||||
|
@ -27,7 +28,7 @@ def _newBasicModel(col, name=None) -> NoteType:
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
def addBasicModel(col) -> NoteType:
|
def addBasicModel(col: _Collection) -> NoteType:
|
||||||
m = _newBasicModel(col)
|
m = _newBasicModel(col)
|
||||||
col.models.add(m)
|
col.models.add(m)
|
||||||
return m
|
return m
|
||||||
|
@ -39,7 +40,7 @@ models.append((lambda: _("Basic"), addBasicModel))
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
def addBasicTypingModel(col) -> NoteType:
|
def addBasicTypingModel(col: _Collection) -> NoteType:
|
||||||
mm = col.models
|
mm = col.models
|
||||||
m = _newBasicModel(col, _("Basic (type in the answer)"))
|
m = _newBasicModel(col, _("Basic (type in the answer)"))
|
||||||
t = m["tmpls"][0]
|
t = m["tmpls"][0]
|
||||||
|
@ -55,7 +56,7 @@ models.append((lambda: _("Basic (type in the answer)"), addBasicTypingModel))
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
def _newForwardReverse(col, name=None) -> NoteType:
|
def _newForwardReverse(col: _Collection, name: Optional[str] = None) -> NoteType:
|
||||||
mm = col.models
|
mm = col.models
|
||||||
m = _newBasicModel(col, name or _("Basic (and reversed card)"))
|
m = _newBasicModel(col, name or _("Basic (and reversed card)"))
|
||||||
t = mm.newTemplate(_("Card 2"))
|
t = mm.newTemplate(_("Card 2"))
|
||||||
|
@ -65,7 +66,7 @@ def _newForwardReverse(col, name=None) -> NoteType:
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
def addForwardReverse(col) -> NoteType:
|
def addForwardReverse(col: _Collection) -> NoteType:
|
||||||
m = _newForwardReverse(col)
|
m = _newForwardReverse(col)
|
||||||
col.models.add(m)
|
col.models.add(m)
|
||||||
return m
|
return m
|
||||||
|
@ -77,7 +78,7 @@ models.append((lambda: _("Basic (and reversed card)"), addForwardReverse))
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
def addForwardOptionalReverse(col) -> NoteType:
|
def addForwardOptionalReverse(col: _Collection) -> NoteType:
|
||||||
mm = col.models
|
mm = col.models
|
||||||
m = _newForwardReverse(col, _("Basic (optional reversed card)"))
|
m = _newForwardReverse(col, _("Basic (optional reversed card)"))
|
||||||
av = _("Add Reverse")
|
av = _("Add Reverse")
|
||||||
|
@ -95,7 +96,7 @@ models.append((lambda: _("Basic (optional reversed card)"), addForwardOptionalRe
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
def addClozeModel(col) -> NoteType:
|
def addClozeModel(col: _Collection) -> NoteType:
|
||||||
mm = col.models
|
mm = col.models
|
||||||
m = mm.new(_("Cloze"))
|
m = mm.new(_("Cloze"))
|
||||||
m["type"] = MODEL_CLOZE
|
m["type"] = MODEL_CLOZE
|
||||||
|
|
Loading…
Reference in a new issue