ulid-transform 1.5.2__cp314-cp314t-musllinux_1_2_aarch64.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.
@@ -0,0 +1,107 @@
1
+ #include "ulid_wrapper.h"
2
+
3
+ #ifdef __SIZEOF_INT128__ // http://stackoverflow.com/a/23981011
4
+ #include "ulid_uint128.hh"
5
+ #else
6
+ #include "ulid_struct.hh"
7
+ #endif
8
+
9
+ /**
10
+ * Generate a new text ULID and write it to the provided buffer.
11
+ * The buffer is NOT null-terminated.
12
+ */
13
+ void _cpp_ulid(char dst[26])
14
+ {
15
+ ulid::ULID ulid;
16
+ ulid::EncodeTimeSystemClockNow(ulid);
17
+ ulid::EncodeEntropyMt19937Fast(ulid);
18
+ ulid::MarshalTo(ulid, dst);
19
+ }
20
+
21
+ /**
22
+ * Generate a new binary ULID and write it to the provided buffer.
23
+ */
24
+ void _cpp_ulid_bytes(uint8_t dst[16])
25
+ {
26
+ ulid::ULID ulid;
27
+ ulid::EncodeTimeSystemClockNow(ulid);
28
+ ulid::EncodeEntropyMt19937Fast(ulid);
29
+ ulid::MarshalBinaryTo(ulid, dst);
30
+ }
31
+
32
+ /**
33
+ * Generate a new text ULID at the provided epoch time and write it to the provided buffer.
34
+ * The buffer is NOT null-terminated.
35
+ */
36
+ void _cpp_ulid_at_time(double epoch_time, char dst[26])
37
+ {
38
+ ulid::ULID ulid;
39
+ ulid::EncodeTimestamp(static_cast<int64_t>(epoch_time * 1000), ulid);
40
+ ulid::EncodeEntropyMt19937Fast(ulid);
41
+ ulid::MarshalTo(ulid, dst);
42
+ }
43
+
44
+ /**
45
+ * Generate a new binary ULID at the provided epoch time and write it to the provided buffer.
46
+ */
47
+ void _cpp_ulid_at_time_bytes(double epoch_time, uint8_t dst[16])
48
+ {
49
+ ulid::ULID ulid;
50
+ ulid::EncodeTimestamp(static_cast<int64_t>(epoch_time * 1000), ulid);
51
+ ulid::EncodeEntropyMt19937Fast(ulid);
52
+ ulid::MarshalBinaryTo(ulid, dst);
53
+ }
54
+
55
+ /**
56
+ * Convert a text ULID to a binary ULID.
57
+ * The buffer passed in must contain at least 26 bytes.
58
+ * Invalid data will result in undefined behavior.
59
+ */
60
+ void _cpp_ulid_to_bytes(const char* ulid_string, uint8_t dst[16])
61
+ {
62
+ ulid::ULID ulid;
63
+ ulid::UnmarshalFrom(ulid_string, ulid);
64
+ ulid::MarshalBinaryTo(ulid, dst);
65
+ }
66
+
67
+ /**
68
+ * Convert a binary ULID to a text ULID.
69
+ * The buffer passed in must contain at least 16 bytes.
70
+ * The output buffer will NOT be null-terminated.
71
+ */
72
+ void _cpp_bytes_to_ulid(const uint8_t b[16], char dst[26])
73
+ {
74
+ ulid::ULID ulid;
75
+ ulid::UnmarshalBinaryFrom(b, ulid);
76
+ ulid::MarshalTo(ulid, dst);
77
+ }
78
+
79
+ /**
80
+ * Convert a buffer of exactly 16 bytes to 32 hex characters.
81
+ * The output buffer will NOT be null-terminated.
82
+ */
83
+ void _cpp_hexlify_16(const uint8_t b[16], char dst[32])
84
+ {
85
+ static const char hexdigits[17] = "0123456789abcdef";
86
+ int in_index, out_index;
87
+ for (in_index = out_index = 0; in_index < 16; in_index++) {
88
+ uint8_t c = b[in_index];
89
+ dst[out_index++] = hexdigits[c >> 4];
90
+ dst[out_index++] = hexdigits[c & 0x0f];
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Interpret the first 6 bytes of a binary ULID as a timestamp.
96
+ */
97
+ uint64_t _cpp_bytes_to_timestamp(const uint8_t b[16])
98
+ {
99
+ uint64_t timestamp = 0;
100
+ timestamp |= static_cast<uint64_t>(b[0]) << 40;
101
+ timestamp |= static_cast<uint64_t>(b[1]) << 32;
102
+ timestamp |= static_cast<uint64_t>(b[2]) << 24;
103
+ timestamp |= static_cast<uint64_t>(b[3]) << 16;
104
+ timestamp |= static_cast<uint64_t>(b[4]) << 8;
105
+ timestamp |= static_cast<uint64_t>(b[5]);
106
+ return timestamp;
107
+ }
@@ -0,0 +1,13 @@
1
+ #ifndef ULID_WRAPPER_H
2
+ #define ULID_WRAPPER_H
3
+ #include <stdint.h>
4
+
5
+ void _cpp_ulid(char dst[26]);
6
+ void _cpp_ulid_bytes(uint8_t dst[16]);
7
+ void _cpp_ulid_at_time(double epoch_time, char dst[26]);
8
+ void _cpp_ulid_at_time_bytes(double epoch_time, uint8_t dst[16]);
9
+ void _cpp_ulid_to_bytes(const char* ulid_string, uint8_t dst[16]);
10
+ void _cpp_bytes_to_ulid(const uint8_t b[16], char dst[26]);
11
+ void _cpp_hexlify_16(const uint8_t b[16], char dst[32]);
12
+ uint64_t _cpp_bytes_to_timestamp(const uint8_t b[16]);
13
+ #endif
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: ulid-transform
3
+ Version: 1.5.2
4
+ Summary: Create and transform ULIDs
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Author: J. Nick Koston
8
+ Author-email: nick@koston.org
9
+ Requires-Python: >=3.11
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Project-URL: Bug Tracker, https://github.com/bluetooth-devices/ulid-transform/issues
21
+ Project-URL: Changelog, https://github.com/bluetooth-devices/ulid-transform/blob/main/CHANGELOG.md
22
+ Project-URL: Repository, https://github.com/bluetooth-devices/ulid-transform
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Fast ULID transformations
26
+
27
+ <p align="center">
28
+ <a href="https://github.com/bluetooth-devices/ulid-transform/actions/workflows/ci.yml?query=branch%3Amain">
29
+ <img src="https://img.shields.io/github/actions/workflow/status/bluetooth-devices/ulid-transform/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
30
+ </a>
31
+ <a href="https://codecov.io/gh/bluetooth-devices/ulid-transform">
32
+ <img src="https://img.shields.io/codecov/c/github/bluetooth-devices/ulid-transform.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
33
+ </a>
34
+ </p>
35
+ <p align="center">
36
+ <a href="https://python-poetry.org/">
37
+ <img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=" alt="Poetry">
38
+ </a>
39
+ <a href="https://github.com/ambv/black">
40
+ <img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square" alt="black">
41
+ </a>
42
+ <a href="https://github.com/pre-commit/pre-commit">
43
+ <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
44
+ </a>
45
+ <a href="https://codspeed.io/bluetooth-devices/ulid-transform"><img src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" alt="CodSpeed Badge"/></a>
46
+ </p>
47
+ <p align="center">
48
+ <a href="https://pypi.org/project/ulid-transform/">
49
+ <img src="https://img.shields.io/pypi/v/ulid-transform.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
50
+ </a>
51
+ <img src="https://img.shields.io/pypi/pyversions/ulid-transform.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">
52
+ <img src="https://img.shields.io/pypi/l/ulid-transform.svg?style=flat-square" alt="License">
53
+ </p>
54
+
55
+ Create and transform ULIDs
56
+
57
+ This library will use the CPP implementation from https://github.com/suyash/ulid if cython is available, and will fallback to pure python if it is not.
58
+
59
+ ## Example
60
+
61
+ ```python
62
+ >>> import ulid_transform
63
+ >>> ulid_transform.ulid_hex()
64
+ '01869a2ea5fb0b43aa056293e47c0a35'
65
+ >>> ulid_transform.ulid_now()
66
+ '0001HZX0NW00GW0X476W5TVBFE'
67
+ >>> ulid_transform.ulid_at_time(1234)
68
+ '000000016JC62D620DGYNG2R8H'
69
+ >>> ulid_transform.ulid_to_bytes('0001HZX0NW00GW0X476W5TVBFE')
70
+ b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
71
+ >> ulid_transform.bytes_to_ulid(b"\x01\x86\x99?\xe8\xf3\x11\xbc\xed\xef\x86U.9\x03z")
72
+ '01GTCKZT7K26YEVVW6AMQ3J0VT'
73
+ >>> ulid_transform.ulid_to_bytes_or_none('0001HZX0NW00GW0X476W5TVBFE')
74
+ b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
75
+ >>> ulid_transform.ulid_to_bytes_or_none(None)
76
+ >>> ulid_transform.bytes_to_ulid_or_none(b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee')
77
+ '0001HZX0NW00GW0X476W5TVBFE'
78
+ >>> ulid_transform.bytes_to_ulid_or_none(None)
79
+ ```
80
+
81
+ ## Installation
82
+
83
+ Install this via pip (or your favourite package manager):
84
+
85
+ `pip install ulid-transform`
86
+
87
+ ## Contributors ✨
88
+
89
+ Thanks to https://github.com/suyash/ulid which provides the cython implementation guts.
90
+
91
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
92
+
93
+ <!-- prettier-ignore-start -->
94
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
95
+ <!-- markdownlint-disable -->
96
+ <!-- markdownlint-enable -->
97
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
98
+ <!-- prettier-ignore-end -->
99
+
100
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
101
+
102
+ ## Credits
103
+
104
+ This package was created with
105
+ [Copier](https://copier.readthedocs.io/) and the
106
+ [browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
107
+ project template.
108
+
@@ -0,0 +1,17 @@
1
+ ulid_transform/__init__.py,sha256=thyiD_vtcTLh6M-B_547NQzEiz2sxetBoHTieXYj6tc,853
2
+ ulid_transform/__init__.pyi,sha256=eRmwQvXnwgj1mhdVokznDZVwOl2Xr_5tEAertTjkI5s,468
3
+ ulid_transform/_py_ulid_impl.py,sha256=hqam9a2A149GUgRzdWdjB2BQ2P_hgTInP1p4JY0Ijz8,10241
4
+ ulid_transform/_ulid_impl.cpython-314-aarch64-linux-musl.so,sha256=Yd_sUwDVCa1rUKI506nlQ3Cr82FfrA1PsCFo6rLqMoM,269041
5
+ ulid_transform/_ulid_impl.cpython-314t-aarch64-linux-musl.so,sha256=57pOPcFPGarm3WUx3eZBSfQ60qgrPOyuxRVT9vVtCn0,269241
6
+ ulid_transform/_ulid_impl.pyx,sha256=C64Ca_ydLglYYadIVgrQvMMVKPbpc6nfaOHTFK66ORU,4441
7
+ ulid_transform/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ ulid_transform/ulid_struct.hh,sha256=tXsl6nrXKI_BGwfHWloWrylaaB71ViXt_IZcso28PHM,10301
9
+ ulid_transform/ulid_uint128.hh,sha256=X_f8EzVdCZvhFvYevCX3kM9FMpfrKAapoRPN4YTxbVM,11331
10
+ ulid_transform/ulid_wrapper.cpp,sha256=lJwX2x19okXRMTA8Pew9HzWt-1iofS7RUEIvI65zAdM,3008
11
+ ulid_transform/ulid_wrapper.h,sha256=3Yuy3H5uN-cRNRMbQvL40NPwXwOfCsTe8KtwyxPZrqg,505
12
+ ulid_transform.libs/libgcc_s-2d945d6c.so.1,sha256=dn-5kQf6XkEWhBOx7tnXMZHJQSbDdSYmPhrx8fiYeI8,201673
13
+ ulid_transform.libs/libstdc++-85f2cd6d.so.6.0.33,sha256=VjT6H3rGbIUp02akWf5sJoz8LifUZ4OFZJYGOR_KyeI,3650097
14
+ ulid_transform-1.5.2.dist-info/METADATA,sha256=vMtfUWYKGcFvVbpYXvdDqntiakuO0CQqtoC3AADg3zY,5619
15
+ ulid_transform-1.5.2.dist-info/WHEEL,sha256=JkqnkBKKARxt3NaO7JXzb98blo4sl67hY_iM8_VdDUI,111
16
+ ulid_transform-1.5.2.dist-info/RECORD,,
17
+ ulid_transform-1.5.2.dist-info/licenses/LICENSE,sha256=gieJjxNidEKH1VXLqbV9tuqnmcnqvMqt5xcmktkn5I4,1072
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.1
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314t-musllinux_1_2_aarch64
@@ -0,0 +1,22 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2022 J. Nick Koston
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.