Skip to content

Commit

Permalink
ENH: catch OSError in RockstarDataset._is_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Jul 20, 2023
1 parent 481f9cd commit fdac07b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions yt/frontends/rockstar/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def _set_code_unit_attributes(self):
def _is_valid(cls, filename: str, *args, **kwargs) -> bool:
if not filename.endswith(".bin"):
return False
with open(filename, mode="rb") as f:
header = fpu.read_cattrs(f, header_dt)

return header["magic"] == 18077126535843729616
try:
with open(filename, mode="rb") as f:
header = fpu.read_cattrs(f, header_dt)
except OSError:
return False
else:
return header["magic"] == 18077126535843729616

0 comments on commit fdac07b

Please sign in to comment.