| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | 
							- import pathlib
 
- class config_exception(Exception):
 
-     """
 
-     This exception is base class for other exceptions in configuration.
 
-     """
 
-     pass
 
- class key_not_implemented(config_exception):
 
-     """ 
 
-     This exception is raised when key is not in defaults config, but found
 
-     in the config file.
 
-     """
 
-     def __init__(self, key: str) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         key : str
 
-             Name of the key, which is not implemented.
 
-         """
 
-         super().__init__("Key \"" + key + "\" is not implemented.")
 
- class bad_type_loaded(config_exception):
 
-     """
 
-     This exception is raised when key loaded from config file is in invalid
 
-     type. Valid type is same as type as type of value that key from defaults
 
-     config.
 
-     """
 
-     def __init__(self, key: str, required: type, own: type) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         key : str
 
-             Name of the key.
 
-         
 
-         required : type
 
-             Required type for that key.
 
-         own : type
 
-             Type of that key from config file.
 
-         """
 
-         
 
-         required = required.__name__
 
-         own = own.__name__
 
-         error = "Value for key \"" + key + "\" must be an " + required
 
-         error = error + " but is " + own + "."
 
-         super().__init__(error)
 
- class invalid_config_processor(config_exception):
 
-     """
 
-     That exception is raised when config preprocessor class, given in 
 
-     config_loader builder is not valid config_loader child class.
 
-     """
 
-     def __init__(self, which: any) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         which : any
 
-             Class given as config preprocessor.
 
-         """
 
-         super().__init__("Invalid config processor: " + str(which) + ".")
 
- class bad_key_type(config_exception):
 
-     """
 
-     That exception is raised when name of the key is not an string.
 
-     """
 
-     def __init__(self, key: any) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         key : any
 
-             Key, which is not an string.
 
-         """
 
-         super().__init__("Key must be string, but is \"" + repr(key) + "\".")
 
- class bad_value_type(config_exception):
 
-     """
 
-     This exception is raised when key in defaults config is not in valid.
 
-     Valid type is string, number (int or float) and boolean. Value can not
 
-     being object, list or other complex types.
 
-     """
 
-     def __init__(self, key: str, value: any) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         key : str
 
-             Name of the invalid key.
 
-         
 
-         value : any
 
-             Value in invalid type.
 
-         """
 
-         error = "Key \"" + key + "\" has invalid type of value. Int, "
 
-         error = error + "string, float or bool is required, but \""
 
-         error = error + repr(value) + "\" found."
 
-         super().__init__(error)
 
- class config_file_not_exists(config_exception):
 
-     """
 
-     That exception is raised when config file, which config_loader tried
 
-     to load, does not exists.
 
-     """
 
-     def __init__(self, file: pathlib.Path) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         file : pathlib.Path
 
-             Config file which not exists.
 
-         """
 
-         super().__init__("Config file " + str(file) + "not exists.")
 
- class config_file_not_readable(config_exception):
 
-     """
 
-     That exception is raised when config file is not readable, because could
 
-     not being opened or have syntax error.
 
-     """
 
-     def __init__(self, error: Exception) -> None:
 
-         """
 
-         Parameters
 
-         ----------
 
-         error : Exception 
 
-             Exception which was raised by json loader or file handler.
 
-         """
 
-         super().__init__("Config file is not readable: " + str(error) + ".")
 
 
  |