aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-08-02 21:42:01 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-08-02 21:53:00 +0200
commite1012e314d6c21ad1b75082a292506cd751a9117 (patch)
tree4530dfff8cf7545d8395c6400fe5efc29e490c42
parentb6c8c2c103b98097adef2fd18547feb6fd7e1952 (diff)
downloadee-python-e1012e314d6c21ad1b75082a292506cd751a9117.tar.gz
ee-python-e1012e314d6c21ad1b75082a292506cd751a9117.tar.bz2
ee-python-e1012e314d6c21ad1b75082a292506cd751a9117.tar.xz
ee-python-e1012e314d6c21ad1b75082a292506cd751a9117.zip
o Fixing a bad bug and learning some Python: list.insert(index, value)
will only insert at index if the list is index long. If not it will just append them. Yay. Much better digikey part data now. Creating a ValueList that automatically expands the list. o Stopping with silly key and value replacements. o Updating tests.
-rw-r--r--demo/doit/ee/digikey-parts/digikey-part/493-4771-1-ND.ini2
-rw-r--r--demo/doit/ee/digikey-parts/digikey-part/BC2AAPC-ND.ini18
-rw-r--r--demo/doit/ee/digikey-parts/digikey-part/RMCF1206JT10K0CT-ND.ini24
-rw-r--r--src/ee/digikey/doit.py4
-rw-r--r--src/ee/ds/__init__.py20
-rw-r--r--test/doit/test_doit.py20
6 files changed, 49 insertions, 39 deletions
diff --git a/demo/doit/ee/digikey-parts/digikey-part/493-4771-1-ND.ini b/demo/doit/ee/digikey-parts/digikey-part/493-4771-1-ND.ini
index 17ab33d..a263bf9 100644
--- a/demo/doit/ee/digikey-parts/digikey-part/493-4771-1-ND.ini
+++ b/demo/doit/ee/digikey-parts/digikey-part/493-4771-1-ND.ini
@@ -8,7 +8,7 @@ mpn = UCA2G100MPD1TD
7/packaging = Cut Tape (CT)
1989/part status = Active
2049/capacitance = 10µF
-3/tolerance = ±20%%
+3/tolerance = ±20%
2079/voltage - rated = 400V
724/esr (equivalent series resistance) = -
725/lifetime @ temp. = 10000 Hrs @ 105°C
diff --git a/demo/doit/ee/digikey-parts/digikey-part/BC2AAPC-ND.ini b/demo/doit/ee/digikey-parts/digikey-part/BC2AAPC-ND.ini
index d25e417..5629485 100644
--- a/demo/doit/ee/digikey-parts/digikey-part/BC2AAPC-ND.ini
+++ b/demo/doit/ee/digikey-parts/digikey-part/BC2AAPC-ND.ini
@@ -5,14 +5,14 @@ type = digikey-part
part-number = BC2AAPC-ND
url = https://www.digikey.com/product-detail/en/mpd-memory-protection-devices/BC2AAPC/BC2AAPC-ND/455777
mpn = BC2AAPC
-7/packaging = Active
-1989/part status = Cylindrical, Holder
-2049/capacitance = Holder (Open)
-3/tolerance = AA
-2079/voltage - rated = 2
-724/esr (equivalent series resistance) = -
-725/lifetime @ temp. = PCB, Through Hole
+1989/part status = Active
252/operating temperature = -10°C ~ 100°C
-52/polarization = PC Pin
-707/ratings = 0.591" (15.01mm)
+69/mounting type = PCB, Through Hole
+1445/battery type, function = Cylindrical, Holder
+91/style = Holder (Open)
+32/battery cell size = AA
+36/number of cells = 2
+1142/battery series = -
+258/termination style = PC Pin
+759/height above board = 0.591" (15.01mm)
diff --git a/demo/doit/ee/digikey-parts/digikey-part/RMCF1206JT10K0CT-ND.ini b/demo/doit/ee/digikey-parts/digikey-part/RMCF1206JT10K0CT-ND.ini
index ce84f05..8cff77a 100644
--- a/demo/doit/ee/digikey-parts/digikey-part/RMCF1206JT10K0CT-ND.ini
+++ b/demo/doit/ee/digikey-parts/digikey-part/RMCF1206JT10K0CT-ND.ini
@@ -7,17 +7,17 @@ url = https://www.digikey.com/product-detail/en/stackpole-electronics-inc/RMCF12
mpn = RMCF1206JT10K0
7/packaging = Cut Tape (CT)
1989/part status = Active
-2049/capacitance = 10 kOhms
-3/tolerance = ±5%%
-2079/voltage - rated = 0.25W, 1/4W
-724/esr (equivalent series resistance) = Thick Film
-725/lifetime @ temp. = Automotive AEC-Q200
+3/tolerance = ±5%
252/operating temperature = -55°C ~ 155°C
-52/polarization = ±200ppm/°C
-707/ratings = 1206 (3216 Metric)
-405/applications = 1206
-2253/ripple current @ low frequency = 0.126" L x 0.063" W (3.20mm x 1.60mm)
-2260/ripple current @ high frequency = 0.028" (0.70mm)
-508/lead spacing = 2
-46/size / dimension = -
+46/size / dimension = 0.126" L x 0.063" W (3.20mm x 1.60mm)
+1500/height - seated (max) = 0.028" (0.70mm)
+16/package / case = 1206 (3216 Metric)
+2085/resistance = 10 kOhms
+2/power (watts) = 0.25W, 1/4W
+174/composition = Thick Film
+5/features = Automotive AEC-Q200
+17/temperature coefficient = ±200ppm/°C
+1291/supplier device package = 1206
+1127/number of terminations = 2
+1531/failure rate = -
diff --git a/src/ee/digikey/doit.py b/src/ee/digikey/doit.py
index 6f7c2d5..0452530 100644
--- a/src/ee/digikey/doit.py
+++ b/src/ee/digikey/doit.py
@@ -142,9 +142,7 @@ def download_part_facts(output: DataSet, in_ds: DataSet):
for a in product.attributes:
key = "{}/{}".format(a.attribute_type.id, a.attribute_type.label)
- key = key.replace("%", "_")
- value = a.value.replace("%", "%%")
- o.set(key, value)
+ o.set(key, a.value)
def task_digikey_fetch_full_part_facts():
diff --git a/src/ee/ds/__init__.py b/src/ee/ds/__init__.py
index 5b4da4d..026ab9b 100644
--- a/src/ee/ds/__init__.py
+++ b/src/ee/ds/__init__.py
@@ -15,7 +15,6 @@ class ObjectType(object):
def __init__(self, name: str):
self._name = name
self._fields = [] # type: List[str]
- self._objects = {}
def __eq__(self, o) -> bool:
other = o # type: ObjectType
@@ -54,11 +53,24 @@ class ObjectType(object):
class Object(object):
+ class ValueList(list):
+ """An auto-expanding version of list."""
+
+ def __setitem__(self, index, value):
+ if index >= len(self):
+ self.extend([None] * (index + 1 - len(self)))
+ list.__setitem__(self, index, value)
+
+ def __getitem__(self, index):
+ if index >= len(self):
+ self.extend([None] * (index + 1 - len(self)))
+ return list.__getitem__(self, index)
+
def __init__(self, ds: "DataSet", ot: ObjectType, key: str):
self._ds = ds
self._ot = ot
self._key = key
- self._data = []
+ self._data = Object.ValueList()
@property
def object_type(self):
@@ -72,7 +84,7 @@ class Object(object):
if self._ds._frozen:
raise Exception("This data set is frozen")
idx = self._ot.index_of(key, create=True)
- self._data.insert(idx, value)
+ self._data[idx] = value
return self
@@ -115,7 +127,7 @@ class Object(object):
def get(self, key: str) -> Optional[str]:
idx = self._ot.index_of(key)
- return self._data[idx] if idx is not None and idx < len(self._data) else None
+ return self._data[idx] if idx is not None else None
def get_req(self, key: str) -> str:
idx = self._ot.index_of(key)
diff --git a/test/doit/test_doit.py b/test/doit/test_doit.py
index 6f70c6b..fc13192 100644
--- a/test/doit/test_doit.py
+++ b/test/doit/test_doit.py
@@ -1,21 +1,20 @@
import inspect
import os
-import os.path
-import logging
-from pathlib import Path
-from ee.ds import DataSetManager
+import pathlib
from inspect import Parameter
-import ee.kicad.doit
-import ee.digikey.doit
-from ee.kicad.doit import *
+import ee.digikey.doit
+import ee.kicad.doit
from ee.digikey.doit import *
+from ee.ds import DataSetManager
+from ee.kicad.doit import *
logger = logging.getLogger(__name__)
-file_dir = Path(__file__).parent
+file_dir = pathlib.Path(__file__).parent
schematics_dir = file_dir / "schematics"
+
def exec_task(task):
targets = task["targets"]
for a in task["actions"]:
@@ -34,7 +33,7 @@ def exec_task(task):
# noinspection SpellCheckingInspection
def test_doit(tmpdir, caplog):
- dsm = DataSetManager(os.path.join(tmpdir, "ee"))
+ dsm = DataSetManager(pathlib.Path(tmpdir) / "ee")
dsm.register_ds("csv", "kicad-footprint", "kicad-footprint-mapping",
path=schematics_dir / "ee" / "kicad-footprint.csv")
@@ -44,7 +43,7 @@ def test_doit(tmpdir, caplog):
lambda ds: ds + ["kicad-footprint"])
ee.kicad.doit.init(sch=schematics_dir / "schematic-1.sch",
- kicad_pcb=schematics_dir / "schematic-1.kicad_pcb",)
+ kicad_pcb=schematics_dir / "schematic-1.kicad_pcb", )
ee.digikey.doit.doit_config.configure(data_set_manager=dsm)
@@ -52,3 +51,4 @@ def test_doit(tmpdir, caplog):
exec_task(task_kicad_pcb_to_data_set())
exec_task(task_kicad_create_component_data_set())
exec_task(task_digikey_resolve_schematic_components())
+ exec_task(task_digikey_fetch_full_part_facts())