main
John Lauer
Review component pin functions and validate isolated library model and hole corrections
7fb4d36
"""Test the manufacturer's J11 hole recommendation without reducing annular/spacing rules."""
from pathlib import Path
import json,hashlib,copy,shutil
import sexp
root=Path(__file__).resolve().parents[1];src=root/'checkpoints/library-model-review/library-model-candidate.kicad_pcb';out=root/'checkpoints/j11-hole-review';out.mkdir(exist_ok=True)
b=sexp.parse(src.read_text());before=copy.deepcopy(b)
f=next(f for f in sexp.find(b,'footprint') if any(p[1:3]==['Reference','J11'] for p in sexp.find(f,'property')))
changes=[]
for p in sexp.find(f,'pad'):
assert sexp.first(p,'size')[1:]==['1','1'] and sexp.first(p,'drill')[1:]==['0.65']
changes.append({'pin':p[1],'oldSize':[1,1],'oldDrill':.65,'newSize':[1.05,1.05],'newDrill':.71})
sexp.first(p,'size')[1:]=[sexp.Sym('1.05'),sexp.Sym('1.05')];sexp.first(p,'drill')[1:]=[sexp.Sym('0.71')]
old_name=f[1];variant='FTS_105_01_L_S_3rdPartyFab';f[1]='Load:'+variant
library=copy.deepcopy(f);library[1]=variant
for key in ['at','uuid','path','sheetname','sheetfile']:
for item in sexp.find(library,key):library.remove(item)
for prop in sexp.find(library,'property'):
if prop[1]=='Reference':prop[2]='REF**'
if prop[1]=='Value':prop[2]=variant
def strip_instance(node):
for item in list(node):
if isinstance(item,list):
if item and item[0] in ['net','uuid']:node.remove(item)
else:strip_instance(item)
strip_instance(library)
board=out/'j11-hole-candidate.kicad_pcb';board.write_text(sexp.dump(b)+'\n');assert sexp.parse(board.read_text())==b
for p in sexp.find(f,'pad'):
sexp.first(p,'size')[1:]=[sexp.Sym('1'),sexp.Sym('1')];sexp.first(p,'drill')[1:]=[sexp.Sym('0.65')]
f[1]=old_name
assert b==before
for ext in ['kicad_pro','kicad_dru']:shutil.copyfile(root/'aiflow/run'/('board-24.'+ext),out/('j11-hole-candidate.'+ext))
shutil.copyfile(root/'kicad/fp-lib-table',out/'fp-lib-table');shutil.copytree(root/'kicad/lib',out/'lib',dirs_exist_ok=True)
(out/'lib/Load.pretty'/f'{variant}.kicad_mod').write_text(sexp.dump(library)+'\n')
r={'projectFootprintVariant':'Load:'+variant,'source':str(src.relative_to(root)),'sourceSha256':hashlib.sha256(src.read_bytes()).hexdigest(),'candidate':str(board.relative_to(root)),'candidateSha256':hashlib.sha256(board.read_bytes()).hexdigest(),'changes':changes,'nominalAnnulusMm':.17,'nominalInterpadGapMm':.22,'ruleAnnulusMinMm':.15,'ruleClearanceMinMm':.2,'manufacturerDrawing':'https://suddendocs.samtec.com/prints/fts-1xx-xx-x-sx-footprint.pdf','tracksViasNetsZonesUnchanged':True,'nativeApplied':False,'nativeDrc':'pending','qualification':'Finished-hole tolerance and fabrication capability remain unqualified'}
(out/'review.json').write_text(json.dumps(r,indent=2)+'\n');print(json.dumps(r,indent=2))