aboutsummaryrefslogtreecommitdiff
path: root/src/ee/project
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-23 07:29:49 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-23 07:32:10 +0100
commit689508e07dba890fff8d1cd06e0029eca1c30994 (patch)
tree50898ade69fc853bf7310ee002767ba3990ae86a /src/ee/project
parent1fe278b37b4031a42f8e27ee4f3251b474efcb16 (diff)
downloadee-python-689508e07dba890fff8d1cd06e0029eca1c30994.tar.gz
ee-python-689508e07dba890fff8d1cd06e0029eca1c30994.tar.bz2
ee-python-689508e07dba890fff8d1cd06e0029eca1c30994.tar.xz
ee-python-689508e07dba890fff8d1cd06e0029eca1c30994.zip
xsd:
o Adding <link> list on <part>. For media, datasheets etc. digikey: o Parsing out media. PartDb: o starting on a more generic object db with indexes. order: o Using the new object db for building data while resolving parts. o Creating a report from the order.
Diffstat (limited to 'src/ee/project')
-rw-r--r--src/ee/project/report.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ee/project/report.py b/src/ee/project/report.py
index 5370f6c..80e590a 100644
--- a/src/ee/project/report.py
+++ b/src/ee/project/report.py
@@ -4,6 +4,7 @@ from typing import Optional
from jinja2 import Environment, PackageLoader, select_autoescape
from ee.tools import mk_parents
+from ee.xml import types, bom_file_utils
class Message(object):
@@ -12,16 +13,40 @@ class Message(object):
self.text = text
+def section_filter(s: str):
+ return "{}\n{}".format(s, "=" * len(s))
+
+
def subsection_filter(s: str):
+ return "{}\n{}".format(s, "-" * len(s))
+
+
+def subsubsection_filter(s: str):
return "{}\n{}".format(s, "~" * len(s))
+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_spn_filter(part: types.Part):
+ return next(iter(bom_file_utils.supplier_part_numbers(part)), None)
+
+
def save_report(package: str, template_name: str, out_file: Path, **kwargs):
env = Environment(
loader=PackageLoader(package, "templates"),
autoescape=select_autoescape(["html", "xml"]),
)
env.filters["subsection"] = subsection_filter
+ env.filters["subsubsection"] = subsubsection_filter
+ env.filters["subsubsubsection"] = subsubsubsection_filter
+ env.filters["first_pn"] = first_pn_filter
+ env.filters["first_spn"] = first_spn_filter
mk_parents(out_file)
with out_file.open("w") as f: