summaryrefslogtreecommitdiff
path: root/webComponent.py
blob: 6b835be6c08a565a9289d5c693cc5b3b8a17e0a7 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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()