xloft 0.6.4__py3-none-any.whl → 0.6.6__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/__init__.py +2 -2
- xloft/converters/__init__.py +12 -0
- xloft/{converter → converters}/human_size.py +2 -30
- {xloft-0.6.4.dist-info → xloft-0.6.6.dist-info}/METADATA +7 -8
- xloft-0.6.6.dist-info/RECORD +11 -0
- xloft/converter/__init__.py +0 -22
- xloft-0.6.4.dist-info/RECORD +0 -11
- {xloft-0.6.4.dist-info → xloft-0.6.6.dist-info}/WHEEL +0 -0
- {xloft-0.6.4.dist-info → xloft-0.6.6.dist-info}/licenses/LICENSE +0 -0
xloft/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Modules exported by this package:
|
|
4
4
|
|
|
5
5
|
- `namedtuple`- Class imitates the behavior of the _named tuple_.
|
|
6
|
-
- `
|
|
6
|
+
- `converters` - Collection of tools for converting data.
|
|
7
7
|
- `itis` - Tools for determining something.
|
|
8
8
|
"""
|
|
9
9
|
|
|
@@ -15,6 +15,6 @@ __all__ = (
|
|
|
15
15
|
"NamedTuple",
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from xloft.
|
|
18
|
+
from xloft.converters.human_size import to_human_size
|
|
19
19
|
from xloft.itis import is_number
|
|
20
20
|
from xloft.namedtuple import NamedTuple
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Collection of tools for converting data.
|
|
2
|
+
|
|
3
|
+
The module contains the following functions:
|
|
4
|
+
|
|
5
|
+
- `to_human_size(n_bytes)` - Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
__all__ = ("to_human_size",)
|
|
11
|
+
|
|
12
|
+
from xloft.converters.human_size import to_human_size
|
|
@@ -3,37 +3,14 @@
|
|
|
3
3
|
The module contains the following functions:
|
|
4
4
|
|
|
5
5
|
- `to_human_size(n_bytes)` - Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
6
|
-
- `get_cache_human_size` - Gets a copy of variable _cache_human_size.
|
|
7
|
-
- `clean_cache_human_size` - Resets of variable _cache_human_size.
|
|
8
6
|
"""
|
|
9
7
|
|
|
10
8
|
from __future__ import annotations
|
|
11
9
|
|
|
12
|
-
__all__ = (
|
|
13
|
-
"to_human_size",
|
|
14
|
-
"get_cache_human_size",
|
|
15
|
-
"clean_cache_human_size",
|
|
16
|
-
)
|
|
10
|
+
__all__ = ("to_human_size",)
|
|
17
11
|
|
|
18
12
|
import math
|
|
19
13
|
|
|
20
|
-
# To caching the results from to_human_size method.
|
|
21
|
-
_cache_human_size: dict[int, str] = {}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def get_cache_human_size() -> dict[int, str]:
|
|
25
|
-
"""Gets a copy of variable _cach_human_size.
|
|
26
|
-
|
|
27
|
-
Hint: To tests.
|
|
28
|
-
"""
|
|
29
|
-
return _cache_human_size.copy()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def clean_cache_human_size() -> None:
|
|
33
|
-
"""Resets of variable _cach_human_size."""
|
|
34
|
-
global _cache_human_size # noqa: PLW0603
|
|
35
|
-
_cache_human_size = {}
|
|
36
|
-
|
|
37
14
|
|
|
38
15
|
def to_human_size(n_bytes: int) -> str:
|
|
39
16
|
"""Converts the number of bytes into a human-readable format.
|
|
@@ -53,15 +30,10 @@ def to_human_size(n_bytes: int) -> str:
|
|
|
53
30
|
Returns:
|
|
54
31
|
Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
55
32
|
"""
|
|
56
|
-
result: str | None = _cache_human_size.get(n_bytes)
|
|
57
|
-
if result is not None:
|
|
58
|
-
return result
|
|
59
33
|
idx: int = math.floor(math.log(n_bytes) / math.log(1024))
|
|
60
34
|
ndigits: int = [0, 3, 6, 9, 12][idx]
|
|
61
35
|
human_size: int | float = n_bytes if n_bytes < 1024 else abs(round(n_bytes / pow(1024, idx), ndigits))
|
|
62
36
|
order = ["bytes", "KB", "MB", "GB", "TB"][idx]
|
|
63
37
|
if math.modf(human_size)[0] == 0.0:
|
|
64
38
|
human_size = int(human_size)
|
|
65
|
-
|
|
66
|
-
_cache_human_size[n_bytes] = result
|
|
67
|
-
return result
|
|
39
|
+
return f"{human_size} {order}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xloft
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.6
|
|
4
4
|
Summary: (XLOFT) X-Library of tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/kebasyaty/xloft
|
|
6
6
|
Project-URL: Repository, https://github.com/kebasyaty/xloft
|
|
@@ -70,13 +70,6 @@ Description-Content-Type: text/markdown
|
|
|
70
70
|
|
|
71
71
|
##
|
|
72
72
|
|
|
73
|
-
<img src="https://raw.githubusercontent.com/kebasyaty/xloft/v0/assets/attention.svg" alt="Attention">
|
|
74
|
-
<p>
|
|
75
|
-
The `quantum` module was deleted.
|
|
76
|
-
<br>
|
|
77
|
-
<a href="https://pypi.python.org/pypi/quantum-loop/" alt="quantum-loop">He is now here</a>
|
|
78
|
-
</p>
|
|
79
|
-
|
|
80
73
|
<br>
|
|
81
74
|
|
|
82
75
|
## Documentation
|
|
@@ -98,6 +91,8 @@ uv add xloft
|
|
|
98
91
|
- **NamedTuple**
|
|
99
92
|
|
|
100
93
|
```python
|
|
94
|
+
"""This class imitates the behavior of the `named tuple`."""
|
|
95
|
+
|
|
101
96
|
from xloft import NamedTuple
|
|
102
97
|
|
|
103
98
|
|
|
@@ -168,6 +163,8 @@ del nt._id # => raise: AttributeCannotBeDelete
|
|
|
168
163
|
- **Converter**
|
|
169
164
|
|
|
170
165
|
```python
|
|
166
|
+
"""Convert the number of bytes into a human-readable format."""
|
|
167
|
+
|
|
171
168
|
from xloft import to_human_size
|
|
172
169
|
|
|
173
170
|
|
|
@@ -179,6 +176,8 @@ to_human_size(1048575) # => 1023.999 KB
|
|
|
179
176
|
- **ItIs**
|
|
180
177
|
|
|
181
178
|
```python
|
|
179
|
+
"""Check if a string is a number."""
|
|
180
|
+
|
|
182
181
|
from xloft import is_number
|
|
183
182
|
|
|
184
183
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
xloft/__init__.py,sha256=oLi6SfT894qR_qmWupAhtKUpfeeMlYek2mcdQB9nZNI,494
|
|
2
|
+
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
+
xloft/itis.py,sha256=Uac1du1Z_rUf3e8uThLWcSYU0F27zThBDW6UMUEHz88,480
|
|
4
|
+
xloft/namedtuple.py,sha256=egEULlfATXM8gMhAMjQSHocwTudqqzXDGTYGZVSUGZs,5725
|
|
5
|
+
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
xloft/converters/__init__.py,sha256=17_p8AQ-_UcKKioJolP_738LHCNOwohJIkCqeyaVO_M,316
|
|
7
|
+
xloft/converters/human_size.py,sha256=NcZRWF64LkQJ8-R00X7MCkNvXwlFDTcp5M3MylQzRTM,1149
|
|
8
|
+
xloft-0.6.6.dist-info/METADATA,sha256=A1jQ0KdswrWd_-q86S_Jkcm6PaTlIfe6zikhPBzzeY4,7432
|
|
9
|
+
xloft-0.6.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
+
xloft-0.6.6.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
11
|
+
xloft-0.6.6.dist-info/RECORD,,
|
xloft/converter/__init__.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"""A collection of instruments for converting data.
|
|
2
|
-
|
|
3
|
-
The module contains the following functions:
|
|
4
|
-
|
|
5
|
-
- `to_human_size(n_bytes)` - Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
6
|
-
- `get_cache_human_size` - Gets a copy of variable _cache_human_size.
|
|
7
|
-
- `clean_cache_human_size` - Resets of variable _cache_human_size.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
|
|
12
|
-
__all__ = (
|
|
13
|
-
"to_human_size",
|
|
14
|
-
"get_cache_human_size",
|
|
15
|
-
"clean_cache_human_size",
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
from xloft.converter.human_size import (
|
|
19
|
-
clean_cache_human_size,
|
|
20
|
-
get_cache_human_size,
|
|
21
|
-
to_human_size,
|
|
22
|
-
)
|
xloft-0.6.4.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
xloft/__init__.py,sha256=edoLxSQjmYOqkA_m7IKUavUPnZdTBz8J0YvgqAzFqqI,535
|
|
2
|
-
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
-
xloft/itis.py,sha256=Uac1du1Z_rUf3e8uThLWcSYU0F27zThBDW6UMUEHz88,480
|
|
4
|
-
xloft/namedtuple.py,sha256=egEULlfATXM8gMhAMjQSHocwTudqqzXDGTYGZVSUGZs,5725
|
|
5
|
-
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xloft/converter/__init__.py,sha256=iTZaq2zKj7NEFpKQ-v-xJAxcT0MdzEODTJkjzUgUrQo,597
|
|
7
|
-
xloft/converter/human_size.py,sha256=vslG12Fln86zuCfXmDlmeijA2mCoLW3R2299PJ0wbxE,1957
|
|
8
|
-
xloft-0.6.4.dist-info/METADATA,sha256=eOmsrmGoPSmjGmPK5KUX7KHt3qcLrUap02v2Gbn_fUw,7509
|
|
9
|
-
xloft-0.6.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
-
xloft-0.6.4.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
11
|
-
xloft-0.6.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|