-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerate.py
42 lines (34 loc) · 1.38 KB
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import codecs
import json
import os
import sys
APPS = ["chat", "vector-store", "coder", "embeddings",
"diffuser", "text-to-audio", "audio-to-text", "upscaler"]
manifests = []
for folder in os.listdir("."):
folder_path = os.path.join(".", folder)
if os.path.isdir(folder_path) and any(s in folder_path for s in APPS):
manifest_path = os.path.join(folder_path, "manifest.json")
readme_path = os.path.join(folder_path, "README.md")
logo_path = os.path.join(folder_path, "logo.svg")
banner_path = os.path.join(folder_path, "banner.svg")
with open(manifest_path) as f:
manifest = json.load(f)
with codecs.open(readme_path, "r", encoding="utf-8") as f:
readme_content = f.read()
manifest["documentation"] = readme_content
if os.path.exists(logo_path):
manifest[
"icon"
] = f"https://raw.githubusercontent.com/premAI-io/prem-registry/{sys.argv[1]}/{folder}/logo.svg"
else:
manifest["icon"] = None
if os.path.exists(banner_path):
manifest[
"banner"
] = f"https://raw.githubusercontent.com/premAI-io/prem-registry/{sys.argv[1]}/{folder}/banner.svg"
else:
manifest["banner"] = None
manifests.append(manifest)
with open("manifests.json", "w") as f:
json.dump(manifests, f)