laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/38909?usp=email )
Change subject: esim.saip.FsProfileElement: Add create_file() method ......................................................................
esim.saip.FsProfileElement: Add create_file() method
So far we mainly created File() instances when parsing existing profiles. However, sometimes we want to programmatically create Files and we should offer a convenience helper to do so, rather than asking API users to worry about low-level details.
Change-Id: I0817819af40f3d0dc0c3d2b91039c5748dd31ee2 --- M pySim/esim/saip/__init__.py 1 file changed, 8 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/09/38909/1
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 94df453..2552c8e 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -643,6 +643,14 @@ file = File(k, v, template.files_by_pename.get(k, None)) self.add_file(file)
+ def create_file(self, pename: str) -> File: + """Programatically create a file by its PE-Name.""" + template = templates.ProfileTemplateRegistry.get_by_oid(self.templateID) + file = File(pename, None, template.files_by_pename.get(pename, None)) + self.add_file(file) + self.decoded[pename] = [] + return file + def _post_decode(self): # not entirely sure about doing this this automatism self.pe2files()