def after_note_updates( self, *, nids: Sequence[int], mark_notes_modified: bool, generate_cards: bool ) -> pb.Empty: input = pb.AfterNoteUpdatesIn( nids=nids, mark_notes_modified=mark_notes_modified, generate_cards=generate_cards, ) output = pb.Empty() output.ParseFromString(self._run_command(44, input)) return output
def search_cards(self, search: str, order: Union[bool, str, int], reverse: bool = False) -> Sequence[int]: if isinstance(order, str): mode = pb.SortOrder(custom=order) elif order is True: mode = pb.SortOrder(from_config=pb.Empty()) elif order is False: mode = pb.SortOrder(none=pb.Empty()) else: # sadly we can't use the protobuf type in a Union, so we # have to accept an int and convert it kind = BuiltinSortKind.Value(BuiltinSortKind.Name(order)) mode = pb.SortOrder( builtin=pb.BuiltinSearchOrder(kind=kind, reverse=reverse)) return self._run_command( pb.BackendInput(search_cards=pb.SearchCardsIn( search=search, order=mode))).search_cards.card_ids
def open_collection( self, *, collection_path: str, media_folder_path: str, media_db_path: str, log_path: str, ) -> pb.Empty: input = pb.OpenCollectionIn( collection_path=collection_path, media_folder_path=media_folder_path, media_db_path=media_db_path, log_path=log_path, ) output = pb.Empty() output.ParseFromString(self._run_command(53, input)) return output
def get_all_config(self) -> Dict[str, Any]: jstr = self._run_command( pb.BackendInput(get_all_config=pb.Empty())).get_all_config return orjson.loads(jstr)
def before_upload(self): self._run_command(pb.BackendInput(before_upload=pb.Empty()))
def abort_media_sync(self): self._run_command(pb.BackendInput(abort_media_sync=pb.Empty()))
def all_deck_config(self) -> Sequence[Dict[str, Any]]: jstr = self._run_command( pb.BackendInput(all_deck_config=pb.Empty())).all_deck_config return orjson.loads(jstr)
def restore_trash(self): self._run_command(pb.BackendInput(restore_trash=pb.Empty()))
def check_media(self) -> MediaCheckOutput: return self._run_command( pb.BackendInput(check_media=pb.Empty()), release_gil=True, ).check_media
def sync_media(self, *, hkey: str, endpoint: str) -> pb.Empty: input = pb.SyncMediaIn(hkey=hkey, endpoint=endpoint) output = pb.Empty() output.ParseFromString(self._run_command(56, input)) return output
def check_database(self) -> Sequence[str]: input = pb.Empty() output = pb.CheckDatabaseOut() output.ParseFromString(self._run_command(55, input)) return output.problems
def close_collection(self, downgrade_to_schema11: bool) -> pb.Empty: input = pb.CloseCollectionIn(downgrade_to_schema11=downgrade_to_schema11) output = pb.Empty() output.ParseFromString(self._run_command(54, input)) return output
def remove_notetype(self, ntid: int) -> pb.Empty: input = pb.NoteTypeID(ntid=ntid) output = pb.Empty() output.ParseFromString(self._run_command(52, input)) return output
def get_notetype_names_and_counts(self) -> Sequence[pb.NoteTypeNameIDUseCount]: input = pb.Empty() output = pb.NoteTypeUseCounts() output.ParseFromString(self._run_command(50, input)) return output.entries
def get_notetype_names(self) -> Sequence[pb.NoteTypeNameID]: input = pb.Empty() output = pb.NoteTypeNames() output.ParseFromString(self._run_command(49, input)) return output.entries
def get_preferences(self) -> pb.CollectionSchedulingSettings: input = pb.Empty() output = pb.Preferences() output.ParseFromString(self._run_command(69, input)) return output.sched
def set_preferences(self, sched: pb.CollectionSchedulingSettings) -> pb.Empty: input = pb.Preferences(sched=sched) output = pb.Empty() output.ParseFromString(self._run_command(70, input)) return output
def abort_media_sync(self) -> pb.Empty: input = pb.Empty() output = pb.Empty() output.ParseFromString(self._run_command(57, input)) return output
def empty_trash(self): self._run_command(pb.BackendInput(empty_trash=pb.Empty()))
def before_upload(self) -> pb.Empty: input = pb.Empty() output = pb.Empty() output.ParseFromString(self._run_command(58, input)) return output
def all_tags(self) -> Sequence[pb.TagUsnTuple]: input = pb.Empty() output = pb.AllTagsOut() output.ParseFromString(self._run_command(62, input)) return output.tags
def set_config_json(self, *, key: str, value_json: bytes) -> pb.Empty: input = pb.SetConfigJsonIn(key=key, value_json=value_json) output = pb.Empty() output.ParseFromString(self._run_command(65, input)) return output
def new_deck_config(self) -> Dict[str, Any]: jstr = self._run_command( pb.BackendInput(new_deck_config=pb.Empty())).new_deck_config return orjson.loads(jstr)
def remove_config(self, val: str) -> pb.Empty: input = pb.String(val=val) output = pb.Empty() output.ParseFromString(self._run_command(66, input)) return output
def all_tags(self) -> Iterable[TagUsnTuple]: return self._run_command( pb.BackendInput(all_tags=pb.Empty())).all_tags.tags
def set_all_config(self, json: bytes) -> pb.Empty: input = pb.Json(json=json) output = pb.Empty() output.ParseFromString(self._run_command(67, input)) return output
def remove_config(self, key: str): self._run_command( pb.BackendInput( set_config_json=pb.SetConfigJson(key=key, remove=pb.Empty())))
def get_all_config(self) -> bytes: input = pb.Empty() output = pb.Json() output.ParseFromString(self._run_command(68, input)) return output.json
def get_all_decks(self) -> Dict[str, Dict[str, Any]]: jstr = self._run_command( pb.BackendInput(get_all_decks=pb.Empty())).get_all_decks return orjson.loads(jstr)
def update_note(self, input: pb.Note) -> pb.Empty: output = pb.Empty() output.ParseFromString(self._run_command(39, input)) return output