summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattori Birnbaum <mattori.birnbaum@gmail.com>2021-05-07 20:48:51 +0900
committerChristian Geier <geier@lostpackets.de>2023-10-28 16:40:56 +0200
commit1dc28db8bb1492fd286c48eaa0fe4a60bc73cc6f (patch)
tree7f10262290f8a4e5676b62b3311b2ee53ac19459
parentd6b209cef316c0f463a56c7ad40818f24483112a (diff)
fix search formatter usage
-rw-r--r--khal/cli.py2
-rw-r--r--khal/controllers.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/khal/cli.py b/khal/cli.py
index e014c413..99e60ea7 100644
--- a/khal/cli.py
+++ b/khal/cli.py
@@ -614,7 +614,7 @@ def _get_cli():
env = {"calendars": ctx.obj['conf']['calendars']}
for event in events:
desc = textwrap.wrap(controllers.human_formatter(format)(
- event.format(relative_to=now, env=env), term_width))
+ event.format(relative_to=now, env=env)), term_width)
event_column.extend(
[colored(d, event.color,
bold_for_light_color=ctx.obj['conf']['view']['bold_for_light_color'])
diff --git a/khal/controllers.py b/khal/controllers.py
index 03a04bae..1239c2be 100644
--- a/khal/controllers.py
+++ b/khal/controllers.py
@@ -76,6 +76,9 @@ def format_day(day: dt.date, format_string: str, locale, attributes=None):
def human_formatter(format_string, width=None):
def fmt(rows):
+ single = type(rows) == dict
+ if single:
+ rows = [rows]
results = []
for row in rows:
s = format_string.format(**row) + style('', reset=True)
@@ -83,7 +86,10 @@ def human_formatter(format_string, width=None):
results += utils.color_wrap(s, width)
else:
results.append(s)
- return results
+ if single:
+ return results[0]
+ else:
+ return results
return fmt