@@ -318,10 +318,10 @@ def _calculate_footprint_bbox(self, package, x, y, angle, mirrored):
318
318
sx , sy = 0 , 0
319
319
320
320
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 ]
325
325
}
326
326
327
327
def _footprint_pads (self , package , x , y , angle , mirrored , refdes ):
@@ -405,11 +405,11 @@ def _footprint_pads(self, package, x, y, angle, mirrored, refdes):
405
405
406
406
elif el .tag == 'smd' :
407
407
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 :
410
410
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 :
413
413
layers = ['B' ]
414
414
else :
415
415
self .logger .error ('Unable to determine layer for '
@@ -449,7 +449,7 @@ def _footprint_pads(self, package, x, y, angle, mirrored, refdes):
449
449
else :
450
450
pad ['shape' ] = 'roundrect'
451
451
pad ['radius' ] = (float (el .attrib ['roundness' ]) / 100 ) \
452
- * float (el .attrib ['dy' ]) / 2
452
+ * float (el .attrib ['dy' ]) / 2
453
453
454
454
if self .config .include_nets and \
455
455
element_pad_nets is not None :
@@ -525,9 +525,10 @@ def _process_footprint(self, package, x, y, angle, mirrored, populate):
525
525
elif el .tag == 'rectangle' :
526
526
_dv = self ._rectangle_vertices (el )
527
527
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 ]
531
532
532
533
# Map vertices back to absolute coordinates
533
534
v = [(x + _x , - y + _y ) for (_x , _y ) in dv ]
@@ -581,8 +582,9 @@ def _process_footprint(self, package, x, y, angle, mirrored, populate):
581
582
else :
582
583
bot = not top
583
584
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)
586
588
if (mirrored and bot ) or (not mirrored and top ):
587
589
dwg_layer ['F' ].append (dwg )
588
590
elif (mirrored and top ) or (not mirrored and bot ):
@@ -645,26 +647,27 @@ def _element_refdes_to_silk(self, el, package):
645
647
tr = self .Rot (p_el .get ('rot' ))
646
648
tr .angle += elr .angle
647
649
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 )
657
659
658
660
for attr in el .iter ('attribute' ):
659
661
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 )
668
671
669
672
@staticmethod
670
673
def _segments_to_polygon (segs , angle = 0 , mirrored = False ):
@@ -719,13 +722,13 @@ def _parse(self, brdfile):
719
722
try :
720
723
brdxml = ElementTree .parse (brdfile )
721
724
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 ))
725
728
return None , None
726
729
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 ))
729
732
return None , None
730
733
731
734
# Pick out key sections
@@ -747,8 +750,8 @@ def _parse(self, brdfile):
747
750
self .min_via_w = 0
748
751
else :
749
752
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" )
752
755
mv = mv [0 ]
753
756
mv_val = float ('' .join (d for d in mv if d in string .digits + '.' ))
754
757
mv_units = ('' .join (d for d in mv if d in string .ascii_lowercase ))
@@ -802,7 +805,7 @@ def _parse(self, brdfile):
802
805
803
806
# For component, get footprint data
804
807
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' ]]
806
809
packages = []
807
810
for lib in libs :
808
811
p = [pac for pac in lib .find ('packages' ).findall ('package' )
0 commit comments