@@ -111,9 +111,9 @@ def __init__(self, rot_string):
111
111
if d in string .digits + '.' ))
112
112
113
113
def __str__ (self ):
114
- return f "Mirrored: { self . mirrored } , " \
115
- f"Spin: { self .spin } , " \
116
- f"Angle: { self .angle } "
114
+ return "Mirrored: {0 }, Spin: {1}, Angle: {2}" . format ( self . mirrored ,
115
+ self .spin ,
116
+ self .angle )
117
117
118
118
def _rectangle_vertices (self , el ):
119
119
# Note: Eagle specifies a rectangle using opposing corners
@@ -782,11 +782,28 @@ def _parse(self, brdfile):
782
782
extra_fields = extra_fields )
783
783
784
784
# For component, get footprint data
785
- library = [lib for lib in board .find ('libraries' ).findall ('library' )
786
- if lib .attrib ['name' ] == el .attrib ['library' ]][0 ]
787
- package = \
788
- [pac for pac in library .find ('packages' ).findall ('package' )
789
- if pac .attrib ['name' ] == el .attrib ['package' ]][0 ]
785
+ libs = [lib for lib in board .find ('libraries' ).findall ('library' )
786
+ if lib .attrib ['name' ] == el .attrib ['library' ]]
787
+ packages = []
788
+ for lib in libs :
789
+ p = [pac for pac in lib .find ('packages' ).findall ('package' )
790
+ if pac .attrib ['name' ] == el .attrib ['package' ]]
791
+ packages .extend (p )
792
+ if not packages :
793
+ self .logger .error ("Package {0} in library {1} not found in "
794
+ "source file {2} for element {3}"
795
+ .format (el .attrib ['package' ],
796
+ el .attrib ['library' ],
797
+ brdfile .name ,
798
+ el .attrib ['name' ]))
799
+ return None , None
800
+ else :
801
+ package = packages [0 ]
802
+ if len (packages ) > 1 :
803
+ self .logger .warn ("Multiple packages found for package {0}"
804
+ " in library {1}, using first instance "
805
+ "found" .format (el .attrib ['package' ],
806
+ el .attrib ['library' ]))
790
807
791
808
elx = float (el .attrib ['x' ])
792
809
ely = float (el .attrib ['y' ])
@@ -835,7 +852,7 @@ def _parse(self, brdfile):
835
852
a .get ('current' ) == 'yes' ]
836
853
variant = None if not variant else variant [0 ]
837
854
if variant :
838
- title = f" { title } , Variant: { variant } "
855
+ title = "{0 }, Variant: {1}" . format ( title , variant )
839
856
840
857
date = datetime .fromtimestamp (
841
858
os .path .getmtime (self .file_name )).strftime ('%Y-%m-%d %H:%M:%S' )
0 commit comments