python-sdk-local 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.
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/PKG-INFO +2 -1
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/http_response.py +1 -1
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/our_object.py +1 -1
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/utilities.py +3 -68
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/PKG-INFO +2 -1
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/SOURCES.txt +0 -1
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/requires.txt +1 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/setup.py +2 -1
- python_sdk_local-0.0.131/python_sdk_local/src/mini_logger.py +0 -131
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/README.md +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/pyproject.toml +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/__init__.py +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/constants.py +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/item.py +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/unified_json.py +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/valid_json_versions.py +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/validate_environment.py +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/dependency_links.txt +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/top_level.txt +0 -0
- {python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/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.133
|
|
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?
|
|
@@ -6,13 +6,14 @@ import re
|
|
|
6
6
|
from datetime import date, datetime, time, timedelta, timezone
|
|
7
7
|
from functools import lru_cache
|
|
8
8
|
from urllib.parse import urlparse
|
|
9
|
-
|
|
9
|
+
import warnings
|
|
10
10
|
import jwt
|
|
11
11
|
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
|
load_dotenv()
|
|
18
19
|
# TODO Let's do brainstorming on this
|
|
@@ -276,44 +277,6 @@ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (dat
|
|
|
276
277
|
return is_datetime_in_datetime_range_result
|
|
277
278
|
|
|
278
279
|
|
|
279
|
-
def get_brand_name() -> str:
|
|
280
|
-
return our_get_env("BRAND_NAME")
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
def get_environment_name() -> str:
|
|
284
|
-
environment_name = our_get_env("ENVIRONMENT_NAME")
|
|
285
|
-
EnvironmentName(environment_name) # if invalid, raises ValueError: x is not a valid EnvironmentName
|
|
286
|
-
return environment_name
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
def our_get_env(key: str, default: str = None, raise_if_not_found: bool = True,
|
|
290
|
-
raise_if_empty: bool = False) -> str:
|
|
291
|
-
logger.start(object={"key": key, "default": default, "raise_if_not_found": raise_if_not_found,
|
|
292
|
-
"raise_if_empty": raise_if_empty})
|
|
293
|
-
env_var = os.getenv(key, default)
|
|
294
|
-
if ((raise_if_not_found and key not in os.environ and default is None)
|
|
295
|
-
or (raise_if_empty and not env_var and not default)):
|
|
296
|
-
raise Exception(f"Environment variable {key} not found - please check your .env file")
|
|
297
|
-
logger.end(object={"env_var": env_var})
|
|
298
|
-
return env_var
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
# TODO As only the database package uses those, let's move those three to the database package
|
|
302
|
-
def get_sql_hostname() -> str:
|
|
303
|
-
return our_get_env("RDS_HOSTNAME")
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
def get_sql_username() -> str:
|
|
307
|
-
return our_get_env("RDS_USERNAME")
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
def get_sql_password() -> str:
|
|
311
|
-
return our_get_env("RDS_PASSWORD")
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
def get_dialog_jwt_secret_key() -> str:
|
|
315
|
-
return our_get_env("DIALOG_JWT_SECRET_KEY", raise_if_empty=True)
|
|
316
|
-
|
|
317
280
|
|
|
318
281
|
def encode_jwt(payload: dict, key: str) -> str:
|
|
319
282
|
"""Example:
|
|
@@ -331,34 +294,6 @@ def decode_jwt(token: str, key: str) -> dict:
|
|
|
331
294
|
return jwt.decode(token, key, algorithms=['HS256'])
|
|
332
295
|
|
|
333
296
|
|
|
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
|
-
|
|
362
297
|
# TODO: add tests to the following functions
|
|
363
298
|
|
|
364
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.133
|
|
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.133', # 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,131 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
import sys
|
|
4
|
-
|
|
5
|
-
LOGGER_MINIMUM_SEVERITY = os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO").upper()
|
|
6
|
-
# logging expects NOTSET/DEBUG/INFO/WARNING/ERROR/FATAL/CRITICAL
|
|
7
|
-
if LOGGER_MINIMUM_SEVERITY.isdigit():
|
|
8
|
-
logger_minimum_severity = int(LOGGER_MINIMUM_SEVERITY)
|
|
9
|
-
# Values from Logger.MessageSeverity
|
|
10
|
-
if logger_minimum_severity < 400:
|
|
11
|
-
LOGGER_MINIMUM_SEVERITY = "DEBUG"
|
|
12
|
-
elif logger_minimum_severity < 600:
|
|
13
|
-
LOGGER_MINIMUM_SEVERITY = "INFO"
|
|
14
|
-
elif logger_minimum_severity < 700:
|
|
15
|
-
LOGGER_MINIMUM_SEVERITY = "WARNING"
|
|
16
|
-
elif logger_minimum_severity < 800:
|
|
17
|
-
LOGGER_MINIMUM_SEVERITY = "ERROR"
|
|
18
|
-
else:
|
|
19
|
-
LOGGER_MINIMUM_SEVERITY = "CRITICAL"
|
|
20
|
-
|
|
21
|
-
logging.basicConfig(level=LOGGER_MINIMUM_SEVERITY, stream=sys.stdout,
|
|
22
|
-
format="%(asctime)s - %(message)s")
|
|
23
|
-
logger = logging.getLogger(__name__)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class MiniLogger:
|
|
27
|
-
# TODO Can we so one generic function call by all
|
|
28
|
-
|
|
29
|
-
@staticmethod
|
|
30
|
-
def start(message: str = "", object: dict = None):
|
|
31
|
-
"""
|
|
32
|
-
Print a log message with the current time.
|
|
33
|
-
|
|
34
|
-
Parameters:
|
|
35
|
-
message (str): The message to be printed.
|
|
36
|
-
object (dict): The object to be printed.
|
|
37
|
-
"""
|
|
38
|
-
if object is None:
|
|
39
|
-
logger.debug(f"START - {message}")
|
|
40
|
-
else:
|
|
41
|
-
logger.debug(f"START - {message} - {object}")
|
|
42
|
-
|
|
43
|
-
@staticmethod
|
|
44
|
-
def end(message: str = "", object: dict = None):
|
|
45
|
-
"""
|
|
46
|
-
Print a log message with the current time.
|
|
47
|
-
|
|
48
|
-
Parameters:
|
|
49
|
-
message (str): The message to be printed.
|
|
50
|
-
"""
|
|
51
|
-
if object is None:
|
|
52
|
-
logger.debug(f"END - {message}")
|
|
53
|
-
else:
|
|
54
|
-
logger.debug(f"END - {message} - {object}")
|
|
55
|
-
|
|
56
|
-
@staticmethod
|
|
57
|
-
def debug(message: str = "", object: dict = None):
|
|
58
|
-
"""
|
|
59
|
-
Print a log message with the current time.
|
|
60
|
-
|
|
61
|
-
Parameters:
|
|
62
|
-
message (str): The message to be printed.
|
|
63
|
-
object (dict): The object to be printed.
|
|
64
|
-
"""
|
|
65
|
-
if object is None:
|
|
66
|
-
logger.debug(f"DEBUG - {message}")
|
|
67
|
-
else:
|
|
68
|
-
logger.debug(f"DEBUG {message} - {object}")
|
|
69
|
-
|
|
70
|
-
@staticmethod
|
|
71
|
-
def info(message: str = "", object: dict = None):
|
|
72
|
-
"""
|
|
73
|
-
Print a log message with the current time.
|
|
74
|
-
|
|
75
|
-
Parameters:
|
|
76
|
-
message (str): The message to be printed.
|
|
77
|
-
object (dict): The object to be printed.
|
|
78
|
-
"""
|
|
79
|
-
if object is None:
|
|
80
|
-
logger.info(f"INFO - {message}")
|
|
81
|
-
else:
|
|
82
|
-
logger.info(f"INFO {message} - {object}")
|
|
83
|
-
|
|
84
|
-
@staticmethod
|
|
85
|
-
def warning(message: str = "", object: dict = None):
|
|
86
|
-
"""
|
|
87
|
-
Print a log message with the current time.
|
|
88
|
-
|
|
89
|
-
Parameters:
|
|
90
|
-
message (str): The message to be printed.
|
|
91
|
-
object (dict): The object to be printed.
|
|
92
|
-
"""
|
|
93
|
-
if object is None:
|
|
94
|
-
logger.warning(f"WARNING - {message}")
|
|
95
|
-
else:
|
|
96
|
-
logger.warning(f"WARNING {message} - {object}")
|
|
97
|
-
|
|
98
|
-
@staticmethod
|
|
99
|
-
def error(message: str = "", object: dict = None):
|
|
100
|
-
"""
|
|
101
|
-
Print a log error message with the current time.
|
|
102
|
-
|
|
103
|
-
Parameters:
|
|
104
|
-
message (str): The message to be printed.
|
|
105
|
-
object (dict): The object to be printed.
|
|
106
|
-
"""
|
|
107
|
-
if object is None:
|
|
108
|
-
logger.error(f"ERROR - {message}")
|
|
109
|
-
else:
|
|
110
|
-
logger.error(f"ERROR - {message} - {object}")
|
|
111
|
-
|
|
112
|
-
@staticmethod
|
|
113
|
-
def exception(message: str = "", object: Exception or dict = None):
|
|
114
|
-
"""
|
|
115
|
-
Print a log error message with the current time.
|
|
116
|
-
|
|
117
|
-
Parameters:
|
|
118
|
-
message (str): The message to be printed.
|
|
119
|
-
object (dict / Exception): The object / Exception to be printed.
|
|
120
|
-
"""
|
|
121
|
-
if isinstance(object, Exception):
|
|
122
|
-
exception = object
|
|
123
|
-
elif isinstance(object, dict):
|
|
124
|
-
exception = object.get("exception")
|
|
125
|
-
else:
|
|
126
|
-
exception = None
|
|
127
|
-
|
|
128
|
-
if object is None:
|
|
129
|
-
logger.exception(f"EXCEPTION - {message}")
|
|
130
|
-
else:
|
|
131
|
-
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.131 → python_sdk_local-0.0.133}/python_sdk_local/src/valid_json_versions.py
RENAMED
|
File without changes
|
{python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local/src/validate_environment.py
RENAMED
|
File without changes
|
{python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_sdk_local-0.0.131 → python_sdk_local-0.0.133}/python_sdk_local.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|