def __init__(self, nodeMap): """ Make a Resource Node from either a collection or a plain senml """ if v._l in nodeMap: self._links = Links(nodeMap[v._l]) else: self._links = Links() self._items = SenmlItems(nodeMap[v._e]) self._baseName = nodeMap[v._bn] self._resource = SenmlCollection(self._links.get(), self._items._items, self._baseName)
class ResourceNode: def __init__(self, nodeMap): """ Make a Resource Node from either a collection or a plain senml """ if v._l in nodeMap: self._links = Links(nodeMap[v._l]) else: self._links = Links() self._items = SenmlItems(nodeMap[v._e]) self._baseName = nodeMap[v._bn] self._resource = SenmlCollection(self._links.get(), self._items._items, self._baseName) def addLinks(self, links): self._resource.addLinks(links) def addItems(self, items): self._resource.addItems(items) def serialize(self): return self._resource.serialize() def load(self, jsonString): self._resource.load(jsonString) return self def getModel(self): return self._resource._senml