1. Ben Bangert
  2. tinkerer

Commits

Ben Bangert  committed 9eb8996

Prune empty/bad categories

  • Participants
  • Parent commits 6cd0522
  • Branches default

Comments (0)

Files changed (1)

File tinkerer/ext/metadata.py

View file
             tags[tag[1]] += 1
         for cat in p.filing["categories"]:
             categories[cat[1]] += 1
+
+    # Prune empty/bad categories
+    for cat in categories.keys():
+        if categories[cat] < 1:
+            categories.pop(cat)
+        if not cat:
+            categories.pop(cat)
+
     context["tags"] = tags
     context["taglinks"] = taglinks
     context["categories"] = categories