mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-03 06:13:02 +02:00
test: topology: Add helper to retrieve graph-global attributes
This will allow us to define attributes that are specific to a particular test system.
This commit is contained in:
+12
-8
@@ -1,6 +1,15 @@
|
||||
import networkx as nx
|
||||
from networkx.algorithms import isomorphism
|
||||
|
||||
def _qstrip(text):
|
||||
if text == None:
|
||||
return None
|
||||
|
||||
if text.startswith("\"") and text.endswith("\""):
|
||||
return text[1:-1]
|
||||
|
||||
return text
|
||||
|
||||
def map_edges(les, pes):
|
||||
acc = []
|
||||
les = sorted(list(les.values()), key=lambda x: x.get("kind", ""), reverse=True)
|
||||
@@ -22,14 +31,6 @@ def match_edge(pes, les):
|
||||
|
||||
class Topology:
|
||||
def __init__(self, dotg):
|
||||
def _qstrip(text):
|
||||
if text == None:
|
||||
return None
|
||||
|
||||
if text.startswith("\"") and text.endswith("\""):
|
||||
return text[1:-1]
|
||||
return text
|
||||
|
||||
self.dotg = dotg
|
||||
self.g = nx.MultiGraph()
|
||||
|
||||
@@ -142,6 +143,9 @@ class Topology:
|
||||
def get_infixen(self):
|
||||
return self.get_nodes(lambda _, attrs: attrs.get("kind") == "infix")
|
||||
|
||||
def get_attr(self, name, default=None):
|
||||
return _qstrip(self.dotg.get_attributes().get(name, default))
|
||||
|
||||
# Support calling this script like so...
|
||||
#
|
||||
# python3 topology.py <physical> <logical>
|
||||
|
||||
Reference in New Issue
Block a user