Skip to content

Commit

Permalink
Adding some tests in _is_dmx to make it successfully fail if not a dmx
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasLecocq committed Nov 27, 2019
1 parent 9d776c5 commit 39584c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions obspy/io/dmx/core.py
Expand Up @@ -81,17 +81,21 @@ def _is_dmx(filename):
while fid.read(12): # we require at least 1 full structtag
fid.seek(-12, 1)
structtag = readstructtag(fid)
if structtag.id_struct == 7:
if int(structtag.len_struct) + int(structtag.len_data) <= 0:
return False
elif structtag.id_struct == 7:
descripttrace = readdescripttrace(fid)
UTCDateTime(descripttrace.begintime)
readdata(fid, descripttrace.length, descripttrace.datatype)
return True
else:
fid.seek(
int(structtag.len_struct) + int(structtag.len_data), 1)

except Exception:
return False
return True

# If it reaches this point, this means no id_struct=7 has been found
return False


def _read_dmx(filename, **kwargs):
Expand Down

0 comments on commit 39584c9

Please sign in to comment.