ulid-transform 2.2.6__tar.gz → 2.2.7__tar.gz
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-2.2.6 → ulid_transform-2.2.7}/PKG-INFO +9 -1
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/README.md +8 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/pyproject.toml +1 -1
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/__init__.py +1 -1
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/_ulid_impl.cpp +11 -3
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/LICENSE +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/build_ext.py +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/__init__.pyi +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/_py_ulid_impl.py +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/py.typed +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/splitmix64.hh +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/ulid_base32.hh +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/ulid_struct.hh +0 -0
- {ulid_transform-2.2.6 → ulid_transform-2.2.7}/src/ulid_transform/ulid_uint128.hh +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ulid-transform
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.7
|
|
4
4
|
Summary: Create and transform ULIDs
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -64,12 +64,20 @@ This library will use the C++ implementation from https://github.com/suyash/ulid
|
|
|
64
64
|
'01869a2ea5fb0b43aa056293e47c0a35'
|
|
65
65
|
>>> ulid_transform.ulid_now()
|
|
66
66
|
'0001HZX0NW00GW0X476W5TVBFE'
|
|
67
|
+
>>> ulid_transform.ulid_now_bytes()
|
|
68
|
+
b'\x01\x9eS\x9d\x1bhl~\x1e\xf7\x959\xe1\xf2\xbe\xea'
|
|
67
69
|
>>> ulid_transform.ulid_at_time(1234)
|
|
68
70
|
'000000016JC62D620DGYNG2R8H'
|
|
71
|
+
>>> ulid_transform.ulid_at_time_bytes(1234)
|
|
72
|
+
b'\x00\x00\x00\x12\xd4Pq+\x1eG?\x91\xe9+|\xbd'
|
|
69
73
|
>>> ulid_transform.ulid_to_bytes('0001HZX0NW00GW0X476W5TVBFE')
|
|
70
74
|
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
|
|
71
75
|
>>> ulid_transform.bytes_to_ulid(b"\x01\x86\x99?\xe8\xf3\x11\xbc\xed\xef\x86U.9\x03z")
|
|
72
76
|
'01GTCKZT7K26YEVVW6AMQ3J0VT'
|
|
77
|
+
>>> ulid_transform.ulid_to_timestamp('0001HZX0NW00GW0X476W5TVBFE') # milliseconds since the epoch
|
|
78
|
+
1677623996
|
|
79
|
+
>>> ulid_transform.ulid_to_timestamp(b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee') # also accepts bytes
|
|
80
|
+
1677623996
|
|
73
81
|
>>> ulid_transform.ulid_to_bytes_or_none('0001HZX0NW00GW0X476W5TVBFE')
|
|
74
82
|
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
|
|
75
83
|
>>> ulid_transform.ulid_to_bytes_or_none(None)
|
|
@@ -40,12 +40,20 @@ This library will use the C++ implementation from https://github.com/suyash/ulid
|
|
|
40
40
|
'01869a2ea5fb0b43aa056293e47c0a35'
|
|
41
41
|
>>> ulid_transform.ulid_now()
|
|
42
42
|
'0001HZX0NW00GW0X476W5TVBFE'
|
|
43
|
+
>>> ulid_transform.ulid_now_bytes()
|
|
44
|
+
b'\x01\x9eS\x9d\x1bhl~\x1e\xf7\x959\xe1\xf2\xbe\xea'
|
|
43
45
|
>>> ulid_transform.ulid_at_time(1234)
|
|
44
46
|
'000000016JC62D620DGYNG2R8H'
|
|
47
|
+
>>> ulid_transform.ulid_at_time_bytes(1234)
|
|
48
|
+
b'\x00\x00\x00\x12\xd4Pq+\x1eG?\x91\xe9+|\xbd'
|
|
45
49
|
>>> ulid_transform.ulid_to_bytes('0001HZX0NW00GW0X476W5TVBFE')
|
|
46
50
|
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
|
|
47
51
|
>>> ulid_transform.bytes_to_ulid(b"\x01\x86\x99?\xe8\xf3\x11\xbc\xed\xef\x86U.9\x03z")
|
|
48
52
|
'01GTCKZT7K26YEVVW6AMQ3J0VT'
|
|
53
|
+
>>> ulid_transform.ulid_to_timestamp('0001HZX0NW00GW0X476W5TVBFE') # milliseconds since the epoch
|
|
54
|
+
1677623996
|
|
55
|
+
>>> ulid_transform.ulid_to_timestamp(b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee') # also accepts bytes
|
|
56
|
+
1677623996
|
|
49
57
|
>>> ulid_transform.ulid_to_bytes_or_none('0001HZX0NW00GW0X476W5TVBFE')
|
|
50
58
|
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
|
|
51
59
|
>>> ulid_transform.ulid_to_bytes_or_none(None)
|
|
@@ -189,7 +189,11 @@ py_ulid_to_bytes(PyObject* module, PyObject* arg)
|
|
|
189
189
|
const char* str = PyUnicode_AsUTF8AndSize(arg, &len);
|
|
190
190
|
if (!str)
|
|
191
191
|
return NULL;
|
|
192
|
-
|
|
192
|
+
// len is the UTF-8 byte length. A non-ASCII string can still be exactly
|
|
193
|
+
// 26 bytes (e.g. 13 two-byte codepoints), so an ASCII check is required to
|
|
194
|
+
// reject it — otherwise DecodeBase32To reads garbage. Mirrors the Python
|
|
195
|
+
// impl's `len(value) != 26 or not value.isascii()`.
|
|
196
|
+
if (len != ULID_TEXT_LEN || !PyUnicode_IS_ASCII(arg)) {
|
|
193
197
|
PyErr_Format(PyExc_ValueError,
|
|
194
198
|
"ULID must be a 26 character string: %R", arg);
|
|
195
199
|
return NULL;
|
|
@@ -229,7 +233,9 @@ py_ulid_to_bytes_or_none(PyObject* module, PyObject* arg)
|
|
|
229
233
|
const char* str = PyUnicode_AsUTF8AndSize(arg, &len);
|
|
230
234
|
if (!str)
|
|
231
235
|
return NULL;
|
|
232
|
-
|
|
236
|
+
// See py_ulid_to_bytes: a non-ASCII string can be exactly 26 UTF-8 bytes,
|
|
237
|
+
// so reject anything non-ASCII to match the Python impl returning None.
|
|
238
|
+
if (len != ULID_TEXT_LEN || !PyUnicode_IS_ASCII(arg))
|
|
233
239
|
Py_RETURN_NONE;
|
|
234
240
|
uint8_t buf[ULID_BYTES_LEN];
|
|
235
241
|
ulid::DecodeBase32To(str, buf);
|
|
@@ -271,7 +277,9 @@ py_ulid_to_timestamp(PyObject* module, PyObject* arg)
|
|
|
271
277
|
const char* str = PyUnicode_AsUTF8AndSize(arg, &len);
|
|
272
278
|
if (!str)
|
|
273
279
|
return NULL;
|
|
274
|
-
|
|
280
|
+
// See py_ulid_to_bytes: a non-ASCII string can be exactly 26 UTF-8 bytes,
|
|
281
|
+
// so reject anything non-ASCII to match the Python impl raising ValueError.
|
|
282
|
+
if (len != ULID_TEXT_LEN || !PyUnicode_IS_ASCII(arg)) {
|
|
275
283
|
PyErr_Format(PyExc_ValueError,
|
|
276
284
|
"ULID must be a 26 character string: %R", arg);
|
|
277
285
|
return NULL;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|