From 6448b401df2643228cc9043cf4f5cb81b5da32e8 Mon Sep 17 00:00:00 2001 From: Septs Date: Sat, 23 May 2020 19:32:58 +0800 Subject: [PATCH] update peer-table to readme --- scripts/roa-ng.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/roa-ng.py b/scripts/roa-ng.py index 5c1b12b..95a4e9b 100755 --- a/scripts/roa-ng.py +++ b/scripts/roa-ng.py @@ -255,13 +255,17 @@ def make_summary(): print("AS{:<15}{}".format(asn, name)) print() print("Peer table:") - peers = list(iter_toml_file("peer")) - maxUpstreamLength = max(map(lambda item: len(item[0].stem), peers)) - print("{:>{}} ~ {}".format("Upstream", maxUpstreamLength, "Downstream")) - for item, entities in peers: - upstream = item.stem - for downstream in sorted(entities["to-peer"], key=str.lower): - print("{:>{}} ~ {}".format(upstream, maxUpstreamLength, downstream)) + peers = { + item.stem: entity["to-peer"] for item, entity in iter_toml_file("peer") + } + peers = [ + (upstream, downstream) + for upstream, downstream_list in peers.items() + for downstream in downstream_list + ] + print("{:>20} ~ {}".format("Upstream", "Downstream")) + for upstream, downstream in peers: + print("{:>20} ~ {}".format(upstream, downstream)) print() print("Route table:") print("{:17}{:30}{:30}{}".format("ASN", "Name", "Prefix", "Supernet"))