forked from pysnmp/mibs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
35 lines (32 loc) · 1.13 KB
/
index.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
import json
import os
#
p = "output/json"
index = {}
for filename in os.listdir(p):
mapped = False
with open(os.path.join(p, filename), "r") as read_file:
jmib = json.load(read_file)
for i in jmib.items():
data = i[1]
if "class" in data:
classname = data["class"]
if classname in ["moduleidentity", "objectidentity"]:
mapped = True
index[data["oid"]] = filename.replace(".json", "")
if not mapped:
for i in jmib.items():
data = i[1]
if "class" in data:
classname = data["class"]
if (
classname not in ["moduleidentity", "objectidentity"]
and "oid" in data
):
mapped = True
index[data["oid"]] = filename.replace(".json", "")
if not mapped and "-TC" not in filename:
print(f"Unable to index {p}/{filename}")
with open("output/index.csv", "w") as f:
for i in index.items():
f.write(f"{i[1]},{i[0]}\n")