"""This module contains helper functions for parsing HTTP GET and POST parameters."""
[docs]defget_primary_keys_from_str_as_list_of_ints(pks:str)->list[int]:"""Gets the primary keys for a str as list[str]. Args: pks: The string in the form <pk0>/<pk1>/.../<pkn>. Duplicate primary keys will cause a ValueError. A trailing / is allowed. Raises: ValueError: If not all primary keys can be interpreted as integers or if duplicates where found. Returns: The list of primary keys. """ifnotpks:err_msg='No primary keys found, got an empty str.'raiseValueError(err_msg)pks_list=pks.split('/')# removing possible trailing empty stringifpks_list[-1]=='':delpks_list[-1]iflen(pks_list)!=len(set(pks_list)):err_msg='Duplicates in query primary key list found.'raiseValueError(err_msg)return[int(pk)forpkinpks_list]