klaatu-python 2.2.0__tar.gz → 2.3.0__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.
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/PKG-INFO +3 -3
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/README.md +1 -1
- klaatu_python-2.3.0/klaatu_python/__init__.py +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python/utils.py +44 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python.egg-info/PKG-INFO +3 -3
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/pyproject.toml +5 -8
- klaatu_python-2.2.0/klaatu_python/__init__.py +0 -1
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/LICENSE +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python/case.py +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python/lock.py +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python.egg-info/SOURCES.txt +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python.egg-info/dependency_links.txt +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python.egg-info/requires.txt +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/klaatu_python.egg-info/top_level.txt +0 -0
- {klaatu_python-2.2.0 → klaatu_python-2.3.0}/setup.cfg +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: klaatu-python
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Author-email: Robert Huselius <robert@huseli.us>
|
|
5
5
|
License-Expression: GPL-3.0-only
|
|
6
6
|
Project-URL: Homepage, https://github.com/Eboreg/klaatu-python
|
|
7
|
-
Project-URL: Source, https://github.com/Eboreg/klaatu-python
|
|
8
7
|
Project-URL: Issues, https://github.com/Eboreg/klaatu-python/issues
|
|
8
|
+
Project-URL: Source, https://github.com/Eboreg/klaatu-python
|
|
9
9
|
Requires-Python: >=3.7
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
@@ -34,7 +34,7 @@ In `pyproject.toml`:
|
|
|
34
34
|
```
|
|
35
35
|
[project]
|
|
36
36
|
dependencies = [
|
|
37
|
-
"
|
|
37
|
+
"klaatu-python",
|
|
38
38
|
...
|
|
39
39
|
]
|
|
40
40
|
```
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from datetime import date, timedelta
|
|
3
|
+
from locale import format_string, localeconv
|
|
3
4
|
from math import ceil, floor, log10
|
|
4
5
|
from typing import Any, Callable, Iterable, Iterator, Literal, Sequence, TypeVar, overload
|
|
5
6
|
from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit
|
|
@@ -69,6 +70,20 @@ def filter_values_not_null(d: dict) -> dict:
|
|
|
69
70
|
return {k: v for k, v in d.items() if v is not None}
|
|
70
71
|
|
|
71
72
|
|
|
73
|
+
def first_not_null(*values: _T | None) -> _T:
|
|
74
|
+
ret = first_not_null_or_null(*values)
|
|
75
|
+
if ret is None:
|
|
76
|
+
raise TypeError("All values are None")
|
|
77
|
+
return ret
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def first_not_null_or_null(*values: _T | None) -> _T | None:
|
|
81
|
+
for value in values:
|
|
82
|
+
if value is not None:
|
|
83
|
+
return value
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
72
87
|
def getitem_nullable(seq: Iterable[_T], idx: int, cond: Callable[[_T], bool] | None = None) -> _T | None:
|
|
73
88
|
"""
|
|
74
89
|
If `seq` has an item at position `idx`, return that item. Otherwise return
|
|
@@ -227,6 +242,35 @@ def is_truthy(value: Any) -> bool:
|
|
|
227
242
|
return bool(value)
|
|
228
243
|
|
|
229
244
|
|
|
245
|
+
def localize_float(
|
|
246
|
+
value: float,
|
|
247
|
+
grouping: bool = True,
|
|
248
|
+
min_decimals: int | None = None,
|
|
249
|
+
max_decimals: int | None = None,
|
|
250
|
+
) -> str:
|
|
251
|
+
if max_decimals is None:
|
|
252
|
+
max_decimals = 15
|
|
253
|
+
|
|
254
|
+
if min_decimals is not None and min_decimals > max_decimals:
|
|
255
|
+
raise ValueError("min_decimals must be <= max_decimals")
|
|
256
|
+
if 15 < (min_decimals or 0) < 0:
|
|
257
|
+
raise ValueError("min_decimals must be >= 0 and <= 15")
|
|
258
|
+
if 15 < (max_decimals or 0) < 0:
|
|
259
|
+
raise ValueError("max_decimals must be >= 0 and <= 15")
|
|
260
|
+
|
|
261
|
+
decimal_separator = localeconv()["decimal_point"]
|
|
262
|
+
ret = format_string("%.*f", (max_decimals, value), grouping=grouping)
|
|
263
|
+
|
|
264
|
+
if decimal_separator in ret:
|
|
265
|
+
base, decimals = ret.split(decimal_separator)
|
|
266
|
+
decimals = decimals.rstrip("0").ljust(min_decimals or 0, "0")
|
|
267
|
+
if not decimals:
|
|
268
|
+
return base
|
|
269
|
+
return base + decimal_separator + decimals
|
|
270
|
+
|
|
271
|
+
return ret
|
|
272
|
+
|
|
273
|
+
|
|
230
274
|
def nonulls(items: Iterable[_T | None]) -> list[_T]:
|
|
231
275
|
"""Just filters away None values from `items`."""
|
|
232
276
|
return [item for item in items if item is not None]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: klaatu-python
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Author-email: Robert Huselius <robert@huseli.us>
|
|
5
5
|
License-Expression: GPL-3.0-only
|
|
6
6
|
Project-URL: Homepage, https://github.com/Eboreg/klaatu-python
|
|
7
|
-
Project-URL: Source, https://github.com/Eboreg/klaatu-python
|
|
8
7
|
Project-URL: Issues, https://github.com/Eboreg/klaatu-python/issues
|
|
8
|
+
Project-URL: Source, https://github.com/Eboreg/klaatu-python
|
|
9
9
|
Requires-Python: >=3.7
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
@@ -34,7 +34,7 @@ In `pyproject.toml`:
|
|
|
34
34
|
```
|
|
35
35
|
[project]
|
|
36
36
|
dependencies = [
|
|
37
|
-
"
|
|
37
|
+
"klaatu-python",
|
|
38
38
|
...
|
|
39
39
|
]
|
|
40
40
|
```
|
|
@@ -3,15 +3,15 @@ build-backend = "setuptools.build_meta"
|
|
|
3
3
|
requires = ["setuptools"]
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
name = "klaatu-python"
|
|
7
|
-
requires-python = ">=3.7"
|
|
8
|
-
dynamic = ["version"]
|
|
9
6
|
authors = [
|
|
10
7
|
{name = "Robert Huselius", email = "robert@huseli.us"},
|
|
11
8
|
]
|
|
12
9
|
license = "GPL-3.0-only"
|
|
13
10
|
license-files = ["LICENSE"]
|
|
11
|
+
name = "klaatu-python"
|
|
14
12
|
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.7"
|
|
14
|
+
version = "2.3.0"
|
|
15
15
|
|
|
16
16
|
[project.optional-dependencies]
|
|
17
17
|
dev = [
|
|
@@ -23,11 +23,8 @@ dev = [
|
|
|
23
23
|
|
|
24
24
|
[project.urls]
|
|
25
25
|
Homepage = "https://github.com/Eboreg/klaatu-python"
|
|
26
|
-
Source = "https://github.com/Eboreg/klaatu-python"
|
|
27
26
|
Issues = "https://github.com/Eboreg/klaatu-python/issues"
|
|
28
|
-
|
|
29
|
-
[tool.setuptools.dynamic]
|
|
30
|
-
version = {attr = "klaatu_python.__version__"}
|
|
27
|
+
Source = "https://github.com/Eboreg/klaatu-python"
|
|
31
28
|
|
|
32
29
|
[tool.isort]
|
|
33
30
|
combine_as_imports = true
|
|
@@ -61,5 +58,5 @@ ignore_missing_imports = true
|
|
|
61
58
|
show_error_codes = true
|
|
62
59
|
|
|
63
60
|
[tool.flake8]
|
|
64
|
-
max-line-length = 119
|
|
65
61
|
max-doc-length = 79
|
|
62
|
+
max-line-length = 119
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|