partslist-vendor: Support "seeed_part_number" field
authorKeith Packard <keithp@keithp.com>
Thu, 2 Nov 2023 04:33:24 +0000 (21:33 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 2 Nov 2023 04:33:24 +0000 (21:33 -0700)
This allows us to leave the existing 4ucon parts in place while
substituting more common part numbers when generating seeed quotes.

Signed-off-by: Keith Packard <keithp@keithp.com>
bin/partslist-vendor

index 423796eb74ac7660b4a453fcbc7ca8bd9aeadac5..6ac421747526497dc0e8ce024e91cdcad6f3b7d1 100755 (executable)
@@ -114,8 +114,15 @@ string quoted(string v)
 
 void process_seeed(string[string] entry)
 {
-       if (entry["loadstatus"] == "noload")
-               return;
+       string part_number = entry["mfg_part_number"];
+       if (hash_test(entry, "seeed_part_number") && entry["seeed_part_number"] != "unknown") {
+               part_number = entry["seeed_part_number"];
+       } else {
+               if (entry["loadstatus"] == "noload") {
+                       File::fprintf(stderr, "skipping part %v\n", entry);
+                       return;
+               }
+       }
 
        static bool start = true;
        if (start) {
@@ -133,7 +140,7 @@ void process_seeed(string[string] entry)
        }
        if (dim(refdes) > 1)
                printf ("\"");
-       printf(",%s,%s\n", quoted(entry["mfg_part_number"]), entry["quantity"]);
+       printf(",%s,%s\n", quoted(part_number), entry["quantity"]);
 }
 
 void process_goldphoenix(string[string] entry)