none-shall-parse 0.6.2__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.
- none_shall_parse/__init__.py +139 -0
- none_shall_parse/dates.py +801 -0
- none_shall_parse/imeis.py +211 -0
- none_shall_parse/lists.py +48 -0
- none_shall_parse/parse.py +196 -0
- none_shall_parse/strings.py +267 -0
- none_shall_parse/types.py +41 -0
- none_shall_parse-0.6.2.dist-info/METADATA +66 -0
- none_shall_parse-0.6.2.dist-info/RECORD +10 -0
- none_shall_parse-0.6.2.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Trinity Shared Python utilities.
|
|
2
|
+
|
|
3
|
+
A collection of shared utilities for Trinity projects.
|
|
4
|
+
|
|
5
|
+
Originally intended to be parsing utilities, this grew to include
|
|
6
|
+
other useful functions.
|
|
7
|
+
|
|
8
|
+
Named for its author Andries Niemandt - whose surname loosely
|
|
9
|
+
translates to "none". Combined this with our parsing intentions
|
|
10
|
+
to create a name which nods to the Black Knight in Monty Python's Holy Grail.
|
|
11
|
+
https://www.youtube.com/watch?v=zKhEw7nD9C4
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
from .dates import (
|
|
15
|
+
DateUtilsError, assert_week_start_date_is_valid,
|
|
16
|
+
assert_month_start_date_is_valid,
|
|
17
|
+
get_datetime_now, za_now, utc_now,
|
|
18
|
+
za_ordinal_year_day_now,
|
|
19
|
+
za_ordinal_year_day_tomorrow, utc_epoch_start,
|
|
20
|
+
now_offset_n_minutes, now_offset_n_hours,
|
|
21
|
+
now_offset_n_days, now_offset_n_months, get_datetime_tomorrow,
|
|
22
|
+
get_datetime_yesterday,
|
|
23
|
+
get_utc_datetime_offset_n_days,
|
|
24
|
+
epoch_to_datetime, epoch_to_utc_datetime,
|
|
25
|
+
is_office_hours_in_timezone,
|
|
26
|
+
get_datetime_from_ordinal_and_sentinel,
|
|
27
|
+
day_span, week_span, month_span, arb_span,
|
|
28
|
+
calendar_month_start_end, unix_timestamp,
|
|
29
|
+
sentinel_date_and_ordinal_to_date,
|
|
30
|
+
seconds_to_end_of_month, standard_tz_timestring,
|
|
31
|
+
get_notice_end_date, dt_to_za_time_string,
|
|
32
|
+
months_ago_selection, is_aware, make_aware,
|
|
33
|
+
unaware_to_utc_aware, timer_decorator, ZA_TZ,
|
|
34
|
+
UTC_TZ, keys_for_span_func,
|
|
35
|
+
)
|
|
36
|
+
from .imeis import (
|
|
37
|
+
get_luhn_digit,
|
|
38
|
+
is_valid_luhn,
|
|
39
|
+
is_valid_imei,
|
|
40
|
+
normalize_imei,
|
|
41
|
+
get_tac_from_imei,
|
|
42
|
+
decrement_imei,
|
|
43
|
+
increment_imei,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
from .lists import (
|
|
47
|
+
flatten,
|
|
48
|
+
safe_list_get,
|
|
49
|
+
)
|
|
50
|
+
from .parse import (
|
|
51
|
+
str_to_bool,
|
|
52
|
+
is_true,
|
|
53
|
+
is_false,
|
|
54
|
+
str_to_strs_list,
|
|
55
|
+
int_to_bool,
|
|
56
|
+
int_or_none,
|
|
57
|
+
choices_code_to_string,
|
|
58
|
+
choices_string_to_code,
|
|
59
|
+
none_or_empty,
|
|
60
|
+
)
|
|
61
|
+
from .strings import (
|
|
62
|
+
slugify,
|
|
63
|
+
random_16,
|
|
64
|
+
to_human_string,
|
|
65
|
+
is_quoted_string,
|
|
66
|
+
is_numeric_string,
|
|
67
|
+
custom_slug,
|
|
68
|
+
b64_encode,
|
|
69
|
+
b64_decode,
|
|
70
|
+
calc_hash,
|
|
71
|
+
generate_random_password,
|
|
72
|
+
)
|
|
73
|
+
from .types import (
|
|
74
|
+
StringLike,
|
|
75
|
+
ChoicesType,
|
|
76
|
+
DateTimeLike,
|
|
77
|
+
DateLike,
|
|
78
|
+
DateTimeOrDateLike,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
__author__ = "Andries Niemandt, Jan Badenhorst"
|
|
82
|
+
__email__ = "andries.niemandt@trintel.co.za, jan@trintel.co.za"
|
|
83
|
+
__license__ = "MIT"
|
|
84
|
+
|
|
85
|
+
__all__ = (
|
|
86
|
+
"DateUtilsError", "assert_week_start_date_is_valid",
|
|
87
|
+
"assert_month_start_date_is_valid",
|
|
88
|
+
"get_datetime_now", "za_now", "utc_now",
|
|
89
|
+
"za_ordinal_year_day_now",
|
|
90
|
+
"za_ordinal_year_day_tomorrow", "utc_epoch_start",
|
|
91
|
+
"now_offset_n_minutes", "now_offset_n_hours",
|
|
92
|
+
"now_offset_n_days", "now_offset_n_months", "get_datetime_tomorrow",
|
|
93
|
+
"get_datetime_yesterday",
|
|
94
|
+
"get_utc_datetime_offset_n_days",
|
|
95
|
+
"epoch_to_datetime", "epoch_to_utc_datetime",
|
|
96
|
+
"is_office_hours_in_timezone",
|
|
97
|
+
"get_datetime_from_ordinal_and_sentinel",
|
|
98
|
+
"day_span", "week_span", "month_span", "arb_span",
|
|
99
|
+
"calendar_month_start_end", "unix_timestamp",
|
|
100
|
+
"sentinel_date_and_ordinal_to_date",
|
|
101
|
+
"seconds_to_end_of_month", "standard_tz_timestring",
|
|
102
|
+
"get_notice_end_date", "dt_to_za_time_string",
|
|
103
|
+
"months_ago_selection", "is_aware", "make_aware",
|
|
104
|
+
"unaware_to_utc_aware", "timer_decorator", "ZA_TZ",
|
|
105
|
+
"UTC_TZ", "keys_for_span_func",
|
|
106
|
+
"get_luhn_digit",
|
|
107
|
+
"is_valid_luhn",
|
|
108
|
+
"is_valid_imei",
|
|
109
|
+
"normalize_imei",
|
|
110
|
+
"get_tac_from_imei",
|
|
111
|
+
"decrement_imei",
|
|
112
|
+
"increment_imei",
|
|
113
|
+
"flatten",
|
|
114
|
+
"safe_list_get",
|
|
115
|
+
"str_to_bool",
|
|
116
|
+
"is_true",
|
|
117
|
+
"is_false",
|
|
118
|
+
"str_to_strs_list",
|
|
119
|
+
"int_to_bool",
|
|
120
|
+
"int_or_none",
|
|
121
|
+
"choices_code_to_string",
|
|
122
|
+
"choices_string_to_code",
|
|
123
|
+
"none_or_empty",
|
|
124
|
+
"slugify",
|
|
125
|
+
"random_16",
|
|
126
|
+
"to_human_string",
|
|
127
|
+
"is_quoted_string",
|
|
128
|
+
"is_numeric_string",
|
|
129
|
+
"custom_slug",
|
|
130
|
+
"b64_encode",
|
|
131
|
+
"b64_decode",
|
|
132
|
+
"calc_hash",
|
|
133
|
+
"generate_random_password",
|
|
134
|
+
"StringLike",
|
|
135
|
+
"ChoicesType",
|
|
136
|
+
"DateTimeLike",
|
|
137
|
+
"DateLike",
|
|
138
|
+
"DateTimeOrDateLike",
|
|
139
|
+
)
|