-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloa4.py
64 lines (57 loc) · 1.89 KB
/
loa4.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import xml.etree.ElementTree as ET
import json
import sys
def printValueAlias(e, valueAlias, defaulted, nodefault):
try:
# print(e.attrib["value"])
# print(e.attrib["default"])
e.attrib["default"]
defaulted.write(valueAlias)
defaulted.write("\n")
defaulted.write(e.attrib["default"])
defaulted.write("\n")
except:
# print(e.attrib["value"])
nodefault.write(valueAlias)
nodefault.write("\n")
soup = ET.parse("/c/x3d-code/www.web3d.org/specifications/X3dUnifiedObjectModel-4.0.xml").getroot()
enums = soup.iter("enumeration")
defaulted = open("./results/loa4defaulted.txt", "w")
nodefault = open("./results/loa4nodefault.txt", "w")
for e in enums:
try:
if e.attrib["loa"] == "4":
printValueAlias(e, e.attrib["value"], defaulted, nodefault)
try:
for alias in e.attrib["alias"].split(','):
printValueAlias(e, alias, defaulted, nodefault)
except KeyError:
pass
except KeyError:
pass
except:
raise
defaulted.close()
nodefault.close()
defaulted = open("./results/loa4defaulted.txt", "r")
nodefault = open("./results/loa4nodefault.txt", "r")
for f in [ defaulted, nodefault ]:
line = f.readline()[:-1]
while line:
enums = soup.iter("enumeration")
for e in enums:
try:
if e.attrib["loa"] == "4":
if e.attrib["value"] == line:
try:
e.attrib["default"]
print(e.attrib["value"], "|", line, "=", e.attrib["default"])
except:
print(e.attrib["value"], "|", line)
except KeyError:
pass
except:
raise
line = f.readline()[:-1]
defaulted.close()
nodefault.close()