pyaiml21.parser.logger.Logger

class pyaiml21.parser.logger.Logger[source][source]

Logger instance is used to report error and warnings during parsing.

The logger offers 3 levels of error messages:
  • weak warning - warnings that should be presented to the user

    only in the strict mode

  • warning - messages about elements that are either ignored or their

    correct representation can be deduced

  • errors - unrepairable errors in the representation

Care should be taken that error-nous aiml constructs are not to be processed anymore as they contain in-interpretable code. Warnings are generally treated as if the corresponding element was not present or was modified accordingly.

Methods

error

Report an error about node as text msg.

error_duplicate_element

Issue an error about duplicated element.

error_missing_attr

Issue an error about missing required attribute.

error_unexpected_element

Issue an error about unexpected element.

error_xml_syntax

Issue an error when XML is malformed.

has_errors

Return true if any errors were discovered during parsing.

has_warnings

Return true if any warnings were found during parsing.

report

Generate a string report about all errors and warnings found.

warn_deprecated

Issue a deprecation warning about node.

warn_not_defined

Warn if node.tag is not defined in given version.

warn_unexpected_attr

Issue a warning about unexpected attribute.

warn_unexpected_element

Issue a warning about unexpected element.

warn_xml_syntax

Issue a warning during XML parsing.

warning

Report a warning about node as text msg.

weak_warning

Report a weak warning.

error(node: pyaiml21.ast.node.Node, msg: str) None[source][source]

Report an error about node as text msg.

error_duplicate_element(node: pyaiml21.ast.node.Node)[source][source]

Issue an error about duplicated element.

error_missing_attr(node: pyaiml21.ast.node.Node, attr: str)[source][source]

Issue an error about missing required attribute.

error_unexpected_element(node: pyaiml21.ast.node.Node)[source][source]

Issue an error about unexpected element.

error_xml_syntax(msg: str, file: Optional[str], line: Optional[int] = None, col: Optional[int] = None)[source][source]

Issue an error when XML is malformed.

has_errors() bool[source][source]

Return true if any errors were discovered during parsing.

has_warnings() bool[source][source]

Return true if any warnings were found during parsing.

report(with_stats: bool = False, strict: bool = False) str[source][source]

Generate a string report about all errors and warnings found.

Parameters
  • with_stats – True if summary of errors and warnings should be included

  • strict – if true, include also weak warnings in the summary

Returns

string with formatted report

warn_deprecated(node: pyaiml21.ast.node.Node, last_version: pyaiml21.aiml.AIMLVersion)[source][source]

Issue a deprecation warning about node.

warn_not_defined(node: pyaiml21.ast.node.Node, def_version: pyaiml21.aiml.AIMLVersion)[source][source]

Warn if node.tag is not defined in given version.

warn_unexpected_attr(node: pyaiml21.ast.node.Node, attr: str)[source][source]

Issue a warning about unexpected attribute.

warn_unexpected_element(node: pyaiml21.ast.node.Node)[source][source]

Issue a warning about unexpected element.

warn_xml_syntax(msg: str, file: Optional[str], line: Optional[int] = None, col: Optional[int] = None)[source][source]

Issue a warning during XML parsing.

warning(node: pyaiml21.ast.node.Node, msg: str) None[source][source]

Report a warning about node as text msg.

weak_warning(node: pyaiml21.ast.node.Node, msg: str) None[source][source]

Report a weak warning.