Files
blessfrey-bottle/src/diary/entries/raw/article-to-html.py
T

36 lines
699 B
Python

import os
import glob
def file_to_string(f):
text = ""
with open(f, 'r') as n:
text = n.read()
n.close()
return text
def fill_text(f):
return file_to_string('res/head.txt') + file_to_string(f) + file_to_string('res/tail.txt')
def create_files(files, directory):
for f in files:
print(f)
n = open(directory + '/' + os.path.basename(f), "w")
n.write(fill_text(f))
n.close()
def collect_raw(d):
return glob.glob(d)
def clear_articles():
files = glob.glob('../*.tpl')
for f in files:
os.remove(f)
def main():
clear_articles()
create_files(collect_raw('entries/*.tpl'), '..')
## Start Program ##
main()