From 8ba17872dc1019f3833cd47bcf6d0df84d516a23 Mon Sep 17 00:00:00 2001 From: SET Date: Sat, 15 Aug 2020 11:04:25 -0300 Subject: [PATCH] Recoded get_user_fields. The previous implementation worked but if we fail to load any of the default fields we could fail to return one of the user defined ones. The new code is more robust. Also commented get_field_names that isn't currently used. --- kiplot/kicad/v5_sch.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kiplot/kicad/v5_sch.py b/kiplot/kicad/v5_sch.py index bd44db9f..c82c8fad 100644 --- a/kiplot/kicad/v5_sch.py +++ b/kiplot/kicad/v5_sch.py @@ -593,14 +593,12 @@ class SchematicComponent(object): return self.dfields[field].value return '' - def get_field_names(self): - return [f.name for f in self.fields] + # def get_field_names(self): + # return [f.name for f in self.fields] def get_user_fields(self): """ Returns a list of tuples with the user defined fields (name, value) """ - if len(self.fields) < 4: - return [] - return [(f.name, f.value) for f in self.fields[4:]] + return [(f.name, f.value) for f in self.fields if f.number > 3] def add_field(self, field): self.fields.append(field)