Skip to content

Commit

Permalink
Add warning when some references are not found in netlist/xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Oct 26, 2018
1 parent a763492 commit 11b7b0b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 13 additions & 1 deletion InteractiveHtmlBom/generate_interactive_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def logerror(msg):
def logwarn(msg):
if is_cli:
logger.warn(msg)
else:
wx.LogWarning(msg)


def skip_component(m, config, extra_data, filter_layer):
Expand Down Expand Up @@ -116,6 +118,7 @@ def natural_sort(l):
}

# build grouped part list
warning_shown = False
part_groups = {}
for m in pcb.GetModules():
if skip_component(m, config, extra_data, filter_layer):
Expand Down Expand Up @@ -145,12 +148,21 @@ def natural_sort(l):
extras = [extra_data[ref].get(f, '')
for f in config.extra_fields]
else:
# Some components are on pcb but not in schematic data.
# Show a warning about possibly outdated netlist/xml file.
# Doing it only once when generating full bom is enough.
if filter_layer is None:
logwarn(
'Component %s is missing from schematic data.' % ref)
warning_shown = True
extras = [''] * len(config.extra_fields)

group_key = (norm_value, tuple(extras), footprint, attr)
valrefs = part_groups.setdefault(group_key, [value, []])
valrefs[1].append(ref)

if warning_shown:
logwarn('Netlist/xml file is likely out of date.')
# build bom table, sort refs
bom_table = []
for (norm_value, extras, footprint, attr), valrefs in part_groups.items():
Expand Down Expand Up @@ -613,7 +625,7 @@ def Run(self):
config.netlist_initial_directory = os.path.dirname(
pcbnew.GetBoard().GetFileName())
extra_data_file = find_latest_schematic_data(
config.netlist_initial_directory)
config.netlist_initial_directory)
if extra_data_file is not None:
dlg.set_extra_data_path(extra_data_file)
config.transfer_to_dialog(dlg.panel)
Expand Down
2 changes: 1 addition & 1 deletion InteractiveHtmlBom/schematic_data/netlistparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def get_extra_field_data(self):
fields = f[1:]
if ref is None:
return None
ref_fields = comp_dict.setdefault(ref, {})
if fields is None:
continue
for f in fields:
if len(f) > 1:
field_set.add(f[1][1])
if len(f) > 2:
ref_fields = comp_dict.setdefault(ref, {})
ref_fields[f[1][1]] = f[2]

return list(field_set), comp_dict
3 changes: 1 addition & 2 deletions InteractiveHtmlBom/schematic_data/xmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ def get_extra_field_data(self):
field_set = set()
comp_dict = {}
for c in components:
ref_fields = comp_dict.setdefault(c.attributes['ref'].value, {})
for f in c.getElementsByTagName('field'):
name = f.attributes['name'].value
if name not in self.DEFAULT_FIELDS:
field_set.add(name)
ref_fields = comp_dict.setdefault(
c.attributes['ref'].value, {})
ref_fields[name] = self.get_text(f.childNodes)

return list(field_set), comp_dict

0 comments on commit 11b7b0b

Please sign in to comment.