laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35735?usp=email )
Change subject: pySim.esim.saip: More type annotations
......................................................................
pySim.esim.saip: More type annotations
Change-Id: Ib549817ee137bab610aea9c89a5ab86c2a7592ea
---
M pySim/esim/saip/__init__.py
1 file changed, 20 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/35/35735/1
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 251395f..7bb2172 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import abc
-from typing import Tuple, List, Optional, Dict
+from typing import Tuple, List, Optional, Dict, Union
import asn1tools
@@ -26,7 +26,7 @@
asn1 = compile_asn1_subdir('saip')
class ProfileElement:
- def _fixup_sqnInit_dec(self):
+ def _fixup_sqnInit_dec(self) -> None:
"""asn1tools has a bug when working with SEQUENCE OF that have DEFAULT values. Let's work around
this."""
if self.type != 'akaParameter':
@@ -39,7 +39,7 @@
# SEQUENCE (SIZE (32)) OF OCTET STRING (SIZE (6))
self.decoded['sqnInit'] = [b'\x00'*6] * 32
- def _fixup_sqnInit_enc(self):
+ def _fixup_sqnInit_enc(self) -> None:
"""asn1tools has a bug when working with SEQUENCE OF that have DEFAULT values. Let's work around
this."""
if self.type != 'akaParameter':
@@ -53,7 +53,7 @@
# none of the fields were initialized with a non-default (non-zero) value, so we can skip it
del self.decoded['sqnInit']
- def parse_der(self, der: bytes):
+ def parse_der(self, der: bytes) -> None:
"""Parse a sequence of PE and store the result in instance attributes."""
self.type, self.decoded = asn1.decode('ProfileElement', der)
# work around asn1tools bug regarding DEFAULT for a SEQUENCE OF
@@ -72,7 +72,7 @@
self._fixup_sqnInit_enc()
return asn1.encode('ProfileElement', (self.type, self.decoded))
- def __str__(self):
+ def __str__(self) -> str:
return self.type
@@ -102,7 +102,7 @@
assert len(l) == 1
return l[0]
- def parse_der(self, der: bytes):
+ def parse_der(self, der: bytes) -> None:
"""Parse a sequence of PE and store the result in self.pe_list."""
self.pe_list = []
remainder = der
@@ -111,11 +111,11 @@
self.pe_list.append(ProfileElement.from_der(first_tlv))
self._process_pelist()
- def _process_pelist(self):
+ def _process_pelist(self) -> None:
self._rebuild_pe_by_type()
self._rebuild_pes_by_naa()
- def _rebuild_pe_by_type(self):
+ def _rebuild_pe_by_type(self) -> None:
self.pe_by_type = {}
# build a dict {pe_type: [pe, pe, pe]}
for pe in self.pe_list:
@@ -124,7 +124,7 @@
else:
self.pe_by_type[pe.type] = [pe]
- def _rebuild_pes_by_naa(self):
+ def _rebuild_pes_by_naa(self) -> None:
"""rebuild the self.pes_by_naa dict {naa: [ [pe, pe, pe], [pe, pe] ]} form,
which basically means for every NAA there's a lsit of instances, and each consists
of a list of a list of PEs."""
@@ -165,8 +165,8 @@
out += pe.to_der()
return out
- def __repr__(self):
+ def __repr__(self) -> str:
return "PESequence(%s)" % ', '.join([str(x) for x in self.pe_list])
- def __iter__(self):
+ def __iter__(self) -> str:
yield from self.pe_list
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35735?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: Ib549817ee137bab610aea9c89a5ab86c2a7592ea
Gerrit-Change-Number: 35735
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: laforge.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/35731?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: add SAIP template handling + v3.1 definitions
......................................................................
add SAIP template handling + v3.1 definitions
This adds classes for describing profile templates as well
as derived classes defining the profile templates of the
"Profile Interoperability Technical Specification", specifically
it's "ANNEX A (Normative): File Structure Templates Definition"
We need a machine-readable definition of those templates, so
we can fully interpret an unprotected profile package (UPP),
as the UPP usually only contains the increment/difference to
a given teplate.
Change-Id: I79bc0a480450ca2de4b687ba6f11d0a4ea4f14c8
---
A pySim/esim/saip/templates.py
1 file changed, 694 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/31/35731/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35731?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: I79bc0a480450ca2de4b687ba6f11d0a4ea4f14c8
Gerrit-Change-Number: 35731
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newpatchset
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35729?usp=email )
Change subject: saip.personalization: Also drop any fillFileOffset
......................................................................
saip.personalization: Also drop any fillFileOffset
When replacing a file's contents, we must not just remove any
fillFileContent tuples, but also the fillFileOffset.
Change-Id: I3e4d97ae9de8a78f7bc0165ece5954481568b800
---
M pySim/esim/saip/personalization.py
1 file changed, 15 insertions(+), 3 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 32a53e6..bde7ce6 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -20,13 +20,13 @@
from pySim.esim.saip import ProfileElement, ProfileElementSequence
-def remove_unwanted_tuples_from_list(l: List[Tuple], unwanted_key:str) -> List[Tuple]:
+def remove_unwanted_tuples_from_list(l: List[Tuple], unwanted_keys: List[str]) -> List[Tuple]:
"""In a list of tuples, remove all tuples whose first part equals 'unwanted_key'."""
- return list(filter(lambda x: x[0] != unwanted_key, l))
+ return list(filter(lambda x: x[0] not in unwanted_keys, l))
def file_replace_content(file: List[Tuple], new_content: bytes):
"""Completely replace all fillFileContent of a decoded 'File' with the new_content."""
- file = remove_unwanted_tuples_from_list(file, 'fillFileContent')
+ file = remove_unwanted_tuples_from_list(file, ['fillFileContent', 'fillFileOffset'])
file.append(('fillFileContent', new_content))
return file
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35729?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: I3e4d97ae9de8a78f7bc0165ece5954481568b800
Gerrit-Change-Number: 35729
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: laforge.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35732?usp=email )
Change subject: requirements.txt: Switch to osmocom fork of asn1tools
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35732?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: Id28fcf060f491bb3d76aa6d8026aa76058edb675
Gerrit-Change-Number: 35732
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 29 Jan 2024 02:24:56 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: laforge.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35731?usp=email )
Change subject: add SAIP template handling + v3.1 definitions
......................................................................
Patch Set 1:
(2 comments)
File pySim/esim/saip/templates.py:
https://gerrit.osmocom.org/c/pysim/+/35731/comment/6ad8d394_7faa632d
PS1, Line 23: __init__
cosmetic: too many params, may of which are optional. I would go for `**kw` here:
```
def __init__(self, fid:int, name:str, ftype: str, **kw):
# ...
self.foo = kw.get('foo') # defaults to None
self.bar = kw.get('bar', True) # defaults to True
```
https://gerrit.osmocom.org/c/pysim/+/35731/comment/f66bf293_989183cf
PS1, Line 531: FilesUsimDf5GSv2
duplicate definition
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35731?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: I79bc0a480450ca2de4b687ba6f11d0a4ea4f14c8
Gerrit-Change-Number: 35731
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 29 Jan 2024 02:24:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: laforge.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35729?usp=email )
Change subject: saip.personalization: Also drop any fillFileOffset
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35729?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: I3e4d97ae9de8a78f7bc0165ece5954481568b800
Gerrit-Change-Number: 35729
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 29 Jan 2024 02:13:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35732?usp=email )
Change subject: requirements.txt: Switch to osmocom fork of asn1tools
......................................................................
requirements.txt: Switch to osmocom fork of asn1tools
This is sadly required as the Interoperable Profile format must process
elements of an ASN.1 sequence in order, which doesn't work if the parser
puts the elements in a python dict.
The osmocom fork of asn1tools hence uses OrderedDict to work around
this problem.
Change-Id: Id28fcf060f491bb3d76aa6d8026aa76058edb675
---
M requirements.txt
1 file changed, 17 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/35732/1
diff --git a/requirements.txt b/requirements.txt
index 5b735f0..c12daf8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,6 +11,6 @@
colorlog
pycryptodomex
cryptography
-asn1tools
+git+https://github.com/osmocom/asn1tools
packaging
git+https://github.com/hologram-io/smpp.pdu
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35732?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: Id28fcf060f491bb3d76aa6d8026aa76058edb675
Gerrit-Change-Number: 35732
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange