pySim.apdu: Refactor cmd_to_dict() method

Let's factor out the "automatic processing using _tlv / _construct" as a
separate method.  This way we enable a derived class to first call that
automatic processing method, and then amend its output in a second step.

Change-Id: I1f066c0f1502020c88d99026c25bf2e283c3b4f5
This commit is contained in:
Harald Welte
2024-07-19 18:21:12 +02:00
parent 03eae595a3
commit 289d2343fa

View File

@@ -292,6 +292,10 @@ class ApduCommand(Apdu, metaclass=ApduCommandMeta):
if callable(method): if callable(method):
return method() return method()
else: else:
return self._cmd_to_dict()
def _cmd_to_dict(self) -> Dict:
"""back-end function performing automatic decoding using _construct / _tlv."""
r = {} r = {}
method = getattr(self, '_decode_p1p2', None) method = getattr(self, '_decode_p1p2', None)
if callable(method): if callable(method):