feat(html processor): add html processor to process template strings

This commit is contained in:
Halyul
2021-06-01 18:15:36 -04:00
parent 77e5eaeaa4
commit a05bbf7558
6 changed files with 76 additions and 32 deletions

25
lib/html_processor.py Normal file
View File

@@ -0,0 +1,25 @@
import pathlib
class HtmlProcessor:
def __init__(self, config):
self.config = config
pass
def process(self, operator, file_path):
with open(pathlib.Path.cwd().joinpath(file_path), "r") as f:
content = f.read()
return content.format(
title=self.config["operators"][operator]["title"],
version=self.__get_version()
)
def build(self, operator, source_path, target_path):
content = self.process(operator, source_path)
with open(pathlib.Path.cwd().joinpath(target_path), "w") as f:
f.write(content)
def __get_version(self):
with open(pathlib.Path.cwd().joinpath("Version"), "r") as f:
version = f.read()
return version