parser module

Test

parser.IGNORE = ['id', 'label', 'placeholders', 'class_name']

Properties to ignore when parsing.

class parser.Node(id, class_name, properties)[source]

Bases: object

Identifies a node object, as found in drawio. On one hand used for the individual components, but on the other hand used as a “group” of multiple nodes.

add_connection(source, target)[source]
add_input(name)[source]
add_output(name)[source]
get_connections()[source]
get_inputs()[source]
get_outputs()[source]
get_properties_string(ignore=[])[source]
is_empty()[source]
class parser.Page(name)[source]

Bases: object

A single page in drawio. Contains multiple nodes.

add_import(im, obj=None)[source]
add_node(node)[source]
get_imports()[source]
get_nodes()[source]
get_sanitized_name()[source]
exception parser.ParseException(message)[source]

Bases: Exception

Semantic exceptions when parsing.

class parser.Parser(filename, setup, ignore_empty_nodes=False)[source]

Bases: object

The drawio parser.

create_node(root, attr, page)[source]
static decode_and_deflate(data)[source]

Draw.io compresses each page as follows: First, all data is url-encoded Next, it is compressed/deflated Finally, it is encoded according to base64.

To obtain the page data, we have to do the reverse.

Returns:Uncompressed and decoded data as a string.
parse()[source]

Does the actual file parsing.

If the file is compressed, we uncompress and work from there. If it wasn’t compressed, we can work with the whole tree.

Returns:A list of Node objects, representing the drawio file.
parse_page(page, nroot)[source]

Parses a single page of the model.

parser.parse_environment(vars)[source]

Parses the set of environment variables, given with the -E/--environment variable.