Пример #1
0
 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
Пример #2
0
 def _get_node(self, node_path):
     if self.closed:
         raise ValueError("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
Пример #3
0
 def _get_node(self, node_path):
     if self.closed:
         raise ValueError("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
Пример #4
0
 def _get_node(self, node_path):
     if self.closed:
         raise ValueError("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
Пример #5
0
 def _get_node(self, node_path):
     if self.closed:
         raise ValueError("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
Пример #6
0
 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: {}}
Пример #7
0
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))
Пример #8
0
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))