mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-18 11:28:33 +03:00
saip: add numeric_base indicator to ConfigurableParameter and ParamSource
By default, numeric_base = None, to indicate that there are no explicit limitations on the number space. For parameters that are definitely decimal, set numeric_base = 10. For definitely hexadecimal, set numeric_base = 16. Do the same for ConfigurableParameter as well as ParamSource, so callers can match them up: if a parameter is numeric_base = 10, then omit sources that are numeric_base = 16, and vice versa. Change-Id: Ib0977bbdd9a85167be7eb46dd331fedd529dae01
This commit is contained in:
@@ -35,6 +35,7 @@ class ParamSource:
|
||||
|
||||
# This name should be short but descriptive, useful for a user interface, like 'random decimal digits'.
|
||||
name = "none"
|
||||
numeric_base = None # or 10 or 16
|
||||
|
||||
def __init__(self, input_val:str):
|
||||
"""Subclasses must implement a constructor with this signature. The input_val is typically a user entered string
|
||||
@@ -89,6 +90,8 @@ class InputExpandingParamSource(ParamSource):
|
||||
class DecimalRangeSource(InputExpandingParamSource):
|
||||
"""abstract: decimal numbers with a value range"""
|
||||
|
||||
numeric_base = 10
|
||||
|
||||
def __init__(self, num_digits, first_value, last_value):
|
||||
"""
|
||||
See also from_str().
|
||||
@@ -148,6 +151,7 @@ class RandomDigitSource(DecimalRangeSource, RandomSourceMixin):
|
||||
class RandomHexDigitSource(InputExpandingParamSource, RandomSourceMixin):
|
||||
"""return a different sequence of random hexadecimal digits each"""
|
||||
name = "random hexadecimal digits"
|
||||
numeric_base = 16
|
||||
used_keys = set()
|
||||
|
||||
def __init__(self, num_digits):
|
||||
|
||||
Reference in New Issue
Block a user