Example #1
0
 def flush(self) -> None:
     self._bugcheck()
     hooks.card_will_flush(self)
     # mtime & usn are set by backend
     card = BackendCard(
         id=self.id,
         nid=self.nid,
         did=self.did,
         ord=self.ord,
         ctype=self.type,
         queue=self.queue,
         due=self.due,
         ivl=self.ivl,
         factor=self.factor,
         reps=self.reps,
         lapses=self.lapses,
         left=self.left,
         odue=self.odue,
         odid=self.odid,
         flags=self.flags,
         data=self.data,
     )
     if self.id != 0:
         self.col.backend.update_card(card)
     else:
         self.id = self.col.backend.add_card(card)
Example #2
0
 def flush(self) -> None:
     self._bugcheck()
     hooks.card_will_flush(self)
     # mtime & usn are set by backend
     card = BackendCard(
         id=self.id,
         note_id=self.nid,
         deck_id=self.did,
         template_idx=self.ord,
         ctype=self.type,
         queue=self.queue,
         due=self.due,
         interval=self.ivl,
         ease_factor=self.factor,
         reps=self.reps,
         lapses=self.lapses,
         remaining_steps=self.left,
         original_due=self.odue,
         original_deck_id=self.odid,
         flags=self.flags,
         data=self.data,
     )
     if self.id != 0:
         self.col.backend.update_card(card)
     else:
         self.id = self.col.backend.add_card(card)
Example #3
0
 def __init__(self, col: anki.storage._Collection, id: Optional[int] = None) -> None:
     self.col = col.weakref()
     self.timerStarted = None
     self._render_output: Optional[anki.template.TemplateRenderOutput] = None
     if id:
         # existing card
         self.id = id
         self.load()
     else:
         # new card with defaults
         self._load_from_backend_card(BackendCard())