6fc1423124
This commit makes Nodes special dicts that return None-like objects for inexistent keys, making it a dynamic attribute store. Also, it removes the D3MapBuilder and moves its logic to the Node and Link classes' newly introduced export() method. Only they need to be changed to populate the final nodes.json with more attributes.
25 lines
525 B
Python
25 lines
525 B
Python
class Link():
|
|
def __init__(self):
|
|
self.id = None
|
|
self.source = LinkConnector()
|
|
self.target = LinkConnector()
|
|
self.quality = None
|
|
self.type = None
|
|
|
|
def export(self):
|
|
return {
|
|
'source': self.source.id,
|
|
'target': self.target.id,
|
|
'quality': self.quality,
|
|
'type': self.type,
|
|
'id': self.id
|
|
}
|
|
|
|
class LinkConnector():
|
|
def __init__(self):
|
|
self.id = None
|
|
self.interface = None
|
|
|
|
def __repr__(self):
|
|
return "LinkConnector(%d, %s)" % (self.id, self.interface)
|