Skip to content

Commit

Permalink
Added some debugging info to the summary
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-wilkins committed Oct 7, 2024
1 parent f07f261 commit aa13492
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sasdata/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from quantities.quantity import NamedQuantity
from sasdata.metadata import Metadata
from sasdata.quantities.accessors import AccessorTarget
from sasdata.data_backing import Group
from sasdata.data_backing import Group, key_tree


class SasData:
def __init__(self, name: str, data_contents: list[NamedQuantity], raw_metadata: Group):
Expand Down Expand Up @@ -33,4 +34,6 @@ def summary(self, indent = " "):
s += f"{indent}Metadata:\n"
s += self.metadata.summary()

s += key_tree(self._raw_metadata)

return s
16 changes: 16 additions & 0 deletions sasdata/data_backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,19 @@ def build_main_data(data: list[NamedQuantity]) -> Function:
pass
case _:
raise NotImplementedError("Unknown ")

def key_tree(data: Group | Dataset, indent_amount=0, indent: str = " ") -> str:
""" Show a metadata tree, showing the names of they keys used to access them"""
s = ""
if isinstance(data, Group):
for key in data.children:
s += indent*indent_amount + key + "\n"
s += key_tree(data.children[key], indent_amount=indent_amount+1, indent=indent)

if isinstance(data, Dataset):
s += indent*indent_amount + "[data]\n"
for key in data.attributes:
s += indent*indent_amount + key + "\n"
s += key_tree(data.attributes[key], indent_amount=indent_amount+1, indent=indent)

return s

0 comments on commit aa13492

Please sign in to comment.