Commit a61eb691 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Move the one function from .util to where it's used

parent 968d05eb
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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):
	"""
@@ -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
@@ -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
+0 −3
Original line number Diff line number Diff line
@@ -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.py

deleted100644 → 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