From 8a34274ead1f3bced073c0ae68c16eaf8e9e07d5 Mon Sep 17 00:00:00 2001 From: QuentinN42 Date: Mon, 25 Apr 2022 21:29:01 +0200 Subject: [PATCH] feat: base builder Signed-off-by: QuentinN42 --- .gitignore | 1 + builder/__main__.py | 36 +++++++++++++++++++ builder/__pycache__/__main__.cpython-310.pyc | Bin 0 -> 1082 bytes builder/templates/index.html | 10 ++++++ requirements.txt | 1 + 5 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 builder/__main__.py create mode 100644 builder/__pycache__/__main__.cpython-310.pyc create mode 100644 builder/templates/index.html create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/builder/__main__.py b/builder/__main__.py new file mode 100644 index 0000000..c48af61 --- /dev/null +++ b/builder/__main__.py @@ -0,0 +1,36 @@ +"""Jinja2 generator.""" +from jinja2 import Environment, FileSystemLoader # type: ignore + + +env = Environment(loader=FileSystemLoader('builder/templates')) + + +def get_arguments() -> dict: + return {"a": "b"} + + +def render(file: str, args: dict) -> str: + """Render a template file.""" + template = env.get_template(file) + return template.render(args) + + +def write_output(result, location) -> None: + """Write output to file.""" + with open(location, "w") as f: + f.write(result) + + +def main(): + """Script entrypoint.""" + write_output( + render( + 'index.html', + get_arguments() + ), + 'build/index.html' + ) + + +if __name__ == "__main__": + main() diff --git a/builder/__pycache__/__main__.cpython-310.pyc b/builder/__pycache__/__main__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d66edd512320c7c8122fbc812433b5a78b8d090d GIT binary patch literal 1082 zcmZuwJ8u&~5Z;&1m-E>;5hRor-3iGSQ7VKG5`qFDBjFH9DQMge8rEO;=#ug&^iYr zNlYY_ET;vFS;1pYiDHVch~yt>ETmA436l-!or~C$P1TgXYCyC(@#K~aAnMC)8Okos&3FE!lm?^nnUigc8{rIgNG}+b^>6ZMxr^s#59HRJ#8SK#+*p*0b^?(^Xlh z(%A0vELWqm+Nk1Xl}e=}YQ5Zf*3-(&bved+HwCDYr=YbD1}SB9L?S-4G_~~TGtn5o zHb3qUj;lfq%7gvEG&2LO7Ai+XgQIztL(4&u6lqo_Nq=@`+f!wdR8Qv!&vmG=pHDT; z+KLI_wE`0AF~&E-!9jJnZi8dU1znO$`hhLk1zXZf#7Gx=uT=>xdub0C&j5z%Va0yL zEm!499Af*;5l#TJBd%LeQiouyzd5~TsJHO60|ql{0VZGpb&=seFmXB#=0k7{SyD+? z>{G`9b&x4JB$5dt$O?8uvJrVe>fKXH;e{!AgYOKnh%fFO>I?`}b2FQpo~hPUEIl2< zGmC1bO4~Ta6krEb>UnOgpI775WL0VDuhFv@S^%`R%NB>FM?(i}}2?+BTV&3fB-ZS)$0L$fJariDt9|3dN~6_uRl>M?~ + + + + + + + {{ a }} + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7f7afbf --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +jinja2