diff --git a/pySim/esim/saip/batch.py b/pySim/esim/saip/batch.py index 2af05790..9fad44fe 100644 --- a/pySim/esim/saip/batch.py +++ b/pySim/esim/saip/batch.py @@ -62,7 +62,7 @@ class BatchPersonalization: def __init__(self, n: int, src_pes: ProfileElementSequence, - params: list[ParamAndSrc]=None, + params: list[ParamAndSrc]=[], csv_rows: Generator=None, ): """ @@ -71,10 +71,10 @@ class BatchPersonalization: copied. params: list of ParamAndSrc instances, defining a ConfigurableParameter and corresponding ParamSource to fill in profile values. - csv_rows: A list or generator producing all CSV rows one at a time, starting with a row containing the column - headers. This is compatible with the python csv.reader. Each row gets passed to - ParamSource.get_next(), such that ParamSource implementations can access the row items. - See param_source.CsvSource. + csv_rows: A generator (or iter(list_of_rows)) producing all CSV rows one at a time, starting with a row + containing the column headers. This is compatible with the python csv.reader. Each row gets passed to + ParamSource.get_next(), such that ParamSource implementations can access the row items. See + param_source.CsvSource. """ self.n = n self.params = params or [] diff --git a/pySim/esim/saip/param_source.py b/pySim/esim/saip/param_source.py index 77f2e1cc..bbd0ccce 100644 --- a/pySim/esim/saip/param_source.py +++ b/pySim/esim/saip/param_source.py @@ -34,6 +34,11 @@ class ParamSource: # This name should be short but descriptive, useful for a user interface, like 'random decimal digits'. name = "none" + def __init__(self, input_val:str): + """Subclasses must implement a constructor with this signature. The input_val is typically a user entered string + value, and the subclass chooses how to store it; for example ConstantSource() just does self.val = input_val.""" + pass + @classmethod def from_str(cls, s:str): """Subclasses implement this: @@ -48,13 +53,12 @@ class ParamSource: This default implementation is an empty source.""" raise ParamSourceExhaustedExn() - class ConstantSource(ParamSource): """one value for all""" name = "constant" - def __init__(self, val:str): - self.val = val + def __init__(self, input_val:str): + self.val = input_val def get_next(self, csv_row:dict=None): return self.val @@ -92,7 +96,7 @@ class DecimalRangeSource(ParamSource): last_str = None first_value = int(first_str) - last_value = int(last_str) if last_str is not None else "9" * len(first_str) + last_value = int(last_str if last_str is not None else "9" * len(first_str)) return cls(num_digits=len(first_str), first_value=first_value, last_value=last_value) class RandomDigitSource(DecimalRangeSource):