From fa85d46af0b91477cf354947df628af0dc0d2800 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 28 Mar 2019 16:38:50 +0100 Subject: ee.xsd: o Renaming to . o Adding on , removing from . A part can have exactly one part. create-order: o Creating anonymous part objects, with two references, one schematic reference and one part-uri reference to the selected part. o Redoing how the order is calculated with the new ObjDb structure. ee.part.Part: o Absorbing bom_file_utils into Part. Much better wrapper object around the xml goop. --- src/ee/project/report.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/ee/project/report.py') diff --git a/src/ee/project/report.py b/src/ee/project/report.py index 80e590a..26cdaa3 100644 --- a/src/ee/project/report.py +++ b/src/ee/project/report.py @@ -3,8 +3,9 @@ from typing import Optional from jinja2 import Environment, PackageLoader, select_autoescape +from ee.part import Part from ee.tools import mk_parents -from ee.xml import types, bom_file_utils +from ee.xml import types class Message(object): @@ -29,12 +30,16 @@ def subsubsubsection_filter(s: str): return "{}\n{}".format(s, "." * len(s)) -def first_pn_filter(part: types.Part): - return next(iter(bom_file_utils.part_numbers(part)), None) +def first_ref_filter(part: Part) -> Optional[types.SchematicReference]: + return part.get_only_schematic_reference() -def first_spn_filter(part: types.Part): - return next(iter(bom_file_utils.supplier_part_numbers(part)), None) +def first_pn_filter(part: Part) -> Optional[types.PartNumber]: + return part.get_only_mpn() + + +def first_spn_filter(part: Part) -> Optional[types.SupplierPartNumber]: + return part.get_only_spn() def save_report(package: str, template_name: str, out_file: Path, **kwargs): @@ -45,6 +50,7 @@ def save_report(package: str, template_name: str, out_file: Path, **kwargs): env.filters["subsection"] = subsection_filter env.filters["subsubsection"] = subsubsection_filter env.filters["subsubsubsection"] = subsubsubsection_filter + env.filters["first_ref"] = first_ref_filter env.filters["first_pn"] = first_pn_filter env.filters["first_spn"] = first_spn_filter -- cgit v1.2.3