diff --git a/python/online/fxreader/pr34/commands_typed/os.py b/python/online/fxreader/pr34/commands_typed/os.py index dc04d62..34d76b0 100644 --- a/python/online/fxreader/pr34/commands_typed/os.py +++ b/python/online/fxreader/pr34/commands_typed/os.py @@ -5,10 +5,11 @@ import ctypes import os import sys import logging +import dataclasses logger = logging.getLogger(__name__) -from typing import (overload, Optional, Literal,) +from typing import (overload, Optional, Literal, Any,) from .cli_bootstrap import PyProject @@ -89,4 +90,45 @@ def runtime_libdirs_init( ctypes.cdll.LoadLibrary(preload_found) else: - raise NotImplementedError \ No newline at end of file + raise NotImplementedError + +class interfaces_index_t: + @dataclasses.dataclass(frozen=True) + class Interface: + @dataclasses.dataclass(frozen=True) + class AddrInfo: + family: str + local: str + + name: str + addr_info: list[AddrInfo] + +def interfaces_index() -> list[Interfaces]: + ip_addr_res: Any = json.loads( + subprocess.check_output([ + 'ip', '-j', 'addr', + ]).decode('utf-8') + ) + + assert isinstance(ip_addr_res, list) + + ip_addr_res2 = cast(list[Any], p_addr_res,) + + assert all([ + isinstance(o, dict) + for o in ip_addr_res2.items() + ]) + + ip_addr_res3 = cast(list[dict[Any, Any]], ip_addr_res2) + + assert all([ + assert isinstance(k, str) + for k, v in o.items() + for o in ip_addr_res3 + ]) + + ip_addr_res4 = cast(list[dict[str, Any]], ip_addr_res3) + + res : list[interfaces_index_t.Interface] = [] + + for o in ip_addr_res4: