def collectBom(components, lscsField, ignore): bom = {} for c in components: if c["unit"] != 1: continue reference = c["reference"] if reference.startswith("#PWR") or reference.startswith( "#FL") or reference in ignore: continue cType = (getField(c, "Value"), getField(c, "Footprint"), getField(c, lscsField)) bom[cType] = bom.get(cType, []) + [reference] return bom
def collectBom(components, lscsFields, ignore): bom = {} for c in components: if c["unit"] != 1: continue reference = c["reference"] if reference.startswith("#PWR") or reference.startswith( "#FL") or reference in ignore: continue orderCode = None for fieldName in lscsFields: orderCode = getField(c, fieldName) if orderCode is not None: break cType = (getField(c, "Value"), getField(c, "Footprint"), orderCode) bom[cType] = bom.get(cType, []) + [reference] return bom
def getCompensation(footprint): if footprint.GetReference() not in bom: return 0, 0, 0 field = None for fieldName in correctionFields: field = getField(bom[footprint.GetReference()], fieldName) if field is not None: break if field is None or field == "": return 0, 0, 0 try: return parseCompensation(field) except FormatError as e: raise FormatError(f"{footprint.GetReference()}: {e}")
def collectBom(components, manufacturerFields, partNumberFields, descriptionFields, notesFields, typeFields, footprintFields, ignore): bom = {} # Use KiCad footprint as fallback for footprint footprintFields.append("Footprint") # Use value as fallback for description descriptionFields.append("Value") for c in components: if c["unit"] != 1: continue reference = c["reference"] if reference.startswith("#PWR") or reference.startswith( "#FL") or reference in ignore: continue manufacturer = None for manufacturerName in manufacturerFields: manufacturer = getField(c, manufacturerName) if manufacturer is not None: break partNumber = None for partNumberName in partNumberFields: partNumber = getField(c, partNumberName) if partNumber is not None: break description = None for descriptionName in descriptionFields: description = getField(c, descriptionName) if description is not None: break notes = None for notesName in notesFields: notes = getField(c, notesName) if notes is not None: break solderType = None for typeName in typeFields: solderType = getField(c, typeName) if solderType is not None: break footprint = None for footprintName in footprintFields: footprint = getField(c, footprintName) if footprint is not None: break cType = (description, footprint, manufacturer, partNumber, notes, solderType) bom[cType] = bom.get(cType, []) + [reference] return bom