cemento.draw_io package#

Submodules#

cemento.draw_io.constants module#

exception cemento.draw_io.constants.BadDiagramError(output_file_path)#

Bases: Exception

exception cemento.draw_io.constants.BaseContainerError(message)#

Bases: Exception

exception cemento.draw_io.constants.BidirectionalEdgeError(edge_id, edge_content, parent_content, child_content)#

Bases: Exception

exception cemento.draw_io.constants.BlankEdgeLabelError(edge_id, connected_terms)#

Bases: BlankLabelError

exception cemento.draw_io.constants.BlankLabelError(message)#

Bases: Exception

exception cemento.draw_io.constants.BlankTermLabelError(term_id)#

Bases: BlankLabelError

exception cemento.draw_io.constants.CircularEdgeError(edge_id, edge_content)#

Bases: DisconnectedEdgeError

class cemento.draw_io.constants.ClassShape(shape_id: str, shape_content: str, x_pos: float, y_pos: float, shape_width: int, shape_height: int, fill_color: str = '#f2f3f4', stroke_color: str = '#000000', tree_folding: int = 1, template_key: str = 'class')#

Bases: Shape

template_key: str = 'class'#
class cemento.draw_io.constants.Connector(connector_id: str, source_id: str, target_id: str, connector_label_id: str, connector_val: str, rel_x_pos: float = 0, rel_y_pos: float = 0, start_pos_x: float = 0.5, start_pos_y: float = 0, end_pos_x: float = 0.5, end_pos_y: float = 1, is_dashed: bool = 0, is_curved: bool = 0, template_key: str = 'connector')#

Bases: DiagramObject

static center_coordinates(x_coordinate: float, y_coordinate: float, shape_height=80, shape_width=200) tuple[float, float]#
static compute_dynamic_position(source_shape_x: float, source_shape_y: float, target_shape_x: float, target_shape_y: float) tuple[float, float, float, float]#
connector_id: str#
connector_label_id: str#
connector_val: str#
end_pos_x: float = 0.5#
end_pos_y: float = 1#
is_curved: bool = 0#
is_dashed: bool = 0#
rel_x_pos: float = 0#
rel_y_pos: float = 0#
resolve_position(source_shape_pos: tuple[float, float], target_shape_pos: tuple[float, float], strat_only: bool = False, horizontal_tree: bool = False) None#
source_id: str#
start_pos_x: float = 0.5#
start_pos_y: float = 0#
target_id: str#
template_key: str = 'connector'#
class cemento.draw_io.constants.ConnectorType(*values)#

Bases: Enum

PROPERTY_CONNECTOR = 'property'#
RANK_CONNECTOR = 'rank'#
exception cemento.draw_io.constants.ContainerSubjectError(container_id, container_value, member_ids, member_values)#

Bases: BaseContainerError

class cemento.draw_io.constants.DiagramInfo(diagram_name: int, diagram_id: int, modify_date: str = <factory>, grid_dx: int = 1600, grid_dy: int = 850, grid_size: int = 10, page_width: int = 1100, page_height: int = 850, diagram_content: int = None, template_key: str = 'scaffold')#

Bases: DiagramObject

diagram_content: int = None#
diagram_id: int#
diagram_name: int#
grid_dx: int = 1600#
grid_dy: int = 850#
grid_size: int = 10#
modify_date: str#
page_height: int = 850#
page_width: int = 1100#
template_key: str = 'scaffold'#
class cemento.draw_io.constants.DiagramKey(*values)#

Bases: Enum

LABEL = 'label'#
TERM_ID = 'term_id'#
class cemento.draw_io.constants.DiagramObject#

Bases: object

exception cemento.draw_io.constants.DisconnectedEdgeError(message)#

Bases: Exception

exception cemento.draw_io.constants.DisconnectedTermError(term_id, term_content)#

Bases: Exception

exception cemento.draw_io.constants.FloatingContainerError(container_id, container_value, member_ids, member_values)#

Bases: BaseContainerError

exception cemento.draw_io.constants.FloatingEdgeError(edge_id, edge_content)#

Bases: DisconnectedEdgeError

class cemento.draw_io.constants.GhostConnector(connector_id: str, source_id: str, target_id: str, connector_label_id: str, connector_val: str, rel_x_pos: float = 0, rel_y_pos: float = 0, start_pos_x: float = 0.5, start_pos_y: float = 0, end_pos_x: float = 0.5, end_pos_y: float = 1, is_dashed: bool = 1, is_curved: bool = 1, template_key: str = 'connector')#

Bases: Connector

is_curved: bool = 1#
is_dashed: bool = 1#
class cemento.draw_io.constants.InstanceShape(shape_id: str, shape_content: str, x_pos: float, y_pos: float, shape_width: int, shape_height: int, fill_color: str = '#f2f3f4', stroke_color: str = '#000000', tree_folding: int = 1, template_key: str = 'instance')#

Bases: Shape

template_key: str = 'instance'#
exception cemento.draw_io.constants.InvertedEdgeError(edge_id, edge_content, parent_content, child_content)#

Bases: Exception

class cemento.draw_io.constants.Label(shape_id: str, shape_content: str, x_pos: float, y_pos: float, shape_width: int = 100, shape_height: int = 40, fill_color: str = 'none', stroke_color: str = 'none', tree_folding: int = 0, template_key: str = 'shape')#

Bases: Shape

fill_color: str = 'none'#
shape_height: int = 40#
shape_width: int = 100#
stroke_color: str = 'none'#
tree_folding: int = 0#
class cemento.draw_io.constants.Line(line_id: str, start_pos_x: float, start_pos_y: float, end_pos_x: float, end_pos_y: float, line_width: int = 50, line_height: int = 50, template_key: str = 'line')#

Bases: DiagramObject

end_pos_x: float#
end_pos_y: float#
line_height: int = 50#
line_id: str#
line_width: int = 50#
start_pos_x: float#
start_pos_y: float#
template_key: str = 'line'#
class cemento.draw_io.constants.LiteralShape(shape_id: str, shape_content: str, x_pos: float, y_pos: float, shape_width: int, shape_height: int, fill_color: str = '#f2f3f4', stroke_color: str = '#000000', tree_folding: int = 1, template_key: str = 'literal')#

Bases: Shape

template_key: str = 'literal'#
exception cemento.draw_io.constants.MissingChildEdgeError(edge_id, edge_content, parent_content)#

Bases: DisconnectedEdgeError

exception cemento.draw_io.constants.MissingParentEdgeError(edge_id, edge_content, child_content)#

Bases: DisconnectedEdgeError

exception cemento.draw_io.constants.NestedSyntaxSugarError(container_id, container_value, member_ids, member_values)#

Bases: BaseContainerError

class cemento.draw_io.constants.NxEdge(subj, obj, pred)#

Bases: NamedTuple

obj: any#

Alias for field number 1

pred: any#

Alias for field number 2

subj: any#

Alias for field number 0

class cemento.draw_io.constants.NxStringEdge(subj: any, obj: any, pred: any)#

Bases: NxEdge

class cemento.draw_io.constants.Shape(shape_id: str, shape_content: str, x_pos: float, y_pos: float, shape_width: int, shape_height: int, fill_color: str = '#f2f3f4', stroke_color: str = '#000000', tree_folding: int = 1, template_key: str = 'shape')#

Bases: object

fill_color: str = '#f2f3f4'#
shape_content: str#
shape_height: int#
shape_id: str#
shape_width: int#
stroke_color: str = '#000000'#
template_key: str = 'shape'#
tree_folding: int = 1#
x_pos: float#
y_pos: float#
class cemento.draw_io.constants.ShapeType(*values)#

Bases: Enum

CLASS = 'class'#
INSTANCE = 'instance'#
LITERAL = 'literal'#
UKNOWN = 'shape'#
class cemento.draw_io.constants.TreeFolding(*values)#

Bases: Enum

FOLD = 1#
NO_FOLD = 0#
exception cemento.draw_io.constants.WrongFileFormatError(message='Wrong file format provided')#

Bases: Exception

cemento.draw_io.constants.get_timestamp_str()#

cemento.draw_io.io module#

cemento.draw_io.io.get_diagram_headers(file_path: str | Path) dict[str, str]#
cemento.draw_io.io.get_template_files() dict[str, str | Path]#
cemento.draw_io.io.write_error_diagram(file_path: str | Path, errors: Iterable[tuple[str, BaseException]]) Path#

cemento.draw_io.preprocessing module#

cemento.draw_io.preprocessing.clean_term(term: str) str#
cemento.draw_io.preprocessing.clean_term_preserving_quotes(term: str) str#
cemento.draw_io.preprocessing.escape_shape_content(shape: Shape) Shape#
cemento.draw_io.preprocessing.find_container_errors_diagram_content(elements: dict[str, dict[str, any]], containers: dict[str, list[str]], rel_ids: set[str]) list[tuple[str, BaseException]]#
cemento.draw_io.preprocessing.find_edge_errors_diagram_content(elements: dict[str, dict[str, any]], serious_only: bool = False) list[tuple[str, BaseException]]#
cemento.draw_io.preprocessing.find_errors_diagram_content(elements: dict[str, dict[str, any]], term_ids: set[str], rel_ids: set[str], serious_only: bool = False, containers: dict[str, list[str]] = None, container_content: Container[str] = None, error_exemptions: set[str] = None) list[tuple[str, BaseException]]#
cemento.draw_io.preprocessing.find_shape_errors_diagram_content(elements: dict[str, dict[str, any]], term_ids: set[str], rel_ids: set[str], container_content: Container[str] = None) list[tuple[str, BaseException]]#
cemento.draw_io.preprocessing.get_connected_term_error_message(element_id, elements)#
cemento.draw_io.preprocessing.get_connected_terms(elements: dict[str, dict[str, any]], rel_ids: set[str])#
cemento.draw_io.preprocessing.get_diagram_error_exemptions(elements: dict[str, dict[str, any]]) set[str]#
cemento.draw_io.preprocessing.is_line(element: dict[str, any]) bool#
cemento.draw_io.preprocessing.map_element_values(elements: dict[str, dict[str, any]], element_ids: Iterable[str]) Iterable[str]#
cemento.draw_io.preprocessing.remove_html_quote(input_str: str) str#
cemento.draw_io.preprocessing.remove_literal_connector_id(connector: Connector) Connector#
cemento.draw_io.preprocessing.remove_literal_id(literal_content: str) str#
cemento.draw_io.preprocessing.remove_literal_shape_id(shape: Shape) Shape#
cemento.draw_io.preprocessing.remove_predicate_quotes(edges: Iterable[NxEdge]) Iterable[NxEdge]#
cemento.draw_io.preprocessing.remove_quotes(input_str: str) str#
cemento.draw_io.preprocessing.replace_quotes(input_str: str) str#
cemento.draw_io.preprocessing.replace_term_quotes(graph: DiGraph) DiGraph#

cemento.draw_io.read_diagram module#

cemento.draw_io.read_diagram.read_drawio(input_path: str | Path, onto_ref_folder: str | Path = None, prefixes_file: str | Path = None, defaults_folder: str | Path = None, relabel_key: DiagramKey = DiagramKey.LABEL, check_errors: bool = False, inverted_rank_arrow: bool = False) DiGraph#

cemento.draw_io.transforms module#

cemento.draw_io.transforms.add_node_to_digraph(graph: DiGraph, node: tuple[any, dict[str, any]]) DiGraph#
cemento.draw_io.transforms.assign_edge_label_attrs(elements: dict[str, dict[str, any]]) dict[str, dict[str, any]]#
cemento.draw_io.transforms.clean_element_values(elements: dict[str, dict[str, any]]) dict[str, dict[str, any]]#
cemento.draw_io.transforms.compute_draw_positions(tree: DiGraph, root_node: any) DiGraph#
cemento.draw_io.transforms.compute_grid_allocations(tree: DiGraph, root_node: any) DiGraph#
cemento.draw_io.transforms.conform_instance_draw_positions(tree: DiGraph, box_offset=1.5) DiGraph#
cemento.draw_io.transforms.conform_tree_positions(trees: list[DiGraph]) list[DiGraph]#
cemento.draw_io.transforms.extract_elements(elements: dict[str, dict[str, any]]) tuple[set[str], set[str]]#
cemento.draw_io.transforms.flip_edges(graph: DiGraph, filter_func: Callable[[any, any, dict[str, any]], bool] = None) DiGraph#
cemento.draw_io.transforms.flip_edges_of_graphs(graphs: Iterable[DiGraph], filter_func: Callable[[any, any, dict[str, any]], bool] = None) Iterable[DiGraph]#
cemento.draw_io.transforms.generate_diagram_content(diagram_name: str, diagram_uid: str, *diagram_objects: list[DiagramObject]) str#
cemento.draw_io.transforms.generate_graph(elements: dict[str, dict[str, any]], term_ids: set[str], relationship_ids: set[str], strat_terms: set[str] = None, exempted_elements: set[str] = None, inverted_rank_arrow: bool = False) DiGraph#
cemento.draw_io.transforms.generate_shapes(graph: DiGraph, diagram_uid: str, offset_x: int = 0, offset_y: int = 0, idx_start: int = 0, shape_color: str = '#f2f3f4', stroke_color: str = '#000000', shape_height: int = 80, shape_width: int = 200) list[Shape]#
cemento.draw_io.transforms.get_connectors(edges: list[~cemento.draw_io.constants.NxStringEdge | tuple[str, str, str]], shape_positions: dict[str, tuple[float, float]], shape_ids: dict[str, str], diagram_uid: str, entity_idx_start: int = 0, connector_type: type[~cemento.draw_io.constants.Connector] = <class 'cemento.draw_io.constants.Connector'>) list[Connector]#
cemento.draw_io.transforms.get_container_collection_types(graph: DiGraph, container_labels: dict[str, str], containers: dict[str, list[str]]) dict[str, str]#
cemento.draw_io.transforms.get_container_values(containers: dict[str, list[str]], elements: dict[str, dict[str, any]]) dict[str, str]#
cemento.draw_io.transforms.get_divider_line_annotations(line: Line, diagram_uid: str, label_id_start: str) list[Label]#
cemento.draw_io.transforms.get_graph_edges(graph: DiGraph, data_filter: Callable[[dict[str, any]], bool] = None) Iterable[NxEdge]#
cemento.draw_io.transforms.get_non_ranked_strat_edges(graph: DiGraph) Iterable[tuple[any, any]]#
cemento.draw_io.transforms.get_predicate_connectors(graph: DiGraph, shape_positions: dict[str, tuple[float, float]], shape_ids: dict[str, str], diagram_uid: str, entity_idx_start: int = 0) list[Connector]#
cemento.draw_io.transforms.get_rank_connectors(graph: DiGraph, shape_positions: dict[str, tuple[float, float]], shape_ids: dict[str, str], diagram_uid: str, entity_idx_start: int = 0) list[Connector]#
cemento.draw_io.transforms.get_rank_connectors_from_trees(trees: list[DiGraph], shape_positions: dict[str, tuple[float, float]], shape_ids: dict[str, str], diagram_uid: str, entity_idx_start: int = 0) list[Connector]#
cemento.draw_io.transforms.get_rank_strat_connectors(graph: DiGraph, connectors: list[Connector], shape_id: dict[str, str]) list[Connector]#
cemento.draw_io.transforms.get_ranked_subgraph(graph: DiGraph) DiGraph#
cemento.draw_io.transforms.get_shape_designation(node: any, node_attr: dict[str, any]) ShapeType#
cemento.draw_io.transforms.get_shape_ids(shapes: list[Shape]) dict[str, str]#
cemento.draw_io.transforms.get_shape_positions(shapes: list[Shape]) dict[str, tuple[float, float]]#
cemento.draw_io.transforms.get_shape_positions_by_id(shapes: list[Shape]) dict[str, tuple[float, float]]#
cemento.draw_io.transforms.get_shapes_from_trees(trees: list[DiGraph], diagram_uid: str, entity_idx_start: int = 0, tree_offsets: list[tuple[float, float]] = None, horizontal_tree: bool = False) list[Shape]#
cemento.draw_io.transforms.get_tree_canvas_size(tree: DiGraph) tuple[float, float]#
cemento.draw_io.transforms.get_tree_dividing_line(tree: DiGraph, line_id: str, offset_x: float = 0, offset_y: float = 0, line_offset_y: float = 0.5) Line#
cemento.draw_io.transforms.get_tree_extents(tree: DiGraph) tuple[tuple[float, float], tuple[float, float]]#
cemento.draw_io.transforms.get_tree_offsets(trees: list[DiGraph], horizontal_tree: bool = False) Iterable[tuple[float, float]]#
cemento.draw_io.transforms.get_tree_size(tree: DiGraph) tuple[int, int]#
cemento.draw_io.transforms.invert_tree(tree: DiGraph) DiGraph#
cemento.draw_io.transforms.no_instance_in_tree(tree: DiGraph) bool#
cemento.draw_io.transforms.parse_containers(elements: dict[str, dict[str, any]]) dict[str, list[str]]#
cemento.draw_io.transforms.parse_elements(file_path: str | Path) dict[str, dict[str, any]]#
cemento.draw_io.transforms.relabel_graph_nodes_with_node_attr(graph: DiGraph, new_attr_label: str = 'term_id') DiGraph#
cemento.draw_io.transforms.replace_element_value_html_quotes(elements: dict[str, dict[str, any]]) dict[str, dict[str, any]]#
cemento.draw_io.transforms.retrieve_elements(file_path: str | Path) dict[str, dict[str, any]]#
cemento.draw_io.transforms.shift_tree(tree: DiGraph, shift_x: float = 0, shift_y: float = 0) DiGraph#
cemento.draw_io.transforms.split_multiple_inheritances(graph: DiGraph) tuple[list[DiGraph], list[tuple[any, any]]]#
cemento.draw_io.transforms.translate_coords(x_pos: float, y_pos: float, origin_x: float = 0, origin_y: float = 0) tuple[int, int]#

cemento.draw_io.write_diagram module#

cemento.draw_io.write_diagram.draw_diagram(shapes: list[Shape], connectors: list[Connector], diagram_output_path: str | Path, *extra_elements: list[DiagramObject], diagram_uid: str = None) None#
cemento.draw_io.write_diagram.draw_tree(graph: DiGraph, diagram_output_path: str | Path, translate_x: int = 0, translate_y: int = 0, classes_only: bool = False, demarcate_boxes: bool = False, horizontal_tree: bool = False) None#

Module contents#