Add gen-all-inventories.sh to version control.
authorW. Trevor King <wking@drexel.edu>
Fri, 7 Jan 2011 03:10:48 +0000 (22:10 -0500)
committerW. Trevor King <wking@drexel.edu>
Fri, 7 Jan 2011 03:10:48 +0000 (22:10 -0500)
contrib/gen-all-inventories.sh [new file with mode: 0755]

diff --git a/contrib/gen-all-inventories.sh b/contrib/gen-all-inventories.sh
new file mode 100755 (executable)
index 0000000..d9b5d56
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# generate a complete inventory for _every_single_storage_location_ !
+# stored in ./docs/locs/<location>.pdf, with <location> being slightly
+# cleaned up...
+#
+# usage: gen-all-inventories.sh
+
+INVENTORY_DB='./current/inventory.db'
+DOC_DIR='./docs/locs' # no trailing slash!
+
+mkdir -p "$DOC_DIR"
+
+while read LOCATION; do
+    echo "Processing '$LOCATION'"
+    OUTPUT_PDF_PATH=$(./bin/chem_db.py -f "$INVENTORY_DB" --inventory --pdf-title "Inventory ($LOCATION)" --valid-record "r['Location']=='$LOCATION'" --sort-field Name | tail -n1)
+    CLEAN_LOCATION=$(echo "$LOCATION" | sed 's/ /_/g')
+    FINAL_PDF_PATH="${DOC_DIR}/${CLEAN_LOCATION}.pdf"
+    mv "$OUTPUT_PDF_PATH" "$FINAL_PDF_PATH"
+    echo "  created $FINAL_PDF_PATH"
+done < <(./bin/chem_db.py -f "$INVENTORY_DB" --list-locations)