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
Report an error about node as text msg.
Issue an error about duplicated element.
Issue an error about missing required attribute.
Issue an error about unexpected element.
Issue an error when XML is malformed.
Return true if any errors were discovered during parsing.
Return true if any warnings were found during parsing.
Generate a string report about all errors and warnings found.
Issue a deprecation warning about node.
Warn if node.tag is not defined in given version.
Issue a warning about unexpected attribute.
Issue a warning about unexpected element.
Issue a warning during XML parsing.
Report a warning about node as text msg.
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.
- 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.