Skip to content

Commit a76a36b

Browse files
committed
Avoid double search.find()
1 parent 8cc78f2 commit a76a36b

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
@@ -69,7 +69,7 @@
6969

7070

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

462462
return appl
463463

464+
def _appl_actuator_modes()
465+
464466
def _appl_regulation_mode_info(self, appliance: etree) -> None:
465467
"""Helper-function for _appliance_info_finder()."""
466468
reg_mode_list: list[str] = []
467469
if (search := search_actuator_functionalities(
468470
appliance, "regulation_mode_control_functionality"
469471
)) is not None:
470-
if search.find("allowed_modes") is not None:
471-
for mode in search.find("allowed_modes"):
472+
if (modes := search.find("allowed_modes")) is not None:
473+
for mode in modes:
472474
reg_mode_list.append(mode.text)
473475
if mode.text == "cooling":
474476
self._cooling_present = True
@@ -483,8 +485,8 @@ def _appl_dhw_mode_info(self, appl: Munch, appliance: etree) -> Munch:
483485
if (search := search_actuator_functionalities(
484486
appliance, "domestic_hot_water_mode_control_functionality"
485487
)) is not None:
486-
if search.find("allowed_modes") is not None:
487-
for mode in search.find("allowed_modes"):
488+
if (modes := search.find("allowed_modes")) is not None:
489+
for mode in modes:
488490
dhw_mode_list.append(mode.text)
489491
self._dhw_allowed_modes = dhw_mode_list
490492

0 commit comments

Comments
 (0)