Rename the core package to periscopex, update UI/docs/Docker/deploy defaults to periscope.michelebigi.it, and keep legacy version/storage key aliases so existing projects keep working. Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
595 B
Python
22 lines
595 B
Python
"""Shared utility functions for the periscopex 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)
|