Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/shacl2code/lang/templates/python/cmd.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import argparse
from pathlib import Path
from typing import Any, Iterable, List
from typing import Any

from .model import (
DataPath,
JSONLDDeserializer,
JSONLDSerializer,
ListProxy,
Expand All @@ -17,13 +18,13 @@ from .model import (
)


def print_tree(objects: Iterable[SHACLObject], all_fields: bool = False) -> None:
def print_tree(objectset: SHACLObjectSet, all_fields: bool = False) -> None:
"""
Print object tree
"""
seen = set()

def callback(value: Any, path: List[str]) -> bool:
def callback(value: Any, path: DataPath) -> bool:
s = (" " * (len(path) - 1)) + f"{path[-1]}"
if isinstance(value, SHACLObject):
s += f" {value} ({id(value)})"
Expand All @@ -47,8 +48,7 @@ def print_tree(objects: Iterable[SHACLObject], all_fields: bool = False) -> None

return True

for o in objects:
o.walk(callback)
objectset.walk(callback)


def main() -> int:
Expand All @@ -65,7 +65,7 @@ def main() -> int:
d.read(f, objectset)

if args.print:
print_tree(objectset.objects)
print_tree(objectset)

if args.outfile:
with args.outfile.open("wb") as f:
Expand Down
Loading
Loading