polyapi-python 0.3.9.dev11__py3-none-any.whl → 0.3.9.dev13__py3-none-any.whl

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.
polyapi/__init__.py CHANGED
@@ -2,8 +2,6 @@ import os
2
2
  import sys
3
3
  import copy
4
4
  import truststore
5
- import logging
6
- import builtins
7
5
  from typing import Any, Dict, Optional, overload, Literal
8
6
  from typing_extensions import TypedDict
9
7
  truststore.inject_into_ssl()
@@ -100,19 +98,4 @@ class _PolyCustom:
100
98
  return new
101
99
 
102
100
 
103
- polyCustom: PolyCustomDict = _PolyCustom()
104
-
105
- original_print = print
106
-
107
- logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(message)s')
108
-
109
- def log_prints(*objects, sep=' ', end='\n', file=sys.stdout, flush=False):
110
- message = sep.join(map(str, objects)) + end
111
- if file is sys.stdout:
112
- logging.info(message)
113
- elif file is sys.stderr:
114
- logging.error(message)
115
- else:
116
- original_print(*objects, sep=sep, end=end, file=file, flush=flush)
117
-
118
- builtins.print = log_prints
101
+ polyCustom: PolyCustomDict = _PolyCustom()
polyapi/execute.py CHANGED
@@ -1,11 +1,12 @@
1
1
  from typing import Dict, Optional
2
2
  import requests
3
3
  import os
4
- import sys
4
+ import logging
5
5
  from requests import Response
6
6
  from polyapi.config import get_api_key_and_url, get_mtls_config
7
7
  from polyapi.exceptions import PolyApiException
8
8
 
9
+ logger = logging.getLogger("poly")
9
10
 
10
11
  def direct_execute(function_type, function_id, data) -> Response:
11
12
  """ execute a specific function id/type
@@ -48,7 +49,7 @@ def direct_execute(function_type, function_id, data) -> Response:
48
49
  if (resp.status_code < 200 or resp.status_code >= 300):
49
50
  error_content = resp.content.decode("utf-8", errors="ignore")
50
51
  if function_type == 'api' and os.getenv("LOGS_ENABLED"):
51
- print(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}", file=sys.stderr)
52
+ logger.error(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
52
53
  elif function_type != 'api':
53
54
  raise PolyApiException(f"{resp.status_code}: {error_content}")
54
55
 
@@ -72,7 +73,7 @@ def execute(function_type, function_id, data) -> Response:
72
73
  if (resp.status_code < 200 or resp.status_code >= 300) and os.getenv("LOGS_ENABLED"):
73
74
  error_content = resp.content.decode("utf-8", errors="ignore")
74
75
  if function_type == 'api' and os.getenv("LOGS_ENABLED"):
75
- print(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}", file=sys.stderr)
76
+ logger.error(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
76
77
  elif function_type != 'api':
77
78
  raise PolyApiException(f"{resp.status_code}: {error_content}")
78
79
 
polyapi/poly_tables.py CHANGED
@@ -310,7 +310,7 @@ def _get_column_type_str(name: str, schema: Dict[str, Any], is_required: bool) -
310
310
  elif col_type == "object":
311
311
  if isinstance(schema.get("patternProperties"), dict):
312
312
  # TODO: Handle multiple pattern properties
313
- result = f"Dict[str, {_get_column_type_str(f'{name}_', schema["patternProperties"], True)}]"
313
+ result = f"Dict[str, {_get_column_type_str(f'{name}_', schema['patternProperties'], True)}]"
314
314
  elif isinstance(schema.get("properties"), dict) and len(schema["properties"].values()) > 0:
315
315
  # TODO: Handle x-poly-refs
316
316
  result = f'"{name}"'
polyapi/schema.py CHANGED
@@ -3,8 +3,6 @@
3
3
  import logging
4
4
  import contextlib
5
5
  import re
6
- import polyapi
7
- import builtins
8
6
  from typing import Dict
9
7
  from jsonschema_gentypes.cli import process_config
10
8
  from jsonschema_gentypes import configuration
@@ -91,12 +89,9 @@ def generate_schema_types(input_data: Dict, root=None):
91
89
  }
92
90
 
93
91
  # jsonschema_gentypes prints source to stdout
94
- # no option to suppress so we do this
95
- # Not reverting the print monkeypatch causes print to bypass redirect
96
- builtins.print = polyapi.original_print
92
+ # no option to surpress so we do this
97
93
  with contextlib.redirect_stdout(None):
98
94
  process_config(config, [tmp_input])
99
- builtins.print = polyapi.log_prints
100
95
 
101
96
  with open(tmp_output, encoding='utf-8') as f:
102
97
  output = f.read()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyapi-python
3
- Version: 0.3.9.dev11
3
+ Version: 0.3.9.dev13
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- polyapi/__init__.py,sha256=y-NBe7eopIdiqvJOD9KRjz90AgTR-zziBovF9h-CNzo,3725
1
+ polyapi/__init__.py,sha256=hw7x4j9JNJfPdkIOZqV0X9pbYcw3_5AH1iQFdSogH-c,3235
2
2
  polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
3
3
  polyapi/api.py,sha256=2nds6ZdNe9OHvCba4IjOPga0CAYIsib2SbhEyDDCmd8,2188
4
4
  polyapi/auth.py,sha256=EGstBjTSdAydI5hGAHeRRc1GcmHshogudb3sxCgO6zA,5341
@@ -9,24 +9,24 @@ polyapi/constants.py,sha256=sc-FnS0SngBLvSu1ZWMs0UCf9EYD1u1Yhfr-sZXGLns,607
9
9
  polyapi/deployables.py,sha256=W8K6D8dypqntwjC9jAHxoR7hTfnG3Oj49nVULtq1OTQ,12133
10
10
  polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
11
11
  polyapi/exceptions.py,sha256=Zh7i7eCUhDuXEdUYjatkLFTeZkrx1BJ1P5ePgbJ9eIY,89
12
- polyapi/execute.py,sha256=WQH5bLG3zLpb5_21y9dUvhCLJy9kiryWcTvr9glCji0,4404
12
+ polyapi/execute.py,sha256=q4xtV6rYO8f-8hULlFTlVgoTVQSahvlMu3FHkFzYpMs,4423
13
13
  polyapi/function_cli.py,sha256=H0sVrbvRBXw_xeApe2MvQw8p_xE7jVTTOU-07Dg041A,4220
14
14
  polyapi/generate.py,sha256=thOrjq4suOkR97x00rthor96aslzzOaAAo4yxLtiuh0,21081
15
15
  polyapi/parser.py,sha256=20ZE7kSXx3UL7QVSIYYxzsnJlygVbsaDAg9q7c41WxQ,20695
16
16
  polyapi/poly_schemas.py,sha256=fZ6AGvHcOKQJtlrzSuzeBNed5DxPMA2dJGdJvuFCHWM,9066
17
- polyapi/poly_tables.py,sha256=xq-6IXsgMjwkpvL62B95tZbMYFJ21d-5hbTzz00saEg,15559
17
+ polyapi/poly_tables.py,sha256=gRLGnNnLdFYuSfy-7gg4hjzzeVak8LJkfLX6n0u4RJg,15559
18
18
  polyapi/prepare.py,sha256=NQzpMIoakNovStvOGOmqSYIpTwiWXaweNSE9se10A2E,7420
19
19
  polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  polyapi/rendered_spec.py,sha256=nJEj2vRgG3N20fU4s-ThRtOIwAuTzXwXuOBIkXljDVc,2240
21
- polyapi/schema.py,sha256=NyS9OgQJM0YAuZ8CLIM_9QitfpZf4lU5MFHlyFZKHCM,5498
21
+ polyapi/schema.py,sha256=-mtRV5iL3CV0X3phXhGYFV8sLz0KouTACOKWyGO9Pwc,5309
22
22
  polyapi/server.py,sha256=YXWxhYBx-hluwDQ8Jvfpy2s8ogz0GsNTMcZVNcP5ca8,2147
23
23
  polyapi/sync.py,sha256=5iiQHu76my2AuGVoPRjD2t9Y0VvGJCZ8W2uG0F1sWPY,6722
24
24
  polyapi/typedefs.py,sha256=VEaYODLm-3a26_cK1uSRoYwenmprLOQQdoKFz4gqK_0,5587
25
25
  polyapi/utils.py,sha256=RpkXWi6jiwjozrX9iovPBK708w0W117ueN41uhQgnZU,12567
26
26
  polyapi/variables.py,sha256=SJv106ePpQP5mx7Iiafl_shtFlE8FoaO9Q8lvw-3IRg,7270
27
27
  polyapi/webhook.py,sha256=I3_uOl4f4L2-2WehzRLMVMRrB-76EiXCPA9Vzoaj30I,5326
28
- polyapi_python-0.3.9.dev11.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
29
- polyapi_python-0.3.9.dev11.dist-info/METADATA,sha256=AUHsgxmqz3BSUNaAbrckRS0X8BJdx4rCwKnyfBWRiTk,5785
30
- polyapi_python-0.3.9.dev11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- polyapi_python-0.3.9.dev11.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
32
- polyapi_python-0.3.9.dev11.dist-info/RECORD,,
28
+ polyapi_python-0.3.9.dev13.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
29
+ polyapi_python-0.3.9.dev13.dist-info/METADATA,sha256=T4AzW7yA3-JgL5qSCqQ3ZwGiQo1Wfd_87nC5wr-zkcs,5785
30
+ polyapi_python-0.3.9.dev13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ polyapi_python-0.3.9.dev13.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
32
+ polyapi_python-0.3.9.dev13.dist-info/RECORD,,