Skip to content

Commit d54e3ee

Browse files
committed
update_ini: improve regex for finding the DISPLAY section
Fixes the bugs - if there is a commented DISPLAY sections before the DISPLAY section, the comments are used instead - DISPLAY section must not be at the end --> empty section
1 parent 0a0b7d4 commit d54e3ee

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/emc/ini/update_ini.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def insert_after(key, new_line, section):
446446
inistring, newini, all_sections = ini_preamble()
447447

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

451451
if section: section = section.group(1)
452452
newini.write("\n[DISPLAY]")
@@ -495,10 +495,6 @@ def insert_after(key, new_line, section):
495495
# ~rename [TRAJ, DISPLAY]MIN_VELOCITY --> MIN_LINEAR_VELOCITY~
496496
# copy [TRAJ]MAX_LINEAR_VELOCITY -> [DISPLAY]MAX_LINEAR_VELOCITY
497497

498-
# Known bugs:
499-
# - if there is a commented DISPLAY sections before the DISPLAY section, the comments are used
500-
# - DISPLAY section must not be at the end --> empty section
501-
502498
#These sections don't need any work.
503499
copysection("FILTER")
504500
copysection("RS274NGC")

0 commit comments

Comments
 (0)