xloft 0.1.19__py3-none-any.whl → 0.1.20__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 -1
- xloft/humanism.py +8 -3
- {xloft-0.1.19.dist-info → xloft-0.1.20.dist-info}/METADATA +4 -1
- xloft-0.1.20.dist-info/RECORD +9 -0
- xloft-0.1.19.dist-info/RECORD +0 -9
- {xloft-0.1.19.dist-info → xloft-0.1.20.dist-info}/WHEEL +0 -0
- {xloft-0.1.19.dist-info → xloft-0.1.20.dist-info}/licenses/LICENSE +0 -0
xloft/__init__.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Modules exported by this package:
|
|
4
4
|
|
|
5
|
-
- `
|
|
5
|
+
- `namedtuple`: Class imitates the behavior of the _named tuple_.
|
|
6
|
+
- `humanism` - A collection of instruments for converting data to format is convenient for humans.
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
__all__ = (
|
xloft/humanism.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""A collection of instruments for converting data to format is convenient for humans.
|
|
2
2
|
|
|
3
3
|
The module contains the following functions:
|
|
4
4
|
|
|
@@ -17,6 +17,8 @@ def to_human_size(size: int) -> str:
|
|
|
17
17
|
200 bytes
|
|
18
18
|
>>> to_human_size(1048576)
|
|
19
19
|
1 MB
|
|
20
|
+
>>> to_human_size(1048575)
|
|
21
|
+
1023.999 KB
|
|
20
22
|
|
|
21
23
|
Args:
|
|
22
24
|
size: The number of bytes.
|
|
@@ -25,6 +27,9 @@ def to_human_size(size: int) -> str:
|
|
|
25
27
|
Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
26
28
|
"""
|
|
27
29
|
idx: int = math.floor(math.log(size) / math.log(1024))
|
|
28
|
-
|
|
30
|
+
ndigits: int = [0, 3, 6, 9, 12][idx]
|
|
31
|
+
human_size: int | float = size if size < 1024 else abs(round(size / pow(1024, idx), ndigits))
|
|
29
32
|
order = ["bytes", "KB", "MB", "GB", "TB"][idx]
|
|
30
|
-
|
|
33
|
+
if math.modf(human_size)[0] == 0.0:
|
|
34
|
+
human_size = int(human_size)
|
|
35
|
+
return f"{human_size} {order}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xloft
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.20
|
|
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
|
|
@@ -164,6 +164,9 @@ print(s) # => 200 bytes
|
|
|
164
164
|
|
|
165
165
|
s = to_human_size(1048576)
|
|
166
166
|
print(s) # => 1 MB
|
|
167
|
+
|
|
168
|
+
s = to_human_size(1048575)
|
|
169
|
+
print(s) # => 1023.999 KB
|
|
167
170
|
```
|
|
168
171
|
|
|
169
172
|
## Changelog
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
xloft/__init__.py,sha256=1gISK3F9XZoQH08YjP0YN5HPUxRgpEe8qih1To2cLT8,387
|
|
2
|
+
xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
|
|
3
|
+
xloft/humanism.py,sha256=I6q56MhviapBSWF4B_1xd77TDwQMM1jrkbl1N-fOURc,1068
|
|
4
|
+
xloft/namedtuple.py,sha256=OkAHqMaV4hN6Qj_oaOYQ9-y9x4Muv4mNrBn48T6RpiI,6818
|
|
5
|
+
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
xloft-0.1.20.dist-info/METADATA,sha256=mQrIKVa1QnRhYXDyzaOnAEl6gryQHEOIgzFtx58GbBQ,6750
|
|
7
|
+
xloft-0.1.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
xloft-0.1.20.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
9
|
+
xloft-0.1.20.dist-info/RECORD,,
|
xloft-0.1.19.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
xloft/__init__.py,sha256=zvpDtBWkgaj3oTMsDSWw2SLl7LMy7zO2SyvEhiKwzmg,287
|
|
2
|
-
xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
|
|
3
|
-
xloft/humanism.py,sha256=KQ-bIQJrVUZ3Xc5mVRQ07bvjq1LJzROr8tTV3RJWC0o,822
|
|
4
|
-
xloft/namedtuple.py,sha256=OkAHqMaV4hN6Qj_oaOYQ9-y9x4Muv4mNrBn48T6RpiI,6818
|
|
5
|
-
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xloft-0.1.19.dist-info/METADATA,sha256=da1niy9aKDAlolNSGNvI2Z9vzhbHkgBs7MJgPMRZsVM,6695
|
|
7
|
-
xloft-0.1.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
-
xloft-0.1.19.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
9
|
-
xloft-0.1.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|