mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-30 05:46:31 -04:00
Former-commit-id: 2d2e733945ba2748a24ed93f861145cf26ac1f13 Former-commit-id: e3b5add08675438e1a08607d081a9a44f426425e
14 lines
515 B
Python
Executable File
14 lines
515 B
Python
Executable File
#!/usr/bin/env python3
|
|
import re
|
|
|
|
targets = (('UNAME-IMPORT-SSHYP', 'sshyp.py', ''), ('UNAME-IMPORT-STWEAK', 'stweak.py', ''))
|
|
|
|
for target in targets:
|
|
# read text from target file
|
|
text, special = open(f"working/{target[1]}", 'r').read(), ''
|
|
# compile regex and modify text
|
|
regex = re.compile(f"# PORT START {target[0]}.*?# PORT END {target[0]}\n", re.DOTALL)
|
|
new_text = re.sub(regex, target[2], text)
|
|
# write updated text to target file
|
|
open(f"working/{target[1]}", 'w').write(new_text)
|