pyGHDL.dom.formatting.GraphML

This module offers formatters to write a design’s graphs as GraphML files.

Classes


Classes

class pyGHDL.dom.formatting.GraphML.Formatter(graph)[source]

Abstract base-class for writing a pyVHDLModel graph as a GraphML file.

A derived formatter provides the two color translation dictionaries and implements WriteGraphML() for the graph it can render.

Inheritance

Inheritance diagram of Formatter

Parameters:

graph (Graph)

NODE_COLORS: ClassVar[Dict[Flag, str]]

Translation dictionary of vertex kind to fill color; set by each derived formatter.

EDGE_COLORS: ClassVar[Dict[Flag, str]]

Translation dictionary of edge kind to line color; set by each derived formatter.

__init__(graph)[source]

Initializes a GraphML formatter for the given graph.

Parameters:

graph (Graph) – The graph to be written as GraphML by WriteGraphML().

Return type:

None

_graph: Graph

The graph to be written as GraphML.

WriteGraphML(path)[source]

Writes the graph as a GraphML file.

Parameters:

path (Path) – The path of the file to write.

class pyGHDL.dom.formatting.GraphML.DependencyGraphFormatter(graph)[source]

Writes a design’s dependency graph as GraphML, grouping the vertices by library.

Inheritance

Inheritance diagram of DependencyGraphFormatter

Parameters:

graph (Graph)

NODE_COLORS: ClassVar[Dict[Flag, str]] = {<DependencyGraphVertexKind.Architecture: 64>: '#ff99cc', <DependencyGraphVertexKind.Configuration: 256>: '#ff9900', <DependencyGraphVertexKind.Context: 4>: '#cc99ff', <DependencyGraphVertexKind.Document: 1>: '#999999', <DependencyGraphVertexKind.Entity: 32>: '#ffff99', <DependencyGraphVertexKind.Library: 2>: '#99ccff', <DependencyGraphVertexKind.Package: 8>: '#ff9900', <DependencyGraphVertexKind.PackageBody: 16>: '#ff9900'}

Translation dictionary of vertex kind to fill color; set by each derived formatter.

EDGE_COLORS: ClassVar[Dict[Flag, str]] = {<DependencyGraphEdgeKind.CompileOrder: 257>: '#ff0000', <DependencyGraphEdgeKind.ComponentInstantiation: 2112>: '#000000', <DependencyGraphEdgeKind.ConfigurationInstantiation: 2080>: '#000000', <DependencyGraphEdgeKind.ContextReference: 516>: '#000000', <DependencyGraphEdgeKind.EntityImplementation: 1040>: '#99ccff', <DependencyGraphEdgeKind.EntityInstantiation: 2064>: '#000000', <DependencyGraphEdgeKind.LibraryClause: 514>: '#000000', <DependencyGraphEdgeKind.PackageImplementation: 1032>: '#99ccff', <DependencyGraphEdgeKind.PackageInstantiation: 2056>: '#000000', <DependencyGraphEdgeKind.SourceFile: 129>: '#000000', <DependencyGraphEdgeKind.UseClause: 520>: '#000000'}

Translation dictionary of edge kind to line color; set by each derived formatter.

WriteGraphML(path)[source]

Writes the dependency graph as a GraphML file, grouping the vertices by library.

The document declares six GraphML keys, four for nodes and two for edges:

Key

Applies to

Attribute

Value

nd1

node

id

The vertex’ ID, repeated as data so a reader ignoring the XML id still sees it.

nd2

node

value

The label to display. An architecture is written as entity(architecture), a document as its ID, anything else as its identifier.

nd3

node

kind

The name of the vertex’ DependencyGraphVertexKind.

nd4

node

color

The fill color from NODE_COLORS, selected by vertex kind.

ed3

edge

kind

The name of the edge’s DependencyGraphEdgeKind.

ed4

edge

color

The line color from EDGE_COLORS, selected by edge kind.

A node’s XML id is the vertex’ ID from the model. An edge has none, so edges are numbered in the order they are written and get e1, e2, …; their source and target are vertex IDs.

The graph is grouped into one subgraph per library: an enclosing node grp_<library> holds a nested <graph id="<library>"> with that library’s vertices. A vertex is assigned to a library by asking the model - a library vertex for itself, a document vertex through its first design unit, anything else through its own Library. Edges are written afterwards at the top level, so an edge may cross from one subgraph into another.

Parameters:

path (Path) – The path of the file to write.

__init__(graph)

Initializes a GraphML formatter for the given graph.

Parameters:

graph (Graph) – The graph to be written as GraphML by WriteGraphML().

Return type:

None

_graph: Graph

The graph to be written as GraphML.

class pyGHDL.dom.formatting.GraphML.HierarchyGraphFormatter(graph)[source]

Writes a design’s hierarchy graph as GraphML.

Inheritance

Inheritance diagram of HierarchyGraphFormatter

Parameters:

graph (Graph)

NODE_COLORS: ClassVar[Dict[Flag, str]] = {<DependencyGraphVertexKind.Architecture: 64>: '#ff99cc', <DependencyGraphVertexKind.Configuration: 256>: '#ff9900', <DependencyGraphVertexKind.Context: 4>: '#cc99ff', <DependencyGraphVertexKind.Document: 1>: '#999999', <DependencyGraphVertexKind.Entity: 32>: '#ffff99', <DependencyGraphVertexKind.Library: 2>: '#99ccff', <DependencyGraphVertexKind.Package: 8>: '#ff9900', <DependencyGraphVertexKind.PackageBody: 16>: '#ff9900'}

Translation dictionary of vertex kind to fill color; set by each derived formatter.

EDGE_COLORS: ClassVar[Dict[Flag, str]] = {<DependencyGraphEdgeKind.CompileOrder: 257>: '#ff0000', <DependencyGraphEdgeKind.ComponentInstantiation: 2112>: '#000000', <DependencyGraphEdgeKind.ConfigurationInstantiation: 2080>: '#000000', <DependencyGraphEdgeKind.ContextReference: 516>: '#000000', <DependencyGraphEdgeKind.EntityImplementation: 1040>: '#99ccff', <DependencyGraphEdgeKind.EntityInstantiation: 2064>: '#000000', <DependencyGraphEdgeKind.LibraryClause: 514>: '#000000', <DependencyGraphEdgeKind.PackageImplementation: 1032>: '#99ccff', <DependencyGraphEdgeKind.SourceFile: 129>: '#000000', <DependencyGraphEdgeKind.UseClause: 520>: '#000000'}

Translation dictionary of edge kind to line color; set by each derived formatter.

WriteGraphML(path)[source]

Writes the hierarchy graph as a GraphML file.

The document declares six GraphML keys, four for nodes and two for edges:

Key

Applies to

Attribute

Value

nd1

node

id

The vertex’ ID, repeated as data so a reader ignoring the XML id still sees it.

nd2

node

value

The label to display. The vertex’ identifier.

nd3

node

kind

The name of the vertex’ DependencyGraphVertexKind.

nd4

node

color

The fill color from NODE_COLORS, selected by vertex kind.

ed3

edge

kind

The name of the edge’s DependencyGraphEdgeKind.

ed4

edge

color

The line color from EDGE_COLORS, selected by edge kind.

A node’s XML id is the vertex’ ID from the model. An edge has none, so edges are numbered in the order they are written and get e1, e2, …; their source and target are vertex IDs.

The vertices are written flat, without subgraphs.

Parameters:

path (Path) – The path of the file to write.

__init__(graph)

Initializes a GraphML formatter for the given graph.

Parameters:

graph (Graph) – The graph to be written as GraphML by WriteGraphML().

Return type:

None

_graph: Graph

The graph to be written as GraphML.

class pyGHDL.dom.formatting.GraphML.CompileOrderGraphFormatter(graph)[source]

Writes a design’s compile order graph as GraphML.

Inheritance

Inheritance diagram of CompileOrderGraphFormatter

Parameters:

graph (Graph)

NODE_COLORS: ClassVar[Dict[Flag, str]] = {<DependencyGraphVertexKind.Architecture: 64>: '#ff99cc', <DependencyGraphVertexKind.Configuration: 256>: '#ff9900', <DependencyGraphVertexKind.Context: 4>: '#cc99ff', <DependencyGraphVertexKind.Document: 1>: '#999999', <DependencyGraphVertexKind.Entity: 32>: '#ffff99', <DependencyGraphVertexKind.Library: 2>: '#99ccff', <DependencyGraphVertexKind.Package: 8>: '#ff9900', <DependencyGraphVertexKind.PackageBody: 16>: '#ff9900'}

Translation dictionary of vertex kind to fill color; set by each derived formatter.

EDGE_COLORS: ClassVar[Dict[Flag, str]] = {<DependencyGraphEdgeKind.CompileOrder: 257>: '#ff0000', <DependencyGraphEdgeKind.ComponentInstantiation: 2112>: '#000000', <DependencyGraphEdgeKind.ConfigurationInstantiation: 2080>: '#000000', <DependencyGraphEdgeKind.ContextReference: 516>: '#000000', <DependencyGraphEdgeKind.EntityImplementation: 1040>: '#99ccff', <DependencyGraphEdgeKind.EntityInstantiation: 2064>: '#000000', <DependencyGraphEdgeKind.LibraryClause: 514>: '#000000', <DependencyGraphEdgeKind.PackageImplementation: 1032>: '#99ccff', <DependencyGraphEdgeKind.SourceFile: 129>: '#000000', <DependencyGraphEdgeKind.UseClause: 520>: '#000000'}

Translation dictionary of edge kind to line color; set by each derived formatter.

WriteGraphML(path)[source]

Writes the compile order graph as a GraphML file.

The document declares six GraphML keys, four for nodes and two for edges:

Key

Applies to

Attribute

Value

nd1

node

id

The vertex’ ID, repeated as data so a reader ignoring the XML id still sees it.

nd2

node

value

The label to display. The vertex’ identifier.

nd3

node

kind

The name of the vertex’ DependencyGraphVertexKind.

nd4

node

color

The fill color from NODE_COLORS, selected by vertex kind.

ed3

edge

kind

The name of the edge’s DependencyGraphEdgeKind.

ed4

edge

color

The line color from EDGE_COLORS, selected by edge kind.

A node’s XML id is the vertex’ ID from the model. An edge has none, so edges are numbered in the order they are written and get e1, e2, …; their source and target are vertex IDs.

The vertices are written flat, without subgraphs.

Parameters:

path (Path) – The path of the file to write.

__init__(graph)

Initializes a GraphML formatter for the given graph.

Parameters:

graph (Graph) – The graph to be written as GraphML by WriteGraphML().

Return type:

None

_graph: Graph

The graph to be written as GraphML.