forked from OpenC2-org/jadn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjaen-convert.py
33 lines (26 loc) · 1 KB
/
jaen-convert.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
"""
Translate JSON Abstract Encoding Notation (JAEN) files
"""
import os
from jaen.codec.jaen import jaen_load, jaen_dump, jaen_check, jaen_analyze
from jaen.convert.tr_jas import jas_load, jas_dump
from jaen.convert.tr_tables import table_dump
if __name__ == "__main__":
for fn in ("openc2",):
ifname = os.path.join("schema", fn)
ofname = os.path.join("schema_gen", fn)
# Convert JAEN Abstract Syntax (JAS) to JAEN
print(os.path.join(os.getcwd(), ifname + ":"))
source = ifname + ".jas"
dest = ofname + "_gens"
schema = jas_load(source)
jaen_check(schema)
jaen_dump(schema, dest + ".jaen", source)
jaen_analyze(schema)
# Convert JAEN to JAS, prettyprinted JAEN, and property tables
source = ifname + ".jaen"
dest = ofname + "_genj"
jaen = jaen_load(source)
jas_dump(jaen, dest + ".jas", source)
jaen_dump(jaen, dest + ".jaen", source)
table_dump(jaen, dest + ".xlsx", source)