mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-09-13 10:33:56 +03:00
2554c60e82
Because of (1) and (2) below, enum.IntEnum is the wrong tool for
EnumParam. Simplify and fix both problems by using a dict as value map,
with capability for unlimited label string, and unlimited type of value.
In short:
(1) EnumParam's enum labels do not live in the python namespace; they are
chosen to make good UI labels and CSV values.
(2) enum values should support any type that the given PES attribute
needs (int, bool, bytes, ...), not only int.
In practice:
(1)
The first purpose of enum.IntEnum is to use the names of an enum in the
python namespace like "MY_LABEL". This means that the enum labels must
be valid python identifiers.
By using enum.IntEnum, we make it impossible to use enum labels like
"SUCI-on" (dash not allowed in python identifier) or "True" (keyword not
allowed as python identifier) or "2" (numeric constant cannot be a
python identifier). IOW, these labels are no longer supported to appear
in a drop-down select box in a web UI.
(2)
The second purpose of enum.IntEnum is to ensure that all values have a
checked type, i.e. int.
By using enum.IntEnum, we can only write int values directly to a PES
attribute. In practice, besides int, some use cases need bool or bytes
etc., i.e. EnumParam should be capable of storing *any* type as value,
as dictated by what needs to be put into the ProfileElementSequence.
History: this patch is the original version of EnumParam, which was
modified during CR to use enum.IntEnum.
Future: new ConfigurableParameters coming up for CR would like to
introduce non-python-identifier enum labels, and non-int values:
- MncLen (labels "2" and "3")
- EuiccMandatoryServiceParam (values True and False)
- EfUstServiceParam like SuciInUsim (labels "SUCI-in-UE" and
"SUCI-in-USIM")
Change-Id: I690ceccf0ec7ef7067bcaa5cec1303cdaf0f78a4
Jenkins: skip-card-test