Respect exclude from BOM

Remove non-standard (and hidden) exclude from BOM field in favor of the
current standard flag
This commit is contained in:
Seth Hillbrand 2023-01-10 14:31:25 -08:00
parent 1dd25dd196
commit 3003d9476a
6 changed files with 57 additions and 14 deletions

View File

@ -73,7 +73,7 @@ except IOError:
# subset the components to those wanted in the BOM, controlled
# by <configure> block in kicad_netlist_reader.py
components = net.getInterestingComponents()
components = net.getInterestingComponents( excludeBOM=True )
compfields = net.gatherComponentFieldUnion(components)
partfields = net.gatherLibPartFieldUnion()

View File

@ -51,7 +51,7 @@ def writerow( acsvwriter, columns ):
utf8row.append( fromNetlistText( str(col) ) )
acsvwriter.writerow( utf8row )
components = net.getInterestingComponents()
components = net.getInterestingComponents( excludeBOM=True )
# Output a field delimited header line
writerow( out, ['Source:', net.getSource()] )

View File

@ -56,7 +56,7 @@ except IOError:
print(__file__, ":", e, file=sys.stderr)
f = sys.stdout
components = net.getInterestingComponents()
components = net.getInterestingComponents( excludeBOM=True )
# Output a set of rows for a header providing general information
html = html.replace('<!--SOURCE-->', net.getSource())

View File

@ -103,7 +103,7 @@ row += "<th>Description</th>" + "<th>Vendor</th></tr>"
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")
components = net.getInterestingComponents()
components = net.getInterestingComponents( excludeBOM=True )
# Get all of the components in groups of matching parts + values
# (see kicad_netlist_reader.py)

View File

@ -52,7 +52,7 @@ def writerow( acsvwriter, columns ):
utf8row.append( fromNetlistText(txt) )
acsvwriter.writerow( utf8row )
components = net.getInterestingComponents()
components = net.getInterestingComponents( excludeBOM=True )
# Output a field delimited header line
writerow( out, ['Source:', net.getSource()] )

View File

@ -405,6 +405,45 @@ class comp():
def getRef(self):
return self.element.get("comp", "ref")
'''
Return true if the component has the DNP property set
'''
def getDNP(self):
for child in self.element.getChildren( "property"):
try:
if child.attributes['name'] == 'dnp':
return True
except KeyError:
continue
return False
'''
Return true if the component has the exclude from BOM property set
'''
def getExcludeFromBOM(self):
for child in self.element.getChildren( "property"):
try:
if child.attributes['name'] == 'exclude_from_bom':
return True
except KeyError:
continue
return False
'''
Return true if the component has the exclude from Board property set
'''
def getExcludeFromBoard(self):
for child in self.element.getChildren( "property"):
try:
if child.attributes['name'] == 'exclude_from_board':
return True
except KeyError:
continue
return False
'''
return the footprint name. if empty and aLibraryToo = True, return the
footprint name from libary
@ -634,7 +673,7 @@ class netlist():
return ret # this is a python 'set'
def getInterestingComponents(self):
def getInterestingComponents(self, excludeBOM=False, excludeBoard=False, DNP=False):
"""Return a subset of all components, those that should show up in the BOM.
Omit those that should not, by consulting the blacklists:
excluded_values, excluded_refs, and excluded_footprints, which hold one
@ -667,23 +706,26 @@ class netlist():
for refs in self.excluded_references:
if refs.match(c.getRef()):
exclude = True
break;
break
if not exclude:
for vals in self.excluded_values:
if vals.match(c.getValue()):
exclude = True
break;
break
if not exclude:
for mods in self.excluded_footprints:
if mods.match(c.getFootprint()):
exclude = True
break;
break
if not exclude:
# This is a fairly personal way to flag DNS (Do Not Stuff). NU for
# me means Normally Uninstalled. You can 'or in' another expression here.
if c.getField( "Installed" ) == 'NU':
exclude = True
if excludeBOM and c.getExcludeFromBOM():
exclude = True
if excludeBoard and c.getExcludeFromBoard():
exclude = True
if DNP and c.getDNP():
exclude = True
if not exclude:
ret.append(c)
@ -716,6 +758,7 @@ class netlist():
# Make sure to start off will all components ungrouped to begin with
for c in components:
c.grouped = False
c.getExcludeFromBOM()
# Group components based on the value, library and part identifiers
for c in components: