python-sdk-remote 0.0.131__tar.gz → 0.0.133__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.131 → python_sdk_remote-0.0.133}/PKG-INFO +10 -2
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/pyproject.toml +1 -1
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/http_response.py +6 -10
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/item.py +0 -3
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/mini_logger.py +2 -5
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/our_object.py +19 -11
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/unified_json.py +0 -4
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/utilities.py +49 -30
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/PKG-INFO +10 -2
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/SOURCES.txt +0 -1
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/setup.py +1 -1
- python_sdk_remote-0.0.131/python_sdk_remote/src/temp.py +0 -18
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/README.md +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/__init__.py +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/constants.py +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/valid_json_versions.py +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/validate_environment.py +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/requires.txt +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/top_level.txt +0 -0
- {python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sdk-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.133
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -13,5 +13,13 @@ Requires-Dist: requests
|
|
|
13
13
|
Requires-Dist: python-dotenv
|
|
14
14
|
Requires-Dist: url-remote
|
|
15
15
|
Requires-Dist: pyjwt
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: summary
|
|
16
24
|
|
|
17
25
|
This is a package for sharing common functions used in different repositories
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "python-sdk-local"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.75" # https://pypi.org/project/python-sdk-local
|
|
8
8
|
description = "python-sdk-local Python Package"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/http_response.py
RENAMED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import traceback
|
|
2
|
-
from datetime import date
|
|
3
2
|
from functools import wraps
|
|
4
3
|
from http import HTTPStatus
|
|
5
4
|
from typing import Any
|
|
6
5
|
|
|
7
6
|
from .mini_logger import MiniLogger as logger
|
|
8
|
-
from .temp import deprecation_warning
|
|
9
7
|
from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
|
|
10
8
|
|
|
11
9
|
HEADERS_KEY = 'headers'
|
|
12
10
|
AUTHORIZATION_KEY = 'authorization'
|
|
13
11
|
AUTHORIZATION_PREFIX = 'Bearer '
|
|
14
12
|
|
|
15
|
-
# TODO: move date(2024, 6, 5) to constants and use it everywhere
|
|
16
|
-
deprecation_warning("http_response", "DELETE", date(2024, 6, 5))
|
|
17
|
-
|
|
18
13
|
|
|
19
14
|
# TODO Align those methods with typescript-sdk https://github.com/circles-zone/typescript-sdk-remote-typescript-package/blob/dev/typescript-sdk/src/utils/index.ts
|
|
20
15
|
# TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
|
|
21
16
|
|
|
22
|
-
# TODO
|
|
17
|
+
# TODO: add handler wrapper?
|
|
18
|
+
|
|
19
|
+
#TODO Shall we add the word body? i.e. get_body_payload_idct_from_event()
|
|
23
20
|
def get_payload_dict_from_event(event: dict) -> dict:
|
|
24
21
|
"""Extracts params sent with payload"""
|
|
25
22
|
return to_dict(event.get('body'))
|
|
@@ -80,9 +77,8 @@ def handler_decorator(logger):
|
|
|
80
77
|
|
|
81
78
|
# TODO: should we auto detect user_jwt if not provided?
|
|
82
79
|
def create_authorization_http_headers(user_jwt: str) -> dict:
|
|
83
|
-
# Not deprecated - we need it in remote packages
|
|
84
80
|
logger.start(object={"user_jwt": user_jwt})
|
|
85
|
-
#
|
|
81
|
+
#TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
|
|
86
82
|
authorization_http_headers = {
|
|
87
83
|
'Content-Type': 'application/json',
|
|
88
84
|
'Authorization': AUTHORIZATION_PREFIX + user_jwt,
|
|
@@ -118,8 +114,8 @@ def create_error_http_response(exception: Exception, status_code: HTTPStatus = H
|
|
|
118
114
|
error_http_response = {
|
|
119
115
|
"statusCode": status_code.value,
|
|
120
116
|
"headers": create_return_http_headers(),
|
|
121
|
-
"body": create_http_body({"error": str(exception),
|
|
122
|
-
|
|
117
|
+
"body": create_http_body({"error": str(exception)}),
|
|
118
|
+
"traceback": traceback.format_exc()
|
|
123
119
|
}
|
|
124
120
|
logger.end(object={"error_http_response": error_http_response})
|
|
125
121
|
return error_http_response
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
|
-
from datetime import date
|
|
3
2
|
|
|
4
3
|
from .our_object import OurObject
|
|
5
|
-
from .temp import deprecation_warning
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
class Item(OurObject):
|
|
9
7
|
def __init__(self, **kwargs):
|
|
10
|
-
deprecation_warning("item", "DELETE", date(2024, 6, 5))
|
|
11
8
|
super().__init__(**kwargs)
|
|
12
9
|
|
|
13
10
|
@abstractmethod
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/mini_logger.py
RENAMED
|
@@ -2,10 +2,7 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
import sys
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
# If not found, default to INFO
|
|
7
|
-
LOGGER_MINIMUM_SEVERITY = os.getenv("MINI_LOGGER_MINIMUM_SEVERITY",
|
|
8
|
-
os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO")).upper()
|
|
5
|
+
LOGGER_MINIMUM_SEVERITY = os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO").upper()
|
|
9
6
|
# logging expects NOTSET/DEBUG/INFO/WARNING/ERROR/FATAL/CRITICAL
|
|
10
7
|
if LOGGER_MINIMUM_SEVERITY.isdigit():
|
|
11
8
|
logger_minimum_severity = int(LOGGER_MINIMUM_SEVERITY)
|
|
@@ -28,7 +25,7 @@ logger = logging.getLogger(__name__)
|
|
|
28
25
|
|
|
29
26
|
class MiniLogger:
|
|
30
27
|
# TODO Can we so one generic function call by all
|
|
31
|
-
|
|
28
|
+
|
|
32
29
|
@staticmethod
|
|
33
30
|
def start(message: str = "", object: dict = None):
|
|
34
31
|
"""
|
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from abc import ABC, abstractmethod
|
|
3
|
-
from datetime import date
|
|
2
|
+
from abc import ABC # , abstractmethod
|
|
4
3
|
|
|
5
4
|
from .mini_logger import MiniLogger as logger
|
|
6
|
-
from .temp import deprecation_warning
|
|
7
5
|
|
|
8
6
|
|
|
9
7
|
# TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
|
|
10
8
|
class OurObject(ABC):
|
|
11
9
|
def __init__(self, **kwargs):
|
|
12
|
-
deprecation_warning("our_object", "DELETE", date(2024, 6, 5))
|
|
13
10
|
INIT_METHOD_NAME = '__init__'
|
|
14
11
|
logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
for field, value in kwargs.items():
|
|
14
|
+
# if field in event_fields:
|
|
15
|
+
setattr(self, field, value)
|
|
16
|
+
|
|
17
|
+
# self.kwargs = kwargs
|
|
16
18
|
logger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
# Commented so we can use it in database foreach()
|
|
21
|
+
# @abstractmethod
|
|
19
22
|
def get_name(self):
|
|
20
23
|
"""Returns the name of the object"""
|
|
21
|
-
raise NotImplementedError(
|
|
22
|
-
"Subclasses must implement the 'get_name' method.")
|
|
24
|
+
# raise NotImplementedError(
|
|
25
|
+
# "Subclasses must implement the 'get_name' method.")
|
|
23
26
|
|
|
24
27
|
def get(self, attr_name: str):
|
|
25
28
|
"""Returns the value of the attribute with the given name"""
|
|
26
29
|
GET_METHOD_NAME = 'get'
|
|
27
30
|
logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
|
|
28
|
-
arguments = getattr(self, 'kwargs', None)
|
|
29
|
-
value = arguments.get(attr_name, None)
|
|
31
|
+
# arguments = getattr(self, 'kwargs', None)
|
|
32
|
+
# value = arguments.get(attr_name, None)
|
|
33
|
+
value = self.__dict__.get(attr_name, None)
|
|
30
34
|
logger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
|
|
31
35
|
return value
|
|
32
36
|
|
|
33
37
|
def get_all_arguments(self):
|
|
34
38
|
"""Returns all the arguments passed to the constructor as a dictionary"""
|
|
35
|
-
return getattr(self, 'kwargs', None)
|
|
39
|
+
# return getattr(self, 'kwargs', None)
|
|
40
|
+
return self.__dict__
|
|
36
41
|
|
|
37
42
|
def to_json(self) -> str:
|
|
38
43
|
"""Returns a json string representation of this object"""
|
|
@@ -57,3 +62,6 @@ class OurObject(ABC):
|
|
|
57
62
|
def __ne__(self, other) -> bool:
|
|
58
63
|
"""Checks if two objects are not equal"""
|
|
59
64
|
return not self.__eq__(other)
|
|
65
|
+
|
|
66
|
+
def get_dict(self):
|
|
67
|
+
return self.__dict__
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/unified_json.py
RENAMED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
from datetime import date
|
|
2
|
-
|
|
3
|
-
from .temp import deprecation_warning
|
|
4
1
|
from .valid_json_versions import valid_json_versions
|
|
5
2
|
|
|
6
3
|
|
|
7
4
|
# TODO Shall we merge it with the machine-learning-unified-json?
|
|
8
5
|
class UnifiedJson:
|
|
9
6
|
def __init__(self, data: dict, json_version: str):
|
|
10
|
-
deprecation_warning("unified_json", "DELETE", date(2024, 6, 5))
|
|
11
7
|
if json_version not in valid_json_versions:
|
|
12
8
|
raise Exception(
|
|
13
9
|
f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import inspect
|
|
1
2
|
import json
|
|
2
3
|
import os
|
|
3
4
|
import random
|
|
4
5
|
import re
|
|
5
6
|
from datetime import date, datetime, time, timedelta, timezone
|
|
7
|
+
from functools import lru_cache
|
|
6
8
|
from urllib.parse import urlparse
|
|
7
9
|
|
|
8
10
|
import jwt
|
|
@@ -11,7 +13,6 @@ from dotenv import load_dotenv
|
|
|
11
13
|
from url_remote.environment_name_enum import EnvironmentName
|
|
12
14
|
|
|
13
15
|
from .mini_logger import MiniLogger as logger
|
|
14
|
-
from .temp import deprecation_warning
|
|
15
16
|
|
|
16
17
|
load_dotenv()
|
|
17
18
|
# TODO Let's do brainstorming on this
|
|
@@ -32,22 +33,19 @@ DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
def append_if_not_exist(lst: list, item: object) -> None:
|
|
35
|
-
deprecation_warning("append_if_not_exist", "DELETE", date(2024, 6, 5))
|
|
36
36
|
if item not in lst:
|
|
37
37
|
lst.append(item)
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def to_dict(data: json or dict or None) -> dict:
|
|
41
|
-
deprecation_warning("to_dict", "DELETE", date(2024, 6, 5))
|
|
42
41
|
if data is None:
|
|
43
42
|
return {}
|
|
44
43
|
if isinstance(data, dict):
|
|
45
44
|
return data
|
|
46
|
-
return json.loads(data)
|
|
45
|
+
return json.loads(data)
|
|
47
46
|
|
|
48
47
|
|
|
49
48
|
def to_json(data: json or dict or None) -> json:
|
|
50
|
-
deprecation_warning("to_json", "DELETE", date(2024, 6, 5))
|
|
51
49
|
if data is None:
|
|
52
50
|
data = {}
|
|
53
51
|
if isinstance(data, dict):
|
|
@@ -56,7 +54,6 @@ def to_json(data: json or dict or None) -> json:
|
|
|
56
54
|
|
|
57
55
|
|
|
58
56
|
def timedelta_to_time_format(time_delta: timedelta) -> str:
|
|
59
|
-
deprecation_warning("timedelta_to_time_format", "DELETE", date(2024, 6, 5))
|
|
60
57
|
"""
|
|
61
58
|
Convert a timedelta to a time format in HH:MM:SS.
|
|
62
59
|
|
|
@@ -93,7 +90,6 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
|
|
|
93
90
|
|
|
94
91
|
|
|
95
92
|
def is_valid_time_range(time_range: tuple) -> bool:
|
|
96
|
-
deprecation_warning("is_valid_time_range", "DELETE", date(2024, 6, 5))
|
|
97
93
|
"""
|
|
98
94
|
Validate that the time range is in the format 'HH:MM:SS'.
|
|
99
95
|
"""
|
|
@@ -120,7 +116,6 @@ def is_valid_time_range(time_range: tuple) -> bool:
|
|
|
120
116
|
# TODO shall we also use Url type and not only str? - Strongly Type which I prefer
|
|
121
117
|
# (if yes we should change it also in all the calls to this function)
|
|
122
118
|
def validate_url(url: str):
|
|
123
|
-
deprecation_warning("validate_url", "DELETE", date(2024, 6, 5))
|
|
124
119
|
logger.start(object={"url": url})
|
|
125
120
|
if url is not None or url != "":
|
|
126
121
|
parsed_url = urlparse(url)
|
|
@@ -132,7 +127,6 @@ def validate_url(url: str):
|
|
|
132
127
|
|
|
133
128
|
|
|
134
129
|
def is_valid_date_range(date_range: tuple) -> bool:
|
|
135
|
-
deprecation_warning("is_valid_date_range", "DELETE", date(2024, 6, 5))
|
|
136
130
|
"""
|
|
137
131
|
Validate that the date range is in the format 'YYYY-MM-DD'.
|
|
138
132
|
"""
|
|
@@ -151,7 +145,6 @@ def is_valid_date_range(date_range: tuple) -> bool:
|
|
|
151
145
|
|
|
152
146
|
|
|
153
147
|
def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
|
|
154
|
-
deprecation_warning("is_valid_datetime_range", "DELETE", date(2024, 6, 5))
|
|
155
148
|
"""
|
|
156
149
|
Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
|
|
157
150
|
"""
|
|
@@ -169,7 +162,6 @@ def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
|
|
|
169
162
|
|
|
170
163
|
|
|
171
164
|
def is_list_of_dicts(obj: object) -> bool:
|
|
172
|
-
deprecation_warning("is_list_of_dicts", "DELETE", date(2024, 6, 5))
|
|
173
165
|
"""
|
|
174
166
|
Check if an object is a list of dictionaries.
|
|
175
167
|
|
|
@@ -214,7 +206,6 @@ def is_list_of_dicts(obj: object) -> bool:
|
|
|
214
206
|
|
|
215
207
|
|
|
216
208
|
def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
|
|
217
|
-
deprecation_warning("is_time_in_time_range", "DELETE", date(2024, 6, 5))
|
|
218
209
|
"""
|
|
219
210
|
Check if the given time is within the specified time range.
|
|
220
211
|
|
|
@@ -238,7 +229,6 @@ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
|
|
|
238
229
|
|
|
239
230
|
|
|
240
231
|
def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
|
|
241
|
-
deprecation_warning("is_date_in_date_range", "DELETE", date(2024, 6, 5))
|
|
242
232
|
"""
|
|
243
233
|
Check if the given date is within the specified date range.
|
|
244
234
|
|
|
@@ -263,7 +253,6 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
|
|
|
263
253
|
|
|
264
254
|
|
|
265
255
|
def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (datetime, datetime)) -> bool:
|
|
266
|
-
deprecation_warning("is_datetime_in_datetime_range", "DELETE", date(2024, 6, 5))
|
|
267
256
|
"""
|
|
268
257
|
Check if the given datetime is within the specified datetime range.
|
|
269
258
|
|
|
@@ -288,11 +277,11 @@ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (dat
|
|
|
288
277
|
|
|
289
278
|
|
|
290
279
|
def get_brand_name() -> str:
|
|
291
|
-
return our_get_env("BRAND_NAME"
|
|
280
|
+
return our_get_env("BRAND_NAME")
|
|
292
281
|
|
|
293
282
|
|
|
294
283
|
def get_environment_name() -> str:
|
|
295
|
-
environment_name = our_get_env("ENVIRONMENT_NAME"
|
|
284
|
+
environment_name = our_get_env("ENVIRONMENT_NAME")
|
|
296
285
|
EnvironmentName(environment_name) # if invalid, raises ValueError: x is not a valid EnvironmentName
|
|
297
286
|
return environment_name
|
|
298
287
|
|
|
@@ -311,15 +300,15 @@ def our_get_env(key: str, default: str = None, raise_if_not_found: bool = True,
|
|
|
311
300
|
|
|
312
301
|
# TODO As only the database package uses those, let's move those three to the database package
|
|
313
302
|
def get_sql_hostname() -> str:
|
|
314
|
-
return our_get_env("RDS_HOSTNAME"
|
|
303
|
+
return our_get_env("RDS_HOSTNAME")
|
|
315
304
|
|
|
316
305
|
|
|
317
306
|
def get_sql_username() -> str:
|
|
318
|
-
return our_get_env("RDS_USERNAME"
|
|
307
|
+
return our_get_env("RDS_USERNAME")
|
|
319
308
|
|
|
320
309
|
|
|
321
310
|
def get_sql_password() -> str:
|
|
322
|
-
return our_get_env("RDS_PASSWORD"
|
|
311
|
+
return our_get_env("RDS_PASSWORD")
|
|
323
312
|
|
|
324
313
|
|
|
325
314
|
def get_dialog_jwt_secret_key() -> str:
|
|
@@ -327,7 +316,6 @@ def get_dialog_jwt_secret_key() -> str:
|
|
|
327
316
|
|
|
328
317
|
|
|
329
318
|
def encode_jwt(payload: dict, key: str) -> str:
|
|
330
|
-
deprecation_warning("encode_jwt", "DELETE", date(2024, 6, 5))
|
|
331
319
|
"""Example:
|
|
332
320
|
payload = {
|
|
333
321
|
"user_id": 123,
|
|
@@ -339,42 +327,64 @@ def encode_jwt(payload: dict, key: str) -> str:
|
|
|
339
327
|
|
|
340
328
|
|
|
341
329
|
def decode_jwt(token: str, key: str) -> dict:
|
|
342
|
-
deprecation_warning("decode_jwt", "DELETE", date(2024, 6, 5))
|
|
343
330
|
"""key can be private / public"""
|
|
344
331
|
return jwt.decode(token, key, algorithms=['HS256'])
|
|
345
332
|
|
|
333
|
+
|
|
334
|
+
def obfuscate_log_dict(log_dict: dict) -> dict:
|
|
335
|
+
"""
|
|
336
|
+
Obfuscate keys:
|
|
337
|
+
- %password%
|
|
338
|
+
- %secret%
|
|
339
|
+
- %token%
|
|
340
|
+
- %jwt%
|
|
341
|
+
- %e%mail%
|
|
342
|
+
- %phone%
|
|
343
|
+
- %name% (first / last / nick / user etc.)
|
|
344
|
+
- %address%
|
|
345
|
+
- %ssn%
|
|
346
|
+
"""
|
|
347
|
+
environment_name = get_environment_name()
|
|
348
|
+
if environment_name == EnvironmentName.PLAY1.value:
|
|
349
|
+
return log_dict
|
|
350
|
+
obfuscated_log_dict = {}
|
|
351
|
+
for key, value in log_dict.items():
|
|
352
|
+
if isinstance(value, dict):
|
|
353
|
+
obfuscated_log_dict[key] = obfuscate_log_dict(value)
|
|
354
|
+
elif re.search(r'password|secret|token|jwt|e[\-_]?mail|phone|name|address|ssn', key, re.IGNORECASE):
|
|
355
|
+
# TODO Maybe we can reveal a small part
|
|
356
|
+
obfuscated_log_dict[key] = "***"
|
|
357
|
+
else:
|
|
358
|
+
obfuscated_log_dict[key] = value
|
|
359
|
+
return obfuscated_log_dict
|
|
360
|
+
|
|
361
|
+
|
|
346
362
|
# TODO: add tests to the following functions
|
|
347
363
|
|
|
348
364
|
def remove_digits(text: str) -> str:
|
|
349
|
-
deprecation_warning("remove_digits", "DELETE", date(2024, 6, 5))
|
|
350
365
|
return ''.join(i for i in text if not i.isdigit())
|
|
351
366
|
|
|
352
367
|
|
|
353
368
|
def generate_otp():
|
|
354
|
-
deprecation_warning("generate_otp", "DELETE", date(2024, 6, 5))
|
|
355
369
|
"""Generates a 6-digit OTP"""
|
|
356
370
|
otp = random.randint(100000, 999999)
|
|
357
371
|
return otp
|
|
358
372
|
|
|
359
373
|
|
|
360
374
|
def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT, tz: timezone = None) -> str:
|
|
361
|
-
deprecation_warning("get_current_datetime_string", "DELETE", date(2024, 6, 5))
|
|
362
375
|
current_datetime_string = datetime.now(tz).strftime(datetime_format)
|
|
363
376
|
return current_datetime_string
|
|
364
377
|
|
|
365
378
|
|
|
366
379
|
def datetime_from_str(date_str: str, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> datetime:
|
|
367
|
-
deprecation_warning("datetime_from_str", "DELETE", date(2024, 6, 5))
|
|
368
380
|
return datetime.strptime(date_str, datetime_format)
|
|
369
381
|
|
|
370
382
|
|
|
371
383
|
def datetime_to_str(input_datetime: datetime, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> str:
|
|
372
|
-
deprecation_warning("datetime_to_str", "DELETE", date(2024, 6, 5))
|
|
373
384
|
return input_datetime.strftime(datetime_format)
|
|
374
385
|
|
|
375
386
|
|
|
376
387
|
def validate_arguments(args: dict) -> None:
|
|
377
|
-
deprecation_warning("validate_arguments", "DELETE", date(2024, 6, 5))
|
|
378
388
|
"""
|
|
379
389
|
Validate method arguments to ensure they are not None or ''
|
|
380
390
|
:param args: arguments to be validated (usually locals())
|
|
@@ -386,7 +396,6 @@ def validate_arguments(args: dict) -> None:
|
|
|
386
396
|
|
|
387
397
|
|
|
388
398
|
def reformat_time_string(input_str: str) -> str:
|
|
389
|
-
deprecation_warning("reformat_time_string", "DELETE", date(2024, 6, 5))
|
|
390
399
|
"""Example:
|
|
391
400
|
"1234" -> "12:34:00:00"
|
|
392
401
|
"""
|
|
@@ -400,12 +409,10 @@ def reformat_time_string(input_str: str) -> str:
|
|
|
400
409
|
|
|
401
410
|
|
|
402
411
|
def get_ip_v4():
|
|
403
|
-
deprecation_warning("get_ip_v4", "DELETE", date(2024, 6, 5))
|
|
404
412
|
return requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
|
|
405
413
|
|
|
406
414
|
|
|
407
415
|
def get_ip_v6():
|
|
408
|
-
deprecation_warning("get_ip_v6", "DELETE", date(2024, 6, 5))
|
|
409
416
|
return requests.get('https://api.seeip.org/jsonip').json()['ip']
|
|
410
417
|
|
|
411
418
|
|
|
@@ -420,3 +427,15 @@ def camel_to_snake(camel_str: str) -> str:
|
|
|
420
427
|
"""Converts camelCase to snake_case."""
|
|
421
428
|
snake_str = re.sub(r'(?<!^)(?=[A-Z])', '_', camel_str).lower()
|
|
422
429
|
return snake_str
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
@lru_cache(maxsize=64) # don't print the same warning multiple times
|
|
433
|
+
def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
|
|
434
|
+
if start_date and start_date < date.today():
|
|
435
|
+
return
|
|
436
|
+
warnings_message = f"Please use {old_name} instead of {new_name}."
|
|
437
|
+
try:
|
|
438
|
+
warnings_message += " Called from: " + inspect.stack()[2].filename
|
|
439
|
+
except Exception:
|
|
440
|
+
pass
|
|
441
|
+
logger.warning(warnings_message)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sdk-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.133
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -13,5 +13,13 @@ Requires-Dist: requests
|
|
|
13
13
|
Requires-Dist: python-dotenv
|
|
14
14
|
Requires-Dist: url-remote
|
|
15
15
|
Requires-Dist: pyjwt
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: summary
|
|
16
24
|
|
|
17
25
|
This is a package for sharing common functions used in different repositories
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/SOURCES.txt
RENAMED
|
@@ -12,7 +12,6 @@ python_sdk_remote/src/http_response.py
|
|
|
12
12
|
python_sdk_remote/src/item.py
|
|
13
13
|
python_sdk_remote/src/mini_logger.py
|
|
14
14
|
python_sdk_remote/src/our_object.py
|
|
15
|
-
python_sdk_remote/src/temp.py
|
|
16
15
|
python_sdk_remote/src/unified_json.py
|
|
17
16
|
python_sdk_remote/src/utilities.py
|
|
18
17
|
python_sdk_remote/src/valid_json_versions.py
|
|
@@ -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.133', # https://pypi.org/project/python-sdk-remote/
|
|
11
11
|
author="Circles",
|
|
12
12
|
author_email="info@circlez.ai",
|
|
13
13
|
description="PyPI Package for Circles Python SDK Local Python",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# TODO: remove once all breaking changes related to deprecation are done
|
|
2
|
-
import inspect
|
|
3
|
-
from datetime import date
|
|
4
|
-
from functools import lru_cache
|
|
5
|
-
|
|
6
|
-
from .mini_logger import MiniLogger as logger
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@lru_cache(maxsize=64) # don't print the same warning multiple times
|
|
10
|
-
def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
|
|
11
|
-
if start_date and start_date < date.today():
|
|
12
|
-
return
|
|
13
|
-
warnings_message = f"{new_name} {old_name} and use the local version."
|
|
14
|
-
try:
|
|
15
|
-
warnings_message += " Called from: " + inspect.stack()[2].filename
|
|
16
|
-
except Exception:
|
|
17
|
-
pass
|
|
18
|
-
logger.warning(warnings_message)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote/src/valid_json_versions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/requires.txt
RENAMED
|
File without changes
|
{python_sdk_remote-0.0.131 → python_sdk_remote-0.0.133}/python_sdk_remote.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|