blob: e3e5e52124a3d8a505b6f459900902522255ac29 (
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
|
#!/usr/bin/env python3
from os import listdir, mkdir
from sys import exit
def get_output(content, template="{content}"):
return template.format(content = content)
def main():
src = 'blog'
dest = 'output'
template = 'template'
try: mkdir(dest)
except FileExistsError: pass
with open(template) as t:
template_contents = t.read()
for file in listdir(src):
with open(src + '/' + file, 'r') as fin:
file_contents = fin.read()
output = get_output(file_contents, template=template_contents)
with open(dest + '/' + file, 'w') as fout:
fout.write(output)
if __name__ == '__main__':
exit(main())
|