py2api 0.0.5__tar.gz → 0.0.6__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.
- {py2api-0.0.5 → py2api-0.0.6}/PKG-INFO +2 -2
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/input_trans.py +2 -1
- py2api-0.0.6/py2api/tests/test_input_trans_else.py +21 -0
- {py2api-0.0.5 → py2api-0.0.6}/pyproject.toml +1 -1
- {py2api-0.0.5 → py2api-0.0.6}/.editorconfig +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.github/workflows/ci.yml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.gitignore +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.idea/misc.xml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.idea/modules.xml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.idea/py2api.iml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.idea/vcs.xml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/.idea/workspace.xml +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/LICENSE +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/README.md +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/docsrc/.gitignore +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/docsrc/Makefile +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/docsrc/conf.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/docsrc/index.rst +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/docsrc/make.bat +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/.gitignore +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/__init__.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/constants.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/defaults.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/errors.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/examples/__init__.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/examples/pong.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/examples/streaming_sine.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/examples/wrapping_a_class.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/examples/wrapping_a_module.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/obj_wrap.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/output_trans.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/__init__.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/app_maker.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/constants.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/obj_wrap.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/old/old_input_trans_with_val_type.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/py2rest/rest2py.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/scrap_obj_wrap.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/tests/wrapping_a_class.py +0 -0
- {py2api-0.0.5 → py2api-0.0.6}/py2api/util.py +0 -0
|
@@ -304,8 +304,9 @@ class InputTrans:
|
|
|
304
304
|
# return trans_func
|
|
305
305
|
|
|
306
306
|
############### _ELSE ###############
|
|
307
|
+
# Only a fallback: a match found above (source, attr or argname) wins.
|
|
307
308
|
_trans_spec = trans_spec.get(_ELSE, TRANS_NOT_FOUND)
|
|
308
|
-
if _trans_spec:
|
|
309
|
+
if trans_func is TRANS_NOT_FOUND and _trans_spec:
|
|
309
310
|
trans_func = self.search_trans_func(
|
|
310
311
|
attr, argname, val, trans_spec=_trans_spec, source=source
|
|
311
312
|
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""``_ELSE`` is a fallback: a more specific match must win over it."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from py2api.constants import _ARGNAME, _ELSE
|
|
6
|
+
from py2api.py2rest.input_trans import InputTrans
|
|
7
|
+
|
|
8
|
+
SPEC = {_ARGNAME: {"index": int, "source": str}, _ELSE: json.loads}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _found(argname):
|
|
12
|
+
return InputTrans(trans_spec=SPEC).search_trans_func(None, argname, "val", SPEC)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_a_matching_argname_beats_else():
|
|
16
|
+
assert _found("source") is str
|
|
17
|
+
assert _found("index") is int
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_else_applies_when_nothing_else_matches():
|
|
21
|
+
assert _found("other") is json.loads
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|