Skip to content
Snippets Groups Projects
Commit 90a3b125 authored by Krisjanis Rijnieks's avatar Krisjanis Rijnieks :lion_face:
Browse files

Add inventory whitelist with items to ignore. Not everything from DigiKey is an electronics part.

parent 71750827
No related branches found
No related tags found
Loading
...@@ -3,12 +3,10 @@ ...@@ -3,12 +3,10 @@
# Author: Krisjanis Rijnieks # Author: Krisjanis Rijnieks
# Created: 2022-04-27 # 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. # The location of the library can change. Supply it from outside.
if [[ ! ${1} ]]; then if [[ ! ${1} ]]; then
echo "Please specify KiCad library file." echo "Please specify KiCad library file and optional whitelist file."
echo "Usage: ./inventory.sh ../fab.kicad_sym" echo "Usage: ./inventory.sh ../fab.kicad_sym ./whitelist.txt"
exit 1 exit 1
fi fi
...@@ -19,10 +17,21 @@ if [[ ! -f ${1} ]]; then ...@@ -19,10 +17,21 @@ if [[ ! -f ${1} ]]; then
exit 1 exit 1
fi 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} LIBRARY_FILE=${1}
WHITELIST_FILE=${2}
INVENTORY_URL="http://inventory.fabcloud.io/data/inv.json" INVENTORY_URL="http://inventory.fabcloud.io/data/inv.json"
SOURCE="Digi-Key" SOURCE="Digi-Key"
# Whitelist. All the tools and materials from Digi-Key go here.
readarray -t WHITELIST < ${WHITELIST_FILE}
WHITELIST=${WHITELIST[@]}
# Colored output # Colored output
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
...@@ -51,6 +60,11 @@ ITEMS=$(curl -s ${INVENTORY_URL} | jq -r '.topics[] | .sources."Digi-Key".catego ...@@ -51,6 +60,11 @@ ITEMS=$(curl -s ${INVENTORY_URL} | jq -r '.topics[] | .sources."Digi-Key".catego
echo "Looking for matches in the library..." echo "Looking for matches in the library..."
for ITEM in ${ITEMS}; do for ITEM in ${ITEMS}; do
# TODO: Look for item in whitelist # TODO: Look for item in whitelist
if [[ ${WHITELIST} == *"${ITEM}"* ]]; then
echo "${ITEM} found in whitelist"
continue
fi
# Look for item in KiCad symbol library # Look for item in KiCad symbol library
if [[ ${KEYWORDS} == *"${ITEM}"* ]]; then if [[ ${KEYWORDS} == *"${ITEM}"* ]]; then
echo -e "${GREEN}${ITEM} found${RESET}" echo -e "${GREEN}${ITEM} found${RESET}"
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment