Skip to content

Commit

Permalink
Improve regex parsing of tcl
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Oct 12, 2023
1 parent 917e4bf commit 799d4af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/zinolib/config/tcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}
Expand Down

0 comments on commit 799d4af

Please sign in to comment.