name: Cleanup obsolete SuperWoW tweak UI on: push: branches: - 'test/remote-fallbacks' permissions: contents: write jobs: cleanup: if: github.event.head_commit.message == 'Cleanup obsolete SuperWoW tweak UI' runs-on: ubuntu-latest steps: - name: Checkout branch uses: actions/checkout@v4 with: ref: test/remote-fallbacks - name: Remove obsolete SuperWoW tweak coupling shell: bash run: | python - <<'PY' from pathlib import Path import re setup = Path('setup_tool.py') text = setup.read_text(encoding='utf-8') methods = re.compile( r' def _superwow_enabled\(self\):\n.*?(?= def build_tweaks_tab\(self, parent\):\n)', re.S, ) text, count = methods.subn('', text, count=1) assert count == 1, f'SuperWoW helper removal count={count}' notice = re.compile( r'( def build_tweaks_tab\(self, parent\):\n)' r' self\.superwow_notice = tk\.Label\(.*?' r' self\.superwow_notice\.pack\(fill="x", padx=10, pady=\(5, 2\)\)\n\n' r'(?= fov_frame = ttk\.LabelFrame)', re.S, ) text, count = notice.subn(lambda m: m.group(1), text, count=1) assert count == 1, f'SuperWoW notice removal count={count}' text, count = re.subn( r'^\s+self\.update_superwow_managed_controls\(\)\n', '', text, flags=re.M, ) assert count >= 1, f'expected obsolete update calls, got {count}' assert 'update_superwow_managed_controls' not in text assert '_superwow_enabled' not in text assert 'superwow_notice' not in text setup.write_text(text, encoding='utf-8', newline='\n') dynamic = Path('setup_tool_dynamic.py') text = dynamic.read_text(encoding='utf-8') callback = ''' command = ( self.update_superwow_managed_controls if dll == "SuperWoWhook.dll" else None ) ''' # Match indentation exactly as stored rather than relying on the # callback being at a fixed line number. callback_re = re.compile( r' command = \(\n' r' self\.update_superwow_managed_controls\n' r' if dll == "SuperWoWhook\.dll"\n' r' else None\n' r' \)\n' ) text, count = callback_re.subn('', text, count=1) assert count == 1, f'dynamic callback removal count={count}' text, count = re.subn(r'^\s+command=command,\n', '', text, count=1, flags=re.M) assert count == 1, f'dynamic command argument removal count={count}' assert 'update_superwow_managed_controls' not in text dynamic.write_text(text, encoding='utf-8', newline='\n') tests = Path('tests/test_safety.py') text = tests.read_text(encoding='utf-8') obsolete_test = re.compile( r' def test_superwow_keeps_vanilla_tweaks_controls_enabled\(self\):\n.*?' r'(?= def test_superwow_modern_cli_keeps_selected_fov_sound_loot_and_background\(self\):\n)', re.S, ) text, count = obsolete_test.subn('', text, count=1) assert count == 1, f'obsolete test removal count={count}' tests.write_text(text, encoding='utf-8', newline='\n') PY - name: Validate syntax and diff run: | python -m py_compile setup_tool.py setup_tool_dynamic.py remote_packages.py tests/test_safety.py git diff --check - name: Commit cleanup run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add setup_tool.py setup_tool_dynamic.py tests/test_safety.py git diff --cached --check git commit -m "Remove SuperWoW Vanilla Tweaks coupling" git push origin HEAD:test/remote-fallbacks