diff options
Diffstat (limited to 'strike.py')
-rwxr-xr-x | strike.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/strike.py b/strike.py new file mode 100755 index 0000000..3ca1e19 --- /dev/null +++ b/strike.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +from os import listdir, mkdir +from sys import exit +from inspect import cleandoc + +def get_output(content): + return cleandoc(f''' + i am a template + with some stuff, + {content}, + and some more stuff + ''') + +def main(): + src = 'blog' + dest = 'output' + + try: mkdir(dest) + except FileExistsError: pass + + for file in listdir(src): + with open(src + '/' + file, 'r') as fin: + file_contents = fin.read() + output = get_output(file_contents) + with open(dest + '/' + file, 'w') as fout: + fout.write(output) + +if __name__ == '__main__': + exit(main()) |