From 745a60b63b6c3510bd8d88adcdf74c054f4cf60d Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 3 Mar 2026 23:47:00 +0100 Subject: [PATCH] Revert "esim/http_json_api: add alternative API interface (follow up)" This reverts commit 8b2a49aa8ebef37d874dd5b8e7545e8e3ac27d77. --- pySim/esim/http_json_api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pySim/esim/http_json_api.py b/pySim/esim/http_json_api.py index cd95e0d6..94e60cba 100644 --- a/pySim/esim/http_json_api.py +++ b/pySim/esim/http_json_api.py @@ -19,6 +19,7 @@ import abc import requests import logging import json +from re import match from typing import Optional import base64 from twisted.web.server import Request @@ -210,7 +211,7 @@ class JsonHttpApiFunction(abc.ABC): # additional custom HTTP headers (server responses) extra_http_res_headers = {} - def __new__(cls, *args, role = 'legacy_client', **kwargs): + def __new__(cls, *args, role = None, **kwargs): """ Args: args: (see JsonHttpApiClient and JsonHttpApiServer) @@ -220,13 +221,14 @@ class JsonHttpApiFunction(abc.ABC): # 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 attr_name.startswith('__')} + cls_attr = { attr_name: getattr(cls, attr_name) for attr_name in dir(cls) if not match("__.*__", attr_name) } # Normal instantiation as JsonHttpApiFunction: - if len(args) == 0 and len(kwargs) == 0: + if len(args) == 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