From f9229cf066eb810a97b3b324527e42d5acba254d Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Thu, 17 Nov 2022 00:35:42 +0200 Subject: Split list and render candidates --- build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'build.py') diff --git a/build.py b/build.py index 6c3d912..60d987d 100644 --- a/build.py +++ b/build.py @@ -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) -- cgit v1.3.1