From 05f04fc272a2f0cba27574303a047778d67ed299 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Thu, 9 Jul 2020 20:29:45 +0200 Subject: [PATCH] single line: now newline for %-notation by default (#496) --- README.md | 2 +- lib/view/line.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dc70ddc..979540d 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ So, these two calls are the same: ``` $ curl wttr.in/London?format=3 London: ⛅️ +7⁰C - $ curl wttr.in/London?format="%l:+%c+%t" + $ curl wttr.in/London?format="%l:+%c+%t\n" London: ⛅️ +7⁰C ``` Keep in mind, that when using in `tmux.conf`, you have to escape `%` with `%`, i.e. write there `%%` instead of `%`. diff --git a/lib/view/line.py b/lib/view/line.py index 358aacf..24da1a2 100644 --- a/lib/view/line.py +++ b/lib/view/line.py @@ -31,10 +31,10 @@ from . import v2 from . import prometheus PRECONFIGURED_FORMAT = { - '1': u'%c %t', - '2': u'%c 🌡️%t 🌬️%w', - '3': u'%l: %c %t', - '4': u'%l: %c 🌡️%t 🌬️%w', + '1': r'%c %t\n', + '2': r'%c 🌡️%t 🌬️%w\n', + '3': r'%l: %c %t\n', + '4': r'%l: %c 🌡️%t 🌬️%w\n', } MOON_PHASES = ( @@ -305,7 +305,7 @@ def render_line(line, data, query): return '' - template_regexp = r'%[^%]*[a-zA-Z]' + template_regexp = r'%[a-zA-Z]' for template_code in re.findall(template_regexp, line): if template_code.lstrip("%") in FORMAT_SYMBOL_ASTRO: local_time_of = get_local_time_of() @@ -358,7 +358,7 @@ def wttr_line(query, parsed_query): data = get_weather_data(location, lang) output = format_weather_data(query, parsed_query, data) - return output.rstrip("\n")+"\n" + return output.rstrip("\n").replace(r"\n", "\n") def main(): """