Plugin architecture

This commit is contained in:
Manuel Ebert 2014-09-27 15:07:22 -07:00
parent a1b5a4099e
commit 6fed042b8b
9 changed files with 287 additions and 188 deletions

14
jrnl/plugins/util.py Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env python
# encoding: utf-8
def get_tags_count(journal):
"""Returns a set of tuples (count, tag) for all tags present in the journal."""
# Astute reader: should the following line leave you as puzzled as me the first time
# I came across this construction, worry not and embrace the ensuing moment of enlightment.
tags = [tag
for entry in journal.entries
for tag in set(entry.tags)]
# To be read: [for entry in journal.entries: for tag in set(entry.tags): tag]
tag_counts = set([(tags.count(tag), tag) for tag in tags])
return tag_counts