aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-28 22:42:18 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-05-28 22:42:18 +0200
commit75e5bbd0679f4212ad6e9a402c9c68b7b5f40cae (patch)
tree230e2164527221649f1a67f020e05b9d6118f4a7
parente1d1095d37deb7b5861737511613546145c79cab (diff)
downloadee-python-75e5bbd0679f4212ad6e9a402c9c68b7b5f40cae.tar.gz
ee-python-75e5bbd0679f4212ad6e9a402c9c68b7b5f40cae.tar.bz2
ee-python-75e5bbd0679f4212ad6e9a402c9c68b7b5f40cae.tar.xz
ee-python-75e5bbd0679f4212ad6e9a402c9c68b7b5f40cae.zip
part-validate-parts: Better messages, inform about selected part's
footprint even if the schematic part doesn't have one.
-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)