Made changes to the filepaths

to enable running of the script from the repo root.
This commit is contained in:
Sammy Hori
2024-11-17 20:58:37 +00:00
parent f581020ab6
commit fe164b7153

13
.github/scripts/render-readme.py vendored Normal file → Executable file
View File

@@ -1,9 +1,14 @@
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
import json import json
DATAFILE = "./data.json"
TEMPLATEPATH = "./.github/"
TEMPLATEFILE = "README.j2"
TARGETFILE = "./README.md"
technologies = {} technologies = {}
with open("../../data.json", 'r') as datafile: with open(DATAFILE, 'r') as datafile:
data = json.loads(datafile.read()) data = json.loads(datafile.read())
for technology in data["technologies"]: for technology in data["technologies"]:
@@ -16,9 +21,9 @@ for repository in data["repositories"]:
technologies[repo_technology] = {"link_id": repo_technology.lower(), "entries": []} technologies[repo_technology] = {"link_id": repo_technology.lower(), "entries": []}
technologies[repo_technology]["entries"].append(repository) technologies[repo_technology]["entries"].append(repository)
env = Environment(loader = FileSystemLoader("..")) env = Environment(loader = FileSystemLoader(TEMPLATEPATH))
template = env.get_template("README.j2") template = env.get_template(TEMPLATEFILE)
categories = [] categories = []
for key, value in zip(technologies.keys(), technologies.values()): for key, value in zip(technologies.keys(), technologies.values()):
@@ -32,4 +37,4 @@ sponsors = data["sponsors"]
output = template.render(categories=categories, sponsors=sponsors) output = template.render(categories=categories, sponsors=sponsors)
open("README.md", "w").write(output) open(TARGETFILE, "w").write(output)