hytos / minorTools / xmlUIDChanger.py @ f37c5383
이력 | 보기 | 이력해설 | 다운로드 (945 Bytes)
1 |
import uuid |
---|---|
2 |
import os |
3 |
|
4 |
def changer(): |
5 |
|
6 |
print("uid changer start")
|
7 |
|
8 |
path = 'W:\SHI\Temp'
|
9 |
xml = 'Sample_Test_Page5.xml'
|
10 |
xmlPath = os.path.join(path, xml) |
11 |
|
12 |
print("xmlPath : " + xmlPath)
|
13 |
|
14 |
fw = open(xmlPath, 'r', encoding='utf8') |
15 |
xmlCon = fw.read() |
16 |
fw.close() |
17 |
|
18 |
uidList = [] |
19 |
|
20 |
for index in range(len(xmlCon)): |
21 |
if len(xmlCon) - index < 36: |
22 |
break
|
23 |
|
24 |
try:
|
25 |
text = xmlCon[index:index + 36]
|
26 |
uid = uuid.UUID(text) |
27 |
uidList.append(str(uid))
|
28 |
except:
|
29 |
pass
|
30 |
finally:
|
31 |
pass
|
32 |
|
33 |
uidList = list(set(uidList)) |
34 |
for uid in uidList: |
35 |
xmlCon = xmlCon.replace(uid, str(uuid.uuid4()))
|
36 |
|
37 |
fw = open(xmlPath, 'w', encoding='utf8') |
38 |
fw.write(xmlCon) |
39 |
fw.close() |
40 |
|
41 |
print("uid changer end")
|
42 |
|
43 |
if __name__ == '__main__': |
44 |
selection = input("start enter 1 : ") |
45 |
if selection == '1': |
46 |
changer() |