diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2013-08-11 19:18:44 +0300 |
---|---|---|
committer | Sergei Trofimovich <slyfox@gentoo.org> | 2013-08-11 19:18:44 +0300 |
commit | fd17a73ec470807adf1b21b6e328642f1a912aee (patch) | |
tree | b1274aac77f577b1913f79df6116f90e2c6808a0 /src/Plugins | |
parent | 99069c2fe2c1af51224ca204c15705d5f7f076fa (diff) | |
download | xmobar-fd17a73ec470807adf1b21b6e328642f1a912aee.tar.gz xmobar-fd17a73ec470807adf1b21b6e328642f1a912aee.tar.bz2 |
Plugins.Monitors.Weather: fix parsing of unknown station name
reported by thunderrd
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'src/Plugins')
-rw-r--r-- | src/Plugins/Monitors/Weather.hs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/Plugins/Monitors/Weather.hs b/src/Plugins/Monitors/Weather.hs index 1277438..6c685ec 100644 --- a/src/Plugins/Monitors/Weather.hs +++ b/src/Plugins/Monitors/Weather.hs @@ -89,11 +89,28 @@ pPressure = do manyTill anyChar $ char '(' skipRestOfLine return $ read s +{- + example of 'http://weather.noaa.gov/pub/data/observations/metar/decoded/VTUD.TXT': + Station name not available + Aug 11, 2013 - 10:00 AM EDT / 2013.08.11 1400 UTC + Wind: from the N (350 degrees) at 1 MPH (1 KT):0 + Visibility: 4 mile(s):0 + Sky conditions: mostly clear + Temperature: 77 F (25 C) + Dew Point: 73 F (23 C) + Relative Humidity: 88% + Pressure (altimeter): 29.77 in. Hg (1008 hPa) + ob: VTUD 111400Z 35001KT 8000 FEW030 25/23 Q1008 A2977 INFO R RWY30 + cycle: 14 +-} parseData :: Parser [WeatherInfo] parseData = - do st <- getAllBut "," - space - ss <- getAllBut "(" + do (st, ss) <- try (string "Station name not available" >> return ("??", "??")) <|> + (do st <- getAllBut "," + space + ss <- getAllBut "(" + return (st, ss) + ) skipRestOfLine >> getAllBut "/" (y,m,d,h) <- pTime w <- getAfterString "Wind: " |