#!/usr/bin/env python3 from pathlib import Path import re import sys app_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path('/opt/virtuality/web/app.py') app_dir = app_path.resolve().parent if app_path.exists() else Path('/opt/virtuality/web') template_path = app_dir / 'templates' / 'vm_detail.html' changed = [] if not template_path.exists(): print(f'legacy boot order cleanup skipped: vm_detail.html not found: {template_path}') raise SystemExit(0) tpl = template_path.read_text() original = tpl legacy_pattern = re.compile( r'\n\s*
\s*\n' r'\s*
\s*\n' r'\s*

Порядок загрузки

\s*\n' r'\s*boot order\s*\n' r'.*?' r'\s*
\s*\n', re.DOTALL, ) tpl, count = legacy_pattern.subn('\n', tpl) if count: changed.append(f'legacy select boot-order card removed: {count}') # Safety cleanup for any accidental duplicated plain select card without the old pill text. plain_select_pattern = re.compile( r'\n\s*
\s*\n' r'\s*
\s*\n' r'\s*

Порядок загрузки

.*?' r'