示例#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 test_explode():
    assert core.explode('/') == []
    assert core.explode('boom') == ['boom']
    assert core.explode('/boom') == ['boom']
    assert core.explode('boom/kaboom') == ['boom', 'kaboom']
示例#7
0
def test_explode():
    assert core.explode('/') == []
    assert core.explode('boom') == ['boom']
    assert core.explode('/boom') == ['boom']
    assert core.explode('boom/kaboom') == ['boom', 'kaboom']