diff --git a/python/online/fxreader/pr34/commands_typed/os.py b/python/online/fxreader/pr34/commands_typed/os.py index 34d76b0..c2bdc86 100644 --- a/python/online/fxreader/pr34/commands_typed/os.py +++ b/python/online/fxreader/pr34/commands_typed/os.py @@ -1,5 +1,7 @@ import shutil import glob +import subprocess +import pydantic import pathlib import ctypes import os @@ -93,9 +95,9 @@ def runtime_libdirs_init( raise NotImplementedError class interfaces_index_t: - @dataclasses.dataclass(frozen=True) + @dataclasses.dataclass class Interface: - @dataclasses.dataclass(frozen=True) + @dataclasses.dataclass class AddrInfo: family: str local: str @@ -103,32 +105,13 @@ class interfaces_index_t: name: str addr_info: list[AddrInfo] -def interfaces_index() -> list[Interfaces]: - ip_addr_res: Any = json.loads( +def interfaces_index() -> list[interfaces_index_t.Interface]: + res = pydantic.RootModel[ + list[interfaces_index_t.Interface] + ].model_validate_json( subprocess.check_output([ 'ip', '-j', 'addr', ]).decode('utf-8') - ) + ).root - 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: + return res diff --git a/python/pyproject.toml b/python/pyproject.toml index 35976b5..835d2fe 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = 'online.fxreader.pr34' -version = '0.1.5.9' +version = '0.1.5.9+27.1' dependencies = [ #"-r requirements.txt", diff --git a/releases/whl/online_fxreader_pr34-0.1.5.9+27.1-py3-none-any.whl b/releases/whl/online_fxreader_pr34-0.1.5.9+27.1-py3-none-any.whl new file mode 100644 index 0000000..55e3df5 --- /dev/null +++ b/releases/whl/online_fxreader_pr34-0.1.5.9+27.1-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0f6f824ee5e87742e4744b13bc86787c9cbd8eecec722103aa603f6fff9566e +size 69644