From bb04320b47d782d11a176af02cf9ee40bbc1c5c7 Mon Sep 17 00:00:00 2001 From: fitnr Date: Sun, 1 Jan 2017 23:40:01 -0500 Subject: [PATCH] fixup --- buoyant/buoy.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buoyant/buoy.py b/buoyant/buoy.py index 143bca7..259b1bd 100644 --- a/buoyant/buoy.py +++ b/buoyant/buoy.py @@ -17,6 +17,7 @@ from io import BytesIO, StringIO import requests from pytz import utc +from . import properties, timezone # Both take station as a GET argument. OBS_ENDPOINT = "http://sdf.ndbc.noaa.gov/sos/server.php" @@ -34,7 +35,9 @@ def parse_unit(prop, dictionary): + '''Do a fuzzy match for `prop` in the dictionary, taking into account unit suffix.''' matches = [k for k in dictionary.keys() if prop in k] + try: value = dictionary[matches[0]] unit = re.search(r' \(([^)]+)\)', matches[0]) @@ -112,6 +115,7 @@ def fetch(self, observation): reader = csv.DictReader(StringIO(request.text)) if observation in ('currents', 'waves', 'winds'): + return _degroup(reader, getattr(properties, observation)) else: result = next(reader)