xtd.core.config.checkers module¶
-
xtd.core.config.checkers.check_file(p_section, p_name, p_value, p_read=False, p_write=False, p_execute=False)[source]¶ check that given config parameter is a valid file with given rwx attributes
If p_value does not exists and only write attribute is requested, the function checks that the file can be created in its parent directory
Parameters: Returns: file absolute path
Return type: Raises: ConfigValueFileError– p_value is a directoryConfigValueFileModeError– p_value dosen’t meet requested rwx attributes
-
xtd.core.config.checkers.check_dir(p_section, p_name, p_value, p_read=False, p_write=False, p_execute=False)[source]¶ check that given value is a valid directory for given rwx attributes
Parameters: Returns: directory absolute path
Return type: Raises: ConfigValueDirError– p_value is not a directoryConfigValueDirModeError– directory doesn’t meet requested rwx attributes
-
xtd.core.config.checkers.check_int(p_section, p_name, p_value, p_min=None, p_max=None)[source]¶ check that given value is a valid integer
If not None, the function will insure that value fits the requested minimum and maximum parameters
Parameters: Returns: integer converted value
Return type: Raises: ConfigValueTypeError– value is not an integer, nor a int-convertible stringConfigValueLimitsError– value doesn’t match requested min and max constraints
-
xtd.core.config.checkers.check_float(p_section, p_name, p_value, p_min=None, p_max=None)[source]¶ check that given value is a valid float
Same as
check_int()Parameters: Raises: ConfigValueTypeError– value is not an integer, nor a int-convertible stringConfigValueLimitsError– value doesn’t match requested min and max constraints
Returns: float converted value
Return type:
-
xtd.core.config.checkers.check_bool(p_section, p_name, p_value)[source]¶ check that given value is a valid boolean
- Valid boolean are :
- native bool object
- str object in the following list :
["on", "yes", "true", "off", "no", "false"](case insensitive)
Parameters: Raises: ConfigValueTypeError– invalid input booleanReturns: converted value
Return type:
-
xtd.core.config.checkers.check_enum(p_section, p_name, p_value, p_values)[source]¶ check that given value matches a set of possible values
Parameters: Raises: ConfigValueEnumError– value not found in possible valuesReturns: input value
Return type:
-
xtd.core.config.checkers.check_mail(p_section, p_name, p_value)[source]¶ check that given value is a syntactical valid mail address
Parameters: Raises: ConfigValueValueError– value not an emailReturns: input value
Return type:
-
xtd.core.config.checkers.check_array(p_section, p_name, p_value, p_check=None, p_delim=', ')[source]¶ check that given value is convertible to array
A str value is converted to array by splitting each comma separated elements
Additionally, the function checks that each elements meets
p_checkfunction requirement.Example:
l_value = "1,2,3,4,5" l_value = check_array(l_value, check_float) print(l_value) # [1.0, 2.0, 3.0, 4.0] l_value = "on,on;off,no;true,false" l_value = check_array(l_value, is_array(p_check=check_bool), p_delim=";") print(l_value) # [[True, True], [False, False], [True, False]]
Parameters: Raises: ConfigValueValueError– value not an emailReturns: array-converted value
Return type:
-
xtd.core.config.checkers.check_host(p_section, p_name, p_value)[source]¶ check that value is locally resolvable hostname
Parameters: Raises: ConfigValueValueError– value not an hostnameReturns: input value
Return type:
-
xtd.core.config.checkers.check_json(p_section, p_name, p_value)[source]¶ check that value is a valid json
if value is str, performs a :py:func:json.loads
Parameters: Raises: ConfigValueValueError– value not a jsonReturns: dict-converted value
Return type:
-
xtd.core.config.checkers.check_socket(p_section, p_name, p_value, p_schemes=None, p_checkUnix=False)[source]¶ check that value is a valid socket url
Parameters: Raises: ConfigValueValueError– value a valid socket urlReturns: input value
Return type:
-
xtd.core.config.checkers.is_file(*p_args, **p_kwds)[source]¶ Currified version of
check_file()
-
xtd.core.config.checkers.is_dir(*p_args, **p_kwds)[source]¶ Currified version of
check_dir()
-
xtd.core.config.checkers.is_int(*p_args, **p_kwds)[source]¶ Currified version of
check_int()
-
xtd.core.config.checkers.is_float(*p_args, **p_kwds)[source]¶ Currified version of
check_float()
-
xtd.core.config.checkers.is_bool(*p_args, **p_kwds)[source]¶ Currified version of
check_bool()
-
xtd.core.config.checkers.is_enum(*p_args, **p_kwds)[source]¶ Currified version of
check_enum()
-
xtd.core.config.checkers.is_mail(*p_args, **p_kwds)[source]¶ Currified version of
check_mail()
-
xtd.core.config.checkers.is_array(*p_args, **p_kwds)[source]¶ Currified version of
check_array()
-
xtd.core.config.checkers.is_host(*p_args, **p_kwds)[source]¶ Currified version of
check_host()
-
xtd.core.config.checkers.is_json(*p_args, **p_kwds)[source]¶ Currified version of
check_json()
-
xtd.core.config.checkers.is_socket(*p_args, **p_kwds)[source]¶ Currified version of
check_socket()