aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-04-05 14:42:48 +0200
committerHarald Welte <laforge@osmocom.org>2022-04-05 14:42:48 +0200
commit0dcdfbfe94952d739255fdb96145ead01abb7c75 (patch)
treecc9d401dc543d763373f44b8cf0d6e528758f40c
parent785d48470930643e2a50157dd5e7fb756eb69106 (diff)
utils: Add DataObjectSequence.encode_multi()
This is the analogous to the decode_multi() method. Change-Id: Ifdd1b1bd4d67f447638858c3e92742ca6f884bfa
-rw-r--r--pySim/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/pySim/utils.py b/pySim/utils.py
index 8a7fcdb..ef770f9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1561,6 +1561,18 @@ class DataObjectSequence:
i += 1
return encoded
+ def encode_multi(self, decoded) -> bytes:
+ """Encode multiple occurrences of the sequence from the decoded input data.
+ Args:
+ decoded : list of json-serializable input data; one sequence per list item
+ Returns:
+ binary encoded output data
+ """
+ encoded = bytearray()
+ for d in decoded:
+ encoded += self.encode(d)
+ return encoded
+
class CardCommand:
"""A single card command / instruction."""