Skip to content
Snippets Groups Projects
Select Git revision
  • 2e24d7f820b3e32e98fbac7b9ae68f812058fbe5
  • master default protected
  • 1.3.1
  • 1.3.0
  • 1.2.0
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • 1.1.0
  • 1.0.19
  • 1.0.18
  • 1.0.17
  • 1.0.16
  • 1.0.15
  • 1.0.14
  • 1.0.13
  • 1.0.12
  • 1.0.10
  • 1.0.9
  • 1.0.8
22 results

TraineeReducer.js

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