Commit 0e83446e by sikang

update

parent 98628cf8
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"LoanHistoryActivity", "LoanHistoryActivity",
"LoginActivity", "LoginActivity",
"SettingsActivity", "SettingsActivity",
"SplashActivity",
"AccountFragment", "AccountFragment",
"ContactInfoFragment", "ContactInfoFragment",
"IdentityInfoFragment", "IdentityInfoFragment",
......
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import json
import string import os
import random import random
import glob, os import string
used_names = [] used_names = []
activity_mangle_setting = {} activity_mangle_setting = {}
def process_file_content(path, file_name): def process_file_content(path, file_name):
# print("processing content: %s..."%path) # print("processing content: %s..."%path)
with open(path, "rt") as fin: with open(path, "rt") as fin:
...@@ -14,17 +15,20 @@ def process_file_content(path, file_name): ...@@ -14,17 +15,20 @@ def process_file_content(path, file_name):
# replace the file content based on mangle settings # replace the file content based on mangle settings
for (src, dst) in activity_mangle_setting.items(): for (src, dst) in activity_mangle_setting.items():
file_content = file_content.replace(src, dst) separator = [" ", ".", "\"", "{", "(", ":"]
for sep in separator:
file_content = file_content.replace(src + sep, dst + separator)
ext = os.path.splitext(file_name)[1] ext = os.path.splitext(file_name)[1]
if ext == '.java': if ext == '.java':
comment = "// machine renamed: %s\n"%file_name comment = "// machine renamed: %s\n" % file_name
file_content = "%s%s"%(comment, file_content) file_content = "%s%s" % (comment, file_content)
with open(path, "wt") as fout: with open(path, "wt") as fout:
fout.write(file_content) fout.write(file_content)
print("done\n") print("done\n")
return return
# rand string for class names # rand string for class names
def gen_rand_str(): def gen_rand_str():
rand_str = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8)) rand_str = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8))
...@@ -34,6 +38,7 @@ def gen_rand_str(): ...@@ -34,6 +38,7 @@ def gen_rand_str():
used_names.append(rand_str) used_names.append(rand_str)
return rand_str return rand_str
# read configs # read configs
with open('obact.json', "rt") as f: with open('obact.json', "rt") as f:
json_root = json.load(f) json_root = json.load(f)
...@@ -45,7 +50,7 @@ with open('obact.json', "rt") as f: ...@@ -45,7 +50,7 @@ with open('obact.json', "rt") as f:
for act_name in activities: for act_name in activities:
activity_mangle_setting[act_name] = gen_rand_str() activity_mangle_setting[act_name] = gen_rand_str()
print("activity mapping %s"%activity_mangle_setting) print("activity mapping %s" % activity_mangle_setting)
root_path = os.path.join(os.getcwd(), source_root) root_path = os.path.join(os.getcwd(), source_root)
# perform content replace for the files # perform content replace for the files
...@@ -69,7 +74,7 @@ for root, dirs, files in os.walk(source_root): ...@@ -69,7 +74,7 @@ for root, dirs, files in os.walk(source_root):
if name in activity_mangle_setting: if name in activity_mangle_setting:
# get the path of the java file # get the path of the java file
src = os.path.join(directory, file) src = os.path.join(directory, file)
dst = os.path.join(directory, "%s.java"%activity_mangle_setting[name]) dst = os.path.join(directory, "%s.java" % activity_mangle_setting[name])
# print("%s -> %s"%(src, dst)) # print("%s -> %s"%(src, dst))
os.rename(src, dst) os.rename(src, dst)
...@@ -77,7 +82,3 @@ print("renaming files done") ...@@ -77,7 +82,3 @@ print("renaming files done")
manifest_path = os.path.join(os.getcwd(), manifest) manifest_path = os.path.join(os.getcwd(), manifest)
process_file_content(manifest_path, "AndroidManifest.xml") process_file_content(manifest_path, "AndroidManifest.xml")
...@@ -14,7 +14,9 @@ def process_file_content(path, file_name): ...@@ -14,7 +14,9 @@ def process_file_content(path, file_name):
# replace the file content based on mangle settings # replace the file content based on mangle settings
for (src, dst) in activity_mangle_setting.items(): for (src, dst) in activity_mangle_setting.items():
file_content = file_content.replace(src, dst) separator = [" ", ".", "\"", "{", "(", ":"]
for sep in separator:
file_content = file_content.replace(src + sep, dst + separator)
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