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

Return can_read as False if no nwbfile version is found #1934

Merged
merged 6 commits into from
Jul 18, 2024
Merged
Changes from 1 commit
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
Next Next commit
add can_read catch if no nwb_version found
stephprince committed Jul 15, 2024
commit 5ede441b66e03b09c71432e3c1de4c1a7aedbb8d
6 changes: 5 additions & 1 deletion src/pynwb/__init__.py
Original file line number Diff line number Diff line change
@@ -269,7 +269,11 @@ def can_read(path: str):
return False
try:
with h5py.File(path, "r") as file: # path is HDF5 file
return get_nwbfile_version(file)[1][0] >= 2 # Major version of NWB >= 2
version_info = get_nwbfile_version(file)
if version_info[0] is None:
return False
else:
return version_info[1][0] >= 2 # Major version of NWB >= 2
except IOError:
return False