Further simplify code

This commit is contained in:
XANTRONIX Industrial 2025-02-20 13:35:56 -05:00
parent 52978b267f
commit 44bd511347

View file

@ -3,8 +3,6 @@ import enum
import datetime
import shapely
from typing import Self
from nexrad.db import DatabaseTable
from nexrad.coord import COORD_SYSTEM
from nexrad.vtec import VTECEvent
@ -220,21 +218,26 @@ class AFOSMessageParser():
def parse_body(self, line: str):
if line == '&&':
self.state = AFOSMessageParserState.TAGS
elif self.timestamp is None:
match = RE_DATE.match(line)
return
if match is not None:
tzoffset = TIMEZONES[match['tz'].upper()]
if self.timestamp is not None:
return
self.timestamp = datetime.datetime(
year = int(match['year']),
month = MONTHS[match['month'].upper()],
day = int(match['day']),
hour = int(match['hour']),
minute = int(match['minute']),
second = 0,
tzinfo = datetime.timezone(datetime.timedelta(hours=tzoffset))
).astimezone(datetime.UTC)
match = RE_DATE.match(line)
if match is not None:
tzoffset = TIMEZONES[match['tz'].upper()]
tzinfo = datetime.timezone(datetime.timedelta(hours=tzoffset))
self.timestamp = datetime.datetime(
year = int(match['year']),
month = MONTHS[match['month'].upper()],
day = int(match['day']),
hour = int(match['hour']),
minute = int(match['minute']),
second = 0,
tzinfo = tzinfo
).astimezone(datetime.UTC)
def parse_tags(self, line: str):
if line == '$$':