neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/40200?usp=email )


Change subject: personalization: indicate default ParamSource per 
ConfigurableParameter
......................................................................

personalization: indicate default ParamSource per ConfigurableParameter

Add default_source class members pointing to ParamSource classes to all
ConfigurableParameter subclasses.

This is useful to automatically set up a default ParamSource for a given
ConfigurableParameter subclass, during user interaction to produce a
batch personalization.

For example, if the user selects a Pin1 parameter, a calling program can
implicitly set this to a RandomDigitSource, which will magically make it
work the way that most users need.

BTW, default_source and default_value can be combined to configure a
matching ParamSource instance:

  my_source = MyParam.default_source.from_str( MyParam.default_value )

Change-Id: Ie58d13bce3fa1aa2547cf3cee918c2f5b30a8b32
---
M pySim/esim/saip/personalization.py
1 file changed, 8 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/00/40200/1

diff --git a/pySim/esim/saip/personalization.py 
b/pySim/esim/saip/personalization.py
index 34d7df9..317cac5 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -130,6 +130,7 @@
     max_len = None
     allow_len = None # a list of specific lengths
     default_value = None
+    default_source = None # a param_source.ParamSource subclass

     def __init__(self, input_value=None):
         self.input_value = input_value # the raw input value as given by caller
@@ -345,6 +346,7 @@
     min_len = 18
     max_len = 20
     default_value = '0' * 18
+    default_source = param_source.IncDigitSource

     @classmethod
     def validate_val(cls, val):
@@ -378,6 +380,7 @@
     min_len = 6
     max_len = 15
     default_value = '00101' + ('0' * 10)
+    default_source = param_source.IncDigitSource

     @classmethod
     def apply_val(cls, pes: ProfileElementSequence, val):
@@ -410,6 +413,7 @@
     key_id = None
     kvn = None
     key_usage_qual = None
+    default_source = param_source.RandomHexDigitSource

     @classmethod
     def _apply_sd(cls, pe: ProfileElement, value):
@@ -566,6 +570,7 @@
     rpad = 16
     keyReference = None
     default_value = '0' * allow_len
+    default_source = param_source.RandomDigitSource

     @classmethod
     def apply_val(cls, pes: ProfileElementSequence, val):
@@ -603,6 +608,7 @@
     min_len = 4
     max_len = 8
     default_value = '0' * max_len
+    default_source = param_source.RandomDigitSource
     keyReference = None

     @staticmethod
@@ -714,6 +720,7 @@
     algo_config_key = 'algorithmID'
     allow_len = 1
     default_value = 1  # Milenage
+    default_source = param_source.ConstantSource

     @classmethod
     def validate_val(cls, val):
@@ -732,6 +739,7 @@
     algo_config_key = 'key'
     allow_len = int(128/8) # length in bytes (from BinaryParam)
     default_value = '00' * allow_len
+    default_source = param_source.RandomHexDigitSource

 class Opc(K):
     name = 'OPc'

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40200?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie58d13bce3fa1aa2547cf3cee918c2f5b30a8b32
Gerrit-Change-Number: 40200
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofm...@sysmocom.de>

Reply via email to