xloft 0.5.2__py3-none-any.whl → 0.6.1__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 CHANGED
@@ -4,14 +4,17 @@ Modules exported by this package:
4
4
 
5
5
  - `namedtuple`- Class imitates the behavior of the _named tuple_.
6
6
  - `human` - A collection of instruments for converting data to format is convenient for humans.
7
+ - `it_is` - Tools for determining something.
7
8
  """
8
9
 
9
10
  from __future__ import annotations
10
11
 
11
12
  __all__ = (
12
13
  "to_human_size",
14
+ "is_number",
13
15
  "NamedTuple",
14
16
  )
15
17
 
16
18
  from xloft.human import to_human_size
19
+ from xloft.it_is import is_number
17
20
  from xloft.namedtuple import NamedTuple
xloft/it_is.py ADDED
@@ -0,0 +1,24 @@
1
+ """Tools for determining something."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __all__ = ("is_number",)
6
+
7
+ import re
8
+
9
+ # Caching
10
+ _REGEX_IS_NUMBER = re.compile(r"^[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$")
11
+
12
+
13
+ def is_number(value: str) -> bool:
14
+ """Check if a string is a number.
15
+
16
+ Only decimal numbers.
17
+
18
+ Args:
19
+ value: Some kind of string.
20
+
21
+ Returns:
22
+ True, if the string is a number.
23
+ """
24
+ return _REGEX_IS_NUMBER.match(value) is not None
xloft/namedtuple.py CHANGED
@@ -14,7 +14,7 @@ from xloft.errors import (
14
14
 
15
15
 
16
16
  class NamedTuple:
17
- """This class imitates the behavior of the *named tuple*."""
17
+ """This class imitates the behavior of the `named tuple`."""
18
18
 
19
19
  def __init__(self, **kwargs: dict[str, Any]) -> None: # noqa: D107
20
20
  self.__dict__["_0D5rSmH9Sy2XUWb5_keys"] = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xloft
3
- Version: 0.5.2
3
+ Version: 0.6.1
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
@@ -61,7 +61,7 @@ Description-Content-Type: text/markdown
61
61
  <a href="https://github.com/kebasyaty/xloft/releases/" alt="GitHub release"><img src="https://img.shields.io/github/release/kebasyaty/xloft" alt="GitHub release"></a>
62
62
  </p>
63
63
  <p align="center">
64
- The collection is represented by three modules of `NamedTuple`, `Human`.
64
+ The collection is represented by three modules of `NamedTuple`, `Human`, `ItIs`.
65
65
  <br>
66
66
  In the future, new tools can be added.
67
67
  </p>
@@ -171,14 +171,31 @@ del nt._id # => raise: AttributeCannotBeDelete
171
171
  from xloft import to_human_size
172
172
 
173
173
 
174
- s = to_human_size(200)
175
- print(s) # => 200 bytes
174
+ to_human_size(200) # => 200 bytes
175
+ to_human_size(1048576) # => 1 MB
176
+ to_human_size(1048575) # => 1023.999 KB
177
+ ```
176
178
 
177
- s = to_human_size(1048576)
178
- print(s) # => 1 MB
179
+ - **ItIs**
179
180
 
180
- s = to_human_size(1048575)
181
- print(s) # => 1023.999 KB
181
+ ```python
182
+ from xloft import is_number
183
+
184
+
185
+ is_number("-1230.0123") # => True
186
+ is_number("+1230.0123") # => True
187
+ is_number("1230.0123") # => True
188
+ is_number("1230.0") # => True
189
+ is_number("1230") # => True
190
+ is_number("1.23e-5") # => True
191
+ is_number("1.23e-05") # => True
192
+ is_number(".5") # => True
193
+
194
+ is_number("") # => False
195
+ is_number(" ") # => False
196
+ is_number("1230.") # => False
197
+ is_number("0x5") # => False
198
+ is_number("0o5") # => False
182
199
  ```
183
200
 
184
201
  ## Changelog
@@ -0,0 +1,10 @@
1
+ xloft/__init__.py,sha256=owfU9Z6DZAKLdm-6mCV3alaUKdXTcPErg-sexMGvcFc,518
2
+ xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
3
+ xloft/human.py,sha256=WQbVOKpOvzGot-c7f3xitbS05JUIQmj3dreGtRV6GA0,1792
4
+ xloft/it_is.py,sha256=Uac1du1Z_rUf3e8uThLWcSYU0F27zThBDW6UMUEHz88,480
5
+ xloft/namedtuple.py,sha256=egEULlfATXM8gMhAMjQSHocwTudqqzXDGTYGZVSUGZs,5725
6
+ xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ xloft-0.6.1.dist-info/METADATA,sha256=Uu6iu9OFbeogIvdQjB9Weg73TsRynofz2E1z9GGxNUw,7502
8
+ xloft-0.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ xloft-0.6.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
10
+ xloft-0.6.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- xloft/__init__.py,sha256=mf6z2-Tnl-CdYMa8mrI5MlTl48G0GQoYNNj2PMp8SsQ,419
2
- xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
3
- xloft/human.py,sha256=WQbVOKpOvzGot-c7f3xitbS05JUIQmj3dreGtRV6GA0,1792
4
- xloft/namedtuple.py,sha256=EygsHfND0P7pw9r7Amzqi0gXsMkhpAdQVEYKDAu3rr0,5725
5
- xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- xloft-0.5.2.dist-info/METADATA,sha256=D5Pyg8nY1XPXiMBYMBjIWPtlZB3T-6IRKDGmeC-9PL8,7079
7
- xloft-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- xloft-0.5.2.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
9
- xloft-0.5.2.dist-info/RECORD,,
File without changes