Skip to content

Commit

Permalink
Simplify metadata handling
Browse files Browse the repository at this point in the history
  • Loading branch information
moble committed Sep 6, 2024
1 parent 60ac710 commit 4c41014
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def invalid(message):
# This means we need to change the suffix *before* the resolve() call.
h5_path = pathlib.Path(file_name_str).with_suffix(".h5").expanduser().resolve()
json_path = pathlib.Path(file_name_str).with_suffix(".json").expanduser().resolve()
metadata_path = (pathlib.Path(file_name_str).parent / "metadata.json").expanduser().resolve()
metadata_path = (pathlib.Path(file_name_str).parent / "metadata").expanduser().resolve()

# This will be used for validation
h5_size = h5_path.stat().st_size
Expand Down Expand Up @@ -571,12 +571,10 @@ def invalid(message):
w = w.to_inertial_frame()

if metadata is None:
if metadata_path.exists():
try:
metadata = Metadata.from_file(metadata_path)
elif metadata_path.with_suffix(".txt").exists():
metadata = Metadata.from_file(metadata_path.with_suffix(".txt"))
else:
invalid(f"\nMetadata files {metadata_path}/.txt cannot be found, but at least one is expected for this data format.")
except ValueError as e:
invalid(f"\n{e},\nbut one is expected for this data format.")

dtb = kwargs.pop("drop_times_before", 0)
if dtb=="begin":
Expand Down

0 comments on commit 4c41014

Please sign in to comment.