feat(html processor): add html processor to process template strings
This commit is contained in:
25
lib/html_processor.py
Normal file
25
lib/html_processor.py
Normal 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
|
||||
Reference in New Issue
Block a user