make attribute db private

This commit is contained in:
Nils Schneider 2012-05-12 14:57:25 +02:00
parent dcfcc9ff36
commit 5a2d480360

View file

@ -1,21 +1,19 @@
import json import json
class D3MapBuilder: class D3MapBuilder:
db = None
def __init__(self, db): def __init__(self, db):
self.db = db self._db = db
def build(self): def build(self):
output = dict() output = dict()
output['nodes'] = [{'group': x.group, 'name': x.name, output['nodes'] = [{'group': x.group, 'name': x.name,
'macs': ', '.join(x.macs) 'macs': ', '.join(x.macs)
} for x in self.db.get_nodes() if x.online] } for x in self._db.get_nodes() if x.online]
output['links'] = [{'source': x.pair[0], 'target': x.pair[1], output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
'distance': x.distance, 'distance': x.distance,
'strength': x.strength 'strength': x.strength
} for x in self.db.get_links()] } for x in self._db.get_links()]
return json.dumps(output) return json.dumps(output)