Loading wpa_supplicant/client/interfaces.py +10 −3 Original line number Diff line number Diff line Loading @@ -22,12 +22,12 @@ from typing import AsyncGenerator from typing import Dict from .. import config from .. import util from ..types import PathLike from ..types import StringMap from . import consts from .base import BaseClient StringMap = Dict[str, str] class InterfaceClient(BaseClient): """ Loading @@ -51,7 +51,7 @@ class InterfaceClient(BaseClient): await self.event(consts.CTRL_EVENT_SCAN_RESULTS) for idx in count(): bss = await self.send_command( consts.COMMAND_BSS, str(idx), convert=util.kv2dict, consts.COMMAND_BSS, str(idx), convert=_kv2dict, ) if not bss: return Loading @@ -76,3 +76,10 @@ class InterfaceClient(BaseClient): f'"{value}"' if isinstance(value, str) else str(value), separator=consts.SEPARATOR_SPACE, ) def _kv2dict(keyvalues: str) -> StringMap: """ Convert a list of line-terminated "key=value" substrings into a dictionary """ return dict(kv.split("=", 1) for kv in keyvalues.splitlines()) # type: ignore wpa_supplicant/types.py +0 −3 Original line number Diff line number Diff line Loading @@ -17,12 +17,9 @@ Types for the various modules and classes of the package """ from os import PathLike as _PathLike from typing import Dict from typing import Union PathLike = Union[str, _PathLike] StringMap = Dict[str, str] __all__ = list(globals().keys()) wpa_supplicant/util.pydeleted 100644 → 0 +0 −26 Original line number Diff line number Diff line # Copyright 2019-2021 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. """ Miscellaneous functions """ from .types import StringMap def kv2dict(keyvalues: str) -> StringMap: """ Convert a list of line-terminated "key=value" substrings into a dictionary """ return dict(kv.split("=", 1) for kv in keyvalues.splitlines()) # type: ignore Loading
wpa_supplicant/client/interfaces.py +10 −3 Original line number Diff line number Diff line Loading @@ -22,12 +22,12 @@ from typing import AsyncGenerator from typing import Dict from .. import config from .. import util from ..types import PathLike from ..types import StringMap from . import consts from .base import BaseClient StringMap = Dict[str, str] class InterfaceClient(BaseClient): """ Loading @@ -51,7 +51,7 @@ class InterfaceClient(BaseClient): await self.event(consts.CTRL_EVENT_SCAN_RESULTS) for idx in count(): bss = await self.send_command( consts.COMMAND_BSS, str(idx), convert=util.kv2dict, consts.COMMAND_BSS, str(idx), convert=_kv2dict, ) if not bss: return Loading @@ -76,3 +76,10 @@ class InterfaceClient(BaseClient): f'"{value}"' if isinstance(value, str) else str(value), separator=consts.SEPARATOR_SPACE, ) def _kv2dict(keyvalues: str) -> StringMap: """ Convert a list of line-terminated "key=value" substrings into a dictionary """ return dict(kv.split("=", 1) for kv in keyvalues.splitlines()) # type: ignore
wpa_supplicant/types.py +0 −3 Original line number Diff line number Diff line Loading @@ -17,12 +17,9 @@ Types for the various modules and classes of the package """ from os import PathLike as _PathLike from typing import Dict from typing import Union PathLike = Union[str, _PathLike] StringMap = Dict[str, str] __all__ = list(globals().keys())
wpa_supplicant/util.pydeleted 100644 → 0 +0 −26 Original line number Diff line number Diff line # Copyright 2019-2021 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. """ Miscellaneous functions """ from .types import StringMap def kv2dict(keyvalues: str) -> StringMap: """ Convert a list of line-terminated "key=value" substrings into a dictionary """ return dict(kv.split("=", 1) for kv in keyvalues.splitlines()) # type: ignore