def _find_path(self, path: str) -> Optional[graph.CommandGraphNode]: """Find an object relative to the current node Finds and returns the command graph node that is defined relative to the current node. """ root = graph.CommandGraphRoot() if path.startswith("/") else self._current_node parts = [i for i in path.split("/") if i] return self._find_node(root, *parts)
def do_cd(self, arg) -> str: """Change to another path. Examples ======== cd layout/0 cd ../layout """ if arg is None: self._current_node = graph.CommandGraphRoot() return '/' next_node = self._find_path(arg) if next_node is not None: self._current_node = next_node return format_selectors(self._current_node.selectors) or '/' else: return "No such path."
def __init__(self, client: CommandInterface, completekey="tab") -> None: self._client = client self._current_node = graph.CommandGraphRoot() # type: graph.CommandGraphNode self._completekey = completekey self._builtins = [i[3:] for i in dir(self) if i.startswith("do_")]