aboutsummaryrefslogtreecommitdiff
path: root/src/ee
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-06-12 22:52:15 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-06-12 22:52:15 +0200
commitd9bb11a8c1f28727afd7c0fe74038a72affb959a (patch)
tree9a14587cc6a87abc9cf4fda9a2f205b10b5b7b6d /src/ee
parent7bea893adbb9e834d11e2706bdedc4f9db4969f8 (diff)
downloadee-python-d9bb11a8c1f28727afd7c0fe74038a72affb959a.tar.gz
ee-python-d9bb11a8c1f28727afd7c0fe74038a72affb959a.tar.bz2
ee-python-d9bb11a8c1f28727afd7c0fe74038a72affb959a.tar.xz
ee-python-d9bb11a8c1f28727afd7c0fe74038a72affb959a.zip
create-bom: Adding a way to ignore schematic entries from the bom with
the new "include-in-bom" fact.
Diffstat (limited to 'src/ee')
-rw-r--r--src/ee/bom.py12
-rw-r--r--src/ee/part/fact_keys.py2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/ee/bom.py b/src/ee/bom.py
index dd1c016..96da25a 100644
--- a/src/ee/bom.py
+++ b/src/ee/bom.py
@@ -6,7 +6,7 @@ from typing import List, Optional
from ee import EeException
from ee.db import ObjDb
from ee.logging import log
-from ee.part import PartDb, load_db, save_db, Part
+from ee.part import PartDb, load_db, save_db, Part, fact_keys
from ee.project import Project, report, SupplierDescriptor
from ee.xml import types
from ee.xml.uris import make_fact_key
@@ -83,6 +83,11 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs:
if part is None:
continue
+ include_in_bom = part.facts.get_value(fact_keys.include_in_bom) or "yes"
+ if include_in_bom == "no":
+ log.debug("Skipping {}, marked as schematic only".format(part.printable_reference))
+ continue
+
bom_parts.add(BomPart(part))
for bom_part in bom_parts:
@@ -136,6 +141,7 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs:
make_report(out_file, unresolved_parts, bom_parts, supplier_parts)
out_parts = PartDb()
+ found_parts = 0
for bom_part in bom_parts:
if not bom_part.selected_part:
log.info("No part selected for {}".format(bom_part.part.printable_reference))
@@ -152,8 +158,10 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs:
if supplier_part:
part.add_part_reference(supplier_part.uri)
+ found_parts += 1
out_parts.add_entry(part, True)
- log.info("Found {} of {} parts, missing {}".format(len(out_parts), len(sch_db), len(unresolved_parts)))
+ log.info("Found {} of {} parts (skipped {} that where not to be included in BOM), missing {}".
+ format(found_parts, len(bom_parts), len(sch_db) - len(bom_parts), len(unresolved_parts)))
save_db(out_path, out_parts)
diff --git a/src/ee/part/fact_keys.py b/src/ee/part/fact_keys.py
index 075d943..4444a9b 100644
--- a/src/ee/part/fact_keys.py
+++ b/src/ee/part/fact_keys.py
@@ -17,3 +17,5 @@ place_part = "http://purl.org/ee/fact-type/place-part"
imperial_footprint_size = "http://purl.org/ee/fact-type/imperial-footprint-size"
footprint = "http://purl.org/ee/fact-type/footprint"
+
+include_in_bom = "http://purl.org/ee/fact-type/include-in-bom"