Skip to content
Snippets Groups Projects
Select Git revision
  • schwifi
  • master default protected
  • eckbalu-master-patch-41181
  • halof
  • our-team
  • 0.12.7 protected
  • 0.12.6 protected
  • 0.12.5 protected
  • 0.12.4 protected
  • 0.12.3 protected
  • 0.12.2 protected
  • 0.12.1 protected
  • 0.12.0 protected
  • 0.11.5 protected
  • 0.11.4 protected
  • 0.11.3 protected
  • 0.11.2 protected
  • 0.11.1 protected
  • 0.11.0 protected
  • 0.10.6 protected
  • 0.10.5 protected
  • 0.10.4 protected
  • 0.10.3 protected
  • 0.10.2 protected
  • 0.10.1 protected
25 results

README.md

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