Systematic rename of all semantic anchors (#region, [DEF], @RELATION) across 1400+ files — backend Python, frontend Svelte/TS, specs, docs: - Flat anchors become Namespace.Module.Entity - @RELATION references updated to match new anchor paths - Zero business logic changes
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# [DEF:Std.Ai.TrivialUtilityShot:Module]
|
|
# @COMPLEXITY: 1
|
|
# @PURPOSE: Reference implementation of a zero-overhead utility using implicit Complexity 1.
|
|
|
|
import re
|
|
from datetime import datetime, timezone
|
|
from typing import Optional
|
|
|
|
# [DEF:Std.Ai.Slugify:Function]
|
|
# @PURPOSE: Converts a string to a URL-safe slug.
|
|
def slugify(text: str) -> str:
|
|
if not text:
|
|
return ""
|
|
text = text.lower().strip()
|
|
text = re.sub(r'[^\w\s-]', '', text)
|
|
return re.sub(r'[-\s]+', '-', text)
|
|
# [/DEF:Std.Ai.Slugify:Function]
|
|
|
|
# [DEF:Std.Ai.GetUtcNow:Function]
|
|
def get_utc_now() -> datetime:
|
|
"""Returns current UTC datetime (purpose is omitted because it's obvious)."""
|
|
return datetime.now(timezone.utc)
|
|
# [/DEF:Std.Ai.GetUtcNow:Function]
|
|
|
|
# [DEF:Std.Ai.PaginationDTO:Class]
|
|
class PaginationDTO:
|
|
# [DEF:Std.Ai.Init:Function]
|
|
def __init__(self, page: int = 1, size: int = 50):
|
|
self.page = max(1, page)
|
|
self.size = min(max(1, size), 1000)
|
|
# [/DEF:Std.Ai.Init:Function]
|
|
|
|
# [DEF:Std.Ai.Offset:Function]
|
|
@property
|
|
def offset(self) -> int:
|
|
return (self.page - 1) * self.size
|
|
# [/DEF:Std.Ai.Offset:Function]
|
|
# [/DEF:Std.Ai.PaginationDTO:Class]
|
|
|
|
# [/DEF:Std.Ai.TrivialUtilityShot:Module] |