mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Small cleanup to zeroconf properties matcher (#107342)
* Small cleanup to zeroconf properties matcher - Switch to dict.items() to avoid dict key lookup - return early when a match is rejected * tweak
This commit is contained in:
parent
44018a4183
commit
851ad21d11
@ -321,12 +321,11 @@ async def _async_register_hass_zc_service(
|
||||
|
||||
def _match_against_props(matcher: dict[str, str], props: dict[str, str | None]) -> bool:
|
||||
"""Check a matcher to ensure all values in props."""
|
||||
return not any(
|
||||
key
|
||||
for key in matcher
|
||||
if key not in props
|
||||
or not _memorized_fnmatch((props[key] or "").lower(), matcher[key])
|
||||
)
|
||||
for key, value in matcher.items():
|
||||
prop_val = props.get(key)
|
||||
if prop_val is None or not _memorized_fnmatch(prop_val.lower(), value):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def is_homekit_paired(props: dict[str, Any]) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user