laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37741?usp=email )
Change subject: pySim.esim.saip.templates: Add expand_default_value() method
......................................................................
pySim.esim.saip.templates: Add expand_default_value() method
This method can be used to expand the default value pattern of the
file system template for the file to the specified (record, file) length.
Change-Id: Id3eb16910c0bdfa572294e14ca1cd44ca95ca69f
---
M pySim/esim/saip/templates.py
1 file changed, 45 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/41/37741/1
diff --git a/pySim/esim/saip/templates.py b/pySim/esim/saip/templates.py
index f1fd975..eff28c2 100644
--- a/pySim/esim/saip/templates.py
+++ b/pySim/esim/saip/templates.py
@@ -17,7 +17,7 @@
from typing import *
from copy import deepcopy
-from pySim.utils import all_subclasses
+from pySim.utils import all_subclasses, h2b
from pySim.filesystem import Path
import pySim.esim.saip.oid as OID
@@ -51,6 +51,10 @@
# initialize empty
self.parent = None
self.children = []
+ if self.default_val:
+ length = self._default_value_len() or 100
+ # run the method once to verify the pattern can be processed
+ self.expand_default_value_pattern(length)
def __str__(self) -> str:
return "FileTemplate(%s)" % (self.name)
@@ -85,6 +89,34 @@
if path[1].lower() == c.name.lower():
return c.get_file_by_path(path[1:])
+ def _default_value_len(self):
+ if self.file_type in ['TR']:
+ return self.file_size
+ elif self.file_type in ['LF', 'CY']:
+ return self.rec_len
+
+ def expand_default_value_pattern(self, length: Optional[int] = None) -> Optional[bytes]:
+ """Expand the default value pattern to the specified length."""
+ if not length:
+ length = self._default_value_len()
+ if not length:
+ raise ValueError("%s does not have a default length" % self)
+ if not self.default_val:
+ return None
+ if not '...' in self.default_val:
+ return h2b(self.default_val)
+ l = self.default_val.split('...')
+ if len(l) != 2:
+ raise ValueError("Pattern '%s' contains more than one ..." % self.default_val)
+ prefix = h2b(l[0])
+ suffix = h2b(l[1])
+ pad_len = length - len(prefix) - len(suffix)
+ if pad_len <= 0:
+ ret = prefix + suffix
+ return ret[:length]
+ return prefix + prefix[-1:] * pad_len + suffix
+
+
class ProfileTemplate:
"""Representation of a SimAlliance/TCA Profile Template. Each Template is identified by its OID and
consists of a number of file definitions. We implement each profile template as a class derived from this
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37741?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: Id3eb16910c0bdfa572294e14ca1cd44ca95ca69f
Gerrit-Change-Number: 37741
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: lynxis lazus, pespin.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/37724?usp=email )
Change subject: gmm: Introduce interface GMMBSSGP
......................................................................
Patch Set 1:
(1 comment)
File include/osmocom/gprs/gmm/gmm_prim.h:
https://gerrit.osmocom.org/c/libosmo-gprs/+/37724/comment/f4c46b05_fdd8dfc9
PS1, Line 369: /* Alloc primitive for GMMBSSGP SAP: */
As was discussed, let's just expose a generic alloc API and let the user fill prim specific fields using designated initializers (or whatever they like). Long function names with dozens of params are not nice, and it gets even worse when you add new fields to prims.
AFAIR, we wanted to rework the existing API, so let's not add even more APIs which are to be removed.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/37724?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I39045833fd43cfe98cb1a3812fbce3fdcaae6dc6
Gerrit-Change-Number: 37724
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Comment-Date: Sat, 03 Aug 2024 11:56:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37728?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: Makefile: add 'install' target
......................................................................
Makefile: add 'install' target
Change-Id: If4901adb648c98d52dbc0abd97413c20503fb278
---
M Makefile
1 file changed, 20 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/28/37728/2
--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37728?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: If4901adb648c98d52dbc0abd97413c20503fb278
Gerrit-Change-Number: 37728
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset