xloft 0.4.6__py3-none-any.whl → 0.4.7__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.
Potentially problematic release.
This version of xloft might be problematic. Click here for more details.
xloft/human.py
CHANGED
|
@@ -9,21 +9,27 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
__all__ = (
|
|
11
11
|
"to_human_size",
|
|
12
|
-
"
|
|
12
|
+
"get_cache_human_size",
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
import math
|
|
16
16
|
|
|
17
17
|
# To caching the results from to_human_size method.
|
|
18
|
-
|
|
18
|
+
_cache_human_size: dict[int, str] = {}
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def
|
|
22
|
-
"""Get a copy of
|
|
21
|
+
def get_cache_human_size() -> dict[int, str]:
|
|
22
|
+
"""Get a copy of variable _cach_human_size.
|
|
23
23
|
|
|
24
24
|
Hint: To tests.
|
|
25
25
|
"""
|
|
26
|
-
return
|
|
26
|
+
return _cache_human_size.copy()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def clean_cache_human_size() -> None:
|
|
30
|
+
"""Reset of variable _cach_human_size."""
|
|
31
|
+
global _cache_human_size # noqa: PLW0603
|
|
32
|
+
_cache_human_size = {}
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
def to_human_size(n_bytes: int) -> str:
|
|
@@ -44,7 +50,7 @@ def to_human_size(n_bytes: int) -> str:
|
|
|
44
50
|
Returns:
|
|
45
51
|
Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
46
52
|
"""
|
|
47
|
-
result: str | None =
|
|
53
|
+
result: str | None = _cache_human_size.get(n_bytes)
|
|
48
54
|
if result is not None:
|
|
49
55
|
return result
|
|
50
56
|
idx: int = math.floor(math.log(n_bytes) / math.log(1024))
|
|
@@ -54,5 +60,5 @@ def to_human_size(n_bytes: int) -> str:
|
|
|
54
60
|
if math.modf(human_size)[0] == 0.0:
|
|
55
61
|
human_size = int(human_size)
|
|
56
62
|
result = f"{human_size} {order}"
|
|
57
|
-
|
|
63
|
+
_cache_human_size[n_bytes] = result
|
|
58
64
|
return result
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
xloft/__init__.py,sha256=UL4IR8EcFjgWoQFayl6FrK2u8QmZytGCwa_E1jDiCmE,475
|
|
2
2
|
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
-
xloft/human.py,sha256=
|
|
3
|
+
xloft/human.py,sha256=WQbVOKpOvzGot-c7f3xitbS05JUIQmj3dreGtRV6GA0,1792
|
|
4
4
|
xloft/namedtuple.py,sha256=a_l3bZF-L2I7MGxuF2CXzAHgNai-Vyj6SY1ODwxs7TU,6856
|
|
5
5
|
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
xloft/quantum.py,sha256=ZkFqqFROC9j5JbwJmej3yL9VJcqElPrrimFTz0Pe3Mk,4679
|
|
7
|
-
xloft-0.4.
|
|
8
|
-
xloft-0.4.
|
|
9
|
-
xloft-0.4.
|
|
10
|
-
xloft-0.4.
|
|
7
|
+
xloft-0.4.7.dist-info/METADATA,sha256=n2eO_R6lJ7VedihIUh4TiLYdDS9CaJR36hQxZyxpYw4,7241
|
|
8
|
+
xloft-0.4.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
xloft-0.4.7.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
+
xloft-0.4.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|