python-sdk-local 0.0.132__tar.gz → 0.0.134__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.
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/PKG-INFO +2 -1
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/http_response.py +1 -1
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/our_object.py +1 -1
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/utilities.py +1 -107
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/PKG-INFO +2 -1
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/SOURCES.txt +0 -1
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/requires.txt +1 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/setup.py +2 -1
- python_sdk_local-0.0.132/python_sdk_local/src/mini_logger.py +0 -137
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/README.md +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/pyproject.toml +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/__init__.py +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/constants.py +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/item.py +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/unified_json.py +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/valid_json_versions.py +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/validate_environment.py +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/dependency_links.txt +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/top_level.txt +0 -0
- {python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-sdk-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.134
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-local-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -13,5 +13,6 @@ Requires-Dist: requests
|
|
|
13
13
|
Requires-Dist: python-dotenv
|
|
14
14
|
Requires-Dist: url-remote
|
|
15
15
|
Requires-Dist: pyjwt
|
|
16
|
+
Requires-Dist: python-sdk-remote
|
|
16
17
|
|
|
17
18
|
This is a package for sharing common functions used in different repositories
|
|
@@ -3,7 +3,7 @@ from functools import wraps
|
|
|
3
3
|
from http import HTTPStatus
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from .mini_logger import MiniLogger as logger
|
|
6
|
+
from python_sdk_remote.mini_logger import MiniLogger as logger
|
|
7
7
|
from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
|
|
8
8
|
|
|
9
9
|
HEADERS_KEY = 'headers'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
3
|
|
|
4
|
-
from .mini_logger import MiniLogger as logger
|
|
4
|
+
from python_sdk_remote.mini_logger import MiniLogger as logger
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
# TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
|
|
@@ -12,7 +12,7 @@ import requests
|
|
|
12
12
|
from dotenv import load_dotenv
|
|
13
13
|
from url_remote.environment_name_enum import EnvironmentName
|
|
14
14
|
|
|
15
|
-
from .mini_logger import MiniLogger as logger
|
|
15
|
+
from python_sdk_remote.mini_logger import MiniLogger as logger
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
load_dotenv()
|
|
@@ -277,79 +277,6 @@ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (dat
|
|
|
277
277
|
return is_datetime_in_datetime_range_result
|
|
278
278
|
|
|
279
279
|
|
|
280
|
-
def get_brand_name() -> str:
|
|
281
|
-
warnings.warn(
|
|
282
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
283
|
-
DeprecationWarning,
|
|
284
|
-
stacklevel=2
|
|
285
|
-
)
|
|
286
|
-
return our_get_env("BRAND_NAME")
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
def get_environment_name() -> str:
|
|
290
|
-
warnings.warn(
|
|
291
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
292
|
-
DeprecationWarning,
|
|
293
|
-
stacklevel=2
|
|
294
|
-
)
|
|
295
|
-
environment_name = our_get_env("ENVIRONMENT_NAME")
|
|
296
|
-
EnvironmentName(environment_name) # if invalid, raises ValueError: x is not a valid EnvironmentName
|
|
297
|
-
return environment_name
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
def our_get_env(key: str, default: str = None, raise_if_not_found: bool = True,
|
|
301
|
-
raise_if_empty: bool = False) -> str:
|
|
302
|
-
warnings.warn(
|
|
303
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
304
|
-
DeprecationWarning,
|
|
305
|
-
stacklevel=2
|
|
306
|
-
)
|
|
307
|
-
logger.start(object={"key": key, "default": default, "raise_if_not_found": raise_if_not_found,
|
|
308
|
-
"raise_if_empty": raise_if_empty})
|
|
309
|
-
env_var = os.getenv(key, default)
|
|
310
|
-
if ((raise_if_not_found and key not in os.environ and default is None)
|
|
311
|
-
or (raise_if_empty and not env_var and not default)):
|
|
312
|
-
raise Exception(f"Environment variable {key} not found - please check your .env file")
|
|
313
|
-
logger.end(object={"env_var": env_var})
|
|
314
|
-
return env_var
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
# TODO As only the database package uses those, let's move those three to the database package
|
|
318
|
-
def get_sql_hostname() -> str:
|
|
319
|
-
warnings.warn(
|
|
320
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
321
|
-
DeprecationWarning,
|
|
322
|
-
stacklevel=2
|
|
323
|
-
)
|
|
324
|
-
return our_get_env("RDS_HOSTNAME")
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
def get_sql_username() -> str:
|
|
328
|
-
warnings.warn(
|
|
329
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
330
|
-
DeprecationWarning,
|
|
331
|
-
stacklevel=2
|
|
332
|
-
)
|
|
333
|
-
return our_get_env("RDS_USERNAME")
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
def get_sql_password() -> str:
|
|
337
|
-
warnings.warn(
|
|
338
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
339
|
-
DeprecationWarning,
|
|
340
|
-
stacklevel=2
|
|
341
|
-
)
|
|
342
|
-
return our_get_env("RDS_PASSWORD")
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
def get_dialog_jwt_secret_key() -> str:
|
|
346
|
-
warnings.warn(
|
|
347
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
348
|
-
DeprecationWarning,
|
|
349
|
-
stacklevel=2
|
|
350
|
-
)
|
|
351
|
-
return our_get_env("DIALOG_JWT_SECRET_KEY", raise_if_empty=True)
|
|
352
|
-
|
|
353
280
|
|
|
354
281
|
def encode_jwt(payload: dict, key: str) -> str:
|
|
355
282
|
"""Example:
|
|
@@ -367,39 +294,6 @@ def decode_jwt(token: str, key: str) -> dict:
|
|
|
367
294
|
return jwt.decode(token, key, algorithms=['HS256'])
|
|
368
295
|
|
|
369
296
|
|
|
370
|
-
def obfuscate_log_dict(log_dict: dict) -> dict:
|
|
371
|
-
warnings.warn(
|
|
372
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
373
|
-
DeprecationWarning,
|
|
374
|
-
stacklevel=2
|
|
375
|
-
)
|
|
376
|
-
"""
|
|
377
|
-
Obfuscate keys:
|
|
378
|
-
- %password%
|
|
379
|
-
- %secret%
|
|
380
|
-
- %token%
|
|
381
|
-
- %jwt%
|
|
382
|
-
- %e%mail%
|
|
383
|
-
- %phone%
|
|
384
|
-
- %name% (first / last / nick / user etc.)
|
|
385
|
-
- %address%
|
|
386
|
-
- %ssn%
|
|
387
|
-
"""
|
|
388
|
-
environment_name = get_environment_name()
|
|
389
|
-
if environment_name == EnvironmentName.PLAY1.value:
|
|
390
|
-
return log_dict
|
|
391
|
-
obfuscated_log_dict = {}
|
|
392
|
-
for key, value in log_dict.items():
|
|
393
|
-
if isinstance(value, dict):
|
|
394
|
-
obfuscated_log_dict[key] = obfuscate_log_dict(value)
|
|
395
|
-
elif re.search(r'password|secret|token|jwt|e[\-_]?mail|phone|name|address|ssn', key, re.IGNORECASE):
|
|
396
|
-
# TODO Maybe we can reveal a small part
|
|
397
|
-
obfuscated_log_dict[key] = "***"
|
|
398
|
-
else:
|
|
399
|
-
obfuscated_log_dict[key] = value
|
|
400
|
-
return obfuscated_log_dict
|
|
401
|
-
|
|
402
|
-
|
|
403
297
|
# TODO: add tests to the following functions
|
|
404
298
|
|
|
405
299
|
def remove_digits(text: str) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-sdk-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.134
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-local-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -13,5 +13,6 @@ Requires-Dist: requests
|
|
|
13
13
|
Requires-Dist: python-dotenv
|
|
14
14
|
Requires-Dist: url-remote
|
|
15
15
|
Requires-Dist: pyjwt
|
|
16
|
+
Requires-Dist: python-sdk-remote
|
|
16
17
|
|
|
17
18
|
This is a package for sharing common functions used in different repositories
|
|
@@ -10,7 +10,6 @@ python_sdk_local/src/__init__.py
|
|
|
10
10
|
python_sdk_local/src/constants.py
|
|
11
11
|
python_sdk_local/src/http_response.py
|
|
12
12
|
python_sdk_local/src/item.py
|
|
13
|
-
python_sdk_local/src/mini_logger.py
|
|
14
13
|
python_sdk_local/src/our_object.py
|
|
15
14
|
python_sdk_local/src/unified_json.py
|
|
16
15
|
python_sdk_local/src/utilities.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.134', # https://pypi.org/project/python-sdk-local/
|
|
11
11
|
author="Circles",
|
|
12
12
|
author_email="info@circlez.ai",
|
|
13
13
|
description="PyPI Package for Circles Python SDK Local Python",
|
|
@@ -27,5 +27,6 @@ setuptools.setup(
|
|
|
27
27
|
"python-dotenv",
|
|
28
28
|
"url-remote",
|
|
29
29
|
"pyjwt",
|
|
30
|
+
"python-sdk-remote"
|
|
30
31
|
]
|
|
31
32
|
)
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
import sys
|
|
4
|
-
|
|
5
|
-
import warnings
|
|
6
|
-
|
|
7
|
-
LOGGER_MINIMUM_SEVERITY = os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO").upper()
|
|
8
|
-
# logging expects NOTSET/DEBUG/INFO/WARNING/ERROR/FATAL/CRITICAL
|
|
9
|
-
if LOGGER_MINIMUM_SEVERITY.isdigit():
|
|
10
|
-
logger_minimum_severity = int(LOGGER_MINIMUM_SEVERITY)
|
|
11
|
-
# Values from Logger.MessageSeverity
|
|
12
|
-
if logger_minimum_severity < 400:
|
|
13
|
-
LOGGER_MINIMUM_SEVERITY = "DEBUG"
|
|
14
|
-
elif logger_minimum_severity < 600:
|
|
15
|
-
LOGGER_MINIMUM_SEVERITY = "INFO"
|
|
16
|
-
elif logger_minimum_severity < 700:
|
|
17
|
-
LOGGER_MINIMUM_SEVERITY = "WARNING"
|
|
18
|
-
elif logger_minimum_severity < 800:
|
|
19
|
-
LOGGER_MINIMUM_SEVERITY = "ERROR"
|
|
20
|
-
else:
|
|
21
|
-
LOGGER_MINIMUM_SEVERITY = "CRITICAL"
|
|
22
|
-
|
|
23
|
-
logging.basicConfig(level=LOGGER_MINIMUM_SEVERITY, stream=sys.stdout,
|
|
24
|
-
format="%(asctime)s - %(message)s")
|
|
25
|
-
logger = logging.getLogger(__name__)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class MiniLogger:
|
|
29
|
-
# TODO Can we so one generic function call by all
|
|
30
|
-
warnings.warn(
|
|
31
|
-
"deprecated_method is deprecated and will be removed in a future version. ",
|
|
32
|
-
DeprecationWarning,
|
|
33
|
-
stacklevel=2
|
|
34
|
-
)
|
|
35
|
-
@staticmethod
|
|
36
|
-
def start(message: str = "", object: dict = None):
|
|
37
|
-
"""
|
|
38
|
-
Print a log message with the current time.
|
|
39
|
-
|
|
40
|
-
Parameters:
|
|
41
|
-
message (str): The message to be printed.
|
|
42
|
-
object (dict): The object to be printed.
|
|
43
|
-
"""
|
|
44
|
-
if object is None:
|
|
45
|
-
logger.debug(f"START - {message}")
|
|
46
|
-
else:
|
|
47
|
-
logger.debug(f"START - {message} - {object}")
|
|
48
|
-
|
|
49
|
-
@staticmethod
|
|
50
|
-
def end(message: str = "", object: dict = None):
|
|
51
|
-
"""
|
|
52
|
-
Print a log message with the current time.
|
|
53
|
-
|
|
54
|
-
Parameters:
|
|
55
|
-
message (str): The message to be printed.
|
|
56
|
-
"""
|
|
57
|
-
if object is None:
|
|
58
|
-
logger.debug(f"END - {message}")
|
|
59
|
-
else:
|
|
60
|
-
logger.debug(f"END - {message} - {object}")
|
|
61
|
-
|
|
62
|
-
@staticmethod
|
|
63
|
-
def debug(message: str = "", object: dict = None):
|
|
64
|
-
"""
|
|
65
|
-
Print a log message with the current time.
|
|
66
|
-
|
|
67
|
-
Parameters:
|
|
68
|
-
message (str): The message to be printed.
|
|
69
|
-
object (dict): The object to be printed.
|
|
70
|
-
"""
|
|
71
|
-
if object is None:
|
|
72
|
-
logger.debug(f"DEBUG - {message}")
|
|
73
|
-
else:
|
|
74
|
-
logger.debug(f"DEBUG {message} - {object}")
|
|
75
|
-
|
|
76
|
-
@staticmethod
|
|
77
|
-
def info(message: str = "", object: dict = None):
|
|
78
|
-
"""
|
|
79
|
-
Print a log message with the current time.
|
|
80
|
-
|
|
81
|
-
Parameters:
|
|
82
|
-
message (str): The message to be printed.
|
|
83
|
-
object (dict): The object to be printed.
|
|
84
|
-
"""
|
|
85
|
-
if object is None:
|
|
86
|
-
logger.info(f"INFO - {message}")
|
|
87
|
-
else:
|
|
88
|
-
logger.info(f"INFO {message} - {object}")
|
|
89
|
-
|
|
90
|
-
@staticmethod
|
|
91
|
-
def warning(message: str = "", object: dict = None):
|
|
92
|
-
"""
|
|
93
|
-
Print a log message with the current time.
|
|
94
|
-
|
|
95
|
-
Parameters:
|
|
96
|
-
message (str): The message to be printed.
|
|
97
|
-
object (dict): The object to be printed.
|
|
98
|
-
"""
|
|
99
|
-
if object is None:
|
|
100
|
-
logger.warning(f"WARNING - {message}")
|
|
101
|
-
else:
|
|
102
|
-
logger.warning(f"WARNING {message} - {object}")
|
|
103
|
-
|
|
104
|
-
@staticmethod
|
|
105
|
-
def error(message: str = "", object: dict = None):
|
|
106
|
-
"""
|
|
107
|
-
Print a log error message with the current time.
|
|
108
|
-
|
|
109
|
-
Parameters:
|
|
110
|
-
message (str): The message to be printed.
|
|
111
|
-
object (dict): The object to be printed.
|
|
112
|
-
"""
|
|
113
|
-
if object is None:
|
|
114
|
-
logger.error(f"ERROR - {message}")
|
|
115
|
-
else:
|
|
116
|
-
logger.error(f"ERROR - {message} - {object}")
|
|
117
|
-
|
|
118
|
-
@staticmethod
|
|
119
|
-
def exception(message: str = "", object: Exception or dict = None):
|
|
120
|
-
"""
|
|
121
|
-
Print a log error message with the current time.
|
|
122
|
-
|
|
123
|
-
Parameters:
|
|
124
|
-
message (str): The message to be printed.
|
|
125
|
-
object (dict / Exception): The object / Exception to be printed.
|
|
126
|
-
"""
|
|
127
|
-
if isinstance(object, Exception):
|
|
128
|
-
exception = object
|
|
129
|
-
elif isinstance(object, dict):
|
|
130
|
-
exception = object.get("exception")
|
|
131
|
-
else:
|
|
132
|
-
exception = None
|
|
133
|
-
|
|
134
|
-
if object is None:
|
|
135
|
-
logger.exception(f"EXCEPTION - {message}")
|
|
136
|
-
else:
|
|
137
|
-
logger.exception(f"EXCEPTION- {message} - {object}", exc_info=exception)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/valid_json_versions.py
RENAMED
|
File without changes
|
{python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local/src/validate_environment.py
RENAMED
|
File without changes
|
{python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_sdk_local-0.0.132 → python_sdk_local-0.0.134}/python_sdk_local.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|