Fix dumb bugs

topo-mov
LEdoian 1 year ago
parent e8e0538e59
commit f86d0a4d37

@ -1,9 +1,10 @@
from . import Annotator, Annotation
import .analysis as analysis
from . import Annotator, Annotation, AnnotatorID
import birdvisu.annotations.analysis as analysis
from ..topo_v3 import VertexID, VertexType
from ..ospffile import load
from collections.abc import Sequence
from collections import defaultdict
from ipaddress import ip_network, IPv4Network
from socket import AF_INET, AF_INET6
@ -233,15 +234,15 @@ class EdgeWidthByCost(StyleAnnotator):
# The param is a function mapping the costs to widths.
# This _is_ hashable, but also it _is_ ugly. But convenient :-)
self.width_for_cost = param if param is not None else _default_width_for_cost
def annotate(topo):
def annotate(self, topo):
result = Annotation()
result.for_edge = {e: self.width_for_cost(e.cost) for e in topo.topology.edges}
result.for_edge = {e: {'width': self.width_for_cost(e.cost)} for e in topo.topology.edges}
return result
class HighlightTopoDiff(StyleAnnotator):
idempotent = True
def __init__(self, _param): pass
def annotate(topo):
def annotate(self, topo):
topodiff = AnnotatorID(annotator=analysis.TopologyDifference)
topo.run_annotator(topodiff) # make sure
td_result = topo.annotations[topodiff]
@ -265,7 +266,7 @@ class HighlightCurrent(StyleAnnotator):
idempotent = False
def __init__(self, what):
self.what = what
def annotate(topo):
def annotate(self, topo):
result = Annotation()
if self.what is None:
# Not going to guess.
@ -275,7 +276,7 @@ class HighlightCurrent(StyleAnnotator):
topo.run_annotator(self.what)
current = topo.annotations[self.what]
if False: 'alignment'
elif self.what.annotator = analysis.ShortestPathTree:
elif self.what.annotator == analysis.ShortestPathTree:
# Highlight edges
result.for_edge = {e: {'highlight_colour': (200, 200, 0, 128)} for e in current.for_edge.keys()}
return result
@ -313,7 +314,7 @@ class MegaStyler(StyleAnnotator):
else:
self.detect = True
def annotate(topo):
def annotate(self, topo):
# First, set some base styles
edge_style = defaultdict(lambda: {
'width': 1,
@ -326,7 +327,7 @@ class MegaStyler(StyleAnnotator):
})
# Walk the annotators and collect the annotations
if not detect:
if not self.detect:
relevant_annotators = self.relevant_annotators
else:
# We will be iterating over this often, so this time it is not a set.

Loading…
Cancel
Save