Further simplify code
This commit is contained in:
parent
52978b267f
commit
44bd511347
1 changed files with 18 additions and 15 deletions
|
@ -3,8 +3,6 @@ import enum
|
||||||
import datetime
|
import datetime
|
||||||
import shapely
|
import shapely
|
||||||
|
|
||||||
from typing import Self
|
|
||||||
|
|
||||||
from nexrad.db import DatabaseTable
|
from nexrad.db import DatabaseTable
|
||||||
from nexrad.coord import COORD_SYSTEM
|
from nexrad.coord import COORD_SYSTEM
|
||||||
from nexrad.vtec import VTECEvent
|
from nexrad.vtec import VTECEvent
|
||||||
|
@ -220,21 +218,26 @@ class AFOSMessageParser():
|
||||||
def parse_body(self, line: str):
|
def parse_body(self, line: str):
|
||||||
if line == '&&':
|
if line == '&&':
|
||||||
self.state = AFOSMessageParserState.TAGS
|
self.state = AFOSMessageParserState.TAGS
|
||||||
elif self.timestamp is None:
|
return
|
||||||
match = RE_DATE.match(line)
|
|
||||||
|
|
||||||
if match is not None:
|
if self.timestamp is not None:
|
||||||
tzoffset = TIMEZONES[match['tz'].upper()]
|
return
|
||||||
|
|
||||||
self.timestamp = datetime.datetime(
|
match = RE_DATE.match(line)
|
||||||
year = int(match['year']),
|
|
||||||
month = MONTHS[match['month'].upper()],
|
if match is not None:
|
||||||
day = int(match['day']),
|
tzoffset = TIMEZONES[match['tz'].upper()]
|
||||||
hour = int(match['hour']),
|
tzinfo = datetime.timezone(datetime.timedelta(hours=tzoffset))
|
||||||
minute = int(match['minute']),
|
|
||||||
second = 0,
|
self.timestamp = datetime.datetime(
|
||||||
tzinfo = datetime.timezone(datetime.timedelta(hours=tzoffset))
|
year = int(match['year']),
|
||||||
).astimezone(datetime.UTC)
|
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):
|
def parse_tags(self, line: str):
|
||||||
if line == '$$':
|
if line == '$$':
|
||||||
|
|
Loading…
Add table
Reference in a new issue