python-sdk-remote 0.0.168__tar.gz → 0.0.170__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.
Potentially problematic release.
This version of python-sdk-remote might be problematic. Click here for more details.
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/PKG-INFO +1 -1
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/datetime_range.py +2 -2
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/http_response.py +20 -7
- python_sdk_remote-0.0.170/python_sdk_remote/src/is_test_data.py +4 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/mini_logger.py +12 -8
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_object.py +22 -12
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_request.py +2 -2
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_request_old.py +2 -2
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/utilities.py +26 -23
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/PKG-INFO +1 -1
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/setup.py +1 -1
- python_sdk_remote-0.0.168/python_sdk_remote/src/is_test_data.py +0 -4
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/README.md +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/pyproject.toml +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/__init__.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/constants.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/constants_src_mini_logger_and_logger.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/exceptions.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/generic_crud.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/item.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_obfuscation.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_objects.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_objects_local.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_objects_remote.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/unified_json.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/valid_json_versions.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/validate_environment.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/version.py +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/SOURCES.txt +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/requires.txt +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/top_level.txt +0 -0
- {python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/setup.cfg +0 -0
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/datetime_range.py
RENAMED
|
@@ -5,7 +5,7 @@ This module provides a DatetimeRange class with start_datetime and end_datetime
|
|
|
5
5
|
as requested in the TODO.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from datetime import datetime
|
|
8
|
+
from datetime import datetime, timedelta
|
|
9
9
|
from typing import Optional
|
|
10
10
|
|
|
11
11
|
from .mini_logger import MiniLogger as logger
|
|
@@ -72,7 +72,7 @@ class DatetimeRange:
|
|
|
72
72
|
logger.end(object={"overlaps_result": result})
|
|
73
73
|
return result
|
|
74
74
|
|
|
75
|
-
def duration(self) ->
|
|
75
|
+
def duration(self) -> timedelta:
|
|
76
76
|
"""
|
|
77
77
|
Calculate the duration of the datetime range.
|
|
78
78
|
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/http_response.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import traceback
|
|
2
2
|
from functools import wraps
|
|
3
3
|
from http import HTTPStatus
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any, Optional, overload
|
|
5
5
|
|
|
6
6
|
from .mini_logger import MiniLogger as logger
|
|
7
7
|
from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
|
|
@@ -117,16 +117,29 @@ def handler_decorator(logger):
|
|
|
117
117
|
return decorator
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
@overload
|
|
121
|
+
def create_authorization_http_headers(user_jwt: str, context: Optional[dict] = None) -> dict:
|
|
122
|
+
...
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@overload
|
|
126
|
+
def create_authorization_http_headers(*, context: dict) -> dict:
|
|
127
|
+
...
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def create_authorization_http_headers(user_jwt: Optional[str] = None, context: Optional[dict] = None) -> dict:
|
|
121
131
|
"""
|
|
122
132
|
Create HTTP headers with authorization token.
|
|
123
|
-
|
|
133
|
+
|
|
134
|
+
Authorization is mandatory: either user_jwt or context must be provided.
|
|
135
|
+
The overloads above make a call with neither a type error, and a call with
|
|
136
|
+
neither still raises ValueError at runtime.
|
|
124
137
|
Auto-detects user_jwt from context if not provided directly.
|
|
125
|
-
|
|
138
|
+
|
|
126
139
|
Args:
|
|
127
140
|
user_jwt: JWT token string. If None, will attempt to extract from context
|
|
128
141
|
context: AWS Lambda context or dict containing authorization info
|
|
129
|
-
|
|
142
|
+
|
|
130
143
|
Returns:
|
|
131
144
|
dict: HTTP headers with authorization
|
|
132
145
|
|
|
@@ -151,7 +164,7 @@ def create_authorization_http_headers(user_jwt: str = None, context: dict = None
|
|
|
151
164
|
return authorization_http_headers
|
|
152
165
|
|
|
153
166
|
|
|
154
|
-
def _extract_jwt_from_context(context: dict) -> str:
|
|
167
|
+
def _extract_jwt_from_context(context: dict) -> Optional[str]:
|
|
155
168
|
"""
|
|
156
169
|
Extract JWT token from various context formats.
|
|
157
170
|
|
|
@@ -159,7 +172,7 @@ def _extract_jwt_from_context(context: dict) -> str:
|
|
|
159
172
|
context: Context dictionary that may contain JWT information
|
|
160
173
|
|
|
161
174
|
Returns:
|
|
162
|
-
str: Extracted JWT token or None if not found
|
|
175
|
+
Optional[str]: Extracted JWT token or None if not found
|
|
163
176
|
"""
|
|
164
177
|
logger.start(object={"context_keys": list(context.keys()) if isinstance(context, dict) else "not_dict"})
|
|
165
178
|
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/mini_logger.py
RENAMED
|
@@ -3,6 +3,8 @@ import os
|
|
|
3
3
|
import sys
|
|
4
4
|
# from enum import Enum
|
|
5
5
|
import inspect
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
6
8
|
from .constants_src_mini_logger_and_logger import LogMessageSeverity, StartEndEnum
|
|
7
9
|
|
|
8
10
|
# Logger configuration constants
|
|
@@ -50,7 +52,8 @@ class MiniLogger:
|
|
|
50
52
|
_is_write_to_sql = False # Should be always False in MiniLogger
|
|
51
53
|
|
|
52
54
|
@staticmethod
|
|
53
|
-
def _log(level: LogMessageSeverity, start_or_end: StartEndEnum = None,
|
|
55
|
+
def _log(level: LogMessageSeverity, start_or_end: Optional[StartEndEnum] = None,
|
|
56
|
+
log_message: Optional[str] = None, **kwargs):
|
|
54
57
|
"""
|
|
55
58
|
Private unified method for all log operations.
|
|
56
59
|
|
|
@@ -81,7 +84,7 @@ class MiniLogger:
|
|
|
81
84
|
method(f"Function: {function}, Line: {line}; {action_name} - {log_message} - {object}")
|
|
82
85
|
|
|
83
86
|
@staticmethod
|
|
84
|
-
def start(log_message: str = None, **kwargs):
|
|
87
|
+
def start(log_message: Optional[str] = None, **kwargs):
|
|
85
88
|
"""
|
|
86
89
|
Log method entry with DEBUG level.
|
|
87
90
|
|
|
@@ -91,7 +94,7 @@ class MiniLogger:
|
|
|
91
94
|
MiniLogger._log(LogMessageSeverity.DEBUG, StartEndEnum.START, log_message, **kwargs)
|
|
92
95
|
|
|
93
96
|
@staticmethod
|
|
94
|
-
def end(log_message: str = None, **kwargs):
|
|
97
|
+
def end(log_message: Optional[str] = None, **kwargs):
|
|
95
98
|
"""
|
|
96
99
|
Log method exit with DEBUG level.
|
|
97
100
|
|
|
@@ -101,7 +104,7 @@ class MiniLogger:
|
|
|
101
104
|
MiniLogger._log(LogMessageSeverity.DEBUG, StartEndEnum.END, log_message, **kwargs)
|
|
102
105
|
|
|
103
106
|
@staticmethod
|
|
104
|
-
def debug(log_message: str = None, **kwargs):
|
|
107
|
+
def debug(log_message: Optional[str] = None, **kwargs):
|
|
105
108
|
"""
|
|
106
109
|
Log debug message.
|
|
107
110
|
|
|
@@ -111,7 +114,7 @@ class MiniLogger:
|
|
|
111
114
|
MiniLogger._log(LogMessageSeverity.DEBUG, log_message=log_message, **kwargs)
|
|
112
115
|
|
|
113
116
|
@staticmethod
|
|
114
|
-
def info(log_message: str = None, **kwargs):
|
|
117
|
+
def info(log_message: Optional[str] = None, **kwargs):
|
|
115
118
|
"""
|
|
116
119
|
Log informational message.
|
|
117
120
|
|
|
@@ -121,7 +124,7 @@ class MiniLogger:
|
|
|
121
124
|
MiniLogger._log(LogMessageSeverity.INFORMATION, log_message=log_message, **kwargs)
|
|
122
125
|
|
|
123
126
|
@staticmethod
|
|
124
|
-
def warning(log_message: str = None, **kwargs):
|
|
127
|
+
def warning(log_message: Optional[str] = None, **kwargs):
|
|
125
128
|
"""
|
|
126
129
|
Log warning message with source information.
|
|
127
130
|
|
|
@@ -131,7 +134,7 @@ class MiniLogger:
|
|
|
131
134
|
MiniLogger._log(LogMessageSeverity.WARNING, log_message=log_message, **kwargs)
|
|
132
135
|
|
|
133
136
|
@staticmethod
|
|
134
|
-
def error(log_message: str = None, **kwargs):
|
|
137
|
+
def error(log_message: Optional[str] = None, **kwargs):
|
|
135
138
|
"""
|
|
136
139
|
Log error message.
|
|
137
140
|
|
|
@@ -141,7 +144,7 @@ class MiniLogger:
|
|
|
141
144
|
MiniLogger._log(LogMessageSeverity.ERROR, log_message=log_message, **kwargs)
|
|
142
145
|
|
|
143
146
|
@staticmethod
|
|
144
|
-
def exception(
|
|
147
|
+
def exception(log_message: Optional[str] = None, **kwargs):
|
|
145
148
|
"""
|
|
146
149
|
Print a log error message with the current time.
|
|
147
150
|
|
|
@@ -149,6 +152,7 @@ class MiniLogger:
|
|
|
149
152
|
log_message (str): The message to be printed.
|
|
150
153
|
"""
|
|
151
154
|
object = kwargs.get("object")
|
|
155
|
+
exception: Optional[Exception]
|
|
152
156
|
if isinstance(object, Exception):
|
|
153
157
|
exception = object
|
|
154
158
|
elif isinstance(object, dict):
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from abc import ABC # , abstractmethod
|
|
3
3
|
from datetime import datetime
|
|
4
|
+
from typing import Any, Optional
|
|
4
5
|
|
|
5
6
|
from .mini_logger import MiniLogger as logger
|
|
6
7
|
|
|
@@ -20,12 +21,12 @@ Usage: Extend this class for all business entities to ensure consistent behavior
|
|
|
20
21
|
"""
|
|
21
22
|
class OurObject(ABC):
|
|
22
23
|
|
|
23
|
-
entity_name = None
|
|
24
|
-
id = None
|
|
24
|
+
entity_name: Optional[str] = None
|
|
25
|
+
id: Optional[int] = None
|
|
25
26
|
|
|
26
27
|
# Needed by print_our_object_with_id()
|
|
27
|
-
name = None
|
|
28
|
-
number = None
|
|
28
|
+
name: Optional[str] = None
|
|
29
|
+
number: Optional[int] = None
|
|
29
30
|
|
|
30
31
|
fields = {
|
|
31
32
|
# Needed by print_our_object_with_id()
|
|
@@ -33,7 +34,8 @@ class OurObject(ABC):
|
|
|
33
34
|
"number"
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
def __init__(self, entity_name: str = None,
|
|
37
|
+
def __init__(self, entity_name: Optional[str] = None,
|
|
38
|
+
id: Optional[int] = None, **kwargs: Any):
|
|
37
39
|
INIT_METHOD_NAME = '__init__'
|
|
38
40
|
logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
|
|
39
41
|
self.set_entity_name(entity_name)
|
|
@@ -59,33 +61,41 @@ class OurObject(ABC):
|
|
|
59
61
|
else:
|
|
60
62
|
setattr(self, field, None)
|
|
61
63
|
|
|
62
|
-
def set_entity_name(self, entity_name: str) -> None:
|
|
64
|
+
def set_entity_name(self, entity_name: Optional[str]) -> None:
|
|
63
65
|
self.entity_name = entity_name
|
|
64
66
|
|
|
65
67
|
def get_id_column_name(self) -> str:
|
|
66
68
|
"""Returns the name of the column that is used as the id of the object"""
|
|
67
|
-
|
|
69
|
+
# BEHAVIOUR NOTE: was `self.entity_name + "_id"`, which raised
|
|
70
|
+
# TypeError on the default entity_name of None. Same fix as in
|
|
71
|
+
# our-object-local, so the two copies stay identical.
|
|
72
|
+
id_column_name = str(self.entity_name) + "_id"
|
|
68
73
|
return id_column_name
|
|
69
74
|
|
|
70
|
-
def set_id(self, id: int) -> None:
|
|
75
|
+
def set_id(self, id: Optional[int]) -> None:
|
|
71
76
|
self.id = id
|
|
72
77
|
|
|
73
|
-
def get_id(self) -> int:
|
|
78
|
+
def get_id(self) -> Optional[int]:
|
|
74
79
|
return self.id
|
|
75
80
|
|
|
76
81
|
# Commented so we can use it in database foreach()
|
|
77
82
|
# @abstractmethod
|
|
78
|
-
def get_name(self) -> str:
|
|
83
|
+
def get_name(self) -> Optional[str]:
|
|
79
84
|
"""Returns the name of the object"""
|
|
80
85
|
# raise NotImplementedError(
|
|
81
86
|
# "Subclasses must implement the 'get_name' method.")
|
|
87
|
+
return None
|
|
82
88
|
|
|
83
|
-
def get(self, attr_name: str) ->
|
|
89
|
+
def get(self, attr_name: str) -> Any:
|
|
84
90
|
"""Returns the value of the attribute with the given name"""
|
|
85
91
|
GET_METHOD_NAME = 'get'
|
|
86
92
|
logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
|
|
93
|
+
# BEHAVIOUR NOTE: the getattr default of None was already there, but
|
|
94
|
+
# .get() was then called on it unconditionally, so any instance built
|
|
95
|
+
# without __init__ - from_json does exactly that - raised
|
|
96
|
+
# AttributeError. Same guard as in our-object-local.
|
|
87
97
|
arguments = getattr(self, 'kwargs', None)
|
|
88
|
-
value = arguments.get(attr_name, None)
|
|
98
|
+
value = arguments.get(attr_name, None) if arguments else None
|
|
89
99
|
logger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
|
|
90
100
|
return value
|
|
91
101
|
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_request.py
RENAMED
|
@@ -76,7 +76,7 @@ class OurRequest:
|
|
|
76
76
|
|
|
77
77
|
logger.start(method_name, object=request_details)
|
|
78
78
|
|
|
79
|
-
last_exception = None
|
|
79
|
+
last_exception: Optional[Exception] = None
|
|
80
80
|
|
|
81
81
|
for attempt in range(retries + 1):
|
|
82
82
|
try:
|
|
@@ -222,7 +222,7 @@ class OurRequest:
|
|
|
222
222
|
|
|
223
223
|
logger.start(method_name, object=request_details)
|
|
224
224
|
|
|
225
|
-
last_exception = None
|
|
225
|
+
last_exception: Optional[Exception] = None
|
|
226
226
|
|
|
227
227
|
for attempt in range(retries + 1):
|
|
228
228
|
try:
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_request_old.py
RENAMED
|
@@ -65,7 +65,7 @@ class OurRequest:
|
|
|
65
65
|
|
|
66
66
|
logger.start(method_name, object=request_details)
|
|
67
67
|
|
|
68
|
-
last_exception = None
|
|
68
|
+
last_exception: Optional[Exception] = None
|
|
69
69
|
|
|
70
70
|
for attempt in range(retries + 1):
|
|
71
71
|
try:
|
|
@@ -210,7 +210,7 @@ class OurRequest:
|
|
|
210
210
|
|
|
211
211
|
logger.start(method_name, object=request_details)
|
|
212
212
|
|
|
213
|
-
last_exception = None
|
|
213
|
+
last_exception: Optional[Exception] = None
|
|
214
214
|
|
|
215
215
|
for attempt in range(retries + 1):
|
|
216
216
|
try:
|
|
@@ -5,7 +5,7 @@ import random
|
|
|
5
5
|
import re
|
|
6
6
|
from datetime import date, datetime, time, timedelta, timezone
|
|
7
7
|
from functools import lru_cache
|
|
8
|
-
from typing import Union
|
|
8
|
+
from typing import Optional, Tuple, Union
|
|
9
9
|
from urllib.parse import urlparse
|
|
10
10
|
|
|
11
11
|
import jwt
|
|
@@ -47,9 +47,9 @@ def append_if_not_exist(lst: list, item: object) -> None:
|
|
|
47
47
|
lst.append(item)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def to_dict(data:
|
|
50
|
+
def to_dict(data: Optional[Union[str, bytes, dict]]) -> dict:
|
|
51
51
|
if data is None:
|
|
52
|
-
to_dict_result = {}
|
|
52
|
+
to_dict_result: dict = {}
|
|
53
53
|
return to_dict_result
|
|
54
54
|
if isinstance(data, dict):
|
|
55
55
|
return data
|
|
@@ -57,7 +57,7 @@ def to_dict(data: json or dict or None) -> dict:
|
|
|
57
57
|
return to_dict_result
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def to_json(data:
|
|
60
|
+
def to_json(data: Optional[Union[str, dict]]) -> str:
|
|
61
61
|
if data is None:
|
|
62
62
|
data = {}
|
|
63
63
|
if isinstance(data, dict):
|
|
@@ -174,7 +174,7 @@ def is_valid_date_range(date_range: tuple) -> bool:
|
|
|
174
174
|
return True
|
|
175
175
|
|
|
176
176
|
|
|
177
|
-
def is_valid_datetime_range(datetime_range:
|
|
177
|
+
def is_valid_datetime_range(datetime_range: Tuple[datetime, datetime]) -> bool:
|
|
178
178
|
"""
|
|
179
179
|
Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
|
|
180
180
|
"""
|
|
@@ -230,7 +230,7 @@ def is_list_of_dicts(obj: object) -> bool:
|
|
|
230
230
|
"is_list_of_dicts_result": is_list_of_dicts_result})
|
|
231
231
|
return is_list_of_dicts_result
|
|
232
232
|
except Exception as exception:
|
|
233
|
-
logger.exception(object=exception)
|
|
233
|
+
logger.exception("is_list_of_dicts failed", object=exception)
|
|
234
234
|
logger.end()
|
|
235
235
|
raise
|
|
236
236
|
|
|
@@ -282,7 +282,7 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
|
|
|
282
282
|
return start_date <= check_date <= end_date
|
|
283
283
|
|
|
284
284
|
|
|
285
|
-
def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range:
|
|
285
|
+
def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: Tuple[datetime, datetime]) -> bool:
|
|
286
286
|
"""
|
|
287
287
|
Check if the given datetime is within the specified datetime range.
|
|
288
288
|
|
|
@@ -306,7 +306,8 @@ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (dat
|
|
|
306
306
|
return is_datetime_in_datetime_range_result
|
|
307
307
|
|
|
308
308
|
|
|
309
|
-
|
|
309
|
+
# TODO shall we rename the function _file_ to _key_value_file_
|
|
310
|
+
def add_to_file_if_not_existed(file: str, key: str, value: Optional[str]) -> None:
|
|
310
311
|
logger.start(object={"file": file, "key": key, "value": value})
|
|
311
312
|
if not os.path.exists(file):
|
|
312
313
|
with open(file, "w") as f:
|
|
@@ -320,7 +321,7 @@ def add_to_file_if_not_existed(file: str, key: str, value: str) -> None:
|
|
|
320
321
|
logger.end()
|
|
321
322
|
|
|
322
323
|
|
|
323
|
-
def update_dot_env_example(key: str, value: str):
|
|
324
|
+
def update_dot_env_example(key: str, value: Optional[str]):
|
|
324
325
|
# Avoid recursion by checking environment directly
|
|
325
326
|
env_name = os.getenv("ENVIRONMENT_NAME", "").lower()
|
|
326
327
|
if env_name == "play1":
|
|
@@ -332,8 +333,9 @@ def update_dot_env_example(key: str, value: str):
|
|
|
332
333
|
# TODO If running in a lower environment(i.e. local1, play1) update .env.example with the key without the value
|
|
333
334
|
# TODO If running in a lower environment(i.e. local1, play1) and the key do not exist look for it in the Team Member Personal Repo and copy both the key and value to the repo .env.{environment_name} file
|
|
334
335
|
# TODO move all our_*_env() to our_env.py
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
# TODO shall we rename optional_prefix to prefix?
|
|
337
|
+
def our_get_env(key: str, default: Optional[str] = None, raise_if_not_found: bool = True,
|
|
338
|
+
raise_if_empty: bool = False, optional_prefix: Optional[str] = None) -> Optional[str]:
|
|
337
339
|
"""
|
|
338
340
|
Get environment variable with optional prefix fallback.
|
|
339
341
|
|
|
@@ -409,7 +411,7 @@ def our_delete_env(key: str, raise_if_not_found: bool = False) -> None:
|
|
|
409
411
|
|
|
410
412
|
|
|
411
413
|
def get_brand_name(raise_if_not_found: bool = True,
|
|
412
|
-
raise_if_empty: bool = False) -> str:
|
|
414
|
+
raise_if_empty: bool = False) -> Optional[str]:
|
|
413
415
|
get_brand_name_result = our_get_env("BRAND_NAME",
|
|
414
416
|
raise_if_not_found=raise_if_not_found,
|
|
415
417
|
raise_if_empty=raise_if_empty)
|
|
@@ -417,7 +419,7 @@ def get_brand_name(raise_if_not_found: bool = True,
|
|
|
417
419
|
|
|
418
420
|
|
|
419
421
|
def get_environment_name(raise_if_not_found: bool = True,
|
|
420
|
-
raise_if_empty: bool = False) -> str:
|
|
422
|
+
raise_if_empty: bool = False) -> Optional[str]:
|
|
421
423
|
environment_name = our_get_env("ENVIRONMENT_NAME",
|
|
422
424
|
raise_if_not_found=raise_if_not_found,
|
|
423
425
|
raise_if_empty=raise_if_empty)
|
|
@@ -430,7 +432,7 @@ def get_environment_name(raise_if_not_found: bool = True,
|
|
|
430
432
|
|
|
431
433
|
|
|
432
434
|
def get_product_user_identifier(raise_if_not_found: bool = True,
|
|
433
|
-
raise_if_empty: bool = False) -> str:
|
|
435
|
+
raise_if_empty: bool = False) -> Optional[str]:
|
|
434
436
|
get_product_user_identifier_result = our_get_env("PRODUCT_USER_IDENTIFIER",
|
|
435
437
|
raise_if_not_found=raise_if_not_found, # noqa E501
|
|
436
438
|
raise_if_empty=raise_if_empty) # noqa E501
|
|
@@ -438,7 +440,7 @@ def get_product_user_identifier(raise_if_not_found: bool = True,
|
|
|
438
440
|
|
|
439
441
|
|
|
440
442
|
def get_product_user_password(raise_if_not_found: bool = True,
|
|
441
|
-
raise_if_empty: bool = False) -> str:
|
|
443
|
+
raise_if_empty: bool = False) -> Optional[str]:
|
|
442
444
|
"""
|
|
443
445
|
Get product user password from environment variables.
|
|
444
446
|
|
|
@@ -460,26 +462,26 @@ def get_product_user_password(raise_if_not_found: bool = True,
|
|
|
460
462
|
|
|
461
463
|
# Database-specific functions - Consider moving to database package when it's created
|
|
462
464
|
def get_sql_hostname(raise_if_not_found: bool = True,
|
|
463
|
-
raise_if_empty: bool = False) -> str:
|
|
465
|
+
raise_if_empty: bool = False) -> Optional[str]:
|
|
464
466
|
get_sql_hostname_result = our_get_env("RDS_HOSTNAME",
|
|
465
467
|
raise_if_empty=raise_if_empty)
|
|
466
468
|
return get_sql_hostname_result
|
|
467
469
|
|
|
468
470
|
|
|
469
|
-
def get_sql_username(raise_if_empty: bool = False) -> str:
|
|
471
|
+
def get_sql_username(raise_if_empty: bool = False) -> Optional[str]:
|
|
470
472
|
get_sql_username_result = our_get_env("RDS_USERNAME",
|
|
471
473
|
raise_if_empty=raise_if_empty)
|
|
472
474
|
return get_sql_username_result
|
|
473
475
|
|
|
474
476
|
|
|
475
|
-
def get_sql_password(raise_if_empty: bool = False) -> str:
|
|
477
|
+
def get_sql_password(raise_if_empty: bool = False) -> Optional[str]:
|
|
476
478
|
get_sql_password_result = our_get_env("RDS_PASSWORD",
|
|
477
479
|
raise_if_empty=raise_if_empty)
|
|
478
480
|
return get_sql_password_result
|
|
479
481
|
|
|
480
482
|
|
|
481
483
|
# Dialog-specific function - Consider moving to dialog repo when it's created
|
|
482
|
-
def get_dialog_jwt_secret_key() -> str:
|
|
484
|
+
def get_dialog_jwt_secret_key() -> Optional[str]:
|
|
483
485
|
get_dialog_jwt_secret_key_result = our_get_env("DIALOG_JWT_SECRET_KEY", raise_if_empty=True)
|
|
484
486
|
return get_dialog_jwt_secret_key_result
|
|
485
487
|
|
|
@@ -517,7 +519,7 @@ def obfuscate_log_dict(log_dict: dict) -> dict:
|
|
|
517
519
|
environment_name = get_environment_name()
|
|
518
520
|
if environment_name == EnvironmentName.PLAY1.value:
|
|
519
521
|
return log_dict
|
|
520
|
-
obfuscated_log_dict = {}
|
|
522
|
+
obfuscated_log_dict: dict = {}
|
|
521
523
|
for key, value in log_dict.items():
|
|
522
524
|
if isinstance(value, dict):
|
|
523
525
|
obfuscated_log_dict[key] = obfuscate_log_dict(value)
|
|
@@ -542,7 +544,8 @@ def generate_otp():
|
|
|
542
544
|
return otp
|
|
543
545
|
|
|
544
546
|
|
|
545
|
-
def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT,
|
|
547
|
+
def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT,
|
|
548
|
+
tz: Optional[timezone] = None) -> str:
|
|
546
549
|
current_datetime_string = datetime.now(tz).strftime(datetime_format)
|
|
547
550
|
return current_datetime_string
|
|
548
551
|
|
|
@@ -557,7 +560,7 @@ def datetime_to_str(input_datetime: datetime, datetime_format: str = DEFAULT_DAT
|
|
|
557
560
|
return datetime_to_str_result
|
|
558
561
|
|
|
559
562
|
|
|
560
|
-
def to_datetime(value: datetime
|
|
563
|
+
def to_datetime(value: Union[datetime, str]) -> datetime:
|
|
561
564
|
"""Return a datetime unchanged, or parse an ISO-8601 string into one.
|
|
562
565
|
|
|
563
566
|
Complements datetime_from_str (which is str-only and uses a strptime format,
|
|
@@ -626,7 +629,7 @@ def camel_to_snake(camel_str: str) -> str:
|
|
|
626
629
|
# We have both deprecation_warning as method in Logger and as a standalone function
|
|
627
630
|
# We can call the deprecation_warning_function from the logger
|
|
628
631
|
@lru_cache(maxsize=64) # don't print the same warning multiple times
|
|
629
|
-
def deprecation_warning_function(old_name: str, new_name: str, start_date: date = None) -> None:
|
|
632
|
+
def deprecation_warning_function(old_name: str, new_name: str, start_date: Optional[date] = None) -> None:
|
|
630
633
|
if start_date and start_date < date.today():
|
|
631
634
|
return
|
|
632
635
|
warnings_message = f"Please use {new_name} instead of {old_name}."
|
|
@@ -7,7 +7,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
|
|
|
7
7
|
# python -m build needs pyproject.toml or setup.py
|
|
8
8
|
setuptools.setup(
|
|
9
9
|
name=PACKAGE_NAME,
|
|
10
|
-
version='0.0.
|
|
10
|
+
version='0.0.170', # https://pypi.org/project/python-sdk-remote#history
|
|
11
11
|
author="Circles",
|
|
12
12
|
author_email="info@circlez.ai",
|
|
13
13
|
description="PyPI Package for Circles Python SDK Local Python",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/generic_crud.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_obfuscation.py
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_objects.py
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_objects_local.py
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/our_objects_remote.py
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/unified_json.py
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote/src/valid_json_versions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/requires.txt
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.168 → python_sdk_remote-0.0.170}/python_sdk_remote.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|