in src/mapillary/utils/verify.py [0:0]
def kwarg_check(kwargs: dict, options: list, callback: str) -> bool:
"""
Checks for keyword arguments amongst the kwarg argument to fall into the options list
:param kwargs: A dictionary that contains the keyword key-value pair arguments
:type kwargs: dict
:param options: A list of possible arguments in kwargs
:type options: list
:param callback: The function that called 'kwarg_check' in the case of an exception
:type callback: str
:raises InvalidOptionError: Invalid option exception
:return: A boolean, whether the kwargs are appropriate or not
:rtype: bool
"""
if kwargs is not None:
for key in kwargs.keys():
if key not in options:
raise InvalidKwargError(
func=callback,
key=key,
value=kwargs[key],
options=options,
)
# If 'zoom' is in kwargs
if ("zoom" in kwargs) and (kwargs["zoom"] < 14 or kwargs["zoom"] > 17):
# Raising exception for invalid zoom value
raise InvalidOptionError(
param="zoom", value=kwargs["zoom"], options=[14, 15, 16, 17]
)
# if 'image_type' is in kwargs
if ("image_type" in kwargs) and (
kwargs["image_type"] not in ["pano", "flat", "all"]
):
# Raising exception for invalid image_type value
raise InvalidOptionError(
param="image_type",
value=kwargs["image_type"],
options=["pano", "flat", "all"],
)
# If all tests pass, return True
return True