diff options
| author | Yuval Adam <_@yuv.al> | 2022-11-17 00:35:42 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2022-11-17 15:38:21 +0200 |
| commit | f9229cf066eb810a97b3b324527e42d5acba254d (patch) | |
| tree | d6f592695e4e00179e04182d015a240d341ecc16 /build.py | |
| parent | bcf0ce69c5ae552797f4daf30214fab446c61d14 (diff) | |
Split list and render candidates
Diffstat (limited to 'build.py')
| -rw-r--r-- | build.py | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -12,7 +12,7 @@ BUILD_DIR = ROOT_PATH / "build" STATIC_DIR = ROOT_PATH / "static" REQUIRED_FIELDS = set(["domain", "name"]) -OPTIONAL_FIELDS = set(["url", "title", "email", "github"]) +OPTIONAL_FIELDS = set(["url", "title", "email", "github", "candidate"]) TEMPLATES = ["index.html"] @@ -24,6 +24,7 @@ for f in listdir(STATIC_DIR): # process all name yamls names = [] +candidates = [] for name in listdir(NAMES_DIR): with open(NAMES_DIR / name, "r") as f: fields = yaml.load(f.read(), Loader=yaml.Loader) @@ -34,8 +35,13 @@ for name in listdir(NAMES_DIR): invalid_fields = field_set - OPTIONAL_FIELDS - REQUIRED_FIELDS if invalid_fields: raise Exception(f"Invalid fields {invalid_fields} in {name}") - names.append(fields) + + if fields.get("candidate"): + candidates.append(fields) + else: + names.append(fields) names = list(sorted(names, key=lambda x: x["domain"])) +candidates = list(sorted(candidates, key=lambda x: x["domain"])) def render_link(value, classes): @@ -56,6 +62,6 @@ env = Environment(loader=PackageLoader("build"), autoescape=select_autoescape()) env.filters["render_link"] = render_link for template in TEMPLATES: t = env.get_template(template) - index = t.render(names=names) + index = t.render(names=names, candidates=candidates) with open(BUILD_DIR / "index.html", "w") as f: f.write(index) |
