def _get_node(self, node_path): core.validate_node_path(node_path) if node_path.startswith(core.NODE_PATH_SEPARATOR): node_path = node_path[1:] node = self._root for name in core.explode(node_path): node = node[self._node][name] return node
def create_node(self, node_path): """ Create a node at the end of the given path; all but the final node in the path must already exist. """ core.validate_node_path(node_path) existing, new = core.split(node_path) existing_node = self._get_node(existing) existing_node[self._node][new] = {self._node: {}, self._array: {}}
def _get_node(self, node_path): if self.closed: raise OSError("I/O operation on closed file") node = self._root if node_path != '': core.validate_node_path(node_path) for name in core.explode(node_path): node = node.groups[name] return node
def _get_node(self, node_path): if self.closed: raise IOError("I/O operation on closed file") if node_path != '': core.validate_node_path(node_path) full_path = os.path.join(self._root, *core.explode(node_path)) if not os.path.isdir(full_path): raise ValueError("Invalid path: {}".format(full_path)) return full_path
def test_validate_node_path(): for bad in utilities.bad_node_paths: try: core.validate_node_path(bad) raise AssertionError( "Invalid path {} should have failed".format(bad)) except core.MeasurementError: pass for good in utilities.good_node_paths: try: core.validate_node_path(good) except core.MeasurementError: raise AssertionError( "Valid path {} should not have failed.".format(good))