diary entries are template files; entries are in diary/entries and links are fixed

This commit is contained in:
chimchooree
2020-10-04 22:11:02 -05:00
parent 258c81178d
commit 155f866cf8
36 changed files with 333 additions and 1109 deletions
+35
View File
@@ -0,0 +1,35 @@
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()