laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37832?usp=email )
Change subject: pySim.filesystem: Permit Path object construction from FID integer list ......................................................................
pySim.filesystem: Permit Path object construction from FID integer list
we so far supported construction of the Path object from a string or a list of strings. Let's also add the option of constructing it from a path consisting of a list of integer FID values.
Change-Id: Ia7e9375b3258d1fbfdc892cefba3e3bbe841c550 --- M pySim/filesystem.py 1 file changed, 4 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/37832/1
diff --git a/pySim/filesystem.py b/pySim/filesystem.py index 624619b..805983b 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -1481,10 +1481,12 @@
class Path: """Representation of a file-system path.""" - def __init__(self, p: Union[str, List[str]]): + def __init__(self, p: Union[str, List[str], List[int]]): # split if given as single string with slahes if isinstance(p, str): p = p.split('/') + elif len(p) and isinstance(p[0], int): + p = ['%04x' % x for x in p] # make sure internal representation alwas is uppercase only self.list = [x.upper() for x in p]
@@ -1514,7 +1516,7 @@
def relative_to_mf(self) -> 'Path': """Return a path relative to MF, i.e. without initial explicit MF.""" - if self.list[0] == 'MF': + if len(self.list) and self.list[0] in ['MF', '3F00']: return Path(self.list[1:]) return self