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

@@ -289,17 +289,15 @@ def init_reader(opts, **kwargs) -> LinkBase:
"""
if opts.pcsc_dev is not None:
from pySim.transport.pcsc import PcscSimLink
sl = PcscSimLink(opts.pcsc_dev, **kwargs)
sl = PcscSimLink(opts, **kwargs)
elif opts.osmocon_sock is not None:
from pySim.transport.calypso import CalypsoSimLink
sl = CalypsoSimLink(sock_path=opts.osmocon_sock, **kwargs)
sl = CalypsoSimLink(opts, **kwargs)
elif opts.modem_dev is not None:
from pySim.transport.modem_atcmd import ModemATCommandLink
sl = ModemATCommandLink(
device=opts.modem_dev, baudrate=opts.modem_baud, **kwargs)
sl = ModemATCommandLink(opts, **kwargs)
else: # Serial reader is default
print("No reader/driver specified; falling back to default (Serial reader)")
from pySim.transport.serial import SerialSimLink
sl = SerialSimLink(device=opts.device,
baudrate=opts.baudrate, **kwargs)
sl = SerialSimLink(opts, **kwargs)
return sl