aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-02-27 16:09:53 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-02-27 16:09:53 +0100
commit0ce5c1e6dcea6643cf72de885c0aca52bf4ac28c (patch)
treeef9109b762a46079ce91aa3376f727aa76abf8b8 /src/ee/part
parentf14a40a4f80275daceeb73f944e1aa1f84d16c79 (diff)
downloadee-python-0ce5c1e6dcea6643cf72de885c0aca52bf4ac28c.tar.gz
ee-python-0ce5c1e6dcea6643cf72de885c0aca52bf4ac28c.tar.bz2
ee-python-0ce5c1e6dcea6643cf72de885c0aca52bf4ac28c.tar.xz
ee-python-0ce5c1e6dcea6643cf72de885c0aca52bf4ac28c.zip
o Always sorting index.xml for better git diffs.
o Normalizing more Digikey facts. o When creating distributor search lists, create a new plain <part> with containing only the part numbers.
Diffstat (limited to 'src/ee/part')
-rw-r--r--src/ee/part/__init__.py5
-rw-r--r--src/ee/part/create_distributor_search_list.py7
2 files changed, 9 insertions, 3 deletions
diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py
index 84a6174..e0b0087 100644
--- a/src/ee/part/__init__.py
+++ b/src/ee/part/__init__.py
@@ -91,7 +91,10 @@ def save_db(dir_path: Path, db: PartDb):
idx.filesProp = indexFile.FileList()
files = idx.filesProp.fileProp
- for part in db.iterparts():
+ parts = db.iterparts()
+ parts = sorted(parts, key=lambda p: p.idProp)
+
+ for part in parts:
id_ = part.id
path = dir_path / "{}.xml".format(id_)
with path.open("w") as f:
diff --git a/src/ee/part/create_distributor_search_list.py b/src/ee/part/create_distributor_search_list.py
index ef91e1f..cfbe0d5 100644
--- a/src/ee/part/create_distributor_search_list.py
+++ b/src/ee/part/create_distributor_search_list.py
@@ -1,6 +1,7 @@
from pathlib import Path
from ee.part import PartDb, load_db, save_db
+from ee.xml import bomFile
from ee.xml.bom_file_utils import *
__all__ = ["create_distributor_search_list"]
@@ -26,8 +27,10 @@ def create_distributor_search_list(in_dir: Path, out_dir: Path):
if entry is not None:
continue
- part.id = pn_value
- out_parts.add_entry(part, True)
+ new_part = bomFile.Part(id=pn_value)
+ new_part.part_numbersProp = part.part_numbersProp
+
+ out_parts.add_entry(new_part, True)
print("Saving {} work parts".format(out_parts.size()))
save_db(out_dir, out_parts)