Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit 37f5916

Browse files
author
Nurfet Becirevic
committed
Using dict.get instead of if/else
1 parent d1193dc commit 37f5916

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

packet/Device.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,11 @@ def __init__(self, data, manager):
2222
self.bonding_mode = data["bonding_mode"]
2323
self.created_at = data["created_at"]
2424
self.updated_at = data["updated_at"]
25-
if "ipxe_script_url" in data:
26-
self.ipxe_script_url = data["ipxe_script_url"]
27-
else:
28-
self.ipxe_script_url = None
29-
if "always_pxe" in data:
30-
self.always_pxe = data["always_pxe"]
31-
else:
32-
self.always_pxe = False
25+
self.ipxe_script_url = data.get("ipxe_script_url", None)
26+
self.always_pxe = data.get("always_pxe", False)
3327
if "storage" in data:
3428
self.storage = data["storage"]
35-
if "customdata" in data:
36-
self.customdata = data["customdata"]
37-
else:
38-
self.customdata = None
29+
self.customdata = data.get("customdata", None)
3930
self.operating_system = data["operating_system"]
4031
self.facility = data["facility"]
4132
self.project = data["project"]
@@ -55,10 +46,7 @@ def __init__(self, data, manager):
5546
if "network_ports" in data:
5647
self.network_ports = data["network_ports"]
5748
self.href = data["href"]
58-
if "spot_instance" in data:
59-
self.spot_instance = data["spot_instance"]
60-
else:
61-
self.spot_instance = False
49+
self.spot_instance = data.get("spot_instance", False)
6250
if "root_password" in data:
6351
self.root_password = data["root_password"]
6452

0 commit comments

Comments
 (0)