@@ -19,9 +19,9 @@ def __init__(self, file_name, config, logger, board=None):
19
19
if self .board is None :
20
20
self .board = pcbnew .LoadBoard (self .file_name ) # type: pcbnew.BOARD
21
21
if hasattr (self .board , 'GetModules' ):
22
- self .footprints = list (self .board .GetModules ())
22
+ self .footprints = list (self .board .GetModules ()) # type: list[pcbnew.MODULE]
23
23
else :
24
- self .footprints = list (self .board .GetFootprints ())
24
+ self .footprints = list (self .board .GetFootprints ()) # type: list[pcbnew.FOOTPRINT]
25
25
self .font_parser = FontParser ()
26
26
27
27
def get_extra_field_data (self , file_name ):
@@ -109,7 +109,7 @@ def get_arc_angles(self, d):
109
109
return round (a1 , 2 ), round (a2 , 2 )
110
110
111
111
def parse_shape (self , d ):
112
- # type: (pcbnew.PCB_SHAPE) -> dict or None
112
+ # type: (pcbnew.PCB_SHAPE) -> dict | None
113
113
shape = {
114
114
pcbnew .S_SEGMENT : "segment" ,
115
115
pcbnew .S_CIRCLE : "circle" ,
@@ -413,10 +413,17 @@ def get_all_drawings(self):
413
413
drawings .append (("val" , f .Value ()))
414
414
for d in f .GraphicalItems ():
415
415
drawings .append ((d .GetClass (), d ))
416
+ if hasattr (f , "GetFields" ):
417
+ fields = f .GetFields () # type: list[pcbnew.PCB_FIELD]
418
+ for field in fields :
419
+ if field .IsReference () or field .IsValue ():
420
+ continue
421
+ drawings .append ((field .GetClass (), field ))
422
+
416
423
return drawings
417
424
418
425
def parse_pad (self , pad ):
419
- # type: (pcbnew.PAD) -> dict or None
426
+ # type: (pcbnew.PAD) -> dict | None
420
427
layers_set = list (pad .GetLayerSet ().Seq ())
421
428
layers = []
422
429
if pcbnew .F_Cu in layers_set :
@@ -497,7 +504,7 @@ def parse_pad(self, pad):
497
504
def parse_footprints (self ):
498
505
# type: () -> list
499
506
footprints = []
500
- for f in self .footprints : # type: pcbnew.FOOTPRINT
507
+ for f in self .footprints :
501
508
ref = f .GetReference ()
502
509
503
510
# bounding box
@@ -619,8 +626,9 @@ def parse_tracks(self, tracks):
619
626
}
620
627
621
628
def parse_zones (self , zones ):
629
+ # type: (list[pcbnew.ZONE]) -> dict
622
630
result = {pcbnew .F_Cu : [], pcbnew .B_Cu : []}
623
- for zone in zones : # type: pcbnew.ZONE
631
+ for zone in zones :
624
632
if (not zone .IsFilled () or
625
633
hasattr (zone , 'GetIsKeepout' ) and zone .GetIsKeepout () or
626
634
hasattr (zone , 'GetIsRuleArea' ) and zone .GetIsRuleArea ()):
0 commit comments