finesse.script.exceptions module

Kat script exceptions.

These are special exceptions that add extra context-specific information when errors occur during parsing or unparsing.

exception finesse.script.exceptions.KatMissingAfterDirective(container, directive)[source]

Bases: KatSyntaxError

Error for when an element name or function ‘(’ is missing.

exception finesse.script.exceptions.KatParsingError(message, **kwargs)[source]

Bases: FinesseException

An error during the parsing process.

This handles errors raised by the tokenizer, parser and builder. These are, confusingly, collectively referred to as the “parser”.

exception finesse.script.exceptions.KatParsingInputSizeWarning[source]

Bases: UserWarning

Warns the users of an unreasonable input size, either the in the total size of the katscript or the length of an individual line.

Both of these might lead to recursion errors or low performance.

exception finesse.script.exceptions.KatParsingWarning[source]

Bases: UserWarning

A warning during the parsing, indicating that exceptions might occur later.

exception finesse.script.exceptions.KatScriptError(error, container, error_items, syntax=None)[source]

Bases: KatParsingError

Detailed kat script error.

Parameters

errorstr or Exception

The error or error message.

containerAddressable

The kat script container, used to show lines before/after error lines if requested.

error_itemssequence of sequences of Addressable

The error(s) to show. Each item of the topmost sequence should itself be an ordered sequence of Addressable objects in increasing order of depth. The last item is considered to be where the error occurred, but the start and end lines (plus optional buffer) of each of the other items are also shown.

syntaxstr, optional

Syntax suggestion to display to the user.

MAX_BUFFER_LINES = 1
chunkify()[source]

Convert the error script into a dict of line numbers to (str, is_error) sequences.

Each (str, is_error) chunk contains a piece of the script specified in error_items, with the is_error flag set depending on whether each error item appeared last in a error_items sequence, which specifies that it is an error as opposed to just useful related code.

Returns

dict

Mapping of line numbers to lists of (str, bool) tuples indicating script chunks and whether they contain an error.

property error_lines[source]
items_to_linemarkers(items)[source]
message()[source]
rubric()[source]
exception finesse.script.exceptions.KatSyntaxError(message, script, token)[source]

Bases: KatScriptError

Error with kat syntax.