summaryrefslogtreecommitdiff
path: root/webComponent.py
diff options
context:
space:
mode:
authorsolongs <[email protected]>2022-06-17 17:33:55 +0800
committersolongs <[email protected]>2022-06-17 17:33:55 +0800
commit7215183403fe147fdc4865a9148f56abdab15cdf (patch)
treeeeadbdea9679f37b0b62aebe696404ab302be943 /webComponent.py
webcomponent
Diffstat (limited to 'webComponent.py')
-rw-r--r--webComponent.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/webComponent.py b/webComponent.py
new file mode 100644
index 0000000..6b835be
--- /dev/null
+++ b/webComponent.py
@@ -0,0 +1,70 @@
+
+import json
+import os
+res = dict()
+
+path = "./src/categories.json"
+f = open(path, "r")
+cat = json.load(f)
+f.close()
+
+res["categories"] = cat
+res["technologies"] = {}
+
+paths = os.listdir("./src/technologies")
+
+root = "./src/technologies"
+for jsonfile in os.listdir("./src/technologies"):
+ path = root + "/" + jsonfile
+ f = open(path, "r", encoding="utf-8")
+ dat = json.load(f)
+ f.close()
+ for key, value in dat.items():
+ res["technologies"][key] = value
+
+data = res
+
+for key, value in data["technologies"].items():
+ try:
+ if "url" in value and value["url"] is not list:
+ data["technologies"][key]["url"] = [value["url"]]
+ except:
+ pass
+ try:
+ if "implies" in value and value["implies"] is not list:
+ data["technologies"][key]["implies"] = [value["implies"]]
+ except:
+ pass
+ try:
+ if "scriptSrc" in value and value["scriptSrc"] is not list:
+ data["technologies"][key]["scriptSrc"] = [value["scriptSrc"]]
+ except:
+ pass
+ try:
+ if "html" in value and not value["html"] is not list:
+ data["technologies"][key]["html"] = [value["html"]]
+ print(data["technologies"][key]["html"])
+ except:
+ pass
+ try:
+ a = value["headers"]
+ except KeyError:
+ data["technologies"][key]["headers"] = {}
+ try:
+ a = value["meta"]
+ except KeyError:
+ data["technologies"][key]["meta"] = {}
+
+ for k in ['headers', 'meta']:
+ obj = data["technologies"][key][k]
+
+f = open("technologies_2.json", "w", encoding="utf-8")
+json.dump(data, f, indent=2)
+f.close()
+
+
+
+
+
+
+