diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-02-24 21:51:38 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-02-24 21:51:38 +0100 |
commit | 80e0623913e87c6480049520590e424a831e0401 (patch) | |
tree | ff27e1d269cac886dd06ab4f9924719f84794e38 /src/ee/tools | |
parent | 8aae5d032dd30118b6d992018391a8bd5be759e4 (diff) | |
download | ee-python-80e0623913e87c6480049520590e424a831e0401.tar.gz ee-python-80e0623913e87c6480049520590e424a831e0401.tar.bz2 ee-python-80e0623913e87c6480049520590e424a831e0401.tar.xz ee-python-80e0623913e87c6480049520590e424a831e0401.zip |
Digikey: replacing requests-based code with selenium.
Adding new tools: digikey-import-parts and digikey-refresh-parts.
Diffstat (limited to 'src/ee/tools')
-rw-r--r-- | src/ee/tools/digikey_download_facts.py | 7 | ||||
-rw-r--r-- | src/ee/tools/digikey_import_parts.py | 17 | ||||
-rw-r--r-- | src/ee/tools/digikey_refresh_parts.py | 22 |
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) |