python-sdk-remote 0.0.70__tar.gz → 0.0.72__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.70 → python-sdk-remote-0.0.72}/PKG-INFO +2 -1
  2. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/README.md +7 -4
  3. python-sdk-remote-0.0.72/pyproject.toml +18 -0
  4. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote/src/mini_logger.py +9 -9
  5. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote/src/our_object.py +17 -9
  6. python-sdk-remote-0.0.72/python_sdk_remote/src/unified_json.py +27 -0
  7. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote/src/utilities.py +65 -48
  8. python-sdk-remote-0.0.72/python_sdk_remote/src/valid_json_versions.py +4 -0
  9. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote.egg-info/PKG-INFO +2 -1
  10. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote.egg-info/SOURCES.txt +1 -2
  11. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote.egg-info/requires.txt +1 -0
  12. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/setup.py +4 -3
  13. python-sdk-remote-0.0.70/pyproject.toml +0 -12
  14. python-sdk-remote-0.0.70/python_sdk_remote/src/constants.py +0 -20
  15. python-sdk-remote-0.0.70/python_sdk_remote/src/unified_json.py +0 -13
  16. python-sdk-remote-0.0.70/python_sdk_remote/src/validate_environment.py +0 -42
  17. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote/src/__init__.py +0 -0
  18. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote/src/item.py +0 -0
  19. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  20. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/python_sdk_remote.egg-info/top_level.txt +0 -0
  21. {python-sdk-remote-0.0.70 → python-sdk-remote-0.0.72}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.70
3
+ Version: 0.0.72
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
@@ -10,5 +10,6 @@ Classifier: License :: Other/Proprietary License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: python-dotenv
13
+ Requires-Dist: url-remote
13
14
 
14
15
  This is a package for sharing common functions used in different repositories
@@ -1,21 +1,24 @@
1
1
  # python-package-backend-template
2
+
2
3
  To create local package and remote package layers (not to create GraphQL and REST-API layers)
3
4
 
4
5
  #database Python scripts in /db folder
5
6
  Please place <table-name>.py in /db<br>
6
7
  No need for seperate file for _ml table<br>
7
8
  Please delete the example file if not needed<br>
8
-
9
+
9
10
  # Create the files to create the database schema, tables, view and populate Meta Data and Test Date
11
+
10
12
  /db/<table-name>.py - CREATE SCHEMA ... CREATE TABLE ... CREATE VIEW ...<br>
11
13
  /db/<table-name>_insert.py to create records
12
14
 
13
15
  # Update the setup.py (i.e.name, version)
14
-
16
+
15
17
  # Please create test directory inside the directory of the project i.e. /<project-name>/tests
16
18
 
17
19
  # Update the serverless.yml in the root directory
20
+
18
21
  provider:
19
- stage: play1
20
-
22
+ stage: play1
23
+
21
24
  Update the endpoints in serverless.yml
@@ -0,0 +1,18 @@
1
+ # This file should be in the future instead of setup.py
2
+ # https://python-poetry.org/docs/pyproject
3
+
4
+ # It seems we need to copy this file also to serverless-com repo, as required by dialog-workflow-python-package
5
+
6
+ [build-system]
7
+ requires = ["setuptools>=61.0"]
8
+ build-backend = "setuptools.build_meta"
9
+
10
+ [tool.poetry]
11
+ name = "python-sdk-local"
12
+ # I believe we are still using the version from setup.py and not from here until potery will work
13
+ version = "0.0.1" # https://pypi.org/project/python-sdk-local i.e. https://pypi.org/project/storage-local/
14
+ description = "python-sdk-local Python Package"
15
+ readme = "README.md"
16
+ authors = [
17
+ "Circlez.ai <info@circlez.ai>",
18
+ ]
@@ -17,7 +17,7 @@ class MiniLogger:
17
17
  if object is None:
18
18
  print(f"{datetime.now()} - START - {message}")
19
19
  else:
20
- print(f"{datetime.now()} - START - {message} - {str(object)}")
20
+ print(f"{datetime.now()} - START - {message} - {object}")
21
21
 
22
22
  @staticmethod
23
23
  def end(message: str = "", object: dict = None):
@@ -30,7 +30,7 @@ class MiniLogger:
30
30
  if object is None:
31
31
  print(f"{datetime.now()} - END - {message}")
32
32
  else:
33
- print(f"{datetime.now()} - END - {message} - {str(object)}")
33
+ print(f"{datetime.now()} - END - {message} - {object}")
34
34
 
35
35
  @staticmethod
36
36
  def info(message: str = "", object: dict = None):
@@ -44,7 +44,7 @@ class MiniLogger:
44
44
  if object is None:
45
45
  print(f"{datetime.now()} - INFO - {message}")
46
46
  else:
47
- print(f"{datetime.now()} - INFO {message} - {str(object)}")
47
+ print(f"{datetime.now()} - INFO {message} - {object}")
48
48
 
49
49
  @staticmethod
50
50
  def warning(message: str = "", object: dict = None):
@@ -58,7 +58,7 @@ class MiniLogger:
58
58
  if object is None:
59
59
  print(f"{datetime.now()} - WARNING - {message}")
60
60
  else:
61
- print(f"{datetime.now()} - WARNING {message} - {str(object)}")
61
+ print(f"{datetime.now()} - WARNING {message} - {object}")
62
62
 
63
63
  @staticmethod
64
64
  def error(message: str = "", object: dict = None):
@@ -70,22 +70,22 @@ class MiniLogger:
70
70
  object (dict): The object to be printed.
71
71
  """
72
72
  if object is None:
73
- print(f"{datetime.now()} - ERROR - {message}", file=sys.stderr)
73
+ print(f"{datetime.now()} - ERROR - {message}", file=sys.stderr)
74
74
  else:
75
75
  print(
76
- f"{datetime.now()} - ERROR - {message} - {str(object)}", file=sys.stderr)
76
+ f"{datetime.now()} - ERROR - {message} - {object}", file=sys.stderr)
77
77
 
78
78
  @staticmethod
79
- def exception(message: str = "", object: dict = None):
79
+ def exception(message: str = "", object: Exception | dict = None):
80
80
  """
81
81
  Print a log error message with the current time.
82
82
 
83
83
  Parameters:
84
84
  message (str): The message to be printed.
85
- object (dict): The object to be printed.
85
+ object (dict / Exception): The object / Exception to be printed.
86
86
  """
87
87
  if object is None:
88
88
  print(f"{datetime.now()} - EXCEPTION - {message}", file=sys.stderr)
89
89
  else:
90
90
  print(
91
- f"{datetime.now()} - EXCEPTION- {message} - {str(object)}", file=sys.stderr)
91
+ f"{datetime.now()} - EXCEPTION- {message} - {object}", file=sys.stderr)
@@ -1,48 +1,56 @@
1
1
  import json
2
2
  from abc import ABC, abstractmethod
3
3
 
4
- from .mini_logger import MiniLogger
4
+ from .mini_logger import MiniLogger as logger
5
5
 
6
6
 
7
+ # TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
7
8
  class OurObject(ABC):
8
9
  def __init__(self, **kwargs):
9
10
  INIT_METHOD_NAME = '__init__'
10
- MiniLogger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
11
+ logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
11
12
  self.kwargs = kwargs
12
- MiniLogger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
13
+ logger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
13
14
 
14
15
  @abstractmethod
15
16
  def get_name(self):
17
+ """Returns the name of the object"""
16
18
  raise NotImplementedError(
17
19
  "Subclasses must implement the 'get_name' method.")
18
20
 
19
21
  def get(self, attr_name: str):
22
+ """Returns the value of the attribute with the given name"""
20
23
  GET_METHOD_NAME = 'get'
21
- MiniLogger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
24
+ logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
22
25
  arguments = getattr(self, 'kwargs', None)
23
26
  value = arguments.get(attr_name, None)
24
- MiniLogger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
27
+ logger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
25
28
  return value
26
29
 
27
30
  def get_all_arguments(self):
31
+ """Returns all the arguments passed to the constructor as a dictionary"""
28
32
  return getattr(self, 'kwargs', None)
29
33
 
30
34
  def to_json(self) -> str:
35
+ """Returns a json string representation of this object"""
31
36
  return json.dumps(self.__dict__)
32
37
 
33
38
  def from_json(self, json_string: str) -> 'OurObject':
39
+ """Returns an instance of the class from a json string"""
34
40
  FROM_JSON_METHOD_NAME = 'from_json'
35
- MiniLogger.start(FROM_JSON_METHOD_NAME,
36
- object={'json_string': json_string})
41
+ logger.start(FROM_JSON_METHOD_NAME,
42
+ object={'json_string': json_string})
37
43
  self.__dict__ = json.loads(json_string)
38
- MiniLogger.end(FROM_JSON_METHOD_NAME,
39
- object={'json_dict': self.__dict__})
44
+ logger.end(FROM_JSON_METHOD_NAME,
45
+ object={'json_dict': self.__dict__})
40
46
  return self
41
47
 
42
48
  def __eq__(self, other) -> bool:
49
+ """Checks if two objects are equal"""
43
50
  if not isinstance(other, OurObject):
44
51
  return False
45
52
  return self.__dict__ == other.__dict__
46
53
 
47
54
  def __ne__(self, other) -> bool:
55
+ """Checks if two objects are not equal"""
48
56
  return not self.__eq__(other)
@@ -0,0 +1,27 @@
1
+ from .valid_json_versions import valid_json_versions
2
+
3
+
4
+ class UnifiedJson:
5
+ def __init__(self, data: dict, json_version: str):
6
+ if json_version not in valid_json_versions:
7
+ raise Exception(
8
+ f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
9
+ f"please make sure you run sql2code."
10
+ )
11
+ self.json_version = json_version
12
+ self.data = data
13
+
14
+ def get_unified_json(self):
15
+ return {"version": self.json_version, "data": self.data}
16
+
17
+ def get_data(self):
18
+ return self.data
19
+
20
+ def get_json_version(self):
21
+ return self.json_version
22
+
23
+ def __str__(self):
24
+ return self.get_unified_json()
25
+
26
+ def __repr__(self):
27
+ return self.__str__()
@@ -1,16 +1,13 @@
1
1
  import json
2
+ import os
2
3
  from datetime import date, datetime, time, timedelta
3
4
  from urllib.parse import urlparse
5
+ from url_remote.environment_name_enum import EnvironmentName
4
6
 
5
- from .mini_logger import MiniLogger
7
+ from dotenv import load_dotenv
6
8
 
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
9
+ from .mini_logger import MiniLogger as logger
10
+ load_dotenv()
14
11
 
15
12
 
16
13
  def timedelta_to_time_format(time_delta: timedelta) -> str:
@@ -30,10 +27,10 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
30
27
  >>> duration = timedelta(hours=2, minutes=30, seconds=45)
31
28
  >>> formatted_time = timedelta_to_time_format(duration)
32
29
  >>> print(formatted_time)
33
- '02:30:45'
30
+ "02:30:45"
34
31
  """
35
32
  TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME = "timedelta_to_time_format"
36
- MiniLogger.start(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME, object={'time_delta': time_delta})
33
+ logger.start(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME, object={'time_delta': time_delta})
37
34
 
38
35
  # Calculate the total seconds and convert to HH:MM:SS format
39
36
  total_seconds = int(time_delta.total_seconds())
@@ -44,8 +41,8 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
44
41
  # Format as "HH:MM:SS"
45
42
  formatted_time = f"{hours:02d}:{minutes:02d}:{seconds:02d}"
46
43
 
47
- MiniLogger.end(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME,
48
- object={'formatted_time': formatted_time})
44
+ logger.end(TIMEDELTA_TO_TIME_FORMAT_METHOD_NAME,
45
+ object={'formatted_time': formatted_time})
49
46
  return formatted_time
50
47
 
51
48
 
@@ -54,25 +51,25 @@ def is_valid_time_range(time_range: tuple) -> bool:
54
51
  Validate that the time range is in the format 'HH:MM:SS'.
55
52
  """
56
53
  IS_VALID_TIME_RANGE_METHOD_NAME = "is_valid_time_range"
57
- MiniLogger.start(IS_VALID_TIME_RANGE_METHOD_NAME, object={
54
+ logger.start(IS_VALID_TIME_RANGE_METHOD_NAME, object={
58
55
  "time_range": time_range.__str__()})
59
- if len(time_range) != RANGE_LENGTH:
60
- MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
56
+ if len(time_range) != 2:
57
+ logger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
61
58
  "is_valid_time_range_result": False, "reason": "len(time_range) != 2"})
62
59
  return False
63
60
 
64
61
  for time_obj in time_range:
65
62
  if not isinstance(time_obj, time):
66
- MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
63
+ logger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
67
64
  "is_valid_time_range_result": False, "reason": "time_range contains non-time objects"})
68
65
  return False
69
66
  time_str = time_obj.strftime('%H:%M:%S')
70
67
  if time_obj.strftime('%H:%M:%S') != time_str:
71
- MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
68
+ logger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
72
69
  "is_valid_time_range_result": False, "reason": "time_range contains invalid time format"})
73
70
  return False
74
71
 
75
- MiniLogger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
72
+ logger.end(IS_VALID_TIME_RANGE_METHOD_NAME, object={
76
73
  "is_valid_time_range_result": True})
77
74
  return True
78
75
 
@@ -89,19 +86,19 @@ def is_valid_date_range(date_range: tuple) -> bool:
89
86
  Validate that the date range is in the format 'YYYY-MM-DD'.
90
87
  """
91
88
  IS_VALID_DATE_RANGE_METHOD_NAME = "is_valid_date_range"
92
- MiniLogger.start(IS_VALID_DATE_RANGE_METHOD_NAME, object={
89
+ logger.start(IS_VALID_DATE_RANGE_METHOD_NAME, object={
93
90
  "date_range": date_range.__str__()})
94
- if len(date_range) != RANGE_LENGTH:
95
- MiniLogger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
91
+ if len(date_range) != 2:
92
+ logger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
96
93
  "is_valid_date_range_result": False, "reason": "len(date_range) != 2"})
97
94
  return False
98
95
 
99
96
  for date_obj in date_range:
100
97
  if not isinstance(date_obj, date):
101
- MiniLogger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
98
+ logger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
102
99
  "is_valid_date_range_result": False, "reason": "date_range contains non-date objects"})
103
100
  return False
104
- MiniLogger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
101
+ logger.end(IS_VALID_DATE_RANGE_METHOD_NAME, object={
105
102
  "is_valid_date_range_result": True})
106
103
  return True
107
104
 
@@ -111,19 +108,19 @@ def is_valid_datetime_range(datetime_range: tuple) -> bool:
111
108
  Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
112
109
  """
113
110
  IS_VALID_DATETIME_RANGE_METHOD_NAME = "is_valid_datetime_range"
114
- MiniLogger.start(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
111
+ logger.start(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
115
112
  "datetime_range": datetime_range.__str__()})
116
- if len(datetime_range) != RANGE_LENGTH:
117
- MiniLogger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
113
+ if len(datetime_range) != 2:
114
+ logger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
118
115
  "is_valid_datetime_range_result": False, "reason": "len(datetime_range) != 2"})
119
116
  return False
120
117
 
121
118
  for datetime_obj in datetime_range:
122
119
  if not isinstance(datetime_obj, datetime):
123
- MiniLogger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
120
+ logger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
124
121
  "is_valid_datetime_range_result": False, "reason": "datetime_range contains non-datetime objects"})
125
122
  return False
126
- MiniLogger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
123
+ logger.end(IS_VALID_DATETIME_RANGE_METHOD_NAME, object={
127
124
  "is_valid_datetime_range_result": True})
128
125
  return True
129
126
 
@@ -152,26 +149,27 @@ def is_list_of_dicts(obj):
152
149
  False
153
150
  """
154
151
  IS_LIST_OF_DICTS_FUNCTION_NAME = "is_list_of_dicts"
155
- MiniLogger.start(IS_LIST_OF_DICTS_FUNCTION_NAME, object={"obj": obj})
152
+ logger.start(IS_LIST_OF_DICTS_FUNCTION_NAME, object={"obj": obj})
156
153
  try:
157
154
  if not isinstance(obj, list):
158
155
  is_list_of_dicts_result = False
159
- MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
156
+ logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
160
157
  "is_list_of_dicts_result": is_list_of_dicts_result})
161
158
  return is_list_of_dicts_result
162
159
  for item in obj:
163
160
  if not isinstance(item, dict):
164
161
  is_list_of_dicts_result = False
165
- MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
162
+ logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
166
163
  "is_list_of_dicts_result": is_list_of_dicts_result})
167
164
  return is_list_of_dicts_result
168
165
  is_list_of_dicts_result = True
169
- MiniLogger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
166
+ logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME, object={
170
167
  "is_list_of_dicts_result": is_list_of_dicts_result})
171
168
  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
169
+ except Exception as exception:
170
+ logger.exception(IS_LIST_OF_DICTS_FUNCTION_NAME, exception)
171
+ logger.end(IS_LIST_OF_DICTS_FUNCTION_NAME)
172
+ raise
175
173
 
176
174
 
177
175
  def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
@@ -186,14 +184,14 @@ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
186
184
  bool: True if the check_time is within the time range, False otherwise.
187
185
  """
188
186
  IS_TIME_IN_TIME_RANGE_METHOD_NAME = "is_time_in_time_range"
189
- MiniLogger.start(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
187
+ logger.start(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
190
188
  "check_time": check_time.__str__(), "time_range": time_range.__str__()})
191
189
  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={
190
+ logger.end(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
193
191
  "is_time_in_time_range_result": False})
194
192
  return False
195
193
  start_time, end_time = time_range
196
- MiniLogger.end(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
194
+ logger.end(IS_TIME_IN_TIME_RANGE_METHOD_NAME, object={
197
195
  "is_time_in_time_range_result": start_time <= check_time <= end_time})
198
196
  return start_time <= check_time <= end_time
199
197
 
@@ -210,15 +208,15 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
210
208
  bool: True if the check_date is within the date range, False otherwise.
211
209
  """
212
210
  IS_DATE_IN_DATE_RANGE_METHOD_NAME = "is_date_in_date_range"
213
- MiniLogger.start(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
211
+ logger.start(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
214
212
  "check_date": check_date.__str__(), "date_range": date_range.__str__()})
215
213
  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={
214
+ logger.end(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
217
215
  "is_date_in_date_range_result": False})
218
216
  return False
219
217
 
220
218
  start_date, end_date = date_range
221
- MiniLogger.end(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
219
+ logger.end(IS_DATE_IN_DATE_RANGE_METHOD_NAME, object={
222
220
  "is_date_in_date_range_result": start_date <= check_date <= end_date})
223
221
  return start_date <= check_date <= end_date
224
222
 
@@ -235,15 +233,15 @@ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: tupl
235
233
  bool: True if the check_datetime is within the datetime range, False otherwise.
236
234
  """
237
235
  IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME = "is_datetime_in_datetime_range"
238
- MiniLogger.start(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME)
236
+ logger.start(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME)
239
237
  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={
238
+ logger.end(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME, object={
241
239
  "is_valid_datetime_range": False})
242
240
  return False
243
241
 
244
242
  start_datetime, end_datetime = datetime_range
245
243
  is_datetime_in_datetime_range_result = start_datetime <= check_datetime <= end_datetime
246
- MiniLogger.end(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME, object={
244
+ logger.end(IS_DATETIME_IN_DATETIME_RANGE_METHOD_NAME, object={
247
245
  "is_datetime_in_datetime_range_result": is_datetime_in_datetime_range_result})
248
246
  return is_datetime_in_datetime_range_result
249
247
 
@@ -276,10 +274,29 @@ def create_http_body(body):
276
274
 
277
275
 
278
276
  def get_brand_name():
279
- validate_brand_name()
280
- return BRAND_NAME
277
+ return our_get_env("BRAND_NAME")
281
278
 
282
279
 
283
280
  def get_environment_name():
284
- validate_environment_name()
285
- return ENVIRONMENT_NAME
281
+ environment_name = our_get_env("ENVIRONMENT_NAME")
282
+ EnvironmentName(environment_name) # if invalid, raises ValueError: x is not a valid EnvironmentName
283
+ return environment_name
284
+
285
+
286
+ def our_get_env(key: str, default: str = None, raise_if_not_found: bool = True) -> str:
287
+ result = os.getenv(key, default)
288
+ if raise_if_not_found and result is None:
289
+ raise Exception(f"Environment variable {key} not found")
290
+ return result
291
+
292
+
293
+ def get_sql_hostname() -> str:
294
+ return our_get_env("RDS_HOSTNAME")
295
+
296
+
297
+ def get_sql_username() -> str:
298
+ return our_get_env("RDS_USERNAME")
299
+
300
+
301
+ def get_sql_password() -> str:
302
+ return our_get_env("RDS_PASSWORD")
@@ -0,0 +1,4 @@
1
+ # Later we'll generate this file using Sql2Code (from json_version database schema)
2
+ valid_json_versions = {
3
+ "240109": "Description"
4
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.70
3
+ Version: 0.0.72
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
@@ -10,5 +10,6 @@ Classifier: License :: Other/Proprietary License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: python-dotenv
13
+ Requires-Dist: url-remote
13
14
 
14
15
  This is a package for sharing common functions used in different repositories
@@ -7,10 +7,9 @@ python_sdk_remote.egg-info/dependency_links.txt
7
7
  python_sdk_remote.egg-info/requires.txt
8
8
  python_sdk_remote.egg-info/top_level.txt
9
9
  python_sdk_remote/src/__init__.py
10
- python_sdk_remote/src/constants.py
11
10
  python_sdk_remote/src/item.py
12
11
  python_sdk_remote/src/mini_logger.py
13
12
  python_sdk_remote/src/our_object.py
14
13
  python_sdk_remote/src/unified_json.py
15
14
  python_sdk_remote/src/utilities.py
16
- python_sdk_remote/src/validate_environment.py
15
+ 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.70', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.72', # https://pypi.org/project/python-sdk-remote/
11
11
  author="Circles",
12
12
  author_email="info@circles.life",
13
13
  description="PyPI Package for Circles Python SDK Local Python",
@@ -23,6 +23,7 @@ setuptools.setup(
23
23
  "Operating System :: OS Independent",
24
24
  ],
25
25
  install_requires=[
26
- "python-dotenv"
26
+ "python-dotenv",
27
+ "url-remote"
27
28
  ]
28
- )
29
+ )
@@ -1,12 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [tool.poetry]
6
- name = "python-sdk-local"
7
- version = "0.0.70" # https://pypi.org/project/python-sdk-local
8
- description = "python-sdk-local Python Package"
9
- readme = "README.md"
10
- authors = [
11
- "Circlez.ai <info@circlez.ai>",
12
- ]
@@ -1,20 +0,0 @@
1
- import os
2
-
3
- PYTHON_SDK_LOCAL_COMPONENT_ID = 184
4
- PYTHON_SDK_LOCAL_COMPONENT_NAME = 'python_sdk_local'
5
-
6
- ENVIRONMENT_NAME = os.getenv("ENVIRONMENT_NAME")
7
- BRAND_NAME = os.getenv("BRAND_NAME")
8
- LOGZIO_TOKEN = os.getenv("LOGZIO_TOKEN")
9
- # TODO Shall Can we use python-sdk function to get the value from Environment?
10
- # TODO Shall we get the value from environment here of send the value to the function as @akiva-skolnik did?
11
- GOOGLE_PORT_FOR_AUTHENTICATION = os.getenv("PORT_FOR_AUTHENTICATION")
12
-
13
- # dummy jwt for testing
14
- TEST_USER_JWT = (
15
- 'eyJhbGciObJIUzI1NiIsImR5cCI4DkpXWCJ9.'
16
- 'eyJlbWFpbCI6ImR1bW15QGVtYWlsLmNvbSIsInVzZXJJZCI'
17
- '6IjEyMzQ1Njc4IiwicHJvZmlsZUlkIjoiMTIzNDU2NzgiLCJy'
18
- 'b2xlcyI6WyJVU0VSIl0sImlhdCI6MTYxNTI0ODQ2MSwiZXhwIjoxNjE1MjUyMDYxfQ.'
19
- 'SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
20
- )
@@ -1,13 +0,0 @@
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__()
@@ -1,42 +0,0 @@
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/")