From d23736d0f58c6b619159ad40957d0aa54986fa3f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 May 2012 14:12:41 +0200 Subject: [PATCH] move Link and Node to seperate files --- bat2nodes.py | 27 +++------------------------ link.py | 6 ++++++ node.py | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 link.py create mode 100644 node.py diff --git a/bat2nodes.py b/bat2nodes.py index 736336f..8fd5cb6 100644 --- a/bat2nodes.py +++ b/bat2nodes.py @@ -8,6 +8,9 @@ import json import fileinput import argparse +from node import Node +from link import Link + parser = argparse.ArgumentParser() parser.add_argument('-a', '--aliases', @@ -27,30 +30,6 @@ aliases = dict() links = set() nodes = [] -class Node(): - def __init__(self): - self.name = "" - self.macs = set() - self.group = 0 - self.online = False - # groups: - # 0 normal node - # 1 aftermath - # 2 gateways - # 3 TT - - def add_mac(self, mac): - self.macs.add(mac) - - def __repr__(self): - return self.macs.__repr__() - -class Link(): - def __init__(self): - self.pair = None - self.distance = None - self.strength = None - def maybe_node_by_mac(nodes, macs): for node in nodes: for mac in macs: diff --git a/link.py b/link.py new file mode 100644 index 0000000..c69b141 --- /dev/null +++ b/link.py @@ -0,0 +1,6 @@ +class Link(): + def __init__(self): + self.pair = None + self.distance = None + self.strength = None + diff --git a/node.py b/node.py new file mode 100644 index 0000000..a77b060 --- /dev/null +++ b/node.py @@ -0,0 +1,19 @@ +class Node(): + def __init__(self): + self.name = "" + self.macs = set() + self.group = 0 + self.online = False + # groups: + # 0 normal node + # 1 aftermath + # 2 gateways + # 3 TT + + def add_mac(self, mac): + self.macs.add(mac) + + def __repr__(self): + return self.macs.__repr__() + +