#!/usr/bin/env python2 # coding: utf-8 TEMPLATE=""" {{ title }}
{% if coming_soon %} {% for item in coming_soon %} {% endfor %} {% endif %} {% if past_workshops %} {% for item in past_workshops[:5] %} {% endfor %} {% if past_workshops[5:] %} {% endif %} {% endif %} {% if recorded_workshops %} {% for item in recorded_workshops %} {% endfor %} {% endif %} {% if self_paced %} {% for item in self_paced %} {% endfor %} {% endif %} {% if all_past_workshops %} {% for item in all_past_workshops %} {% if item.video %} {% endif %} {% endfor %} {% endif %}
{{ title }}
Note: while some workshops are delivered in French, slides are always in English.
Free video of our latest workshop
Getting Started With Kubernetes and Container Orchestration
This is a live recording of a 1-day workshop that took place at QCON London in March 2019.
If you're interested, we can deliver that workshop (or longer courses) to your team or organization.
Contact Jérôme Petazzoni to make that happen!
Coming soon near you
{{ item.title }} {% if item.slides %}{% endif %} {% if item.attend %} {% else %}

{{ item.status }}

{% endif %}
Scheduled {{ item.prettydate }} at {{ item.event }} in {{item.city }}.
Past workshops
{{ item.title }} {% if item.slides %} {% else %}

{{ item.status }}

{% endif %}
{% if item.video %}{% endif %}
Delivered {{ item.prettydate }} at {{ item.event }} in {{item.city }}.
... and at least {{ past_workshops[5:] | length }} more.
Recorded workshops
{{ item.title }}
Delivered {{ item.prettydate }} at {{ item.event }} in {{item.city }}.
Self-paced tutorials
{{ item.title }}
Past workshops
{{ item.title }}
Delivered {{ item.prettydate }} at {{ item.event }} in {{item.city }}.
""".decode("utf-8") import datetime import jinja2 import yaml items = yaml.load(open("index.yaml")) # Items with a date correspond to scheduled sessions. # Items without a date correspond to self-paced content. # The date should be specified as a string (e.g. 2018-11-26). # It can also be a list of two elements (e.g. [2018-11-26, 2018-11-28]). # The latter indicates an event spanning multiple dates. # The first date will be used in the generated page, but the event # will be considered "current" (and therefore, shown in the list of # upcoming events) until the second date. for item in items: if "date" in item: date = item["date"] if type(date) == list: date_begin, date_end = date else: date_begin, date_end = date, date suffix = { 1: "st", 2: "nd", 3: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"}.get(date_begin.day, "th") # %e is a non-standard extension (it displays the day, but without a # leading zero). If strftime fails with ValueError, try to fall back # on %d (which displays the day but with a leading zero when needed). try: item["prettydate"] = date_begin.strftime("%B %e{}, %Y").format(suffix) except ValueError: item["prettydate"] = date_begin.strftime("%B %d{}, %Y").format(suffix) item["begin"] = date_begin item["end"] = date_end today = datetime.date.today() coming_soon = [i for i in items if i.get("date") and i["end"] >= today] coming_soon.sort(key=lambda i: i["begin"]) past_workshops = [i for i in items if i.get("date") and i["end"] < today] past_workshops.sort(key=lambda i: i["begin"], reverse=True) self_paced = [i for i in items if not i.get("date")] recorded_workshops = [i for i in items if i.get("video")] template = jinja2.Template(TEMPLATE) with open("index.html", "w") as f: f.write(template.render( title="Container Training", coming_soon=coming_soon, past_workshops=past_workshops, self_paced=self_paced, recorded_workshops=recorded_workshops ).encode("utf-8")) with open("past.html", "w") as f: f.write(template.render( title="Container Training", all_past_workshops=past_workshops ).encode("utf-8"))