-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.py
More file actions
84 lines (65 loc) · 2.36 KB
/
checker.py
File metadata and controls
84 lines (65 loc) · 2.36 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import xml.dom.minidom
#---------------functions def---------------------------------------------------------
def getSkinName(skinNode):
atts = skinNode.getElementsByTagName('att')
for att in atts:
if att.getAttribute("name") == 'Name':
return att.getAttribute("value")
def isEqualAtt(attNode1, attNode2):
equal = True
if not attNode1.getAttribute("name") == attNode2.getAttribute("name"):
equal = False
if not attNode1.getAttribute("value") == attNode2.getAttribute("value"):
equal = False
if not attNode1.getAttribute("type") == attNode2.getAttribute("type"):
equal = False
return equal
def compareSkin(skin1, skin2):
isSameSkin = True
atts1 = skin1.getElementsByTagName('att')
atts2 = skin2.getElementsByTagName('att')
index = 0
for index in range(len(atts1)):
if not isEqualAtt(atts1[index], atts2[index]):
if not atts1[index].getAttribute('name') == 'Name':
isSameSkin = False
break
#if isSameSkin:
# output skin name
# print atts1[0].getAttribute('value'), '==', atts2[0].getAttribute('value')
return isSameSkin
def updateElements(dom):
root = dom.documentElement
return root.getElementsByTagName('skin')
#---------------functions-------------------------------------------------------------
file_object = open('output.log','w')
#open skin.xml file.
dom = xml.dom.minidom.parse('skin.xml')
root = dom.documentElement
skins = root.getElementsByTagName('skin')
skinsNumber = len(skins)
totalReduplicate = 0
while(len(skins) >= 2):
foundSame = False
firstSkin = skins[0]
skins.remove(skins[0])
print 'scan skin ', getSkinName(firstSkin)
index = 0
while (index < len(skins)):
if compareSkin(firstSkin, skins[index]):
if not foundSame:
totalReduplicate += 1
file_object.write(getSkinName(firstSkin))
foundSame = True
file_object.write(' ,')
totalReduplicate += 1
file_object.write(getSkinName(skins[index]))
skins.remove(skins[index])
else:
index += 1
if foundSame:
file_object.write('\n')
print 'total skins number is:', skinsNumber
print 'total reduplicate mount:', totalReduplicate
print 'scan finished'
file_object.close()