Files
sshyp/port-jobs/RMEXTMAN.py
T
RandyTheSilly 37075230cc Added port-job for disabling extension management; applied to Haiku and Termux packages
Former-commit-id: eb66222b45b41fbd92712dacd23ed825ba377982
Former-commit-id: 0544589759a4e41c005aae8a6b00fcdff58f72d9
2023-07-11 12:34:59 -04:00

20 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
import re
devtype_replacement = """_install_type = curses_radio(('client (ssh-synchronized)', 'client (offline)'),
'device + sync type configuration')"""
targets = (('TWEAK-EXTEND-FUNCTIONS', 'stweak.py', '\n', '\n\n', ''),
('TWEAK-EXTEND-OPTION', 'stweak.py', '', '', "curses_radio(['okay'], "
"'extension management is not supported on this platform\\\\n\\\\ninstead, you may install and manage "
"extensions through your system package manager\\\\n\\\\nofficial extension packages are available "
"at https://github.com/rwinkhart/sshyp-labs/releases')"))
for target in targets:
# read text from target file
text = open(f"working/{target[1]}", 'r').read()
# compile regex and modify text
regex = re.compile(f"{target[2]}# PORT START {target[0]}.*?# PORT END {target[0]}{target[3]}", re.DOTALL)
new_text = re.sub(regex, target[4], text)
# write updated text to target file
open(f"working/{target[1]}", 'w').write(new_text)