mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-28 08:18:36 +03:00
filesystem: raise exception only when applicable
We should first see if any of the files in the tree actually
require a service mapping before raising
ValueError('TODO: implement recursive service -> file mapping')
Change-Id: I9c339f0cac020e7eec7f4f840748040e5f77923d
This commit is contained in:
@@ -301,6 +301,14 @@ class CardDF(CardFile):
|
|||||||
else:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
def _has_service(self):
|
||||||
|
if self.service:
|
||||||
|
return True
|
||||||
|
for c in self.children.values():
|
||||||
|
if isinstance(c, CardDF):
|
||||||
|
if c._has_service():
|
||||||
|
return True
|
||||||
|
|
||||||
def add_file(self, child: CardFile, ignore_existing: bool = False):
|
def add_file(self, child: CardFile, ignore_existing: bool = False):
|
||||||
"""Add a child (DF/EF) to this DF.
|
"""Add a child (DF/EF) to this DF.
|
||||||
Args:
|
Args:
|
||||||
@@ -336,7 +344,10 @@ class CardDF(CardFile):
|
|||||||
for c in child.children.values():
|
for c in child.children.values():
|
||||||
self._add_file_services(c)
|
self._add_file_services(c)
|
||||||
if isinstance(c, CardDF):
|
if isinstance(c, CardDF):
|
||||||
raise ValueError('TODO: implement recursive service -> file mapping')
|
for gc in c.children.values():
|
||||||
|
if isinstance(gc, CardDF):
|
||||||
|
if gc._has_service():
|
||||||
|
raise ValueError('TODO: implement recursive service -> file mapping')
|
||||||
|
|
||||||
def add_files(self, children: Iterable[CardFile], ignore_existing: bool = False):
|
def add_files(self, children: Iterable[CardFile], ignore_existing: bool = False):
|
||||||
"""Add a list of child (DF/EF) to this DF
|
"""Add a list of child (DF/EF) to this DF
|
||||||
|
|||||||
Reference in New Issue
Block a user