main
John Lauer Add JST GH libraries, native schematic parity and revised sensor harness study with reviewed clips 1ac01c3
"""Isolated three-position sensor schematic, with explicit unused pin."""
from pathlib import Path
import copy,shutil,uuid,json
import sexp
R=Path(__file__).resolve().parents[1]; O=R/'checkpoints/sensor-gh-review-v8'; S=sexp.Sym
for f in (R/'kicad').glob('*.kicad_sch'): shutil.copy2(f,O/f.name)
p=O/'mechanical.kicad_sch'; t=sexp.parse(p.read_text())
lib=next(x for x in sexp.find(sexp.first(t,'lib_symbols'),'symbol') if x[1]=='Load:J10')
unit=next(x for x in sexp.find(lib,'symbol') if x[1]=='J10_1_1')
pin=copy.deepcopy(sexp.find(unit,'pin')[1]); sexp.first(pin,'at')[2]=S('-3.81')
sexp.first(pin,'name')[1]='3';sexp.first(pin,'number')[1]='3';unit.append(pin)
inst=next(x for x in sexp.find(t,'symbol') if sexp.first(x,'lib_id')[1]=='Load:J10')
for prop in sexp.find(inst,'property'):
 if prop[1]=='MPN': prop[2]='BM03B-GHS-TBT'
 if prop[1]=='Value': prop[2]='JST GH case sensor'
 if prop[1]=='Footprint':prop[2]='Load:JST_GH_BM03B-GHS-TBT_1x03-1MP_P1.25mm_Vertical'
inst.append([S('pin'),'3',[S('uuid'),str(uuid.uuid4())]])
t.append([S('no_connect'),[S('at'),S('90.17'),S('58.42')],[S('uuid'),str(uuid.uuid4())]])
p.write_text(sexp.dump(t)+'\n')
print('Isolated 11-sheet candidate; J10.3 explicit NC at90.17,58.42')
# Reuse proven complete-hierarchy native export and parity assertions.
s=(R/'tools/validate_release_fet_netlist_native.py').read_text().replace('checkpoints/release-fet-review','checkpoints/sensor-gh-review-v8').replace('review/release-fet-netlist','review/sensor-gh-netlist').replace('release-fet-candidate.kicad_pcb','sensor-gh-candidate.kicad_pcb')
(R/'tools/validate_sensor_netlist_native.py').write_text(s)