Files
sshyp/port-jobs/UNAME.py
T
RandyTheSilly d031e3c7ab Use tempfile.NamedTemporaryFile() for editing notes, removing the need for shm_gen()
Former-commit-id: 2d2e733945ba2748a24ed93f861145cf26ac1f13
Former-commit-id: e3b5add08675438e1a08607d081a9a44f426425e
2023-06-18 14:10:25 -04:00

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)