aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ee/tools/part_validate_parts.py44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/ee/tools/part_validate_parts.py b/src/ee/tools/part_validate_parts.py
index 65477e5..699bcce 100644
--- a/src/ee/tools/part_validate_parts.py
+++ b/src/ee/tools/part_validate_parts.py
@@ -57,35 +57,55 @@ class Context(object):
return self.uri_idx.get_single(part_uri)
+def check_has_part(ctx: Context, bom: Part, sch: Part):
+ ms = Messages(sch)
+
+ part_ref = bom.get_only_part_reference()
+
+ if part_ref is None:
+ ms.warning("Part has footprint in schematic but no BOM part selected.")
+
+ return ms
+
+
def check_has_footprint(ctx: Context, bom: Part, sch: Part):
ms = Messages(sch)
fp = sch.facts.get_value(common_fact_types.footprint)
- if fp is None:
- return ms.warning("No footprint in schematic part")
- part_ref = bom.get_only_part_reference()
+ supplier_ref = bom.get_only_part_reference()
- if part_ref is None:
- return ms.warning("Part has footprint in schematic but no BOM part selected.")
+ if fp is None:
+ ms.warning("No footprint in schematic part")
- supplier_part = ctx.get_supplier_part(part_ref.part_uriProp)
+ if supplier_ref is None:
+ return # Just return, other checks will tell about missing BOM part
+
+ supplier_part = ctx.get_supplier_part(supplier_ref.part_uriProp)
supplier_fp = supplier_part.facts.get_value(common_fact_types.footprint)
- if supplier_fp is None:
- return ms.warning(f"Part has footprint in schematic and a BOM part but the BOM part doesn't have a footprint. "
- f"Part's footprint: {fp}.")
- if fp != supplier_fp:
+ if supplier_ref is not None and supplier_fp is None:
+ ms.warning(f"The BOM part does not have a footprint.")
+
+ if fp is not None and supplier_fp is not None and fp != supplier_fp:
return ms.warning("Part has footprint in schematic and a BOM part but their footprints do not match. "
f"Footprints: part: {fp}, BOM: {supplier_fp}.")
- return ms.info("Part has footprint and BOM part. Their footprints matches.")
+ if fp is None and supplier_fp is not None:
+ return ms.warning(f"The schematic part's footprint should be compatible with the BOM part's' footprint: "
+ f"{supplier_fp}.")
+
+ if len(ms.messages) == 0:
+ ms.info("Part has footprint and BOM part. Their footprints matches.")
+
+ return ms
def validate(f, ctx: Context, bom_part: Part, sch_part: Part):
validators = [
- check_has_footprint
+ check_has_footprint,
+ check_has_part,
]
messages = Messages(sch_part)