Cleanup relative imports

This commit is contained in:
Josh Wu
2025-04-12 23:02:28 +08:00
parent 58f153afc4
commit a57cf13e2e
34 changed files with 123 additions and 106 deletions

View File

@@ -20,8 +20,13 @@ import logging
import os
from typing import Optional
from .common import Transport, AsyncPipeSink, SnoopingTransport, TransportSpecError
from ..snoop import create_snooper
from bumble.transport.common import (
Transport,
AsyncPipeSink,
SnoopingTransport,
TransportSpecError,
)
from bumble.snoop import create_snooper
# -----------------------------------------------------------------------------
# Logging
@@ -108,80 +113,80 @@ async def _open_transport(scheme: str, spec: Optional[str]) -> Transport:
# pylint: disable=too-many-return-statements
if scheme == 'serial' and spec:
from .serial import open_serial_transport
from bumble.transport.serial import open_serial_transport
return await open_serial_transport(spec)
if scheme == 'udp' and spec:
from .udp import open_udp_transport
from bumble.transport.udp import open_udp_transport
return await open_udp_transport(spec)
if scheme == 'tcp-client' and spec:
from .tcp_client import open_tcp_client_transport
from bumble.transport.tcp_client import open_tcp_client_transport
return await open_tcp_client_transport(spec)
if scheme == 'tcp-server' and spec:
from .tcp_server import open_tcp_server_transport
from bumble.transport.tcp_server import open_tcp_server_transport
return await open_tcp_server_transport(spec)
if scheme == 'ws-client' and spec:
from .ws_client import open_ws_client_transport
from bumble.transport.ws_client import open_ws_client_transport
return await open_ws_client_transport(spec)
if scheme == 'ws-server' and spec:
from .ws_server import open_ws_server_transport
from bumble.transport.ws_server import open_ws_server_transport
return await open_ws_server_transport(spec)
if scheme == 'pty':
from .pty import open_pty_transport
from bumble.transport.pty import open_pty_transport
return await open_pty_transport(spec)
if scheme == 'file':
from .file import open_file_transport
from bumble.transport.file import open_file_transport
assert spec is not None
return await open_file_transport(spec)
if scheme == 'vhci':
from .vhci import open_vhci_transport
from bumble.transport.vhci import open_vhci_transport
return await open_vhci_transport(spec)
if scheme == 'hci-socket':
from .hci_socket import open_hci_socket_transport
from bumble.transport.hci_socket import open_hci_socket_transport
return await open_hci_socket_transport(spec)
if scheme == 'usb':
from .usb import open_usb_transport
from bumble.transport.usb import open_usb_transport
assert spec
return await open_usb_transport(spec)
if scheme == 'pyusb':
from .pyusb import open_pyusb_transport
from bumble.transport.pyusb import open_pyusb_transport
assert spec
return await open_pyusb_transport(spec)
if scheme == 'android-emulator':
from .android_emulator import open_android_emulator_transport
from bumble.transport.android_emulator import open_android_emulator_transport
return await open_android_emulator_transport(spec)
if scheme == 'android-netsim':
from .android_netsim import open_android_netsim_transport
from bumble.transport.android_netsim import open_android_netsim_transport
return await open_android_netsim_transport(spec)
if scheme == 'unix':
from .unix import open_unix_client_transport
from bumble.transport.unix import open_unix_client_transport
assert spec
return await open_unix_client_transport(spec)
@@ -204,8 +209,8 @@ async def open_transport_or_link(name: str) -> Transport:
"""
if name.startswith('link-relay:'):
logger.warning('Link Relay has been deprecated.')
from ..controller import Controller
from ..link import RemoteLink # lazy import
from bumble.controller import Controller
from bumble.link import RemoteLink # lazy import
link = RemoteLink(name[11:])
await link.wait_until_connected()