Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM driver uses (E, F, I, UP, B at line length 100, Python 3.10). Mapping and Iterable come from collections.abc, imports are sorted. What ruff cannot fix comes in the next commit.
25 lines
828 B
Python
25 lines
828 B
Python
"""UpdateService firmware inventory (``UpdateService/FirmwareInventory/*``)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from .common import boolean, link_list, status, text
|
|
|
|
|
|
def parse_firmware(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
"""One SoftwareInventory member: what it is, its version, whether it can be updated."""
|
|
state, health = status(item)
|
|
return {
|
|
"id": text(item.get("Id")),
|
|
"name": text(item.get("Name")),
|
|
"version": text(item.get("Version")),
|
|
"updateable": boolean(item.get("Updateable")),
|
|
"manufacturer": text(item.get("Manufacturer")),
|
|
"release_date": text(item.get("ReleaseDate")),
|
|
"state": state,
|
|
"health": health,
|
|
"related": link_list(item, "RelatedItem"),
|
|
}
|