From c6fd1d314afd914fd3723b4d1e38452518810d05 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 19 Dec 2025 15:25:09 +0100 Subject: [PATCH] esim.saip.FsProfileElement: Add file2pe() for single file conversion We've had files2pe() for re-encoding all of the files, but let's add a specific one for re-encoding only one of the files (such as commonly needed during personalization) Change-Id: I7b7f61aae6b7df6946dadf2f78fddf92995603ec --- pySim/esim/saip/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 1c0c7156..c0f53408 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -633,8 +633,15 @@ class FsProfileElement(ProfileElement): self.pe_sequence.cur_df = pe_df self.pe_sequence.cur_df = self.pe_sequence.cur_df.add_file(file) + def file2pe(self, file: File): + """Update the "decoded" member for the given file with the contents from the given File instance. + We expect that the File instance is part of self.files""" + if self.files[file.pe_name] != file: + raise ValueError("The file you passed is not part of this ProfileElement") + self.decoded[file.pe_name] = file.to_tuples() + def files2pe(self): - """Update the "decoded" member with the contents of the "files" member.""" + """Update the "decoded" member for each file with the contents of the "files" member.""" for k, f in self.files.items(): self.decoded[k] = f.to_tuples()