Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the possibility to unroll the scientific metadata tree from a particular point #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions pyscicat/hdf5/scientific_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def unwind(


def scientific_metadata(
filename, excludeRootEntry: bool = True, skipKeyList: list = []
filename, excludeRootEntry: bool = True, skipKeyList: list = [], startPath:str="/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake8 is probably going to want spaces around the =

) -> dict:
"""
Goals:
Expand All @@ -106,6 +106,7 @@ def scientific_metadata(
scientificMetadata=scientific_metadata(Path('./my_file.h5'), skipKeyList=['sasdata1'])
If the root branch is singular, it can be omitted from the output dictionary by setting
excludeRootEntry to True
The start path from where to traverse the tree can be specified with the "startPath" argument.

"""
# ensure the filename argument is of class Path
Expand All @@ -116,7 +117,7 @@ def scientific_metadata(
with h5py.File(filename, "r") as h5f:
# let's see if we can do this simpler
metadata = dict() # .fromkeys(prior_keys)
unwind(h5f, "/", metadata, skipKeyList=skipKeyList)
unwind(h5f, startPath, metadata, skipKeyList=skipKeyList)

# first metadata entry is empty, so enter one level deeper.
if len(metadata.keys()) == 1 and list(metadata.keys())[0] == "":
Expand Down