Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_replace(script, new_script, name):
- with open(script,encoding="utf-8", mode="r") as script_file:
- script_text = script_file.read()
- for d2mo_script in new_script:
- with open(d2mo_script, encoding='utf-8', mode='r') as d2mo_script_file:
- text = d2mo_script_file.read()
- text_index_from = (text.find('"from"')+7)
- text_index_to = (text.find('"to"')-2)
- text_old = text[text_index_from:text_index_to]
- text_index_from = text.find('"to"')+5
- text_index_to = text.rfind('}')-5
- text_new = text[text_index_from:text_index_to]
- if text_old in script_text:
- script_text = script_text.replace(text_old, text_new)
- with open(name, encoding='utf-8', mode='w') as new_script_file:
- new_script_file.write(script_text)
Advertisement
Add Comment
Please, Sign In to add comment