aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-28 15:25:31 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-05-28 15:32:04 +0200
commit4c2c0ea503bd38cc637e0c3279cb0d508d831594 (patch)
treeaa249472211edd34202cac2a4f5034b466d5adce
parent79ee5e3c64c0140a61324914d24049478a9cf7f5 (diff)
downloadee-python-4c2c0ea503bd38cc637e0c3279cb0d508d831594.tar.gz
ee-python-4c2c0ea503bd38cc637e0c3279cb0d508d831594.tar.bz2
ee-python-4c2c0ea503bd38cc637e0c3279cb0d508d831594.tar.xz
ee-python-4c2c0ea503bd38cc637e0c3279cb0d508d831594.zip
part-validate-parts: Better output, yielding a message even if
everything is ok. ninja: Include the digikey.dl as a dependency even if custom is used. digikey.dl: More rules.
-rw-r--r--src/ee/souffle/digikey.dl29
-rw-r--r--src/ee/tools/part_validate_parts.py6
-rw-r--r--src/ee/tools/templates/build.ninja.j22
3 files changed, 32 insertions, 5 deletions
diff --git a/src/ee/souffle/digikey.dl b/src/ee/souffle/digikey.dl
index 06123ea..940e31d 100644
--- a/src/ee/souffle/digikey.dl
+++ b/src/ee/souffle/digikey.dl
@@ -2,5 +2,30 @@
.output fact
-fact(part, "http://purl.org/ee/fact-type/footprint", "1005") :-
- fact(part, "http://purl.org/ee/digikey-fact-key#16", "0402 (1005 Metric)").
+#define RESISTANCE "http://purl.org/ee/digikey-fact-key#2085"
+#define CAPACITANCE "http://purl.org/ee/digikey-fact-key#2049"
+#define SURFACE_MOUNT_LAND_SIZE "http://purl.org/ee/digikey-fact-key#884"
+#define PACKAGE "http://purl.org/ee/digikey-fact-key#16"
+#define MOUNTING_TYPE "http://purl.org/ee/digikey-fact-key#69"
+
+/*
+I though this rule would be good enough, but I keep on getting errors like this:
+
+warning: wrong index position provided by substr("DO-21",6,5) functor.
+
+fact(part, "http://purl.org/ee/fact-type/footprint", res) :-
+ fact(part, PACKAGE, package),
+ match(".*\([0-9][0-9][0-9][0-9] Metric\)", package),
+ res_ = substr(package, 0, strlen(package)-8),
+ res = substr(res_, 6, strlen(res_))
+ .
+*/
+
+.decl dk_to_ipc(dk:symbol, ipc:symbol)
+
+dk_to_ipc("0402 (1005 Metric)", "1005").
+dk_to_ipc("0805 (2012 Metric)", "2012").
+
+fact(part, "http://purl.org/ee/fact-type/footprint", ipc) :-
+ fact(part, "http://purl.org/ee/digikey-fact-key#16", dk),
+ dk_to_ipc(dk, ipc).
diff --git a/src/ee/tools/part_validate_parts.py b/src/ee/tools/part_validate_parts.py
index a9c5ba7..65477e5 100644
--- a/src/ee/tools/part_validate_parts.py
+++ b/src/ee/tools/part_validate_parts.py
@@ -80,7 +80,7 @@ def check_has_footprint(ctx: Context, bom: Part, sch: Part):
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}.")
- ms.info("Part has footprint and BOM part. Their footprints matches.")
+ return ms.info("Part has footprint and BOM part. Their footprints matches.")
def validate(f, ctx: Context, bom_part: Part, sch_part: Part):
@@ -144,7 +144,7 @@ def work(bom_path: Path, sch_path: Path, report_path: Path, part_dbs: List[Path]
print("Message index", file=f)
print("=============", file=f)
print("", file=f)
- for message, messages_ in groupby(messages.messages, lambda m: m[2]):
+ for message, messages_ in groupby(sorted(messages.messages, key=lambda m: m[2]), lambda m: m[2]):
messages = list(messages_)
print(message, file=f)
print("{}".format("-" * len(message)), file=f)
@@ -152,6 +152,8 @@ def work(bom_path: Path, sch_path: Path, report_path: Path, part_dbs: List[Path]
for m in messages:
print(" * {}".format(m[0].printable_reference), file=f)
+ print("", file=f)
+
parser = argparse.ArgumentParser()
ee.tools.add_default_argparse_group(parser)
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 206a487..e8ce404 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -138,7 +138,7 @@ build ee/{{ s }}/souffle/facts.dl: part-apply-souffle-pre ee/{{ s }}/downloaded.
{%- set main=souffle_ee_src + "/" + s + ".dl" %}
{%- set alt="ee/custom/" + s + "-souffle.dl" %}
-build ee/{{ s }}/souffle/out/fact.csv: souffle {{ alt if is_file(alt) else main }} | ee/{{ s }}/souffle/facts.dl
+build ee/{{ s }}/souffle/out/fact.csv: souffle {{ alt if is_file(alt) else main }} | {{ main }} ee/{{ s }}/souffle/facts.dl
work = ee/{{ s }}/souffle
build ee/{{ s }}/parts.xml: part-apply-souffle-post ee/{{ s }}/souffle/out/fact.csv