neels has uploaded this change for review.

View Change

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 alrady used in
ConfigurableParameter: add an is_abstract flag.

Prep for Ie7171c152a7b478736f8825050305606b5af5735

Change-Id: Icfccdd0a8ecb5e0e9d22afa490d73c9f1849a64c
---
M pySim/esim/saip/param_source.py
1 file changed, 7 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/06/40206/1
diff --git a/pySim/esim/saip/param_source.py b/pySim/esim/saip/param_source.py
index ffb03b2..407882d 100644
--- a/pySim/esim/saip/param_source.py
+++ b/pySim/esim/saip/param_source.py
@@ -31,6 +31,7 @@

class ParamSource:
'abstract parameter source'
+ is_abstract = True

# This name should be short but descriptive, useful for a user interface, like 'random decimal digits'.
name = 'none'
@@ -41,7 +42,7 @@
# return a set() so that multiple inheritance does not return dups
return set(c
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
@@ -60,6 +61,7 @@

class ConstantSource(ParamSource):
'one value for all'
+ is_abstract = False
name = 'constant'

def __init__(self, val:str):
@@ -70,6 +72,7 @@

class RandomDigitSource(ParamSource):
'return a different sequence of random decimal digits each'
+ is_abstract = False
name = 'random decimal digits'

def __init__(self, num_digits, first_value, last_value):
@@ -109,6 +112,7 @@

class RandomHexDigitSource(ParamSource):
'return a different sequence of random hexadecimal digits each'
+ is_abstract = False
name = 'random hexadecimal digits'

def __init__(self, num_digits):
@@ -131,6 +135,7 @@

class IncDigitSource(RandomDigitSource):
'incrementing sequence of digits'
+ is_abstract = False
name = 'incrementing decimal digits'

def __init__(self, *args, **kwargs):
@@ -160,6 +165,7 @@

class CsvSource(ParamSource):
'apply a column from a CSV row, as passed in to ParamSource.get_next(csv_row)'
+ is_abstract = False
name = 'from CSV'

def __init__(self, csv_column):

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

Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icfccdd0a8ecb5e0e9d22afa490d73c9f1849a64c
Gerrit-Change-Number: 40206
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr@sysmocom.de>