AnasSarkiz/muse-voice-remote

Muse Voice Remote — bare ESP32-S3R8, 155 TOP JLCPCB parts with real supplier CAD, native 3D assembly and GLB exports. Revised 17 mm case allocation; 0.30 mm via drill /0.45 mm pad. Checked prototype PCB; mechanical, RF and MUSE qualification pending.

Version
1.3.2
License
unset
Stars
0

scripts/save-jlcpcb-stock.py

#!/usr/bin/env python3
"""Bind current official JLCPCB responses to the imported C-numbers."""
import csv
import datetime
import json
import pathlib

root = pathlib.Path(__file__).resolve().parents[1]
selection_path = root / "docs/jlcpcb-import-selection.json"
selection = json.loads(selection_path.read_text())
audit = json.loads((root / "docs/jlcpcb-stock-audit.json").read_text())
evidence = []
for selected in selection["parts"]:
    row = next(r for r in audit["parts"] if r["mpn"] == selected["mpn"])
    match = next((m for m in row["exact_matches"] if m["lcsc"] == selected["lcsc"]), None)
    if match is None or not isinstance(match["stock"], int) or match["stock"] < selected["quantity"]:
        raise RuntimeError(f"No sufficient current stock for imported {selected['lcsc']} {selected['mpn']}")
    selected.update(stock=match["stock"], checked_at=row["checked_at"], raw_response=row["raw_response"])
    evidence.append({"mpn": selected["mpn"], "lcsc": selected["lcsc"], "supplier": "jlcpcb",
                     "stock": match["stock"], "checked_at": row["checked_at"],
                     "status": "live-stock-positive", "inventory_kind": "Official JLCPCB live assembly catalog",
                     "url": f"https://jlcpcb.com/partdetail/{selected['lcsc']}",
                     "raw_response": row["raw_response"], "meta": {"stale": False},
                     "exact_matches": [{"mfr":selected["mpn"], "manufacturer":selected["manufacturer"],
                                        "stock":match["stock"], "lcsc":selected["lcsc"],
                                        "marketplace":False, "discontinued":False}]})
selection_path.write_text(json.dumps(selection, indent=2) + "\n")
result = {"checked_at": datetime.datetime.now(datetime.timezone.utc).isoformat(),
          "all_parts_verified_in_stock": False,
          "all_populated_pcb_parts_have_positive_snapshot": True,
          "unique_pcb_mpns": len(selection["parts"]),
          "populated_pcb_components": sum(p["quantity"] for p in selection["parts"]),
          "required_quantities": {p["mpn"]:p["quantity"] for p in selection["parts"]},
          "note": "Official JLCPCB snapshots, not stock reservations. Off-board panel, pack, antenna and transducers require separate qualification.",
          "parts": evidence}
(root / "docs/stock-evidence.json").write_text(json.dumps(result, indent=2) + "\n")
with (root / "docs/procurement.csv").open("w") as fd:
    writer = csv.writer(fd)
    writer.writerow(["MPN","JLCPCB","Manufacturer","Quantity","References","Reported_stock","Checked_at","Product_URL"])
    for p in selection["parts"]:
        writer.writerow([p["mpn"],p["lcsc"],p["manufacturer"],p["quantity"]," ".join(p["references"]),p["stock"],p["checked_at"],f"https://jlcpcb.com/partdetail/{p['lcsc']}"])
print(f"Verified exact official stock for {result['populated_pcb_components']} PCB devices / {result['unique_pcb_mpns']} imported JLCPCB part numbers.")