diff options
| author | Yuval Adam <_@yuv.al> | 2022-11-26 09:51:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-26 09:51:17 +0200 |
| commit | 7387c7cb3ef89c0227b53a19a8057c35e6aec6e9 (patch) | |
| tree | 7f2cf28cf070aab45266b9950dd7e9b64eb61666 /build.py | |
| parent | 6d40823ded0bed7c32ebd9747d261f03b09b6893 (diff) | |
| parent | 76583e5aca961cc68eb6d3f8438b1a7d113b1c14 (diff) | |
Merge pull request #57 from yuvadm/candidates
Add mass of 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) |
