python-sdk-local 0.0.144__tar.gz → 0.0.146__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.
Files changed (20) hide show
  1. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/PKG-INFO +1 -1
  2. python_sdk_local-0.0.146/python_sdk_local/src/service_response.py +55 -0
  3. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/unified_json.py +0 -1
  4. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/utilities.py +8 -7
  5. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local.egg-info/PKG-INFO +1 -1
  6. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local.egg-info/SOURCES.txt +1 -0
  7. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/setup.py +1 -1
  8. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/README.md +0 -0
  9. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/pyproject.toml +0 -0
  10. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/__init__.py +0 -0
  11. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/constants.py +0 -0
  12. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/http_response.py +0 -0
  13. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/item.py +0 -0
  14. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/our_object.py +0 -0
  15. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/valid_json_versions.py +0 -0
  16. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local/src/validate_environment.py +0 -0
  17. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local.egg-info/dependency_links.txt +0 -0
  18. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local.egg-info/requires.txt +0 -0
  19. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/python_sdk_local.egg-info/top_level.txt +0 -0
  20. {python_sdk_local-0.0.144 → python_sdk_local-0.0.146}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sdk-local
3
- Version: 0.0.144
3
+ Version: 0.0.146
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
@@ -0,0 +1,55 @@
1
+ import copy
2
+
3
+
4
+ # TODO: move to python-sdk
5
+ class ServiceResponse:
6
+ """
7
+ A class to represent a service response.
8
+ """
9
+
10
+ def __init__(
11
+ self,
12
+ message_internal: dict,
13
+ message_external: dict,
14
+ is_success: bool = False,
15
+ data: dict = None,
16
+ ):
17
+ """
18
+ Initializes the ServiceResponse instance.
19
+
20
+ :param status_code: HTTP status code of the response.
21
+ :param message: Message describing the response.
22
+ :param data: Optional data to be included in the response.
23
+ """
24
+ # self.status_code = status_code
25
+
26
+ self.message = copy.deepcopy(message_internal)
27
+ self.message_internal_english = message_internal
28
+ # self.message_external_ml = {"en": message_external, "he": message_external}
29
+
30
+ if isinstance(message_external, dict) and (
31
+ "en" in message_external or "he" in message_external
32
+ ):
33
+ self.message_external_ml = message_external
34
+ else:
35
+ # Original behavior for string input
36
+ self.message_external_ml = {"en": message_external, "he": message_external}
37
+
38
+ self.is_success = is_success
39
+ self.data = copy.deepcopy(data) if data else {}
40
+
41
+ def to_http_response(self) -> dict:
42
+ """
43
+ Converts the ServiceResponse instance to a dictionary format suitable for HTTP response.
44
+
45
+ :return: A dictionary representation of the ServiceResponse instance.
46
+ """
47
+ http_response = {
48
+ # "statusCode": self.status_code,
49
+ "message": self.message,
50
+ "messageInternal": self.message_internal_english,
51
+ "messageExternalMl": self.message_external_ml,
52
+ "isSuccess": self.is_success,
53
+ "data": self.data if self.data else {},
54
+ }
55
+ return http_response
@@ -2,7 +2,6 @@ from .valid_json_versions import valid_json_versions
2
2
  from logger_local.MetaLogger import MetaLogger
3
3
 
4
4
 
5
- #
6
5
  # TODO Shall we merge it with the machine-learning-unified-json?
7
6
  class UnifiedJson(metaclass=MetaLogger):
8
7
  def __init__(self, data: dict, json_version: str):
@@ -1,4 +1,4 @@
1
- import inspect
1
+ import inspect # noqa
2
2
  import json
3
3
  import os
4
4
  import random
@@ -35,7 +35,7 @@ def append_if_not_exist(lst: list, item: object) -> None:
35
35
  lst.append(item)
36
36
 
37
37
 
38
- def to_dict(data: json or dict or None) -> dict:
38
+ def to_dict(data: dict | None) -> dict:
39
39
  if data is None:
40
40
  return {}
41
41
  if isinstance(data, dict):
@@ -43,11 +43,12 @@ def to_dict(data: json or dict or None) -> dict:
43
43
  return json.loads(data)
44
44
 
45
45
 
46
- def to_json(data: json or dict or None) -> json:
46
+ def to_json(data: dict | None) -> json:
47
47
  if data is None:
48
48
  data = {}
49
49
  if isinstance(data, dict):
50
- return json.dumps(data)
50
+ json_data = json.dumps(data, default=str)
51
+ return json_data
51
52
  return data
52
53
 
53
54
 
@@ -142,7 +143,7 @@ def is_valid_date_range(date_range: tuple) -> bool:
142
143
  return True
143
144
 
144
145
 
145
- def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
146
+ def is_valid_datetime_range(datetime_range: tuple[datetime, datetime]) -> bool:
146
147
  """
147
148
  Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
148
149
  """
@@ -250,7 +251,7 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
250
251
  return start_date <= check_date <= end_date
251
252
 
252
253
 
253
- def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (datetime, datetime)) -> bool:
254
+ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: tuple[datetime, datetime]) -> bool:
254
255
  """
255
256
  Check if the given datetime is within the specified datetime range.
256
257
 
@@ -334,7 +335,7 @@ def reformat_time_string(input_str: str) -> str:
334
335
  minutes = "00" if len(input_str) < 4 else input_str[2:4]
335
336
  seconds = "00" if len(input_str) < 6 else input_str[4:6]
336
337
  milliseconds = "00" if len(input_str) < 8 else input_str[6:8]
337
- # TODO Shall we use DEFAULT_DATETIME_FORMAT and have the formats in the central
338
+ # TODO Shall we use DEFAULT_DATETIME_FORMAT and have the formats in the central
338
339
  time_format = f"{hours}:{minutes}:{seconds}:{milliseconds}"
339
340
  return time_format
340
341
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sdk-local
3
- Version: 0.0.144
3
+ Version: 0.0.146
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
@@ -11,6 +11,7 @@ python_sdk_local/src/constants.py
11
11
  python_sdk_local/src/http_response.py
12
12
  python_sdk_local/src/item.py
13
13
  python_sdk_local/src/our_object.py
14
+ python_sdk_local/src/service_response.py
14
15
  python_sdk_local/src/unified_json.py
15
16
  python_sdk_local/src/utilities.py
16
17
  python_sdk_local/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.144', # https://pypi.org/project/python-sdk-local/
10
+ version='0.0.146', # 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",