From 8aa71d62e5232ac75fd26b329506a31b66decafa Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 8 Jul 2012 01:30:21 +0200 Subject: [PATCH] fuzzy mac matching for wiki imports --- nodedb.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nodedb.py b/nodedb.py index 6d936c8..2d10464 100644 --- a/nodedb.py +++ b/nodedb.py @@ -22,6 +22,18 @@ class NodeDB: def get_nodes(self): return self._nodes + # this methods has evil side-effects! + # Better don't call it :-) + def maybe_node_by_fuzzy_mac(self, mac): + mac_a = mac.lower() + + for node in self._nodes: + for mac_b in node.macs: + if is_similar(mac_a, mac_b): + return node + + raise + def maybe_node_by_mac(self, macs): for node in self._nodes: for mac in macs: @@ -268,7 +280,7 @@ class NodeDB: continue try: - node = self.maybe_node_by_mac((data[0], )) + node = self.maybe_node_by_fuzzy_mac(data[0]) except: node = Node() node.add_mac(data[0])