def flush(self) -> None: self._bugcheck() hooks.card_will_flush(self) # mtime & usn are set by backend card = _pb.Card( 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)
def __init__( self, col: anki.collection.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(_pb.Card())
def _to_backend_card(self) -> _pb.Card: # mtime & usn are set by backend return _pb.Card( 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, )
def get_card(self, cid: int) -> pb.Card: input = pb.CardID(cid=cid) output = pb.Card() output.ParseFromString(self._run_command(63, input)) return output