laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35351?usp=email )

Change subject: filesystem: use sort path when selecting an application
......................................................................

filesystem: use sort path when selecting an application

The method build_select_path_to uses the internal file system tree model
to find the path to a given file. This works the same for applications
(ADF) as it works for normal files (EF/DF). However, an application can
be selected anytime from any location in the filesystem tree. There is
no need to select a specific path leading to that application first.
This means that if there is an ADF somewhere in the resulting
inter_path, we may clip everything before that ADF.

Related: OS#5418
Change-Id: I838a99bb47afc73b4274baecb04fff31abf7b2e2
---
M pySim/filesystem.py
1 file changed, 29 insertions(+), 1 deletion(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index d39162c..35863a8 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -136,6 +136,16 @@
         return ret

     def build_select_path_to(self, target: 'CardFile') -> 
Optional[List['CardFile']]:
+
+        # special-case handling for applications. Applications may be selected
+        # any time from any location. If there is an ADF somewhere in the path,
+        # we may clip everything before that ADF.
+        def clip_path(inter_path):
+            for i in reversed(range(0, len(inter_path))):
+                if isinstance(inter_path[i], CardADF):
+                    return inter_path[i:]
+            return inter_path
+
         """Build the relative sequence of files we need to traverse to get 
from us to 'target'."""
         # special-case handling for selecting MF while we MF is selected
         if target == target.get_mf():
@@ -152,7 +162,7 @@
                     for te2 in target_fqpath[i+1:]:
                         inter_path.append(te2)
                     # we found our common ancestor
-                    return inter_path[1:]
+                    return clip_path(inter_path[1:])
         return None

     def get_mf(self) -> Optional['CardMF']:

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35351?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I838a99bb47afc73b4274baecb04fff31abf7b2e2
Gerrit-Change-Number: 35351
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to