|
| 1 | +import requests |
| 2 | +import os |
| 3 | +import sys |
| 4 | +import yaml |
| 5 | +from datetime import datetime |
| 6 | + |
| 7 | +ORG = "ManiVaultStudio" |
| 8 | +REPO = sys.argv[1] if len(sys.argv) > 1 else "Scatterplot" |
| 9 | +OUTPUT_PATH = f"{REPO.lower()}.md" |
| 10 | +GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") |
| 11 | + |
| 12 | +HEADERS = { |
| 13 | + "Accept": "application/vnd.github+json", |
| 14 | +} |
| 15 | +if GITHUB_TOKEN: |
| 16 | + HEADERS["Authorization"] = f"Bearer {GITHUB_TOKEN}" |
| 17 | + |
| 18 | +def fetch_plugin_info(): |
| 19 | + url = f"https://raw.githubusercontent.com/{ORG}/{REPO}/master/PluginInfo.json" |
| 20 | + r = requests.get(url) |
| 21 | + r.raise_for_status() |
| 22 | + return r.json() |
| 23 | + |
| 24 | +def fetch_contributors(): |
| 25 | + url = f"https://api.github.com/repos/{ORG}/{REPO}/contributors" |
| 26 | + r = requests.get(url, headers=HEADERS) |
| 27 | + r.raise_for_status() |
| 28 | + return [user["login"] for user in r.json()] |
| 29 | + |
| 30 | +def write_markdown(info, authors): |
| 31 | + metadata = { |
| 32 | + "layout": "plugin", |
| 33 | + "name": info["name"], |
| 34 | + "shortname": info["name"].split()[0], |
| 35 | + "key": REPO.lower(), |
| 36 | + "type": info.get("type", "").lower(), |
| 37 | + "version": info["version"]["plugin"], |
| 38 | + "date": datetime.today().strftime("%Y-%m-%d %H:%M:%S"), |
| 39 | + "organization": "ManiVault", |
| 40 | + "organization-link": "https://www.manivault.studio", |
| 41 | + "authors": authors, |
| 42 | + "shortdescription": f"{info['type']} plugin with dependencies: {', '.join(info.get('dependencies', []))}" |
| 43 | + } |
| 44 | + |
| 45 | + with open(OUTPUT_PATH, "w") as f: |
| 46 | + f.write("---\n") |
| 47 | + yaml.dump(metadata, f, sort_keys=False) |
| 48 | + f.write("---\n") |
| 49 | + |
| 50 | + print(f"✅ Updated {OUTPUT_PATH}") |
| 51 | + |
| 52 | +if __name__ == "__main__": |
| 53 | + info = fetch_plugin_info() |
| 54 | + authors = fetch_contributors() |
| 55 | + write_markdown(info, authors) |
0 commit comments