mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-28 16:28:33 +03:00
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
This commit is contained in:
@@ -1481,10 +1481,12 @@ class CardModel(abc.ABC):
|
|||||||
|
|
||||||
class Path:
|
class Path:
|
||||||
"""Representation of a file-system 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
|
# split if given as single string with slahes
|
||||||
if isinstance(p, str):
|
if isinstance(p, str):
|
||||||
p = p.split('/')
|
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
|
# make sure internal representation alwas is uppercase only
|
||||||
self.list = [x.upper() for x in p]
|
self.list = [x.upper() for x in p]
|
||||||
|
|
||||||
@@ -1514,7 +1516,7 @@ class Path:
|
|||||||
|
|
||||||
def relative_to_mf(self) -> 'Path':
|
def relative_to_mf(self) -> 'Path':
|
||||||
"""Return a path relative to MF, i.e. without initial explicit MF."""
|
"""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 Path(self.list[1:])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user