Improve robustness of TTBB parser

This commit is contained in:
XANTRONIX 2025-03-30 13:16:56 -04:00
parent 14b06f9667
commit ee801726a8

View file

@ -407,7 +407,7 @@ class RAOBObs():
} }
def parse_ttbb_sample(self, tokens: list[str]) -> dict: def parse_ttbb_sample(self, tokens: list[str]) -> dict:
if tokens[0] == 'NIL': if len(tokens) < 2 or tokens[0] == 'NIL':
return {} return {}
hp = self.parse_pressure(tokens[0]) hp = self.parse_pressure(tokens[0])
@ -430,7 +430,10 @@ class RAOBObs():
station = self.tokens[1] station = self.tokens[1]
samples = list() samples = list()
i = 2 sample = self.parse_ttbb_sample(self.tokens[2:4])
samples.append(sample)
i = 4
while i < len(self.tokens): while i < len(self.tokens):
if self.tokens[i] == '21212': if self.tokens[i] == '21212':