add sort param support in CDX API class (#156)
see https://nla.github.io/outbackcdx/api.html#operation/query sort takes string input which must be one of the follwoing: - default - closest - reverse This commit shall help in closing issue at https://github.com/akamhy/waybackpy/issues/155
This commit is contained in:
@@ -151,3 +151,24 @@ def check_match_type(match_type: Optional[str], url: str) -> bool:
|
||||
raise WaybackError(exc_message)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def check_sort(sort: Optional[str]) -> bool:
|
||||
"""
|
||||
Check that the sort argument passed by the end-user is valid.
|
||||
If not valid then raise WaybackError.
|
||||
"""
|
||||
|
||||
legal_sort = ["default", "closest", "reverse"]
|
||||
|
||||
if not sort:
|
||||
return True
|
||||
|
||||
if sort not in legal_sort:
|
||||
exc_message = (
|
||||
f"{sort} is not an allowed argument for sort.\n"
|
||||
"Use one from 'default', 'closest' or 'reverse'"
|
||||
)
|
||||
raise WaybackError(exc_message)
|
||||
|
||||
return True
|
||||
|
Reference in New Issue
Block a user