python-sdk-remote 0.0.136__tar.gz → 0.0.138__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 (20) hide show
  1. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/PKG-INFO +1 -2
  2. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/http_response.py +2 -2
  3. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/item.py +3 -1
  4. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/our_object.py +40 -37
  5. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/utilities.py +1 -1
  6. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote.egg-info/PKG-INFO +1 -2
  7. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/setup.py +3 -2
  8. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/README.md +0 -0
  9. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/pyproject.toml +0 -0
  10. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/__init__.py +0 -0
  11. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/constants.py +0 -0
  12. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/mini_logger.py +0 -0
  13. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/unified_json.py +0 -0
  14. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/valid_json_versions.py +0 -0
  15. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote/src/validate_environment.py +0 -0
  16. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote.egg-info/SOURCES.txt +0 -0
  17. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  18. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote.egg-info/requires.txt +0 -0
  19. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/python_sdk_remote.egg-info/top_level.txt +0 -0
  20. {python_sdk_remote-0.0.136 → python_sdk_remote-0.0.138}/setup.cfg +0 -0
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sdk-remote
3
- Version: 0.0.136
3
+ Version: 0.0.138
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
7
7
  Author-email: info@circlez.ai
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: Other/Proprietary License
10
9
  Classifier: Operating System :: OS Independent
11
10
  Description-Content-Type: text/markdown
12
11
  Requires-Dist: requests
@@ -16,7 +16,7 @@ AUTHORIZATION_PREFIX = 'Bearer '
16
16
 
17
17
  # TODO: add handler wrapper?
18
18
 
19
- #TODO Shall we add the word body? i.e. get_body_payload_idct_from_event()
19
+ # TODO Shall we add the word body? i.e. get_body_payload_idct_from_event()
20
20
  def get_payload_dict_from_event(event: dict) -> dict:
21
21
  """Extracts params sent with payload"""
22
22
  return to_dict(event.get('body'))
@@ -78,7 +78,7 @@ def handler_decorator(logger):
78
78
  # TODO: should we auto detect user_jwt if not provided?
79
79
  def create_authorization_http_headers(user_jwt: str) -> dict:
80
80
  logger.start(object={"user_jwt": user_jwt})
81
- #TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
81
+ # TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
82
82
  authorization_http_headers = {
83
83
  'Content-Type': 'application/json',
84
84
  'Authorization': AUTHORIZATION_PREFIX + user_jwt,
@@ -2,10 +2,12 @@ from abc import abstractmethod
2
2
 
3
3
  from .our_object import OurObject
4
4
 
5
+ ENTITY_NAME = "item"
6
+
5
7
 
6
8
  class Item(OurObject):
7
9
  def __init__(self, **kwargs):
8
- super().__init__(**kwargs)
10
+ super().__init__(ENTITY_NAME, **kwargs)
9
11
 
10
12
  @abstractmethod
11
13
  def get_id(self):
@@ -1,70 +1,67 @@
1
1
  import json
2
2
  from abc import ABC # , abstractmethod
3
- from datetime import datetime
4
3
 
5
4
  from .mini_logger import MiniLogger as logger
6
5
 
7
6
 
8
7
  # TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
9
8
  class OurObject(ABC):
10
- def __init__(self, id_column_name, **kwargs):
9
+
10
+ entity_name = None
11
+
12
+ # Needed by print_our_object_with_id()
13
+ name = None
14
+ number = None
15
+
16
+ fields = {
17
+ # Needed by print_our_object_with_id()
18
+ "name",
19
+ "number"
20
+ }
21
+
22
+ def __init__(self, entity_name, **kwargs):
11
23
  INIT_METHOD_NAME = '__init__'
12
24
  logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
13
- setattr(self, 'id_column_name', id_column_name)
14
- for field, value in kwargs.items():
15
- # if field in event_fields:
16
- setattr(self, field, value)
17
-
18
- # self.kwargs = kwargs
25
+ self.entity_name = entity_name
26
+ self.kwargs = kwargs
19
27
  logger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
20
28
 
21
- def get_id_column_name(self):
22
- """Returns the id of the object"""
23
- return self.get('id_column_name')
29
+ def __convert_kwargs_to_fields(self, kwargs, fields):
30
+ for field, value in kwargs.items():
31
+ if field in fields:
32
+ setattr(self, field, value)
33
+
34
+ # TODO Do we need it?
35
+ def __convert_fields_to_kwargs(self, fields, kwargs):
36
+ for field in fields:
37
+ if field in kwargs:
38
+ setattr(self, field, kwargs[field])
39
+ else:
40
+ setattr(self, field, None)
24
41
 
25
42
  # Commented so we can use it in database foreach()
26
43
  # @abstractmethod
27
44
  def get_name(self):
28
45
  """Returns the name of the object"""
29
46
  # raise NotImplementedError(
30
- # "Subclasses must implement the 'get_name' method.")
47
+ # "Subclasses must implement the 'get_name' method.")
31
48
 
32
49
  def get(self, attr_name: str):
33
50
  """Returns the value of the attribute with the given name"""
34
51
  GET_METHOD_NAME = 'get'
35
52
  logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
36
- # arguments = getattr(self, 'kwargs', None)
37
- # value = arguments.get(attr_name, None)
38
- value = self.__dict__.get(attr_name, None)
53
+ arguments = getattr(self, 'kwargs', None)
54
+ value = arguments.get(attr_name, None)
39
55
  logger.end(GET_METHOD_NAME, object={'attr_name': attr_name})
40
56
  return value
41
57
 
42
58
  def get_all_arguments(self):
43
59
  """Returns all the arguments passed to the constructor as a dictionary"""
44
- # return getattr(self, 'kwargs', None)
45
- return self.__dict__
60
+ return getattr(self, 'kwargs', None)
46
61
 
47
62
  def to_json(self) -> str:
48
- """This is backwards compatible with the previous implementation"""
49
- return self.to_json_str()
50
-
51
- def to_json_dict(self) -> str:
52
- """Returns a json string representation of this object"""
53
- json_str = self.to_json_str()
54
- json_dict = json.loads(json_str)
55
-
56
- return json_dict
57
-
58
- def to_json_str(self) -> str:
59
63
  """Returns a json string representation of this object"""
60
- return json.dumps(self.__dict__, default=self._serialize)
61
-
62
- @staticmethod
63
- def _serialize(obj):
64
- """Custom serialization function for unsupported types. Used by json.dumps"""
65
- if isinstance(obj, datetime):
66
- return obj.isoformat() # Converts datetime to ISO 8601 string
67
- raise TypeError(f"Type {type(obj)} not serializable")
64
+ return json.dumps(self.__dict__)
68
65
 
69
66
  def from_json(self, json_string: str) -> 'OurObject':
70
67
  """Returns an instance of the class from a json string"""
@@ -86,5 +83,11 @@ class OurObject(ABC):
86
83
  """Checks if two objects are not equal"""
87
84
  return not self.__eq__(other)
88
85
 
89
- def get_dict(self):
86
+ def __str__(self):
87
+ return self.entity_name + ": " + str(self.__dict__)
88
+
89
+ def __repr__(self):
90
+ return self.entity_name + ": " + str(self.__dict__)
91
+
92
+ def to_dict(self):
90
93
  return self.__dict__
@@ -403,7 +403,7 @@ def reformat_time_string(input_str: str) -> str:
403
403
  minutes = "00" if len(input_str) < 4 else input_str[2:4]
404
404
  seconds = "00" if len(input_str) < 6 else input_str[4:6]
405
405
  milliseconds = "00" if len(input_str) < 8 else input_str[6:8]
406
- # TODO Shall we use DEFAULT_DATETIME_FORMAT and have the formats in the central
406
+ # TODO Shall we use DEFAULT_DATETIME_FORMAT and have the formats in the central
407
407
  time_format = f"{hours}:{minutes}:{seconds}:{milliseconds}"
408
408
  return time_format
409
409
 
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sdk-remote
3
- Version: 0.0.136
3
+ Version: 0.0.138
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
7
7
  Author-email: info@circlez.ai
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: Other/Proprietary License
10
9
  Classifier: Operating System :: OS Independent
11
10
  Description-Content-Type: text/markdown
12
11
  Requires-Dist: requests
@@ -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.136', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.138', # https://pypi.org/project/python-sdk-remote/
11
11
  author="Circles",
12
12
  author_email="info@circlez.ai",
13
13
  description="PyPI Package for Circles Python SDK Local Python",
@@ -19,7 +19,8 @@ setuptools.setup(
19
19
  package_data={package_dir: ['*.py']},
20
20
  classifiers=[
21
21
  "Programming Language :: Python :: 3",
22
- "License :: Other/Proprietary License",
22
+ # https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license
23
+ # "License :: MIT AND (Apache-2.0 OR BSD-2-Clause)",
23
24
  "Operating System :: OS Independent",
24
25
  ],
25
26
  install_requires=[