Skip to content

Commit ef0fb47

Browse files
committed
update_ini: keep emtpy lines at the end of a section
1 parent 610dbfa commit ef0fb47

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/emc/ini/update_ini.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
def copysection(block):
1616
#Just makes a straight copy of blocks that don't need any work
17-
regex = r"^\s*\[%s\](.+?)(?:^\s*\[|\Z)" % block
18-
section = re.search(regex, inistring, re.M | re.DOTALL)
19-
newini.write("\n[%s]" % block)
17+
regex = r"^\s*\[%s\](\n(?:^(?!\[).*\n?)*)" % block
18+
# regex = r"^\[%s\](\n(?:^(?!\[).*\n?)*)" % block
19+
section = re.search(regex, inistring, re.M)
20+
newini.write("[%s]" % block)
2021
if section is not None:
2122
newini.write(section.group(1))
2223
all_sections.remove(block)
2324
else:
24-
newini.write("\n#No Content\n")
25+
newini.write("\n#No Content\n\n")
2526

2627
def writeifexists(file, section, src_item, dest_item = "None"):
2728
#Writes a new entry to the file, but only if it exists
@@ -444,9 +445,10 @@ def get_kins(joints, coordinates):
444445
inistring, newini, all_sections = ini_preamble()
445446

446447
all_sections.remove("DISPLAY")
447-
section = re.search(r"\[DISPLAY\](.+?)\n\[", inistring, re.DOTALL)
448+
section = re.search(r"\[DISPLAY\](.+?\n)(?=\[)", inistring, re.DOTALL)
449+
448450
if section: section = section.group(1)
449-
newini.write("\n[DISPLAY]\n")
451+
newini.write("\n[DISPLAY]")
450452
if section != None:
451453
if re.search("MIN_SPINDLE_OVERRIDE", section):
452454
section = re.sub("MIN_SPINDLE_OVERRIDE", "MIN_SPINDLE_0_OVERRIDE", section)

0 commit comments

Comments
 (0)