Made chapter/act summaries optional

This commit is contained in:
Dmytro Yeroshkin 2021-10-22 11:54:19 +02:00
parent 93b3af2c3b
commit d79e3f5b80
1 changed files with 22 additions and 20 deletions

View File

@ -79,12 +79,12 @@ def main():
word_count_by_act[act_heading] += word_count_by_chapter[chapter_heading]
total_word_count += word_count_by_chapter[chapter_heading]
if '-c' in arguments or '--chapter' in arguments:
# Print out word counts.
for chapter_heading, chapter_word_count in word_count_by_chapter.items():
if chapter_heading is None:
continue
if len(status_by_chapter[chapter_heading]) > 1:
print(f'chapter {chapter_heading}:')
@ -97,15 +97,17 @@ def main():
else:
print(f'chapter {chapter_heading}: {chapter_word_count:,}')
print()
if '-a' in arguments or '--act' in arguments:
for act_heading, act_word_count in word_count_by_act.items():
if act_heading is None:
continue
print('act {}: {:,} words (~{}%)'.format(act_heading, act_word_count, act_word_count * 100 // total_word_count))
print()
for status, status_word_count in word_count_by_status.items():
print('{}: {:,} words (~{}%)'.format(status, status_word_count, status_word_count * 100 // total_word_count))