示例#1
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
示例#2
0
 def search_cards(self, *, search: str, order: pb.SortOrder) -> Sequence[int]:
     input = pb.SearchCardsIn(search=search, order=order)
     output = pb.SearchCardsOut()
     output.ParseFromString(self._run_command(7, input))
     return output.card_ids