[S] Change in pysim[master]: saip-tool: add function to write PE sequence
dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/39859?usp=email ) Change subject: saip-tool: add function to write PE sequence ...................................................................... saip-tool: add function to write PE sequence To prevent code duplication and to make the implementation simpler, let's add a function that takes care of writing the PE sequnece to an output file. Change-Id: I38733422270f5b9c18187b7f247b84bf21f9121b --- M contrib/saip-tool.py 1 file changed, 8 insertions(+), 6 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved Jenkins Builder: Verified diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py index 763e18d..b7282bd 100755 --- a/contrib/saip-tool.py +++ b/contrib/saip-tool.py @@ -65,6 +65,12 @@ parser_info = subparsers.add_parser('tree', help='Display the filesystem tree') +def write_pes(pes: ProfileElementSequence, output_file:str): + """write the PE sequence to a file""" + print("Writing %u PEs to file '%s'..." % (len(pes.pe_list), output_file)) + with open(output_file, 'wb') as f: + f.write(pes.to_der()) + def do_split(pes: ProfileElementSequence, opts): i = 0 for pe in pes.pe_list: @@ -132,9 +138,7 @@ pes.pe_list = new_pe_list pes._process_pelist() - print("Writing %u PEs to file '%s'..." % (len(pes.pe_list), opts.output_file)) - with open(opts.output_file, 'wb') as f: - f.write(pes.to_der()) + write_pes(pes, opts.output_file) def do_remove_naa(pes: ProfileElementSequence, opts): if not opts.naa_type in NAAs: @@ -142,9 +146,7 @@ naa = NAAs[opts.naa_type] print("Removing NAAs of type '%s' from Sequence..." % opts.naa_type) pes.remove_naas_of_type(naa) - print("Writing %u PEs to file '%s'..." % (len(pes.pe_list), opts.output_file)) - with open(opts.output_file, 'wb') as f: - f.write(pes.to_der()) + write_pes(pes, opts.output_file) def do_info(pes: ProfileElementSequence, opts): def get_naa_count(pes: ProfileElementSequence) -> dict: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/39859?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I38733422270f5b9c18187b7f247b84bf21f9121b Gerrit-Change-Number: 39859 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org>
participants (1)
-
dexter