diff --git a/README.md b/README.md index 2ed9403..fb10479 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ To specify your own custom output format, use the special `%`-notation: l Location, m Moonphase 🌑🌒🌓🌔🌕🌖🌗🌘, M Moonday, + p precipitation (mm), + P pressure (hPa), ``` So, these two calls are the same: diff --git a/lib/wttr_line.py b/lib/wttr_line.py index 7db0c78..50786cd 100644 --- a/lib/wttr_line.py +++ b/lib/wttr_line.py @@ -89,6 +89,26 @@ def render_humidity(data, query): humidity += '%' return humidity +def render_precipitation(data, query): + """ + precipitation (p) + """ + + answer = data.get('precipMM', '') + if answer: + answer += 'mm' + return answer + +def render_pressure(data, query): + """ + pressure (P) + """ + + answer = data.get('pressure', '') + if answer: + answer += 'hPa' + return answer + def render_wind(data, query): """ wind (w) @@ -166,6 +186,8 @@ FORMAT_SYMBOL = { 'm': render_moonphase, 'M': render_moonday, 's': render_sunset, + 'p': render_precipitation, + 'P': render_pressure, } def render_line(line, data, query):