diff --git a/catcli/noder.py b/catcli/noder.py index 15f53e8..cab21cc 100644 --- a/catcli/noder.py +++ b/catcli/noder.py @@ -376,6 +376,26 @@ class Noder: if len(line) > 0: Logger.stdout_nocolor(line) + def node_has_subs(self, node: Any) -> bool: + """ + node may have children + we explicitely handle all case + for clarity + """ + if not node: + return False + if node.type == nodes.TYPE_TOP: + return True + if node.type == nodes.TYPE_FILE: + return False + if node.type == nodes.TYPE_DIR: + return True + if node.type == nodes.TYPE_STORAGE: + return True + if node.type == nodes.TYPE_ARCHIVED: + return True + return False + def _print_node_native(self, node: NodeAny, pre: str = '', withpath: bool = False, @@ -678,8 +698,20 @@ class Noder: resolv = anytree.resolver.Resolver('name') found = [] try: - # resolve the path in the tree - found = resolv.glob(top, path) + if '*' in path or '?' in path: + # we need to handle glob + found = resolv.glob(top, path) + else: + # we have a canonical path + found = resolv.get(top, path) + if found and self.node_has_subs(found): + # let's find its children as well + print(path) + modpath = os.path.join(path, '*') + found = resolv.glob(top, modpath) + else: + found = [found] + if len(found) < 1: # nothing found self._debug('nothing found') diff --git a/catcli/utils.py b/catcli/utils.py index 4dca31b..60d07d1 100644 --- a/catcli/utils.py +++ b/catcli/utils.py @@ -41,9 +41,9 @@ def path_to_search_all(path: str) -> str: if not path.endswith(os.path.sep): # ensure ends with a separator path += os.path.sep - if not path.endswith(WILD): - # add wild card - path += WILD + # if not path.endswith(WILD): + # # add wild card + # path += WILD return path