main
John Lauer
Preserve adopted board30 and validated resistor library candidates with native-render dependency
7fa0c9c
"""Bind the isolated full schematic hierarchy to the reviewed Bourns footprint."""
from pathlib import Path
import json,shutil
import sexp
R=Path(__file__).resolve().parents[1];O=R/'checkpoints/bourns-land-review-v2'
rows=json.loads((O/'selection-review.json').read_text())['references'];refs={x['reference'] for x in rows};seen=set();binding='Load:R_0402_Bourns_CR_1.00x0.50mm'
for source in (R/'kicad').glob('*.kicad_sch'):
t=sexp.parse(source.read_text())
for sym in sexp.find(t,'symbol'):
props={x[1]:x for x in sexp.find(sym,'property')};ref=props.get('Reference',[None,None,None])[2]
if ref in refs:
assert props['MPN'][2].startswith('CR0402-FX-'),ref
props['Footprint'][2]=binding;seen.add(ref)
(O/source.name).write_text(sexp.dump(t)+'\n')
assert seen==refs,(seen^refs)
s=(R/'tools/validate_sensor_netlist_native.py').read_text().replace('sensor-gh-review-v8','bourns-land-review-v2').replace('review/sensor-gh-netlist','review/bourns-netlist').replace('sensor-gh-candidate.kicad_pcb','native-saved/bourns-land-candidate.kicad_pcb')
s+='\nrefs='+repr(sorted(refs))+'''\nfor ref in refs:
c=n.find(f"components/comp[@ref='{ref}']")
assert c.findtext('footprint')=='Load:R_0402_Bourns_CR_1.00x0.50mm',(ref,c.findtext('footprint'))
print('31 exact Bourns footprint bindings verified in native schematic export')
'''
(R/'tools/validate_bourns_netlist_native.py').write_text(s)
print('Prepared complete hierarchy with31 isolated footprint binding changes')