dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/pysim/+/42101?usp=email )
Change subject: esim/http_json_api: add alternative API interface (follow up)
......................................................................
esim/http_json_api: add alternative API interface (follow up)
This is a follow up patch to change:
I2a5d4b59b12e08d5eae7a1215814d3a69c8921f6
- do not ignore length of kwargs
- fix role parameter (roles other than 'legacy_client' can be used now)
- use startswith instead of match
Related: SYS#7866
Change-Id: Ifae13e82d671ff09bddf771f063a388d2ab283eb
---
M pySim/esim/http_json_api.py
1 file changed, 3 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/01/42101/1
diff --git a/pySim/esim/http_json_api.py b/pySim/esim/http_json_api.py
index 94e60cb..cd95e0d 100644
--- a/pySim/esim/http_json_api.py
+++ b/pySim/esim/http_json_api.py
@@ -19,7 +19,6 @@
import requests
import logging
import json
-from re import match
from typing import Optional
import base64
from twisted.web.server import Request
@@ -211,7 +210,7 @@
# additional custom HTTP headers (server responses)
extra_http_res_headers = {}
- def __new__(cls, *args, role = None, **kwargs):
+ def __new__(cls, *args, role = 'legacy_client', **kwargs):
"""
Args:
args: (see JsonHttpApiClient and JsonHttpApiServer)
@@ -221,14 +220,13 @@
# Create a dictionary with the class attributes of this class (the
properties listed above and the encode_
# decode_ methods below). The dictionary will not include any
dunder/magic methods
- cls_attr = { attr_name: getattr(cls, attr_name) for attr_name in
dir(cls) if not match("__.*__", attr_name) }
+ cls_attr = {attr_name: getattr(cls, attr_name) for attr_name in
dir(cls) if not attr_name.startswith('__')}
# Normal instantiation as JsonHttpApiFunction:
- if len(args) == 0:
+ if len(args) == 0 and len(kwargs) == 0:
return type(cls.__name__, (abc.ABC,), cls_attr)()
# Instantiation as as JsonHttpApiFunction with a JsonHttpApiClient or
JsonHttpApiServer base
- role = kwargs.get('role', 'legacy_client')
if role == 'legacy_client':
# Deprecated: With the advent of the server role
(JsonHttpApiServer) the API had to be changed. To maintain
# compatibility with existing code (out-of-tree) the original
behaviour and API interface and behaviour had
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/42101?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifae13e82d671ff09bddf771f063a388d2ab283eb
Gerrit-Change-Number: 42101
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>