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:
Neels Hofmeyr
2026-02-02 02:23:52 +01:00
parent 59bec08eae
commit 03e17a7366
2 changed files with 10 additions and 0 deletions

View File

@@ -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
@classmethod
def from_str(cls, s:str):
@@ -85,6 +86,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().
@@ -144,6 +147,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):