xtensa-build-zephyr.py: don't make "." a special case in tree listing

Small simplification.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2022-10-18 04:07:39 +00:00 committed by Kai Vehmanen
parent 0497212dca
commit a42592eda1
1 changed files with 6 additions and 9 deletions

View File

@ -294,7 +294,7 @@ def execute_command(*run_args, **run_kwargs):
def show_installed_files():
"""[summary] Scans output directory building binary tree from files and folders
then presents them in similar way to linux tree command."""
graph_root = AnyNode(name=STAGING_DIR.name, long_name=STAGING_DIR.name, parent=None)
graph_root = AnyNode(name=STAGING_DIR.name, long_name=".", parent=None)
relative_entries = [
entry.relative_to(STAGING_DIR) for entry in sorted(STAGING_DIR.glob("**/*"))
]
@ -302,14 +302,11 @@ def show_installed_files():
for entry in relative_entries:
# Node's documentation does allow random attributes
# pylint: disable=no-member
if str(entry.parent) == ".":
nodes.append(AnyNode(name=entry.name, long_name=str(entry), parent=graph_root))
else:
# sorted() makes sure our parent is already there.
# This is slightly awkward, a recursive function would be more readable
matches = [node for node in nodes if node.long_name == str(entry.parent)]
assert len(matches) == 1, f'"{entry}" does not have exactly one parent'
nodes.append(AnyNode(name=entry.name, long_name=str(entry), parent=matches[0]))
# sorted() makes sure our parent is already there.
# This is slightly awkward, a recursive function would be more readable
matches = [node for node in nodes if node.long_name == str(entry.parent)]
assert len(matches) == 1, f'"{entry}" does not have exactly one parent'
nodes.append(AnyNode(name=entry.name, long_name=str(entry), parent=matches[0]))
for pre, _, node in RenderTree(graph_root):
print(f"{pre}{node.name}")