2021-01-02 19:28:03 +01:00
|
|
|
from uuid import UUID
|
|
|
|
|
2020-12-30 22:07:43 +01:00
|
|
|
import shortuuid
|
|
|
|
|
|
|
|
|
2021-01-02 19:28:03 +01:00
|
|
|
def encode_uuid(uuid_value: UUID) -> str:
|
|
|
|
"""
|
|
|
|
Return short id string from an UUID
|
|
|
|
"""
|
2020-12-30 22:07:43 +01:00
|
|
|
return shortuuid.encode(uuid_value)
|
|
|
|
|
|
|
|
|
2021-01-02 19:28:03 +01:00
|
|
|
def decode_short_id(short_id: str) -> UUID:
|
|
|
|
"""
|
|
|
|
Return UUID from a short id string
|
|
|
|
"""
|
2020-12-30 22:07:43 +01:00
|
|
|
return shortuuid.decode(short_id)
|