ulid-transform 0.9.0__cp310-cp310-win32.whl → 0.10.1__cp310-cp310-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ulid_transform/__init__.py +19 -3
- ulid_transform/_ulid_impl.cp310-win32.pyd +0 -0
- ulid_transform/_ulid_impl.pyx +11 -0
- ulid_transform/ulid_impl.py +26 -0
- {ulid_transform-0.9.0.dist-info → ulid_transform-0.10.1.dist-info}/METADATA +8 -1
- ulid_transform-0.10.1.dist-info/RECORD +14 -0
- {ulid_transform-0.9.0.dist-info → ulid_transform-0.10.1.dist-info}/WHEEL +1 -1
- ulid_transform-0.9.0.dist-info/RECORD +0 -14
- {ulid_transform-0.9.0.dist-info → ulid_transform-0.10.1.dist-info}/LICENSE +0 -0
ulid_transform/__init__.py
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
-
__version__ = "0.
|
1
|
+
__version__ = "0.10.1"
|
2
2
|
|
3
|
-
from .ulid_impl import
|
3
|
+
from .ulid_impl import (
|
4
|
+
bytes_to_ulid,
|
5
|
+
bytes_to_ulid_or_none,
|
6
|
+
ulid_at_time,
|
7
|
+
ulid_hex,
|
8
|
+
ulid_now,
|
9
|
+
ulid_to_bytes,
|
10
|
+
ulid_to_bytes_or_none,
|
11
|
+
)
|
4
12
|
|
5
|
-
__all__ = [
|
13
|
+
__all__ = [
|
14
|
+
"ulid_now",
|
15
|
+
"ulid_at_time",
|
16
|
+
"ulid_hex",
|
17
|
+
"ulid_to_bytes",
|
18
|
+
"bytes_to_ulid",
|
19
|
+
"ulid_to_bytes_or_none",
|
20
|
+
"bytes_to_ulid_or_none",
|
21
|
+
]
|
Binary file
|
ulid_transform/_ulid_impl.pyx
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
from libcpp.string cimport string
|
3
3
|
|
4
4
|
from time import time
|
5
|
+
from typing import Optional
|
5
6
|
|
6
7
|
import cython
|
7
8
|
|
@@ -28,3 +29,13 @@ def _bytes_to_ulid(ulid_bytes: bytes) -> str:
|
|
28
29
|
if len(ulid_bytes) != 16:
|
29
30
|
raise ValueError(f"ULID bytes be 16 bytes: {ulid_bytes}")
|
30
31
|
return _cpp_bytes_to_ulid(ulid_bytes).decode("ascii")
|
32
|
+
|
33
|
+
def _ulid_to_bytes_or_none(ulid_str: Optional[str]) -> Optional[bytes]:
|
34
|
+
if ulid_str is None or len(ulid_str) != 26:
|
35
|
+
return None
|
36
|
+
return _cpp_ulid_to_bytes(ulid_str.encode("ascii"))
|
37
|
+
|
38
|
+
def _bytes_to_ulid_or_none(ulid_bytes: Optional[bytes]) -> Optional[str]:
|
39
|
+
if ulid_bytes is None or len(ulid_bytes) != 16:
|
40
|
+
return None
|
41
|
+
return _cpp_bytes_to_ulid(ulid_bytes).decode("ascii")
|
ulid_transform/ulid_impl.py
CHANGED
@@ -410,10 +410,33 @@ def bytes_to_ulid(value: bytes) -> str:
|
|
410
410
|
return _encode(value)
|
411
411
|
|
412
412
|
|
413
|
+
def ulid_to_bytes_or_none(ulid: str | None) -> bytes | None:
|
414
|
+
"""Convert an ulid to bytes."""
|
415
|
+
if ulid is None:
|
416
|
+
return None
|
417
|
+
try:
|
418
|
+
return ulid_to_bytes(ulid)
|
419
|
+
except ValueError:
|
420
|
+
return None
|
421
|
+
|
422
|
+
|
423
|
+
def bytes_to_ulid_or_none(_bytes: bytes | None) -> str | None:
|
424
|
+
"""Convert bytes to a ulid."""
|
425
|
+
if _bytes is None:
|
426
|
+
return None
|
427
|
+
try:
|
428
|
+
return bytes_to_ulid(_bytes)
|
429
|
+
except ValueError:
|
430
|
+
return None
|
431
|
+
|
432
|
+
|
413
433
|
try:
|
414
434
|
from ._ulid_impl import ( # type: ignore[no-redef] # noqa: F811 F401 # pragma: no cover
|
415
435
|
_bytes_to_ulid as bytes_to_ulid,
|
416
436
|
)
|
437
|
+
from ._ulid_impl import ( # type: ignore[no-redef] # noqa: F811 F401 # pragma: no cover
|
438
|
+
_bytes_to_ulid_or_none as bytes_to_ulid_or_none,
|
439
|
+
)
|
417
440
|
from ._ulid_impl import ( # type: ignore[no-redef] # noqa: F811 F401 # pragma: no cover
|
418
441
|
_ulid_at_time as ulid_at_time,
|
419
442
|
)
|
@@ -423,5 +446,8 @@ try:
|
|
423
446
|
from ._ulid_impl import ( # type: ignore[no-redef] # noqa: F811 F401 # pragma: no cover
|
424
447
|
_ulid_to_bytes as ulid_to_bytes,
|
425
448
|
)
|
449
|
+
from ._ulid_impl import ( # type: ignore[no-redef] # noqa: F811 F401 # pragma: no cover
|
450
|
+
_ulid_to_bytes_or_none as ulid_to_bytes_or_none,
|
451
|
+
)
|
426
452
|
except ImportError: # pragma: no cover
|
427
453
|
pass # pragma: no cover
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ulid-transform
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.10.1
|
4
4
|
Summary: Create and transform ULIDs
|
5
5
|
Home-page: https://github.com/bdraco/ulid-transform
|
6
6
|
License: MIT
|
@@ -15,6 +15,7 @@ Classifier: Operating System :: OS Independent
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
16
16
|
Classifier: Programming Language :: Python :: 3.10
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
18
19
|
Classifier: Topic :: Software Development :: Libraries
|
19
20
|
Project-URL: Bug Tracker, https://github.com/bdraco/ulid-transform/issues
|
20
21
|
Project-URL: Changelog, https://github.com/bdraco/ulid-transform/blob/main/CHANGELOG.md
|
@@ -68,6 +69,12 @@ This library will use the CPP implementation from https://github.com/suyash/ulid
|
|
68
69
|
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
|
69
70
|
>> ulid_transform.bytes_to_ulid(b"\x01\x86\x99?\xe8\xf3\x11\xbc\xed\xef\x86U.9\x03z")
|
70
71
|
'01GTCKZT7K26YEVVW6AMQ3J0VT'
|
72
|
+
>>> ulid_transform.ulid_to_bytes_or_none('0001HZX0NW00GW0X476W5TVBFE')
|
73
|
+
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
|
74
|
+
>>> ulid_transform.ulid_to_bytes_or_none(None)
|
75
|
+
>>> ulid_transform.bytes_to_ulid_or_none(b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee')
|
76
|
+
'0001HZX0NW00GW0X476W5TVBFE'
|
77
|
+
>>> ulid_transform.bytes_to_ulid_or_none(None)
|
71
78
|
```
|
72
79
|
|
73
80
|
## Installation
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ulid_transform/__init__.py,sha256=p3JHoB6geHaG050xbrrcyDbWg6c1S7lz_mZ8RKaUHoc,377
|
2
|
+
ulid_transform/_ulid_impl.pyx,sha256=Qlhh9TuB5JyxNHhr370W5pgYx5AdZpkvANbBYVLCmWY,1347
|
3
|
+
ulid_transform/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
ulid_transform/ulid.hh,sha256=RwGduPUOt5AEfAaAkafGaHyhr2yd7vfHJeY0lOXlTPw,312
|
5
|
+
ulid_transform/ulid_impl.py,sha256=-OqxT7yi7tloT6EnRMmxLMgSLmGSb-hPhO4kn99vDiU,10934
|
6
|
+
ulid_transform/ulid_struct.hh,sha256=Jh326iAyOkEaEpBZr4CY6xOOSXqO_hcsBS37qUcUCeM,20025
|
7
|
+
ulid_transform/ulid_uint128.hh,sha256=ibwgd8Qksjc0oG52h8kb7ClJruJe9CyfMQra4B3fk1E,15370
|
8
|
+
ulid_transform/ulid_wrapper.cpp,sha256=-S7Eq1ae0bHeEOaY1uWHRn2RA9MQG2PrFcIJSl_37Rg,933
|
9
|
+
ulid_transform/ulid_wrapper.h,sha256=H_AaGGLSS3ymjaRh4uUhG-lvFUrwJhnLL0irzDoqgZM,275
|
10
|
+
ulid_transform/_ulid_impl.cp310-win32.pyd,sha256=c-Ph7363VI2BpZC_g6VGa_x624UIRYcRMaW-kfAEfd4,48128
|
11
|
+
ulid_transform-0.10.1.dist-info/LICENSE,sha256=glXAnenXQvBuN4WzZ8ikikOHF6v3qq4_z8fCZobbgxs,1094
|
12
|
+
ulid_transform-0.10.1.dist-info/METADATA,sha256=ydvpOxvAknjpYdK-nYRIh4MinZg1R5YeM21If61j25I,5389
|
13
|
+
ulid_transform-0.10.1.dist-info/WHEEL,sha256=Svdtsh_n4IQBUqbkNwiBdP0wkpbnh9mYvfQdH6BQhAs,94
|
14
|
+
ulid_transform-0.10.1.dist-info/RECORD,,
|
@@ -1,14 +0,0 @@
|
|
1
|
-
ulid_transform/__init__.py,sha256=Ygji_LvT3WDRjCkum56ZATKaKBDuPVOobFdvnjgKuR8,200
|
2
|
-
ulid_transform/_ulid_impl.pyx,sha256=YpiQyHY-1L3n0WZMnfLV2iKxX_UdvdcukunYmb2sfco,906
|
3
|
-
ulid_transform/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
ulid_transform/ulid.hh,sha256=RwGduPUOt5AEfAaAkafGaHyhr2yd7vfHJeY0lOXlTPw,312
|
5
|
-
ulid_transform/ulid_impl.py,sha256=axxu_OzIg2IbRwomlwJWzUOhkfSqSlSFq4PwwljvG3o,10137
|
6
|
-
ulid_transform/ulid_struct.hh,sha256=Jh326iAyOkEaEpBZr4CY6xOOSXqO_hcsBS37qUcUCeM,20025
|
7
|
-
ulid_transform/ulid_uint128.hh,sha256=ibwgd8Qksjc0oG52h8kb7ClJruJe9CyfMQra4B3fk1E,15370
|
8
|
-
ulid_transform/ulid_wrapper.cpp,sha256=-S7Eq1ae0bHeEOaY1uWHRn2RA9MQG2PrFcIJSl_37Rg,933
|
9
|
-
ulid_transform/ulid_wrapper.h,sha256=H_AaGGLSS3ymjaRh4uUhG-lvFUrwJhnLL0irzDoqgZM,275
|
10
|
-
ulid_transform/_ulid_impl.cp310-win32.pyd,sha256=DsV5G9fqFw6qGIC9szXC5XiyMHbkTWosGrjCxZBQ28s,44032
|
11
|
-
ulid_transform-0.9.0.dist-info/LICENSE,sha256=glXAnenXQvBuN4WzZ8ikikOHF6v3qq4_z8fCZobbgxs,1094
|
12
|
-
ulid_transform-0.9.0.dist-info/METADATA,sha256=u-O1V_V9o2imsx2LvthvkmxuhyYXzpcVcSg8LCWiJBo,4989
|
13
|
-
ulid_transform-0.9.0.dist-info/WHEEL,sha256=U_aieYgVgnjpBlVf2E_HWIwF1cD-y7OSzO3POi3yL5k,94
|
14
|
-
ulid_transform-0.9.0.dist-info/RECORD,,
|
File without changes
|