mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-07-06 03:38:47 +03:00
Allow saving unknown files with raw data
When a file has no custom encoder, the decode path returns {'raw': ...}
but the encode path raised NotImplementedError. Add a fallback in all
encoder methods to return the raw data directly when present in the
abstract_data dict, allowing unknown files to round-trip.
This commit is contained in:
@@ -863,6 +863,8 @@ class TransparentEF(CardEF):
|
||||
t = self._tlv() if inspect.isclass(self._tlv) else self._tlv
|
||||
t.from_dict(abstract_data)
|
||||
return t.to_tlv()
|
||||
if 'raw' in abstract_data:
|
||||
return h2b(abstract_data['raw'])
|
||||
raise NotImplementedError(
|
||||
"%s encoder not yet implemented. Patches welcome." % self)
|
||||
|
||||
@@ -892,6 +894,8 @@ class TransparentEF(CardEF):
|
||||
t = self._tlv() if inspect.isclass(self._tlv) else self._tlv
|
||||
t.from_dict(abstract_data)
|
||||
return b2h(t.to_tlv())
|
||||
if 'raw' in abstract_data:
|
||||
return abstract_data['raw']
|
||||
raise NotImplementedError(
|
||||
"%s encoder not yet implemented. Patches welcome." % self)
|
||||
|
||||
@@ -1166,6 +1170,8 @@ class LinFixedEF(CardEF):
|
||||
t = self._tlv() if inspect.isclass(self._tlv) else self._tlv
|
||||
t.from_dict(abstract_data)
|
||||
return b2h(t.to_tlv())
|
||||
if 'raw' in abstract_data:
|
||||
return abstract_data['raw']
|
||||
raise NotImplementedError(
|
||||
"%s encoder not yet implemented. Patches welcome." % self)
|
||||
|
||||
@@ -1195,6 +1201,8 @@ class LinFixedEF(CardEF):
|
||||
t = self._tlv() if inspect.isclass(self._tlv) else self._tlv
|
||||
t.from_dict(abstract_data)
|
||||
return t.to_tlv()
|
||||
if 'raw' in abstract_data:
|
||||
return h2b(abstract_data['raw'])
|
||||
raise NotImplementedError(
|
||||
"%s encoder not yet implemented. Patches welcome." % self)
|
||||
|
||||
@@ -1386,6 +1394,8 @@ class TransRecEF(TransparentEF):
|
||||
t = self._tlv() if inspect.isclass(self._tlv) else self._tlv
|
||||
t.from_dict(abstract_data)
|
||||
return b2h(t.to_tlv())
|
||||
if 'raw' in abstract_data:
|
||||
return abstract_data['raw']
|
||||
raise NotImplementedError(
|
||||
"%s encoder not yet implemented. Patches welcome." % self)
|
||||
|
||||
@@ -1415,6 +1425,8 @@ class TransRecEF(TransparentEF):
|
||||
t = self._tlv() if inspect.isclass(self._tlv) else self._tlv
|
||||
t.from_dict(abstract_data)
|
||||
return t.to_tlv()
|
||||
if 'raw' in abstract_data:
|
||||
return h2b(abstract_data['raw'])
|
||||
raise NotImplementedError(
|
||||
"%s encoder not yet implemented. Patches welcome." % self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user