Exemplo n.º 1
0
 def __delitem__(self, path):
     test = self._node[datapath(path)]
     if owner(test) == self._codelet.path:
         del self._node[datapath(path)]
     else:
         raise ValueError("%s trying to remove data created by %s"
                          % (str(self._codelet.path), str(owner(test))))
Exemplo n.º 2
0
 def __setitem__(self, path, value):
     path = datapath(path)
     needs_stamp = False
     if isinstance(value, (DataGroup, DatasetWrapper)):
         value = value._node
     else:
         needs_stamp = True
     self._node[path] = value
     if needs_stamp:
         node = self._node[path]
         stamp(node, "data", self._codelet.dependency_attributes())
Exemplo n.º 3
0
 def __getitem__(self, path_or_ref):
     if isstring(path_or_ref):
         path = datapath(path_or_ref)
     else:
         path = self._node[path_or_ref].name
         assert path.startswith('/data')
     path = path.split('/')
     if path[0] == '':
         # datapath() ensures that path must start with
         # ['', 'data'] in this case. Move up the parent
         # chain to the root of the /data hierarchy.
         path = path[2:]
         node = self
         while node is not node.parent:
             node = node.parent
     else:
         node = self
     for element in path:
         node = node._wrap_and_track_dependencies(node._node[element])
     return node
Exemplo n.º 4
0
 def require_dataset(self, path, *args, **kwargs):
     ds = self._node.require_dataset(datapath(path), *args, **kwargs)
     self._stamp_new_node(ds, "data")
     return DatasetWrapper(self, ds, self._codelet)
Exemplo n.º 5
0
 def require_group(self, path):
     group = self._node.require_group(datapath(path))
     self._stamp_new_node(group, "group")
     return DataGroup(self._paper, self, group,
                      self._codelet, self._data_item)