mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
This commit introduces a PackageSearch-derivative class: `RPCSearch`. This derivative modifies callback behavior of PackageSearch to suit RPC searches, including [make|check|opt]depends `by` types. Signed-off-by: Kevin Morris <kevr@0cost.org>
21 lines
472 B
Python
21 lines
472 B
Python
""" Constant default values centralized in one place. """
|
|
|
|
# Default [O]ffset
|
|
O = 0
|
|
|
|
# Default [P]er [P]age
|
|
PP = 50
|
|
|
|
# A whitelist of valid PP values
|
|
PP_WHITELIST = {50, 100, 250}
|
|
|
|
# Default `by` parameter for RPC search.
|
|
RPC_SEARCH_BY = "name-desc"
|
|
|
|
|
|
def fallback_pp(per_page: int) -> int:
|
|
""" If `per_page` is a valid value in PP_WHITELIST, return it.
|
|
Otherwise, return defaults.PP. """
|
|
if per_page not in PP_WHITELIST:
|
|
return PP
|
|
return per_page
|