Commit 82da982e by sikang

bug fix

parent 0f95ec34
......@@ -44,13 +44,19 @@ class StringGarble:
with open(path, "r") as f:
fileContent = f.read()
strings = ""
strings_head = ""
strings_foot = ""
for i in range(0,random.randint(100,500)):
key = self.__gen_rand_str()
value = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=random.randint(5, 100)))
strings += "<string name=\"%s\">%s</string>\n"% (key,value)
if i % random.randint(1,10) == 0:
strings_head += "<string name=\"%s\">%s</string>\n"% (key,value)
else:
strings_foot += "<string name=\"%s\">%s</string>\n"% (key,value)
with open(path, "w") as f_w:
fileContent = fileContent.replace("</resources>","%s\n</resources>"% strings)
fileContent = fileContent.replace("</resources>","%s\n</resources>"% strings_head)
fileContent = fileContent.replace("<resources>","<resources>\n%s"% strings_foot)
f_w.write(fileContent)
......
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