Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
fitnr committed Jan 2, 2017
1 parent ed850c2 commit bb04320
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions buoyant/buoy.py
Expand Up @@ -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"
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bb04320

Please sign in to comment.