From 90a3b125722637be33b9f5838983795879332346 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks <krisjanis.rijnieks@gmail.com> Date: Wed, 27 Apr 2022 21:20:41 +0300 Subject: [PATCH] Add inventory whitelist with items to ignore. Not everything from DigiKey is an electronics part. --- tests/inventory.sh | 22 ++++++++++++++++++---- tests/whitelist.txt | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 tests/whitelist.txt diff --git a/tests/inventory.sh b/tests/inventory.sh index b269667..12650e3 100755 --- a/tests/inventory.sh +++ b/tests/inventory.sh @@ -3,12 +3,10 @@ # Author: Krisjanis Rijnieks # Created: 2022-04-27 -# TODO: Create whitelist (some parts from DigiKey are not electronics parts) - # The location of the library can change. Supply it from outside. if [[ ! ${1} ]]; then - echo "Please specify KiCad library file." - echo "Usage: ./inventory.sh ../fab.kicad_sym" + echo "Please specify KiCad library file and optional whitelist file." + echo "Usage: ./inventory.sh ../fab.kicad_sym ./whitelist.txt" exit 1 fi @@ -19,10 +17,21 @@ if [[ ! -f ${1} ]]; then exit 1 fi +if [[ ${2} && ! -f ${2} ]]; then + echo "Provided whitelist file node not exist." + echo "Make sure the path to the whitelist file is correct." + exit 1 +fi + LIBRARY_FILE=${1} +WHITELIST_FILE=${2} INVENTORY_URL="http://inventory.fabcloud.io/data/inv.json" SOURCE="Digi-Key" +# Whitelist. All the tools and materials from Digi-Key go here. +readarray -t WHITELIST < ${WHITELIST_FILE} +WHITELIST=${WHITELIST[@]} + # Colored output RED='\033[0;31m' GREEN='\033[0;32m' @@ -51,6 +60,11 @@ ITEMS=$(curl -s ${INVENTORY_URL} | jq -r '.topics[] | .sources."Digi-Key".catego echo "Looking for matches in the library..." for ITEM in ${ITEMS}; do # TODO: Look for item in whitelist + if [[ ${WHITELIST} == *"${ITEM}"* ]]; then + echo "${ITEM} found in whitelist" + continue + fi + # Look for item in KiCad symbol library if [[ ${KEYWORDS} == *"${ITEM}"* ]]; then echo -e "${GREEN}${ITEM} found${RESET}" diff --git a/tests/whitelist.txt b/tests/whitelist.txt new file mode 100644 index 0000000..f13deb8 --- /dev/null +++ b/tests/whitelist.txt @@ -0,0 +1,18 @@ +EROP7SA +MS54VN +L4GN +26034 +201 +XP600 +PA70057-ND +TS391SNL +SMDSWLF.020 4OZ +SMDSW.020 4OZ +Q-B-10AS +13605 +13630 +13660 +ATATMEL-ICE-BASIC +8022 +8193 +112990066 -- GitLab