From a368b622c5203e06887f6a3d2881e59b779db1f6 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 26 Sep 2019 06:44:34 -0500 Subject: [PATCH] Adding Probability of Precipitation to one-line output --- README.md | 1 + lib/wttr_line.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 10d8683..159e744 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ To specify your own custom output format, use the special `%`-notation: m Moonphase 🌑🌒🌓🌔🌕🌖🌗🌘, M Moonday, p precipitation (mm), + o Probability of Precipitation, P pressure (hPa), ``` diff --git a/lib/wttr_line.py b/lib/wttr_line.py index 5ede450..48fb6a1 100644 --- a/lib/wttr_line.py +++ b/lib/wttr_line.py @@ -101,6 +101,16 @@ def render_precipitation(data, query): answer += 'mm' return answer +def render_precipitation_chance(data, query): + """ + precipitation chance (o) + """ + + answer = data.get('chanceofrain', '') + if answer: + answer += '%' + return answer + def render_pressure(data, query): """ pressure (P) @@ -189,6 +199,7 @@ FORMAT_SYMBOL = { 'M': render_moonday, 's': render_sunset, 'p': render_precipitation, + 'o': render_precipitation_chance, 'P': render_pressure, }