Bug fixes and features #1

Merged
witten merged 12 commits from deroshkin/novel-stats-fork:deroshkin_branch into master 2021-10-22 20:05:18 +00:00
1 changed files with 12 additions and 0 deletions
Showing only changes of commit 93b3af2c3b - Show all commits

View File

@ -3,6 +3,7 @@
import collections
import sys
import os
CHAPTER_MARKER = '## '
@ -26,6 +27,14 @@ def count_words(line):
def main():
arguments = sys.argv[1:]
filename = arguments[0]
tmpfilename = None
if '-pp' in arguments:
import MarkdownPP
tmpfilename = f'.tmp-{os.getpid}.md'
MarkdownPP.MarkdownPP(input=open(filename), output=open(tmpfilename,'w'), modules=list(MarkdownPP.modules))
Review

Clever!

Clever!
filename = tmpfilename
chapter_heading = None
act_heading = None
total_word_count = 0
@ -101,6 +110,9 @@ def main():
print('{}: {:,} words (~{}%)'.format(status, status_word_count, status_word_count * 100 // total_word_count))
print('total: {:,} words'.format(total_word_count))
if tmpfilename:
os.remove(tmpfilename)
if __name__ == '__main__':
Review

Code changes look great! At some point it'd probably be good to switch to "formal" argument parsing (argparse, etc.), but certainly not needed now.

Code changes look great! At some point it'd probably be good to switch to "formal" argument parsing (`argparse`, etc.), but certainly not needed now.