Fixes bug when showing tags when no tags are defined.

Closes #63
This commit is contained in:
Manuel Ebert 2013-04-17 10:27:17 +02:00
parent b2a5b7b219
commit 8ed2e36669
2 changed files with 4 additions and 1 deletions

View file

@ -5,6 +5,7 @@ Changelog
* [Improved] Installs pycrypto by default * [Improved] Installs pycrypto by default
* [Improved] Removed clint in favour of colorama * [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 * [Fixed] Smaller fixes and typos
### 1.0.1 (March 12, 2013) ### 1.0.1 (March 12, 2013)

View file

@ -106,7 +106,9 @@ def print_tags(journal):
] ]
# To be read: [for entry in journal.entries: for tag in set(entry.tags): tag] # 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} 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) tag_counts = filter(lambda x: x[0] > 1, tag_counts)
print('[Removed tags that appear only once.]') print('[Removed tags that appear only once.]')
for n, tag in sorted(tag_counts, reverse=False): for n, tag in sorted(tag_counts, reverse=False):