|
14 | 14 |
|
15 | 15 | def copysection(block): |
16 | 16 | #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) |
20 | 21 | if section is not None: |
21 | 22 | newini.write(section.group(1)) |
22 | 23 | all_sections.remove(block) |
23 | 24 | else: |
24 | | - newini.write("\n#No Content\n") |
| 25 | + newini.write("\n#No Content\n\n") |
25 | 26 |
|
26 | 27 | def writeifexists(file, section, src_item, dest_item = "None"): |
27 | 28 | #Writes a new entry to the file, but only if it exists |
@@ -444,9 +445,10 @@ def get_kins(joints, coordinates): |
444 | 445 | inistring, newini, all_sections = ini_preamble() |
445 | 446 |
|
446 | 447 | 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 | + |
448 | 450 | if section: section = section.group(1) |
449 | | - newini.write("\n[DISPLAY]\n") |
| 451 | + newini.write("\n[DISPLAY]") |
450 | 452 | if section != None: |
451 | 453 | if re.search("MIN_SPINDLE_OVERRIDE", section): |
452 | 454 | section = re.sub("MIN_SPINDLE_OVERRIDE", "MIN_SPINDLE_0_OVERRIDE", section) |
|
0 commit comments