From c681406f2847dd848679a7895c07c6fb643ff7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Thu, 7 May 2026 05:03:42 +0900 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B0=D1=82=D1=87=20DHCP=20leases=20?= =?UTF-8?q?=D0=B1=D1=8B=D0=BB=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B4=D0=BB=D1=8F=20Python=20re.subn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/patch_dhcp_leases_empty.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/patch_dhcp_leases_empty.py b/scripts/patch_dhcp_leases_empty.py index 5a7b0ec..71ff968 100644 --- a/scripts/patch_dhcp_leases_empty.py +++ b/scripts/patch_dhcp_leases_empty.py @@ -19,7 +19,7 @@ if not dashboard_template_path.exists(): text = app_path.read_text(encoding='utf-8') # Older versions of this patch injected helper blocks. Remove them first so repeated -# installs stay deterministic and do not accumulate stale NETWORK_NAME references. +# installs stay deterministic and do not accumulate stale references. text, removed_helpers = re.subn( r"\n\ndef parse_dhcp_leases_output\(output: str\).*?\n\ndef parse_virsh_list\(\) -> list\[dict\[str, str\]\]:", "\n\ndef parse_virsh_list() -> list[dict[str, str]]:", @@ -65,9 +65,11 @@ new_parse_virsh_list = '''def parse_virsh_list() -> list[dict[str, str]]: return rows ''' +pattern = r"def parse_virsh_list\(\) -> list\[dict\[str, str\]\]:.*?\n\ndef parse_pool_list\(\) -> list\[dict\[str, str\]\]:" +replacement = new_parse_virsh_list + "\n\ndef parse_pool_list() -> list[dict[str, str]]:" text, replaced = re.subn( - r"def parse_virsh_list\(\) -> list\[dict\[str, str\]\]:.*?\n\ndef parse_pool_list\(\) -> list\[dict\[str, str\]\]:", - new_parse_virsh_list + "\n\ndef parse_pool_list() -> list[dict[str, str]]:", + pattern, + lambda _match: replacement, text, count=1, flags=re.S, @@ -108,6 +110,4 @@ for item in changed: for item in warnings: print(f'WARN: {item}') -# This patch must never break the installer. If it cannot find an older marker, -# the panel can still run without the extra IP column logic. raise SystemExit(0)