Agentic schematic validation: datasheet extraction via Claude Console Skills, netlist/BOM design graph, per-IC direct datasheet review with page citations, capacitor derating, Next.js report UI. Extracted from the Pinscope cloud codebase. Auth and billing live in the private gateway repo behind stable seams (billing_hook.py, adapter files listed in CLAUDE.md).
22 lines
594 B
Python
22 lines
594 B
Python
"""Shared utility functions for the pinscopex core library."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
|
|
def safe_mpn(mpn: str) -> str:
|
|
"""Sanitize an MPN string for use in filenames and storage keys."""
|
|
return mpn.replace("/", "_").replace(":", "_")
|
|
|
|
|
|
def natural_sort_key(s: str) -> tuple:
|
|
"""Sort key for natural ordering: R1, R2, R10 (not R1, R10, R2)."""
|
|
parts: list[int | str] = []
|
|
for chunk in re.split(r"(\d+)", s):
|
|
if chunk.isdigit():
|
|
parts.append(int(chunk))
|
|
else:
|
|
parts.append(chunk.lower())
|
|
return tuple(parts)
|