validator¶
This module contains the following classes:
Validator
, assessing whether user input is well-formed;ValidatorResult
, a record holding validation result and possibly messages.
-
class
aeneas.validator.
Validator
(rconf=None, logger=None)[source]¶ A validator to assess whether user input is well-formed.
Parameters: - rconf (
RuntimeConfiguration
) – a runtime configuration - logger (
Logger
) – the logger object
-
check_config_txt
(contents, is_config_string=False)[source]¶ Check whether the given TXT config file contents (if
is_config_string
isFalse
) or TXT config string (ifis_config_string
isTrue
) is well-formed and it has all the required parameters.Parameters: - contents (string) – the TXT config file contents or TXT config string
- is_config_string (bool) – if
True
, contents is a config string
Return type:
-
check_config_xml
(contents)[source]¶ Check whether the given XML config file contents is well-formed and it has all the required parameters.
Parameters: - contents (string) – the XML config file contents or XML config string
- is_config_string (bool) – if
True
, contents is a config string
Return type:
-
check_configuration_string
(config_string, is_job=True, external_name=False)[source]¶ Check whether the given job or task configuration string is well-formed (if
is_bstring
isTrue
) and it has all the required parameters.Parameters: - config_string (string) – the byte string or Unicode string to be checked
- is_job (bool) – if
True
,config_string
is a job config string - external_name (bool) – if
True
, the task name is provided externally, and it is not required to appear in the config string
Return type:
-
check_container
(container_path, container_format=None, config_string=None)[source]¶ Check whether the given container is well-formed.
Parameters: - container_path (string) – the path of the container to be checked
- container_format (
ContainerFormat
) – the format of the container - config_string (string) – the configuration string generated by the wizard
Return type:
-
check_file_encoding
(input_file_path)[source]¶ Check whether the given file is UTF-8 encoded.
Parameters: input_file_path (string) – the path of the file to be checked Return type: ValidatorResult
-
check_raw_string
(string, is_bstring=True)[source]¶ Check whether the given string is properly UTF-8 encoded (if
is_bytes
isTrue
), it is not empty, and it does not contain reserved characters.Parameters: - string (string) – the byte string or Unicode string to be checked
- is_bstring (bool) – if True, string is a byte string
Return type:
- rconf (
-
class
aeneas.validator.
ValidatorResult
[source]¶ A structure to contain the result of a validation.
-
add_error
(message)[source]¶ Add a message to the errors.
Parameters: message (string) – the message to be added
-
add_warning
(message)[source]¶ Add a message to the warnings.
Parameters: message (string) – the message to be added
-
errors
¶ The list of emitted errors.
Return type: list of strings
-
passed
¶ The result of a validation.
Return
True
if passed, possibly with emitted warnings.Return
False
if not passed, that is, at least one error emitted.Return type: bool
-
pretty_print
(warnings=False)[source]¶ Pretty print warnings and errors.
Parameters: warnings (bool) – if True
, also print warnings.Return type: string
-
warnings
¶ The list of emitted warnings.
Return type: list of strings
-