-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcheck_customsetting.py
More file actions
51 lines (42 loc) · 1.41 KB
/
Copy pathcheck_customsetting.py
File metadata and controls
51 lines (42 loc) · 1.41 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
# coding:utf-8
import os
import re
def out_replace_file(component):
# return r"replace_component(i,r'GetComponent("+'"' + component + '")'+"'"+',r"GetComponent(typeof(' + component + '))")\n'
return r'replace_component(i,r"GetComponent('+"'" + component + "')"+'"'+",r'GetComponent(typeof(" + component + "))')\n"
# return "replace_component(i,r'""+component+'"',"typeof("+component+")")"
def check_component(filePath):
savePath = "1.txt"
file = open(savePath,"wb")
file.write("")
file.close()
with open(savePath, 'a') as outFile:
with open(filePath,'rb') as inFile:
while True:
content = inFile.readline()
# if re.findall(r"_GT(typeof((.*?)))"):
# outFile.write(content)
# p1 = re.compile(r'[typeof(](.*?)[))]', re.S) #最小匹配
# print(re.findall(p1, content))
# if re.findall(p1,content):
# outFile.write(re.findall(p1,content))
str = content.strip()
str = (out_replace_file(str).strip("\n"))
# print(out_replace_file(str))
print(str)
outFile.write(str + "\n")
# print(out_replace_file(content))
if not content:
return
pass
# with open(filePath,"rb") as inFile:
# while True:
# content = inFile.readline()
# print(content)
# if not content:
# return
# pass
if __name__ == '__main__':
# check_component("F://XGame//Assets//Editor//Custom//CustomSettings.cs")
check_component("Component.txt")
# print(out_replace_file("UILabel"))