pySim-shell: Allow selecting of deep paths like DF.GSM/EF.IMSI
With this patch applied, users can directly enter commands like
select DF.GSM/EF.IMSI or
select ADF.USIM/DF.5GS/EF.5GAUTHKEYS
This feature doesn't have tabl completion, so it's mostly useful
for when you know what to select, or for use within scripts.
Change-Id: I681a132eb2df4b2aba4c2ccbdd21c6d5b88443e3
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index d1c3e1f..bef9005 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1411,6 +1411,22 @@
name : Name of file to select
cmd_app : Command Application State (for unregistering old file commands)
"""
+ # handling of entire paths with multiple directories/elements
+ if '/' in name:
+ prev_sel_file = self.selected_file
+ pathlist = name.split('/')
+ # treat /DF.GSM/foo like MF/DF.GSM/foo
+ if pathlist[0] == '':
+ pathlist[0] = 'MF'
+ try:
+ for p in pathlist:
+ self.select(p, cmd_app)
+ return
+ except Exception as e:
+ # if any intermediate step fails, go back to where we were
+ self.select_file(prev_sel_file, cmd_app)
+ raise e
+
sels = self.selected_file.get_selectables()
if is_hex(name):
name = name.lower()