Account for a few more edge cases.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
6d99b896c9
commit
c8651856a0
|
@ -72,7 +72,7 @@ def main():
|
||||||
word_count_by_chapter = collections.defaultdict(int)
|
word_count_by_chapter = collections.defaultdict(int)
|
||||||
word_count_by_status = collections.defaultdict(int)
|
word_count_by_status = collections.defaultdict(int)
|
||||||
word_count_by_act = 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
|
current_status = None
|
||||||
|
|
||||||
for line in mdfile.readlines():
|
for line in mdfile.readlines():
|
||||||
|
@ -83,15 +83,15 @@ def main():
|
||||||
chapter_heading = line[len(CHAPTER_MARKER) :].strip('()\n')
|
chapter_heading = line[len(CHAPTER_MARKER) :].strip('()\n')
|
||||||
|
|
||||||
# Count the words in chapter heading, because the chapter number and title count as words.
|
# 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)
|
if chapter_heading:
|
||||||
|
word_count_by_chapter[chapter_heading] = count_words(chapter_heading)
|
||||||
status_by_chapter[chapter_heading] = collections.defaultdict(int)
|
current_status = None
|
||||||
current_status = None
|
|
||||||
# Modified to allow multiple statuses in a single chapter, can swap back and forth.
|
# Modified to allow multiple statuses in a single chapter, can swap back and forth.
|
||||||
elif line.startswith(STATUS_MARKER):
|
elif line.startswith(STATUS_MARKER):
|
||||||
if current_status is None:
|
if current_status is None:
|
||||||
current_status = line[len(STATUS_MARKER) :].strip('()\n')
|
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:
|
else:
|
||||||
current_status = line[len(STATUS_MARKER) :].strip('()\n')
|
current_status = line[len(STATUS_MARKER) :].strip('()\n')
|
||||||
elif line.startswith(ACT_MARKER):
|
elif line.startswith(ACT_MARKER):
|
||||||
|
|
Loading…
Reference in New Issue