From 7ec28c3a0abc6ad1a290070f40c8de8af7f7a6d0 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 21 Aug 2016 11:21:27 +0200 Subject: [PATCH] Simplify logic in get_edges_for_peers. --- scripts/sendGraph.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/sendGraph.py b/scripts/sendGraph.py index e7ae3bc..a6bb9b3 100755 --- a/scripts/sendGraph.py +++ b/scripts/sendGraph.py @@ -215,12 +215,8 @@ def get_edges_for_peers(edges, peers, node_ip): for peer_key in peers: peer_ip = key_utils.to_ipv6(peer_key) - if node_ip > peer_ip: - A = node_ip - B = peer_ip - else: - A = peer_ip - B = node_ip + A = max(node_ip, peer_ip) + B = min(node_ip, peer_ip) edge = { 'a': A, 'b': B } @@ -228,8 +224,8 @@ def get_edges_for_peers(edges, peers, node_ip): if A not in edges: edges[A] = [] - if not([True for edge in edges[A] if edge['b'] == B]): - edges[A] += [edge] + if not any(edge['b'] == B for edge in edges[A]): + edges[A].append(edge) def send_graph(nodes, edges):