python-ulid 4.0.1__py3-none-any.whl → 4.1.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-4.0.1.dist-info → python_ulid-4.1.0.dist-info}/METADATA +4 -5
- python_ulid-4.1.0.dist-info/RECORD +10 -0
- {python_ulid-4.0.1.dist-info → python_ulid-4.1.0.dist-info}/WHEEL +1 -1
- ulid/__init__.py +4 -13
- ulid/__main__.py +8 -4
- ulid/base32.py +3 -1
- python_ulid-4.0.1.dist-info/RECORD +0 -10
- {python_ulid-4.0.1.dist-info → python_ulid-4.1.0.dist-info}/entry_points.txt +0 -0
- {python_ulid-4.0.1.dist-info → python_ulid-4.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: python-ulid
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.1.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
|
|
@@ -18,14 +18,13 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
18
18
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
19
|
Classifier: Operating System :: POSIX :: Linux
|
|
20
20
|
Classifier: Programming Language :: Python
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
23
|
Classifier: Programming Language :: Python :: 3.13
|
|
25
24
|
Classifier: Programming Language :: Python :: 3.14
|
|
26
25
|
Classifier: Topic :: Software Development :: Libraries
|
|
27
|
-
Requires-Python: >=3.
|
|
28
|
-
Requires-Dist: typing-extensions; python_version < '3.
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Requires-Dist: typing-extensions; python_version < '3.12'
|
|
29
28
|
Provides-Extra: pydantic
|
|
30
29
|
Requires-Dist: pydantic>=2.0; extra == 'pydantic'
|
|
31
30
|
Description-Content-Type: text/x-rst
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ulid/__init__.py,sha256=vD10dtMt6iV4_iLJTBkiNwlcBzy1ID0uJg_Dw21iXxY,20995
|
|
2
|
+
ulid/__main__.py,sha256=nyRtUgdkXbxxvCRz4XtvnrYWqY6NhHFG2Uf7HtUS18Q,5647
|
|
3
|
+
ulid/base32.py,sha256=40jH4ADBs5ZTpfJmLYvwijiy_rGP1JGum7fFkLmkv7k,6088
|
|
4
|
+
ulid/constants.py,sha256=lbCLRNQXq8qnOdz_w-nJf_j5dC2X7Gjv-8GJUbs5jX8,503
|
|
5
|
+
ulid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
python_ulid-4.1.0.dist-info/METADATA,sha256=Zmlduve0O4R_HHJjgnc_TFop8CrLeDZVNmLTGX-W0Ck,8707
|
|
7
|
+
python_ulid-4.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
8
|
+
python_ulid-4.1.0.dist-info/entry_points.txt,sha256=9214ghzfSgS8a-TjjlWDF7bI7KSaeewOCBKn5uz7bdU,50
|
|
9
|
+
python_ulid-4.1.0.dist-info/licenses/LICENSE,sha256=DiDPNhW5yUHIqaKowvX0c1c9xWiI0xW4ji8R9N2NJbw,1056
|
|
10
|
+
python_ulid-4.1.0.dist-info/RECORD,,
|
ulid/__init__.py
CHANGED
|
@@ -7,7 +7,8 @@ import time
|
|
|
7
7
|
import uuid
|
|
8
8
|
from collections.abc import Callable
|
|
9
9
|
from datetime import datetime
|
|
10
|
-
from datetime import
|
|
10
|
+
from datetime import UTC
|
|
11
|
+
from importlib.metadata import version
|
|
11
12
|
from threading import Lock
|
|
12
13
|
from typing import Any
|
|
13
14
|
from typing import cast
|
|
@@ -25,22 +26,12 @@ from ulid import constants
|
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
if TYPE_CHECKING: # pragma: no cover
|
|
28
|
-
import
|
|
29
|
+
from typing import Self
|
|
29
30
|
|
|
30
31
|
from pydantic import GetCoreSchemaHandler
|
|
31
32
|
from pydantic import ValidatorFunctionWrapHandler
|
|
32
33
|
from pydantic_core import CoreSchema
|
|
33
34
|
|
|
34
|
-
if sys.version_info >= (3, 11):
|
|
35
|
-
from typing import Self
|
|
36
|
-
else:
|
|
37
|
-
from typing_extensions import Self
|
|
38
|
-
|
|
39
|
-
try:
|
|
40
|
-
from importlib.metadata import version
|
|
41
|
-
except ImportError: # pragma: no cover
|
|
42
|
-
from importlib_metadata import version # type: ignore
|
|
43
|
-
|
|
44
35
|
|
|
45
36
|
__version__ = version("python-ulid")
|
|
46
37
|
|
|
@@ -413,7 +404,7 @@ class ULID:
|
|
|
413
404
|
>>> ulid.datetime
|
|
414
405
|
datetime.datetime(2020, 4, 30, 14, 33, 27, 560000, tzinfo=datetime.timezone.utc)
|
|
415
406
|
"""
|
|
416
|
-
return datetime.fromtimestamp(self.timestamp,
|
|
407
|
+
return datetime.fromtimestamp(self.timestamp, UTC)
|
|
417
408
|
|
|
418
409
|
@functools.cached_property
|
|
419
410
|
def hex(self) -> str:
|
ulid/__main__.py
CHANGED
|
@@ -45,7 +45,11 @@ def make_parser(prog: str | None = None) -> argparse.ArgumentParser:
|
|
|
45
45
|
width=min(shutil.get_terminal_size().columns - 2, 127),
|
|
46
46
|
),
|
|
47
47
|
)
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
def help(*_args: Any) -> None:
|
|
50
|
+
parser.print_help()
|
|
51
|
+
|
|
52
|
+
parser.set_defaults(func=help)
|
|
49
53
|
parser.add_argument("--version", "-V", action="version", version=ulid.__version__)
|
|
50
54
|
|
|
51
55
|
subparsers = parser.add_subparsers(title="subcommands")
|
|
@@ -163,10 +167,10 @@ def show(args: argparse.Namespace) -> str:
|
|
|
163
167
|
).strip()
|
|
164
168
|
|
|
165
169
|
|
|
166
|
-
def entrypoint() -> None: # pragma: no cover
|
|
167
|
-
if (value := main(sys.argv[1:])) is not None:
|
|
170
|
+
def entrypoint(prog: str | None = None) -> None: # pragma: no cover
|
|
171
|
+
if (value := main(sys.argv[1:], prog)) is not None:
|
|
168
172
|
print(value) # noqa: T201
|
|
169
173
|
|
|
170
174
|
|
|
171
175
|
if __name__ == "__main__": # pragma: no cover
|
|
172
|
-
|
|
176
|
+
entrypoint("python -m ulid")
|
ulid/base32.py
CHANGED
|
@@ -7,6 +7,8 @@ from ulid import constants
|
|
|
7
7
|
# https://github.com/RobThree/NUlid/blob/89f5a9fc827d191ae5adafe42547575ed3a47723/NUlid/Ulid.cs#L168
|
|
8
8
|
|
|
9
9
|
ENCODE: str = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
|
|
10
|
+
# The ULID spec defines the string representation as case insensitive.
|
|
11
|
+
DECODE_ALPHABET: str = ENCODE + ENCODE.lower()
|
|
10
12
|
DECODE: Sequence[int] = [
|
|
11
13
|
0xFF,
|
|
12
14
|
0xFF,
|
|
@@ -194,7 +196,7 @@ def encode_randomness(binary: bytes) -> str:
|
|
|
194
196
|
def decode(encoded: str) -> bytes:
|
|
195
197
|
if len(encoded) != constants.REPR_LEN:
|
|
196
198
|
raise ValueError("Encoded ULID has to be exactly 26 characters long.")
|
|
197
|
-
if any((c not in
|
|
199
|
+
if any((c not in DECODE_ALPHABET) for c in encoded):
|
|
198
200
|
raise ValueError(f"Encoded ULID can only consist of letters in {ENCODE}.")
|
|
199
201
|
return decode_timestamp(encoded[: constants.TIMESTAMP_REPR_LEN]) + decode_randomness(
|
|
200
202
|
encoded[constants.TIMESTAMP_REPR_LEN :]
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
ulid/__init__.py,sha256=RUAerfe39tcNib2oAREKB7U9DfF-rdXueNg3kF76zV8,21227
|
|
2
|
-
ulid/__main__.py,sha256=ZP8ZbhQ_o-O4Ckbba87bZ4NkwzrSFhAkrRLmUnzkW0Y,5586
|
|
3
|
-
ulid/base32.py,sha256=iUE5BGPW5Dul-Eu3ITvcymk8acNkIFAVTlrL12YIPKI,5961
|
|
4
|
-
ulid/constants.py,sha256=lbCLRNQXq8qnOdz_w-nJf_j5dC2X7Gjv-8GJUbs5jX8,503
|
|
5
|
-
ulid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
python_ulid-4.0.1.dist-info/METADATA,sha256=LuILMUf_zi1x8OonhM9KEuPdygFqPs9R4ubHAMxn6fQ,8758
|
|
7
|
-
python_ulid-4.0.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
8
|
-
python_ulid-4.0.1.dist-info/entry_points.txt,sha256=9214ghzfSgS8a-TjjlWDF7bI7KSaeewOCBKn5uz7bdU,50
|
|
9
|
-
python_ulid-4.0.1.dist-info/licenses/LICENSE,sha256=DiDPNhW5yUHIqaKowvX0c1c9xWiI0xW4ji8R9N2NJbw,1056
|
|
10
|
-
python_ulid-4.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|