# -*- coding: utf-8 -*-"""Exception creator and helpers, argument validators, and more."""importtypingasTifT.TYPE_CHECKING:# pragma: no coverfrom.core.s3pathimportS3Path
[docs]defensure_one_and_only_one_not_none(**kwargs)->None:""" Ensure only exact one of the keyword argument is not None. """iflen(kwargs)==0:raiseValueErrorifsum([visnotNonefor_,vinkwargs.items()])!=1:raiseValueError(f"one and only one of arguments from "f"{list(kwargs)} can be not None!")
[docs]defensure_all_none(**kwargs)->None:""" Ensure all the keyword arguments are None. """iflen(kwargs)==0:raiseValueErrorifsum([visnotNonefor_,vinkwargs.items()])!=0:raiseValueError(f"arguments from {list(kwargs)} has to be all None!")
class_S3PathTypeError(TypeError):_expected_type:str@classmethoddefmake(cls:T.Type[T.Union[Exception,"_S3PathTypeError"]],s3path:"S3Path",):returncls(f"{s3path!r} is not a {cls._expected_type}! ")