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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_setup_entry | (hass, entry, async_add_entities) | Set up SimpliSafe locks based on a config entry. | Set up SimpliSafe locks based on a config entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up SimpliSafe locks based on a config entry."""
simplisafe = hass.data[DOMAIN][DATA_CLIENT][entry.entry_id]
async_add_entities(
[
SimpliSafeLock(simplisafe, system, lock)
for system in simplisafe.systems.val... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"simplisafe",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CLIENT",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"async_add_entities",
"(",
"[",
"S... | [
16,
0
] | [
25,
5
] | python | en | ['en', 'da', 'en'] | True |
SimpliSafeLock.__init__ | (self, simplisafe, system, lock) | Initialize. | Initialize. | def __init__(self, simplisafe, system, lock):
"""Initialize."""
super().__init__(simplisafe, system, lock.name, serial=lock.serial)
self._lock = lock
self._is_locked = None
for event_type in (EVENT_LOCK_LOCKED, EVENT_LOCK_UNLOCKED):
self.websocket_events_to_listen_fo... | [
"def",
"__init__",
"(",
"self",
",",
"simplisafe",
",",
"system",
",",
"lock",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"simplisafe",
",",
"system",
",",
"lock",
".",
"name",
",",
"serial",
"=",
"lock",
".",
"serial",
")",
"self",
".",
"_... | [
31,
4
] | [
38,
66
] | python | en | ['en', 'en', 'it'] | False |
SimpliSafeLock.is_locked | (self) | Return true if the lock is locked. | Return true if the lock is locked. | def is_locked(self):
"""Return true if the lock is locked."""
return self._is_locked | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_locked"
] | [
41,
4
] | [
43,
30
] | python | en | ['en', 'mt', 'en'] | True |
SimpliSafeLock.async_lock | (self, **kwargs) | Lock the lock. | Lock the lock. | async def async_lock(self, **kwargs):
"""Lock the lock."""
try:
await self._lock.lock()
except SimplipyError as err:
LOGGER.error('Error while locking "%s": %s', self._lock.name, err)
return | [
"async",
"def",
"async_lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"await",
"self",
".",
"_lock",
".",
"lock",
"(",
")",
"except",
"SimplipyError",
"as",
"err",
":",
"LOGGER",
".",
"error",
"(",
"'Error while locking \"%s\": %s'",
... | [
45,
4
] | [
51,
18
] | python | en | ['en', 'la', 'en'] | True |
SimpliSafeLock.async_unlock | (self, **kwargs) | Unlock the lock. | Unlock the lock. | async def async_unlock(self, **kwargs):
"""Unlock the lock."""
try:
await self._lock.unlock()
except SimplipyError as err:
LOGGER.error('Error while unlocking "%s": %s', self._lock.name, err)
return | [
"async",
"def",
"async_unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"await",
"self",
".",
"_lock",
".",
"unlock",
"(",
")",
"except",
"SimplipyError",
"as",
"err",
":",
"LOGGER",
".",
"error",
"(",
"'Error while unlocking \"%s\": %s... | [
53,
4
] | [
59,
18
] | python | en | ['en', 'ms', 'en'] | True |
SimpliSafeLock.async_update_from_rest_api | (self) | Update the entity with the provided REST API data. | Update the entity with the provided REST API data. | def async_update_from_rest_api(self):
"""Update the entity with the provided REST API data."""
self._attrs.update(
{
ATTR_LOCK_LOW_BATTERY: self._lock.lock_low_battery,
ATTR_JAMMED: self._lock.state == LockStates.jammed,
ATTR_PIN_PAD_LOW_BATTER... | [
"def",
"async_update_from_rest_api",
"(",
"self",
")",
":",
"self",
".",
"_attrs",
".",
"update",
"(",
"{",
"ATTR_LOCK_LOW_BATTERY",
":",
"self",
".",
"_lock",
".",
"lock_low_battery",
",",
"ATTR_JAMMED",
":",
"self",
".",
"_lock",
".",
"state",
"==",
"LockS... | [
62,
4
] | [
72,
63
] | python | en | ['en', 'en', 'en'] | True |
SimpliSafeLock.async_update_from_websocket_event | (self, event) | Update the entity with the provided websocket event data. | Update the entity with the provided websocket event data. | def async_update_from_websocket_event(self, event):
"""Update the entity with the provided websocket event data."""
if event.event_type == EVENT_LOCK_LOCKED:
self._is_locked = True
else:
self._is_locked = False | [
"def",
"async_update_from_websocket_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"event_type",
"==",
"EVENT_LOCK_LOCKED",
":",
"self",
".",
"_is_locked",
"=",
"True",
"else",
":",
"self",
".",
"_is_locked",
"=",
"False"
] | [
75,
4
] | [
80,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the wiffi component. config contains data from configuration.yaml. | Set up the wiffi component. config contains data from configuration.yaml. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the wiffi component. config contains data from configuration.yaml."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"return",
"True"
] | [
35,
0
] | [
37,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, config_entry: ConfigEntry) | Set up wiffi from a config entry, config_entry contains data from config entry database. | Set up wiffi from a config entry, config_entry contains data from config entry database. | async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Set up wiffi from a config entry, config_entry contains data from config entry database."""
if not config_entry.update_listeners:
config_entry.add_update_listener(async_update_options)
# create api object
api = Wiff... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
":",
"if",
"not",
"config_entry",
".",
"update_listeners",
":",
"config_entry",
".",
"add_update_listener",
"(",
"async_update_options",
")",
"# cre... | [
40,
0
] | [
66,
15
] | python | en | ['en', 'en', 'en'] | True |
async_update_options | (hass: HomeAssistant, config_entry: ConfigEntry) | Update options. | Update options. | async def async_update_options(hass: HomeAssistant, config_entry: ConfigEntry):
"""Update options."""
await hass.config_entries.async_reload(config_entry.entry_id) | [
"async",
"def",
"async_update_options",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"config_entry",
".",
"entry_id",
")"
] | [
69,
0
] | [
71,
65
] | python | en | ['en', 'en', 'en'] | False |
async_unload_entry | (hass: HomeAssistant, config_entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Unload a config entry."""
api: "WiffiIntegrationApi" = hass.data[DOMAIN][config_entry.entry_id]
await api.server.close_server()
unload_ok = all(
await asyncio.gather(
*[
hass.config_entr... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
")",
":",
"api",
":",
"\"WiffiIntegrationApi\"",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"await",... | [
74,
0
] | [
91,
20
] | python | en | ['en', 'es', 'en'] | True |
generate_unique_id | (device, metric) | Generate a unique string for the entity. | Generate a unique string for the entity. | def generate_unique_id(device, metric):
"""Generate a unique string for the entity."""
return f"{device.mac_address.replace(':', '')}-{metric.name}" | [
"def",
"generate_unique_id",
"(",
"device",
",",
"metric",
")",
":",
"return",
"f\"{device.mac_address.replace(':', '')}-{metric.name}\""
] | [
94,
0
] | [
96,
65
] | python | en | ['en', 'en', 'en'] | True |
WiffiIntegrationApi.__init__ | (self, hass) | Initialize the instance. | Initialize the instance. | def __init__(self, hass):
"""Initialize the instance."""
self._hass = hass
self._server = None
self._known_devices = {}
self._periodic_callback = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_server",
"=",
"None",
"self",
".",
"_known_devices",
"=",
"{",
"}",
"self",
".",
"_periodic_callback",
"=",
"None"
] | [
102,
4
] | [
107,
38
] | python | en | ['en', 'en', 'en'] | True |
WiffiIntegrationApi.async_setup | (self, config_entry) | Set up api instance. | Set up api instance. | def async_setup(self, config_entry):
"""Set up api instance."""
self._server = WiffiTcpServer(config_entry.data[CONF_PORT], self)
self._periodic_callback = async_track_time_interval(
self._hass, self._periodic_tick, timedelta(seconds=10)
) | [
"def",
"async_setup",
"(",
"self",
",",
"config_entry",
")",
":",
"self",
".",
"_server",
"=",
"WiffiTcpServer",
"(",
"config_entry",
".",
"data",
"[",
"CONF_PORT",
"]",
",",
"self",
")",
"self",
".",
"_periodic_callback",
"=",
"async_track_time_interval",
"("... | [
109,
4
] | [
114,
9
] | python | en | ['en', 'pt', 'en'] | True |
WiffiIntegrationApi.shutdown | (self) | Shutdown wiffi api.
Remove listener for periodic callbacks.
| Shutdown wiffi api. | def shutdown(self):
"""Shutdown wiffi api.
Remove listener for periodic callbacks.
"""
remove_listener = self._periodic_callback
if remove_listener is not None:
remove_listener() | [
"def",
"shutdown",
"(",
"self",
")",
":",
"remove_listener",
"=",
"self",
".",
"_periodic_callback",
"if",
"remove_listener",
"is",
"not",
"None",
":",
"remove_listener",
"(",
")"
] | [
116,
4
] | [
123,
29
] | python | en | ['en', 'ja-Latn', 'sw'] | False |
WiffiIntegrationApi.__call__ | (self, device, metrics) | Process callback from TCP server if new data arrives from a device. | Process callback from TCP server if new data arrives from a device. | async def __call__(self, device, metrics):
"""Process callback from TCP server if new data arrives from a device."""
if device.mac_address not in self._known_devices:
# add empty set for new device
self._known_devices[device.mac_address] = set()
for metric in metrics:
... | [
"async",
"def",
"__call__",
"(",
"self",
",",
"device",
",",
"metrics",
")",
":",
"if",
"device",
".",
"mac_address",
"not",
"in",
"self",
".",
"_known_devices",
":",
"# add empty set for new device",
"self",
".",
"_known_devices",
"[",
"device",
".",
"mac_add... | [
125,
4
] | [
141,
17
] | python | en | ['en', 'en', 'en'] | True |
WiffiIntegrationApi.server | (self) | Return TCP server instance for start + close. | Return TCP server instance for start + close. | def server(self):
"""Return TCP server instance for start + close."""
return self._server | [
"def",
"server",
"(",
"self",
")",
":",
"return",
"self",
".",
"_server"
] | [
144,
4
] | [
146,
27
] | python | en | ['en', 'no', 'en'] | True |
WiffiIntegrationApi._periodic_tick | (self, now=None) | Check if any entity has timed out because it has not been updated. | Check if any entity has timed out because it has not been updated. | def _periodic_tick(self, now=None):
"""Check if any entity has timed out because it has not been updated."""
async_dispatcher_send(self._hass, CHECK_ENTITIES_SIGNAL) | [
"def",
"_periodic_tick",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"CHECK_ENTITIES_SIGNAL",
")"
] | [
149,
4
] | [
151,
64
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity.__init__ | (self, device, metric, options) | Initialize the base elements of a wiffi entity. | Initialize the base elements of a wiffi entity. | def __init__(self, device, metric, options):
"""Initialize the base elements of a wiffi entity."""
self._id = generate_unique_id(device, metric)
self._device_info = {
"connections": {
(device_registry.CONNECTION_NETWORK_MAC, device.mac_address)
},
... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"metric",
",",
"options",
")",
":",
"self",
".",
"_id",
"=",
"generate_unique_id",
"(",
"device",
",",
"metric",
")",
"self",
".",
"_device_info",
"=",
"{",
"\"connections\"",
":",
"{",
"(",
"device_reg... | [
157,
4
] | [
173,
66
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity.async_added_to_hass | (self) | Entity has been added to hass. | Entity has been added to hass. | async def async_added_to_hass(self):
"""Entity has been added to hass."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"{UPDATE_ENTITY_SIGNAL}-{self._id}",
self._update_value_callback,
)
)
self.async_o... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"f\"{UPDATE_ENTITY_SIGNAL}-{self._id}\"",
",",
"self",
".",
"_update_value_callback",
",",
")",
")",
"self",... | [
175,
4
] | [
188,
9
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity.should_poll | (self) | Disable polling because data driven . | Disable polling because data driven . | def should_poll(self):
"""Disable polling because data driven ."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
191,
4
] | [
193,
20
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity.device_info | (self) | Return wiffi device info which is shared between all entities of a device. | Return wiffi device info which is shared between all entities of a device. | def device_info(self):
"""Return wiffi device info which is shared between all entities of a device."""
return self._device_info | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_info"
] | [
196,
4
] | [
198,
32
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity.unique_id | (self) | Return unique id for entity. | Return unique id for entity. | def unique_id(self):
"""Return unique id for entity."""
return self._id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_id"
] | [
201,
4
] | [
203,
23
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity.name | (self) | Return entity name. | Return entity name. | def name(self):
"""Return entity name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
206,
4
] | [
208,
25
] | python | en | ['en', 'ig', 'en'] | True |
WiffiEntity.available | (self) | Return true if value is valid. | Return true if value is valid. | def available(self):
"""Return true if value is valid."""
return self._value is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value",
"is",
"not",
"None"
] | [
211,
4
] | [
213,
38
] | python | en | ['en', 'et', 'en'] | True |
WiffiEntity.reset_expiration_date | (self) | Reset value expiration date.
Will be called by derived classes after a value update has been received.
| Reset value expiration date. | def reset_expiration_date(self):
"""Reset value expiration date.
Will be called by derived classes after a value update has been received.
"""
self._expiration_date = utcnow() + timedelta(minutes=self._timeout) | [
"def",
"reset_expiration_date",
"(",
"self",
")",
":",
"self",
".",
"_expiration_date",
"=",
"utcnow",
"(",
")",
"+",
"timedelta",
"(",
"minutes",
"=",
"self",
".",
"_timeout",
")"
] | [
215,
4
] | [
220,
75
] | python | en | ['fr', 'en', 'en'] | True |
WiffiEntity._update_value_callback | (self, device, metric) | Update the value of the entity. | Update the value of the entity. | def _update_value_callback(self, device, metric):
"""Update the value of the entity.""" | [
"def",
"_update_value_callback",
"(",
"self",
",",
"device",
",",
"metric",
")",
":"
] | [
223,
4
] | [
224,
45
] | python | en | ['en', 'en', 'en'] | True |
WiffiEntity._check_expiration_date | (self) | Periodically check if entity value has been updated.
If there are no more updates from the wiffi device, the value will be
set to unavailable.
| Periodically check if entity value has been updated. | def _check_expiration_date(self):
"""Periodically check if entity value has been updated.
If there are no more updates from the wiffi device, the value will be
set to unavailable.
"""
if (
self._value is not None
and self._expiration_date is not None
... | [
"def",
"_check_expiration_date",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_value",
"is",
"not",
"None",
"and",
"self",
".",
"_expiration_date",
"is",
"not",
"None",
"and",
"utcnow",
"(",
")",
">",
"self",
".",
"_expiration_date",
")",
":",
"self",... | [
227,
4
] | [
239,
39
] | python | en | ['en', 'en', 'en'] | True |
GreedyPolicy.__init__ | (self, supply_top_k: int = 1, demand_top_k: int = 1) |
Agent that executes a greedy policy. If the event type is supply, send as many bikes as possible to one of the
demand_k stations with the most empty slots. If the event type is demand, request as many bikes as possible from
one of the supply_k stations with the most bikes.
Args:
... |
Agent that executes a greedy policy. If the event type is supply, send as many bikes as possible to one of the
demand_k stations with the most empty slots. If the event type is demand, request as many bikes as possible from
one of the supply_k stations with the most bikes. | def __init__(self, supply_top_k: int = 1, demand_top_k: int = 1):
"""
Agent that executes a greedy policy. If the event type is supply, send as many bikes as possible to one of the
demand_k stations with the most empty slots. If the event type is demand, request as many bikes as possible from
... | [
"def",
"__init__",
"(",
"self",
",",
"supply_top_k",
":",
"int",
"=",
"1",
",",
"demand_top_k",
":",
"int",
"=",
"1",
")",
":",
"self",
".",
"_supply_top_k",
"=",
"supply_top_k",
"self",
".",
"_demand_top_k",
"=",
"demand_top_k"
] | [
18,
4
] | [
29,
41
] | python | en | ['en', 'error', 'th'] | False |
floats_list | (shape, scale=1.0, rng=None, name=None) | Creates a random float32 tensor | Creates a random float32 tensor | def floats_list(shape, scale=1.0, rng=None, name=None):
"""Creates a random float32 tensor"""
if rng is None:
rng = global_rng
values = []
for batch_idx in range(shape[0]):
values.append([])
for _ in range(shape[1]):
values[-1].append(rng.random() * scale)
retur... | [
"def",
"floats_list",
"(",
"shape",
",",
"scale",
"=",
"1.0",
",",
"rng",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"global_rng",
"values",
"=",
"[",
"]",
"for",
"batch_idx",
"in",
"range",
"(",
... | [
40,
0
] | [
51,
17
] | python | en | ['en', 'ca', 'en'] | True |
is_valid_proxy | (data) |
is data is valid proxy format
:param data:
:return:
|
is data is valid proxy format
:param data:
:return:
| def is_valid_proxy(data):
"""
is data is valid proxy format
:param data:
:return:
"""
return re.match('\d+\.\d+\.\d+\.\d+\:\d+', data) | [
"def",
"is_valid_proxy",
"(",
"data",
")",
":",
"return",
"re",
".",
"match",
"(",
"'\\d+\\.\\d+\\.\\d+\\.\\d+\\:\\d+'",
",",
"data",
")"
] | [
4,
0
] | [
10,
52
] | python | en | ['en', 'error', 'th'] | False |
convert_proxy_or_proxies | (data) |
convert list of str to valid proxies or proxy
:param data:
:return:
|
convert list of str to valid proxies or proxy
:param data:
:return:
| def convert_proxy_or_proxies(data):
"""
convert list of str to valid proxies or proxy
:param data:
:return:
"""
if not data:
return None
# if list of proxies
if isinstance(data, list):
result = []
for item in data:
# skip invalid item
item ... | [
"def",
"convert_proxy_or_proxies",
"(",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"None",
"# if list of proxies",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"data",
":",
"# skip invalid... | [
13,
0
] | [
33,
47
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass: HomeAssistant, config: Config) | Set up configured GIOS. | Set up configured GIOS. | async def async_setup(hass: HomeAssistant, config: Config) -> bool:
"""Set up configured GIOS."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"Config",
")",
"->",
"bool",
":",
"return",
"True"
] | [
17,
0
] | [
19,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up GIOS as config entry. | Set up GIOS as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up GIOS as config entry."""
station_id = config_entry.data[CONF_STATION_ID]
_LOGGER.debug("Using station_id: %s", station_id)
websession = async_get_clientsession(hass)
coordinator = GiosDataUpdateCoordinator(hass, websession, station_id)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"station_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_STATION_ID",
"]",
"_LOGGER",
".",
"debug",
"(",
"\"Using station_id: %s\"",
",",
"station_id",
")",
"websession",
"=",
"as... | [
22,
0
] | [
41,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
hass.data[DOMAIN].pop(config_entry.entry_id)
await hass.config_entries.async_forward_entry_unload(config_entry, "air_quality")
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"config_entry",
".",
"entry_id",
")",
"await",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
... | [
44,
0
] | [
48,
15
] | python | en | ['en', 'es', 'en'] | True |
GiosDataUpdateCoordinator.__init__ | (self, hass, session, station_id) | Class to manage fetching GIOS data API. | Class to manage fetching GIOS data API. | def __init__(self, hass, session, station_id):
"""Class to manage fetching GIOS data API."""
self.gios = Gios(station_id, session)
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL) | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"session",
",",
"station_id",
")",
":",
"self",
".",
"gios",
"=",
"Gios",
"(",
"station_id",
",",
"session",
")",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"_LOGGER",
",",
"name",
"=",
"... | [
54,
4
] | [
58,
83
] | python | en | ['en', 'en', 'en'] | True |
GiosDataUpdateCoordinator._async_update_data | (self) | Update data via library. | Update data via library. | async def _async_update_data(self):
"""Update data via library."""
try:
with timeout(30):
await self.gios.update()
except (
ApiError,
NoStationError,
ClientConnectorError,
InvalidSensorsData,
) as error:
... | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
":",
"try",
":",
"with",
"timeout",
"(",
"30",
")",
":",
"await",
"self",
".",
"gios",
".",
"update",
"(",
")",
"except",
"(",
"ApiError",
",",
"NoStationError",
",",
"ClientConnectorError",
",",
"I... | [
60,
4
] | [
72,
29
] | python | en | ['fr', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
20,
0
] | [
22,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
26,
0
] | [
28,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
32,
0
] | [
34,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_triggers | (hass, device_reg, entity_reg) | Test we get the expected triggers from a lock. | Test we get the expected triggers from a lock. | async def test_get_triggers(hass, device_reg, entity_reg):
"""Test we get the expected triggers from a lock."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
conn... | [
"async",
"def",
"test_get_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
37,
0
] | [
63,
50
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change | (hass, calls) | Test for turn_on and turn_off triggers firing. | Test for turn_on and turn_off triggers firing. | async def test_if_fires_on_state_change(hass, calls):
"""Test for turn_on and turn_off triggers firing."""
hass.states.async_set("lock.entity", STATE_UNLOCKED)
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
... | [
"async",
"def",
"test_if_fires_on_state_change",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"lock.entity\"",
",",
"STATE_UNLOCKED",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"D... | [
66,
0
] | [
131,
82
] | python | en | ['en', 'en', 'en'] | True |
test_scan_match_st | (hass, caplog) | Test matching based on ST. | Test matching based on ST. | async def test_scan_match_st(hass, caplog):
"""Test matching based on ST."""
scanner = ssdp.Scanner(hass, {"mock-domain": [{"st": "mock-st"}]})
with patch(
"netdisco.ssdp.scan",
return_value=[
Mock(
st="mock-st",
location=None,
val... | [
"async",
"def",
"test_scan_match_st",
"(",
"hass",
",",
"caplog",
")",
":",
"scanner",
"=",
"ssdp",
".",
"Scanner",
"(",
"hass",
",",
"{",
"\"mock-domain\"",
":",
"[",
"{",
"\"st\"",
":",
"\"mock-st\"",
"}",
"]",
"}",
")",
"with",
"patch",
"(",
"\"netd... | [
12,
0
] | [
40,
57
] | python | en | ['en', 'en', 'en'] | True |
test_scan_match_upnp_devicedesc | (hass, aioclient_mock, key) | Test matching based on UPnP device description data. | Test matching based on UPnP device description data. | async def test_scan_match_upnp_devicedesc(hass, aioclient_mock, key):
"""Test matching based on UPnP device description data."""
aioclient_mock.get(
"http://1.1.1.1",
text=f"""
<root>
<device>
<{key}>Paulus</{key}>
</device>
</root>
""",
)
scanner = ssdp.Scanner(hass, {"mock-... | [
"async",
"def",
"test_scan_match_upnp_devicedesc",
"(",
"hass",
",",
"aioclient_mock",
",",
"key",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://1.1.1.1\"",
",",
"text",
"=",
"f\"\"\"\n<root>\n <device>\n <{key}>Paulus</{key}>\n </device>\n</root>\n \"\"\"",
... | [
46,
0
] | [
70,
70
] | python | en | ['en', 'en', 'en'] | True |
test_scan_not_all_present | (hass, aioclient_mock) | Test match fails if some specified attributes are not present. | Test match fails if some specified attributes are not present. | async def test_scan_not_all_present(hass, aioclient_mock):
"""Test match fails if some specified attributes are not present."""
aioclient_mock.get(
"http://1.1.1.1",
text="""
<root>
<device>
<deviceType>Paulus</deviceType>
</device>
</root>
""",
)
scanner = ssdp.Scanner(
... | [
"async",
"def",
"test_scan_not_all_present",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://1.1.1.1\"",
",",
"text",
"=",
"\"\"\"\n<root>\n <device>\n <deviceType>Paulus</deviceType>\n </device>\n</root>\n \"\"\"",
",",
")",
... | [
73,
0
] | [
105,
35
] | python | en | ['en', 'en', 'en'] | True |
test_scan_not_all_match | (hass, aioclient_mock) | Test match fails if some specified attribute values differ. | Test match fails if some specified attribute values differ. | async def test_scan_not_all_match(hass, aioclient_mock):
"""Test match fails if some specified attribute values differ."""
aioclient_mock.get(
"http://1.1.1.1",
text="""
<root>
<device>
<deviceType>Paulus</deviceType>
<manufacturer>Paulus</manufacturer>
</device>
</root>
""",
... | [
"async",
"def",
"test_scan_not_all_match",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://1.1.1.1\"",
",",
"text",
"=",
"\"\"\"\n<root>\n <device>\n <deviceType>Paulus</deviceType>\n <manufacturer>Paulus</manufacturer>\n </device>... | [
108,
0
] | [
141,
35
] | python | en | ['en', 'en', 'en'] | True |
test_scan_description_fetch_fail | (hass, aioclient_mock, exc) | Test failing to fetch description. | Test failing to fetch description. | async def test_scan_description_fetch_fail(hass, aioclient_mock, exc):
"""Test failing to fetch description."""
aioclient_mock.get("http://1.1.1.1", exc=exc)
scanner = ssdp.Scanner(hass, {})
with patch(
"netdisco.ssdp.scan",
return_value=[Mock(st="mock-st", location="http://1.1.1.1", va... | [
"async",
"def",
"test_scan_description_fetch_fail",
"(",
"hass",
",",
"aioclient_mock",
",",
"exc",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://1.1.1.1\"",
",",
"exc",
"=",
"exc",
")",
"scanner",
"=",
"ssdp",
".",
"Scanner",
"(",
"hass",
",",
"{",... | [
145,
0
] | [
154,
38
] | python | en | ['en', 'fr', 'en'] | True |
test_scan_description_parse_fail | (hass, aioclient_mock) | Test invalid XML. | Test invalid XML. | async def test_scan_description_parse_fail(hass, aioclient_mock):
"""Test invalid XML."""
aioclient_mock.get(
"http://1.1.1.1",
text="""
<root>INVALIDXML
""",
)
scanner = ssdp.Scanner(hass, {})
with patch(
"netdisco.ssdp.scan",
return_value=[Mock(st="mock-st", lo... | [
"async",
"def",
"test_scan_description_parse_fail",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://1.1.1.1\"",
",",
"text",
"=",
"\"\"\"\n<root>INVALIDXML\n \"\"\"",
",",
")",
"scanner",
"=",
"ssdp",
".",
"Scanner",
"("... | [
157,
0
] | [
171,
38
] | python | en | ['en', 'et', 'en'] | True |
OnnxExportTestCase.test_infer_dynamic_axis_pytorch | (self) |
Validate the dynamic axis generated for each parameters are correct
|
Validate the dynamic axis generated for each parameters are correct
| def test_infer_dynamic_axis_pytorch(self):
"""
Validate the dynamic axis generated for each parameters are correct
"""
from transformers import BertModel
model = BertModel(BertConfig.from_pretrained("lysandre/tiny-bert-random"))
tokenizer = BertTokenizerFast.from_pretrai... | [
"def",
"test_infer_dynamic_axis_pytorch",
"(",
"self",
")",
":",
"from",
"transformers",
"import",
"BertModel",
"model",
"=",
"BertModel",
"(",
"BertConfig",
".",
"from_pretrained",
"(",
"\"lysandre/tiny-bert-random\"",
")",
")",
"tokenizer",
"=",
"BertTokenizerFast",
... | [
116,
4
] | [
124,
61
] | python | en | ['en', 'error', 'th'] | False |
OnnxExportTestCase.test_infer_dynamic_axis_tf | (self) |
Validate the dynamic axis generated for each parameters are correct
|
Validate the dynamic axis generated for each parameters are correct
| def test_infer_dynamic_axis_tf(self):
"""
Validate the dynamic axis generated for each parameters are correct
"""
from transformers import TFBertModel
model = TFBertModel(BertConfig.from_pretrained("lysandre/tiny-bert-random"))
tokenizer = BertTokenizerFast.from_pretrain... | [
"def",
"test_infer_dynamic_axis_tf",
"(",
"self",
")",
":",
"from",
"transformers",
"import",
"TFBertModel",
"model",
"=",
"TFBertModel",
"(",
"BertConfig",
".",
"from_pretrained",
"(",
"\"lysandre/tiny-bert-random\"",
")",
")",
"tokenizer",
"=",
"BertTokenizerFast",
... | [
129,
4
] | [
137,
61
] | python | en | ['en', 'error', 'th'] | False |
OnnxExportTestCase.test_ensure_valid_input | (self) |
Validate parameters are correctly exported
GPT2 has "past" parameter in the middle of input_ids, token_type_ids and attention_mask.
ONNX doesn't support export with a dictionary, only a tuple. Thus we need to ensure we remove
token_type_ids and attention_mask for now to not having a Non... |
Validate parameters are correctly exported
GPT2 has "past" parameter in the middle of input_ids, token_type_ids and attention_mask.
ONNX doesn't support export with a dictionary, only a tuple. Thus we need to ensure we remove
token_type_ids and attention_mask for now to not having a Non... | def test_ensure_valid_input(self):
"""
Validate parameters are correctly exported
GPT2 has "past" parameter in the middle of input_ids, token_type_ids and attention_mask.
ONNX doesn't support export with a dictionary, only a tuple. Thus we need to ensure we remove
token_type_ids ... | [
"def",
"test_ensure_valid_input",
"(",
"self",
")",
":",
"# All generated args are valid",
"input_names",
"=",
"[",
"\"input_ids\"",
",",
"\"attention_mask\"",
",",
"\"token_type_ids\"",
"]",
"tokens",
"=",
"{",
"\"input_ids\"",
":",
"[",
"1",
",",
"2",
",",
"3",
... | [
159,
4
] | [
190,
61
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Initialize light.group platform. | Initialize light.group platform. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Initialize light.group platform."""
async_add_entities(
[LightGroup(cast(str, config.get(CONF_NAME)), config[CONF_ENTITIES])]
) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
"->",
"None",
":",
"async_add_entities",
"(",
"[",
"LightGroup",
"(",
"cast",
"("... | [
68,
0
] | [
74,
5
] | python | en | ['en', 'cs', 'en'] | True |
_find_state_attributes | (states: List[State], key: str) | Find attributes with matching key from states. | Find attributes with matching key from states. | def _find_state_attributes(states: List[State], key: str) -> Iterator[Any]:
"""Find attributes with matching key from states."""
for state in states:
value = state.attributes.get(key)
if value is not None:
yield value | [
"def",
"_find_state_attributes",
"(",
"states",
":",
"List",
"[",
"State",
"]",
",",
"key",
":",
"str",
")",
"->",
"Iterator",
"[",
"Any",
"]",
":",
"for",
"state",
"in",
"states",
":",
"value",
"=",
"state",
".",
"attributes",
".",
"get",
"(",
"key"... | [
334,
0
] | [
339,
23
] | python | en | ['en', 'en', 'en'] | True |
_mean_int | (*args) | Return the mean of the supplied values. | Return the mean of the supplied values. | def _mean_int(*args):
"""Return the mean of the supplied values."""
return int(sum(args) / len(args)) | [
"def",
"_mean_int",
"(",
"*",
"args",
")",
":",
"return",
"int",
"(",
"sum",
"(",
"args",
")",
"/",
"len",
"(",
"args",
")",
")"
] | [
342,
0
] | [
344,
37
] | python | en | ['en', 'en', 'en'] | True |
_mean_tuple | (*args) | Return the mean values along the columns of the supplied values. | Return the mean values along the columns of the supplied values. | def _mean_tuple(*args):
"""Return the mean values along the columns of the supplied values."""
return tuple(sum(x) / len(x) for x in zip(*args)) | [
"def",
"_mean_tuple",
"(",
"*",
"args",
")",
":",
"return",
"tuple",
"(",
"sum",
"(",
"x",
")",
"/",
"len",
"(",
"x",
")",
"for",
"x",
"in",
"zip",
"(",
"*",
"args",
")",
")"
] | [
347,
0
] | [
349,
53
] | python | en | ['en', 'en', 'en'] | True |
_reduce_attribute | (
states: List[State],
key: str,
default: Optional[Any] = None,
reduce: Callable[..., Any] = _mean_int,
) | Find the first attribute matching key from states.
If none are found, return default.
| Find the first attribute matching key from states. | def _reduce_attribute(
states: List[State],
key: str,
default: Optional[Any] = None,
reduce: Callable[..., Any] = _mean_int,
) -> Any:
"""Find the first attribute matching key from states.
If none are found, return default.
"""
attrs = list(_find_state_attributes(states, key))
if n... | [
"def",
"_reduce_attribute",
"(",
"states",
":",
"List",
"[",
"State",
"]",
",",
"key",
":",
"str",
",",
"default",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"reduce",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
"=",
"_mean_int",
",",
")... | [
352,
0
] | [
370,
25
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.__init__ | (self, name: str, entity_ids: List[str]) | Initialize a light group. | Initialize a light group. | def __init__(self, name: str, entity_ids: List[str]) -> None:
"""Initialize a light group."""
self._name = name
self._entity_ids = entity_ids
self._is_on = False
self._available = False
self._icon = "mdi:lightbulb-group"
self._brightness: Optional[int] = None
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
":",
"str",
",",
"entity_ids",
":",
"List",
"[",
"str",
"]",
")",
"->",
"None",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_entity_ids",
"=",
"entity_ids",
"self",
".",
"_is_on",
"=",
"False",
... | [
80,
4
] | [
95,
41
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self) -> None:
"""Register callbacks."""
async def async_state_changed_listener(event):
"""Handle child updates."""
self.async_set_context(event.context)
await self.async_defer_or_update_ha_state()
assert self.hass
self.... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"async",
"def",
"async_state_changed_listener",
"(",
"event",
")",
":",
"\"\"\"Handle child updates.\"\"\"",
"self",
".",
"async_set_context",
"(",
"event",
".",
"context",
")",
"await",
"... | [
97,
4
] | [
116,
43
] | python | en | ['en', 'no', 'en'] | False |
LightGroup.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
119,
4
] | [
121,
25
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.is_on | (self) | Return the on/off state of the light group. | Return the on/off state of the light group. | def is_on(self) -> bool:
"""Return the on/off state of the light group."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_is_on"
] | [
124,
4
] | [
126,
26
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.available | (self) | Return whether the light group is available. | Return whether the light group is available. | def available(self) -> bool:
"""Return whether the light group is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
129,
4
] | [
131,
30
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.icon | (self) | Return the light group icon. | Return the light group icon. | def icon(self):
"""Return the light group icon."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
134,
4
] | [
136,
25
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.brightness | (self) | Return the brightness of this light group between 0..255. | Return the brightness of this light group between 0..255. | def brightness(self) -> Optional[int]:
"""Return the brightness of this light group between 0..255."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_brightness"
] | [
139,
4
] | [
141,
31
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.hs_color | (self) | Return the HS color value [float, float]. | Return the HS color value [float, float]. | def hs_color(self) -> Optional[Tuple[float, float]]:
"""Return the HS color value [float, float]."""
return self._hs_color | [
"def",
"hs_color",
"(",
"self",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"float",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_hs_color"
] | [
144,
4
] | [
146,
29
] | python | en | ['en', 'da', 'en'] | True |
LightGroup.color_temp | (self) | Return the CT color value in mireds. | Return the CT color value in mireds. | def color_temp(self) -> Optional[int]:
"""Return the CT color value in mireds."""
return self._color_temp | [
"def",
"color_temp",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_color_temp"
] | [
149,
4
] | [
151,
31
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.min_mireds | (self) | Return the coldest color_temp that this light group supports. | Return the coldest color_temp that this light group supports. | def min_mireds(self) -> Optional[int]:
"""Return the coldest color_temp that this light group supports."""
return self._min_mireds | [
"def",
"min_mireds",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_min_mireds"
] | [
154,
4
] | [
156,
31
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.max_mireds | (self) | Return the warmest color_temp that this light group supports. | Return the warmest color_temp that this light group supports. | def max_mireds(self) -> Optional[int]:
"""Return the warmest color_temp that this light group supports."""
return self._max_mireds | [
"def",
"max_mireds",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_max_mireds"
] | [
159,
4
] | [
161,
31
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.white_value | (self) | Return the white value of this light group between 0..255. | Return the white value of this light group between 0..255. | def white_value(self) -> Optional[int]:
"""Return the white value of this light group between 0..255."""
return self._white_value | [
"def",
"white_value",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"self",
".",
"_white_value"
] | [
164,
4
] | [
166,
32
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.effect_list | (self) | Return the list of supported effects. | Return the list of supported effects. | def effect_list(self) -> Optional[List[str]]:
"""Return the list of supported effects."""
return self._effect_list | [
"def",
"effect_list",
"(",
"self",
")",
"->",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
":",
"return",
"self",
".",
"_effect_list"
] | [
169,
4
] | [
171,
32
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.effect | (self) | Return the current effect. | Return the current effect. | def effect(self) -> Optional[str]:
"""Return the current effect."""
return self._effect | [
"def",
"effect",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_effect"
] | [
174,
4
] | [
176,
27
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
return self._supported_features | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_supported_features"
] | [
179,
4
] | [
181,
39
] | python | en | ['da', 'en', 'en'] | True |
LightGroup.should_poll | (self) | No polling needed for a light group. | No polling needed for a light group. | def should_poll(self) -> bool:
"""No polling needed for a light group."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
184,
4
] | [
186,
20
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.device_state_attributes | (self) | Return the state attributes for the light group. | Return the state attributes for the light group. | def device_state_attributes(self):
"""Return the state attributes for the light group."""
return {ATTR_ENTITY_ID: self._entity_ids} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ENTITY_ID",
":",
"self",
".",
"_entity_ids",
"}"
] | [
189,
4
] | [
191,
49
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.async_turn_on | (self, **kwargs) | Forward the turn_on command to all lights in the light group. | Forward the turn_on command to all lights in the light group. | async def async_turn_on(self, **kwargs):
"""Forward the turn_on command to all lights in the light group."""
data = {ATTR_ENTITY_ID: self._entity_ids}
emulate_color_temp_entity_ids = []
if ATTR_BRIGHTNESS in kwargs:
data[ATTR_BRIGHTNESS] = kwargs[ATTR_BRIGHTNESS]
if... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"self",
".",
"_entity_ids",
"}",
"emulate_color_temp_entity_ids",
"=",
"[",
"]",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"data",
... | [
193,
4
] | [
271,
9
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.async_turn_off | (self, **kwargs) | Forward the turn_off command to all lights in the light group. | Forward the turn_off command to all lights in the light group. | async def async_turn_off(self, **kwargs):
"""Forward the turn_off command to all lights in the light group."""
data = {ATTR_ENTITY_ID: self._entity_ids}
if ATTR_TRANSITION in kwargs:
data[ATTR_TRANSITION] = kwargs[ATTR_TRANSITION]
await self.hass.services.async_call(
... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"self",
".",
"_entity_ids",
"}",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"data",
"[",
"ATTR_TRANSITION",
"]",
"=",
"kwargs",
... | [
273,
4
] | [
286,
9
] | python | en | ['en', 'en', 'en'] | True |
LightGroup.async_update | (self) | Query all members and determine the light group state. | Query all members and determine the light group state. | async def async_update(self):
"""Query all members and determine the light group state."""
all_states = [self.hass.states.get(x) for x in self._entity_ids]
states: List[State] = list(filter(None, all_states))
on_states = [state for state in states if state.state == STATE_ON]
sel... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"all_states",
"=",
"[",
"self",
".",
"hass",
".",
"states",
".",
"get",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_entity_ids",
"]",
"states",
":",
"List",
"[",
"State",
"]",
"=",
"list",
... | [
288,
4
] | [
331,
55
] | python | en | ['en', 'en', 'en'] | True |
verify_ebusd_config | (config) | Verify eBusd config. | Verify eBusd config. | def verify_ebusd_config(config):
"""Verify eBusd config."""
circuit = config[CONF_CIRCUIT]
for condition in config[CONF_MONITORED_CONDITIONS]:
if condition not in SENSOR_TYPES[circuit]:
raise vol.Invalid(f"Condition '{condition}' not in '{circuit}'.")
return config | [
"def",
"verify_ebusd_config",
"(",
"config",
")",
":",
"circuit",
"=",
"config",
"[",
"CONF_CIRCUIT",
"]",
"for",
"condition",
"in",
"config",
"[",
"CONF_MONITORED_CONDITIONS",
"]",
":",
"if",
"condition",
"not",
"in",
"SENSOR_TYPES",
"[",
"circuit",
"]",
":",... | [
27,
0
] | [
33,
17
] | python | en | ['en', 'pt', 'it'] | False |
setup | (hass, config) | Set up the eBusd component. | Set up the eBusd component. | def setup(hass, config):
"""Set up the eBusd component."""
_LOGGER.debug("Integration setup started")
conf = config[DOMAIN]
name = conf[CONF_NAME]
circuit = conf[CONF_CIRCUIT]
monitored_conditions = conf.get(CONF_MONITORED_CONDITIONS)
server_address = (conf.get(CONF_HOST), conf.get(CONF_PORT... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Integration setup started\"",
")",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"name",
"=",
"conf",
"[",
"CONF_NAME",
"]",
"circuit",
"=",
"conf",
"[",
"CONF_CIRCUIT",
... | [
55,
0
] | [
81,
20
] | python | en | ['en', 'en', 'en'] | True |
EbusdData.__init__ | (self, address, circuit) | Initialize the data object. | Initialize the data object. | def __init__(self, address, circuit):
"""Initialize the data object."""
self._circuit = circuit
self._address = address
self.value = {} | [
"def",
"__init__",
"(",
"self",
",",
"address",
",",
"circuit",
")",
":",
"self",
".",
"_circuit",
"=",
"circuit",
"self",
".",
"_address",
"=",
"address",
"self",
".",
"value",
"=",
"{",
"}"
] | [
87,
4
] | [
91,
23
] | python | en | ['en', 'en', 'en'] | True |
EbusdData.update | (self, name, stype) | Call the Ebusd API to update the data. | Call the Ebusd API to update the data. | def update(self, name, stype):
"""Call the Ebusd API to update the data."""
try:
_LOGGER.debug("Opening socket to ebusd %s", name)
command_result = ebusdpy.read(
self._address, self._circuit, name, stype, CACHE_TTL
)
if command_result is no... | [
"def",
"update",
"(",
"self",
",",
"name",
",",
"stype",
")",
":",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Opening socket to ebusd %s\"",
",",
"name",
")",
"command_result",
"=",
"ebusdpy",
".",
"read",
"(",
"self",
".",
"_address",
",",
"self",
"."... | [
93,
4
] | [
107,
44
] | python | en | ['en', 'mi', 'en'] | True |
EbusdData.write | (self, call) | Call write methon on ebusd. | Call write methon on ebusd. | def write(self, call):
"""Call write methon on ebusd."""
name = call.data.get("name")
value = call.data.get("value")
try:
_LOGGER.debug("Opening socket to ebusd %s", name)
command_result = ebusdpy.write(self._address, self._circuit, name, value)
if co... | [
"def",
"write",
"(",
"self",
",",
"call",
")",
":",
"name",
"=",
"call",
".",
"data",
".",
"get",
"(",
"\"name\"",
")",
"value",
"=",
"call",
".",
"data",
".",
"get",
"(",
"\"value\"",
")",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Opening socke... | [
109,
4
] | [
121,
30
] | python | en | ['en', 'mi', 'nl'] | False |
test_setup_component | (hass) | Simple test setup of component. | Simple test setup of component. | async def test_setup_component(hass):
"""Simple test setup of component."""
result = await async_setup_component(hass, geo_location.DOMAIN, {})
assert result | [
"async",
"def",
"test_setup_component",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"geo_location",
".",
"DOMAIN",
",",
"{",
"}",
")",
"assert",
"result"
] | [
8,
0
] | [
11,
17
] | python | en | ['en', 'en', 'en'] | True |
test_event | (hass) | Simple test of the geolocation event class. | Simple test of the geolocation event class. | async def test_event(hass):
"""Simple test of the geolocation event class."""
entity = GeolocationEvent()
assert entity.state is None
assert entity.distance is None
assert entity.latitude is None
assert entity.longitude is None
with pytest.raises(NotImplementedError):
assert entity.... | [
"async",
"def",
"test_event",
"(",
"hass",
")",
":",
"entity",
"=",
"GeolocationEvent",
"(",
")",
"assert",
"entity",
".",
"state",
"is",
"None",
"assert",
"entity",
".",
"distance",
"is",
"None",
"assert",
"entity",
".",
"latitude",
"is",
"None",
"assert"... | [
14,
0
] | [
23,
36
] | python | en | ['en', 'en', 'en'] | True |
uniqify_urls | (soup, attr, slug) |
Change url(#some-id) references by prefixing the slug to the unique ID.
|
Change url(#some-id) references by prefixing the slug to the unique ID.
| def uniqify_urls(soup, attr, slug):
"""
Change url(#some-id) references by prefixing the slug to the unique ID.
"""
els = soup.find_all(attrs={attr: True})
for el in els:
if "url(#" in el[attr]:
el[attr] = el[attr].replace("url(#", "url(#"+slug) | [
"def",
"uniqify_urls",
"(",
"soup",
",",
"attr",
",",
"slug",
")",
":",
"els",
"=",
"soup",
".",
"find_all",
"(",
"attrs",
"=",
"{",
"attr",
":",
"True",
"}",
")",
"for",
"el",
"in",
"els",
":",
"if",
"\"url(#\"",
"in",
"el",
"[",
"attr",
"]",
... | [
12,
0
] | [
19,
62
] | python | en | ['en', 'error', 'th'] | False |
mock_healthybox | () | Mock fb.check_box_health. | Mock fb.check_box_health. | def mock_healthybox():
"""Mock fb.check_box_health."""
check_box_health = (
"homeassistant.components.facebox.image_processing.check_box_health"
)
with patch(check_box_health, return_value=MOCK_BOX_ID) as _mock_healthybox:
yield _mock_healthybox | [
"def",
"mock_healthybox",
"(",
")",
":",
"check_box_health",
"=",
"(",
"\"homeassistant.components.facebox.image_processing.check_box_health\"",
")",
"with",
"patch",
"(",
"check_box_health",
",",
"return_value",
"=",
"MOCK_BOX_ID",
")",
"as",
"_mock_healthybox",
":",
"yi... | [
80,
0
] | [
86,
30
] | python | en | ['en', 'fil', 'en'] | False |
mock_isfile | () | Mock os.path.isfile. | Mock os.path.isfile. | def mock_isfile():
"""Mock os.path.isfile."""
with patch(
"homeassistant.components.facebox.image_processing.cv.isfile", return_value=True
) as _mock_isfile:
yield _mock_isfile | [
"def",
"mock_isfile",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.facebox.image_processing.cv.isfile\"",
",",
"return_value",
"=",
"True",
")",
"as",
"_mock_isfile",
":",
"yield",
"_mock_isfile"
] | [
90,
0
] | [
95,
26
] | python | en | ['en', 'sm', 'en'] | False |
mock_image | () | Return a mock camera image. | Return a mock camera image. | def mock_image():
"""Return a mock camera image."""
with patch(
"homeassistant.components.demo.camera.DemoCamera.camera_image",
return_value=b"Test",
) as image:
yield image | [
"def",
"mock_image",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.demo.camera.DemoCamera.camera_image\"",
",",
"return_value",
"=",
"b\"Test\"",
",",
")",
"as",
"image",
":",
"yield",
"image"
] | [
99,
0
] | [
105,
19
] | python | da | ['es', 'da', 'en'] | False |
test_check_box_health | (caplog) | Test check box health. | Test check box health. | def test_check_box_health(caplog):
"""Test check box health."""
with requests_mock.Mocker() as mock_req:
url = f"http://{MOCK_IP}:{MOCK_PORT}/healthz"
mock_req.get(url, status_code=HTTP_OK, json=MOCK_HEALTH)
assert fb.check_box_health(url, "user", "pass") == MOCK_BOX_ID
mock_req... | [
"def",
"test_check_box_health",
"(",
"caplog",
")",
":",
"with",
"requests_mock",
".",
"Mocker",
"(",
")",
"as",
"mock_req",
":",
"url",
"=",
"f\"http://{MOCK_IP}:{MOCK_PORT}/healthz\"",
"mock_req",
".",
"get",
"(",
"url",
",",
"status_code",
"=",
"HTTP_OK",
","... | [
118,
0
] | [
131,
68
] | python | en | ['it', 'gd', 'en'] | False |
test_encode_image | () | Test that binary data is encoded correctly. | Test that binary data is encoded correctly. | def test_encode_image():
"""Test that binary data is encoded correctly."""
assert fb.encode_image(b"test") == "dGVzdA==" | [
"def",
"test_encode_image",
"(",
")",
":",
"assert",
"fb",
".",
"encode_image",
"(",
"b\"test\"",
")",
"==",
"\"dGVzdA==\""
] | [
134,
0
] | [
136,
49
] | python | en | ['en', 'en', 'en'] | True |
test_get_matched_faces | () | Test that matched_faces are parsed correctly. | Test that matched_faces are parsed correctly. | def test_get_matched_faces():
"""Test that matched_faces are parsed correctly."""
assert fb.get_matched_faces(PARSED_FACES) == MATCHED_FACES | [
"def",
"test_get_matched_faces",
"(",
")",
":",
"assert",
"fb",
".",
"get_matched_faces",
"(",
"PARSED_FACES",
")",
"==",
"MATCHED_FACES"
] | [
139,
0
] | [
141,
62
] | python | en | ['en', 'en', 'en'] | True |
test_parse_faces | () | Test parsing of raw face data, and generation of matched_faces. | Test parsing of raw face data, and generation of matched_faces. | def test_parse_faces():
"""Test parsing of raw face data, and generation of matched_faces."""
assert fb.parse_faces(MOCK_JSON["faces"]) == PARSED_FACES | [
"def",
"test_parse_faces",
"(",
")",
":",
"assert",
"fb",
".",
"parse_faces",
"(",
"MOCK_JSON",
"[",
"\"faces\"",
"]",
")",
"==",
"PARSED_FACES"
] | [
144,
0
] | [
146,
61
] | python | en | ['en', 'en', 'en'] | True |
test_valid_file_path | () | Test that an invalid file_path is caught. | Test that an invalid file_path is caught. | def test_valid_file_path():
"""Test that an invalid file_path is caught."""
assert not fb.valid_file_path("test_path") | [
"def",
"test_valid_file_path",
"(",
")",
":",
"assert",
"not",
"fb",
".",
"valid_file_path",
"(",
"\"test_path\"",
")"
] | [
150,
0
] | [
152,
46
] | python | en | ['en', 'en', 'en'] | True |
test_setup_platform | (hass, mock_healthybox) | Set up platform with one entity. | Set up platform with one entity. | async def test_setup_platform(hass, mock_healthybox):
"""Set up platform with one entity."""
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
await hass.async_block_till_done()
assert hass.states.get(VALID_ENTITY_ID) | [
"async",
"def",
"test_setup_platform",
"(",
"hass",
",",
"mock_healthybox",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"ip",
".",
"DOMAIN",
",",
"VALID_CONFIG",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"hass",
... | [
155,
0
] | [
159,
43
] | python | en | ['en', 'en', 'en'] | True |
test_setup_platform_with_auth | (hass, mock_healthybox) | Set up platform with one entity and auth. | Set up platform with one entity and auth. | async def test_setup_platform_with_auth(hass, mock_healthybox):
"""Set up platform with one entity and auth."""
valid_config_auth = VALID_CONFIG.copy()
valid_config_auth[ip.DOMAIN][CONF_USERNAME] = MOCK_USERNAME
valid_config_auth[ip.DOMAIN][CONF_PASSWORD] = MOCK_PASSWORD
await async_setup_component... | [
"async",
"def",
"test_setup_platform_with_auth",
"(",
"hass",
",",
"mock_healthybox",
")",
":",
"valid_config_auth",
"=",
"VALID_CONFIG",
".",
"copy",
"(",
")",
"valid_config_auth",
"[",
"ip",
".",
"DOMAIN",
"]",
"[",
"CONF_USERNAME",
"]",
"=",
"MOCK_USERNAME",
... | [
162,
0
] | [
170,
43
] | python | en | ['en', 'en', 'en'] | True |
test_process_image | (hass, mock_healthybox, mock_image) | Test successful processing of an image. | Test successful processing of an image. | async def test_process_image(hass, mock_healthybox, mock_image):
"""Test successful processing of an image."""
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
await hass.async_block_till_done()
assert hass.states.get(VALID_ENTITY_ID)
face_events = []
@callback
def mock_face_even... | [
"async",
"def",
"test_process_image",
"(",
"hass",
",",
"mock_healthybox",
",",
"mock_image",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"ip",
".",
"DOMAIN",
",",
"VALID_CONFIG",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
... | [
173,
0
] | [
214,
5
] | python | en | ['en', 'en', 'en'] | True |
test_process_image_errors | (hass, mock_healthybox, mock_image, caplog) | Test process_image errors. | Test process_image errors. | async def test_process_image_errors(hass, mock_healthybox, mock_image, caplog):
"""Test process_image errors."""
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
await hass.async_block_till_done()
assert hass.states.get(VALID_ENTITY_ID)
# Test connection error.
with requests_mock.Mock... | [
"async",
"def",
"test_process_image_errors",
"(",
"hass",
",",
"mock_healthybox",
",",
"mock_image",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"ip",
".",
"DOMAIN",
",",
"VALID_CONFIG",
")",
"await",
"hass",
".",
"async_block_ti... | [
217,
0
] | [
244,
62
] | python | da | ['da', 'zh', 'en'] | False |
test_teach_service | (
hass, mock_healthybox, mock_image, mock_isfile, mock_open_file, caplog
) | Test teaching of facebox. | Test teaching of facebox. | async def test_teach_service(
hass, mock_healthybox, mock_image, mock_isfile, mock_open_file, caplog
):
"""Test teaching of facebox."""
await async_setup_component(hass, ip.DOMAIN, VALID_CONFIG)
await hass.async_block_till_done()
assert hass.states.get(VALID_ENTITY_ID)
# Patch out 'is_allowed_p... | [
"async",
"def",
"test_teach_service",
"(",
"hass",
",",
"mock_healthybox",
",",
"mock_image",
",",
"mock_isfile",
",",
"mock_open_file",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"ip",
".",
"DOMAIN",
",",
"VALID_CONFIG",
")",
... | [
247,
0
] | [
315,
68
] | python | en | ['en', 'jv', 'en'] | True |
test_setup_platform_with_name | (hass, mock_healthybox) | Set up platform with one entity and a name. | Set up platform with one entity and a name. | async def test_setup_platform_with_name(hass, mock_healthybox):
"""Set up platform with one entity and a name."""
named_entity_id = f"image_processing.{MOCK_NAME}"
valid_config_named = VALID_CONFIG.copy()
valid_config_named[ip.DOMAIN][ip.CONF_SOURCE][ip.CONF_NAME] = MOCK_NAME
await async_setup_com... | [
"async",
"def",
"test_setup_platform_with_name",
"(",
"hass",
",",
"mock_healthybox",
")",
":",
"named_entity_id",
"=",
"f\"image_processing.{MOCK_NAME}\"",
"valid_config_named",
"=",
"VALID_CONFIG",
".",
"copy",
"(",
")",
"valid_config_named",
"[",
"ip",
".",
"DOMAIN",... | [
318,
0
] | [
329,
64
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Yeelight Sunflower Light platform. | Set up the Yeelight Sunflower Light platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Yeelight Sunflower Light platform."""
host = config.get(CONF_HOST)
hub = yeelightsunflower.Hub(host)
if not hub.available:
_LOGGER.error("Could not connect to Yeelight Sunflower hub")
return False
ad... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"hub",
"=",
"yeelightsunflower",
".",
"Hub",
"(",
"host",
")",
"if",
"not",
... | [
25,
0
] | [
34,
68
] | python | en | ['en', 'ky', 'en'] | True |
SunflowerBulb.__init__ | (self, light) | Initialize a Yeelight Sunflower bulb. | Initialize a Yeelight Sunflower bulb. | def __init__(self, light):
"""Initialize a Yeelight Sunflower bulb."""
self._light = light
self._available = light.available
self._brightness = light.brightness
self._is_on = light.is_on
self._rgb_color = light.rgb_color
self._unique_id = light.zid | [
"def",
"__init__",
"(",
"self",
",",
"light",
")",
":",
"self",
".",
"_light",
"=",
"light",
"self",
".",
"_available",
"=",
"light",
".",
"available",
"self",
".",
"_brightness",
"=",
"light",
".",
"brightness",
"self",
".",
"_is_on",
"=",
"light",
".... | [
40,
4
] | [
47,
35
] | python | en | ['en', 'lb', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.