aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ee/bom.py5
-rw-r--r--src/ee/templates/bom.rst.j259
2 files changed, 41 insertions, 23 deletions
diff --git a/src/ee/bom.py b/src/ee/bom.py
index cf18955..57eb558 100644
--- a/src/ee/bom.py
+++ b/src/ee/bom.py
@@ -9,7 +9,6 @@ from ee.logging import log
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
__all__ = ["create_bom"]
@@ -137,8 +136,8 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs:
format(bom_part.ref, ",".join(references)))
bom_parts.add_index("uri", lambda bp: bp.selected_part.uri if bp.selected_part else None)
- bom_parts.add_multi_index("supplier,part", lambda op: (
- op.selected_part.supplier, op.selected_part.uri) if op.selected_part else None)
+ bom_parts.add_multi_index("supplier,part", lambda bp: (
+ bp.selected_part.supplier, bp.selected_part.uri) if bp.selected_part else None)
out_file = project.report_dir / (os.path.splitext(out_path.name)[0] + ".rst")
make_report(out_file, unresolved_parts, bom_parts, supplier_parts)
diff --git a/src/ee/templates/bom.rst.j2 b/src/ee/templates/bom.rst.j2
index c8bed20..454d3f1 100644
--- a/src/ee/templates/bom.rst.j2
+++ b/src/ee/templates/bom.rst.j2
@@ -2,41 +2,59 @@
BOM
===
-{% if unresolved_parts %}
+{%- if unresolved_parts %}
+Unresolved Parts
+----------------
+
{{- unresolved_parts|length }} unresolved parts:
-{% for op in unresolved_parts %}
-* `{{ op.ref }} <ref-{{ op.ref }}_>`_
+{% for bp in unresolved_parts %}
+* `{{ bp.ref }} <ref-{{ bp.ref }}_>`_
{%- endfor %}
{%- endif %}
++-{{ "-"*30 }}-+-{{ "-"*60 }}-+-{{ "-"*60 }}-+
+| {{ "%-30s" | format("Reference") }} | {{ "%-60s" | format("MPN") }} | {{ "%-60s" | format("MPN") }} |
++={{ "="*30 }}=+={{ "="*60 }}=+={{ "="*60 }}=+
+{%- for bp in bom_parts %}
+{%- set ref="_`{}`".format(bp.ref, bp.ref) %}
+{%- set mpn=bp.selected_part.get_only_mpn().valueProp %}
+{%- set spn=bp.selected_part.get_only_spn().valueProp %}
+{%- set spn="`{} <part-{}_>`_".format(spn, spn) %}
+| {{ "%-30s" | format(ref) }} | {{ "%-60s" | format(mpn) }} | {{ "%-60s" | format(spn) }} |
++-{{ "-"*30 }}-+-{{ "-"*60 }}-+-{{ "-"*60 }}-+
+{%- endfor %}
+{#
Parts for BOM
===============
-{% for op in bom_parts %}
-.. _ref-{{ op.ref }}:
+{% for bp in bom_parts %}
+.. _ref-{{ bp.ref }}:
-{{ op.ref | subsection }}
-{% if op.available_from|length == 0 %}
+{{ bp.ref | subsection }}
+{% if not bp.selected_part %}
Could not find part.
-{% if op.part.get_mpns()|length == 1 -%}
-MPN: {{ op.part.get_mpns()[0].valueProp }}
-{% elif op.part.get_mpns()|length > 1 -%}
-{%- for mpn in op.part.get_mpns() %}
+{% if bp.part.get_mpns()|length == 1 -%}
+MPN: {{ bp.part.get_mpns()[0].valueProp }}
+{% elif bp.part.get_mpns()|length > 1 -%}
+{%- for mpn in bp.part.get_mpns() %}
MPNs:
-* {{ mpn.valueProp }}
+* {{ mpn.valuePrbp }}
{%- endfor %}
{%- endif -%}
-{% if op.part.get_spns()|length == 1 -%}
-SPN: {{ op.part.get_spns()[0].valueProp }}
-{% elif op.part.get_spns()|length > 1 -%}
-{%- for spn in op.part.get_spns() %}
+#}
+{# #}{#
+
+{% if bp.part.get_spns()|length == 1 -%}
+SPN: {{ bp.part.get_spns()[0].valueProp }}
+{% elif bp.part.get_spns()|length > 1 -%}
+{%- for spn in bp.part.get_spns() %}
SPNs:
* {{ spn.valueProp }}
{%- endfor %}
{%- endif -%}
-{% elif op.available_from|length == 1 %}
-{%- set part=op.available_from.values()|first %}
+{% elif bp.selected_part %}
+{%- set part=bp.selected_part %}
{%- set pn=part|first_pn %}
{%- set spn=part|first_spn %}
Selected supplier: {{ part.supplier }}{{ (", pn: " + pn.valueProp) if pn else "" }}{{ (", spn: " + spn.valueProp) if spn else "" }}.
@@ -45,6 +63,7 @@ Part: `{{pn.valueProp}} <part-{{pn.valueProp}}_>`_
MANY
{% endif %}
{%- endfor %}
+#}
Part details
============
@@ -56,7 +75,7 @@ Part details
{%- set pn=part|first_pn %}
{%- set spn=part|first_spn %}
{%- set title=pn.valueProp if pn else (spn.valueProp if spn else "???") %}
-.. _part-{{title}}:
+.. _part-{{spn.valueProp}}:
{{ title|subsubsection }}
@@ -66,7 +85,7 @@ Description {{ part.description }}
{%- endif %}
MPN {{ pn.value }}
SPN {{ spn.value }}
-Used by: {% for op in bom_part_uri_idx.get(part.uriProp) %}`{{ op.ref }} <ref-{{ op.ref }}_>`_{{ ", " if not loop.last }}{% endfor %}
+Used by: {% for bp in bom_part_uri_idx.get(part.uri) %}`{{ bp.ref }} <{{ bp.ref }}_>`_{{ ", " if not loop.last }}{% endfor %}
=========== ===
{#
Facts