none-shall-parse 0.4.3__tar.gz → 0.4.5__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.
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/PKG-INFO +1 -1
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/pyproject.toml +1 -1
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/__init__.py +8 -2
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/lists.py +2 -2
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/strings.py +19 -0
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/README.md +0 -0
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/dates.py +0 -0
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/imeis.py +0 -0
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/parse.py +0 -0
- {none_shall_parse-0.4.3 → none_shall_parse-0.4.5}/src/none_shall_parse/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: none-shall-parse
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
4
4
|
Summary: Trinity Shared Python utilities.
|
|
5
5
|
Author: Andries Niemandt, Jan Badenhorst
|
|
6
6
|
Author-email: Andries Niemandt <andries.niemandt@trintel.co.za>, Jan Badenhorst <jan@trintel.co.za>
|
|
@@ -72,7 +72,10 @@ from .strings import (
|
|
|
72
72
|
)
|
|
73
73
|
from .types import (
|
|
74
74
|
StringLike,
|
|
75
|
-
ChoicesType
|
|
75
|
+
ChoicesType,
|
|
76
|
+
DateTimeLike,
|
|
77
|
+
DateLike,
|
|
78
|
+
DateTimeOrDateLike,
|
|
76
79
|
)
|
|
77
80
|
|
|
78
81
|
__author__ = "Andries Niemandt, Jan Badenhorst"
|
|
@@ -129,5 +132,8 @@ __all__ = (
|
|
|
129
132
|
"calc_hash",
|
|
130
133
|
"generate_random_password",
|
|
131
134
|
"StringLike",
|
|
132
|
-
"ChoicesType"
|
|
135
|
+
"ChoicesType",
|
|
136
|
+
"DateTimeLike",
|
|
137
|
+
"DateLike",
|
|
138
|
+
"DateTimeOrDateLike",
|
|
133
139
|
)
|
|
@@ -20,13 +20,13 @@ def flatten(some_list: Iterable) -> Generator[Any, None, None]:
|
|
|
20
20
|
:rtype: Generator[Any, None, None]
|
|
21
21
|
"""
|
|
22
22
|
for el in some_list:
|
|
23
|
-
if isinstance(el,
|
|
23
|
+
if isinstance(el, Iterable) and not isinstance(el, (str, bytes)):
|
|
24
24
|
yield from flatten(el)
|
|
25
25
|
else:
|
|
26
26
|
yield el
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def safe_list_get(lst: List[T], idx: int, default: T) -> T:
|
|
29
|
+
def safe_list_get(lst: List[T], idx: int, default: T = None) -> T:
|
|
30
30
|
"""
|
|
31
31
|
Retrieve an element from a list by its index or return a default value if the index
|
|
32
32
|
is out of range. This function ensures no IndexError is raised during the retrieval
|
|
@@ -246,3 +246,22 @@ def generate_random_password(n: int = 10) -> str:
|
|
|
246
246
|
):
|
|
247
247
|
break
|
|
248
248
|
return password
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def generate_crypto_password(n: int = 32) -> str:
|
|
252
|
+
"""
|
|
253
|
+
Generates a cryptographically secure password string.
|
|
254
|
+
|
|
255
|
+
This function uses the `secrets` module to generate a cryptographically
|
|
256
|
+
secure random string with a specified length. The default length of
|
|
257
|
+
the password is 32 characters.
|
|
258
|
+
|
|
259
|
+
Parameters:
|
|
260
|
+
n: int, optional
|
|
261
|
+
Length of the password string. Defaults to 32.
|
|
262
|
+
|
|
263
|
+
Returns:
|
|
264
|
+
str
|
|
265
|
+
A cryptographically secure randomly generated password string.
|
|
266
|
+
"""
|
|
267
|
+
return secrets.token_urlsafe(n)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|