blob: 3ca1e19cf556c7a98e4836f62b0b9cfef6938fae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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())
|