Skip to content

Commit

Permalink
NPI-3290 raise a clearer error (referencing the source file if possib…
Browse files Browse the repository at this point in the history
…le) when an empty Sinex header is encountered
  • Loading branch information
treefern committed May 6, 2024
1 parent 78fb403 commit 2a8802d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gnssanalysis/gn_io/sinex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def _get_snx_header(path_or_bytes):
header_begin = snx_bytes.find(b"%=SNX")
header_end = snx_bytes.find(b"\n", header_begin)
snx_hline = snx_bytes[header_begin:header_end].decode()
if len(snx_hline) == 0: # Raise an inteligible error if the Sinex header is effectively empty.
# Is the source bytes, or a path / str path? If not bytes, we can output it.
if isinstance(path_or_bytes, bytes):
raise ValueError(f"Sinex header is empty for UNKNOWN file (passed in as bytes object not path)")
else:
raise ValueError(f"Sinex header is empty for file: '{str(path_or_bytes)}'")
dates = _gn_datetime.yydoysec2datetime([snx_hline[15:27], snx_hline[32:44], snx_hline[45:57]]).tolist()
return {
"version": float(snx_hline[6:10]),
Expand Down

0 comments on commit 2a8802d

Please sign in to comment.