Files
periscope/backend/pinscopex/utils.py
T
Siddharth Kothari 6672d2be57 Pinscope open-source core
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).
2026-07-16 21:29:45 -07:00

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)