fixeria submitted this change.

View Change



6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
saip: add numeric_base indicator to ConfigurableParameter

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
Jenkins: skip-card-test
---
M pySim/esim/saip/personalization.py
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 782e8e2..efde37a 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -71,6 +71,7 @@
min_len: minimum length of an input str; min_len = 4
max_len: maximum length of an input str; max_len = 8
allow_len: permit only specific lengths; allow_len = (8, 16, 32)
+ numeric_base: indicate hex / decimal, if any; numeric_base = None; numeric_base = 10; numeric_base = 16

Subclasses may change the meaning of these by overriding validate_val(), for example that the length counts
resulting bytes instead of a hexstring length. Most subclasses will be covered by the default validate_val().
@@ -126,6 +127,7 @@
allow_len = None # a list of specific lengths
example_input = None
default_source = None # a param_source.ParamSource subclass
+ numeric_base = None # or 10 or 16

def __init__(self, input_value=None):
self.input_value = input_value # the raw input value as given by caller
@@ -301,6 +303,7 @@
"""
allow_types = (str, int)
allow_chars = '0123456789'
+ numeric_base = 10

@classmethod
def validate_val(cls, val):
@@ -346,6 +349,7 @@
class IntegerParam(ConfigurableParameter):
allow_types = (str, int)
allow_chars = '0123456789'
+ numeric_base = 10

# two integers, if the resulting int should be range limited
min_val = None
@@ -378,6 +382,7 @@
allow_types = (str, io.BytesIO, bytes, bytearray, int)
allow_chars = '0123456789abcdefABCDEF'
strip_chars = ' \t\r\n'
+ numeric_base = 16
default_source = param_source.RandomHexDigitSource

@classmethod
@@ -551,6 +556,7 @@
name = 'SMSP-TP-SC-ADDR'
allow_chars = '+0123456789'
strip_chars = ' \t\r\n'
+ numeric_base = 10
max_len = 21 # '+' and 20 digits
min_len = 1
example_input = '+49301234567'

To view, visit change 42268. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib0977bbdd9a85167be7eb46dd331fedd529dae01
Gerrit-Change-Number: 42268
Gerrit-PatchSet: 8
Gerrit-Owner: neels <nhofmeyr@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>