2021-06-23 21:26:35 +01:00
|
|
|
### Generation helper for index.html
|
|
|
|
|
2021-06-24 00:38:47 +01:00
|
|
|
from .. import file as util_file
|
|
|
|
from .. import csv as util_csv
|
|
|
|
import shutil
|
2021-06-23 21:26:35 +01:00
|
|
|
|
2021-06-24 00:38:47 +01:00
|
|
|
|
|
|
|
def generate(templatedir, destinationdir, filename):
|
|
|
|
"""Main generation function for index.html generation helper.
|
|
|
|
|
|
|
|
templatedir -- the relative path of the template html file's directory
|
|
|
|
destinationpath -- the directory where index.html should be generated
|
|
|
|
filename -- the filename of the index page (always index.html)
|
|
|
|
"""
|
2021-06-23 21:26:35 +01:00
|
|
|
print("- index.py -")
|
2021-06-24 00:38:47 +01:00
|
|
|
|
|
|
|
shutil.copy(f"{templatedir}/{filename}", destinationdir)
|
|
|
|
|
|
|
|
config = util_csv.dictReaderFirstRow("../csv/config.csv")
|
|
|
|
|
|
|
|
for key in config.keys():
|
|
|
|
util_file.replaceTextInFile(f"{destinationdir}/{filename}", key, config[key])
|