acheck.checking.check_interface

class acheck.checking.check_interface.Check(tool_meta: ToolObjectsMeta, group: CheckGroup, displayed_name: str | None = None, active: bool = True, disabled: bool = False, options: Dict[str, str | bool | int | float] | None = None)[source]

Bases: ABC

This is an interface for creating checks

Variables:
  • id (int) – This id is necessary to identify the checks in the tool, it is assigned automatically when creating the check. Defaults to “-1”.

  • logs (List[str]) – A list to pass additional outputs to the tool. Defaults to “[]”.

Parameters:
  • tool_meta (ToolObjectsMeta) – (Instance Attribute) A current instance of a ToolObjectsMeta object, which was initiated in the main script.

  • group (check_interface.CheckGroup) – A group to differentiate between the checks’ behavior.

  • displayed_name (str) – (Instance Attribute) A custom name that will be displayed in the tool.

  • active (bool) – Activates the check in the tool directly, the check can be deactivated in the tool. Defaults to “true”.

  • disabled (bool) – If this attribute is True, the check is disabled in the tool and cannot be used. This usually happens when certain requirements are not met to run the check correctly, e.g. third party software. If the run method raises an exception this also will be set to True.

  • options (Dict[str, Union[str,bool,int,float]]) – All additional arguments that the check requires specifically for itself are stored here.

Options:

Each option can be either of type str, bool, int or float. Generally all additional attributes defined in the check class are automatically converted into an option. However, all options with value can also be set by default when initializing the check.

get_option_as_config(option: str, value: str)[source]

A function that checks if all arguments have an appropriate type. Otherwise, it raises an error. Allowed typed are: int, str, bool, float.

Returns:

A dictionary containing all extra arguments.

Return type:

Dict[str, Union[str,bool,int,float]]

Raises:

TypeError – If arguments are not of type int, str, float or bool.

get_option_types()[source]

A function that checks if all arguments have an appropriate type. Otherwise, it raises an error. Allowed typed are: int, str, bool, float.

Returns:

A dictionary containing all extra arguments.

Return type:

Dict[str, Union[str,bool,int,float]]

Raises:

TypeError – If arguments are not of type int, str, float or bool.

abstract run(annotation: Path, domain: Path, problem: Path, line_limit: int = -1) List[Error][source]

Start the check. All checks must inherit from this abstract class and need to implement their own run() method.

Parameters:
  • annotation (Path) – Path of the annotation file

  • problem (Path) – Path of the domain file

  • domain (Path) – Path of the problem file

  • line_limit (int) – Limits the check of the annotation up to a certain line. Defaults to “-1”.

Returns:

A list containing all the errors that were found during the check.

Return type:

List[Error]

class acheck.checking.check_interface.CheckGroup(value)[source]

Bases: Enum

Separating checks into different groups with different behavior.

Async = 3

Checks in this group will always run next to every check in the Default group. Such as spell checking.

Default = (2,)

Checks in this group are executed one after another. If a check throws an error, the loop will stop. It will move on if all error thrown by the actual checker are fixed.

PreStart = (0,)

PreStart checks are evaluated before the program starts. Such as file reading. Checks in this group will be running one by one. PreStart Checks will also be added to the Default group.

class acheck.checking.check_interface.ToolObjectsMeta(output: ~pathlib.Path | None = None, annotations: ~typing.List[~typing.Dict] = <factory>, models: ~typing.List[~typing.Dict] = <factory>, pwl: ~pathlib.Path | None = None, pel: ~pathlib.Path | None = None, signatures: ~pathlib.Path | None = None, validator: ~pathlib.Path | None = None)[source]

Bases: object

Holds all information about all needed file paths and names

Parameters:
  • output (Path) – The output path for the folder structure of the working copy, defaults to None

  • annotations (List[Dict]) – A list of all annotation objects

  • models (List[Dict]) – A list of all model objects

  • pwl (Path) – The path for the personal words list of the spelling corrector

  • pel (Path) – The path for the excluded words list of the spelling corrector

  • signatures (Path) – The path of the signature file that stores the signature marked as correct for each action.

  • validator (Path) – The path of the plan validator executable.

annotations: List[Dict]
models: List[Dict]
output: Path = None
pel: Path = None
pwl: Path = None
signatures: Path = None
validator: Path = None
acheck.checking.check_interface.logger = <Logger acheck.checking.check_interface (WARNING)>

Register logging

acheck.checking.error

class acheck.checking.error.Error(file_name: Path, error_type: ErrorType, check_id: int, line_number: int = -1, incorrect_sequence: Sequence | None = None, fixes: List[Fix] | None = None, error_level=ErrorLevel.Error, advice: str | None = None)[source]

Bases: object

Specifies an error that holds all information about the problem found in the annotation.

Parameters:
  • file_name (Path) – Path of the file.

  • error_type (ErrorType) – Specifies the type of the error.

  • check_id (int) – To identify the error by check.

  • line_number (int) – In which line did the error occur. Defaults to “-1”, if the error cannot be assigned to a line.

  • incorrect_sequence (Sequence) – Specifies the character sequence that might be wrong. Defaults to “None”, if there is no sequence.

  • fixes (List[Fix]) – A list of fix objects that can be used to correct the error.

  • error_level (ErrorLevel) – Specifies the error level. Defaults to “ErrorLevel.Error”.

  • advice (str) – A specific message that describes the error in more detail and contains important information. It is usually generated automatically based on all other attributes.

to_dict()[source]

Returns the error object as dictionary.

Return type:

Dict

class acheck.checking.error.ErrorLevel(value)[source]

Bases: IntEnum

Different error levels enable the division of errors into two groups

Error = 1

Errors are serious problems that require direct intervention to keep the program running.

Warning = 0

Warnings are displayed, but they do not cause direct interference and do not cancel the program

class acheck.checking.error.ErrorType(value)[source]

Bases: Enum

All different error types that a check can display

IllegalCSVFile = 2

There is an error when opening or reading a csv file

IllegalCharacter = 4

There are symbols in the annotation that are not allowed

IllegalDomainDescription = 12

The PDDL description is not correct

IllegalExpressionStructure = 7

The structure of the expressions does not correspond to the predefined structure of an annotation expression

IllegalFile = 1

There is an error when opening or reading the file

IllegalProblemDescription = 13

The PDDL description is not correct

IllegalSignature = 10

The signature of an action is not correct or marked as correct

IllegalTimestampNoNumber = 5

The time slice of an annotation is not a number

IllegalTimestampNotAscending = 6

The time stamps of the actions are equal and or not ascending

IllegalUppercase = 14
PlanValidationError = 11

An error occurred when validating the plan resulting from the annotation.

UnknownAction = 8

An action is not defined in the domain

UnknownObject = 9

Another object is not known in the domain

WrongSpelling = 3

There a spelling mistake

class acheck.checking.error.Fix(correct_string: str | None = None, fix_code: FixCode = FixCode.Alert)[source]

Bases: object

An object that holds information about how to fix the error or warning

Parameters:
  • correct_string (str) – If there is a corrected character sequence, then it can be saved here. Defaults to “None”.

  • fix_code (FixCode) – Specifies the type of fix. Defaults to “FixCode.Alert”.

class acheck.checking.error.FixCode(value)[source]

Bases: Enum

All different types of fixes which can be proposed as solutions to work with in the tool

AdaptModel = 5

The model must be adapted

AddToDict = 6

The model must be adapted

Alert = 1

A message is displayed in the tool

RemoveSequence = 3

An incorrect character sequence can be removed

ReplaceSequence = 2

An incorrect character sequence can be replaced by a correct one

WhitelistSignature = 4

a special signature of an action is locked as currently correct signature

class acheck.checking.error.Sequence(start_index=0, char_sequence='')[source]

Bases: object

An object that holds information about the incorrect character sequence

Parameters:
  • start_index (int) – Specifies the index at the position of the line where the incorrect character sequence starts. Defaults to “0”.

  • char_sequence (str) – If there is an incorrect character sequence, then it can be saved here. Defaults to “”.

acheck.checking.error.build_advice(error_type, line_number, incorrect_sequence, fixes, error_level) str[source]

Takes error parameters and builds an advice message :return str: A nicely formatted message that contains all information about the error.

acheck.checking.error.from_dict(error_dict)[source]

Takes an error as dictionary and creates an error object.

Parameters:

error_dict – Error object as dictionary.

Returns:

Error object

acheck.checking.error.group_errors_by_line(error_list: List[Error]) dict[source]

Group errors by line :param error_list: List of errors :return: A dictionary that contains all errors by line. It has each line as a key and the values are all associated errors in a list.

acheck.checking.error.group_errors_inline(errors: List[Error]) dict[source]

Errors are grouped by line. If the sequences of the errors overlap, they are included in the same group. :param List[Error] errors: List of errors :return: A dictionary that contains all groups. It has the start index and the end index of each group as a key and the values are then all associated errors in a list.

acheck.checking.error.logger = <Logger acheck.checking.error (WARNING)>

Register logging

acheck.checking.error.read_list(file_name) List[Error][source]

Reads a error list file from json and creates a list of error objects :param file_name: Path of the file :return: List of error objects :rtype: List[Error] or None, if there is an error with the list. :raises IOError: If an error occurred during reading the error list file.

acheck.checking.error.write_groups(file_name, error_list: List[Error]) None[source]

Takes a list of errors and writes the json groups file.

Parameters:
  • file_name – Path of the file

  • error_list – List of error objects

acheck.checking.error.write_list(file_name, error_list) None[source]

Writes a list of errors into a json file.

Parameters:
  • file_name – Path of the file

  • error_list – List of error objects