From 606537d959e142c3267906c646dcf20f61b2fbd7 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Fri, 12 Feb 2021 10:13:34 -0800 Subject: [PATCH] Fix category and topic building --- redstring/library.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/redstring/library.py b/redstring/library.py index 6982937..0579b6c 100644 --- a/redstring/library.py +++ b/redstring/library.py @@ -17,16 +17,18 @@ def generate_index_document(directory: str) -> Document: document: Document = load(f) # Check if this document specifies a tab, and create it if necessary. - category = document.get_tag('category') - if not category: + if category_tag := document.get_tag('category'): + category = category_tag.value + else: category = 'index' if category not in categories: categories[category] = {} category_tab = categories[category] # Check if this document specifies a topic, and create it if necessary. - topic = document.get_tag('topic') - if not topic: + if topic_tag := document.get_tag('topic'): + topic = topic_tag.value + else: topic = 'uncategorized' if '.' in topic: topic, subtopic = topic.split('.', maxsplit=1)