Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
ConfigEntries.async_unload | (self, entry_id: str) | Unload a config entry. | Unload a config entry. | async def async_unload(self, entry_id: str) -> bool:
"""Unload a config entry."""
entry = self.async_get_entry(entry_id)
if entry is None:
raise UnknownEntry
if entry.state in UNRECOVERABLE_STATES:
raise OperationNotAllowed
return await entry.async_unlo... | [
"async",
"def",
"async_unload",
"(",
"self",
",",
"entry_id",
":",
"str",
")",
"->",
"bool",
":",
"entry",
"=",
"self",
".",
"async_get_entry",
"(",
"entry_id",
")",
"if",
"entry",
"is",
"None",
":",
"raise",
"UnknownEntry",
"if",
"entry",
".",
"state",
... | [
733,
4
] | [
743,
50
] | python | en | ['en', 'es', 'en'] | True |
ConfigEntries.async_reload | (self, entry_id: str) | Reload an entry.
If an entry was not loaded, will just load.
| Reload an entry. | async def async_reload(self, entry_id: str) -> bool:
"""Reload an entry.
If an entry was not loaded, will just load.
"""
unload_result = await self.async_unload(entry_id)
if not unload_result:
return unload_result
return await self.async_setup(entry_id) | [
"async",
"def",
"async_reload",
"(",
"self",
",",
"entry_id",
":",
"str",
")",
"->",
"bool",
":",
"unload_result",
"=",
"await",
"self",
".",
"async_unload",
"(",
"entry_id",
")",
"if",
"not",
"unload_result",
":",
"return",
"unload_result",
"return",
"await... | [
745,
4
] | [
755,
47
] | python | en | ['en', 'en', 'en'] | True |
ConfigEntries.async_update_entry | (
self,
entry: ConfigEntry,
*,
# pylint: disable=dangerous-default-value # _UNDEFs not modified
unique_id: Union[str, dict, None] = _UNDEF,
title: Union[str, dict] = _UNDEF,
data: dict = _UNDEF,
options: dict = _UNDEF,
system_options: dict = _UNDEF... | Update a config entry.
If the entry was changed, the update_listeners are
fired and this function returns True
If the entry was not changed, the update_listeners are
not fired and this function returns False
| Update a config entry. | def async_update_entry(
self,
entry: ConfigEntry,
*,
# pylint: disable=dangerous-default-value # _UNDEFs not modified
unique_id: Union[str, dict, None] = _UNDEF,
title: Union[str, dict] = _UNDEF,
data: dict = _UNDEF,
options: dict = _UNDEF,
system_... | [
"def",
"async_update_entry",
"(",
"self",
",",
"entry",
":",
"ConfigEntry",
",",
"*",
",",
"# pylint: disable=dangerous-default-value # _UNDEFs not modified",
"unique_id",
":",
"Union",
"[",
"str",
",",
"dict",
",",
"None",
"]",
"=",
"_UNDEF",
",",
"title",
":",
... | [
758,
4
] | [
812,
19
] | python | en | ['en', 'en', 'en'] | True |
ConfigEntries.async_forward_entry_setup | (self, entry: ConfigEntry, domain: str) | Forward the setup of an entry to a different component.
By default an entry is setup with the component it belongs to. If that
component also has related platforms, the component will have to
forward the entry to be setup by that component.
You don't want to await this coroutine if it ... | Forward the setup of an entry to a different component. | async def async_forward_entry_setup(self, entry: ConfigEntry, domain: str) -> bool:
"""Forward the setup of an entry to a different component.
By default an entry is setup with the component it belongs to. If that
component also has related platforms, the component will have to
forward ... | [
"async",
"def",
"async_forward_entry_setup",
"(",
"self",
",",
"entry",
":",
"ConfigEntry",
",",
"domain",
":",
"str",
")",
"->",
"bool",
":",
"# Setup Component if not set up yet",
"if",
"domain",
"not",
"in",
"self",
".",
"hass",
".",
"config",
".",
"compone... | [
814,
4
] | [
834,
19
] | python | en | ['en', 'en', 'en'] | True |
ConfigEntries.async_forward_entry_unload | (self, entry: ConfigEntry, domain: str) | Forward the unloading of an entry to a different component. | Forward the unloading of an entry to a different component. | async def async_forward_entry_unload(self, entry: ConfigEntry, domain: str) -> bool:
"""Forward the unloading of an entry to a different component."""
# It was never loaded.
if domain not in self.hass.config.components:
return True
integration = await loader.async_get_integr... | [
"async",
"def",
"async_forward_entry_unload",
"(",
"self",
",",
"entry",
":",
"ConfigEntry",
",",
"domain",
":",
"str",
")",
"->",
"bool",
":",
"# It was never loaded.",
"if",
"domain",
"not",
"in",
"self",
".",
"hass",
".",
"config",
".",
"components",
":",... | [
836,
4
] | [
844,
75
] | python | en | ['en', 'en', 'en'] | True |
ConfigEntries._async_schedule_save | (self) | Save the entity registry to a file. | Save the entity registry to a file. | def _async_schedule_save(self) -> None:
"""Save the entity registry to a file."""
self._store.async_delay_save(self._data_to_save, SAVE_DELAY) | [
"def",
"_async_schedule_save",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_store",
".",
"async_delay_save",
"(",
"self",
".",
"_data_to_save",
",",
"SAVE_DELAY",
")"
] | [
847,
4
] | [
849,
68
] | python | en | ['en', 'en', 'en'] | True |
ConfigEntries._data_to_save | (self) | Return data to save. | Return data to save. | def _data_to_save(self) -> Dict[str, List[Dict[str, Any]]]:
"""Return data to save."""
return {"entries": [entry.as_dict() for entry in self._entries]} | [
"def",
"_data_to_save",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"]",
":",
"return",
"{",
"\"entries\"",
":",
"[",
"entry",
".",
"as_dict",
"(",
")",
"for",
"entry",
"in",
"self",
"."... | [
852,
4
] | [
854,
72
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.__init_subclass__ | (cls, domain: Optional[str] = None, **kwargs: Any) | Initialize a subclass, register if possible. | Initialize a subclass, register if possible. | def __init_subclass__(cls, domain: Optional[str] = None, **kwargs: Any) -> None:
"""Initialize a subclass, register if possible."""
super().__init_subclass__(**kwargs) # type: ignore
if domain is not None:
HANDLERS.register(domain)(cls) | [
"def",
"__init_subclass__",
"(",
"cls",
",",
"domain",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init_subclass__",
"(",
"*",
"*",
"kwargs",
")",
"# type: ign... | [
865,
4
] | [
869,
42
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.unique_id | (self) | Return unique ID if available. | Return unique ID if available. | def unique_id(self) -> Optional[str]:
"""Return unique ID if available."""
# pylint: disable=no-member
if not self.context:
return None
return cast(Optional[str], self.context.get("unique_id")) | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# pylint: disable=no-member",
"if",
"not",
"self",
".",
"context",
":",
"return",
"None",
"return",
"cast",
"(",
"Optional",
"[",
"str",
"]",
",",
"self",
".",
"context",
".",... | [
874,
4
] | [
880,
65
] | python | en | ['fr', 'en', 'en'] | True |
ConfigFlow.async_get_options_flow | (config_entry: ConfigEntry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry: ConfigEntry) -> "OptionsFlow":
"""Get the options flow for this handler."""
raise data_entry_flow.UnknownHandler | [
"def",
"async_get_options_flow",
"(",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"\"OptionsFlow\"",
":",
"raise",
"data_entry_flow",
".",
"UnknownHandler"
] | [
884,
4
] | [
886,
44
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow._abort_if_unique_id_configured | (
self,
updates: Optional[Dict[Any, Any]] = None,
reload_on_update: bool = True,
) | Abort if the unique ID is already configured. | Abort if the unique ID is already configured. | def _abort_if_unique_id_configured(
self,
updates: Optional[Dict[Any, Any]] = None,
reload_on_update: bool = True,
) -> None:
"""Abort if the unique ID is already configured."""
assert self.hass
if self.unique_id is None:
return
for entry in self.... | [
"def",
"_abort_if_unique_id_configured",
"(",
"self",
",",
"updates",
":",
"Optional",
"[",
"Dict",
"[",
"Any",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"reload_on_update",
":",
"bool",
"=",
"True",
",",
")",
"->",
"None",
":",
"assert",
"self",
".",
"h... | [
889,
4
] | [
913,
69
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_set_unique_id | (
self, unique_id: Optional[str] = None, *, raise_on_progress: bool = True
) | Set a unique ID for the config flow.
Returns optionally existing config entry with same ID.
| Set a unique ID for the config flow. | async def async_set_unique_id(
self, unique_id: Optional[str] = None, *, raise_on_progress: bool = True
) -> Optional[ConfigEntry]:
"""Set a unique ID for the config flow.
Returns optionally existing config entry with same ID.
"""
if unique_id is None:
self.conte... | [
"async",
"def",
"async_set_unique_id",
"(",
"self",
",",
"unique_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
",",
"raise_on_progress",
":",
"bool",
"=",
"True",
")",
"->",
"Optional",
"[",
"ConfigEntry",
"]",
":",
"if",
"unique_id",
"is... | [
915,
4
] | [
944,
19
] | python | en | ['en', 'fr', 'en'] | True |
ConfigFlow._async_current_entries | (self) | Return current entries. | Return current entries. | def _async_current_entries(self) -> List[ConfigEntry]:
"""Return current entries."""
assert self.hass is not None
return self.hass.config_entries.async_entries(self.handler) | [
"def",
"_async_current_entries",
"(",
"self",
")",
"->",
"List",
"[",
"ConfigEntry",
"]",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"return",
"self",
".",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"self",
".",
"handler",
")"
... | [
947,
4
] | [
950,
67
] | python | en | ['fr', 'en', 'en'] | True |
ConfigFlow._async_current_ids | (self, include_ignore: bool = True) | Return current unique IDs. | Return current unique IDs. | def _async_current_ids(self, include_ignore: bool = True) -> Set[Optional[str]]:
"""Return current unique IDs."""
assert self.hass is not None
return {
entry.unique_id
for entry in self.hass.config_entries.async_entries(self.handler)
if include_ignore or entry... | [
"def",
"_async_current_ids",
"(",
"self",
",",
"include_ignore",
":",
"bool",
"=",
"True",
")",
"->",
"Set",
"[",
"Optional",
"[",
"str",
"]",
"]",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"return",
"{",
"entry",
".",
"unique_id",
"for"... | [
953,
4
] | [
960,
9
] | python | en | ['fr', 'la', 'en'] | False |
ConfigFlow._async_in_progress | (self) | Return other in progress flows for current domain. | Return other in progress flows for current domain. | def _async_in_progress(self) -> List[Dict]:
"""Return other in progress flows for current domain."""
assert self.hass is not None
return [
flw
for flw in self.hass.config_entries.flow.async_progress()
if flw["handler"] == self.handler and flw["flow_id"] != sel... | [
"def",
"_async_in_progress",
"(",
"self",
")",
"->",
"List",
"[",
"Dict",
"]",
":",
"assert",
"self",
".",
"hass",
"is",
"not",
"None",
"return",
"[",
"flw",
"for",
"flw",
"in",
"self",
".",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_progr... | [
963,
4
] | [
970,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_ignore | (self, user_input: Dict[str, Any]) | Ignore this config flow. | Ignore this config flow. | async def async_step_ignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]:
"""Ignore this config flow."""
await self.async_set_unique_id(user_input["unique_id"], raise_on_progress=False)
return self.async_create_entry(title="Ignored", data={}) | [
"async",
"def",
"async_step_ignore",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"user_input",
"[",
"\"unique_id\"",
"]",... | [
972,
4
] | [
975,
64
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_unignore | (self, user_input: Dict[str, Any]) | Rediscover a config entry by it's unique_id. | Rediscover a config entry by it's unique_id. | async def async_step_unignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]:
"""Rediscover a config entry by it's unique_id."""
return self.async_abort(reason="not_implemented") | [
"async",
"def",
"async_step_unignore",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"not_implemented\"",
")"
] | [
977,
4
] | [
979,
57
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (
self, user_input: Optional[Dict[str, Any]] = None
) | Handle a flow initiated by the user. | Handle a flow initiated by the user. | async def async_step_user(
self, user_input: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""Handle a flow initiated by the user."""
return self.async_abort(reason="not_implemented") | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
... | [
981,
4
] | [
985,
57
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow._async_handle_discovery_without_unique_id | (self) | Mark this flow discovered, without a unique identifier.
If a flow initiated by discovery, doesn't have a unique ID, this can
be used alternatively. It will ensure only 1 flow is started and only
when the handler has no existing config entries.
It ensures that the discovery can be ignor... | Mark this flow discovered, without a unique identifier. | async def _async_handle_discovery_without_unique_id(self) -> None:
"""Mark this flow discovered, without a unique identifier.
If a flow initiated by discovery, doesn't have a unique ID, this can
be used alternatively. It will ensure only 1 flow is started and only
when the handler has n... | [
"async",
"def",
"_async_handle_discovery_without_unique_id",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"unique_id",
"is",
"not",
"None",
":",
"return",
"# Abort if the handler has config entries already",
"if",
"self",
".",
"_async_current_entries",
"(",
... | [
987,
4
] | [
1010,
66
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_discovery | (
self, discovery_info: Dict[str, Any]
) | Handle a flow initialized by discovery. | Handle a flow initialized by discovery. | async def async_step_discovery(
self, discovery_info: Dict[str, Any]
) -> Dict[str, Any]:
"""Handle a flow initialized by discovery."""
await self._async_handle_discovery_without_unique_id()
return await self.async_step_user() | [
"async",
"def",
"async_step_discovery",
"(",
"self",
",",
"discovery_info",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"await",
"self",
".",
"_async_handle_discovery_without_unique_id",
"(",
")",
"return",
... | [
1012,
4
] | [
1017,
43
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_abort | (
self, *, reason: str, description_placeholders: Optional[Dict] = None
) | Abort the config flow. | Abort the config flow. | def async_abort(
self, *, reason: str, description_placeholders: Optional[Dict] = None
) -> Dict[str, Any]:
"""Abort the config flow."""
assert self.hass
# Remove reauth notification if no reauth flows are in progress
if self.source == SOURCE_REAUTH and not any(
... | [
"def",
"async_abort",
"(",
"self",
",",
"*",
",",
"reason",
":",
"str",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"assert",
"self",
".",
"hass",
"# Remove reaut... | [
1020,
4
] | [
1038,
9
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowManager.async_create_flow | (
self,
handler_key: Any,
*,
context: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
) | Create an options flow for a config entry.
Entry_id and flow.handler is the same thing to map entry with flow.
| Create an options flow for a config entry. | async def async_create_flow(
self,
handler_key: Any,
*,
context: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
) -> "OptionsFlow":
"""Create an options flow for a config entry.
Entry_id and flow.handler is the same thing to map entry... | [
"async",
"def",
"async_create_flow",
"(",
"self",
",",
"handler_key",
":",
"Any",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"data",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"An... | [
1050,
4
] | [
1068,
86
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowManager.async_finish_flow | (
self, flow: data_entry_flow.FlowHandler, result: Dict[str, Any]
) | Finish an options flow and update options for configuration entry.
Flow.handler and entry_id is the same thing to map flow with entry.
| Finish an options flow and update options for configuration entry. | async def async_finish_flow(
self, flow: data_entry_flow.FlowHandler, result: Dict[str, Any]
) -> Dict[str, Any]:
"""Finish an options flow and update options for configuration entry.
Flow.handler and entry_id is the same thing to map flow with entry.
"""
flow = cast(Options... | [
"async",
"def",
"async_finish_flow",
"(",
"self",
",",
"flow",
":",
"data_entry_flow",
".",
"FlowHandler",
",",
"result",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"flow",
"=",
"cast",
"(",
"Option... | [
1070,
4
] | [
1089,
21
] | python | en | ['en', 'en', 'en'] | True |
EntityRegistryDisabledHandler.__init__ | (self, hass: HomeAssistant) | Initialize the handler. | Initialize the handler. | def __init__(self, hass: HomeAssistant) -> None:
"""Initialize the handler."""
self.hass = hass
self.registry: Optional[entity_registry.EntityRegistry] = None
self.changed: Set[str] = set()
self._remove_call_later: Optional[Callable[[], None]] = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"registry",
":",
"Optional",
"[",
"entity_registry",
".",
"EntityRegistry",
"]",
"=",
"None",
"self",
".",
"changed"... | [
1116,
4
] | [
1121,
68
] | python | en | ['en', 'en', 'en'] | True |
EntityRegistryDisabledHandler.async_setup | (self) | Set up the disable handler. | Set up the disable handler. | def async_setup(self) -> None:
"""Set up the disable handler."""
self.hass.bus.async_listen(
entity_registry.EVENT_ENTITY_REGISTRY_UPDATED, self._handle_entry_updated
) | [
"def",
"async_setup",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"hass",
".",
"bus",
".",
"async_listen",
"(",
"entity_registry",
".",
"EVENT_ENTITY_REGISTRY_UPDATED",
",",
"self",
".",
"_handle_entry_updated",
")"
] | [
1124,
4
] | [
1128,
9
] | python | en | ['en', 'en', 'en'] | True |
EntityRegistryDisabledHandler._handle_entry_updated | (self, event: Event) | Handle entity registry entry update. | Handle entity registry entry update. | async def _handle_entry_updated(self, event: Event) -> None:
"""Handle entity registry entry update."""
if (
event.data["action"] != "update"
or "disabled_by" not in event.data["changes"]
):
return
if self.registry is None:
self.registry =... | [
"async",
"def",
"_handle_entry_updated",
"(",
"self",
",",
"event",
":",
"Event",
")",
"->",
"None",
":",
"if",
"(",
"event",
".",
"data",
"[",
"\"action\"",
"]",
"!=",
"\"update\"",
"or",
"\"disabled_by\"",
"not",
"in",
"event",
".",
"data",
"[",
"\"cha... | [
1130,
4
] | [
1173,
9
] | python | en | ['en', 'af', 'en'] | True |
EntityRegistryDisabledHandler._handle_reload | (self, _now: Any) | Handle a reload. | Handle a reload. | async def _handle_reload(self, _now: Any) -> None:
"""Handle a reload."""
self._remove_call_later = None
to_reload = self.changed
self.changed = set()
_LOGGER.info(
"Reloading configuration entries because disabled_by changed in entity registry: %s",
", "... | [
"async",
"def",
"_handle_reload",
"(",
"self",
",",
"_now",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"_remove_call_later",
"=",
"None",
"to_reload",
"=",
"self",
".",
"changed",
"self",
".",
"changed",
"=",
"set",
"(",
")",
"_LOGGER",
".",
"inf... | [
1175,
4
] | [
1188,
9
] | python | en | ['en', 'ca', 'en'] | True |
setup | () | Set up for tests. | Set up for tests. | def setup():
"""Set up for tests."""
global TMP_DIR
TMP_DIR = mkdtemp() | [
"def",
"setup",
"(",
")",
":",
"global",
"TMP_DIR",
"TMP_DIR",
"=",
"mkdtemp",
"(",
")"
] | [
31,
0
] | [
34,
23
] | python | en | ['en', 'da', 'en'] | True |
teardown | () | Clean up after tests. | Clean up after tests. | def teardown():
"""Clean up after tests."""
for fname in os.listdir(TMP_DIR):
os.remove(os.path.join(TMP_DIR, fname))
os.rmdir(TMP_DIR) | [
"def",
"teardown",
"(",
")",
":",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"TMP_DIR",
")",
":",
"os",
".",
"remove",
"(",
"os",
".",
"path",
".",
"join",
"(",
"TMP_DIR",
",",
"fname",
")",
")",
"os",
".",
"rmdir",
"(",
"TMP_DIR",
")"
] | [
37,
0
] | [
41,
21
] | python | en | ['en', 'en', 'en'] | True |
test_save_and_load | () | Test saving and loading back. | Test saving and loading back. | def test_save_and_load():
"""Test saving and loading back."""
fname = _path_for("test1")
save_json(fname, TEST_JSON_A)
data = load_json(fname)
assert data == TEST_JSON_A | [
"def",
"test_save_and_load",
"(",
")",
":",
"fname",
"=",
"_path_for",
"(",
"\"test1\"",
")",
"save_json",
"(",
"fname",
",",
"TEST_JSON_A",
")",
"data",
"=",
"load_json",
"(",
"fname",
")",
"assert",
"data",
"==",
"TEST_JSON_A"
] | [
48,
0
] | [
53,
30
] | python | en | ['en', 'en', 'en'] | True |
test_save_and_load_private | () | Test we can load private files and that they are protected. | Test we can load private files and that they are protected. | def test_save_and_load_private():
"""Test we can load private files and that they are protected."""
fname = _path_for("test2")
save_json(fname, TEST_JSON_A, private=True)
data = load_json(fname)
assert data == TEST_JSON_A
stats = os.stat(fname)
assert stats.st_mode & 0o77 == 0 | [
"def",
"test_save_and_load_private",
"(",
")",
":",
"fname",
"=",
"_path_for",
"(",
"\"test2\"",
")",
"save_json",
"(",
"fname",
",",
"TEST_JSON_A",
",",
"private",
"=",
"True",
")",
"data",
"=",
"load_json",
"(",
"fname",
")",
"assert",
"data",
"==",
"TES... | [
60,
0
] | [
67,
36
] | python | en | ['en', 'en', 'en'] | True |
test_overwrite_and_reload | () | Test that we can overwrite an existing file and read back. | Test that we can overwrite an existing file and read back. | def test_overwrite_and_reload():
"""Test that we can overwrite an existing file and read back."""
fname = _path_for("test3")
save_json(fname, TEST_JSON_A)
save_json(fname, TEST_JSON_B)
data = load_json(fname)
assert data == TEST_JSON_B | [
"def",
"test_overwrite_and_reload",
"(",
")",
":",
"fname",
"=",
"_path_for",
"(",
"\"test3\"",
")",
"save_json",
"(",
"fname",
",",
"TEST_JSON_A",
")",
"save_json",
"(",
"fname",
",",
"TEST_JSON_B",
")",
"data",
"=",
"load_json",
"(",
"fname",
")",
"assert"... | [
70,
0
] | [
76,
30
] | python | en | ['en', 'en', 'en'] | True |
test_save_bad_data | () | Test error from trying to save unserialisable data. | Test error from trying to save unserialisable data. | def test_save_bad_data():
"""Test error from trying to save unserialisable data."""
with pytest.raises(SerializationError) as excinfo:
save_json("test4", {"hello": set()})
assert (
"Failed to serialize to JSON: test4. Bad data at $.hello=set()(<class 'set'>"
in str(excinfo.value)
... | [
"def",
"test_save_bad_data",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"SerializationError",
")",
"as",
"excinfo",
":",
"save_json",
"(",
"\"test4\"",
",",
"{",
"\"hello\"",
":",
"set",
"(",
")",
"}",
")",
"assert",
"(",
"\"Failed to serialize to ... | [
79,
0
] | [
87,
5
] | python | en | ['en', 'en', 'en'] | True |
test_load_bad_data | () | Test error from trying to load unserialisable data. | Test error from trying to load unserialisable data. | def test_load_bad_data():
"""Test error from trying to load unserialisable data."""
fname = _path_for("test5")
with open(fname, "w") as fh:
fh.write(TEST_BAD_SERIALIED)
with pytest.raises(HomeAssistantError):
load_json(fname) | [
"def",
"test_load_bad_data",
"(",
")",
":",
"fname",
"=",
"_path_for",
"(",
"\"test5\"",
")",
"with",
"open",
"(",
"fname",
",",
"\"w\"",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"TEST_BAD_SERIALIED",
")",
"with",
"pytest",
".",
"raises",
"(",
"H... | [
90,
0
] | [
96,
24
] | python | en | ['en', 'en', 'en'] | True |
test_custom_encoder | () | Test serializing with a custom encoder. | Test serializing with a custom encoder. | def test_custom_encoder():
"""Test serializing with a custom encoder."""
class MockJSONEncoder(JSONEncoder):
"""Mock JSON encoder."""
def default(self, o):
"""Mock JSON encode method."""
return "9"
fname = _path_for("test6")
save_json(fname, Mock(), encoder=Moc... | [
"def",
"test_custom_encoder",
"(",
")",
":",
"class",
"MockJSONEncoder",
"(",
"JSONEncoder",
")",
":",
"\"\"\"Mock JSON encoder.\"\"\"",
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"\"\"\"Mock JSON encode method.\"\"\"",
"return",
"\"9\"",
"fname",
"=",
"_pat... | [
99,
0
] | [
112,
22
] | python | en | ['en', 'en', 'en'] | True |
test_find_unserializable_data | () | Find unserializeable data. | Find unserializeable data. | def test_find_unserializable_data():
"""Find unserializeable data."""
assert find_paths_unserializable_data(1) == {}
assert find_paths_unserializable_data([1, 2]) == {}
assert find_paths_unserializable_data({"something": "yo"}) == {}
assert find_paths_unserializable_data({"something": set()}) == {
... | [
"def",
"test_find_unserializable_data",
"(",
")",
":",
"assert",
"find_paths_unserializable_data",
"(",
"1",
")",
"==",
"{",
"}",
"assert",
"find_paths_unserializable_data",
"(",
"[",
"1",
",",
"2",
"]",
")",
"==",
"{",
"}",
"assert",
"find_paths_unserializable_da... | [
115,
0
] | [
165,
5
] | python | en | ['en', 'en', 'de'] | True |
test_config_update | (gogogate2api_mock, hass: HomeAssistant) | Test config setup where the config is updated. | Test config setup where the config is updated. | async def test_config_update(gogogate2api_mock, hass: HomeAssistant) -> None:
"""Test config setup where the config is updated."""
api = MagicMock(GogoGate2Api)
api.info.side_effect = Exception("Error")
gogogate2api_mock.return_value = api
config_entry = MockConfigEntry(
domain=DOMAIN,
... | [
"async",
"def",
"test_config_update",
"(",
"gogogate2api_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"api",
"=",
"MagicMock",
"(",
"GogoGate2Api",
")",
"api",
".",
"info",
".",
"side_effect",
"=",
"Exception",
"(",
"\"Error\"",
")",
"go... | [
22,
0
] | [
47,
5
] | python | en | ['en', 'en', 'en'] | True |
test_config_no_update | (ismartgateapi_mock, hass: HomeAssistant) | Test config setup where the data is not updated. | Test config setup where the data is not updated. | async def test_config_no_update(ismartgateapi_mock, hass: HomeAssistant) -> None:
"""Test config setup where the data is not updated."""
api = MagicMock(GogoGate2Api)
api.info.side_effect = Exception("Error")
ismartgateapi_mock.return_value = api
config_entry = MockConfigEntry(
domain=DOMAI... | [
"async",
"def",
"test_config_no_update",
"(",
"ismartgateapi_mock",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"api",
"=",
"MagicMock",
"(",
"GogoGate2Api",
")",
"api",
".",
"info",
".",
"side_effect",
"=",
"Exception",
"(",
"\"Error\"",
")",
... | [
51,
0
] | [
76,
5
] | python | en | ['en', 'en', 'en'] | True |
test_auth_fail | (hass: HomeAssistant) | Test authorization failures. | Test authorization failures. | async def test_auth_fail(hass: HomeAssistant) -> None:
"""Test authorization failures."""
coordinator_mock: DeviceDataUpdateCoordinator = MagicMock(
spec=DeviceDataUpdateCoordinator
)
coordinator_mock.last_update_success = False
config_entry = MockConfigEntry()
config_entry.add_to_hass... | [
"async",
"def",
"test_auth_fail",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"coordinator_mock",
":",
"DeviceDataUpdateCoordinator",
"=",
"MagicMock",
"(",
"spec",
"=",
"DeviceDataUpdateCoordinator",
")",
"coordinator_mock",
".",
"last_update_success",
... | [
79,
0
] | [
94,
51
] | python | el-Latn | ['fr', 'el-Latn', 'en'] | False |
async_setup_platform | (
hass: HomeAssistantType,
config: Dict,
async_add_entities: Callable,
discovery_info: Dict,
) | Set up the switcher platform for the switch component. | Set up the switcher platform for the switch component. | async def async_setup_platform(
hass: HomeAssistantType,
config: Dict,
async_add_entities: Callable,
discovery_info: Dict,
) -> None:
"""Set up the switcher platform for the switch component."""
if discovery_info is None:
return
async_add_entities([SwitcherControl(hass.data[DOMAIN][D... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"Dict",
",",
"async_add_entities",
":",
"Callable",
",",
"discovery_info",
":",
"Dict",
",",
")",
"->",
"None",
":",
"if",
"discovery_info",
"is",
"None",
":",
... | [
39,
0
] | [
48,
73
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.__init__ | (self, device_data: "SwitcherV2Device") | Initialize the entity. | Initialize the entity. | def __init__(self, device_data: "SwitcherV2Device") -> None:
"""Initialize the entity."""
self._self_initiated = False
self._device_data = device_data
self._state = device_data.state | [
"def",
"__init__",
"(",
"self",
",",
"device_data",
":",
"\"SwitcherV2Device\"",
")",
"->",
"None",
":",
"self",
".",
"_self_initiated",
"=",
"False",
"self",
".",
"_device_data",
"=",
"device_data",
"self",
".",
"_state",
"=",
"device_data",
".",
"state"
] | [
54,
4
] | [
58,
39
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.name | (self) | Return the device's name. | Return the device's name. | def name(self) -> str:
"""Return the device's name."""
return self._device_data.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device_data",
".",
"name"
] | [
61,
4
] | [
63,
37
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.should_poll | (self) | Return False, entity pushes its state to HA. | Return False, entity pushes its state to HA. | def should_poll(self) -> bool:
"""Return False, entity pushes its state to HA."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
66,
4
] | [
68,
20
] | python | en | ['en', 'zu', 'en'] | True |
SwitcherControl.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._device_data.device_id}-{self._device_data.mac_addr}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device_data.device_id}-{self._device_data.mac_addr}\""
] | [
71,
4
] | [
73,
76
] | python | ca | ['fr', 'ca', 'en'] | False |
SwitcherControl.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self) -> bool:
"""Return True if entity is on."""
return self._state == SWITCHER_STATE_ON | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state",
"==",
"SWITCHER_STATE_ON"
] | [
76,
4
] | [
79,
47
] | python | en | ['en', 'cy', 'en'] | True |
SwitcherControl.current_power_w | (self) | Return the current power usage in W. | Return the current power usage in W. | def current_power_w(self) -> int:
"""Return the current power usage in W."""
return self._device_data.power_consumption | [
"def",
"current_power_w",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_device_data",
".",
"power_consumption"
] | [
82,
4
] | [
84,
50
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.device_state_attributes | (self) | Return the optional state attributes. | Return the optional state attributes. | def device_state_attributes(self) -> Dict:
"""Return the optional state attributes."""
attribs = {}
for prop, attr in DEVICE_PROPERTIES_TO_HA_ATTRIBUTES.items():
value = getattr(self._device_data, prop)
if value and value is not WAITING_TEXT:
attribs[att... | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
":",
"attribs",
"=",
"{",
"}",
"for",
"prop",
",",
"attr",
"in",
"DEVICE_PROPERTIES_TO_HA_ATTRIBUTES",
".",
"items",
"(",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
".",
"_device_data",
... | [
87,
4
] | [
97,
22
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._state in [SWITCHER_STATE_ON, SWITCHER_STATE_OFF] | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state",
"in",
"[",
"SWITCHER_STATE_ON",
",",
"SWITCHER_STATE_OFF",
"]"
] | [
100,
4
] | [
103,
69
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self) -> None:
"""Run when entity about to be added to hass."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_SWITCHER_DEVICE_UPDATE, self.async_update_data
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_SWITCHER_DEVICE_UPDATE",
",",
"self",
".",
"async_update_data",
")",
")"
] | [
105,
4
] | [
111,
9
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.async_update_data | (self, device_data: "SwitcherV2Device") | Update the entity data. | Update the entity data. | async def async_update_data(self, device_data: "SwitcherV2Device") -> None:
"""Update the entity data."""
if device_data:
if self._self_initiated:
self._self_initiated = False
else:
self._device_data = device_data
self._state = self... | [
"async",
"def",
"async_update_data",
"(",
"self",
",",
"device_data",
":",
"\"SwitcherV2Device\"",
")",
"->",
"None",
":",
"if",
"device_data",
":",
"if",
"self",
".",
"_self_initiated",
":",
"self",
".",
"_self_initiated",
"=",
"False",
"else",
":",
"self",
... | [
113,
4
] | [
121,
43
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.async_turn_on | (self, **kwargs: Dict) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs: Dict) -> None:
"""Turn the entity on."""
await self._control_device(True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Dict",
")",
"->",
"None",
":",
"await",
"self",
".",
"_control_device",
"(",
"True",
")"
] | [
123,
4
] | [
125,
40
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl.async_turn_off | (self, **kwargs: Dict) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs: Dict) -> None:
"""Turn the entity off."""
await self._control_device(False) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Dict",
")",
"->",
"None",
":",
"await",
"self",
".",
"_control_device",
"(",
"False",
")"
] | [
127,
4
] | [
129,
41
] | python | en | ['en', 'en', 'en'] | True |
SwitcherControl._control_device | (self, send_on: bool) | Turn the entity on or off. | Turn the entity on or off. | async def _control_device(self, send_on: bool) -> None:
"""Turn the entity on or off."""
response: "SwitcherV2ControlResponseMSG" = None
async with SwitcherV2Api(
self.hass.loop,
self._device_data.ip_addr,
self._device_data.phone_id,
self._device_... | [
"async",
"def",
"_control_device",
"(",
"self",
",",
"send_on",
":",
"bool",
")",
"->",
"None",
":",
"response",
":",
"\"SwitcherV2ControlResponseMSG\"",
"=",
"None",
"async",
"with",
"SwitcherV2Api",
"(",
"self",
".",
"hass",
".",
"loop",
",",
"self",
".",
... | [
131,
4
] | [
149,
39
] | python | en | ['en', 'en', 'en'] | True |
TestVultrBinarySensorSetup.add_entities | (self, devices, action) | Mock add devices. | Mock add devices. | def add_entities(self, devices, action):
"""Mock add devices."""
for device in devices:
self.DEVICES.append(device) | [
"def",
"add_entities",
"(",
"self",
",",
"devices",
",",
"action",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"DEVICES",
".",
"append",
"(",
"device",
")"
] | [
31,
4
] | [
34,
39
] | python | en | ['es', 'en', 'en'] | True |
TestVultrBinarySensorSetup.setUp | (self) | Init values for this testcase class. | Init values for this testcase class. | def setUp(self):
"""Init values for this testcase class."""
self.hass = get_test_home_assistant()
self.configs = [
{CONF_SUBSCRIPTION: "576965", CONF_NAME: "A Server"},
{CONF_SUBSCRIPTION: "123456", CONF_NAME: "Failed Server"},
{CONF_SUBSCRIPTION: "555555", CO... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"configs",
"=",
"[",
"{",
"CONF_SUBSCRIPTION",
":",
"\"576965\"",
",",
"CONF_NAME",
":",
"\"A Server\"",
"}",
",",
"{",
"CONF_SUBSCRIPTION",
... | [
36,
4
] | [
44,
47
] | python | en | ['en', 'en', 'en'] | True |
TestVultrBinarySensorSetup.tear_down_cleanup | (self) | Stop our started services. | Stop our started services. | def tear_down_cleanup(self):
"""Stop our started services."""
self.hass.stop() | [
"def",
"tear_down_cleanup",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
46,
4
] | [
48,
24
] | python | en | ['de', 'en', 'en'] | True |
TestVultrBinarySensorSetup.test_binary_sensor | (self, mock) | Test successful instance. | Test successful instance. | def test_binary_sensor(self, mock):
"""Test successful instance."""
mock.get(
"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567",
text=load_fixture("vultr_account_info.json"),
)
with patch(
"vultr.Vultr.server_list",
return_val... | [
"def",
"test_binary_sensor",
"(",
"self",
",",
"mock",
")",
":",
"mock",
".",
"get",
"(",
"\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"vultr_account_info.json\"",
")",
",",
")",
"with",
"patch",
"(",
"... | [
51,
4
] | [
103,
69
] | python | en | ['en', 'ro', 'en'] | True |
TestVultrBinarySensorSetup.test_invalid_sensor_config | (self) | Test config type failures. | Test config type failures. | def test_invalid_sensor_config(self):
"""Test config type failures."""
with pytest.raises(vol.Invalid): # No subs
vultr.PLATFORM_SCHEMA({CONF_PLATFORM: base_vultr.DOMAIN}) | [
"def",
"test_invalid_sensor_config",
"(",
"self",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"# No subs",
"vultr",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"base_vultr",
".",
"DOMAIN",
"}",
")"
] | [
105,
4
] | [
108,
69
] | python | en | ['en', 'en', 'en'] | True |
TestVultrBinarySensorSetup.test_invalid_sensors | (self, mock) | Test the VultrBinarySensor fails. | Test the VultrBinarySensor fails. | def test_invalid_sensors(self, mock):
"""Test the VultrBinarySensor fails."""
mock.get(
"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567",
text=load_fixture("vultr_account_info.json"),
)
with patch(
"vultr.Vultr.server_list",
... | [
"def",
"test_invalid_sensors",
"(",
"self",
",",
"mock",
")",
":",
"mock",
".",
"get",
"(",
"\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"vultr_account_info.json\"",
")",
",",
")",
"with",
"patch",
"(",
... | [
111,
4
] | [
142,
35
] | python | en | ['en', 'ga', 'en'] | True |
generate_rand_file | (fl_name) |
generate random file and write to `fl_name`
|
generate random file and write to `fl_name`
| def generate_rand_file(fl_name):
"""
generate random file and write to `fl_name`
"""
fl_size = random.randint(1024, 102400)
fl_dir = os.path.split(fl_name)[0]
if not os.path.exists(fl_dir):
os.makedirs(fl_dir)
with open(fl_name, 'wb') as fout:
fout.write(os.urandom(fl_size)) | [
"def",
"generate_rand_file",
"(",
"fl_name",
")",
":",
"fl_size",
"=",
"random",
".",
"randint",
"(",
"1024",
",",
"102400",
")",
"fl_dir",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fl_name",
")",
"[",
"0",
"]",
"if",
"not",
"os",
".",
"path",
".... | [
16,
0
] | [
25,
39
] | python | en | ['en', 'error', 'th'] | False |
check_sum | (fl_name, tid=None) |
compute checksum for generated file of `fl_name`
|
compute checksum for generated file of `fl_name`
| def check_sum(fl_name, tid=None):
"""
compute checksum for generated file of `fl_name`
"""
hasher = hashlib.md5()
with open(fl_name, 'rb') as fin:
for chunk in iter(lambda: fin.read(4096), b""):
hasher.update(chunk)
ret = hasher.hexdigest()
if tid is not None:
ret... | [
"def",
"check_sum",
"(",
"fl_name",
",",
"tid",
"=",
"None",
")",
":",
"hasher",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"fl_name",
",",
"'rb'",
")",
"as",
"fin",
":",
"for",
"chunk",
"in",
"iter",
"(",
"lambda",
":",
"fin",
".... | [
28,
0
] | [
39,
14
] | python | en | ['en', 'error', 'th'] | False |
setup | (hass, config) | Set up the Raspberry Pi Remote GPIO component. | Set up the Raspberry Pi Remote GPIO component. | def setup(hass, config):
"""Set up the Raspberry Pi Remote GPIO component."""
return True | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"return",
"True"
] | [
15,
0
] | [
17,
15
] | python | en | ['en', 'pt', 'en'] | True |
setup_output | (address, port, invert_logic) | Set up a GPIO as output. | Set up a GPIO as output. | def setup_output(address, port, invert_logic):
"""Set up a GPIO as output."""
try:
return LED(
port, active_high=not invert_logic, pin_factory=PiGPIOFactory(address)
)
except (ValueError, IndexError, KeyError):
return None | [
"def",
"setup_output",
"(",
"address",
",",
"port",
",",
"invert_logic",
")",
":",
"try",
":",
"return",
"LED",
"(",
"port",
",",
"active_high",
"=",
"not",
"invert_logic",
",",
"pin_factory",
"=",
"PiGPIOFactory",
"(",
"address",
")",
")",
"except",
"(",
... | [
20,
0
] | [
28,
19
] | python | en | ['en', 'el-Latn', 'en'] | True |
setup_input | (address, port, pull_mode, bouncetime) | Set up a GPIO as input. | Set up a GPIO as input. | def setup_input(address, port, pull_mode, bouncetime):
"""Set up a GPIO as input."""
if pull_mode == "UP":
pull_gpio_up = True
elif pull_mode == "DOWN":
pull_gpio_up = False
try:
return Button(
port,
pull_up=pull_gpio_up,
bounce_time=bounceti... | [
"def",
"setup_input",
"(",
"address",
",",
"port",
",",
"pull_mode",
",",
"bouncetime",
")",
":",
"if",
"pull_mode",
"==",
"\"UP\"",
":",
"pull_gpio_up",
"=",
"True",
"elif",
"pull_mode",
"==",
"\"DOWN\"",
":",
"pull_gpio_up",
"=",
"False",
"try",
":",
"re... | [
31,
0
] | [
47,
19
] | python | en | ['en', 'haw', 'en'] | True |
write_output | (switch, value) | Write a value to a GPIO. | Write a value to a GPIO. | def write_output(switch, value):
"""Write a value to a GPIO."""
if value == 1:
switch.on()
if value == 0:
switch.off() | [
"def",
"write_output",
"(",
"switch",
",",
"value",
")",
":",
"if",
"value",
"==",
"1",
":",
"switch",
".",
"on",
"(",
")",
"if",
"value",
"==",
"0",
":",
"switch",
".",
"off",
"(",
")"
] | [
50,
0
] | [
55,
20
] | python | en | ['en', 'pt', 'en'] | True |
read_input | (button) | Read a value from a GPIO. | Read a value from a GPIO. | def read_input(button):
"""Read a value from a GPIO."""
return button.is_pressed | [
"def",
"read_input",
"(",
"button",
")",
":",
"return",
"button",
".",
"is_pressed"
] | [
58,
0
] | [
60,
28
] | python | en | ['en', 'en', 'en'] | True |
ieee | () | IEEE fixture. | IEEE fixture. | def ieee():
"""IEEE fixture."""
return t.EUI64.deserialize(b"ieeeaddr")[0] | [
"def",
"ieee",
"(",
")",
":",
"return",
"t",
".",
"EUI64",
".",
"deserialize",
"(",
"b\"ieeeaddr\"",
")",
"[",
"0",
"]"
] | [
21,
0
] | [
23,
46
] | python | en | ['en', 'nl', 'en'] | False |
nwk | () | NWK fixture. | NWK fixture. | def nwk():
"""NWK fixture."""
return t.NWK(0xBEEF) | [
"def",
"nwk",
"(",
")",
":",
"return",
"t",
".",
"NWK",
"(",
"0xBEEF",
")"
] | [
27,
0
] | [
29,
24
] | python | en | ['en', 'nl', 'en'] | False |
zha_gateway | (hass, setup_zha) | Return ZhaGateway fixture. | Return ZhaGateway fixture. | async def zha_gateway(hass, setup_zha):
"""Return ZhaGateway fixture."""
await setup_zha()
return get_zha_gateway(hass) | [
"async",
"def",
"zha_gateway",
"(",
"hass",
",",
"setup_zha",
")",
":",
"await",
"setup_zha",
"(",
")",
"return",
"get_zha_gateway",
"(",
"hass",
")"
] | [
33,
0
] | [
36,
32
] | python | en | ['en', 'eu', 'en'] | True |
channel_pool | () | Endpoint Channels fixture. | Endpoint Channels fixture. | def channel_pool():
"""Endpoint Channels fixture."""
ch_pool_mock = mock.MagicMock(spec_set=zha_channels.ChannelPool)
type(ch_pool_mock).skip_configuration = mock.PropertyMock(return_value=False)
ch_pool_mock.id = 1
return ch_pool_mock | [
"def",
"channel_pool",
"(",
")",
":",
"ch_pool_mock",
"=",
"mock",
".",
"MagicMock",
"(",
"spec_set",
"=",
"zha_channels",
".",
"ChannelPool",
")",
"type",
"(",
"ch_pool_mock",
")",
".",
"skip_configuration",
"=",
"mock",
".",
"PropertyMock",
"(",
"return_valu... | [
40,
0
] | [
45,
23
] | python | en | ['en', 'fr', 'en'] | True |
poll_control_ch | (channel_pool, zigpy_device_mock) | Poll control channel fixture. | Poll control channel fixture. | def poll_control_ch(channel_pool, zigpy_device_mock):
"""Poll control channel fixture."""
cluster_id = zigpy.zcl.clusters.general.PollControl.cluster_id
zigpy_dev = zigpy_device_mock(
{1: {"in_clusters": [cluster_id], "out_clusters": [], "device_type": 0x1234}},
"00:11:22:33:44:55:66:77",
... | [
"def",
"poll_control_ch",
"(",
"channel_pool",
",",
"zigpy_device_mock",
")",
":",
"cluster_id",
"=",
"zigpy",
".",
"zcl",
".",
"clusters",
".",
"general",
".",
"PollControl",
".",
"cluster_id",
"zigpy_dev",
"=",
"zigpy_device_mock",
"(",
"{",
"1",
":",
"{",
... | [
49,
0
] | [
61,
47
] | python | en | ['en', 'en', 'en'] | True |
poll_control_device | (zha_device_restored, zigpy_device_mock) | Poll control device fixture. | Poll control device fixture. | async def poll_control_device(zha_device_restored, zigpy_device_mock):
"""Poll control device fixture."""
cluster_id = zigpy.zcl.clusters.general.PollControl.cluster_id
zigpy_dev = zigpy_device_mock(
{1: {"in_clusters": [cluster_id], "out_clusters": [], "device_type": 0x1234}},
"00:11:22:33:... | [
"async",
"def",
"poll_control_device",
"(",
"zha_device_restored",
",",
"zigpy_device_mock",
")",
":",
"cluster_id",
"=",
"zigpy",
".",
"zcl",
".",
"clusters",
".",
"general",
".",
"PollControl",
".",
"cluster_id",
"zigpy_dev",
"=",
"zigpy_device_mock",
"(",
"{",
... | [
65,
0
] | [
76,
21
] | python | en | ['sv', 'en', 'en'] | True |
test_in_channel_config | (
cluster_id, bind_count, attrs, channel_pool, zigpy_device_mock, zha_gateway
) | Test ZHA core channel configuration for input clusters. | Test ZHA core channel configuration for input clusters. | async def test_in_channel_config(
cluster_id, bind_count, attrs, channel_pool, zigpy_device_mock, zha_gateway
):
"""Test ZHA core channel configuration for input clusters."""
zigpy_dev = zigpy_device_mock(
{1: {"in_clusters": [cluster_id], "out_clusters": [], "device_type": 0x1234}},
"00:11:... | [
"async",
"def",
"test_in_channel_config",
"(",
"cluster_id",
",",
"bind_count",
",",
"attrs",
",",
"channel_pool",
",",
"zigpy_device_mock",
",",
"zha_gateway",
")",
":",
"zigpy_dev",
"=",
"zigpy_device_mock",
"(",
"{",
"1",
":",
"{",
"\"in_clusters\"",
":",
"["... | [
122,
0
] | [
144,
39
] | python | en | ['en', 'en', 'en'] | True |
test_out_channel_config | (
cluster_id, bind_count, channel_pool, zigpy_device_mock, zha_gateway
) | Test ZHA core channel configuration for output clusters. | Test ZHA core channel configuration for output clusters. | async def test_out_channel_config(
cluster_id, bind_count, channel_pool, zigpy_device_mock, zha_gateway
):
"""Test ZHA core channel configuration for output clusters."""
zigpy_dev = zigpy_device_mock(
{1: {"out_clusters": [cluster_id], "in_clusters": [], "device_type": 0x1234}},
"00:11:22:33... | [
"async",
"def",
"test_out_channel_config",
"(",
"cluster_id",
",",
"bind_count",
",",
"channel_pool",
",",
"zigpy_device_mock",
",",
"zha_gateway",
")",
":",
"zigpy_dev",
"=",
"zigpy_device_mock",
"(",
"{",
"1",
":",
"{",
"\"out_clusters\"",
":",
"[",
"cluster_id"... | [
179,
0
] | [
200,
54
] | python | en | ['en', 'en', 'en'] | True |
test_channel_registry | () | Test ZIGBEE Channel Registry. | Test ZIGBEE Channel Registry. | def test_channel_registry():
"""Test ZIGBEE Channel Registry."""
for (cluster_id, channel) in registries.ZIGBEE_CHANNEL_REGISTRY.items():
assert isinstance(cluster_id, int)
assert 0 <= cluster_id <= 0xFFFF
assert issubclass(channel, base_channels.ZigbeeChannel) | [
"def",
"test_channel_registry",
"(",
")",
":",
"for",
"(",
"cluster_id",
",",
"channel",
")",
"in",
"registries",
".",
"ZIGBEE_CHANNEL_REGISTRY",
".",
"items",
"(",
")",
":",
"assert",
"isinstance",
"(",
"cluster_id",
",",
"int",
")",
"assert",
"0",
"<=",
... | [
203,
0
] | [
208,
63
] | python | fy | ['it', 'fy', 'ur'] | False |
test_epch_unclaimed_channels | (channel) | Test unclaimed channels. | Test unclaimed channels. | def test_epch_unclaimed_channels(channel):
"""Test unclaimed channels."""
ch_1 = channel(zha_const.CHANNEL_ON_OFF, 6)
ch_2 = channel(zha_const.CHANNEL_LEVEL, 8)
ch_3 = channel(zha_const.CHANNEL_COLOR, 768)
ep_channels = zha_channels.ChannelPool(
mock.MagicMock(spec_set=zha_channels.Channel... | [
"def",
"test_epch_unclaimed_channels",
"(",
"channel",
")",
":",
"ch_1",
"=",
"channel",
"(",
"zha_const",
".",
"CHANNEL_ON_OFF",
",",
"6",
")",
"ch_2",
"=",
"channel",
"(",
"zha_const",
".",
"CHANNEL_LEVEL",
",",
"8",
")",
"ch_3",
"=",
"channel",
"(",
"zh... | [
211,
0
] | [
244,
36
] | python | en | ['da', 'en', 'en'] | True |
test_epch_claim_channels | (channel) | Test channel claiming. | Test channel claiming. | def test_epch_claim_channels(channel):
"""Test channel claiming."""
ch_1 = channel(zha_const.CHANNEL_ON_OFF, 6)
ch_2 = channel(zha_const.CHANNEL_LEVEL, 8)
ch_3 = channel(zha_const.CHANNEL_COLOR, 768)
ep_channels = zha_channels.ChannelPool(
mock.MagicMock(spec_set=zha_channels.Channels), mo... | [
"def",
"test_epch_claim_channels",
"(",
"channel",
")",
":",
"ch_1",
"=",
"channel",
"(",
"zha_const",
".",
"CHANNEL_ON_OFF",
",",
"6",
")",
"ch_2",
"=",
"channel",
"(",
"zha_const",
".",
"CHANNEL_LEVEL",
",",
"8",
")",
"ch_3",
"=",
"channel",
"(",
"zha_co... | [
247,
0
] | [
276,
57
] | python | en | ['it', 'en', 'en'] | True |
test_ep_channels_all_channels | (m1, zha_device_mock) | Test EndpointChannels adding all channels. | Test EndpointChannels adding all channels. | def test_ep_channels_all_channels(m1, zha_device_mock):
"""Test EndpointChannels adding all channels."""
zha_device = zha_device_mock(
{
1: {
"in_clusters": [0, 1, 6, 8],
"out_clusters": [],
"device_type": zigpy.profiles.zha.DeviceType.ON_OFF_S... | [
"def",
"test_ep_channels_all_channels",
"(",
"m1",
",",
"zha_device_mock",
")",
":",
"zha_device",
"=",
"zha_device_mock",
"(",
"{",
"1",
":",
"{",
"\"in_clusters\"",
":",
"[",
"0",
",",
"1",
",",
"6",
",",
"8",
"]",
",",
"\"out_clusters\"",
":",
"[",
"]... | [
286,
0
] | [
327,
49
] | python | en | ['en', 'en', 'en'] | True |
test_channel_power_config | (m1, zha_device_mock) | Test that channels only get a single power channel. | Test that channels only get a single power channel. | def test_channel_power_config(m1, zha_device_mock):
"""Test that channels only get a single power channel."""
in_clusters = [0, 1, 6, 8]
zha_device = zha_device_mock(
{
1: {"in_clusters": in_clusters, "out_clusters": [], "device_type": 0x0000},
2: {
"in_cluste... | [
"def",
"test_channel_power_config",
"(",
"m1",
",",
"zha_device_mock",
")",
":",
"in_clusters",
"=",
"[",
"0",
",",
"1",
",",
"6",
",",
"8",
"]",
"zha_device",
"=",
"zha_device_mock",
"(",
"{",
"1",
":",
"{",
"\"in_clusters\"",
":",
"in_clusters",
",",
"... | [
337,
0
] | [
379,
46
] | python | en | ['en', 'en', 'en'] | True |
test_ep_channels_configure | (channel) | Test unclaimed channels. | Test unclaimed channels. | async def test_ep_channels_configure(channel):
"""Test unclaimed channels."""
ch_1 = channel(zha_const.CHANNEL_ON_OFF, 6)
ch_2 = channel(zha_const.CHANNEL_LEVEL, 8)
ch_3 = channel(zha_const.CHANNEL_COLOR, 768)
ch_3.async_configure = tests.async_mock.AsyncMock(side_effect=asyncio.TimeoutError)
c... | [
"async",
"def",
"test_ep_channels_configure",
"(",
"channel",
")",
":",
"ch_1",
"=",
"channel",
"(",
"zha_const",
".",
"CHANNEL_ON_OFF",
",",
"6",
")",
"ch_2",
"=",
"channel",
"(",
"zha_const",
".",
"CHANNEL_LEVEL",
",",
"8",
")",
"ch_3",
"=",
"channel",
"... | [
382,
0
] | [
415,
39
] | python | en | ['da', 'en', 'en'] | True |
test_poll_control_configure | (poll_control_ch) | Test poll control channel configuration. | Test poll control channel configuration. | async def test_poll_control_configure(poll_control_ch):
"""Test poll control channel configuration."""
await poll_control_ch.async_configure()
assert poll_control_ch.cluster.write_attributes.call_count == 1
assert poll_control_ch.cluster.write_attributes.call_args[0][0] == {
"checkin_interval": ... | [
"async",
"def",
"test_poll_control_configure",
"(",
"poll_control_ch",
")",
":",
"await",
"poll_control_ch",
".",
"async_configure",
"(",
")",
"assert",
"poll_control_ch",
".",
"cluster",
".",
"write_attributes",
".",
"call_count",
"==",
"1",
"assert",
"poll_control_c... | [
418,
0
] | [
424,
5
] | python | en | ['en', 'en', 'en'] | True |
test_poll_control_checkin_response | (poll_control_ch) | Test poll control channel checkin response. | Test poll control channel checkin response. | async def test_poll_control_checkin_response(poll_control_ch):
"""Test poll control channel checkin response."""
rsp_mock = tests.async_mock.AsyncMock()
set_interval_mock = tests.async_mock.AsyncMock()
cluster = poll_control_ch.cluster
patch_1 = mock.patch.object(cluster, "checkin_response", rsp_moc... | [
"async",
"def",
"test_poll_control_checkin_response",
"(",
"poll_control_ch",
")",
":",
"rsp_mock",
"=",
"tests",
".",
"async_mock",
".",
"AsyncMock",
"(",
")",
"set_interval_mock",
"=",
"tests",
".",
"async_mock",
".",
"AsyncMock",
"(",
")",
"cluster",
"=",
"po... | [
427,
0
] | [
446,
69
] | python | en | ['it', 'en', 'en'] | True |
test_poll_control_cluster_command | (hass, poll_control_device) | Test poll control channel response to cluster command. | Test poll control channel response to cluster command. | async def test_poll_control_cluster_command(hass, poll_control_device):
"""Test poll control channel response to cluster command."""
checkin_mock = tests.async_mock.AsyncMock()
poll_control_ch = poll_control_device.channels.pools[0].all_channels["1:0x0020"]
cluster = poll_control_ch.cluster
events =... | [
"async",
"def",
"test_poll_control_cluster_command",
"(",
"hass",
",",
"poll_control_device",
")",
":",
"checkin_mock",
"=",
"tests",
".",
"async_mock",
".",
"AsyncMock",
"(",
")",
"poll_control_ch",
"=",
"poll_control_device",
".",
"channels",
".",
"pools",
"[",
... | [
449,
0
] | [
475,
61
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Dexcom sensors. | Set up the Dexcom sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Dexcom sensors."""
coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]
username = config_entry.data[CONF_USERNAME]
unit_of_measurement = config_entry.options[CONF_UNIT_OF_MEASUREMENT]
sensors = []
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"COORDINATOR",
"]",
"username",
"=",
"con... | [
7,
0
] | [
15,
38
] | python | en | ['en', 'ca', 'en'] | True |
DexcomGlucoseValueSensor.__init__ | (self, coordinator, username, unit_of_measurement) | Initialize the sensor. | Initialize the sensor. | def __init__(self, coordinator, username, unit_of_measurement):
"""Initialize the sensor."""
super().__init__(coordinator)
self._state = None
self._unit_of_measurement = unit_of_measurement
self._attribute_unit_of_measurement = (
"mg_dl" if unit_of_measurement == MG_D... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"username",
",",
"unit_of_measurement",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_unit_of_measurement",
"=",
"unit_of_mea... | [
21,
4
] | [
30,
45
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseValueSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
33,
4
] | [
35,
25
] | python | en | ['en', 'mi', 'en'] | True |
DexcomGlucoseValueSensor.icon | (self) | Return the icon for the frontend. | Return the icon for the frontend. | def icon(self):
"""Return the icon for the frontend."""
return GLUCOSE_VALUE_ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"GLUCOSE_VALUE_ICON"
] | [
38,
4
] | [
40,
33
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseValueSensor.unit_of_measurement | (self) | Return the unit of measurement of the device. | Return the unit of measurement of the device. | def unit_of_measurement(self):
"""Return the unit of measurement of the device."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
43,
4
] | [
45,
40
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseValueSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self.coordinator.data:
return getattr(self.coordinator.data, self._attribute_unit_of_measurement)
return None | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"coordinator",
".",
"data",
":",
"return",
"getattr",
"(",
"self",
".",
"coordinator",
".",
"data",
",",
"self",
".",
"_attribute_unit_of_measurement",
")",
"return",
"None"
] | [
48,
4
] | [
52,
19
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseValueSensor.unique_id | (self) | Device unique id. | Device unique id. | def unique_id(self):
"""Device unique id."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
55,
4
] | [
57,
30
] | python | en | ['fr', 'it', 'en'] | False |
DexcomGlucoseTrendSensor.__init__ | (self, coordinator, username) | Initialize the sensor. | Initialize the sensor. | def __init__(self, coordinator, username):
"""Initialize the sensor."""
super().__init__(coordinator)
self._state = None
self._name = f"{DOMAIN}_{username}_glucose_trend"
self._unique_id = f"{username}-trend" | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"username",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_name",
"=",
"f\"{DOMAIN}_{username}_glucose_trend\"",
"self",
".",
... | [
63,
4
] | [
68,
45
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseTrendSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
71,
4
] | [
73,
25
] | python | en | ['en', 'mi', 'en'] | True |
DexcomGlucoseTrendSensor.icon | (self) | Return the icon for the frontend. | Return the icon for the frontend. | def icon(self):
"""Return the icon for the frontend."""
if self.coordinator.data:
return GLUCOSE_TREND_ICON[self.coordinator.data.trend]
return GLUCOSE_TREND_ICON[0] | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"coordinator",
".",
"data",
":",
"return",
"GLUCOSE_TREND_ICON",
"[",
"self",
".",
"coordinator",
".",
"data",
".",
"trend",
"]",
"return",
"GLUCOSE_TREND_ICON",
"[",
"0",
"]"
] | [
76,
4
] | [
80,
36
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseTrendSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self.coordinator.data:
return self.coordinator.data.trend_description
return None | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"coordinator",
".",
"data",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
".",
"trend_description",
"return",
"None"
] | [
83,
4
] | [
87,
19
] | python | en | ['en', 'en', 'en'] | True |
DexcomGlucoseTrendSensor.unique_id | (self) | Device unique id. | Device unique id. | def unique_id(self):
"""Device unique id."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
90,
4
] | [
92,
30
] | python | en | ['fr', 'it', 'en'] | False |
SomaFlowHandler.__init__ | (self) | Instantiate config flow. | Instantiate config flow. | def __init__(self):
"""Instantiate config flow.""" | [
"def",
"__init__",
"(",
"self",
")",
":"
] | [
23,
4
] | [
24,
38
] | python | en | ['en', 'nl', 'en'] | True |
SomaFlowHandler.async_step_user | (self, user_input=None) | Handle a flow start. | Handle a flow start. | async def async_step_user(self, user_input=None):
"""Handle a flow start."""
if user_input is None:
data = {
vol.Required(CONF_HOST): str,
vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
}
return self.async_show_form(step_id="user"... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"data",
"=",
"{",
"vol",
".",
"Required",
"(",
"CONF_HOST",
")",
":",
"str",
",",
"vol",
".",
"Required",
"(",
"CONF_PORT",... | [
26,
4
] | [
36,
57
] | python | en | ['en', 'lb', 'en'] | True |
SomaFlowHandler.async_step_creation | (self, user_input=None) | Finish config flow. | Finish config flow. | async def async_step_creation(self, user_input=None):
"""Finish config flow."""
api = SomaApi(user_input["host"], user_input["port"])
try:
result = await self.hass.async_add_executor_job(api.list_devices)
_LOGGER.info("Successfully set up Soma Connect")
if res... | [
"async",
"def",
"async_step_creation",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"api",
"=",
"SomaApi",
"(",
"user_input",
"[",
"\"host\"",
"]",
",",
"user_input",
"[",
"\"port\"",
"]",
")",
"try",
":",
"result",
"=",
"await",
"self",
".",
... | [
38,
4
] | [
58,
62
] | python | en | ['de', 'en', 'en'] | True |
SomaFlowHandler.async_step_import | (self, user_input=None) | Handle flow start from existing config section. | Handle flow start from existing config section. | async def async_step_import(self, user_input=None):
"""Handle flow start from existing config section."""
if self.hass.config_entries.async_entries(DOMAIN):
return self.async_abort(reason="already_setup")
return await self.async_step_creation(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"alread... | [
60,
4
] | [
64,
57
] | python | en | ['en', 'en', 'en'] | True |
get_split | (split_name, dataset_dir, file_pattern=None, reader=None) | Gets a dataset tuple with instructions for reading flowers.
Args:
split_name: A train/validation split name.
dataset_dir: The base directory of the dataset sources.
file_pattern: The file pattern to use when matching the dataset sources.
It is assumed that the pattern contains a '%s' string so that... | Gets a dataset tuple with instructions for reading flowers. | def get_split(split_name, dataset_dir, file_pattern=None, reader=None):
"""Gets a dataset tuple with instructions for reading flowers.
Args:
split_name: A train/validation split name.
dataset_dir: The base directory of the dataset sources.
file_pattern: The file pattern to use when matching the dataset... | [
"def",
"get_split",
"(",
"split_name",
",",
"dataset_dir",
",",
"file_pattern",
"=",
"None",
",",
"reader",
"=",
"None",
")",
":",
"if",
"split_name",
"not",
"in",
"SPLITS_TO_SIZES",
":",
"raise",
"ValueError",
"(",
"'split name %s was not recognized.'",
"%",
"s... | [
44,
0
] | [
98,
38
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.