transport: Pass argparse.Namespace directly into transport classes

It's odd that the individual transport driver specifies their argparse
options but then the core transport part evaluates them individually.
This means we cannot add new options within a transport.

Let's pass the Namespace instance into the constructor of the
specific transport to improve this.

Change-Id: Ib977007dd605ec9a9c09a3d143d2c2308991a12c
This commit is contained in:
Harald Welte
2023-12-17 12:38:29 +01:00
committed by laforge
parent c108595041
commit 0f177c1d29
6 changed files with 23 additions and 21 deletions

View File

@@ -35,7 +35,10 @@ from pySim.exceptions import *
class ModemATCommandLink(LinkBase):
"""Transport Link for 3GPP TS 27.007 compliant modems."""
def __init__(self, device: str = '/dev/ttyUSB0', baudrate: int = 115200, **kwargs):
def __init__(self, opts: argparse.Namespace = argparse.Namespace(modem_dev='/dev/ttyUSB0',
modem_baud=115200), **kwargs):
device = opts.modem_dev
baudrate = opts.modem_baud
super().__init__(**kwargs)
if os.environ.get('PYSIM_INTEGRATION_TEST') == "1":
print("Using modem for Generic SIM Access (3GPP TS 27.007)")