aboutsummaryrefslogtreecommitdiff
path: root/src/ee
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-25 11:55:54 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-25 12:58:59 +0100
commit50ee4b871bc9d0076cabaa5d2ea4ad1ba7b8e15a (patch)
tree05ee9273b41efa1d9268b32f829881c6f6d06eaa /src/ee
parentb230198488ef670ed6e374e0d39d5f4e6ac07e8d (diff)
downloadee-python-50ee4b871bc9d0076cabaa5d2ea4ad1ba7b8e15a.tar.gz
ee-python-50ee4b871bc9d0076cabaa5d2ea4ad1ba7b8e15a.tar.bz2
ee-python-50ee4b871bc9d0076cabaa5d2ea4ad1ba7b8e15a.tar.xz
ee-python-50ee4b871bc9d0076cabaa5d2ea4ad1ba7b8e15a.zip
ninja tool: changing to generate the files in the current directory.
build.ninja.j2: nits. olinuxino: Improving parsing of part values.
Diffstat (limited to 'src/ee')
-rw-r--r--src/ee/part/fact_keys.py13
-rw-r--r--src/ee/project/__init__.py7
-rw-r--r--src/ee/tools/ninja.py7
-rw-r--r--src/ee/tools/templates/build.ninja.j25
-rw-r--r--src/ee/xml/bom_file_utils.py5
5 files changed, 29 insertions, 8 deletions
diff --git a/src/ee/part/fact_keys.py b/src/ee/part/fact_keys.py
new file mode 100644
index 0000000..5ca3c5b
--- /dev/null
+++ b/src/ee/part/fact_keys.py
@@ -0,0 +1,13 @@
+capacitance = "http://purl.org/ee/fact-type/capacitance"
+max_voltage = "http://purl.org/ee/fact-type/voltage"
+# https://en.wikipedia.org/wiki/Ceramic_capacitor#Class_2_ceramic_capacitors
+rs_198_class_2 = "http://purl.org/ee/fact-type/rs-198 class 2"
+resistance = "http://purl.org/ee/fact-type/resistance"
+value_tolerance = "http://purl.org/ee/fact-type/value-tolerance"
+
+# Should only be used when the type of value is unknown (i.e. not a capacitor, resistor etc)
+value = "http://purl.org/ee/fact-type/value"
+
+place_part = "http://purl.org/ee/fact-type/place-part"
+
+imperial_footprint_size = "http://purl.org/ee/fact-type/imperial-footprint-size"
diff --git a/src/ee/project/__init__.py b/src/ee/project/__init__.py
index a1f042f..5943a7c 100644
--- a/src/ee/project/__init__.py
+++ b/src/ee/project/__init__.py
@@ -6,8 +6,11 @@ def load_config(project_dir: Path) -> configparser.ConfigParser:
config = configparser.ConfigParser()
config_path = project_dir / ".ee" / "config"
- with config_path.open("r") as f:
- config.read_file(f, source=str(config_path))
+ try:
+ with config_path.open("r") as f:
+ config.read_file(f, source=str(config_path))
+ except FileNotFoundError:
+ pass
return config
diff --git a/src/ee/tools/ninja.py b/src/ee/tools/ninja.py
index 0987004..f04b174 100644
--- a/src/ee/tools/ninja.py
+++ b/src/ee/tools/ninja.py
@@ -28,7 +28,7 @@ def ninja_path_filter(s: Union[Path, str, List[str]]) -> str:
raise Exception("Unsupported argument type: {}".format(type(s)))
-def parent_dir_filter(s: str) -> Path:
+def parent_dir_filter(s: Union[str, Path]) -> Path:
return Path(s).parent
@@ -76,9 +76,10 @@ def generate(project: Project, sch_path: Path, kicad_bom_strategy: Optional[str]
if gerber_zip is not None:
params["gerber_zip"] = gerber_zip
- build_ninja = sch_path.parent / "build.ninja"
+ # ee_dir = sch_path.parent / "ee"
+ ee_dir = Path(".")
+ build_ninja = ee_dir / "build.ninja"
- ee_dir = sch_path.parent / "ee"
parts_yaml_files = [path for path in ee_dir.iterdir() if str(path).endswith("-parts.yaml")]
params["parts_yaml_files"] = parts_yaml_files
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 9489aac..514e177 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -52,9 +52,8 @@ build {{ gerber_zip }}: kicad-gerber $pcb
{%- endif %}
build ee/sch.xml: kicad-make-bom $sch
- strategy = {{ "--strategy " + kicad_bom_strategy if kicad_bom_strategy else "" }}
-
-{%- for d in distributors %}
+ strategy ={{ " --strategy " + kicad_bom_strategy if kicad_bom_strategy else "" }}
+{% for d in distributors %}
# Distributor {{ d }}
build ee/{{ d }}/search-list.xml: part-create-distributor-search-list ee/sch.xml
distributor = {{ d }}
diff --git a/src/ee/xml/bom_file_utils.py b/src/ee/xml/bom_file_utils.py
index 207ac5a..97b609f 100644
--- a/src/ee/xml/bom_file_utils.py
+++ b/src/ee/xml/bom_file_utils.py
@@ -42,3 +42,8 @@ def facts(part: types.Part, create=False) -> Optional[types.FactList]:
fs = types.FactList()
part.factsProp = fs
return fs
+
+
+def find_fact(fs: types.FactList, key: str) -> Optional[types.Fact]:
+ l: List[types.Fact] = fs.factProp
+ return next((f for f in l if f.keyProp == key), None)