mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
saip: SmspTpScAddr: fix get_values_from_pes
Change-Id: I2010305340499c907bb7618c04c61e194db34814
This commit is contained in:
@@ -554,21 +554,39 @@ class SmspTpScAddr(ConfigurableParameter):
|
|||||||
example_input = '+49301234567'
|
example_input = '+49301234567'
|
||||||
default_source = param_source.ConstantSource
|
default_source = param_source.ConstantSource
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def validate_val(cls, val):
|
def str_to_tuple(addr_str):
|
||||||
val = super().validate_val(val)
|
|
||||||
addr_str = str(val)
|
|
||||||
if addr_str[0] == '+':
|
if addr_str[0] == '+':
|
||||||
digits = addr_str[1:]
|
digits = addr_str[1:]
|
||||||
international = True
|
international = True
|
||||||
else:
|
else:
|
||||||
digits = addr_str
|
digits = addr_str
|
||||||
international = False
|
international = False
|
||||||
|
return (international, digits)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tuple_to_str(addr_tuple):
|
||||||
|
international, digits = addr_tuple
|
||||||
|
if international:
|
||||||
|
ret = '+'
|
||||||
|
else:
|
||||||
|
ret = ''
|
||||||
|
ret += digits
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def validate_val(cls, val):
|
||||||
|
val = super().validate_val(val)
|
||||||
|
|
||||||
|
addr_tuple = cls.str_to_tuple(str(val))
|
||||||
|
|
||||||
|
international, digits = addr_tuple
|
||||||
if len(digits) > 20:
|
if len(digits) > 20:
|
||||||
raise ValueError(f'TP-SC-ADDR must not exceed 20 digits: {digits!r}')
|
raise ValueError(f'TP-SC-ADDR must not exceed 20 digits: {digits!r}')
|
||||||
if not digits.isdecimal():
|
if not digits.isdecimal():
|
||||||
raise ValueError(f'TP-SC-ADDR must only contain decimal digits: {digits!r}')
|
raise ValueError(f'TP-SC-ADDR must only contain decimal digits: {digits!r}')
|
||||||
return (international, digits)
|
|
||||||
|
return addr_tuple
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_val(cls, pes: ProfileElementSequence, val):
|
def apply_val(cls, pes: ProfileElementSequence, val):
|
||||||
@@ -627,7 +645,7 @@ class SmspTpScAddr(ConfigurableParameter):
|
|||||||
continue
|
continue
|
||||||
international = (international == 'international')
|
international = (international == 'international')
|
||||||
|
|
||||||
yield (international, digits)
|
yield { cls.name: cls.tuple_to_str((international, digits)) }
|
||||||
|
|
||||||
|
|
||||||
class SdKey(BinaryParam):
|
class SdKey(BinaryParam):
|
||||||
|
|||||||
Reference in New Issue
Block a user