mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-30 14:36:13 +02:00
Plugin architecture
This commit is contained in:
parent
a1b5a4099e
commit
6fed042b8b
9 changed files with 287 additions and 188 deletions
14
jrnl/plugins/util.py
Normal file
14
jrnl/plugins/util.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue