aboutsummaryrefslogtreecommitdiff
path: root/src/ee/tools
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-20 23:36:49 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-05-20 23:36:49 +0200
commit9bbb4f8f3a1d8e2bfe1f06c945081153435de940 (patch)
tree9624e2303ca87859e6952707e450eadca8e69bb3 /src/ee/tools
parent5f3623b8dd26b37b9ea6011bf71467b2a608b5ff (diff)
downloadee-python-9bbb4f8f3a1d8e2bfe1f06c945081153435de940.tar.gz
ee-python-9bbb4f8f3a1d8e2bfe1f06c945081153435de940.tar.bz2
ee-python-9bbb4f8f3a1d8e2bfe1f06c945081153435de940.tar.xz
ee-python-9bbb4f8f3a1d8e2bfe1f06c945081153435de940.zip
o Replacing digikey-normalize-facts with part-apply-function. Moving
code from tool to ee.digikey.functions.
Diffstat (limited to 'src/ee/tools')
-rw-r--r--src/ee/tools/digikey_normalize_facts.py19
-rw-r--r--src/ee/tools/init.py7
-rw-r--r--src/ee/tools/part_apply_function.py5
-rw-r--r--src/ee/tools/templates/build.ninja.j227
4 files changed, 23 insertions, 35 deletions
diff --git a/src/ee/tools/digikey_normalize_facts.py b/src/ee/tools/digikey_normalize_facts.py
deleted file mode 100644
index decf435..0000000
--- a/src/ee/tools/digikey_normalize_facts.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import argparse
-from pathlib import Path
-
-from ee.digikey.normalize_facts import normalize_facts
-
-parser = argparse.ArgumentParser()
-
-parser.add_argument("--in",
- dest="in_",
- required=True,
- metavar="PART DB")
-
-parser.add_argument("--out",
- required=True,
- metavar="PART DB")
-
-args = parser.parse_args()
-
-normalize_facts(Path(args.in_), Path(args.out))
diff --git a/src/ee/tools/init.py b/src/ee/tools/init.py
index 6d7908e..f77b60b 100644
--- a/src/ee/tools/init.py
+++ b/src/ee/tools/init.py
@@ -35,6 +35,12 @@ def init_kicad_project(basedir: Path, cfg, args):
cfg["kicad-project"]["strategy"] = args.kicad_bom_strategy
+def init_digikey(project: Project):
+ project.cfg.add_section("supplier:digikey")
+
+ project.cfg["supplier:digikey"]["function"] = "ee.kicad.digikey.functions.default"
+
+
def init_seeed_opl(project: Project):
import ee.supplier.seeed
ee.supplier.seeed.init_project(project)
@@ -45,6 +51,7 @@ def init(project_dir: Path, basedir: Path, args):
project = Project(project_dir, cfg)
init_kicad_project(basedir, cfg, args)
+ init_digikey(project)
init_seeed_opl(project)
if args.create_bom_strategy:
diff --git a/src/ee/tools/part_apply_function.py b/src/ee/tools/part_apply_function.py
index af51b5a..b2c9585 100644
--- a/src/ee/tools/part_apply_function.py
+++ b/src/ee/tools/part_apply_function.py
@@ -72,15 +72,14 @@ parser.add_argument("--function",
metavar="FUNCTION")
parser.add_argument("--argument",
- required=True,
nargs="*",
metavar="ARG")
parser.add_argument("--execution",
- default="default")
+ required=True)
args = parser.parse_args()
project = Project.load()
report = project.report_dir / "apply-function" / (args.execution + ".rst")
-work(Path(args.in_path), Path(args.out), report, args.function, args.argument)
+work(Path(args.in_path), Path(args.out), report, args.function, args.argument or [])
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 0aaa76f..cb98921 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -26,7 +26,7 @@ rule pn-part-search-list
command = $ee pn-part-search-list --in $in --out $out --supplier $supplier
rule part-apply-function
- command = $ee part-apply-function --in $in --out $out $functions $arguments
+ command = $ee part-apply-function --execution $execution --in $in --out $out $functions $arguments
rule part-find-requirements
description = part-find-requirements
@@ -39,18 +39,10 @@ rule digikey-search-parts
description = digikey-search-parts
command = $ee digikey-search-parts --in $in --out $out
-rule digikey-normalize-facts
- description = digikey-normalize-facts
- command = $ee digikey-normalize-facts --in $in --out $out
-
rule element14-search-parts
description = element14-search-parts
command = $ee element14-search-parts --in $in --out $out
-rule element14-normalize-facts
- description = element14-normalize-facts
- command = $ee element14-normalize-facts --in $in --out $out
-
rule create-bom
description = create-bom
command = $ee create-bom --schematic $schematic --part-db $part_dbs --out $out $strategy
@@ -81,6 +73,7 @@ build {{ gerber_zip }}: kicad-gerber $pcb
{% if sch is defined -%}
build ee/kicad-sch.xml: kicad-make-bom $sch
build ee/sch.xml: part-apply-function ee/kicad-sch.xml
+ execution = kicad
{%- if project.cfg["kicad-project"]["functions"] %}
functions = --function {{ project.cfg["kicad-project"]["functions"] }}
{%- else %}
@@ -89,7 +82,7 @@ build ee/sch.xml: part-apply-function ee/kicad-sch.xml
{%- if project.cfg["kicad-project"]["function-arguments"] %}
arguments = --argument {{ project.cfg["kicad-project"]["function-arguments"] }}
{%- else %}
- arguments = --argument ""
+ arguments =
{%- endif %}
{%- endif %}
@@ -98,15 +91,23 @@ build $report_dir/part-validate-parts.rst: part-validate-parts ee/sch.xml
build ee/requirements.xml: part-find-requirements ee/sch.xml
{% for s in distributors %}
+{%- set cfg = project.cfg["supplier:" + s] if "supplier:" + s in project.cfg else None %}
# Supplier {{ s }}
build ee/{{ s }}/pn-part-search-list.xml: pn-part-search-list ee/sch.xml
supplier = {{ s }}
build ee/{{ s }}/downloaded.xml | ee/{{ s }}/downloaded.rst: {{ s }}-search-parts ee/{{ s }}/pn-part-search-list.xml
-build ee/{{ s }}/parts.xml: {{ s }}-normalize-facts ee/{{ s }}/downloaded.xml
-
-default ee/{{ s }}/parts.xml
+build ee/{{ s }}/parts.xml: part-apply-function ee/{{ s }}/downloaded.xml
+ execution = {{ s }}
+{%- if cfg and "functions" in cfg %}
+ functions = --function {{ cfg["functions"] }}
+{%- else %}
+ functions = --function ee.{{ s }}.functions.default
+{%- endif %}
+{%- if cfg and "function-arguments" in cfg %}
+ arguments = --argument {{ cfg["function-arguments"] }}
+{%- endif %}
{%- endfor %}
{%- for f in parts_yaml_files %}