示例#1
0
    def addBasicCard(self, front: str, back: str, tags: List[str] = []):
        basicCard = self.generateCardOutline(model='Basic', tags=tags)
        basicCard['fields'] = {
            'Front': front,
            'Back': back
        }

        ankiApi.invoke('addNote', note=basicCard)
示例#2
0
    def generateCardOutline(self, model: str, tags: List[str] = []):
        if model not in ankiApi.invoke('modelNames'):
            raise Exception('card type does not yet exist')

        return {
            'deckName': self.title,
            'modelName': model,
            'options': {
                'allowDuplicate': False,
                'duplicateScope': 'deck'
            },
            'fields': {},
            'tags': tags,
        }
示例#3
0
 def addCustomCard(self, model: str, fields: Dict[str, str], tags: List[str] = []):
     customCard = self.generateCardOutline(model=model, tags=tags)
     for fieldName, fieldContent in fields.items():
         customCard['fields'][fieldName] = fieldContent
     
     ankiApi.invoke('addNote', note=customCard)
示例#4
0
 def create(self):
     ankiApi.invoke('createDeck', deck=self.title)
示例#5
0
    def __init__(self, title: str):
        self.title = title

        # If deck doesn't exist, make it
        if self.title not in ankiApi.invoke('deckNames'):
            self.create()