Example #1
0
 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
Example #2
0
    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
Example #3
0
 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
Example #4
0
 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)
Example #5
0
 def before_upload(self):
     self._run_command(pb.BackendInput(before_upload=pb.Empty()))
Example #6
0
 def abort_media_sync(self):
     self._run_command(pb.BackendInput(abort_media_sync=pb.Empty()))
Example #7
0
 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)
Example #8
0
 def restore_trash(self):
     self._run_command(pb.BackendInput(restore_trash=pb.Empty()))
Example #9
0
 def check_media(self) -> MediaCheckOutput:
     return self._run_command(
         pb.BackendInput(check_media=pb.Empty()),
         release_gil=True,
     ).check_media
Example #10
0
 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
Example #11
0
 def check_database(self) -> Sequence[str]:
     input = pb.Empty()
     output = pb.CheckDatabaseOut()
     output.ParseFromString(self._run_command(55, input))
     return output.problems
Example #12
0
 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
Example #13
0
 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
Example #14
0
 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
Example #15
0
 def get_notetype_names(self) -> Sequence[pb.NoteTypeNameID]:
     input = pb.Empty()
     output = pb.NoteTypeNames()
     output.ParseFromString(self._run_command(49, input))
     return output.entries
Example #16
0
 def get_preferences(self) -> pb.CollectionSchedulingSettings:
     input = pb.Empty()
     output = pb.Preferences()
     output.ParseFromString(self._run_command(69, input))
     return output.sched
Example #17
0
 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
Example #18
0
 def abort_media_sync(self) -> pb.Empty:
     input = pb.Empty()
     output = pb.Empty()
     output.ParseFromString(self._run_command(57, input))
     return output
Example #19
0
 def empty_trash(self):
     self._run_command(pb.BackendInput(empty_trash=pb.Empty()))
Example #20
0
 def before_upload(self) -> pb.Empty:
     input = pb.Empty()
     output = pb.Empty()
     output.ParseFromString(self._run_command(58, input))
     return output
Example #21
0
 def all_tags(self) -> Sequence[pb.TagUsnTuple]:
     input = pb.Empty()
     output = pb.AllTagsOut()
     output.ParseFromString(self._run_command(62, input))
     return output.tags
Example #22
0
 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
Example #23
0
 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)
Example #24
0
 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
Example #25
0
 def all_tags(self) -> Iterable[TagUsnTuple]:
     return self._run_command(
         pb.BackendInput(all_tags=pb.Empty())).all_tags.tags
Example #26
0
 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
Example #27
0
 def remove_config(self, key: str):
     self._run_command(
         pb.BackendInput(
             set_config_json=pb.SetConfigJson(key=key, remove=pb.Empty())))
Example #28
0
 def get_all_config(self) -> bytes:
     input = pb.Empty()
     output = pb.Json()
     output.ParseFromString(self._run_command(68, input))
     return output.json
Example #29
0
 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)
Example #30
0
 def update_note(self, input: pb.Note) -> pb.Empty:
     output = pb.Empty()
     output.ParseFromString(self._run_command(39, input))
     return output