python-sdk-remote 0.0.93__tar.gz → 0.0.95__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.93 → python_sdk_remote-0.0.95}/PKG-INFO +1 -2
  2. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/http_response.py +22 -7
  3. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/utilities.py +5 -0
  4. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote.egg-info/PKG-INFO +1 -2
  5. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote.egg-info/SOURCES.txt +0 -1
  6. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote.egg-info/requires.txt +0 -1
  7. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/setup.py +2 -3
  8. python_sdk_remote-0.0.93/python_sdk_remote/src/get_dependencies.py +0 -58
  9. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/README.md +0 -0
  10. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/pyproject.toml +0 -0
  11. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/__init__.py +0 -0
  12. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/constants.py +0 -0
  13. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/item.py +0 -0
  14. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/mini_logger.py +0 -0
  15. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/our_object.py +0 -0
  16. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/unified_json.py +0 -0
  17. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/valid_json_versions.py +0 -0
  18. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote/src/validate_environment.py +0 -0
  19. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  20. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/python_sdk_remote.egg-info/top_level.txt +0 -0
  21. {python_sdk_remote-0.0.93 → python_sdk_remote-0.0.95}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.93
3
+ Version: 0.0.95
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
@@ -11,6 +11,5 @@ Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: python-dotenv
13
13
  Requires-Dist: url-remote
14
- Requires-Dist: http-status-codes
15
14
 
16
15
  This is a package for sharing common functions used in different repositories
@@ -1,5 +1,6 @@
1
1
  import json
2
- from http_constants import status
2
+ from typing import Any
3
+ from http import HTTPStatus
3
4
 
4
5
  from .mini_logger import MiniLogger as logger
5
6
 
@@ -10,7 +11,21 @@ AUTHORIZATION_PREFIX = 'Bearer '
10
11
  # 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 # noqa501
11
12
  # TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
12
13
 
13
- # Former name was create_http_headers()
14
+ # TODO: add handler wrapper?
15
+
16
+ def get_payload_dict_from_event(event: dict) -> dict:
17
+ """Extracts params sent with payload"""
18
+ return json.loads(event.get('body') or '{}')
19
+
20
+ def get_path_parameters_dict_from_event(event: dict) -> dict:
21
+ """Extracts params sent implicitly: `url/param?test=5` -> param
22
+ (when the path is defined with /{param})"""
23
+ return event.get('pathParameters') or {}
24
+
25
+ def get_query_string_parameters_from_event(event: dict) -> dict:
26
+ """Extracts params sent explicitly: `url/test?a=1&b=2` -> {'a': '1', 'b': '2'}"""
27
+ return event.get("queryStringParameters") or {} # params sent with ?a=1&b=2
28
+
14
29
  def create_authorization_http_headers(user_jwt: str) -> dict:
15
30
  logger.start(object={"user_jwt": user_jwt})
16
31
  authorization_http_headers = {
@@ -40,10 +55,10 @@ def create_return_http_headers() -> dict:
40
55
  logger.end(object={"return_http_headers": return_http_headers})
41
56
  return return_http_headers
42
57
 
43
- def create_error_http_response(exception: Exception) -> dict:
58
+ def create_error_http_response(exception: Exception, status_code: HTTPStatus = HTTPStatus.BAD_REQUEST) -> dict:
44
59
  logger.start(object={"exception": exception})
45
60
  error_http_response = {
46
- "statusCode": status.BAD_GATEWAY,
61
+ "statusCode": HTTPStatus.value,
47
62
  "headers": create_return_http_headers(),
48
63
  "body": create_http_body({"error": str(exception)})
49
64
  }
@@ -51,10 +66,10 @@ def create_error_http_response(exception: Exception) -> dict:
51
66
  return error_http_response
52
67
 
53
68
 
54
- def create_ok_http_response(body: dict) -> dict:
69
+ def create_ok_http_response(body: Any) -> dict:
55
70
  logger.start(object={"body": body})
56
71
  ok_http_response = {
57
- "statusCode": status.OK,
72
+ "statusCode": HTTPStatus.OK.value,
58
73
  "headers": create_return_http_headers(),
59
74
  "body": create_http_body(body)
60
75
  }
@@ -63,7 +78,7 @@ def create_ok_http_response(body: dict) -> dict:
63
78
 
64
79
 
65
80
  # https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format
66
- def create_http_body(body: dict) -> str:
81
+ def create_http_body(body: Any) -> str:
67
82
  # TODO console.warning() if the body is not a valid camelCase JSON
68
83
  # https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
69
84
  logger.start(object={"body": body})
@@ -10,7 +10,12 @@ from .http_response import (create_authorization_http_headers, get_user_jwt_from
10
10
  from .mini_logger import MiniLogger as logger
11
11
 
12
12
  load_dotenv()
13
+ # raise Exception("Failed to load environment variables from .env file\n"
14
+ # "Please check if the file exists, maybe you are not in the right venv?")
13
15
 
16
+ # TODO: add cache with/out timeout decorator
17
+
18
+ DEFAULT_LANG_CODE_STR = "en"
14
19
 
15
20
  def timedelta_to_time_format(time_delta: timedelta) -> str:
16
21
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.93
3
+ Version: 0.0.95
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
@@ -11,6 +11,5 @@ Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: python-dotenv
13
13
  Requires-Dist: url-remote
14
- Requires-Dist: http-status-codes
15
14
 
16
15
  This is a package for sharing common functions used in different repositories
@@ -8,7 +8,6 @@ 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
10
  python_sdk_remote/src/constants.py
11
- python_sdk_remote/src/get_dependencies.py
12
11
  python_sdk_remote/src/http_response.py
13
12
  python_sdk_remote/src/item.py
14
13
  python_sdk_remote/src/mini_logger.py
@@ -1,3 +1,2 @@
1
1
  python-dotenv
2
2
  url-remote
3
- http-status-codes
@@ -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.93', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.95', # 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",
@@ -24,7 +24,6 @@ setuptools.setup(
24
24
  ],
25
25
  install_requires=[
26
26
  "python-dotenv",
27
- "url-remote",
28
- "http-status-codes"
27
+ "url-remote"
29
28
  ]
30
29
  )
@@ -1,58 +0,0 @@
1
- # pip install BeautifulSoup4 requests importlib-metadata
2
- import subprocess
3
- import sys
4
- import json
5
- from collections import defaultdict
6
-
7
- import importlib_metadata
8
- import requests
9
- from bs4 import BeautifulSoup
10
-
11
-
12
- def install(packages):
13
- print("Installing...", packages)
14
- if isinstance(packages, str):
15
- packages = [packages]
16
- try:
17
- subprocess.run([sys.executable, "-m", "pip", "install", "-U", "--no-deps"] + packages, check=False)
18
- except Exception as e:
19
- print(e)
20
-
21
-
22
- def get_dependencies_per_package(include_packages):
23
- dependencies_per_package = defaultdict(list)
24
- for dist in importlib_metadata.distributions():
25
- package_name = dist.metadata['Name']
26
- if package_name not in include_packages:
27
- continue
28
-
29
- dependencies = dist.metadata.get_all('Requires-Dist', [])
30
- for dependency in dependencies:
31
- depend_on = dependency.split()[0]
32
- if depend_on in include_packages:
33
- dependencies_per_package[depend_on].append(package_name)
34
-
35
- return dependencies_per_package
36
-
37
-
38
- def get_included_packages():
39
- url = "https://pypi.org/user/circles/"
40
- class_name = "package-snippet__title"
41
-
42
- response = requests.get(url)
43
- soup = BeautifulSoup(response.text, "html.parser")
44
- package_names = soup.find_all("h3", class_=class_name)
45
- included_packages = [package_name.text for package_name in package_names]
46
- install(included_packages)
47
- return included_packages
48
-
49
-
50
- def main():
51
- include_packages = get_included_packages()
52
- dependencies_per_package = get_dependencies_per_package(include_packages)
53
- with open('dependencies.json', 'w') as f:
54
- json.dump(dependencies_per_package, f, indent=4)
55
-
56
-
57
- if __name__ == "__main__":
58
- main()