aboutsummaryrefslogtreecommitdiff
path: root/src/ee/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/tools')
-rw-r--r--src/ee/tools/digikey_download_facts.py7
-rw-r--r--src/ee/tools/digikey_import_parts.py17
-rw-r--r--src/ee/tools/digikey_refresh_parts.py22
3 files changed, 43 insertions, 3 deletions
diff --git a/src/ee/tools/digikey_download_facts.py b/src/ee/tools/digikey_download_facts.py
index ee4cf20..3ab8551 100644
--- a/src/ee/tools/digikey_download_facts.py
+++ b/src/ee/tools/digikey_download_facts.py
@@ -45,7 +45,8 @@ parser.add_argument("--force",
args = parser.parse_args()
digikey = dk.Digikey()
-client = dk.DigikeyClient(digikey, on_download=log.debug)
+client = dk.DigikeyClient(on_download=log.debug)
+parser = dk.DigikeyParser(digikey)
repo = dk.DigikeyRepository(digikey, args.out)
@@ -79,7 +80,7 @@ for q in queries:
continue
log.info("Searching for {}".format(p))
- response = client.search(p)
+ response = parser.parse_string(client.search(p))
todos = []
@@ -108,7 +109,7 @@ for q in queries:
log.warn("Part not found")
for part_number in todos:
- response = client.search(part_number)
+ response = parser.parse_string(client.search(part_number))
if response.response_type == SearchResponseTypes.SINGLE:
p = sorted(response.products, key=lambda p: p.part_number)[0]
diff --git a/src/ee/tools/digikey_import_parts.py b/src/ee/tools/digikey_import_parts.py
new file mode 100644
index 0000000..77f87e8
--- /dev/null
+++ b/src/ee/tools/digikey_import_parts.py
@@ -0,0 +1,17 @@
+import argparse
+from ee.digikey.import_parts import import_parts
+
+parser = argparse.ArgumentParser(description="Import all parts in XML file into Digi-Key parts list")
+
+parser.add_argument("--in",
+ dest="in_",
+ required=True,
+ metavar="FILE")
+
+parser.add_argument("--out",
+ required=True,
+ metavar="FILE")
+
+args = parser.parse_args()
+
+import_parts(args.in_, args.out)
diff --git a/src/ee/tools/digikey_refresh_parts.py b/src/ee/tools/digikey_refresh_parts.py
new file mode 100644
index 0000000..e3e3b35
--- /dev/null
+++ b/src/ee/tools/digikey_refresh_parts.py
@@ -0,0 +1,22 @@
+import argparse
+from pathlib import Path
+
+from ee.digikey.refresh_parts import refresh_parts
+
+parser = argparse.ArgumentParser()
+
+parser.add_argument("--in",
+ dest="in_",
+ required=True,
+ metavar="FILE")
+
+parser.add_argument("--out",
+ required=True,
+ metavar="FILE")
+
+args = parser.parse_args()
+
+cache_dir = ".ee/cache"
+force = True
+
+refresh_parts(Path(args.in_), Path(args.out), Path(cache_dir), force)