none-shall-parse 0.6.0__tar.gz → 0.6.2__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.6.0 → none_shall_parse-0.6.2}/PKG-INFO +1 -1
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/pyproject.toml +1 -1
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/src/none_shall_parse/dates.py +15 -3
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/src/none_shall_parse/lists.py +6 -6
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/README.md +0 -0
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/src/none_shall_parse/__init__.py +0 -0
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/src/none_shall_parse/imeis.py +0 -0
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/src/none_shall_parse/parse.py +0 -0
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/src/none_shall_parse/strings.py +0 -0
- {none_shall_parse-0.6.0 → none_shall_parse-0.6.2}/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.6.
|
|
3
|
+
Version: 0.6.2
|
|
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>
|
|
@@ -682,9 +682,21 @@ def get_notice_end_date(given_date: DateTimeLike | date | Date | None = None) ->
|
|
|
682
682
|
return end_date
|
|
683
683
|
|
|
684
684
|
|
|
685
|
-
def dt_to_za_time_string(v:
|
|
686
|
-
"""Convert DateTime to South Africa time string
|
|
687
|
-
|
|
685
|
+
def dt_to_za_time_string(v: DateTimeOrDateLike | None) -> str | None:
|
|
686
|
+
"""Convert DateTime or Date to South Africa time string.
|
|
687
|
+
|
|
688
|
+
For datetime objects: returns "YYYY-MM-DD HH:MM:SS" in ZA timezone.
|
|
689
|
+
For date objects: returns "YYYY-MM-DD" (no time component).
|
|
690
|
+
For None: returns None.
|
|
691
|
+
"""
|
|
692
|
+
if v is None:
|
|
693
|
+
return None
|
|
694
|
+
|
|
695
|
+
# Handle date objects (no time component)
|
|
696
|
+
if isinstance(v, date) and not isinstance(v, datetime):
|
|
697
|
+
return v.strftime("%Y-%m-%d")
|
|
698
|
+
|
|
699
|
+
# Convert datetime to Pendulum
|
|
688
700
|
naive = v.tzinfo is None
|
|
689
701
|
if naive:
|
|
690
702
|
pdt = pendulum.instance(v, tz=ZA_TZ)
|
|
@@ -29,20 +29,20 @@ def flatten(some_list: Iterable) -> Generator[Any, None, None]:
|
|
|
29
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
|
-
is out of range
|
|
33
|
-
|
|
32
|
+
is out of range or the input is not subscriptable. This function ensures safe retrieval
|
|
33
|
+
by providing a fallback value when access fails.
|
|
34
34
|
|
|
35
|
-
:param lst: The list from which the element is to be retrieved.
|
|
35
|
+
:param lst: The list from which the element is to be retrieved (may be None).
|
|
36
36
|
:type lst: List[T]
|
|
37
37
|
:param idx: The index of the element to retrieve from the list.
|
|
38
38
|
:type idx: int
|
|
39
|
-
:param default: The fallback value to be returned if
|
|
39
|
+
:param default: The fallback value to be returned if retrieval fails.
|
|
40
40
|
:type default: T
|
|
41
41
|
:return: The element at the specified index, or the default value
|
|
42
|
-
if the index is out of range.
|
|
42
|
+
if the index is out of range or lst is None/not subscriptable.
|
|
43
43
|
:rtype: T
|
|
44
44
|
"""
|
|
45
45
|
try:
|
|
46
46
|
return lst[idx]
|
|
47
|
-
except IndexError:
|
|
47
|
+
except (IndexError, TypeError):
|
|
48
48
|
return default
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|