dexter has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/39861?usp=email
)
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: saip-tool: add option to extact profile elements to file
......................................................................
saip-tool: add option to extact profile elements to file
In some cases it may be helpful to extract a single profile element
from the sequence to a dedicated file.
Change-Id: I77a80bfaf8970660a84fa61f7e08f404ffc4c2da
---
M contrib/saip-tool.py
1 file changed, 14 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py
index b7282bd..c2115a6 100755
--- a/contrib/saip-tool.py
+++ b/contrib/saip-tool.py
@@ -48,6 +48,10 @@
parser_check = subparsers.add_parser('check', help='Run constraint checkers
on PE-Sequence')
+parser_rpe = subparsers.add_parser('extract-pe', help='Extract specified PE
to (DER encoded) file')
+parser_rpe.add_argument('--pe-file', required=True, help='PE file name')
+parser_rpe.add_argument('--identification', type=int, help='Extract PE
matching specified identification')
+
parser_rpe = subparsers.add_parser('remove-pe', help='Remove specified PEs
from PE-Sequence')
parser_rpe.add_argument('--output-file', required=True, help='Output file
name')
parser_rpe.add_argument('--identification', type=int, action='append',
help='Remove PEs matching specified identification')
@@ -126,6 +130,14 @@
checker.check(pes)
print("All good!")
+def do_extract_pe(pes: ProfileElementSequence, opts):
+ new_pe_list = []
+ for pe in pes.pe_list:
+ if pe.identification == opts.identification:
+ print("Extracting PE %s (id=%u) to file %s..." % (pe,
pe.identification, opts.pe_file))
+ with open(opts.pe_file, 'wb') as f:
+ f.write(pe.to_der())
+
def do_remove_pe(pes: ProfileElementSequence, opts):
new_pe_list = []
for pe in pes.pe_list:
@@ -248,6 +260,8 @@
do_dump(pes, opts)
elif opts.command == 'check':
do_check(pes, opts)
+ elif opts.command == 'extract-pe':
+ do_extract_pe(pes, opts)
elif opts.command == 'remove-pe':
do_remove_pe(pes, opts)
elif opts.command == 'remove-naa':
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/39861?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: I77a80bfaf8970660a84fa61f7e08f404ffc4c2da
Gerrit-Change-Number: 39861
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>