import re

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

# Extract net classes / names
nets = {}
for line in pcb_data.split("\n"):
    match = re.search(r'\(net (\d+) "([^"]+)"\)', line)
    if match:
        nets[int(match.group(1))] = match.group(2)

vcc_net = None
v3v3_net = None
for n_id, name in nets.items():
    if name == "VCC":
        vcc_net = n_id
    if name == "+3V3":
        v3v3_net = n_id

print(f"VCC net ID: {vcc_net}")
print(f"+3V3 net ID: {v3v3_net}")

if vcc_net is None or v3v3_net is None:
    print("Could not find nets!")
else:
    print(
        "Both nets exist. If they have different IDs, they are considered separate by KiCad."
    )
