python-ulid 2.5.0__py3-none-any.whl → 2.7.0__py3-none-any.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.
- {python_ulid-2.5.0.dist-info → python_ulid-2.7.0.dist-info}/METADATA +1 -1
- python_ulid-2.7.0.dist-info/RECORD +10 -0
- ulid/__init__.py +6 -0
- ulid/base32.py +5 -0
- python_ulid-2.5.0.dist-info/RECORD +0 -10
- {python_ulid-2.5.0.dist-info → python_ulid-2.7.0.dist-info}/WHEEL +0 -0
- {python_ulid-2.5.0.dist-info → python_ulid-2.7.0.dist-info}/entry_points.txt +0 -0
- {python_ulid-2.5.0.dist-info → python_ulid-2.7.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: python-ulid
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
4
|
Summary: Universally unique lexicographically sortable identifier
|
|
5
5
|
Project-URL: Homepage, https://github.com/mdomke/python-ulid
|
|
6
6
|
Project-URL: Documentation, https://python-ulid.readthedocs.io
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ulid/__init__.py,sha256=tPyxks3cQzUiqkRdLgoDuunqiz090RiFkUfCMGxw7fU,9588
|
|
2
|
+
ulid/__main__.py,sha256=Cmg0NEz3GUZ2WhsZVpY3-Kq-JOkxJFaLsRNgj3Aosyw,5341
|
|
3
|
+
ulid/base32.py,sha256=cMj7Ye9qRdWn3n3hwaEXGMi2OkqmleAAxE20y7qmBqI,6184
|
|
4
|
+
ulid/constants.py,sha256=N_nw4W2ciXO8C1IeuO3YK3j4_x9QW-0KyvrSQUuM-G4,241
|
|
5
|
+
ulid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
python_ulid-2.7.0.dist-info/METADATA,sha256=zJASFWDrkYVNYfnjjA70QGCC_kyzfyufEog6Ig4emH8,5782
|
|
7
|
+
python_ulid-2.7.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
8
|
+
python_ulid-2.7.0.dist-info/entry_points.txt,sha256=9214ghzfSgS8a-TjjlWDF7bI7KSaeewOCBKn5uz7bdU,50
|
|
9
|
+
python_ulid-2.7.0.dist-info/licenses/LICENSE,sha256=DiDPNhW5yUHIqaKowvX0c1c9xWiI0xW4ji8R9N2NJbw,1056
|
|
10
|
+
python_ulid-2.7.0.dist-info/RECORD,,
|
ulid/__init__.py
CHANGED
|
@@ -71,6 +71,12 @@ class ULID:
|
|
|
71
71
|
>>> ulid = ULID()
|
|
72
72
|
>>> str(ulid)
|
|
73
73
|
'01E75PVKXA3GFABX1M1J9NZZNF'
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
value (bytes, None): A sequence of 16 bytes representing an encoded ULID.
|
|
77
|
+
|
|
78
|
+
Raises:
|
|
79
|
+
ValueError: If the provided value is not a valid encoded ULID.
|
|
74
80
|
"""
|
|
75
81
|
|
|
76
82
|
def __init__(self, value: bytes | None = None) -> None:
|
ulid/base32.py
CHANGED
|
@@ -198,6 +198,8 @@ def encode_randomness(binary: bytes) -> str:
|
|
|
198
198
|
def decode(encoded: str) -> bytes:
|
|
199
199
|
if len(encoded) != constants.REPR_LEN:
|
|
200
200
|
raise ValueError("Encoded ULID has to be exactly 26 characters long.")
|
|
201
|
+
if any((c not in ENCODE) for c in encoded):
|
|
202
|
+
raise ValueError(f"Encoded ULID can only consist of letters in {ENCODE}.")
|
|
201
203
|
return decode_timestamp(encoded[: constants.TIMESTAMP_REPR_LEN]) + decode_randomness(
|
|
202
204
|
encoded[constants.TIMESTAMP_REPR_LEN :]
|
|
203
205
|
)
|
|
@@ -208,6 +210,9 @@ def decode_timestamp(encoded: str) -> bytes:
|
|
|
208
210
|
raise ValueError("ULID timestamp has to be exactly 10 characters long.")
|
|
209
211
|
lut = DECODE
|
|
210
212
|
values: bytes = bytes(encoded, "ascii")
|
|
213
|
+
# https://github.com/ulid/spec?tab=readme-ov-file#overflow-errors-when-parsing-base32-strings
|
|
214
|
+
if lut[values[0]] > 7:
|
|
215
|
+
raise ValueError(f"Timestamp value {encoded} is too large and will overflow 128-bits.")
|
|
211
216
|
return bytes(
|
|
212
217
|
[
|
|
213
218
|
((lut[values[0]] << 5) | lut[values[1]]) & 0xFF,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
ulid/__init__.py,sha256=zy-30DJ8TvBy4TbOg5Jg3nYO8K6IN1O-6VN1X179EzY,9410
|
|
2
|
-
ulid/__main__.py,sha256=Cmg0NEz3GUZ2WhsZVpY3-Kq-JOkxJFaLsRNgj3Aosyw,5341
|
|
3
|
-
ulid/base32.py,sha256=OkU4FBqohJgV_ZRc3dTbjPlUTSSeC9ddFlPXD2vA8vc,5832
|
|
4
|
-
ulid/constants.py,sha256=N_nw4W2ciXO8C1IeuO3YK3j4_x9QW-0KyvrSQUuM-G4,241
|
|
5
|
-
ulid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
python_ulid-2.5.0.dist-info/METADATA,sha256=7BkkVqpVMiLr6U7aN1GGwfybKl-GP7BDz2-St3wO5BU,5782
|
|
7
|
-
python_ulid-2.5.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
8
|
-
python_ulid-2.5.0.dist-info/entry_points.txt,sha256=9214ghzfSgS8a-TjjlWDF7bI7KSaeewOCBKn5uz7bdU,50
|
|
9
|
-
python_ulid-2.5.0.dist-info/licenses/LICENSE,sha256=DiDPNhW5yUHIqaKowvX0c1c9xWiI0xW4ji8R9N2NJbw,1056
|
|
10
|
-
python_ulid-2.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|