Skip to content

Commit af2fad7

Browse files
committed
Eagle parser: formatting and lint fixes
1 parent 3302982 commit af2fad7

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

InteractiveHtmlBom/ecad/fusion_eagle.py

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ def _calculate_footprint_bbox(self, package, x, y, angle, mirrored):
318318
sx, sy = 0, 0
319319

320320
return {
321-
'pos': [x + dx, -y - dy],
322-
'angle': _angle,
323-
'relpos': [0, 0],
324-
'size': [sx, sy]
321+
'pos': [x + dx, -y - dy],
322+
'angle': _angle,
323+
'relpos': [0, 0],
324+
'size': [sx, sy]
325325
}
326326

327327
def _footprint_pads(self, package, x, y, angle, mirrored, refdes):
@@ -405,11 +405,11 @@ def _footprint_pads(self, package, x, y, angle, mirrored, refdes):
405405

406406
elif el.tag == 'smd':
407407
layer = el.attrib['layer']
408-
if layer == '1' and not mirrored or \
409-
layer == '16' and mirrored:
408+
if layer == self.TOP_COPPER_LAYER and not mirrored or \
409+
layer == self.BOT_COPPER_LAYER and mirrored:
410410
layers = ['F']
411-
elif layer == '1' and mirrored or \
412-
layer == '16' and not mirrored:
411+
elif layer == self.TOP_COPPER_LAYER and mirrored or \
412+
layer == self.BOT_COPPER_LAYER and not mirrored:
413413
layers = ['B']
414414
else:
415415
self.logger.error('Unable to determine layer for '
@@ -449,7 +449,7 @@ def _footprint_pads(self, package, x, y, angle, mirrored, refdes):
449449
else:
450450
pad['shape'] = 'roundrect'
451451
pad['radius'] = (float(el.attrib['roundness']) / 100) \
452-
* float(el.attrib['dy']) / 2
452+
* float(el.attrib['dy']) / 2
453453

454454
if self.config.include_nets and \
455455
element_pad_nets is not None:
@@ -525,9 +525,10 @@ def _process_footprint(self, package, x, y, angle, mirrored, populate):
525525
elif el.tag == 'rectangle':
526526
_dv = self._rectangle_vertices(el)
527527

528-
# Rotate rectangle about component origin based on component angle
529-
dv = [self._rotate(_x, _y, -angle, mirrored) for (_x, _y) in
530-
_dv]
528+
# Rotate rectangle about component origin based on
529+
# component angle
530+
dv = [self._rotate(_x, _y, -angle, mirrored)
531+
for (_x, _y) in _dv]
531532

532533
# Map vertices back to absolute coordinates
533534
v = [(x + _x, -y + _y) for (_x, _y) in dv]
@@ -581,8 +582,9 @@ def _process_footprint(self, package, x, y, angle, mirrored, populate):
581582
else:
582583
bot = not top
583584

584-
# Note that in Eagle terminology, 'mirrored' essentially means
585-
# 'flipped' (i.e. to the opposite side of the board)
585+
# Note that in Eagle terminology, 'mirrored'
586+
# essentially means 'flipped' (i.e. to the opposite
587+
# side of the board)
586588
if (mirrored and bot) or (not mirrored and top):
587589
dwg_layer['F'].append(dwg)
588590
elif (mirrored and top) or (not mirrored and bot):
@@ -645,26 +647,27 @@ def _element_refdes_to_silk(self, el, package):
645647
tr = self.Rot(p_el.get('rot'))
646648
tr.angle += elr.angle
647649
tr.mirrored ^= elr.mirrored
648-
self._name_to_silk(name=el.attrib['name'],
649-
x=elx+dx,
650-
y=ely-dy,
651-
elr=elr,
652-
tr=tr,
653-
align=p_el.get('align'),
654-
size=float(p_el.attrib['size']),
655-
ratio=float(p_el.get('ratio', '8'))/100)
656-
650+
self._name_to_silk(
651+
name=el.attrib['name'],
652+
x=elx + dx,
653+
y=ely - dy,
654+
elr=elr,
655+
tr=tr,
656+
align=p_el.get('align'),
657+
size=float(p_el.attrib['size']),
658+
ratio=float(p_el.get('ratio', '8')) / 100)
657659

658660
for attr in el.iter('attribute'):
659661
if attr.attrib['name'] == 'NAME':
660-
self._name_to_silk(name=el.attrib['name'],
661-
x=float(attr.attrib['x']),
662-
y=-float(attr.attrib['y']),
663-
elr=self.Rot(el.get('rot')),
664-
tr=self.Rot(attr.get('rot')),
665-
align=attr.attrib.get('align'),
666-
size=float(attr.attrib['size']),
667-
ratio=float(attr.get('ratio', '8')) / 100)
662+
self._name_to_silk(
663+
name=el.attrib['name'],
664+
x=float(attr.attrib['x']),
665+
y=-float(attr.attrib['y']),
666+
elr=self.Rot(el.get('rot')),
667+
tr=self.Rot(attr.get('rot')),
668+
align=attr.attrib.get('align'),
669+
size=float(attr.attrib['size']),
670+
ratio=float(attr.get('ratio', '8')) / 100)
668671

669672
@staticmethod
670673
def _segments_to_polygon(segs, angle=0, mirrored=False):
@@ -719,13 +722,13 @@ def _parse(self, brdfile):
719722
try:
720723
brdxml = ElementTree.parse(brdfile)
721724
except ElementTree.ParseError as err:
722-
self.logger.error("Exception occurred trying to parse {0}, message:"
723-
" {1}"
724-
.format(brdfile.name, err.msg))
725+
self.logger.error(
726+
"Exception occurred trying to parse {0}, message: {1}"
727+
.format(brdfile.name, err.msg))
725728
return None, None
726729
if brdxml is None:
727-
self.logger.error("No data was able to be parsed from {0}"
728-
.format(brdfile.name))
730+
self.logger.error(
731+
"No data was able to be parsed from {0}".format(brdfile.name))
729732
return None, None
730733

731734
# Pick out key sections
@@ -747,8 +750,8 @@ def _parse(self, brdfile):
747750
self.min_via_w = 0
748751
else:
749752
if len(mv) > 1:
750-
self.logger.warning("Multiple rlMinViaOuter found, using first "
751-
"occurrence")
753+
self.logger.warning(
754+
"Multiple rlMinViaOuter found, using first occurrence")
752755
mv = mv[0]
753756
mv_val = float(''.join(d for d in mv if d in string.digits + '.'))
754757
mv_units = (''.join(d for d in mv if d in string.ascii_lowercase))
@@ -802,7 +805,7 @@ def _parse(self, brdfile):
802805

803806
# For component, get footprint data
804807
libs = [lib for lib in board.find('libraries').findall('library')
805-
if lib.attrib['name'] == el.attrib['library']]
808+
if lib.attrib['name'] == el.attrib['library']]
806809
packages = []
807810
for lib in libs:
808811
p = [pac for pac in lib.find('packages').findall('package')

0 commit comments

Comments
 (0)