Commit 1a693391 by sikang

bug fix

parent b0f8c09f
...@@ -21,13 +21,20 @@ class ActivityGarble: ...@@ -21,13 +21,20 @@ class ActivityGarble:
#替换文件内容 #替换文件内容
def __process_file_content(self, path, file_name): def __process_file_content(self, path, file_name):
# print("processing content: %s..."%path) # print("processing content: %s..."%path)
chars = "_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
with open(path, "rt") as fin: with open(path, "rt") as fin:
file_content = fin.read() file_content = fin.read()
# replace the file content based on mangle settings # replace the file content based on mangle settings
for (src, dst) in self.activity_mapping.items(): for (src, dst) in self.activity_mapping.items():
separator = [" ", ".", "\"", "{", "}", "(", ")", "[", "]","<",">", ":", ";", ","] #避免命名重复,确保要替换的部分前后没有合法的命名字符,如果有则还原
for sep in separator: file_content = file_content.replace(src, dst)
file_content = file_content.replace(src + sep, dst + sep).replace(sep+src, sep+dst) for char in chars:
if char + dst in file_content:
file_content = file_content.replace(char + dst, char + src)
elif dst + char in file_content:
file_content = file_content.replace(dst + char, src + char)
ext = os.path.splitext(file_name)[1] ext = os.path.splitext(file_name)[1]
if ext == '.java': if ext == '.java':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment