Exemple #1
0
 def update(self, g: Dict[str, Any], preserve_usn=True) -> None:
     "Add or update an existing deck. Used for syncing and merging."
     try:
         g["id"] = self.col.backend.add_or_update_deck_legacy(
             deck=to_json_bytes(g), preserve_usn_and_mtime=preserve_usn)
     except anki.rsbackend.DeckIsFilteredError:
         raise DeckRenameError("deck was filtered")
Exemple #2
0
 def update(self, m: NoteType, preserve_usn=True) -> None:
     "Add or update an existing model. Use .save() instead."
     self._remove_from_cache(m["id"])
     self.ensureNameUnique(m)
     m["id"] = self.col.backend.add_or_update_notetype(
         json=to_json_bytes(m), preserve_usn_and_mtime=preserve_usn)
     self.setCurrent(m)
     self._mutate_after_write(m)
Exemple #3
0
def mi_partially_render(self) -> PartiallyRenderedCard:
    global originalAnswer, originalQuestion, ogTemplate
    if self._template:
        out = self._col.backend.render_uncommitted_card(
            note=self._note.to_backend_note(),
            card_ord=self._card.ord,
            template=to_json_bytes(self._template),
            fill_empty=self._fill_empty,
        )
    else:
        template = getTemplateCheckingForCloze(self._card)
        template['afmt'] = getEditableFields(template['afmt'])
        template['qfmt'] = getEditableFields(template['qfmt'])
        out = self._col.backend.render_uncommitted_card(
            note=self._note.to_backend_note(),
            card_ord=self._card.ord,
            template=to_json_bytes(template),
            fill_empty=self._fill_empty,
        )
    return PartiallyRenderedCard.from_proto(out)
Exemple #4
0
 def _partially_render(self) -> PartiallyRenderedCard:
     if self._template:
         # card layout screen
         out = self._col.backend.render_uncommitted_card(
             note=self._note.to_backend_note(),
             card_ord=self._card.ord,
             template=to_json_bytes(self._template),
             fill_empty=self._fill_empty,
         )
     else:
         # existing card (eg study mode)
         out = self._col.backend.render_existing_card(card_id=self._card.id,
                                                      browser=self._browser)
     return PartiallyRenderedCard.from_proto(out)
Exemple #5
0
 def update_config(self, conf: Dict[str, Any], preserve_usn=False) -> None:
     conf["id"] = self.col.backend.add_or_update_deck_config_legacy(
         config=to_json_bytes(conf), preserve_usn_and_mtime=preserve_usn)
Exemple #6
0
 def set(self, key: str, val: Any) -> None:
     self.col.backend.set_config_json(key=key,
                                      value_json=to_json_bytes(val))