Skip to content

Commit 0cab09c

Browse files
committed
update_ini: fix/improve regex for finding the DISPLAY section
1 parent 76b1ddd commit 0cab09c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/emc/ini/update_ini.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def ini_preamble():
435435
inistring, newini, all_sections = ini_preamble()
436436

437437
all_sections.remove("DISPLAY")
438-
section = re.search(r"\[DISPLAY\](.+?\n)(?=\[)", inistring, re.DOTALL)
438+
section = re.search(r"(?:^|\n)[ \t]*(?!#)\[DISPLAY\](.+?\n)(?=\[|$)", inistring, re.DOTALL)
439439

440440
if section: section = section.group(1)
441441
newini.write("\n[DISPLAY]")
@@ -467,7 +467,7 @@ def ini_preamble():
467467
# move [TRAJ]MIN_LINEAR_VELOCITY -> [DISPLAY]MIN_LINEAR_VELOCITY
468468
# rename [TRAJ, DISPLAY]MIN_VELOCITY --> MIN_LINEAR_VELOCITY
469469
# copy [TRAJ]MAX_LINEAR_VELOCITY -> [DISPLAY]MAX_LINEAR_VELOCITY
470-
470+
471471
#These sections don't need any work.
472472
copysection("FILTER")
473473
copysection("RS274NGC")

0 commit comments

Comments
 (0)