python-sdk-remote 0.0.127__tar.gz → 0.0.129__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 (22) hide show
  1. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/PKG-INFO +1 -1
  2. python_sdk_remote-0.0.129/README.md +11 -0
  3. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/constants.py +0 -9
  4. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/http_response.py +55 -16
  5. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/item.py +4 -3
  6. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/our_object.py +3 -9
  7. python_sdk_remote-0.0.129/python_sdk_remote/src/temp.py +15 -0
  8. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/unified_json.py +3 -8
  9. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/utilities.py +46 -32
  10. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote.egg-info/PKG-INFO +1 -1
  11. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote.egg-info/SOURCES.txt +1 -0
  12. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/setup.py +1 -1
  13. python_sdk_remote-0.0.127/README.md +0 -27
  14. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/pyproject.toml +0 -0
  15. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/__init__.py +0 -0
  16. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/mini_logger.py +0 -0
  17. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/valid_json_versions.py +0 -0
  18. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote/src/validate_environment.py +0 -0
  19. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  20. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote.egg-info/requires.txt +0 -0
  21. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/python_sdk_remote.egg-info/top_level.txt +0 -0
  22. {python_sdk_remote-0.0.127 → python_sdk_remote-0.0.129}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.127
3
+ Version: 0.0.129
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
@@ -0,0 +1,11 @@
1
+ # TODO: rewrite with more example
2
+
3
+ In serverless, use this decorator:
4
+ ```py
5
+ from python_sdk_remote.http_response import handler_decorator
6
+ from logger_local.Logger import Logger
7
+ logger = Logger.create_logger(object=your_logger_object)
8
+ @handler_decorator(logger=logger)
9
+ def my_handler(request_parameters: dict) -> dict:
10
+ # here you can use both camelCase and snake_case keys from request_parameters
11
+ ```
@@ -1,17 +1,8 @@
1
- import os
2
-
3
1
  from logger_local.LoggerComponentEnum import LoggerComponentEnum
4
2
 
5
3
  PYTHON_SDK_REMOTE_COMPONENT_ID = 184
6
4
  PYTHON_SDK_REMOTE_COMPONENT_NAME = 'python_sdk_remote'
7
5
 
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
6
  OBJECT_TO_INSERT_CODE = {
16
7
  'component_id': PYTHON_SDK_REMOTE_COMPONENT_ID,
17
8
  'component_name': PYTHON_SDK_REMOTE_COMPONENT_NAME,
@@ -1,42 +1,85 @@
1
- import json
2
1
  import traceback
2
+ from functools import wraps
3
3
  from http import HTTPStatus
4
4
  from typing import Any
5
5
 
6
6
  from .mini_logger import MiniLogger as logger
7
- import warnings
7
+ from datetime import date
8
+ from . import temp
9
+ from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
8
10
 
9
11
  HEADERS_KEY = 'headers'
10
12
  AUTHORIZATION_KEY = 'authorization'
11
13
  AUTHORIZATION_PREFIX = 'Bearer '
12
14
 
15
+ temp.deprecation_warning("http_response","DELETE",date(2024,7,25))
13
16
 
14
17
  # 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
15
18
  # TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
16
19
 
17
20
  # TODO: add handler wrapper?
18
21
 
22
+ #TODO Shall we add the word body? i.e. get_body_payload_idct_from_event()
19
23
  def get_payload_dict_from_event(event: dict) -> dict:
20
- warnings.warn("DELETE get_payload_dict_from_event",DeprecationWarning,stacklevel=2)
21
24
  """Extracts params sent with payload"""
22
- return json.loads(event.get('body') or '{}')
25
+ return to_dict(event.get('body'))
23
26
 
24
27
 
25
28
  def get_path_parameters_dict_from_event(event: dict) -> dict:
26
- warnings.warn("DELETE get_path_parameters_dict_from_event",DeprecationWarning,stacklevel=2)
27
29
  """Extracts params sent implicitly: `url/param?test=5` -> param
28
30
  (when the path is defined with /{param})"""
29
31
  return event.get('pathParameters') or {}
30
32
 
31
33
 
32
34
  def get_query_string_parameters_from_event(event: dict) -> dict:
33
- warnings.warn("DELETE get_query_string_parameters_from_event",DeprecationWarning,stacklevel=2)
34
35
  """Extracts params sent explicitly: `url/test?a=1&b=2` -> {'a': '1', 'b': '2'}"""
35
36
  return event.get("queryStringParameters") or {} # params sent with ?a=1&b=2
36
37
 
37
38
 
39
+ def get_request_parameters_from_event(event: dict) -> dict:
40
+ """Extracts all params from the event object.
41
+ The order of precedence is: payload > path > query string
42
+ returns a dictionary with all the parameters, with both camelCase and snake_case keys."""
43
+ all_parameters_dict = get_payload_dict_from_event(event)
44
+ all_parameters_dict.update(get_path_parameters_dict_from_event(event))
45
+ all_parameters_dict.update(get_query_string_parameters_from_event(event))
46
+ all_parameters_dict = {camel_to_snake(key): value for key, value in all_parameters_dict.items()}
47
+ all_parameters_dict.update({snake_to_camel(key): value for key, value in all_parameters_dict.items()})
48
+ return all_parameters_dict
49
+
50
+
51
+ # TODO: test
52
+ def handler_decorator(logger):
53
+ """Decorator for AWS Lambda handler functions. It wraps the handler function with logging and error handling.
54
+ Usage:
55
+ from python_sdk_remote.http_response import handler_decorator
56
+ logger = ...
57
+ @handler_decorator(logger=logger)
58
+ def my_handler(request_parameters: dict) -> dict:
59
+ return {"message": "Hello, World!"}"""
60
+
61
+ def decorator(handler: callable) -> callable:
62
+ @wraps(handler)
63
+ def wrapper(event, context):
64
+ handler_response = None
65
+ try:
66
+ logger.start(object={"event": event, "context": context})
67
+ request_parameters = get_request_parameters_from_event(event)
68
+ body_result: dict = handler(request_parameters)
69
+ handler_response = create_ok_http_response(body_result)
70
+ except Exception as e:
71
+ handler_response = create_error_http_response(e)
72
+ finally:
73
+ logger.end(object={"handler_response": handler_response})
74
+ return handler_response
75
+
76
+ return wrapper
77
+
78
+ return decorator
79
+
80
+
81
+ # TODO: should we auto detect user_jwt if not provided?
38
82
  def create_authorization_http_headers(user_jwt: str) -> dict:
39
- warnings.warn("DELETE create_authorization_http_headers",DeprecationWarning,stacklevel=2)
40
83
  logger.start(object={"user_jwt": user_jwt})
41
84
  #TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
42
85
  authorization_http_headers = {
@@ -48,7 +91,6 @@ def create_authorization_http_headers(user_jwt: str) -> dict:
48
91
 
49
92
 
50
93
  def get_user_jwt_from_event(event: dict) -> str:
51
- warnings.warn("DELETE get_user_jwt_from_event",DeprecationWarning,stacklevel=2)
52
94
  logger.start(object={"event": event})
53
95
  auth_header = event.get(HEADERS_KEY, {}).get(AUTHORIZATION_KEY)
54
96
  if auth_header is None:
@@ -59,7 +101,6 @@ def get_user_jwt_from_event(event: dict) -> str:
59
101
 
60
102
 
61
103
  def create_return_http_headers() -> dict:
62
- warnings.warn("DELETE create_return_http_headers",DeprecationWarning,stacklevel=2)
63
104
  logger.start()
64
105
  # Adding "Access-Control-Allow-Origin" : "*" to take care of CORS from localhost
65
106
  # TODO Do we need to add those? In which cases? try adding crossDomain: true, to the request, 'Access-Control-Allow-Credentials': true to header
@@ -72,7 +113,6 @@ def create_return_http_headers() -> dict:
72
113
 
73
114
 
74
115
  def create_error_http_response(exception: Exception, status_code: HTTPStatus = HTTPStatus.BAD_REQUEST) -> dict:
75
- warnings.warn("DELETE create_error_http_response",DeprecationWarning,stacklevel=2)
76
116
  logger.start(object={"exception": exception})
77
117
  error_http_response = {
78
118
  "statusCode": status_code.value,
@@ -85,12 +125,12 @@ def create_error_http_response(exception: Exception, status_code: HTTPStatus = H
85
125
 
86
126
 
87
127
  def create_ok_http_response(body: Any) -> dict:
88
- warnings.warn("DELETE create_ok_http_response",DeprecationWarning,stacklevel=2)
89
128
  logger.start(object={"body": body})
129
+ # TODO: test sending statusCode/headers/body inside the body
90
130
  ok_http_response = {
91
- "statusCode": HTTPStatus.OK.value,
92
- "headers": create_return_http_headers(),
93
- "body": create_http_body(body)
131
+ "statusCode": body.get("statusCode") or HTTPStatus.OK.value,
132
+ "headers": body.get("headers") or create_return_http_headers(),
133
+ "body": create_http_body(body.get("body") or body)
94
134
  }
95
135
  logger.end(object={"ok_http_response": ok_http_response})
96
136
  return ok_http_response
@@ -98,10 +138,9 @@ def create_ok_http_response(body: Any) -> dict:
98
138
 
99
139
  # https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format
100
140
  def create_http_body(body: Any) -> str:
101
- warnings.warn("DELETE create_http_body",DeprecationWarning,stacklevel=2)
102
141
  # TODO console.warning() if the body is not a valid camelCase JSON
103
142
  # https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
104
143
  logger.start(object={"body": body})
105
- http_body = json.dumps(body)
144
+ http_body = to_json(body)
106
145
  logger.end(object={"http_body": http_body})
107
146
  return http_body
@@ -1,13 +1,14 @@
1
1
  from abc import abstractmethod
2
2
 
3
3
  from .our_object import OurObject
4
- import warnings
4
+ from datetime import date
5
+ from . import temp
6
+
5
7
  class Item(OurObject):
6
8
  def __init__(self, **kwargs):
7
- warnings.warn("DELETE __init__",DeprecationWarning,stacklevel=2)
9
+ temp.deprecation_warning("item","DELETE",date(2024,7,25))
8
10
  super().__init__(**kwargs)
9
11
 
10
12
  @abstractmethod
11
13
  def get_id(self):
12
- warnings.warn("DELETE get_id",DeprecationWarning,stacklevel=2)
13
14
  raise NotImplementedError("Subclasses must implement the 'get_id' method.")
@@ -2,13 +2,14 @@ import json
2
2
  from abc import ABC, abstractmethod
3
3
 
4
4
  from .mini_logger import MiniLogger as logger
5
- import warnings
5
+ from datetime import date
6
+ from . import temp
6
7
 
7
8
 
8
9
  # TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
9
10
  class OurObject(ABC):
10
11
  def __init__(self, **kwargs):
11
- warnings.warn("DELETE __init__",DeprecationWarning,stacklevel=2)
12
+ temp.deprecation_warning("our_object","DELETE",date(2024,7,25))
12
13
  INIT_METHOD_NAME = '__init__'
13
14
  logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
14
15
  self.kwargs = kwargs
@@ -16,13 +17,11 @@ class OurObject(ABC):
16
17
 
17
18
  @abstractmethod
18
19
  def get_name(self):
19
- warnings.warn("DELETE get_name",DeprecationWarning,stacklevel=2)
20
20
  """Returns the name of the object"""
21
21
  raise NotImplementedError(
22
22
  "Subclasses must implement the 'get_name' method.")
23
23
 
24
24
  def get(self, attr_name: str):
25
- warnings.warn("DELETE get",DeprecationWarning,stacklevel=2)
26
25
  """Returns the value of the attribute with the given name"""
27
26
  GET_METHOD_NAME = 'get'
28
27
  logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
@@ -32,17 +31,14 @@ class OurObject(ABC):
32
31
  return value
33
32
 
34
33
  def get_all_arguments(self):
35
- warnings.warn("DELETE get_all_arguments",DeprecationWarning,stacklevel=2)
36
34
  """Returns all the arguments passed to the constructor as a dictionary"""
37
35
  return getattr(self, 'kwargs', None)
38
36
 
39
37
  def to_json(self) -> str:
40
- warnings.warn("DELETE to_json",DeprecationWarning,stacklevel=2)
41
38
  """Returns a json string representation of this object"""
42
39
  return json.dumps(self.__dict__)
43
40
 
44
41
  def from_json(self, json_string: str) -> 'OurObject':
45
- warnings.warn("DELETE from_json",DeprecationWarning,stacklevel=2)
46
42
  """Returns an instance of the class from a json string"""
47
43
  FROM_JSON_METHOD_NAME = 'from_json'
48
44
  logger.start(FROM_JSON_METHOD_NAME,
@@ -53,13 +49,11 @@ class OurObject(ABC):
53
49
  return self
54
50
 
55
51
  def __eq__(self, other) -> bool:
56
- warnings.warn("DELETE __eq__",DeprecationWarning,stacklevel=2)
57
52
  """Checks if two objects are equal"""
58
53
  if not isinstance(other, OurObject):
59
54
  return False
60
55
  return self.__dict__ == other.__dict__
61
56
 
62
57
  def __ne__(self, other) -> bool:
63
- warnings.warn("DELETE __ne__",DeprecationWarning,stacklevel=2)
64
58
  """Checks if two objects are not equal"""
65
59
  return not self.__eq__(other)
@@ -0,0 +1,15 @@
1
+ from functools import lru_cache
2
+ from datetime import date
3
+ import inspect
4
+ from .mini_logger import MiniLogger as logger
5
+
6
+ @lru_cache(maxsize=64) # don't print the same warning multiple times
7
+ def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
8
+ if start_date and start_date < date.today():
9
+ return
10
+ warnings_message = f"Please use {old_name} instead of {new_name}."
11
+ try:
12
+ warnings_message += " Called from: " + inspect.stack()[2].filename
13
+ except Exception:
14
+ pass
15
+ logger.warning(warnings_message)
@@ -1,11 +1,11 @@
1
1
  from .valid_json_versions import valid_json_versions
2
- import warnings
3
-
2
+ from datetime import date
3
+ from . import temp
4
4
 
5
5
  # TODO Shall we merge it with the machine-learning-unified-json?
6
6
  class UnifiedJson:
7
7
  def __init__(self, data: dict, json_version: str):
8
- warnings.warn("DELETE __init__",DeprecationWarning,stacklevel=2)
8
+ temp.deprecation_warning("unified_json","DELETE",date(2024,7,25))
9
9
  if json_version not in valid_json_versions:
10
10
  raise Exception(
11
11
  f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
@@ -15,21 +15,16 @@ class UnifiedJson:
15
15
  self.data = data
16
16
 
17
17
  def get_unified_json(self):
18
- warnings.warn("DELETE get_unified_json",DeprecationWarning,stacklevel=2)
19
18
  return {"version": self.json_version, "data": self.data}
20
19
 
21
20
  def get_data(self):
22
- warnings.warn("DELETE get_data",DeprecationWarning,stacklevel=2)
23
21
  return self.data
24
22
 
25
23
  def get_json_version(self):
26
- warnings.warn("DELETE get_json_version",DeprecationWarning,stacklevel=2)
27
24
  return self.json_version
28
25
 
29
26
  def __str__(self):
30
- warnings.warn("DELETE __str__",DeprecationWarning,stacklevel=2)
31
27
  return self.get_unified_json()
32
28
 
33
29
  def __repr__(self):
34
- warnings.warn("DELETE __repr__",DeprecationWarning,stacklevel=2)
35
30
  return self.__str__()
@@ -1,21 +1,19 @@
1
+ import inspect
1
2
  import json
2
- import jwt
3
- import requests
4
- import re
5
3
  import os
6
4
  import random
5
+ import re
7
6
  from datetime import date, datetime, time, timedelta, timezone
7
+ from functools import lru_cache
8
8
  from urllib.parse import urlparse
9
- import warnings
9
+ from . import temp
10
10
 
11
+ import jwt
12
+ import requests
11
13
  from dotenv import load_dotenv
12
14
  from url_remote.environment_name_enum import EnvironmentName
13
15
 
14
16
  from .mini_logger import MiniLogger as logger
15
- from .http_response import (create_authorization_http_headers, # noqa - used for backwards compatibility
16
- get_user_jwt_from_event,
17
- create_return_http_headers, create_error_http_response, create_ok_http_response,
18
- create_http_body)
19
17
 
20
18
  load_dotenv()
21
19
  # TODO Let's do brainstorming on this
@@ -36,13 +34,13 @@ DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
36
34
 
37
35
 
38
36
  def append_if_not_exist(lst: list, item: object) -> None:
39
- warnings.warn("DELETE append_if_not_exist",DeprecationWarning,stacklevel=2)
37
+ temp.deprecation_warning("append_if_not_exist","DELETE",date(2024,7,25))
40
38
  if item not in lst:
41
39
  lst.append(item)
42
40
 
43
41
 
44
42
  def to_dict(data: json or dict or None) -> dict:
45
- warnings.warn("DELETE to_dict",DeprecationWarning,stacklevel=2)
43
+ temp.deprecation_warning("to_dict","DELETE",date(2024,7,25))
46
44
  if data is None:
47
45
  return {}
48
46
  if isinstance(data, dict):
@@ -51,7 +49,7 @@ def to_dict(data: json or dict or None) -> dict:
51
49
 
52
50
 
53
51
  def to_json(data: json or dict or None) -> json:
54
- warnings.warn("DELETE to_json",DeprecationWarning,stacklevel=2)
52
+ temp.deprecation_warning("to_json","DELETE",date(2024,7,25))
55
53
  if data is None:
56
54
  data = {}
57
55
  if isinstance(data, dict):
@@ -60,7 +58,7 @@ def to_json(data: json or dict or None) -> json:
60
58
 
61
59
 
62
60
  def timedelta_to_time_format(time_delta: timedelta) -> str:
63
- warnings.warn("DELETE timedelta_to_time_format",DeprecationWarning,stacklevel=2)
61
+ temp.deprecation_warning("timedelta_to_time_format","DELETE",date(2024,7,25))
64
62
  """
65
63
  Convert a timedelta to a time format in HH:MM:SS.
66
64
 
@@ -97,7 +95,7 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
97
95
 
98
96
 
99
97
  def is_valid_time_range(time_range: tuple) -> bool:
100
- warnings.warn("DELETE is_valid_time_range",DeprecationWarning,stacklevel=2)
98
+ temp.deprecation_warning("is_valid_time_range","DELETE",date(2024,7,25))
101
99
  """
102
100
  Validate that the time range is in the format 'HH:MM:SS'.
103
101
  """
@@ -124,7 +122,7 @@ def is_valid_time_range(time_range: tuple) -> bool:
124
122
  # TODO shall we also use Url type and not only str? - Strongly Type which I prefer
125
123
  # (if yes we should change it also in all the calls to this function)
126
124
  def validate_url(url: str):
127
- warnings.warn("DELETE validate_url",DeprecationWarning,stacklevel=2)
125
+ temp.deprecation_warning("validate_url","DELETE",date(2024,7,25))
128
126
  logger.start(object={"url": url})
129
127
  if url is not None or url != "":
130
128
  parsed_url = urlparse(url)
@@ -136,7 +134,7 @@ def validate_url(url: str):
136
134
 
137
135
 
138
136
  def is_valid_date_range(date_range: tuple) -> bool:
139
- warnings.warn("DELETE is_valid_date_range",DeprecationWarning,stacklevel=2)
137
+ temp.deprecation_warning("is_valid_date_range","DELETE",date(2024,7,25))
140
138
  """
141
139
  Validate that the date range is in the format 'YYYY-MM-DD'.
142
140
  """
@@ -155,7 +153,7 @@ def is_valid_date_range(date_range: tuple) -> bool:
155
153
 
156
154
 
157
155
  def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
158
- warnings.warn("DELETE is_valid_datetime_range",DeprecationWarning,stacklevel=2)
156
+ temp.deprecation_warning("is_valid_datetime_range","DELETE",date(2024,7,25))
159
157
  """
160
158
  Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
161
159
  """
@@ -173,7 +171,7 @@ def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
173
171
 
174
172
 
175
173
  def is_list_of_dicts(obj: object) -> bool:
176
- warnings.warn("DELETE is_list_of_dicts",DeprecationWarning,stacklevel=2)
174
+ temp.deprecation_warning("is_list_of_dicts","DELETE",date(2024,7,25))
177
175
  """
178
176
  Check if an object is a list of dictionaries.
179
177
 
@@ -218,7 +216,7 @@ def is_list_of_dicts(obj: object) -> bool:
218
216
 
219
217
 
220
218
  def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
221
- warnings.warn("DELETE is_time_in_time_range",DeprecationWarning,stacklevel=2)
219
+ temp.deprecation_warning("is_time_in_time_range","DELETE",date(2024,7,25))
222
220
  """
223
221
  Check if the given time is within the specified time range.
224
222
 
@@ -242,7 +240,7 @@ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
242
240
 
243
241
 
244
242
  def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
245
- warnings.warn("DELETE is_date_in_date_range",DeprecationWarning,stacklevel=2)
243
+ temp.deprecation_warning("is_date_in_date_range","DELETE",date(2024,7,25))
246
244
  """
247
245
  Check if the given date is within the specified date range.
248
246
 
@@ -267,7 +265,7 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
267
265
 
268
266
 
269
267
  def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (datetime, datetime)) -> bool:
270
- warnings.warn("DELETE is_datetime_in_datetime_range",DeprecationWarning,stacklevel=2)
268
+ temp.deprecation_warning("is_datetime_in_datetime_range","DELETE",date(2024,7,25))
271
269
  """
272
270
  Check if the given datetime is within the specified datetime range.
273
271
 
@@ -331,7 +329,7 @@ def get_dialog_jwt_secret_key() -> str:
331
329
 
332
330
 
333
331
  def encode_jwt(payload: dict, key: str) -> str:
334
- warnings.warn("DELETE encode_jwt",DeprecationWarning,stacklevel=2)
332
+ temp.deprecation_warning("encode_jwt","DELETE",date(2024,7,25))
335
333
  """Example:
336
334
  payload = {
337
335
  "user_id": 123,
@@ -343,7 +341,7 @@ def encode_jwt(payload: dict, key: str) -> str:
343
341
 
344
342
 
345
343
  def decode_jwt(token: str, key: str) -> dict:
346
- warnings.warn("DELETE decode_jwt",DeprecationWarning,stacklevel=2)
344
+ temp.deprecation_warning("decode_jwt","DELETE",date(2024,7,25))
347
345
  """key can be private / public"""
348
346
  return jwt.decode(token, key, algorithms=['HS256'])
349
347
 
@@ -369,44 +367,45 @@ def obfuscate_log_dict(log_dict: dict) -> dict:
369
367
  if isinstance(value, dict):
370
368
  obfuscated_log_dict[key] = obfuscate_log_dict(value)
371
369
  elif re.search(r'password|secret|token|jwt|e[\-_]?mail|phone|name|address|ssn', key, re.IGNORECASE):
372
- # TODO Maybe we can reveal a small part
370
+ # TODO Maybe we can reveal a small part
373
371
  obfuscated_log_dict[key] = "***"
374
372
  else:
375
373
  obfuscated_log_dict[key] = value
376
374
  return obfuscated_log_dict
377
375
 
376
+
378
377
  # TODO: add tests to the following functions
379
378
 
380
379
  def remove_digits(text: str) -> str:
381
- warnings.warn("DELETE remove_digits",DeprecationWarning,stacklevel=2)
380
+ temp.deprecation_warning("remove_digits","DELETE",date(2024,7,25))
382
381
  return ''.join(i for i in text if not i.isdigit())
383
382
 
384
383
 
385
384
  def generate_otp():
386
- warnings.warn("DELETE generate_otp",DeprecationWarning,stacklevel=2)
385
+ temp.deprecation_warning("generate_otp","DELETE",date(2024,7,25))
387
386
  """Generates a 6-digit OTP"""
388
387
  otp = random.randint(100000, 999999)
389
388
  return otp
390
389
 
391
390
 
392
391
  def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT, tz: timezone = None) -> str:
393
- warnings.warn("DELETE get_current_datetime_string",DeprecationWarning,stacklevel=2)
392
+ temp.deprecation_warning("get_current_datetime_string","DELETE",date(2024,7,25))
394
393
  current_datetime_string = datetime.now(tz).strftime(datetime_format)
395
394
  return current_datetime_string
396
395
 
397
396
 
398
397
  def datetime_from_str(date_str: str, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> datetime:
399
- warnings.warn("DELETE datetime_from_str",DeprecationWarning,stacklevel=2)
398
+ temp.deprecation_warning("datetime_from_str","DELETE",date(2024,7,25))
400
399
  return datetime.strptime(date_str, datetime_format)
401
400
 
402
401
 
403
402
  def datetime_to_str(input_datetime: datetime, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> str:
404
- warnings.warn("DELETE datetime_to_str",DeprecationWarning,stacklevel=2)
403
+ temp.deprecation_warning("datetime_to_str","DELETE",date(2024,7,25))
405
404
  return input_datetime.strftime(datetime_format)
406
405
 
407
406
 
408
407
  def validate_arguments(args: dict) -> None:
409
- warnings.warn("DELETE validate_arguments",DeprecationWarning,stacklevel=2)
408
+ temp.deprecation_warning("validate_arguments","DELETE",date(2024,7,25))
410
409
  """
411
410
  Validate method arguments to ensure they are not None or ''
412
411
  :param args: arguments to be validated (usually locals())
@@ -418,7 +417,7 @@ def validate_arguments(args: dict) -> None:
418
417
 
419
418
 
420
419
  def reformat_time_string(input_str: str) -> str:
421
- warnings.warn("DELETE reformat_time_string",DeprecationWarning,stacklevel=2)
420
+ temp.deprecation_warning("reformat_time_string","DELETE",date(2024,7,25))
422
421
  """Example:
423
422
  "1234" -> "12:34:00:00"
424
423
  """
@@ -432,10 +431,25 @@ def reformat_time_string(input_str: str) -> str:
432
431
 
433
432
 
434
433
  def get_ip_v4():
435
- warnings.warn("DELETE get_ip_v4",DeprecationWarning,stacklevel=2)
434
+ temp.deprecation_warning("get_ip_v4","DELETE",date(2024,7,25))
436
435
  return requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
437
436
 
438
437
 
439
438
  def get_ip_v6():
440
- warnings.warn("DELETE get_ip_v6",DeprecationWarning,stacklevel=2)
439
+ temp.deprecation_warning("get_ip_v6","DELETE",date(2024,7,25))
441
440
  return requests.get('https://api.seeip.org/jsonip').json()['ip']
441
+
442
+
443
+ def snake_to_camel(snake_str: str) -> str:
444
+ """Converts snake_case to camelCase."""
445
+ components = snake_str.split('_')
446
+ camel_str = components[0] + ''.join(x.title() for x in components[1:])
447
+ return camel_str
448
+
449
+
450
+ def camel_to_snake(camel_str: str) -> str:
451
+ """Converts camelCase to snake_case."""
452
+ snake_str = re.sub(r'(?<!^)(?=[A-Z])', '_', camel_str).lower()
453
+ return snake_str
454
+
455
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.127
3
+ Version: 0.0.129
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
@@ -12,6 +12,7 @@ python_sdk_remote/src/http_response.py
12
12
  python_sdk_remote/src/item.py
13
13
  python_sdk_remote/src/mini_logger.py
14
14
  python_sdk_remote/src/our_object.py
15
+ python_sdk_remote/src/temp.py
15
16
  python_sdk_remote/src/unified_json.py
16
17
  python_sdk_remote/src/utilities.py
17
18
  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.127', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.129', # 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",
@@ -1,27 +0,0 @@
1
- # python-sdk-package
2
-
3
- https://github.com/grosser/repo_dependency_graph Ruby, Graph the dependencies of your repositories
4
- https://github.com/thebjorn/pydeps Python
5
-
6
- To create local package and remote package layers (not to create GraphQL and REST-API layers)
7
-
8
- #database Python scripts in /db folder
9
- Please place <table-name>.py in /db<br>
10
- No need for seperate file for _ml table<br>
11
- Please delete the example file if not needed<br>
12
-
13
- # Create the files to create the database schema, tables, view and populate Meta Data and Test Date
14
-
15
- /db/<table-name>.py - CREATE SCHEMA ... CREATE TABLE ... CREATE VIEW ...<br>
16
- /db/<table-name>_insert.py to create records
17
-
18
- # Update the setup.py (i.e.name, version)
19
-
20
- # Please create test directory inside the directory of the project i.e. /<project-name>/tests
21
-
22
- # Update the serverless.yml in the root directory
23
-
24
- provider:
25
- stage: play1
26
-
27
- Update the endpoints in serverless.yml