Skip to content
Snippets Groups Projects
Commit 3f00bb00 authored by Daniele Serafini's avatar Daniele Serafini
Browse files

flat json output with known and swhid values

parent bbf296f7
No related branches found
Tags v0.1.1
No related merge requests found
......@@ -58,7 +58,7 @@ class Tree:
def show(self, format) -> None:
"""Show tree in different formats"""
if format == "json":
print(json.dumps(self.getTree(), indent=4, sort_keys=True))
print(json.dumps(self.toDict(), indent=4, sort_keys=True))
elif format == "text":
isatty = sys.stdout.isatty()
......@@ -157,27 +157,6 @@ class Tree:
if child_node.otype == DIRECTORY:
yield from child_node.iterate()
def getTree(self):
"""Walk through the tree to discover content or directory that have
a persistent identifier. If a persistent identifier is found it saves
the path with the relative PID.
Returns:
child_tree: the tree with the content/directory found
"""
child_tree = {}
for path, child_node in self.children.items():
rel_path = str(child_node.path.relative_to(self.path))
if child_node.swhid:
child_tree[rel_path] = child_node.swhid
else:
next_tree = child_node.getTree()
if next_tree:
child_tree[rel_path] = next_tree
return child_tree
def __getSubDirsInfo(self, root, directories):
"""Fills the directories given in input with the contents information
stored inside the directory child, only if they have contents.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment