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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: none-shall-parse
3
- Version: 0.4.3
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>
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "none-shall-parse"
7
- version = "0.4.3"
7
+ version = "0.4.5"
8
8
  description = "Trinity Shared Python utilities."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -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, collections.Iterable) and not isinstance(el, (str, bytes)):
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)