Skip to content

Commit c8dd4fe

Browse files
committed
Avoid double search.find()
1 parent 46780b4 commit c8dd4fe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

plugwise/helper.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969

7070
def search_actuator_functionalities(appliance: etree, actuator: str) -> etree | None:
71-
"""Helper-function for finding the relevant xml-structure."""
71+
"""Helper-function for finding the relevant actuator xml-structure."""
7272
locator = f"./actuator_functionalities/{actuator}"
7373
if (search := appliance.find(locator)) is not None:
7474
return search
@@ -454,14 +454,16 @@ def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
454454

455455
return appl
456456

457+
def _appl_actuator_modes()
458+
457459
def _appl_regulation_mode_info(self, appliance: etree) -> None:
458460
"""Helper-function for _appliance_info_finder()."""
459461
reg_mode_list: list[str] = []
460462
if (search := search_actuator_functionalities(
461463
appliance, "regulation_mode_control_functionality"
462464
)) is not None:
463-
if search.find("allowed_modes") is not None:
464-
for mode in search.find("allowed_modes"):
465+
if (modes := search.find("allowed_modes")) is not None:
466+
for mode in modes:
465467
reg_mode_list.append(mode.text)
466468
if mode.text == "cooling":
467469
self._cooling_present = True
@@ -476,8 +478,8 @@ def _appl_dhw_mode_info(self, appl: Munch, appliance: etree) -> Munch:
476478
if (search := search_actuator_functionalities(
477479
appliance, "domestic_hot_water_mode_control_functionality"
478480
)) is not None:
479-
if search.find("allowed_modes") is not None:
480-
for mode in search.find("allowed_modes"):
481+
if (modes := search.find("allowed_modes")) is not None:
482+
for mode in modes:
481483
dhw_mode_list.append(mode.text)
482484
self._dhw_allowed_modes = dhw_mode_list
483485

0 commit comments

Comments
 (0)