ADCT Python
Python client API implementation for publishing ADCT data
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
adctk.uuid_compat.UUID7Generator Class Reference

Public Member Functions

uuid.UUID uuid7 (cls)
 

Protected Member Functions

None _initialize (cls)
 

Static Protected Attributes

 _uuid7_func = None
 

Detailed Description

A wrapper class that provides UUIDv7 generation.

It uses the native standard library `uuid.uuid7` if available (Python >= 3.14).
Otherwise, it falls back to the third-party `uuid_utils`.

Member Function Documentation

◆ _initialize()

None adctk.uuid_compat.UUID7Generator._initialize (   cls)
protected
Dynamically detects the best available UUIDv7 implementation.
19 def _initialize(cls) -> None:
20 """Dynamically detects the best available UUIDv7 implementation."""
21 if hasattr(uuid, "uuid7"):
22 cls._uuid7_func = uuid.uuid7
23 return
24
25 try:
26 import uuid_utils
27 cls._uuid7_func = uuid_utils.uuid7
28 return
29 except ImportError:
30 pass
31
32 try:
33 import uuid6
34 cls._uuid7_func = uuid6.uuid7
35 warnings.warn(
36 "Standard 'uuid.uuid7' and 'uuid_utils' not found. "
37 "Falling back to slower, pure-Python 'uuid6' package.",
38 RuntimeWarning
39 )
40 return
41 except ImportError:
42 pass
43
44 raise ImportError(
45 "No valid UUIDv7 implementation found. Please upgrade to "
46 "Python >= 3.14 or install 'uuid-utils' via 'pip install uuid-utils'."
47 )
48

◆ uuid7()

uuid.UUID adctk.uuid_compat.UUID7Generator.uuid7 (   cls)
Generates a UUIDv7 object using the best available backend.

Returns:
    uuid.UUID: A standard Python UUID object.
50 def uuid7(cls) -> uuid.UUID:
51 """Generates a UUIDv7 object using the best available backend.
52
53 Returns:
54 uuid.UUID: A standard Python UUID object.
55 """
56 if cls._uuid7_func is None:
57 cls._initialize()
58
59 return cls._uuid7_func()
60
61
62# ==========================================
63# Example Usage
64# ==========================================

Member Data Documentation

◆ _uuid7_func

adctk.uuid_compat.UUID7Generator._uuid7_func = None
staticprotected

The documentation for this class was generated from the following file: