blob: 84ec9cfd337e65129c2bd63fe21677a3cea2b0a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import typing
import pathlib
from ..general import SysCommand
def udevadm_info(path :pathlib.Path) -> typing.Dict[str, str]:
if path.resolve().exists() is False:
return {}
result = SysCommand(f"udevadm info {path.resolve()}")
data = {}
for line in result:
if b': ' in line and b'=' in line:
_, obj = line.split(b': ', 1)
key, value = obj.split(b'=', 1)
data[key.decode('UTF-8').lower()] = value.decode('UTF-8').strip()
return data
|