mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Modernised tag count syntax, Python 3 idioms galore!
This commit is contained in:
parent
cfbfcbc50b
commit
f96d73d2e1
1 changed files with 3 additions and 7 deletions
10
jrnl.py
10
jrnl.py
|
@ -457,13 +457,9 @@ if __name__ == "__main__":
|
||||||
print(journal)
|
print(journal)
|
||||||
|
|
||||||
elif args.tags: # get all tags
|
elif args.tags: # get all tags
|
||||||
tags = {}
|
tags = [tag for entry in journal.entries for tag in set(entry.tags)]
|
||||||
for entry in journal.entries:
|
tag_counts = {(tags.count(tag), tag) for tag in tags}
|
||||||
for tag in entry.tags:
|
for n, tag in sorted(tag_counts, reverse=True):
|
||||||
tags[tag] = tags.get(tag, 0) + 1
|
|
||||||
tags = [(n, tag) for tag, n in tags.viewitems()]
|
|
||||||
tags.sort(reverse=True)
|
|
||||||
for n, tag in tags:
|
|
||||||
print "%-20s : %d" % (tag, n)
|
print "%-20s : %d" % (tag, n)
|
||||||
|
|
||||||
elif args.json: # export to json
|
elif args.json: # export to json
|
||||||
|
|
Loading…
Add table
Reference in a new issue