import re

with open("boardloaf-he/boardloafhe.kicad_sch", "r") as f:
    sch = f.read()

junction = """	(junction (at 35.56 41.91) (diameter 0) (color 0 0 0 0)
		(uuid "11111111-2222-3333-4444-555555555555")
	)
"""

# Insert junction before the last parenthesis
sch = sch.rstrip()
if sch.endswith(")"):
    sch = sch[:-1] + junction + ")\n"

with open("boardloaf-he/boardloafhe.kicad_sch", "w") as f:
    f.write(sch)

print("Added junction.")
