Skip to content

Commit

Permalink
Add datasheet field as extra field
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
qu1ck committed Jun 2, 2019
1 parent 554cbb5 commit 04f4afb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions InteractiveHtmlBom/ecad/kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ def parse(self):
title = os.path.splitext(pcb_file_name)[0]
edges, bbox = self.parse_edges(self.board)
if bbox is None:
self.logger.err('Please draw pcb outline on the edges '
'layer on sheet or any module before '
'generating BOM.')
self.logger.error('Please draw pcb outline on the edges '
'layer on sheet or any module before '
'generating BOM.')
return
bbox = {
"minx": bbox.GetPosition().x * 1e-6,
Expand Down
6 changes: 6 additions & 0 deletions InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ def get_extra_field_data(self):
for c in components:
ref = None
fields = None
datasheet = None
for f in c[1:]:
if f[0] == 'ref':
ref = f[1]
if f[0] == 'fields':
fields = f[1:]
if f[0] == 'datasheet':
datasheet = f[1]
if ref is None:
return None
ref_fields = comp_dict.setdefault(ref, {})
if datasheet and datasheet != '~':
field_set.add('datasheet')
ref_fields['datasheet'] = datasheet
if fields is None:
continue
for f in fields:
Expand Down
6 changes: 6 additions & 0 deletions InteractiveHtmlBom/ecad/kicad_extra/xmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def get_extra_field_data(self):
comp_dict = {}
for c in components:
ref_fields = comp_dict.setdefault(c.attributes['ref'].value, {})
datasheet = c.getElementsByTagName('datasheet')
if datasheet:
datasheet = self.get_text(datasheet[0].childNodes)
if datasheet != '~':
field_set.add('datasheet')
ref_fields['datasheet'] = datasheet
for f in c.getElementsByTagName('field'):
name = f.attributes['name'].value
if name not in self.DEFAULT_FIELDS:
Expand Down

0 comments on commit 04f4afb

Please sign in to comment.