From 8d17fb5bc4b0dae0758e01a44d77d87acf2e686a Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 14 Mar 2019 06:27:16 +0100 Subject: o Adding module for searching on element14. o Starting on functionality create orders. Very WIP. o Adding a concept of an "ee project". Can load a gitconfig-like config file. o Adding a tool to import a yaml file into a part xml file. --- src/ee/element14/search_parts.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/ee/element14/search_parts.py (limited to 'src/ee/element14/search_parts.py') diff --git a/src/ee/element14/search_parts.py b/src/ee/element14/search_parts.py new file mode 100644 index 0000000..724485c --- /dev/null +++ b/src/ee/element14/search_parts.py @@ -0,0 +1,31 @@ +from pathlib import Path + +from ee.element14 import * +from ee.part import PartDb, load_db, save_db +from ee.xml import bom_file_utils, bomFile + +__all__ = ["search_parts"] + + +def search_parts(in_dir: Path, out_dir: Path, cache_dir: Path, config: Element14Config): + in_db = load_db(in_dir) + out_parts = PartDb() + + client = Element14Client(config, cache_dir) + + for part in in_db.iterparts(): + mpn = bom_file_utils.find_pn(part) + + query = mpn # TODO: suppor dpn + + out_id = query + + client.search(term="manuPartNum:" + query) + + out_part = bomFile.Part(id=out_id, + distributor_info=bomFile.DistributorInfo(), + part_numbers=part.part_numbersProp) + di = out_part.distributor_infoProp + + print("Saving {} work parts".format(out_parts.size())) + save_db(out_dir, out_parts) -- cgit v1.2.3