mirror of
https://github.com/sileht/bird-lg.git
synced 2024-11-22 06:54:43 +01:00
basic caracter escape for pydot html label
This commit is contained in:
parent
af5faf98c1
commit
725b8d3a3d
11
lg.py
11
lg.py
|
@ -361,9 +361,15 @@ def show_bgpmap():
|
||||||
nodes = {}
|
nodes = {}
|
||||||
edges = {}
|
edges = {}
|
||||||
|
|
||||||
|
def escape(label):
|
||||||
|
label = label.replace("&", "&")
|
||||||
|
label = label.replace(">", ">")
|
||||||
|
label = label.replace("<", "<")
|
||||||
|
return label
|
||||||
|
|
||||||
def add_node(_as, **kwargs):
|
def add_node(_as, **kwargs):
|
||||||
if _as not in nodes:
|
if _as not in nodes:
|
||||||
kwargs["label"] = '<<TABLE CELLBORDER="0" BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD ALIGN="CENTER">' + kwargs.get("label", get_as_name(_as)).replace("\r","<BR/>") + "</TD></TR></TABLE>>"
|
kwargs["label"] = '<<TABLE CELLBORDER="0" BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD ALIGN="CENTER">' + escape(kwargs.get("label", get_as_name(_as))).replace("\r","<BR/>") + "</TD></TR></TABLE>>"
|
||||||
nodes[_as] = pydot.Node(_as, style="filled", fontsize="10", **kwargs)
|
nodes[_as] = pydot.Node(_as, style="filled", fontsize="10", **kwargs)
|
||||||
graph.add_node(nodes[_as])
|
graph.add_node(nodes[_as])
|
||||||
return nodes[_as]
|
return nodes[_as]
|
||||||
|
@ -386,7 +392,8 @@ def show_bgpmap():
|
||||||
labels = [ kwargs["label"] ] + [ l for l in labels if not l.startswith(label_without_star) ]
|
labels = [ kwargs["label"] ] + [ l for l in labels if not l.startswith(label_without_star) ]
|
||||||
labels = sorted(labels, cmp=lambda x,y: x.endswith("*") and -1 or 1)
|
labels = sorted(labels, cmp=lambda x,y: x.endswith("*") and -1 or 1)
|
||||||
|
|
||||||
e.set_label("\r".join(labels))
|
label = escape("\r".join(labels))
|
||||||
|
e.set_label(label)
|
||||||
return edges[edge_tuple]
|
return edges[edge_tuple]
|
||||||
|
|
||||||
for host, asmaps in data.iteritems():
|
for host, asmaps in data.iteritems():
|
||||||
|
|
Loading…
Reference in a new issue