def addDecks(parent, decks): for head, did, rev, lrn, new, children in decks: name = self.mw.col.decks.get(did)["name"] shortname = DeckManager.basename(name) if children: subm = parent.addMenu(shortname) subm.addItem(_("Filter"), self._filterFunc("deck", name)) subm.addSeparator() addDecks(subm, children) else: if did != 1 or self.col.decks.should_default_be_displayed( force_default=False, assume_no_child=True ): parent.addItem(shortname, self._filterFunc("deck", name))
def fields_for_rendering(col: anki.storage._Collection, card: Card, note: Note) -> Dict[str, str]: # fields from note fields = dict(note.items()) # add special fields fields["Tags"] = note.stringTags().strip() fields["Type"] = card.note_type()["name"] fields["Deck"] = col.decks.name(card.odid or card.did) fields["Subdeck"] = DeckManager.basename(fields["Deck"]) fields["Card"] = card.template()["name"] flag = card.userFlag() fields["CardFlag"] = flag and f"flag{flag}" or "" fields["c%d" % (card.ord + 1)] = "1" return fields
def fields(self) -> dict[str, str]: print(".fields() is obsolete, use .note() or .card()") if not self._fields: # fields from note fields = dict(self._note.items()) # add (most) special fields fields["Tags"] = self._note.string_tags().strip() fields["Type"] = self._note_type["name"] fields["Deck"] = self._col.decks.name(self._card.current_deck_id()) fields["Subdeck"] = DeckManager.basename(fields["Deck"]) if self._template: fields["Card"] = self._template["name"] else: fields["Card"] = "" flag = self._card.user_flag() fields["CardFlag"] = flag and f"flag{flag}" or "" self._fields = fields return self._fields