python-sdk-remote 0.0.68__tar.gz → 0.0.69__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.

Files changed (21) hide show
  1. {python-sdk-remote-0.0.68 → python-sdk-remote-0.0.69}/PKG-INFO +2 -1
  2. {python-sdk-remote-0.0.68 → python-sdk-remote-0.0.69}/pyproject.toml +1 -1
  3. python-sdk-remote-0.0.69/python_sdk_remote/src/__init__.py +0 -0
  4. python-sdk-remote-0.0.69/python_sdk_remote/src/constants.py +28 -0
  5. python-sdk-remote-0.0.69/python_sdk_remote/src/item.py +12 -0
  6. python-sdk-remote-0.0.69/python_sdk_remote/src/mini_logger.py +91 -0
  7. python-sdk-remote-0.0.69/python_sdk_remote/src/our_object.py +48 -0
  8. python-sdk-remote-0.0.69/python_sdk_remote/src/unified_json.py +13 -0
  9. python-sdk-remote-0.0.69/python_sdk_remote/src/utilities.py +285 -0
  10. python-sdk-remote-0.0.69/python_sdk_remote/src/validate_environment.py +42 -0
  11. {python-sdk-remote-0.0.68 → python-sdk-remote-0.0.69}/python_sdk_remote.egg-info/PKG-INFO +2 -1
  12. python-sdk-remote-0.0.69/python_sdk_remote.egg-info/SOURCES.txt +16 -0
  13. python-sdk-remote-0.0.69/python_sdk_remote.egg-info/requires.txt +1 -0
  14. python-sdk-remote-0.0.69/python_sdk_remote.egg-info/top_level.txt +1 -0
  15. python-sdk-remote-0.0.69/setup.py +28 -0
  16. python-sdk-remote-0.0.68/python_sdk_remote.egg-info/SOURCES.txt +0 -7
  17. python-sdk-remote-0.0.68/python_sdk_remote.egg-info/top_level.txt +0 -1
  18. python-sdk-remote-0.0.68/setup.py +0 -20
  19. {python-sdk-remote-0.0.68 → python-sdk-remote-0.0.69}/README.md +0 -0
  20. {python-sdk-remote-0.0.68 → python-sdk-remote-0.0.69}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  21. {python-sdk-remote-0.0.68 → python-sdk-remote-0.0.69}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.68
3
+ Version: 0.0.69
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
@@ -9,5 +9,6 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: Other/Proprietary License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
+ Requires-Dist: python-dotenv
12
13
 
13
14
  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.68" # https://pypi.org/project/python-sdk-local
7
+ version = "0.0.69" # https://pypi.org/project/python-sdk-local
8
8
  description = "python-sdk-local Python Package"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -0,0 +1,28 @@
1
+ import os
2
+
3
+ from logger_local.LoggerComponentEnum import LoggerComponentEnum
4
+
5
+ PYTHON_SDK_LOCAL_COMPONENT_ID = 184
6
+ PYTHON_SDK_LOCAL_COMPONENT_NAME = 'python_sdk_local'
7
+
8
+ ENVIRONMENT_NAME = os.getenv("ENVIRONMENT_NAME")
9
+ BRAND_NAME = os.getenv("BRAND_NAME")
10
+ LOGZIO_TOKEN = os.getenv("LOGZIO_TOKEN")
11
+ # TODO Shall Can we use python-sdk function to get the value from Environment?
12
+ # TODO Shall we get the value from environment here of send the value to the function as @akiva-skolnik did?
13
+ GOOGLE_PORT_FOR_AUTHENTICATION = os.getenv("PORT_FOR_AUTHENTICATION")
14
+
15
+ OBJECT_TO_INSERT_CODE = {
16
+ 'component_id': PYTHON_SDK_LOCAL_COMPONENT_ID,
17
+ 'component_name': PYTHON_SDK_LOCAL_COMPONENT_NAME,
18
+ 'component_category': LoggerComponentEnum.ComponentCategory.Code.value,
19
+ 'developer_email': 'sahar.g@circ.zone'
20
+ }
21
+
22
+ OBJECT_TO_INSERT_TEST = {
23
+ 'component_id': PYTHON_SDK_LOCAL_COMPONENT_ID,
24
+ 'component_name': PYTHON_SDK_LOCAL_COMPONENT_NAME,
25
+ 'component_category': LoggerComponentEnum.ComponentCategory.Unit_Test.value,
26
+ 'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
27
+ 'developer_email': 'sahar.g@circ.zone'
28
+ }
@@ -0,0 +1,12 @@
1
+ from abc import abstractmethod
2
+
3
+ from .our_object import OurObject
4
+
5
+
6
+ class Item(OurObject):
7
+ def __init__(self, **kwargs):
8
+ super().__init__(**kwargs)
9
+
10
+ @abstractmethod
11
+ def get_id(self):
12
+ raise NotImplementedError("Subclasses must implement the 'get_id' method.")
@@ -0,0 +1,91 @@
1
+ import sys
2
+ from datetime import datetime
3
+
4
+
5
+ class MiniLogger:
6
+ # TODO Can we so one generic function call by all
7
+ # TODO Shall we user the Python logging package?
8
+
9
+ @staticmethod
10
+ def start(message: str = "", object: dict = None):
11
+ """
12
+ Print a log message with the current time.
13
+
14
+ Parameters:
15
+ message (str): The message to be printed.
16
+ """
17
+ if object is None:
18
+ print(f"{datetime.now()} - START - {message}")
19
+ else:
20
+ print(f"{datetime.now()} - START - {message} - {str(object)}")
21
+
22
+ @staticmethod
23
+ def end(message: str = "", object: dict = None):
24
+ """
25
+ Print a log message with the current time.
26
+
27
+ Parameters:
28
+ message (str): The message to be printed.
29
+ """
30
+ if object is None:
31
+ print(f"{datetime.now()} - END - {message}")
32
+ else:
33
+ print(f"{datetime.now()} - END - {message} - {str(object)}")
34
+
35
+ @staticmethod
36
+ def info(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
+ print(f"{datetime.now()} - INFO - {message}")
46
+ else:
47
+ print(f"{datetime.now()} - INFO {message} - {str(object)}")
48
+
49
+ @staticmethod
50
+ def warning(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
+ object (dict): The object to be printed.
57
+ """
58
+ if object is None:
59
+ print(f"{datetime.now()} - WARNING - {message}")
60
+ else:
61
+ print(f"{datetime.now()} - WARNING {message} - {str(object)}")
62
+
63
+ @staticmethod
64
+ def error(message: str = "", object: dict = None):
65
+ """
66
+ Print a log error message with the current time.
67
+
68
+ Parameters:
69
+ message (str): The message to be printed.
70
+ object (dict): The object to be printed.
71
+ """
72
+ if object is None:
73
+ print(f"{datetime.now()} - ERROR - {message}", file=sys.stderr)
74
+ else:
75
+ print(
76
+ f"{datetime.now()} - ERROR - {message} - {str(object)}", file=sys.stderr)
77
+
78
+ @staticmethod
79
+ def exception(message: str = "", object: dict = None):
80
+ """
81
+ Print a log error message with the current time.
82
+
83
+ Parameters:
84
+ message (str): The message to be printed.
85
+ object (dict): The object to be printed.
86
+ """
87
+ if object is None:
88
+ print(f"{datetime.now()} - EXCEPTION - {message}", file=sys.stderr)
89
+ else:
90
+ print(
91
+ f"{datetime.now()} - EXCEPTION- {message} - {str(object)}", file=sys.stderr)
@@ -0,0 +1,48 @@
1
+ import json
2
+ from abc import ABC, abstractmethod
3
+
4
+ from .mini_logger import MiniLogger
5
+
6
+
7
+ class OurObject(ABC):
8
+ def __init__(self, **kwargs):
9
+ INIT_METHOD_NAME = '__init__'
10
+ MiniLogger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
11
+ self.kwargs = kwargs
12
+ MiniLogger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
13
+
14
+ @abstractmethod
15
+ def get_name(self):
16
+ raise NotImplementedError(
17
+ "Subclasses must implement the 'get_name' method.")
18
+
19
+ def get(self, attr_name: str):
20
+ GET_METHOD_NAME = 'get'
21
+ MiniLogger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
22
+ arguments = getattr(self, 'kwargs', None)
23
+ value = arguments.get(attr_name, None)
24
+ MiniLogger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
25
+ return value
26
+
27
+ def get_all_arguments(self):
28
+ return getattr(self, 'kwargs', None)
29
+
30
+ def to_json(self) -> str:
31
+ return json.dumps(self.__dict__)
32
+
33
+ def from_json(self, json_string: str) -> 'OurObject':
34
+ FROM_JSON_METHOD_NAME = 'from_json'
35
+ MiniLogger.start(FROM_JSON_METHOD_NAME,
36
+ object={'json_string': json_string})
37
+ self.__dict__ = json.loads(json_string)
38
+ MiniLogger.end(FROM_JSON_METHOD_NAME,
39
+ object={'json_dict': self.__dict__})
40
+ return self
41
+
42
+ def __eq__(self, other) -> bool:
43
+ if not isinstance(other, OurObject):
44
+ return False
45
+ return self.__dict__ == other.__dict__
46
+
47
+ def __ne__(self, other) -> bool:
48
+ return not self.__eq__(other)
@@ -0,0 +1,13 @@
1
+ class UnifiedJson:
2
+ def __init__(self, data: dict, version: str):
3
+ self.version = version
4
+ self.data = data
5
+
6
+ def get_unified_json(self):
7
+ return {"version": self.version, "data": self.data}
8
+
9
+ def __str__(self):
10
+ return self.get_unified_json()
11
+
12
+ def __repr__(self):
13
+ return self.__str__()
@@ -0,0 +1,285 @@
1
+ import json
2
+ from datetime import date, datetime, time, timedelta
3
+ from urllib.parse import urlparse
4
+
5
+ from .mini_logger import MiniLogger
6
+
7
+ from .constants import (BRAND_NAME, ENVIRONMENT_NAME) # noqa: E402
8
+
9
+ from .validate_environment import (validate_brand_name, # noqa: E402
10
+ validate_environment_name)
11
+
12
+
13
+ RANGE_LENGTH = 2
14
+
15
+
16
+ def timedelta_to_time_format(time_delta: timedelta) -> str:
17
+ """
18
+ Convert a timedelta to a time format in HH:MM:SS.
19
+
20
+ Parameters:
21
+ time_delta (datetime.timedelta): The timedelta to be converted.
22
+
23
+ Returns:
24
+ str: A string in HH:MM:SS format representing the time duration.
25
+
26
+ Example:
27
+ Usage of timedelta_to_time_format:
28
+
29
+ >>> from datetime import timedelta
30
+ >>> duration = timedelta(hours=2, minutes=30, seconds=45)
31
+ >>> formatted_time = timedelta_to_time_format(duration)
32
+ >>> print(formatted_time)
33
+ '02:30:45'
34
+ """
35
+ TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME = "timedelta_to_time_format"
36
+ MiniLogger.start(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME, object={'time_delta': time_delta})
37
+
38
+ # Calculate the total seconds and convert to HH:MM:SS format
39
+ total_seconds = int(time_delta.total_seconds())
40
+ hours = total_seconds // 3600
41
+ minutes = (total_seconds % 3600) // 60
42
+ seconds = total_seconds % 60
43
+
44
+ # Format as "HH:MM:SS"
45
+ formatted_time = f"{hours:02d}:{minutes:02d}:{seconds:02d}"
46
+
47
+ MiniLogger.end(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME,
48
+ object={'formatted_time': formatted_time})
49
+ return formatted_time
50
+
51
+
52
+ def is_valid_time_range(time_range: tuple) -> bool:
53
+ """
54
+ Validate that the time range is in the format 'HH:MM:SS'.
55
+ """
56
+ IS_VALID_TIME_RANGE_METHOD_NAME = "is_valid_time_range"
57
+ MiniLogger.start(IS_VALID_TIME_RANGE_METHOD_NAME, object={
58
+ "time_range": time_range.__str__()})
59
+ if len(time_range) != RANGE_LENGTH:
60
+ MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
61
+ "is_valid_time_range_result": False, "reason": "len(time_range) != 2"})
62
+ return False
63
+
64
+ for time_obj in time_range:
65
+ if not isinstance(time_obj, time):
66
+ MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
67
+ "is_valid_time_range_result": False, "reason": "time_range contains non-time objects"})
68
+ return False
69
+ time_str = time_obj.strftime('%H:%M:%S')
70
+ if time_obj.strftime('%H:%M:%S') != time_str:
71
+ MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
72
+ "is_valid_time_range_result": False, "reason": "time_range contains invalid time format"})
73
+ return False
74
+
75
+ MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
76
+ "is_valid_time_range_result": True})
77
+ return True
78
+
79
+
80
+ def validate_url(url):
81
+ if url is not None or url != "":
82
+ parsed_url = urlparse(url)
83
+ return parsed_url.scheme and parsed_url.netloc
84
+ return True
85
+
86
+
87
+ def is_valid_date_range(date_range: tuple) -> bool:
88
+ """
89
+ Validate that the date range is in the format 'YYYY-MM-DD'.
90
+ """
91
+ IS_VALID_DATE_RANGE_METHOD_NAME = "is_valid_date_range"
92
+ MiniLogger.start(IS_VALID_DATE_RANGE_METHOD_NAME, object={
93
+ "date_range": date_range.__str__()})
94
+ if len(date_range) != RANGE_LENGTH:
95
+ MiniLogger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
96
+ "is_valid_date_range_result": False, "reason": "len(date_range) != 2"})
97
+ return False
98
+
99
+ for date_obj in date_range:
100
+ if not isinstance(date_obj, date):
101
+ MiniLogger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
102
+ "is_valid_date_range_result": False, "reason": "date_range contains non-date objects"})
103
+ return False
104
+ MiniLogger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
105
+ "is_valid_date_range_result": True})
106
+ return True
107
+
108
+
109
+ def is_valid_datetime_range(datetime_range: tuple) -> bool:
110
+ """
111
+ Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
112
+ """
113
+ IS_VALID_DATETIME_RANGE_METHOD_NAME = "is_valid_datetime_range"
114
+ MiniLogger.start(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
115
+ "datetime_range": datetime_range.__str__()})
116
+ if len(datetime_range) != RANGE_LENGTH:
117
+ MiniLogger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
118
+ "is_valid_datetime_range_result": False, "reason": "len(datetime_range) != 2"})
119
+ return False
120
+
121
+ for datetime_obj in datetime_range:
122
+ if not isinstance(datetime_obj, datetime):
123
+ MiniLogger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
124
+ "is_valid_datetime_range_result": False, "reason": "datetime_range contains non-datetime objects"})
125
+ return False
126
+ MiniLogger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
127
+ "is_valid_datetime_range_result": True})
128
+ return True
129
+
130
+
131
+ def is_list_of_dicts(obj):
132
+ """
133
+ Check if an object is a list of dictionaries.
134
+
135
+ Parameters:
136
+ obj (object): The object to be checked.
137
+
138
+ Returns:
139
+ bool: True if the object is a list of dictionaries, False otherwise.
140
+
141
+ Example:
142
+ Usage of is_list_of_dicts:
143
+
144
+ >>> data = [{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]
145
+ >>> result = is_list_of_dicts(data)
146
+ >>> print(result)
147
+ True
148
+
149
+ >>> data = [1, 2, 3]
150
+ >>> result = is_list_of_dicts(data)
151
+ >>> print(result)
152
+ False
153
+ """
154
+ IS_LIST_OF_DICTS_FUNCTION_NAME = "is_list_of_dicts"
155
+ MiniLogger.start(IS_LIST_OF_DICTS_FUNCTION_NAME, object={"obj": obj})
156
+ try:
157
+ if not isinstance(obj, list):
158
+ is_list_of_dicts_result = False
159
+ MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
160
+ "is_list_of_dicts_result": is_list_of_dicts_result})
161
+ return is_list_of_dicts_result
162
+ for item in obj:
163
+ if not isinstance(item, dict):
164
+ is_list_of_dicts_result = False
165
+ MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
166
+ "is_list_of_dicts_result": is_list_of_dicts_result})
167
+ return is_list_of_dicts_result
168
+ is_list_of_dicts_result = True
169
+ MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
170
+ "is_list_of_dicts_result": is_list_of_dicts_result})
171
+ return is_list_of_dicts_result
172
+ except Exception as e:
173
+ MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, exception=e)
174
+ raise e
175
+
176
+
177
+ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
178
+ """
179
+ Check if the given time is within the specified time range.
180
+
181
+ Parameters:
182
+ check_time (str): The time to check in 'HH:MM:SS' format.
183
+ time_range (tuple): A tuple containing start and end times in 'HH:MM:SS' format.
184
+
185
+ Returns:
186
+ bool: True if the check_time is within the time range, False otherwise.
187
+ """
188
+ IS_TIME_IN_TIME_RANGE_METHOD_NAME = "is_time_in_time_range"
189
+ MiniLogger.start(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
190
+ "check_time": check_time.__str__(), "time_range": time_range.__str__()})
191
+ if not is_valid_time_range(time_range) or not isinstance(check_time, time):
192
+ MiniLogger.end(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
193
+ "is_time_in_time_range_result": False})
194
+ return False
195
+ start_time, end_time = time_range
196
+ MiniLogger.end(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
197
+ "is_time_in_time_range_result": start_time <= check_time <= end_time})
198
+ return start_time <= check_time <= end_time
199
+
200
+
201
+ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
202
+ """
203
+ Check if the given date is within the specified date range.
204
+
205
+ Parameters:
206
+ check_date (str): The date to check in 'YYYY-MM-DD' format.
207
+ date_range (tuple): A tuple containing start and end dates in 'YYYY-MM-DD' format.
208
+
209
+ Returns:
210
+ bool: True if the check_date is within the date range, False otherwise.
211
+ """
212
+ IS_DATE_IN_DATE_RANGE_METHOD_NAME = "is_date_in_date_range"
213
+ MiniLogger.start(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
214
+ "check_date": check_date.__str__(), "date_range": date_range.__str__()})
215
+ if not is_valid_date_range(date_range) or not isinstance(check_date, date):
216
+ MiniLogger.end(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
217
+ "is_date_in_date_range_result": False})
218
+ return False
219
+
220
+ start_date, end_date = date_range
221
+ MiniLogger.end(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
222
+ "is_date_in_date_range_result": start_date <= check_date <= end_date})
223
+ return start_date <= check_date <= end_date
224
+
225
+
226
+ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: tuple) -> bool:
227
+ """
228
+ Check if the given datetime is within the specified datetime range.
229
+
230
+ Parameters:
231
+ check_datetime (str): The datetime to check in 'YYYY-MM-DD HH:MM:SS' format.
232
+ datetime_range (tuple): A tuple containing start and end datetimes in 'YYYY-MM-DD HH:MM:SS' format.
233
+
234
+ Returns:
235
+ bool: True if the check_datetime is within the datetime range, False otherwise.
236
+ """
237
+ IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME = "is_datetime_in_datetime_range"
238
+ MiniLogger.start(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME)
239
+ if not is_valid_datetime_range(datetime_range) or not isinstance(check_datetime, datetime):
240
+ MiniLogger.end(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME, object={
241
+ "is_valid_datetime_range": False})
242
+ return False
243
+
244
+ start_datetime, end_datetime = datetime_range
245
+ is_datetime_in_datetime_range_result = start_datetime <= check_datetime <= end_datetime
246
+ MiniLogger.end(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME, object={
247
+ "is_datetime_in_datetime_range_result": is_datetime_in_datetime_range_result})
248
+ return is_datetime_in_datetime_range_result
249
+
250
+
251
+ # 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 # noqa501
252
+ # TODO Take those three functions to a separate file http_response.py
253
+ # TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
254
+
255
+ # Former name was create_http_headers()
256
+ def create_authorization_http_headers(user_jwt: str):
257
+ http_headers = {
258
+ 'Content-Type': 'application/json',
259
+ 'Authorization': f'Bearer {user_jwt}',
260
+ }
261
+ return http_headers
262
+
263
+
264
+ def create_return_http_headers():
265
+ return {
266
+ "Content-Type": "application/json",
267
+ "Access-Control-Allow-Origin": "*",
268
+ }
269
+
270
+
271
+ # https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format
272
+ def create_http_body(body):
273
+ # TODO console.warning() if the body is not a valid camelCase JSON
274
+ # https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
275
+ return json.dumps(body)
276
+
277
+
278
+ def get_brand_name():
279
+ validate_brand_name()
280
+ return BRAND_NAME
281
+
282
+
283
+ def get_environment_name():
284
+ validate_environment_name()
285
+ return ENVIRONMENT_NAME
@@ -0,0 +1,42 @@
1
+ from .constants import BRAND_NAME, ENVIRONMENT_NAME, LOGZIO_TOKEN, GOOGLE_PORT_FOR_AUTHENTICATION
2
+
3
+
4
+ # TODO Align with https://github.com/circles-zone/typescript-sdk-remote-typescript-package/edit/dev/typescript-sdk/src/utils/index.ts validateTenantEnvironmentVariables() # noqa501
5
+ def validate_enviroment_variables():
6
+ validate_brand_name()
7
+ validate_environment_name()
8
+ # if(os.getenv("PRODUCT_USER_IDENTIFIER") is None):
9
+ # raise Exception("logger-local-python-package LoggerLocal.py please add Environment Variable called "
10
+ # "PRODUCT_USER_IDENTIFIER (instead of PRODUCT_USERNAME)")
11
+ # removed by Idan because it dont has to be in every project
12
+ #TODO Shall we push those commented lines of code to the repo?
13
+ # if(os.getenv("PRODUCT_PASSWORD") is None):
14
+ # raise Exception("logger-local-python-package LoggerLocal.py please add Environment Variable called PRODUCT_PASSWORD")
15
+ validate_logzio_token()
16
+ validate_google_port_for_authentication()
17
+
18
+
19
+ def validate_environment_name():
20
+ if ENVIRONMENT_NAME is None:
21
+ raise Exception("logger-local-python-package LoggerLocal.py please add Environment Variable called "
22
+ "ENVIRONMENT_NAME=local or play1 (instead of ENVIRONMENT)")
23
+
24
+
25
+ def validate_brand_name():
26
+ if BRAND_NAME is None:
27
+ raise Exception(
28
+ "logger-local-python-package LoggerLocal.py please add Environment Variable called BRAND_NAME=Circlez")
29
+
30
+
31
+ def validate_logzio_token():
32
+ if LOGZIO_TOKEN is None:
33
+ raise Exception("logger-local-python-package LoggerLocal.py please add Environment Variable called"
34
+ " LOGZIO_TOKEN=cXNHuVkkffkilnkKzZlWExECRlSKqopE")
35
+
36
+
37
+ def validate_google_port_for_authentication():
38
+ if GOOGLE_PORT_FOR_AUTHENTICATION is None:
39
+ # The port is 54219 because the authentication url is http://localhost:54219/
40
+ raise Exception("please add Environment Variable"
41
+ " PORT_FOR_AUTHENTICATION=54219 because"
42
+ " the authentication url is http://localhost:54219/")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.68
3
+ Version: 0.0.69
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
@@ -9,5 +9,6 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: Other/Proprietary License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
+ Requires-Dist: python-dotenv
12
13
 
13
14
  This is a package for sharing common functions used in different repositories
@@ -0,0 +1,16 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ python_sdk_remote.egg-info/PKG-INFO
5
+ python_sdk_remote.egg-info/SOURCES.txt
6
+ python_sdk_remote.egg-info/dependency_links.txt
7
+ python_sdk_remote.egg-info/requires.txt
8
+ python_sdk_remote.egg-info/top_level.txt
9
+ python_sdk_remote/src/__init__.py
10
+ python_sdk_remote/src/constants.py
11
+ python_sdk_remote/src/item.py
12
+ python_sdk_remote/src/mini_logger.py
13
+ python_sdk_remote/src/our_object.py
14
+ python_sdk_remote/src/unified_json.py
15
+ python_sdk_remote/src/utilities.py
16
+ python_sdk_remote/src/validate_environment.py
@@ -0,0 +1 @@
1
+ python_sdk_remote
@@ -0,0 +1,28 @@
1
+ import setuptools
2
+
3
+ PACKAGE_NAME = "python-sdk-remote"
4
+ package_dir = PACKAGE_NAME.replace("-", "_")
5
+
6
+ # used by python -m build
7
+ # python -m build needs pyproject.toml or setup.py
8
+ setuptools.setup(
9
+ name=PACKAGE_NAME,
10
+ version='0.0.69', # https://pypi.org/project/python-sdk-remote/
11
+ author="Circles",
12
+ author_email="info@circles.life",
13
+ description="PyPI Package for Circles Python SDK Local Python",
14
+ long_description="This is a package for sharing common functions used in different repositories",
15
+ long_description_content_type="text/markdown",
16
+ url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
17
+ packages=[package_dir],
18
+ package_dir={package_dir: f'{package_dir}/src'},
19
+ package_data={package_dir: ['*.py']},
20
+ classifiers=[
21
+ "Programming Language :: Python :: 3",
22
+ "License :: Other/Proprietary License",
23
+ "Operating System :: OS Independent",
24
+ ],
25
+ install_requires=[
26
+ "python-dotenv"
27
+ ]
28
+ )
@@ -1,7 +0,0 @@
1
- README.md
2
- pyproject.toml
3
- setup.py
4
- python_sdk_remote.egg-info/PKG-INFO
5
- python_sdk_remote.egg-info/SOURCES.txt
6
- python_sdk_remote.egg-info/dependency_links.txt
7
- python_sdk_remote.egg-info/top_level.txt
@@ -1,20 +0,0 @@
1
- import setuptools
2
-
3
- # used by python -m build
4
- # python -m build needs pyproject.toml or setup.py
5
- setuptools.setup(
6
- name='python-sdk-remote',
7
- version='0.0.68', # https://pypi.org/project/python-sdk-remote/
8
- author="Circles",
9
- author_email="info@circles.life",
10
- description="PyPI Package for Circles Python SDK Local Python",
11
- long_description="This is a package for sharing common functions used in different repositories",
12
- long_description_content_type="text/markdown",
13
- url="https://github.com/circles-zone/python-sdk-remote-python-package",
14
- packages=setuptools.find_packages(),
15
- classifiers=[
16
- "Programming Language :: Python :: 3",
17
- "License :: Other/Proprietary License",
18
- "Operating System :: OS Independent",
19
- ],
20
- )