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