From 73c63d8c307bdbeb534c24fb51d4093c2fcbb86d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 29 Mar 2019 16:41:25 +0100 Subject: Project: o adding cache_dir field, useful for controlling where cached data is placed from a central place. o Updating tools to use this new variable. --- src/ee/tools/digikey_search_parts.py | 6 ++++-- src/ee/tools/element14_search_parts.py | 12 ++++++------ src/ee/tools/seeed_download_opl.py | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/ee/tools') diff --git a/src/ee/tools/digikey_search_parts.py b/src/ee/tools/digikey_search_parts.py index 9f35e33..6cf104d 100644 --- a/src/ee/tools/digikey_search_parts.py +++ b/src/ee/tools/digikey_search_parts.py @@ -2,6 +2,7 @@ import argparse from pathlib import Path from ee.digikey.search_parts import search_parts +from ee.project import Project parser = argparse.ArgumentParser() @@ -16,6 +17,7 @@ parser.add_argument("--out", args = parser.parse_args() -cache_dir = ".ee/cache/digikey" +project = Project.load() +cache_dir = project.cache_dir / "digikey" -search_parts(Path(args.in_path), Path(args.out), Path(cache_dir)) +search_parts(Path(args.in_path), Path(args.out), cache_dir) diff --git a/src/ee/tools/element14_search_parts.py b/src/ee/tools/element14_search_parts.py index 11fd3e1..e2ef414 100644 --- a/src/ee/tools/element14_search_parts.py +++ b/src/ee/tools/element14_search_parts.py @@ -1,9 +1,9 @@ import argparse from pathlib import Path -from ee import project from ee.element14 import Element14Config from ee.element14.search_parts import search_parts +from ee.project import Project parser = argparse.ArgumentParser() @@ -18,13 +18,13 @@ parser.add_argument("--out", args = parser.parse_args() -cache_dir = ".ee/cache/element14" +project = Project.load() -config = project.load_config(Path(".")) +cache_dir = project.cache_dir / "element14" e14_config = Element14Config( - store=config.get("element14", "store", fallback=None), - api_key=config.get("element14", "api-key", fallback=None) + store=project.cfg.get("element14", "store", fallback=None), + api_key=project.cfg.get("element14", "api-key", fallback=None) ) -search_parts(Path(args.in_path), Path(args.out), Path(cache_dir), e14_config) +search_parts(Path(args.in_path), Path(args.out), cache_dir, e14_config) diff --git a/src/ee/tools/seeed_download_opl.py b/src/ee/tools/seeed_download_opl.py index 3f8b07b..efbdfb3 100644 --- a/src/ee/tools/seeed_download_opl.py +++ b/src/ee/tools/seeed_download_opl.py @@ -1,6 +1,7 @@ import argparse from pathlib import Path +from ee.project import Project from ee.supplier import seeed parser = argparse.ArgumentParser() @@ -15,6 +16,7 @@ parser.add_argument("--opl", args = parser.parse_args() -cache_dir = ".ee/cache/seeed" +project = Project.load() +cache_dir = project.cache_dir / "seeed" -seeed.download_opl(Path(args.out), Path(cache_dir), args.opl) +seeed.download_opl(Path(args.out), cache_dir, args.opl) -- cgit v1.2.3