mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-26 23:38:32 +03:00
esim param_source: add is_abstract flag
Allow omitting some ParamSource subclassed from ParamSource.get_all_implementations(). My previous attempts at automagically detecting abstract classes failed conceptually, and the easiest, most explicit way is already used in ConfigurableParameter: add an is_abstract flag. Prep for Ie7171c152a7b478736f8825050305606b5af5735 Change-Id: Icfccdd0a8ecb5e0e9d22afa490d73c9f1849a64c
This commit is contained in:
@@ -31,6 +31,7 @@ class ParamSourceUndefinedExn(ParamSourceExn):
|
|||||||
|
|
||||||
class ParamSource:
|
class ParamSource:
|
||||||
'abstract parameter source. For usage, see personalization.BatchPersonalization.'
|
'abstract parameter source. For usage, see personalization.BatchPersonalization.'
|
||||||
|
is_abstract = True
|
||||||
|
|
||||||
# This name should be short but descriptive, useful for a user interface, like 'random decimal digits'.
|
# This name should be short but descriptive, useful for a user interface, like 'random decimal digits'.
|
||||||
name = 'none'
|
name = 'none'
|
||||||
@@ -41,7 +42,7 @@ class ParamSource:
|
|||||||
# return a set() so that multiple inheritance does not return dups
|
# return a set() so that multiple inheritance does not return dups
|
||||||
return set(c
|
return set(c
|
||||||
for c in all_subclasses_of(cls)
|
for c in all_subclasses_of(cls)
|
||||||
if ((not blacklist) or (c not in blacklist))
|
if (not c.is_abstract) and ((not blacklist) or (c not in blacklist))
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -60,6 +61,7 @@ class ParamSource:
|
|||||||
|
|
||||||
class ConstantSource(ParamSource):
|
class ConstantSource(ParamSource):
|
||||||
'one value for all'
|
'one value for all'
|
||||||
|
is_abstract = False
|
||||||
name = 'constant'
|
name = 'constant'
|
||||||
|
|
||||||
def __init__(self, val:str):
|
def __init__(self, val:str):
|
||||||
@@ -70,6 +72,7 @@ class ConstantSource(ParamSource):
|
|||||||
|
|
||||||
class RandomDigitSource(ParamSource):
|
class RandomDigitSource(ParamSource):
|
||||||
'return a different sequence of random decimal digits each'
|
'return a different sequence of random decimal digits each'
|
||||||
|
is_abstract = False
|
||||||
name = 'random decimal digits'
|
name = 'random decimal digits'
|
||||||
|
|
||||||
def __init__(self, num_digits, first_value, last_value):
|
def __init__(self, num_digits, first_value, last_value):
|
||||||
@@ -111,6 +114,7 @@ class RandomDigitSource(ParamSource):
|
|||||||
|
|
||||||
class RandomHexDigitSource(ParamSource):
|
class RandomHexDigitSource(ParamSource):
|
||||||
'return a different sequence of random hexadecimal digits each'
|
'return a different sequence of random hexadecimal digits each'
|
||||||
|
is_abstract = False
|
||||||
name = 'random hexadecimal digits'
|
name = 'random hexadecimal digits'
|
||||||
|
|
||||||
def __init__(self, num_digits):
|
def __init__(self, num_digits):
|
||||||
@@ -133,6 +137,7 @@ class RandomHexDigitSource(ParamSource):
|
|||||||
|
|
||||||
class IncDigitSource(RandomDigitSource):
|
class IncDigitSource(RandomDigitSource):
|
||||||
'incrementing sequence of digits'
|
'incrementing sequence of digits'
|
||||||
|
is_abstract = False
|
||||||
name = 'incrementing decimal digits'
|
name = 'incrementing decimal digits'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@@ -162,6 +167,7 @@ class IncDigitSource(RandomDigitSource):
|
|||||||
|
|
||||||
class CsvSource(ParamSource):
|
class CsvSource(ParamSource):
|
||||||
'apply a column from a CSV row, as passed in to ParamSource.get_next(csv_row)'
|
'apply a column from a CSV row, as passed in to ParamSource.get_next(csv_row)'
|
||||||
|
is_abstract = False
|
||||||
name = 'from CSV'
|
name = 'from CSV'
|
||||||
|
|
||||||
def __init__(self, csv_column):
|
def __init__(self, csv_column):
|
||||||
|
|||||||
Reference in New Issue
Block a user