Account for a few more edge cases.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Dan Helfman 2022-01-10 09:59:18 -08:00
parent 6d99b896c9
commit c8651856a0
1 changed files with 6 additions and 6 deletions

View File

@ -72,7 +72,7 @@ def main():
word_count_by_chapter = collections.defaultdict(int)
word_count_by_status = collections.defaultdict(int)
word_count_by_act = collections.defaultdict(int)
status_by_chapter = {}
status_by_chapter = collections.defaultdict(lambda: collections.defaultdict(int))
current_status = None
for line in mdfile.readlines():
@ -83,15 +83,15 @@ def main():
chapter_heading = line[len(CHAPTER_MARKER) :].strip('()\n')
# Count the words in chapter heading, because the chapter number and title count as words.
word_count_by_chapter[chapter_heading] = count_words(chapter_heading)
status_by_chapter[chapter_heading] = collections.defaultdict(int)
current_status = None
if chapter_heading:
word_count_by_chapter[chapter_heading] = count_words(chapter_heading)
current_status = None
# Modified to allow multiple statuses in a single chapter, can swap back and forth.
elif line.startswith(STATUS_MARKER):
if current_status is None:
current_status = line[len(STATUS_MARKER) :].strip('()\n')
status_by_chapter[chapter_heading][current_status] = count_words(chapter_heading)
if chapter_heading:
status_by_chapter[chapter_heading][current_status] = count_words(chapter_heading)
else:
current_status = line[len(STATUS_MARKER) :].strip('()\n')
elif line.startswith(ACT_MARKER):