Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/pyipp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,50 @@ def merge_marker_data(data: dict[str, Any]) -> list[Marker]: # noqa: PLR0912
marker_highs.append(100)
marker_lows.append(0)

elif isinstance(data.get("marker-names"), str):
marker_names = [data["marker-names"]]

mlen = 1
marker_colors.append("")
marker_levels.append(-2)
marker_types.append("unknown")
marker_highs.append(100)
marker_lows.append(0)

if isinstance(data.get("marker-colors"), list):
for index, list_value in enumerate(data["marker-colors"]):
if index < mlen:
marker_colors[index] = list_value
elif isinstance(data.get("marker-colors"), str) and mlen == 1:
marker_colors[0] = data.get("marker-colors")

if isinstance(data.get("marker-levels"), list):
for index, list_value in enumerate(data["marker-levels"]):
if index < mlen:
marker_levels[index] = list_value
elif isinstance(data.get("marker-levels"), int) and mlen == 1:
marker_levels[0] = data.get("marker-levels")

if isinstance(data.get("marker-high-levels"), list):
for index, list_value in enumerate(data["marker-high-levels"]):
if index < mlen:
marker_highs[index] = list_value
elif isinstance(data.get("marker-high-levels"), int) and mlen == 1:
marker_highs[0] = data.get("marker-high-levels")

if isinstance(data.get("marker-low-levels"), list):
for index, list_value in enumerate(data["marker-low-levels"]):
if index < mlen:
marker_lows[index] = list_value
elif isinstance(data.get("marker-low-levels"), int) and mlen == 1:
marker_lows[0] = data.get("marker-low-levels")

if isinstance(data.get("marker-types"), list):
for index, list_value in enumerate(data["marker-types"]):
if index < mlen:
marker_types[index] = list_value
elif isinstance(data.get("marker-types"), str) and mlen == 1:
marker_types[0] = data.get("marker-types")

if isinstance(marker_names, list) and mlen > 0:
markers = [
Expand Down Expand Up @@ -238,15 +258,34 @@ def merge_uri_data(data: dict[str, Any]) -> list[Uri]:
auth.append(None)
security.append(None)

elif isinstance(data.get("printer-uri-supported"), str):
_uris = [data["printer-uri-supported"]]
ulen = 1

auth.append(None)
security.append(None)

if isinstance(data.get("uri-authentication-supported"), list):
for k, list_value in enumerate(data["uri-authentication-supported"]):
if k < ulen:
auth[k] = list_value if list_value != "none" else None
elif isinstance(data.get("uri-authentication-supported"), str) and ulen == 1:
auth[0] = (
data["uri-authentication-supported"]
if data["uri-authentication-supported"] != "none"
else None
)

if isinstance(data.get("uri-security-supported"), list):
for k, list_value in enumerate(data["uri-security-supported"]):
if k < ulen:
security[k] = list_value if list_value != "none" else None
elif isinstance(data.get("uri-security-supported"), str) and ulen == 1:
security[0] = (
data["uri-security-supported"]
if data["uri-security-supported"] != "none"
else None
)

if isinstance(_uris, list) and ulen > 0:
uris = [
Expand Down