Loading wpa_supplicant/client/base.py +4 −3 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import logging import pathlib import os from re import compile as regex from typing import Any, Callable, Optional, Set, Sequence, Tuple, Union from typing import Any, Callable, Optional, Sequence, Tuple import anyio from . import consts from .. import errors, util from ..types import PathLike # 128kB (actual max size slightly less than this) Loading Loading @@ -89,7 +90,7 @@ class BaseClient: async def __aexit__(self, *exc_info): await self.disconnect() async def connect(self, path: consts.Path): async def connect(self, path: PathLike): """ Connect to a WPA-Supplicant daemon through the given address """ Loading Loading @@ -217,7 +218,7 @@ class BaseClient: await msgqueue.put((prio, name, msg)) @contextlib.contextmanager def _events_queue(self, events: Union[Sequence, Set]): def _events_queue(self, events: Sequence[str]): evtqueues = self._eventqueues queue = anyio.create_queue(1) for evt in events: Loading wpa_supplicant/client/consts.py +1 −10 Original line number Diff line number Diff line Loading @@ -13,18 +13,9 @@ # limitations under the License. """ Constants any types for the various client modules and classes Constants for the various client modules and classes """ import os from typing import Union # Types Path = Union[str, os.PathLike] # Commands COMMAND_PING = "PING" Loading wpa_supplicant/client/interfaces.py +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from typing import Any, Dict, Iterable from . import consts from .base import BaseClient from .. import config, util from ..types import PathLike, StringMap class InterfaceClient(BaseClient): Loading @@ -31,11 +32,11 @@ class InterfaceClient(BaseClient): name = None async def connect(self, path: consts.Path): async def connect(self, path: PathLike): await super().connect(path) self.name = await self.send_command(consts.COMMAND_IFNAME, convert=str) async def scan(self) -> Iterable[dict]: async def scan(self) -> Iterable[StringMap]: """ Iteratively produces the details of all detectable IEEE 802.11 BSS Loading wpa_supplicant/client/master.py +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from typing import Set from . import consts from .base import BaseClient from .interfaces import InterfaceClient from ..types import PathLike class MasterClient(BaseClient): Loading @@ -31,7 +32,7 @@ class MasterClient(BaseClient): ctrl_dir = None async def connect(self, path: consts.Path): async def connect(self, path: PathLike): if not isinstance(path, pathlib.Path): path = pathlib.Path(path) await super().connect(path) Loading wpa_supplicant/types.py 0 → 100644 +28 −0 Original line number Diff line number Diff line # Copyright 2019 Dom Sekotill <dom.sekotill@kodo.org.uk> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Types for the various modules and classes of the package """ from os import PathLike from typing import Dict, Union PathLike = Union[str, PathLike] StringMap = Dict[str, str] __all__ = list(globals().keys()) Loading
wpa_supplicant/client/base.py +4 −3 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import logging import pathlib import os from re import compile as regex from typing import Any, Callable, Optional, Set, Sequence, Tuple, Union from typing import Any, Callable, Optional, Sequence, Tuple import anyio from . import consts from .. import errors, util from ..types import PathLike # 128kB (actual max size slightly less than this) Loading Loading @@ -89,7 +90,7 @@ class BaseClient: async def __aexit__(self, *exc_info): await self.disconnect() async def connect(self, path: consts.Path): async def connect(self, path: PathLike): """ Connect to a WPA-Supplicant daemon through the given address """ Loading Loading @@ -217,7 +218,7 @@ class BaseClient: await msgqueue.put((prio, name, msg)) @contextlib.contextmanager def _events_queue(self, events: Union[Sequence, Set]): def _events_queue(self, events: Sequence[str]): evtqueues = self._eventqueues queue = anyio.create_queue(1) for evt in events: Loading
wpa_supplicant/client/consts.py +1 −10 Original line number Diff line number Diff line Loading @@ -13,18 +13,9 @@ # limitations under the License. """ Constants any types for the various client modules and classes Constants for the various client modules and classes """ import os from typing import Union # Types Path = Union[str, os.PathLike] # Commands COMMAND_PING = "PING" Loading
wpa_supplicant/client/interfaces.py +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from typing import Any, Dict, Iterable from . import consts from .base import BaseClient from .. import config, util from ..types import PathLike, StringMap class InterfaceClient(BaseClient): Loading @@ -31,11 +32,11 @@ class InterfaceClient(BaseClient): name = None async def connect(self, path: consts.Path): async def connect(self, path: PathLike): await super().connect(path) self.name = await self.send_command(consts.COMMAND_IFNAME, convert=str) async def scan(self) -> Iterable[dict]: async def scan(self) -> Iterable[StringMap]: """ Iteratively produces the details of all detectable IEEE 802.11 BSS Loading
wpa_supplicant/client/master.py +2 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from typing import Set from . import consts from .base import BaseClient from .interfaces import InterfaceClient from ..types import PathLike class MasterClient(BaseClient): Loading @@ -31,7 +32,7 @@ class MasterClient(BaseClient): ctrl_dir = None async def connect(self, path: consts.Path): async def connect(self, path: PathLike): if not isinstance(path, pathlib.Path): path = pathlib.Path(path) await super().connect(path) Loading
wpa_supplicant/types.py 0 → 100644 +28 −0 Original line number Diff line number Diff line # Copyright 2019 Dom Sekotill <dom.sekotill@kodo.org.uk> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Types for the various modules and classes of the package """ from os import PathLike from typing import Dict, Union PathLike = Union[str, PathLike] StringMap = Dict[str, str] __all__ = list(globals().keys())