[docs]classUndefinedProfile(ValueError):"""The given profile ('{name}') is not registered with ``ini2toml``. Are you sure you have the right plugins installed and loaded? """def__init__(self,name:str,available:Sequence[str]):msg=self.__class__.__doc__or""super().__init__(msg.format(name=name)+f"Available: {', '.join(available)})")@classmethoddefcheck(cls,name:str,available:List[str]):""":meta private:"""ifnamenotinavailable:raisecls(name,available)
[docs]classAlreadyRegisteredAugmentation(ValueError):"""The profile augmentation '{name}' is already registered for '{existing}'. Some installed plugins seem to be in conflict with each other, please check '{new}' and '{existing}'. If you are the developer behind one of them, please use a different name. """def__init__(self,name:str,new:Callable,existing:Callable):existing_id=f"{existing.__module__}.{existing.__qualname__}"new_id=f"{new.__module__}.{new.__qualname__}"msg=dedent(self.__class__.__doc__or"")super().__init__(msg.format(name=name,new=new_id,existing=existing_id))@classmethoddefcheck(cls,name:str,fn:Callable,registry:Mapping[str,types.ProfileAugmentation]):""":meta private:"""ifnameinregistry:raisecls(name,fn,registry[name].fn)
[docs]classInvalidAugmentationName(ValueError):"""Profile augmentations should be valid python identifiers"""def__init__(self,name:str):msg=self.__class__.__doc__or""super().__init__(f"{msg} ({name!r} given)")
[docs]classInvalidTOMLKey(ValueError):"""{key!r} is not a valid key in the intermediate TOML representation"""def__init__(self,key):msg=self.__doc__.format(key=key)super().__init__(msg)
[docs]classInvalidCfgBlock(ValueError):# pragma: no cover -- not supposed to happen"""Something is wrong with the provided ``.ini/.cfg`` AST"""def__init__(self,block):super().__init__(f"{block.__class__}: {block}",{"block_object":block})