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

Change subject: esim.saip: Move OID to separate sub-module
......................................................................

esim.saip: Move OID to separate sub-module

This helps us to prevent circular imports in follow-up code.

Change-Id: I94f85f2257d4702376f4ba5eb995a544a2e53fd3
---
M pySim/esim/saip/__init__.py
A pySim/esim/saip/oid.py
2 files changed, 84 insertions(+), 57 deletions(-)

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




diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 9b182e5..251395f 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -25,63 +25,6 @@

 asn1 = compile_asn1_subdir('saip')
 
-class oid:
-    class OID:
-        @staticmethod
-        def intlist_from_str(instr: str) -> List[int]:
-            return [int(x) for x in instr.split('.')]
-
-        def __init__(self, initializer):
-            if type(initializer) == str:
-                self.intlist = self.intlist_from_str(initializer)
-            else:
-                self.intlist = initializer
-
-        def __str__(self):
-            return '.'.join([str(x) for x in self.intlist])
-
-        def __repr__(self):
-            return 'OID(%s)' % (str(self))
-
-
-    class eOID(OID):
-        """OID helper for TCA eUICC prefix"""
-        __prefix = [2,23,143,1]
-        def __init__(self, initializer):
-            if type(initializer) == str:
-                initializer = self.intlist_from_str(initializer)
-            super().__init__(self.__prefix + initializer)
-
-    MF = eOID("2.1")
-    DF_CD = eOID("2.2")
-    DF_TELECOM = eOID("2.3")
-    DF_TELECOM_v2 = eOID("2.3.2")
-    ADF_USIM_by_default = eOID("2.4")
-    ADF_USIM_by_default_v2 = eOID("2.4.2")
-    ADF_USIM_not_by_default = eOID("2.5")
-    ADF_USIM_not_by_default_v2 = eOID("2.5.2")
-    ADF_USIM_not_by_default_v3 = eOID("2.5.3")
-    DF_PHONEBOOK_ADF_USIM = eOID("2.6")
-    DF_GSM_ACCESS_ADF_USIM = eOID("2.7")
-    ADF_ISIM_by_default = eOID("2.8")
-    ADF_ISIM_not_by_default = eOID("2.9")
-    ADF_ISIM_not_by_default_v2 = eOID("2.9.2")
-    ADF_CSIM_by_default = eOID("2.10")
-    ADF_CSIM_by_default_v2 = eOID("2.10.2")
-    ADF_CSIM_not_by_default = eOID("2.11")
-    ADF_CSIM_not_by_default_v2 = eOID("2.11.2")
-    DF_EAP = eOID("2.12")
-    DF_5GS = eOID("2.13")
-    DF_5GS_v2 = eOID("2.13.2")
-    DF_5GS_v3 = eOID("2.13.3")
-    DF_5GS_v4 = eOID("2.13.4")
-    DF_SAIP = eOID("2.14")
-    DF_SNPN = eOID("2.15")
-    DF_5GProSe = eOID("2.16")
-    IoT_default = eOID("2.17")
-    IoT_default = eOID("2.18")
-
-
 class ProfileElement:
     def _fixup_sqnInit_dec(self):
         """asn1tools has a bug when working with SEQUENCE OF that have DEFAULT 
values. Let's work around
diff --git a/pySim/esim/saip/oid.py b/pySim/esim/saip/oid.py
new file mode 100644
index 0000000..8b2870e
--- /dev/null
+++ b/pySim/esim/saip/oid.py
@@ -0,0 +1,73 @@
+# Implementation of SimAlliance/TCA Interoperable Profile OIDs
+#
+# (C) 2023-2024 by Harald Welte <[email protected]>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from typing import List, Union
+
+class OID:
+    @staticmethod
+    def intlist_from_str(instr: str) -> List[int]:
+        return [int(x) for x in instr.split('.')]
+
+    def __init__(self, initializer: Union[List[int], str]):
+        if type(initializer) == str:
+            self.intlist = self.intlist_from_str(initializer)
+        else:
+            self.intlist = initializer
+
+    def __str__(self) -> str:
+        return '.'.join([str(x) for x in self.intlist])
+
+    def __repr__(self) -> str:
+        return 'OID(%s)' % (str(self))
+
+
+class eOID(OID):
+    """OID helper for TCA eUICC prefix"""
+    __prefix = [2,23,143,1]
+    def __init__(self, initializer):
+        if type(initializer) == str:
+            initializer = self.intlist_from_str(initializer)
+        super().__init__(self.__prefix + initializer)
+
+MF = eOID("2.1")
+DF_CD = eOID("2.2")
+DF_TELECOM = eOID("2.3")
+DF_TELECOM_v2 = eOID("2.3.2")
+ADF_USIM_by_default = eOID("2.4")
+ADF_USIM_by_default_v2 = eOID("2.4.2")
+ADF_USIM_not_by_default = eOID("2.5")
+ADF_USIM_not_by_default_v2 = eOID("2.5.2")
+ADF_USIM_not_by_default_v3 = eOID("2.5.3")
+DF_PHONEBOOK_ADF_USIM = eOID("2.6")
+DF_GSM_ACCESS_ADF_USIM = eOID("2.7")
+ADF_ISIM_by_default = eOID("2.8")
+ADF_ISIM_not_by_default = eOID("2.9")
+ADF_ISIM_not_by_default_v2 = eOID("2.9.2")
+ADF_CSIM_by_default = eOID("2.10")
+ADF_CSIM_by_default_v2 = eOID("2.10.2")
+ADF_CSIM_not_by_default = eOID("2.11")
+ADF_CSIM_not_by_default_v2 = eOID("2.11.2")
+DF_EAP = eOID("2.12")
+DF_5GS = eOID("2.13")
+DF_5GS_v2 = eOID("2.13.2")
+DF_5GS_v3 = eOID("2.13.3")
+DF_5GS_v4 = eOID("2.13.4")
+DF_SAIP = eOID("2.14")
+DF_SNPN = eOID("2.15")
+DF_5GProSe = eOID("2.16")
+IoT_default = eOID("2.17")
+IoT_default = eOID("2.18")

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35734?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: I94f85f2257d4702376f4ba5eb995a544a2e53fd3
Gerrit-Change-Number: 35734
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to