Skip to content
Snippets Groups Projects
Commit 785b6d72 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Fix arrow direction, remove duplicate switch-switch lines

parent a7dcb35b
Branches
No related tags found
No related merge requests found
......@@ -94,11 +94,15 @@ def get_total_speed(links):
return sum(link.get_speed() for link in links if link.get_speed() is not None)
def group_links(links):
def _make_name(link):
return "{} {}".format(link.node_from, link.node_to)
def _make_name(link, invert=False):
name_from, name_to = link.node_from, link.node_to
if invert:
name_from, name_to = name_to, name_from
return "{} {}".format(name_from, name_to)
groups = {}
for link in links:
name = _make_name(link)
if _make_name(link, invert=True) not in groups:
groups[name] = groups.get(name, []) + [link]
result = []
for group in groups.values():
......@@ -252,7 +256,7 @@ class ConfigWriter:
def write_links(self, links):
self.write("LINK {}".format(",".join(link.name for link in links)))
self.write("NODES {} {}".format(links[0].node_from, links[0].node_to), 1)
self.write("NODES {} {}".format(links[0].node_to, links[0].node_from), 1)
self.write("TARGET {}".format(" ".join(
os.path.join(self.source_path, link.name + ".html")
for link in links)), 1)
......@@ -261,14 +265,6 @@ class ConfigWriter:
self.write("WIDTH {}".format(6 if total_speed == 2 else (8 if total_speed == 20 else 4)), 1)
self.write()
def write_link(self, link):
self.write("LINK {}".format(link.name))
self.write("NODES {} {}".format(link.node_from, link.node_to), 1)
# TODO: bandwidth
self.write("TARGET {}".format(
os.path.join(self.source_path, link.name + ".html")), 1)
self.write()
if __name__ == "__main__":
import argparse
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment