From 799d4afc9cea83a7d0c22f9da55b6491cf1c6ac7 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Tue, 5 Sep 2023 14:17:25 +0200 Subject: [PATCH] Improve regex parsing of tcl --- src/zinolib/config/tcl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zinolib/config/tcl.py b/src/zinolib/config/tcl.py index 2f38c23..0e5b8da 100644 --- a/src/zinolib/config/tcl.py +++ b/src/zinolib/config/tcl.py @@ -62,11 +62,11 @@ def parse(text): lines = text.split("\n") config = {} for line in lines: - _set = re.findall(r"^\s?set _?([a-zA-Z0-9]+)(?:\((.*)\))? (.*)$", line) - if _set: - group = _set[0][1] if _set[0][1] != "" else "default" - key = _set[0][0] - value = _set[0][2] + match = re.fullmatch(r"\s?set _?([a-zA-Z0-9]+)(?:\((.*)\))? (.*)", line) + if match: + key, group, value = match.groups() + if not group: + group = "default" if group not in config: config[group] = {}