summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2022-11-17 00:35:42 +0200
committerYuval Adam <_@yuv.al>2022-11-17 15:38:21 +0200
commitf9229cf066eb810a97b3b324527e42d5acba254d (patch)
treed6f592695e4e00179e04182d015a240d341ecc16 /build.py
parentbcf0ce69c5ae552797f4daf30214fab446c61d14 (diff)
Split list and render candidates
Diffstat (limited to 'build.py')
-rw-r--r--build.py12
1 files changed, 9 insertions, 3 deletions
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)