Attention is currently required from: laforge, pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/31066 )
Change subject: ts_51_011: Implement Extended BCD Coding ......................................................................
Patch Set 2: Code-Review-1
(1 comment)
File pySim/ts_51_011.py:
https://gerrit.osmocom.org/c/pysim/+/31066/comment/7c605ca1_69d6a9f0 PS2, Line 366: 'dialing_nr'/ExtendedBcdAdapter(BcdAdapter(Rpad(Bytes(10)))),
yes, the ExtendedBcdAdapter is written in a way that it just translates the */# characters, and in o […]
But then it's not really a BcdAdapter, if it simply translates the */# characters? I don't want to block your work, but currently it looks cumbersome and confusing. Here is my proposal:
class ExtendedBcdAdapter(BcdAdapter): """convert a bytes() type to a string of BCD nibbles, replacing a/b with */# """
def _decode(self, obj, context, path): obj = obj.lower().replace("a","*").replace("b","#") return super()._decode(obj, context, path)
def _encode(self, obj, context, path): obj = obj.replace("*","a").replace("#","b") return super()._encode(obj, context, path)
With this implementation it can be used directly.