laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/36027?usp=email )

Change subject: saip.personalization: automatically compute class 'name' 
attribute
......................................................................

saip.personalization: automatically compute class 'name' attribute

We can use the metaclass to set a proper non-camel-case name attribute.

Change-Id: If02df436c8f5ce01d21e9ee077ad3736e669d103
---
M pySim/esim/saip/personalization.py
1 file changed, 13 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/pySim/esim/saip/personalization.py 
b/pySim/esim/saip/personalization.py
index 7ac0dbd..3dad208 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -19,6 +19,7 @@
 import io
 from typing import List, Tuple

+from pySim.tlv import camel_to_snake
 from pySim.utils import enc_iccid, enc_imsi, h2b, rpad, sanitize_iccid
 from pySim.esim.saip import ProfileElement, ProfileElementSequence

@@ -41,6 +42,7 @@
         x = super().__new__(metacls, name, bases, namespace)
         for k, v in kwargs.items():
             setattr(x, k, v)
+        setattr(x, 'name', camel_to_snake(name))
         return x

 class ConfigurableParameter(abc.ABC, metaclass=ClassVarMeta):
@@ -63,7 +65,6 @@
 class Iccid(ConfigurableParameter):
     """Configurable ICCID.  Expects the value to be a string of decimal digits.
     If the string of digits is only 18 digits long, a Luhn check digit will be 
added."""
-    name = 'iccid'

     def validate(self):
         # convert to string as it migt be an integer
@@ -83,7 +84,6 @@
 class Imsi(ConfigurableParameter):
     """Configurable IMSI. Expects value to be a string of digits. 
Automatically sets the ACC to
     the last digit of the IMSI."""
-    name = 'imsi'

     def validate(self):
         # convert to string as it migt be an integer

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/36027?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: If02df436c8f5ce01d21e9ee077ad3736e669d103
Gerrit-Change-Number: 36027
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to