in rotation.py [0:0]
def generate_html(rotations):
path = Path("docs")
path.mkdir(exist_ok=True)
fpath = (path / "index.html").with_suffix(".html")
this_week = rotations[get_week(DATE)]
next_week = rotations[get_week(DATE + timedelta(weeks=1))]
html = """
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Performance Triage: Rotation</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa"
crossorigin="anonymous"></script>
<div class="container">
<header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
<svg class="bi me-2" width="40" height="32">
<use xlink:href="#bootstrap"></use>
</svg>
<span class="fs-4">Performance Triage: Rotation</span>
</a>
<ul class="nav nav-pills">
<li class="nav-item"><a href="calculator.html" class="nav-link">Impact Calculator</a></li>
<li class="nav-item"><a href="#" class="nav-link active" aria-current="page">Rotation</a>
</li>
</ul>
<a class="mx-3 d-flex" href="https://github.com/mozilla/perf-triage" target="_blank" rel="noopener noreferrer" title="Go to the Git repository (this opens in a new window)">
<svg width="22" height="22" class="octicon octicon-mark-github m-auto" viewBox="0 0 16 16" version="1.1" aria-label="github"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
</header>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6">
<div class="card mb-3">
<div class="card-header text-bg-primary">
This week
</div>
<ol class="list-group list-group-flush">
<li class="list-group-item"><strong>{{this_week.leader}}</strong></li>
{% for sheriff in this_week.sheriffs %}<li class="list-group-item">{{sheriff}}</li>
{% endfor %}
</ol>
</div>
</div>
<div class="col-sm-6">
<div class="card mb-3">
<div class="card-header text-bg-secondary">
Next week
</div>
<ol class="list-group list-group-flush">
<li class="list-group-item"><strong>{{next_week.leader}}</strong></li>
{% for sheriff in next_week.sheriffs %}<li class="list-group-item">{{sheriff}}</li>
{% endfor %}
</ol>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="card mb-3">
<div class="card-header">
History
</div>
<ul class="list-group list-group-flush">
{% for date in history %}<li class="list-group-item">{{ date }}: <strong>{{ history[date].leader }}</strong>, {{ history[date].sheriffs }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<div class="mb-3">Generated on {{timestamp}}.</div>
</div>
</body>
</html>"""
import jinja2
environment = jinja2.Environment()
template = environment.from_string(html)
history = dict(sorted(rotations.items(), reverse=True)[2:])
with fpath.open(mode="w+") as html:
html.write(
template.render(
this_week=this_week,
next_week=next_week,
history=history,
timestamp=DATE,
)
)