python-sdk-remote 0.0.130__tar.gz → 0.0.132__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.130 → python_sdk_remote-0.0.132}/PKG-INFO +10 -2
  2. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/pyproject.toml +1 -1
  3. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/http_response.py +4 -7
  4. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/item.py +0 -3
  5. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/mini_logger.py +2 -5
  6. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/our_object.py +4 -6
  7. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/unified_json.py +0 -4
  8. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/utilities.py +15 -25
  9. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote.egg-info/PKG-INFO +10 -2
  10. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote.egg-info/SOURCES.txt +0 -1
  11. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/setup.py +1 -1
  12. python_sdk_remote-0.0.130/python_sdk_remote/src/temp.py +0 -18
  13. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/README.md +0 -0
  14. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/__init__.py +0 -0
  15. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/constants.py +0 -0
  16. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/valid_json_versions.py +0 -0
  17. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote/src/validate_environment.py +0 -0
  18. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  19. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote.egg-info/requires.txt +0 -0
  20. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/python_sdk_remote.egg-info/top_level.txt +0 -0
  21. {python_sdk_remote-0.0.130 → python_sdk_remote-0.0.132}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-sdk-remote
3
- Version: 0.0.130
3
+ Version: 0.0.132
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
@@ -13,5 +13,13 @@ Requires-Dist: requests
13
13
  Requires-Dist: python-dotenv
14
14
  Requires-Dist: url-remote
15
15
  Requires-Dist: pyjwt
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: requires-dist
23
+ Dynamic: summary
16
24
 
17
25
  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.76" # https://pypi.org/project/python-sdk-local
7
+ version = "0.0.75" # https://pypi.org/project/python-sdk-local
8
8
  description = "python-sdk-local Python Package"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -1,25 +1,22 @@
1
1
  import traceback
2
- from datetime import date
3
2
  from functools import wraps
4
3
  from http import HTTPStatus
5
4
  from typing import Any
6
5
 
7
6
  from .mini_logger import MiniLogger as logger
8
- from .temp import deprecation_warning
9
7
  from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
10
8
 
11
9
  HEADERS_KEY = 'headers'
12
10
  AUTHORIZATION_KEY = 'authorization'
13
11
  AUTHORIZATION_PREFIX = 'Bearer '
14
12
 
15
- # TODO: move date(2024, 6, 5) to constants and use it everywhere
16
- deprecation_warning("http_response", "DELETE", date(2024, 6, 5))
17
-
18
13
 
19
14
  # 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
20
15
  # TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
21
16
 
22
- # TODO Shall we add the word body? i.e. get_body_payload_dict_from_event()
17
+ # TODO: add handler wrapper?
18
+
19
+ #TODO Shall we add the word body? i.e. get_body_payload_idct_from_event()
23
20
  def get_payload_dict_from_event(event: dict) -> dict:
24
21
  """Extracts params sent with payload"""
25
22
  return to_dict(event.get('body'))
@@ -81,7 +78,7 @@ def handler_decorator(logger):
81
78
  # TODO: should we auto detect user_jwt if not provided?
82
79
  def create_authorization_http_headers(user_jwt: str) -> dict:
83
80
  logger.start(object={"user_jwt": user_jwt})
84
- # 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.
85
82
  authorization_http_headers = {
86
83
  'Content-Type': 'application/json',
87
84
  'Authorization': AUTHORIZATION_PREFIX + user_jwt,
@@ -1,13 +1,10 @@
1
1
  from abc import abstractmethod
2
- from datetime import date
3
2
 
4
3
  from .our_object import OurObject
5
- from .temp import deprecation_warning
6
4
 
7
5
 
8
6
  class Item(OurObject):
9
7
  def __init__(self, **kwargs):
10
- deprecation_warning("item", "DELETE", date(2024, 6, 5))
11
8
  super().__init__(**kwargs)
12
9
 
13
10
  @abstractmethod
@@ -2,10 +2,7 @@ import logging
2
2
  import os
3
3
  import sys
4
4
 
5
- # Try to get MINI_LOGGER_MINIMUM_SEVERITY from the environment, if not found, try to get LOGGER_MINIMUM_SEVERITY
6
- # If not found, default to INFO
7
- LOGGER_MINIMUM_SEVERITY = os.getenv("MINI_LOGGER_MINIMUM_SEVERITY",
8
- os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO")).upper()
5
+ LOGGER_MINIMUM_SEVERITY = os.getenv("LOGGER_MINIMUM_SEVERITY", "INFO").upper()
9
6
  # logging expects NOTSET/DEBUG/INFO/WARNING/ERROR/FATAL/CRITICAL
10
7
  if LOGGER_MINIMUM_SEVERITY.isdigit():
11
8
  logger_minimum_severity = int(LOGGER_MINIMUM_SEVERITY)
@@ -28,7 +25,7 @@ logger = logging.getLogger(__name__)
28
25
 
29
26
  class MiniLogger:
30
27
  # TODO Can we so one generic function call by all
31
- # TODO: print the caller function name
28
+
32
29
  @staticmethod
33
30
  def start(message: str = "", object: dict = None):
34
31
  """
@@ -1,25 +1,23 @@
1
1
  import json
2
2
  from abc import ABC, abstractmethod
3
- from datetime import date
4
3
 
5
4
  from .mini_logger import MiniLogger as logger
6
- from .temp import deprecation_warning
7
5
 
8
6
 
9
7
  # TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
10
8
  class OurObject(ABC):
11
9
  def __init__(self, **kwargs):
12
- deprecation_warning("our_object", "DELETE", date(2024, 6, 5))
13
10
  INIT_METHOD_NAME = '__init__'
14
11
  logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
15
12
  self.kwargs = kwargs
16
13
  logger.end(INIT_METHOD_NAME, object={'kwargs': kwargs})
17
14
 
18
- @abstractmethod
15
+ # Commented so we can use it in database foreach()
16
+ #@abstractmethod
19
17
  def get_name(self):
20
18
  """Returns the name of the object"""
21
- raise NotImplementedError(
22
- "Subclasses must implement the 'get_name' method.")
19
+ #raise NotImplementedError(
20
+ #"Subclasses must implement the 'get_name' method.")
23
21
 
24
22
  def get(self, attr_name: str):
25
23
  """Returns the value of the attribute with the given name"""
@@ -1,13 +1,9 @@
1
- from datetime import date
2
-
3
- from .temp import deprecation_warning
4
1
  from .valid_json_versions import valid_json_versions
5
2
 
6
3
 
7
4
  # TODO Shall we merge it with the machine-learning-unified-json?
8
5
  class UnifiedJson:
9
6
  def __init__(self, data: dict, json_version: str):
10
- deprecation_warning("unified_json", "DELETE", date(2024, 6, 5))
11
7
  if json_version not in valid_json_versions:
12
8
  raise Exception(
13
9
  f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
@@ -1,8 +1,10 @@
1
+ import inspect
1
2
  import json
2
3
  import os
3
4
  import random
4
5
  import re
5
6
  from datetime import date, datetime, time, timedelta, timezone
7
+ from functools import lru_cache
6
8
  from urllib.parse import urlparse
7
9
 
8
10
  import jwt
@@ -11,7 +13,6 @@ from dotenv import load_dotenv
11
13
  from url_remote.environment_name_enum import EnvironmentName
12
14
 
13
15
  from .mini_logger import MiniLogger as logger
14
- from .temp import deprecation_warning
15
16
 
16
17
  load_dotenv()
17
18
  # TODO Let's do brainstorming on this
@@ -32,22 +33,19 @@ DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
32
33
 
33
34
 
34
35
  def append_if_not_exist(lst: list, item: object) -> None:
35
- deprecation_warning("append_if_not_exist", "DELETE", date(2024, 6, 5))
36
36
  if item not in lst:
37
37
  lst.append(item)
38
38
 
39
39
 
40
40
  def to_dict(data: json or dict or None) -> dict:
41
- deprecation_warning("to_dict", "DELETE", date(2024, 6, 5))
42
41
  if data is None:
43
42
  return {}
44
43
  if isinstance(data, dict):
45
44
  return data
46
- return json.loads(data) # TODO: replace all `return statement` with `return identifier`
45
+ return json.loads(data)
47
46
 
48
47
 
49
48
  def to_json(data: json or dict or None) -> json:
50
- deprecation_warning("to_json", "DELETE", date(2024, 6, 5))
51
49
  if data is None:
52
50
  data = {}
53
51
  if isinstance(data, dict):
@@ -56,7 +54,6 @@ def to_json(data: json or dict or None) -> json:
56
54
 
57
55
 
58
56
  def timedelta_to_time_format(time_delta: timedelta) -> str:
59
- deprecation_warning("timedelta_to_time_format", "DELETE", date(2024, 6, 5))
60
57
  """
61
58
  Convert a timedelta to a time format in HH:MM:SS.
62
59
 
@@ -93,7 +90,6 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
93
90
 
94
91
 
95
92
  def is_valid_time_range(time_range: tuple) -> bool:
96
- deprecation_warning("is_valid_time_range", "DELETE", date(2024, 6, 5))
97
93
  """
98
94
  Validate that the time range is in the format 'HH:MM:SS'.
99
95
  """
@@ -120,7 +116,6 @@ def is_valid_time_range(time_range: tuple) -> bool:
120
116
  # TODO shall we also use Url type and not only str? - Strongly Type which I prefer
121
117
  # (if yes we should change it also in all the calls to this function)
122
118
  def validate_url(url: str):
123
- deprecation_warning("validate_url", "DELETE", date(2024, 6, 5))
124
119
  logger.start(object={"url": url})
125
120
  if url is not None or url != "":
126
121
  parsed_url = urlparse(url)
@@ -132,7 +127,6 @@ def validate_url(url: str):
132
127
 
133
128
 
134
129
  def is_valid_date_range(date_range: tuple) -> bool:
135
- deprecation_warning("is_valid_date_range", "DELETE", date(2024, 6, 5))
136
130
  """
137
131
  Validate that the date range is in the format 'YYYY-MM-DD'.
138
132
  """
@@ -151,7 +145,6 @@ def is_valid_date_range(date_range: tuple) -> bool:
151
145
 
152
146
 
153
147
  def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
154
- deprecation_warning("is_valid_datetime_range", "DELETE", date(2024, 6, 5))
155
148
  """
156
149
  Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
157
150
  """
@@ -169,7 +162,6 @@ def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
169
162
 
170
163
 
171
164
  def is_list_of_dicts(obj: object) -> bool:
172
- deprecation_warning("is_list_of_dicts", "DELETE", date(2024, 6, 5))
173
165
  """
174
166
  Check if an object is a list of dictionaries.
175
167
 
@@ -214,7 +206,6 @@ def is_list_of_dicts(obj: object) -> bool:
214
206
 
215
207
 
216
208
  def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
217
- deprecation_warning("is_time_in_time_range", "DELETE", date(2024, 6, 5))
218
209
  """
219
210
  Check if the given time is within the specified time range.
220
211
 
@@ -238,7 +229,6 @@ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
238
229
 
239
230
 
240
231
  def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
241
- deprecation_warning("is_date_in_date_range", "DELETE", date(2024, 6, 5))
242
232
  """
243
233
  Check if the given date is within the specified date range.
244
234
 
@@ -263,7 +253,6 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
263
253
 
264
254
 
265
255
  def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (datetime, datetime)) -> bool:
266
- deprecation_warning("is_datetime_in_datetime_range", "DELETE", date(2024, 6, 5))
267
256
  """
268
257
  Check if the given datetime is within the specified datetime range.
269
258
 
@@ -327,7 +316,6 @@ def get_dialog_jwt_secret_key() -> str:
327
316
 
328
317
 
329
318
  def encode_jwt(payload: dict, key: str) -> str:
330
- deprecation_warning("encode_jwt", "DELETE", date(2024, 6, 5))
331
319
  """Example:
332
320
  payload = {
333
321
  "user_id": 123,
@@ -339,7 +327,6 @@ def encode_jwt(payload: dict, key: str) -> str:
339
327
 
340
328
 
341
329
  def decode_jwt(token: str, key: str) -> dict:
342
- deprecation_warning("decode_jwt", "DELETE", date(2024, 6, 5))
343
330
  """key can be private / public"""
344
331
  return jwt.decode(token, key, algorithms=['HS256'])
345
332
 
@@ -375,35 +362,29 @@ def obfuscate_log_dict(log_dict: dict) -> dict:
375
362
  # TODO: add tests to the following functions
376
363
 
377
364
  def remove_digits(text: str) -> str:
378
- deprecation_warning("remove_digits", "DELETE", date(2024, 6, 5))
379
365
  return ''.join(i for i in text if not i.isdigit())
380
366
 
381
367
 
382
368
  def generate_otp():
383
- deprecation_warning("generate_otp", "DELETE", date(2024, 6, 5))
384
369
  """Generates a 6-digit OTP"""
385
370
  otp = random.randint(100000, 999999)
386
371
  return otp
387
372
 
388
373
 
389
374
  def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT, tz: timezone = None) -> str:
390
- deprecation_warning("get_current_datetime_string", "DELETE", date(2024, 6, 5))
391
375
  current_datetime_string = datetime.now(tz).strftime(datetime_format)
392
376
  return current_datetime_string
393
377
 
394
378
 
395
379
  def datetime_from_str(date_str: str, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> datetime:
396
- deprecation_warning("datetime_from_str", "DELETE", date(2024, 6, 5))
397
380
  return datetime.strptime(date_str, datetime_format)
398
381
 
399
382
 
400
383
  def datetime_to_str(input_datetime: datetime, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> str:
401
- deprecation_warning("datetime_to_str", "DELETE", date(2024, 6, 5))
402
384
  return input_datetime.strftime(datetime_format)
403
385
 
404
386
 
405
387
  def validate_arguments(args: dict) -> None:
406
- deprecation_warning("validate_arguments", "DELETE", date(2024, 6, 5))
407
388
  """
408
389
  Validate method arguments to ensure they are not None or ''
409
390
  :param args: arguments to be validated (usually locals())
@@ -415,7 +396,6 @@ def validate_arguments(args: dict) -> None:
415
396
 
416
397
 
417
398
  def reformat_time_string(input_str: str) -> str:
418
- deprecation_warning("reformat_time_string", "DELETE", date(2024, 6, 5))
419
399
  """Example:
420
400
  "1234" -> "12:34:00:00"
421
401
  """
@@ -429,12 +409,10 @@ def reformat_time_string(input_str: str) -> str:
429
409
 
430
410
 
431
411
  def get_ip_v4():
432
- deprecation_warning("get_ip_v4", "DELETE", date(2024, 6, 5))
433
412
  return requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
434
413
 
435
414
 
436
415
  def get_ip_v6():
437
- deprecation_warning("get_ip_v6", "DELETE", date(2024, 6, 5))
438
416
  return requests.get('https://api.seeip.org/jsonip').json()['ip']
439
417
 
440
418
 
@@ -449,3 +427,15 @@ def camel_to_snake(camel_str: str) -> str:
449
427
  """Converts camelCase to snake_case."""
450
428
  snake_str = re.sub(r'(?<!^)(?=[A-Z])', '_', camel_str).lower()
451
429
  return snake_str
430
+
431
+
432
+ @lru_cache(maxsize=64) # don't print the same warning multiple times
433
+ def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
434
+ if start_date and start_date < date.today():
435
+ return
436
+ warnings_message = f"Please use {old_name} instead of {new_name}."
437
+ try:
438
+ warnings_message += " Called from: " + inspect.stack()[2].filename
439
+ except Exception:
440
+ pass
441
+ logger.warning(warnings_message)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-sdk-remote
3
- Version: 0.0.130
3
+ Version: 0.0.132
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
@@ -13,5 +13,13 @@ Requires-Dist: requests
13
13
  Requires-Dist: python-dotenv
14
14
  Requires-Dist: url-remote
15
15
  Requires-Dist: pyjwt
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: requires-dist
23
+ Dynamic: summary
16
24
 
17
25
  This is a package for sharing common functions used in different repositories
@@ -12,7 +12,6 @@ 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
16
15
  python_sdk_remote/src/unified_json.py
17
16
  python_sdk_remote/src/utilities.py
18
17
  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.130', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.132', # 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,18 +0,0 @@
1
- # TODO: remove once all breaking changes related to deprecation are done
2
- import inspect
3
- from datetime import date
4
- from functools import lru_cache
5
-
6
- from .mini_logger import MiniLogger as logger
7
-
8
-
9
- @lru_cache(maxsize=64) # don't print the same warning multiple times
10
- def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
11
- if start_date and start_date < date.today():
12
- return
13
- warnings_message = f"{new_name} {old_name} and use the local version."
14
- try:
15
- warnings_message += " Called from: " + inspect.stack()[2].filename
16
- except Exception:
17
- pass
18
- logger.warning(warnings_message)