Skip to content
Snippets Groups Projects
Select Git revision
  • 4c8af8a98b91f603d73e16979f048e1d14587eff
  • master default
2 results

qml.qrc

Blame
  • 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()