atk-common 1.30.0__py3-none-any.whl → 1.31.0__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.
- atk_common/__init__.py +5 -1
- atk_common/datetime_utils.py +48 -1
- atk_common/file_utils.py +4 -0
- {atk_common-1.30.0.dist-info → atk_common-1.31.0.dist-info}/METADATA +1 -1
- {atk_common-1.30.0.dist-info → atk_common-1.31.0.dist-info}/RECORD +8 -7
- {atk_common-1.30.0.dist-info → atk_common-1.31.0.dist-info}/WHEEL +0 -0
- {atk_common-1.30.0.dist-info → atk_common-1.31.0.dist-info}/licenses/license.txt +0 -0
- {atk_common-1.30.0.dist-info → atk_common-1.31.0.dist-info}/top_level.txt +0 -0
atk_common/__init__.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# __init__.py
|
2
|
-
from atk_common.datetime_utils import get_utc_date_time, seconds_to_utc_timestamp, get_utc_date_from_iso
|
2
|
+
from atk_common.datetime_utils import get_utc_date_time, seconds_to_utc_timestamp, get_utc_date_from_iso, adjust_millisescond, convert_to_utc
|
3
3
|
from atk_common.db_utils import sql, sql_with_record, convert_none_to_null, date_time_utc_column
|
4
4
|
from atk_common.env_utils import get_env_value
|
5
5
|
from atk_common.error_utils import get_message, create_error_log, get_error_entity, handle_error, get_response_error, get_error_type
|
6
6
|
from atk_common.http_utils import is_http_status_ok, is_http_status_internal, get_test_response
|
7
|
+
from atk_common.file_utils import get_image_file_type
|
7
8
|
from atk_common.log_utils import add_log_item, add_log_item_http
|
8
9
|
from atk_common.rabbitmq_consumer import RabbitMQConsumer
|
9
10
|
from atk_common.response_utils import create_response, is_response_ok
|
@@ -13,6 +14,8 @@ __all__ = [
|
|
13
14
|
'get_utc_date_time',
|
14
15
|
'seconds_to_utc_timestamp',
|
15
16
|
'get_utc_date_from_iso',
|
17
|
+
'adjust_millisescond',
|
18
|
+
'convert_to_utc',
|
16
19
|
'sql',
|
17
20
|
'sql_with_record',
|
18
21
|
'convert_none_to_null',
|
@@ -27,6 +30,7 @@ __all__ = [
|
|
27
30
|
'is_http_status_ok',
|
28
31
|
'is_http_status_internal',
|
29
32
|
'get_test_response',
|
33
|
+
'get_image_file_type',
|
30
34
|
'add_log_item',
|
31
35
|
'add_log_item_http',
|
32
36
|
'RabbitMQConsumer',
|
atk_common/datetime_utils.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
from datetime import datetime, timezone
|
1
|
+
from datetime import datetime, timezone, timedelta
|
2
|
+
from zoneinfo import ZoneInfo
|
2
3
|
|
3
4
|
def get_utc_date_time():
|
4
5
|
return str(datetime.now(timezone.utc))
|
@@ -10,3 +11,49 @@ def get_utc_date_from_iso(date_time):
|
|
10
11
|
dt = datetime.fromisoformat(date_time)
|
11
12
|
dt_utc = dt.astimezone(timezone.utc)
|
12
13
|
return str(dt_utc.date())
|
14
|
+
|
15
|
+
def adjust_millisescond(dt_str):
|
16
|
+
if '.' in dt_str:
|
17
|
+
dt_part, frac = dt_str.split('.')
|
18
|
+
frac = frac[:6] # keep only the first 6 digits
|
19
|
+
dt_str_clean = f"{dt_part}.{frac}"
|
20
|
+
return dt_str_clean
|
21
|
+
else:
|
22
|
+
dt_str_clean = dt_str
|
23
|
+
return dt_str_clean
|
24
|
+
|
25
|
+
# Original datetime string, handles:
|
26
|
+
# dt_str = '2023-02-01T14:13:08.653133+01:00'
|
27
|
+
# dt_str = '2023-02-01T14:13:08.653133 01:00'
|
28
|
+
# dt_str = '2024-01-03T08:13:52.705474147'
|
29
|
+
def convert_to_utc(dt_str):
|
30
|
+
# Split datetime and offset
|
31
|
+
if '+' in dt_str:
|
32
|
+
parts = dt_str.split('+')
|
33
|
+
else:
|
34
|
+
parts = dt_str.split(' ')
|
35
|
+
if len(parts) == 2:
|
36
|
+
dt_part, offset_part = parts
|
37
|
+
else:
|
38
|
+
dt_part = parts[0]
|
39
|
+
offset_part = None # or set a default if needed
|
40
|
+
|
41
|
+
dt_part = adjust_millisescond(dt_part)
|
42
|
+
dt_naive = datetime.fromisoformat(dt_part)
|
43
|
+
|
44
|
+
if offset_part is None:
|
45
|
+
dt_aware = dt_naive.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
46
|
+
dt_utc = dt_aware.astimezone(ZoneInfo("UTC"))
|
47
|
+
return dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
48
|
+
else:
|
49
|
+
# Create a timezone object using the offset
|
50
|
+
hours_offset = int(offset_part.split(':')[0])
|
51
|
+
minutes_offset = int(offset_part.split(':')[1])
|
52
|
+
tzinfo = timezone(timedelta(hours=hours_offset, minutes=minutes_offset))
|
53
|
+
|
54
|
+
# Assign the timezone to the datetime
|
55
|
+
dt_with_tz = dt_naive.replace(tzinfo=tzinfo)
|
56
|
+
|
57
|
+
# Convert to UTC
|
58
|
+
dt_utc =dt_with_tz.astimezone(timezone.utc)
|
59
|
+
return dt_utc.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
atk_common/file_utils.py
ADDED
@@ -1,9 +1,10 @@
|
|
1
|
-
atk_common/__init__.py,sha256=
|
2
|
-
atk_common/datetime_utils.py,sha256=
|
1
|
+
atk_common/__init__.py,sha256=OuZhyf-yBBSnpTnwg5Mr8OOwAXFvv3zr4_B-9w5hdhk,1531
|
2
|
+
atk_common/datetime_utils.py,sha256=3OIzPCt7W3vA4HvjnlfV0KJjRAjXuTaJ_QOa-cCMNns,2044
|
3
3
|
atk_common/db_utils.py,sha256=odUtXcS7Mumw5eGyVyVimL_U_lP7TqMX9v8nWO5nMvg,902
|
4
4
|
atk_common/docker_utils.py,sha256=nkUhp2OhwJsm41JDujHDY-JxQfdDjy91duprH59Esfk,2084
|
5
5
|
atk_common/env_utils.py,sha256=66v-S0vlkJNaun6ay1XcOGRtYJb4Ce4odJsWxuaHsQc,373
|
6
6
|
atk_common/error_utils.py,sha256=7SN-Jz3i2MGIPqsexnjgbZg5poMnALLEiCJQ4za5im4,2398
|
7
|
+
atk_common/file_utils.py,sha256=UDwcRquO9IrqRrlUM0t-_g4R1-FKt8ZqQinSEqXOAk8,112
|
7
8
|
atk_common/http_utils.py,sha256=M1Qz2Cus3Ek8nUOqraT-30GKSj7nkAvJx2f7rnpX5Pk,656
|
8
9
|
atk_common/log_utils.py,sha256=k7VaknmSGvHQV6-eznltNUa3BOAywjFHkhVzDT1P0Hs,496
|
9
10
|
atk_common/mq_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -39,7 +40,7 @@ atk_common/enums/sensor_type_enum.py,sha256=UBa3LPyGTKgEJV578CqFlwXjnlXqVlybrvzd
|
|
39
40
|
atk_common/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
|
40
41
|
atk_common/enums/speed_control_status_type_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
|
41
42
|
atk_common/enums/violation_type_enum.py,sha256=01qTHOj-O8bOc-nwIHVnxLosm4cusD_YuqXM3ZsiRRk,86
|
42
|
-
atk_common-1.
|
43
|
+
atk_common-1.31.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
|
43
44
|
atk_package/__init__.py,sha256=EceDa352WFHTdC_LxYANXf_TS9pGzK3MCx87bwAKTvg,811
|
44
45
|
atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
|
45
46
|
atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
|
@@ -52,7 +53,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
|
|
52
53
|
atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
|
53
54
|
atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
|
54
55
|
shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
|
-
atk_common-1.
|
56
|
-
atk_common-1.
|
57
|
-
atk_common-1.
|
58
|
-
atk_common-1.
|
56
|
+
atk_common-1.31.0.dist-info/METADATA,sha256=FMJ_09qDYlnMza2vcWYklVTtfRqv45bLHtGejSI9Kvk,1464
|
57
|
+
atk_common-1.31.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
58
|
+
atk_common-1.31.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
|
59
|
+
atk_common-1.31.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|