pyGHDL.dom.formatting.GraphML
This module offers formatters to write a design’s graphs as GraphML files.
Classes
Formatter: Abstract base-class for writing a pyVHDLModel graph as a GraphML file.DependencyGraphFormatter: Writes a design’s dependency graph as GraphML, grouping the vertices by library.HierarchyGraphFormatter: Writes a design’s hierarchy graph as GraphML.CompileOrderGraphFormatter: Writes a design’s compile order graph as GraphML.
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
- 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 byWriteGraphML().- Return type:
None
- _graph: Graph
The graph to be written as GraphML.
- class pyGHDL.dom.formatting.GraphML.DependencyGraphFormatter(graph)[source]
Writes a design’s dependency graph as GraphML, grouping the vertices by library.
Inheritance
- 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
nd1node
idThe vertex’ ID, repeated as data so a reader ignoring the XML
idstill sees it.nd2node
valueThe label to display. An architecture is written as
entity(architecture), a document as its ID, anything else as its identifier.nd3node
kindThe name of the vertex’
DependencyGraphVertexKind.nd4node
colorThe fill color from
NODE_COLORS, selected by vertex kind.ed3edge
kindThe name of the edge’s
DependencyGraphEdgeKind.ed4edge
colorThe line color from
EDGE_COLORS, selected by edge kind.A node’s XML
idis the vertex’ ID from the model. An edge has none, so edges are numbered in the order they are written and gete1,e2, …; theirsourceandtargetare 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 ownLibrary. 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 byWriteGraphML().- 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
- 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
nd1node
idThe vertex’ ID, repeated as data so a reader ignoring the XML
idstill sees it.nd2node
valueThe label to display. The vertex’ identifier.
nd3node
kindThe name of the vertex’
DependencyGraphVertexKind.nd4node
colorThe fill color from
NODE_COLORS, selected by vertex kind.ed3edge
kindThe name of the edge’s
DependencyGraphEdgeKind.ed4edge
colorThe line color from
EDGE_COLORS, selected by edge kind.A node’s XML
idis the vertex’ ID from the model. An edge has none, so edges are numbered in the order they are written and gete1,e2, …; theirsourceandtargetare 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 byWriteGraphML().- 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
- 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
nd1node
idThe vertex’ ID, repeated as data so a reader ignoring the XML
idstill sees it.nd2node
valueThe label to display. The vertex’ identifier.
nd3node
kindThe name of the vertex’
DependencyGraphVertexKind.nd4node
colorThe fill color from
NODE_COLORS, selected by vertex kind.ed3edge
kindThe name of the edge’s
DependencyGraphEdgeKind.ed4edge
colorThe line color from
EDGE_COLORS, selected by edge kind.A node’s XML
idis the vertex’ ID from the model. An edge has none, so edges are numbered in the order they are written and gete1,e2, …; theirsourceandtargetare 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 byWriteGraphML().- Return type:
None
- _graph: Graph
The graph to be written as GraphML.