Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

0 downloads

dbbasic-object-server/object_ids.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 signup: the person chooses the password and name on the confirm page 83c7aa6 2 weeks, 5 days ago History
object_ids.py · 780 bytes · 35 lines
1"""Shared ID helpers for DBBASIC-created resources."""
2
3from __future__ import annotations
4
5from uuid import UUID, uuid4
6
7
8def new_uuid4() -> str:
9 """Return a canonical UUIDv4 string."""
10 return str(uuid4())
11
12
13def normalize_uuid4(value: object) -> str | None:
14 """Return a canonical UUIDv4 string, or ``None`` for non-UUIDv4 input."""
15 if value is None:
16 return None
17
18 text = str(value).strip()
19 if not text:
20 return None
21
22 try:
23 parsed = UUID(text)
24 except (TypeError, ValueError, AttributeError):
25 return None
26
27 if parsed.version != 4:
28 return None
29
30 return str(parsed)
31
32
33def is_uuid4(value: object) -> bool:
34 """Return True when ``value`` is a UUIDv4 string."""
35 return normalize_uuid4(value) is not None