Implemented 'Part Lib' and 'Footprint Lib' columns.
This commit is contained in:
parent
e0bce9a874
commit
d8ff6c92aa
|
|
@ -4,6 +4,7 @@ This code is adapted from https://github.com/SchrodingersGat/KiBoM by Oliver Hen
|
|||
|
||||
Here is all the logic to convert a list of components into the rows and columns used to create the BoM.
|
||||
"""
|
||||
# TODO Sheetpath
|
||||
from .units import compare_values, comp_match
|
||||
from .bom_writer import write_bom
|
||||
from .columnlist import ColumnList
|
||||
|
|
@ -244,24 +245,14 @@ class ComponentGroup(object):
|
|||
dnc=" (DNC)" if self.is_fixed() else "")
|
||||
|
||||
self.fields[ColumnList.COL_GRP_BUILD_QUANTITY_L] = str(q * self.cfg.number) if self.is_fitted() else "0"
|
||||
self.fields[ColumnList.COL_VALUE_L] = self.components[0].value
|
||||
self.fields[ColumnList.COL_PART_L] = self.components[0].name
|
||||
# self.fields[ColumnList.COL_PART_LIB_L] = self.components[0].getLibName() TODO
|
||||
comp = self.components[0]
|
||||
self.fields[ColumnList.COL_VALUE_L] = comp.value
|
||||
self.fields[ColumnList.COL_PART_L] = comp.name
|
||||
self.fields[ColumnList.COL_PART_LIB_L] = comp.lib
|
||||
self.fields[ColumnList.COL_DATASHEET_L] = comp.datasheet
|
||||
self.fields[ColumnList.COL_FP_L] = comp.footprint
|
||||
self.fields[ColumnList.COL_FP_LIB_L] = comp.footprint_lib
|
||||
# self.fields[ColumnList.COL_DESCRIPTION_L] = self.components[0].getDescription() TODO
|
||||
self.fields[ColumnList.COL_DATASHEET_L] = self.components[0].datasheet
|
||||
|
||||
# Footprint field requires special attention
|
||||
# TODO: Optimize?
|
||||
fp = self.components[0].footprint.split(":")
|
||||
if len(fp) >= 2:
|
||||
self.fields[ColumnList.COL_FP_LIB_L] = fp[0]
|
||||
self.fields[ColumnList.COL_FP_L] = fp[1]
|
||||
elif len(fp) == 1:
|
||||
self.fields[ColumnList.COL_FP_LIB_L] = ""
|
||||
self.fields[ColumnList.COL_FP_L] = fp[0]
|
||||
else:
|
||||
self.fields[ColumnList.COL_FP_LIB_L] = ""
|
||||
self.fields[ColumnList.COL_FP_L] = ""
|
||||
|
||||
def get_row(self, columns):
|
||||
""" Return a dict of the KiCad data based on the supplied columns """
|
||||
|
|
|
|||
|
|
@ -115,6 +115,10 @@ class SchematicComponent(object):
|
|||
def get_field_names(self):
|
||||
return [f.name for f in self.fields]
|
||||
|
||||
def add_field(self, field):
|
||||
self.fields.append(field)
|
||||
self.dfields[field.name.lower()] = field
|
||||
|
||||
def _solve_ref(self, path):
|
||||
""" Look fo the correct reference for this path.
|
||||
Returns the default reference if no paths defined.
|
||||
|
|
@ -136,6 +140,11 @@ class SchematicComponent(object):
|
|||
""" Fills the default fields from the fields attribute """
|
||||
f = self.fields
|
||||
c = len(f)
|
||||
self.field_ref = None
|
||||
self.value = None
|
||||
self.footprint = None
|
||||
self.footprint_lib = None
|
||||
self.datasheet = None
|
||||
if len(f) < 4:
|
||||
logger.warning('Component {} without the basic fields'.format(self.ref))
|
||||
if c > 0:
|
||||
|
|
@ -143,7 +152,15 @@ class SchematicComponent(object):
|
|||
if c > 1:
|
||||
self.value = f[1].value
|
||||
if c > 2:
|
||||
self.footprint = f[2].value
|
||||
res = f[2].value.split(':')
|
||||
cres = len(res)
|
||||
if cres == 1:
|
||||
self.footprint = res[0]
|
||||
elif cres == 2:
|
||||
self.footprint_lib = res[0]
|
||||
self.footprint = res[1]
|
||||
else:
|
||||
raise SchFileError('Footprint with more than one colon', f[2].value, _sch_line_number)
|
||||
if c > 3:
|
||||
self.datasheet = f[3].value
|
||||
|
||||
|
|
@ -197,9 +214,7 @@ class SchematicComponent(object):
|
|||
comp.fields = []
|
||||
comp.dfields = {}
|
||||
while line[0] == 'F':
|
||||
field = SchematicField.parse(line)
|
||||
comp.fields.append(field)
|
||||
comp.dfields[field.name.lower()] = field
|
||||
comp.add_field(SchematicField.parse(line))
|
||||
line = _get_line(f)
|
||||
# Redundant pos
|
||||
if not line.startswith('\t'+str(comp.unit)):
|
||||
|
|
|
|||
Loading…
Reference in New Issue