Select Git revision
TraineeReducer.js
Forked from
KSZK / DevTeam / kszkepzes / old / kszkepzes-frontend
Source project has a limited visibility.
app.py 908 B
import os
import yaml
from jinja2 import Template
import shutil
import random
def batch(iterable, n=1):
l = len(iterable)
for ndx in range(0, l, n):
yield iterable[ndx:min(ndx + n, l)]
with open(r'input.yaml') as file:
data = yaml.load(file, yaml.FullLoader)
page = data["page"]
projects = data["projects"]
random.shuffle(projects)
for x in batch(projects, 3):
r = random.randint(0, 3)
if r < len(x):
x[r]["bordered"] = True
jinja2_template_string = open("site/template.html", 'r').read()
template = Template(jinja2_template_string)
html_template_string = template.render({"page": page, "projects": projects})
shutil.rmtree("output", True)
shutil.copytree("site", "output")
os.remove("output/template.html")
output = open("output/index.html", "w")
output.write(html_template_string)
output.close()