filesystem: Use Tuple for transparent file size

As the documentation strings say: The size should be a *tuple*.  In
reality we so far passed a set.  The problem with the set is that
ordering is not guaranteed, and hence we cannot assume the first and
second item have meaning (minimum vs. default size).

While at it, use a type annotation to catch such bugs easily.

Change-Id: I553616f8c6c4aaa8f635b3d7d94e8e8f49ed5a56
This commit is contained in:
Harald Welte
2022-07-21 15:19:23 +02:00
parent b2e4b4a300
commit 13edf30d6c
7 changed files with 72 additions and 70 deletions

View File

@@ -49,6 +49,8 @@ from pySim.commands import SimCardCommands
# tuple: logical-and of the listed services requires this file
CardFileService = Union[int, List[int], Tuple[int, ...]]
Size = Tuple[int, Optional[int]]
def lchan_nr_from_cla(cla: int) -> int:
"""Resolve the logical channel number from the CLA byte."""
# TS 102 221 10.1.1 Coding of Class Byte
@@ -642,7 +644,7 @@ class TransparentEF(CardEF):
self._cmd.poutput_json(data)
def __init__(self, fid: str, sfid: str = None, name: str = None, desc: str = None, parent: CardDF = None,
size={1, None}, **kwargs):
size: Size = (1, None), **kwargs):
"""
Args:
fid : File Identifier (4 hex digits)
@@ -1057,7 +1059,7 @@ class TransRecEF(TransparentEF):
"""
def __init__(self, fid: str, rec_len: int, sfid: str = None, name: str = None, desc: str = None,
parent: Optional[CardDF] = None, size={1, None}, **kwargs):
parent: Optional[CardDF] = None, size: Size = (1, None), **kwargs):
"""
Args:
fid : File Identifier (4 hex digits)
@@ -1245,7 +1247,7 @@ class BerTlvEF(CardEF):
self._cmd.poutput(data)
def __init__(self, fid: str, sfid: str = None, name: str = None, desc: str = None, parent: CardDF = None,
size={1, None}, **kwargs):
size: Size = (1, None), **kwargs):
"""
Args:
fid : File Identifier (4 hex digits)