avoid overriding weather dict keys
This commit is contained in:
parent
5530c96f8e
commit
b24e56803c
10
owrx/aprs.py
10
owrx/aprs.py
@ -105,12 +105,13 @@ class WeatherParser(object):
|
|||||||
WeatherMapping("s", "snowfall", 3, lambda x: x * 25.4),
|
WeatherMapping("s", "snowfall", 3, lambda x: x * 25.4),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data, weather={}):
|
||||||
self.data = data
|
self.data = data
|
||||||
|
self.weather = weather
|
||||||
|
|
||||||
def getWeather(self):
|
def getWeather(self):
|
||||||
doWork = True
|
doWork = True
|
||||||
weather = {}
|
weather = self.weather
|
||||||
while doWork:
|
while doWork:
|
||||||
mapping = next((m for m in WeatherParser.mappings if m.matches(self.data)), None)
|
mapping = next((m for m in WeatherParser.mappings if m.matches(self.data)), None)
|
||||||
if mapping:
|
if mapping:
|
||||||
@ -343,10 +344,9 @@ class AprsParser(object):
|
|||||||
pass
|
pass
|
||||||
comment = comment[7:]
|
comment = comment[7:]
|
||||||
|
|
||||||
parser = WeatherParser(comment)
|
parser = WeatherParser(comment, weather)
|
||||||
weather.update(parser.getWeather())
|
aprsData["weather"] = parser.getWeather()
|
||||||
comment = parser.getRemainder()
|
comment = parser.getRemainder()
|
||||||
aprsData["weather"] = weather
|
|
||||||
elif len(comment) > 6:
|
elif len(comment) > 6:
|
||||||
if comment[3] == "/":
|
if comment[3] == "/":
|
||||||
# course and speed
|
# course and speed
|
||||||
|
Loading…
Reference in New Issue
Block a user