From 9a72e04ec7ed328542e57753a3833999398892e7 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Tue, 23 Apr 2019 17:31:46 +0200 Subject: [PATCH] pressure (P) and precipitation (p) (fixes #293) --- README.md | 2 ++ lib/wttr_line.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) 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):