From 8ed2e3666932456a85cfc4aba3354c1c03c82a4b Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Wed, 17 Apr 2013 10:27:17 +0200 Subject: [PATCH] Fixes bug when showing tags when no tags are defined. Closes #63 --- CHANGELOG.md | 1 + jrnl/jrnl.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f83c9c6a..c68a3ab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changelog * [Improved] Installs pycrypto by default * [Improved] Removed clint in favour of colorama +* [Fixed] Fixed a bug where showing tags failed when no tags are defined. * [Fixed] Smaller fixes and typos ### 1.0.1 (March 12, 2013) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 2de3fd16..ac3ba67e 100755 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -106,7 +106,9 @@ def print_tags(journal): ] # To be read: [for entry in journal.entries: for tag in set(entry.tags): tag] tag_counts = {(tags.count(tag), tag) for tag in tags} - if min(tag_counts)[0] == 0: + if not tag_counts: + print('[No tags found in journal.]') + elif min(tag_counts)[0] == 0: tag_counts = filter(lambda x: x[0] > 1, tag_counts) print('[Removed tags that appear only once.]') for n, tag in sorted(tag_counts, reverse=False):