python-ulid 2.6.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.6.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 +2 -8
- ulid/base32.py +3 -0
- python_ulid-2.6.0.dist-info/RECORD +0 -10
- {python_ulid-2.6.0.dist-info → python_ulid-2.7.0.dist-info}/WHEEL +0 -0
- {python_ulid-2.6.0.dist-info → python_ulid-2.7.0.dist-info}/entry_points.txt +0 -0
- {python_ulid-2.6.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
|
@@ -74,23 +74,17 @@ class ULID:
|
|
|
74
74
|
|
|
75
75
|
Args:
|
|
76
76
|
value (bytes, None): A sequence of 16 bytes representing an encoded ULID.
|
|
77
|
-
validate (bool): If set to `True` validate if the timestamp part is valid.
|
|
78
77
|
|
|
79
78
|
Raises:
|
|
80
79
|
ValueError: If the provided value is not a valid encoded ULID.
|
|
81
80
|
"""
|
|
82
81
|
|
|
83
|
-
def __init__(self, value: bytes | None = None
|
|
82
|
+
def __init__(self, value: bytes | None = None) -> None:
|
|
84
83
|
if value is not None and len(value) != constants.BYTES_LEN:
|
|
85
84
|
raise ValueError("ULID has to be exactly 16 bytes long.")
|
|
86
85
|
self.bytes: bytes = (
|
|
87
86
|
value or ULID.from_timestamp(time.time_ns() // constants.NANOSECS_IN_MILLISECS).bytes
|
|
88
87
|
)
|
|
89
|
-
if value is not None and validate:
|
|
90
|
-
try:
|
|
91
|
-
self.datetime # noqa: B018
|
|
92
|
-
except ValueError as err:
|
|
93
|
-
raise ValueError("ULID timestamp is out of range.") from err
|
|
94
88
|
|
|
95
89
|
@classmethod
|
|
96
90
|
@validate_type(datetime)
|
|
@@ -137,7 +131,7 @@ class ULID:
|
|
|
137
131
|
>>> ULID.from_uuid(uuid4())
|
|
138
132
|
ULID(27Q506DP7E9YNRXA0XVD8Z5YSG)
|
|
139
133
|
"""
|
|
140
|
-
return cls(value.bytes
|
|
134
|
+
return cls(value.bytes)
|
|
141
135
|
|
|
142
136
|
@classmethod
|
|
143
137
|
@validate_type(bytes)
|
ulid/base32.py
CHANGED
|
@@ -210,6 +210,9 @@ def decode_timestamp(encoded: str) -> bytes:
|
|
|
210
210
|
raise ValueError("ULID timestamp has to be exactly 10 characters long.")
|
|
211
211
|
lut = DECODE
|
|
212
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.")
|
|
213
216
|
return bytes(
|
|
214
217
|
[
|
|
215
218
|
((lut[values[0]] << 5) | lut[values[1]]) & 0xFF,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
ulid/__init__.py,sha256=BziBUk2I6PxKvymNA0ddyUcfF9b_Zv7PKsTPV_ojixI,9929
|
|
2
|
-
ulid/__main__.py,sha256=Cmg0NEz3GUZ2WhsZVpY3-Kq-JOkxJFaLsRNgj3Aosyw,5341
|
|
3
|
-
ulid/base32.py,sha256=aj8pfBmuvviEJtdcGGiGImdSN_UMdVsBvIXlFkiqD1o,5963
|
|
4
|
-
ulid/constants.py,sha256=N_nw4W2ciXO8C1IeuO3YK3j4_x9QW-0KyvrSQUuM-G4,241
|
|
5
|
-
ulid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
python_ulid-2.6.0.dist-info/METADATA,sha256=NxDvmvrp4DzyfibtLfBPh3D605fWHRY_p709_rxwwG0,5782
|
|
7
|
-
python_ulid-2.6.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
8
|
-
python_ulid-2.6.0.dist-info/entry_points.txt,sha256=9214ghzfSgS8a-TjjlWDF7bI7KSaeewOCBKn5uz7bdU,50
|
|
9
|
-
python_ulid-2.6.0.dist-info/licenses/LICENSE,sha256=DiDPNhW5yUHIqaKowvX0c1c9xWiI0xW4ji8R9N2NJbw,1056
|
|
10
|
-
python_ulid-2.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|