mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Move order docstring back into find_cards()
This commit is contained in:
parent
b1a06fb807
commit
7b316a7151
1 changed files with 17 additions and 18 deletions
|
@ -497,8 +497,22 @@ class Collection:
|
||||||
reverse: bool = False,
|
reverse: bool = False,
|
||||||
) -> Sequence[CardId]:
|
) -> Sequence[CardId]:
|
||||||
"""Return card ids matching the provided search.
|
"""Return card ids matching the provided search.
|
||||||
|
|
||||||
To programmatically construct a search string, see .build_search_string().
|
To programmatically construct a search string, see .build_search_string().
|
||||||
To define a sort order, see _build_sort_mode().
|
|
||||||
|
If order=True, use the sort order stored in the collection config
|
||||||
|
If order=False, do no ordering
|
||||||
|
|
||||||
|
If order is a string, that text is added after 'order by' in the sql statement.
|
||||||
|
You must add ' asc' or ' desc' to the order, as Anki will replace asc with
|
||||||
|
desc and vice versa when reverse is set in the collection config, eg
|
||||||
|
order="c.ivl asc, c.due desc".
|
||||||
|
|
||||||
|
If order is a BuiltinSort.Kind value, sort using that builtin sort, eg
|
||||||
|
col.find_cards("", order=BuiltinSort.Kind.CARD_DUE)
|
||||||
|
|
||||||
|
The reverse argument only applies when a BuiltinSort.Kind is provided;
|
||||||
|
otherwise the collection config defines whether reverse is set or not.
|
||||||
"""
|
"""
|
||||||
mode = _build_sort_mode(order, reverse)
|
mode = _build_sort_mode(order, reverse)
|
||||||
return cast(
|
return cast(
|
||||||
|
@ -512,8 +526,9 @@ class Collection:
|
||||||
reverse: bool = False,
|
reverse: bool = False,
|
||||||
) -> Sequence[NoteId]:
|
) -> Sequence[NoteId]:
|
||||||
"""Return note ids matching the provided search.
|
"""Return note ids matching the provided search.
|
||||||
|
|
||||||
To programmatically construct a search string, see .build_search_string().
|
To programmatically construct a search string, see .build_search_string().
|
||||||
To define a sort order, see _build_sort_mode().
|
The order parameter is documented in .find_cards().
|
||||||
"""
|
"""
|
||||||
mode = _build_sort_mode(order, reverse)
|
mode = _build_sort_mode(order, reverse)
|
||||||
return cast(
|
return cast(
|
||||||
|
@ -1072,22 +1087,6 @@ def _build_sort_mode(
|
||||||
order: Union[bool, str, BuiltinSort.Kind.V],
|
order: Union[bool, str, BuiltinSort.Kind.V],
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
) -> _pb.SortOrder:
|
) -> _pb.SortOrder:
|
||||||
"""Return a SortOrder object for use in find_cards() or find_notes().
|
|
||||||
|
|
||||||
If order=True, use the sort order stored in the collection config
|
|
||||||
If order=False, do no ordering
|
|
||||||
|
|
||||||
If order is a string, that text is added after 'order by' in the sql statement.
|
|
||||||
You must add ' asc' or ' desc' to the order, as Anki will replace asc with
|
|
||||||
desc and vice versa when reverse is set in the collection config, eg
|
|
||||||
order="c.ivl asc, c.due desc".
|
|
||||||
|
|
||||||
If order is a BuiltinSort.Kind value, sort using that builtin sort, eg
|
|
||||||
col.find_cards("", order=BuiltinSort.Kind.CARD_DUE)
|
|
||||||
|
|
||||||
The reverse argument only applies when a BuiltinSort.Kind is provided;
|
|
||||||
otherwise the collection config defines whether reverse is set or not.
|
|
||||||
"""
|
|
||||||
if isinstance(order, str):
|
if isinstance(order, str):
|
||||||
return _pb.SortOrder(custom=order)
|
return _pb.SortOrder(custom=order)
|
||||||
elif isinstance(order, bool):
|
elif isinstance(order, bool):
|
||||||
|
|
Loading…
Reference in a new issue