mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
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
This commit is contained in:
@@ -643,6 +643,14 @@ class FsProfileElement(ProfileElement):
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user