mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-18 03:18:34 +03:00
personalization: discover all useful ConfigurableParameter subclasses
Discover all non-abstract subclasses of ConfigurableParameter in ConfigurableParameter.get_all_implementations(). To be able to automatically discover all practically useful ConfigurableParameter subclasses, introduce the is_abstract flag. ConfigurableParameter itself sets is_abstract = True, by default "hiding" subclasses. As soon as a subclass sets is_abstract = False, it becomes "public". It depends on the calling code to actually implement that decision -- this flag enables calling code to do so sanely. For example, the BinaryParam superclass keeps is_abstract = True, because per se it isn't capable of doing anything. The fully useful K and Opc subclasses set is_abstract = False. Implementation choice: I first tried to query an implicit abstract status via abc / @abstractmethod ways, but it did not match well. A subclass has no good implicit indicator, we need a flag instead. For example, a superclass may provide an apply_val() implementation and hence appear as non-abstract, but it is still not usable because a specific 'key' member is still None, which various subclasses set. Related: SYS#6768 Change-Id: I4970657294130b6b65d50ff19ffbb9ebab3be609
This commit is contained in:
@@ -1109,3 +1109,9 @@ class CardCommandSet:
|
||||
if cla and not cmd.match_cla(cla):
|
||||
return None
|
||||
return cmd
|
||||
|
||||
|
||||
def all_subclasses_of(cls):
|
||||
for subc in cls.__subclasses__():
|
||||
yield subc
|
||||
yield from all_subclasses_of(subc)
|
||||
|
||||
Reference in New Issue
Block a user