mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-30 06:26:14 +02:00
14 lines
604 B
Python
14 lines
604 B
Python
#!/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
|