Skip to content

Commit

Permalink
Fix for crash reading in textual UVOT mode (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jak574 authored Nov 13, 2024
1 parent 7d24f58 commit 2e8333d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions swifttools/swift_too/swift_instruments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Lookup table for XRT modes
import re


XRTMODES = {
0: "Auto",
1: "Null",
Expand Down Expand Up @@ -42,6 +45,11 @@ class TOOAPI_Instruments:
def uvot_mode_setter(self, attr, mode):
if type(mode) == str and "0x" in mode:
"""Convert hex string to int"""
uvot_mode = re.match(r"0x([0-9a-fA-F]+)", mode)
if uvot_mode is not None:
setattr(self, f"_{attr}", int(uvot_mode.group(0), 16))
else:
setattr(self, f"_{attr}", mode)
setattr(self, f"_{attr}", int(mode.split(":")[0], 16))
elif type(mode) == str:
"""Convert decimal string to int"""
Expand Down

0 comments on commit 2e8333d

Please sign in to comment.