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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WordpieceTokenizer.tokenize | (self, text) |
Tokenizes a piece of text into its word pieces. This uses a greedy longest-match-first algorithm to perform
tokenization using the given vocabulary.
For example, :obj:`input = "unaffable"` wil return as output :obj:`["un", "##aff", "##able"]`.
Args:
text: A single token or w... |
Tokenizes a piece of text into its word pieces. This uses a greedy longest-match-first algorithm to perform
tokenization using the given vocabulary. | def tokenize(self, text):
"""
Tokenizes a piece of text into its word pieces. This uses a greedy longest-match-first algorithm to perform
tokenization using the given vocabulary.
For example, :obj:`input = "unaffable"` wil return as output :obj:`["un", "##aff", "##able"]`.
Args... | [
"def",
"tokenize",
"(",
"self",
",",
"text",
")",
":",
"output_tokens",
"=",
"[",
"]",
"for",
"token",
"in",
"whitespace_tokenize",
"(",
"text",
")",
":",
"chars",
"=",
"list",
"(",
"token",
")",
"if",
"len",
"(",
"chars",
")",
">",
"self",
".",
"m... | [
511,
4
] | [
557,
28
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass, config) | Set up the Ambient PWS component. | Set up the Ambient PWS component. | async def async_setup(hass, config):
"""Set up the Ambient PWS component."""
hass.data[DOMAIN] = {}
hass.data[DOMAIN][DATA_CLIENT] = {}
if DOMAIN not in config:
return True
conf = config[DOMAIN]
# Store config for use during entry setup:
hass.data[DOMAIN][DATA_CONFIG] = conf
... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CLIENT",
"]",
"=",
"{",
"}",
"if",
"DOMAIN",
"not",
"in",
"config",
"... | [
263,
0
] | [
284,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up the Ambient PWS as config entry. | Set up the Ambient PWS as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up the Ambient PWS as config entry."""
if not config_entry.unique_id:
hass.config_entries.async_update_entry(
config_entry, unique_id=config_entry.data[CONF_APP_KEY]
)
session = aiohttp_client.async_get_clientsession(hass)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"if",
"not",
"config_entry",
".",
"unique_id",
":",
"hass",
".",
"config_entries",
".",
"async_update_entry",
"(",
"config_entry",
",",
"unique_id",
"=",
"config_entry",
".",
"data"... | [
287,
0
] | [
317,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload an Ambient PWS config entry. | Unload an Ambient PWS config entry. | async def async_unload_entry(hass, config_entry):
"""Unload an Ambient PWS config entry."""
ambient = hass.data[DOMAIN][DATA_CLIENT].pop(config_entry.entry_id)
hass.async_create_task(ambient.ws_disconnect())
tasks = [
hass.config_entries.async_forward_entry_unload(config_entry, component)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"ambient",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CLIENT",
"]",
".",
"pop",
"(",
"config_entry",
".",
"entry_id",
")",
"hass",
".",
"async_create_task",
"("... | [
320,
0
] | [
332,
15
] | python | en | ['en', 'en', 'en'] | True |
async_migrate_entry | (hass, config_entry) | Migrate old entry. | Migrate old entry. | async def async_migrate_entry(hass, config_entry):
"""Migrate old entry."""
version = config_entry.version
_LOGGER.debug("Migrating from version %s", version)
# 1 -> 2: Unique ID format changed, so delete and re-import:
if version == 1:
dev_reg = await hass.helpers.device_registry.async_ge... | [
"async",
"def",
"async_migrate_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"version",
"=",
"config_entry",
".",
"version",
"_LOGGER",
".",
"debug",
"(",
"\"Migrating from version %s\"",
",",
"version",
")",
"# 1 -> 2: Unique ID format changed, so delete and re-imp... | [
335,
0
] | [
354,
15
] | python | en | ['en', 'en', 'en'] | True |
AmbientStation.__init__ | (self, hass, config_entry, client) | Initialize. | Initialize. | def __init__(self, hass, config_entry, client):
"""Initialize."""
self._config_entry = config_entry
self._entry_setup_complete = False
self._hass = hass
self._ws_reconnect_delay = DEFAULT_SOCKET_MIN_RETRY
self.client = client
self.stations = {} | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
",",
"client",
")",
":",
"self",
".",
"_config_entry",
"=",
"config_entry",
"self",
".",
"_entry_setup_complete",
"=",
"False",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_ws_reconnect_d... | [
360,
4
] | [
367,
26
] | python | en | ['en', 'en', 'it'] | False |
AmbientStation._attempt_connect | (self) | Attempt to connect to the socket (retrying later on fail). | Attempt to connect to the socket (retrying later on fail). | async def _attempt_connect(self):
"""Attempt to connect to the socket (retrying later on fail)."""
async def connect(timestamp=None):
"""Connect."""
await self.client.websocket.connect()
try:
await connect()
except WebsocketError as err:
... | [
"async",
"def",
"_attempt_connect",
"(",
"self",
")",
":",
"async",
"def",
"connect",
"(",
"timestamp",
"=",
"None",
")",
":",
"\"\"\"Connect.\"\"\"",
"await",
"self",
".",
"client",
".",
"websocket",
".",
"connect",
"(",
")",
"try",
":",
"await",
"connect... | [
369,
4
] | [
381,
75
] | python | en | ['en', 'en', 'en'] | True |
AmbientStation.ws_connect | (self) | Register handlers and connect to the websocket. | Register handlers and connect to the websocket. | async def ws_connect(self):
"""Register handlers and connect to the websocket."""
def on_connect():
"""Define a handler to fire when the websocket is connected."""
_LOGGER.info("Connected to websocket")
def on_data(data):
"""Define a handler to fire when the... | [
"async",
"def",
"ws_connect",
"(",
"self",
")",
":",
"def",
"on_connect",
"(",
")",
":",
"\"\"\"Define a handler to fire when the websocket is connected.\"\"\"",
"_LOGGER",
".",
"info",
"(",
"\"Connected to websocket\"",
")",
"def",
"on_data",
"(",
"data",
")",
":",
... | [
383,
4
] | [
450,
37
] | python | en | ['en', 'en', 'en'] | True |
AmbientStation.ws_disconnect | (self) | Disconnect from the websocket. | Disconnect from the websocket. | async def ws_disconnect(self):
"""Disconnect from the websocket."""
await self.client.websocket.disconnect() | [
"async",
"def",
"ws_disconnect",
"(",
"self",
")",
":",
"await",
"self",
".",
"client",
".",
"websocket",
".",
"disconnect",
"(",
")"
] | [
452,
4
] | [
454,
48
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherEntity.__init__ | (
self, ambient, mac_address, station_name, sensor_type, sensor_name, device_class
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self, ambient, mac_address, station_name, sensor_type, sensor_name, device_class
):
"""Initialize the sensor."""
self._ambient = ambient
self._device_class = device_class
self._mac_address = mac_address
self._sensor_name = sensor_name
self._senso... | [
"def",
"__init__",
"(",
"self",
",",
"ambient",
",",
"mac_address",
",",
"station_name",
",",
"sensor_type",
",",
"sensor_name",
",",
"device_class",
")",
":",
"self",
".",
"_ambient",
"=",
"ambient",
"self",
".",
"_device_class",
"=",
"device_class",
"self",
... | [
460,
4
] | [
470,
41
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherEntity.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
# Since the solarradiation_lx sensor is created only if the
# user shows a solarradiation sensor, ensure that the
# solarradiation_lx sensor shows as available if the solarradiation
# sensor is available:
if s... | [
"def",
"available",
"(",
"self",
")",
":",
"# Since the solarradiation_lx sensor is created only if the",
"# user shows a solarradiation sensor, ensure that the",
"# solarradiation_lx sensor shows as available if the solarradiation",
"# sensor is available:",
"if",
"self",
".",
"_sensor_ty... | [
473,
4
] | [
491,
9
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherEntity.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
494,
4
] | [
496,
33
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherEntity.device_info | (self) | Return device registry information for this entity. | Return device registry information for this entity. | def device_info(self):
"""Return device registry information for this entity."""
return {
"identifiers": {(DOMAIN, self._mac_address)},
"name": self._station_name,
"manufacturer": "Ambient Weather",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_mac_address",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_station_name",
",",
"\"manufacturer\"",
":",
"\"Ambient Weather\"",
",",
... | [
499,
4
] | [
505,
9
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherEntity.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self._station_name}_{self._sensor_name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._station_name}_{self._sensor_name}\""
] | [
508,
4
] | [
510,
58
] | python | en | ['en', 'mi', 'en'] | True |
AmbientWeatherEntity.should_poll | (self) | Disable polling. | Disable polling. | def should_poll(self):
"""Disable polling."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
513,
4
] | [
515,
20
] | python | en | ['fr', 'en', 'en'] | False |
AmbientWeatherEntity.unique_id | (self) | Return a unique, unchanging string that represents this sensor. | Return a unique, unchanging string that represents this sensor. | def unique_id(self):
"""Return a unique, unchanging string that represents this sensor."""
return f"{self._mac_address}_{self._sensor_type}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._mac_address}_{self._sensor_type}\""
] | [
518,
4
] | [
520,
57
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
@callback
def update():
"""Update the state."""
self.update_from_latest_data()
self.async_write_ha_state()
self.async_on_remove(
async_dispatcher_connect(
self... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"update",
"(",
")",
":",
"\"\"\"Update the state.\"\"\"",
"self",
".",
"update_from_latest_data",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")",
"self",
".",
"async_o... | [
522,
4
] | [
537,
38
] | python | en | ['en', 'no', 'en'] | False |
AmbientWeatherEntity.update_from_latest_data | (self) | Update the entity from the latest data. | Update the entity from the latest data. | def update_from_latest_data(self):
"""Update the entity from the latest data."""
raise NotImplementedError | [
"def",
"update_from_latest_data",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
540,
4
] | [
542,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Tesla binary_sensors by config_entry. | Set up the Tesla binary_sensors by config_entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Tesla binary_sensors by config_entry."""
coordinator = hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"]
entities = []
for device in hass.data[TESLA_DOMAIN][config_entry.entry_id]["devices"]["switch"]:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"TESLA_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"\"coordinator\"",
"]",
"entities",
"... | [
10,
0
] | [
22,
38
] | python | en | ['en', 'en', 'en'] | True |
ChargerSwitch.async_turn_on | (self, **kwargs) | Send the on command. | Send the on command. | async def async_turn_on(self, **kwargs):
"""Send the on command."""
_LOGGER.debug("Enable charging: %s", self.name)
await self.tesla_device.start_charge() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Enable charging: %s\"",
",",
"self",
".",
"name",
")",
"await",
"self",
".",
"tesla_device",
".",
"start_charge",
"(",
")"
] | [
28,
4
] | [
31,
46
] | python | en | ['en', 'en', 'en'] | True |
ChargerSwitch.async_turn_off | (self, **kwargs) | Send the off command. | Send the off command. | async def async_turn_off(self, **kwargs):
"""Send the off command."""
_LOGGER.debug("Disable charging for: %s", self.name)
await self.tesla_device.stop_charge() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Disable charging for: %s\"",
",",
"self",
".",
"name",
")",
"await",
"self",
".",
"tesla_device",
".",
"stop_charge",
"(",
")"
] | [
33,
4
] | [
36,
45
] | python | en | ['en', 'en', 'en'] | True |
ChargerSwitch.is_on | (self) | Get whether the switch is in on state. | Get whether the switch is in on state. | def is_on(self):
"""Get whether the switch is in on state."""
if self.tesla_device.is_charging() is None:
return None
return self.tesla_device.is_charging() | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"tesla_device",
".",
"is_charging",
"(",
")",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"tesla_device",
".",
"is_charging",
"(",
")"
] | [
39,
4
] | [
43,
46
] | python | en | ['en', 'en', 'en'] | True |
RangeSwitch.async_turn_on | (self, **kwargs) | Send the on command. | Send the on command. | async def async_turn_on(self, **kwargs):
"""Send the on command."""
_LOGGER.debug("Enable max range charging: %s", self.name)
await self.tesla_device.set_max() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Enable max range charging: %s\"",
",",
"self",
".",
"name",
")",
"await",
"self",
".",
"tesla_device",
".",
"set_max",
"(",
")"
] | [
49,
4
] | [
52,
41
] | python | en | ['en', 'en', 'en'] | True |
RangeSwitch.async_turn_off | (self, **kwargs) | Send the off command. | Send the off command. | async def async_turn_off(self, **kwargs):
"""Send the off command."""
_LOGGER.debug("Disable max range charging: %s", self.name)
await self.tesla_device.set_standard() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Disable max range charging: %s\"",
",",
"self",
".",
"name",
")",
"await",
"self",
".",
"tesla_device",
".",
"set_standard",
"(",
")"
] | [
54,
4
] | [
57,
46
] | python | en | ['en', 'en', 'en'] | True |
RangeSwitch.is_on | (self) | Get whether the switch is in on state. | Get whether the switch is in on state. | def is_on(self):
"""Get whether the switch is in on state."""
if self.tesla_device.is_maxrange() is None:
return None
return bool(self.tesla_device.is_maxrange()) | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"tesla_device",
".",
"is_maxrange",
"(",
")",
"is",
"None",
":",
"return",
"None",
"return",
"bool",
"(",
"self",
".",
"tesla_device",
".",
"is_maxrange",
"(",
")",
")"
] | [
60,
4
] | [
64,
52
] | python | en | ['en', 'en', 'en'] | True |
UpdateSwitch.__init__ | (self, tesla_device, coordinator) | Initialise the switch. | Initialise the switch. | def __init__(self, tesla_device, coordinator):
"""Initialise the switch."""
super().__init__(tesla_device, coordinator)
self.controller = coordinator.controller | [
"def",
"__init__",
"(",
"self",
",",
"tesla_device",
",",
"coordinator",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"tesla_device",
",",
"coordinator",
")",
"self",
".",
"controller",
"=",
"coordinator",
".",
"controller"
] | [
70,
4
] | [
73,
48
] | python | en | ['en', 'en', 'en'] | True |
UpdateSwitch.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return super().name.replace("charger", "update") | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"super",
"(",
")",
".",
"name",
".",
"replace",
"(",
"\"charger\"",
",",
"\"update\"",
")"
] | [
76,
4
] | [
78,
56
] | python | en | ['en', 'en', 'en'] | True |
UpdateSwitch.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return super().unique_id.replace("charger", "update") | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"super",
"(",
")",
".",
"unique_id",
".",
"replace",
"(",
"\"charger\"",
",",
"\"update\"",
")"
] | [
81,
4
] | [
83,
61
] | python | ca | ['fr', 'ca', 'en'] | False |
UpdateSwitch.async_turn_on | (self, **kwargs) | Send the on command. | Send the on command. | async def async_turn_on(self, **kwargs):
"""Send the on command."""
_LOGGER.debug("Enable updates: %s %s", self.name, self.tesla_device.id())
self.controller.set_updates(self.tesla_device.id(), True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Enable updates: %s %s\"",
",",
"self",
".",
"name",
",",
"self",
".",
"tesla_device",
".",
"id",
"(",
")",
")",
"self",
".",
"controller",
... | [
85,
4
] | [
88,
65
] | python | en | ['en', 'en', 'en'] | True |
UpdateSwitch.async_turn_off | (self, **kwargs) | Send the off command. | Send the off command. | async def async_turn_off(self, **kwargs):
"""Send the off command."""
_LOGGER.debug("Disable updates: %s %s", self.name, self.tesla_device.id())
self.controller.set_updates(self.tesla_device.id(), False) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Disable updates: %s %s\"",
",",
"self",
".",
"name",
",",
"self",
".",
"tesla_device",
".",
"id",
"(",
")",
")",
"self",
".",
"controller",... | [
90,
4
] | [
93,
66
] | python | en | ['en', 'en', 'en'] | True |
UpdateSwitch.is_on | (self) | Get whether the switch is in on state. | Get whether the switch is in on state. | def is_on(self):
"""Get whether the switch is in on state."""
if self.controller.get_updates(self.tesla_device.id()) is None:
return None
return bool(self.controller.get_updates(self.tesla_device.id())) | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"controller",
".",
"get_updates",
"(",
"self",
".",
"tesla_device",
".",
"id",
"(",
")",
")",
"is",
"None",
":",
"return",
"None",
"return",
"bool",
"(",
"self",
".",
"controller",
".",
"get_u... | [
96,
4
] | [
100,
72
] | python | en | ['en', 'en', 'en'] | True |
SentryModeSwitch.async_turn_on | (self, **kwargs) | Send the on command. | Send the on command. | async def async_turn_on(self, **kwargs):
"""Send the on command."""
_LOGGER.debug("Enable sentry mode: %s", self.name)
await self.tesla_device.enable_sentry_mode() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Enable sentry mode: %s\"",
",",
"self",
".",
"name",
")",
"await",
"self",
".",
"tesla_device",
".",
"enable_sentry_mode",
"(",
")"
] | [
106,
4
] | [
109,
52
] | python | en | ['en', 'en', 'en'] | True |
SentryModeSwitch.async_turn_off | (self, **kwargs) | Send the off command. | Send the off command. | async def async_turn_off(self, **kwargs):
"""Send the off command."""
_LOGGER.debug("Disable sentry mode: %s", self.name)
await self.tesla_device.disable_sentry_mode() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Disable sentry mode: %s\"",
",",
"self",
".",
"name",
")",
"await",
"self",
".",
"tesla_device",
".",
"disable_sentry_mode",
"(",
")"
] | [
111,
4
] | [
114,
53
] | python | en | ['en', 'en', 'en'] | True |
SentryModeSwitch.is_on | (self) | Get whether the switch is in on state. | Get whether the switch is in on state. | def is_on(self):
"""Get whether the switch is in on state."""
if self.tesla_device.is_on() is None:
return None
return self.tesla_device.is_on() | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"tesla_device",
".",
"is_on",
"(",
")",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"tesla_device",
".",
"is_on",
"(",
")"
] | [
117,
4
] | [
121,
40
] | python | en | ['en', '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",
")"
] | [
25,
0
] | [
27,
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",
")"
] | [
31,
0
] | [
33,
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\"",
")"
] | [
37,
0
] | [
39,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_conditions | (hass, device_reg, entity_reg) | Test we get the expected conditions from a binary_sensor. | Test we get the expected conditions from a binary_sensor. | async def test_get_conditions(hass, device_reg, entity_reg):
"""Test we get the expected conditions from a binary_sensor."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry =... | [
"async",
"def",
"test_get_conditions",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"config_entry",
"=",
"MockConfigE... | [
42,
0
] | [
76,
44
] | python | en | ['en', 'en', 'en'] | True |
test_get_condition_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a binary_sensor condition. | Test we get the expected capabilities from a binary_sensor condition. | async def test_get_condition_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a binary_sensor condition."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_i... | [
"async",
"def",
"test_get_condition_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"h... | [
79,
0
] | [
98,
52
] | python | en | ['en', 'en', 'en'] | True |
test_if_state | (hass, calls) | Test for turn_on and turn_off conditions. | Test for turn_on and turn_off conditions. | async def test_if_state(hass, calls):
"""Test for turn_on and turn_off conditions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
sensor1 = platform.... | [
"async",
"def",
"test_if_state",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",... | [
101,
0
] | [
171,
64
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_for_condition | (hass, calls) | Test for firing if condition is on with delay. | Test for firing if condition is on with delay. | async def test_if_fires_on_for_condition(hass, calls):
"""Test for firing if condition is on with delay."""
point1 = dt_util.utcnow()
point2 = point1 + timedelta(seconds=10)
point3 = point2 + timedelta(seconds=10)
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert... | [
"async",
"def",
"test_if_fires_on_for_condition",
"(",
"hass",
",",
"calls",
")",
":",
"point1",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"point2",
"=",
"point1",
"+",
"timedelta",
"(",
"seconds",
"=",
"10",
")",
"point3",
"=",
"point2",
"+",
"timedelta",
... | [
174,
0
] | [
242,
68
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up the isy994 integration from YAML. | Set up the isy994 integration from YAML. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the isy994 integration from YAML."""
isy_config: Optional[ConfigType] = config.get(DOMAIN)
hass.data.setdefault(DOMAIN, {})
if not isy_config:
return True
# Only import if we haven't before.
config_entry ... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"isy_config",
":",
"Optional",
"[",
"ConfigType",
"]",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"hass",
".",
"data",
".",
... | [
67,
0
] | [
89,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: config_entries.ConfigEntry
) | Set up the ISY 994 integration. | Set up the ISY 994 integration. | async def async_setup_entry(
hass: HomeAssistant, entry: config_entries.ConfigEntry
) -> bool:
"""Set up the ISY 994 integration."""
# As there currently is no way to import options from yaml
# when setting up a config entry, we fallback to adding
# the options to the config entry and pull them out ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"bool",
":",
"# As there currently is no way to import options from yaml",
"# when setting up a config entry, we fallback to adding",
"# t... | [
99,
0
] | [
197,
15
] | python | en | ['en', 'en', 'en'] | True |
_async_update_listener | (
hass: HomeAssistant, entry: config_entries.ConfigEntry
) | Handle options update. | Handle options update. | async def _async_update_listener(
hass: HomeAssistant, entry: config_entries.ConfigEntry
):
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id) | [
"async",
"def",
"_async_update_listener",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"entry",
".",
"entry_id",
")"
] | [
200,
0
] | [
204,
58
] | python | en | ['en', 'nl', 'en'] | True |
async_unload_entry | (
hass: HomeAssistant, entry: config_entries.ConfigEntry
) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(
hass: HomeAssistant, entry: config_entries.ConfigEntry
) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in SUPPORTED... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_e... | [
242,
0
] | [
273,
20
] | python | en | ['en', 'es', 'en'] | True |
setup | (hass, config) | Set up the Coinbase component.
Will automatically setup sensors to support
wallets discovered on the network.
| Set up the Coinbase component. | def setup(hass, config):
"""Set up the Coinbase component.
Will automatically setup sensors to support
wallets discovered on the network.
"""
api_key = config[DOMAIN][CONF_API_KEY]
api_secret = config[DOMAIN][CONF_API_SECRET]
account_currencies = config[DOMAIN].get(CONF_ACCOUNT_CURRENCIES)
... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"api_key",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_API_KEY",
"]",
"api_secret",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_API_SECRET",
"]",
"account_currencies",
"=",
"config",
"[",
"DOMAIN",
... | [
44,
0
] | [
75,
15
] | python | en | ['en', 'en', 'en'] | True |
CoinbaseData.__init__ | (self, api_key, api_secret) | Init the coinbase data object. | Init the coinbase data object. | def __init__(self, api_key, api_secret):
"""Init the coinbase data object."""
self.client = Client(api_key, api_secret)
self.update() | [
"def",
"__init__",
"(",
"self",
",",
"api_key",
",",
"api_secret",
")",
":",
"self",
".",
"client",
"=",
"Client",
"(",
"api_key",
",",
"api_secret",
")",
"self",
".",
"update",
"(",
")"
] | [
81,
4
] | [
85,
21
] | python | en | ['en', 'en', 'en'] | True |
CoinbaseData.update | (self) | Get the latest data from coinbase. | Get the latest data from coinbase. | def update(self):
"""Get the latest data from coinbase."""
try:
self.accounts = self.client.get_accounts()
self.exchange_rates = self.client.get_exchange_rates()
except AuthenticationError as coinbase_error:
_LOGGER.error(
"Authentication erro... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"accounts",
"=",
"self",
".",
"client",
".",
"get_accounts",
"(",
")",
"self",
".",
"exchange_rates",
"=",
"self",
".",
"client",
".",
"get_exchange_rates",
"(",
")",
"except",
"Authenticat... | [
88,
4
] | [
97,
13
] | python | en | ['en', 'en', 'en'] | True |
update_version_in_file | (fname, version, pattern) | Update the version in one file using a specific pattern. | Update the version in one file using a specific pattern. | def update_version_in_file(fname, version, pattern):
"""Update the version in one file using a specific pattern."""
with open(fname, "r", encoding="utf-8", newline="\n") as f:
code = f.read()
re_pattern, replace = REPLACE_PATTERNS[pattern]
replace = replace.replace("VERSION", version)
code =... | [
"def",
"update_version_in_file",
"(",
"fname",
",",
"version",
",",
"pattern",
")",
":",
"with",
"open",
"(",
"fname",
",",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"newline",
"=",
"\"\\n\"",
")",
"as",
"f",
":",
"code",
"=",
"f",
".",
"read",
... | [
40,
0
] | [
48,
21
] | python | en | ['en', 'en', 'en'] | True |
update_version_in_examples | (version) | Update the version in all examples files. | Update the version in all examples files. | def update_version_in_examples(version):
"""Update the version in all examples files."""
for folder, directories, fnames in os.walk(PATH_TO_EXAMPLES):
# Removing some of the folders with non-actively maintained examples from the walk
if "research_projects" in directories:
directories... | [
"def",
"update_version_in_examples",
"(",
"version",
")",
":",
"for",
"folder",
",",
"directories",
",",
"fnames",
"in",
"os",
".",
"walk",
"(",
"PATH_TO_EXAMPLES",
")",
":",
"# Removing some of the folders with non-actively maintained examples from the walk",
"if",
"\"re... | [
51,
0
] | [
61,
96
] | python | en | ['en', 'en', 'en'] | True |
global_version_update | (version, patch=False) | Update the version in all needed files. | Update the version in all needed files. | def global_version_update(version, patch=False):
"""Update the version in all needed files."""
for pattern, fname in REPLACE_FILES.items():
update_version_in_file(fname, version, pattern)
if not patch:
update_version_in_examples(version) | [
"def",
"global_version_update",
"(",
"version",
",",
"patch",
"=",
"False",
")",
":",
"for",
"pattern",
",",
"fname",
"in",
"REPLACE_FILES",
".",
"items",
"(",
")",
":",
"update_version_in_file",
"(",
"fname",
",",
"version",
",",
"pattern",
")",
"if",
"no... | [
64,
0
] | [
69,
43
] | python | en | ['en', 'en', 'en'] | True |
clean_master_ref_in_model_list | () | Replace the links from master doc tp stable doc in the model list of the README. | Replace the links from master doc tp stable doc in the model list of the README. | def clean_master_ref_in_model_list():
"""Replace the links from master doc tp stable doc in the model list of the README."""
# If the introduction or the conclusion of the list change, the prompts may need to be updated.
_start_prompt = "🤗 Transformers currently provides the following architectures"
_e... | [
"def",
"clean_master_ref_in_model_list",
"(",
")",
":",
"# If the introduction or the conclusion of the list change, the prompts may need to be updated.",
"_start_prompt",
"=",
"\"🤗 Transformers currently provides the following architectures\"",
"_end_prompt",
"=",
"\"1. Want to contribute a ... | [
72,
0
] | [
97,
27
] | python | en | ['en', 'en', 'en'] | True |
get_version | () | Reads the current version in the __init__. | Reads the current version in the __init__. | def get_version():
"""Reads the current version in the __init__."""
with open(REPLACE_FILES["init"], "r") as f:
code = f.read()
default_version = REPLACE_PATTERNS["init"][0].search(code).groups()[0]
return packaging.version.parse(default_version) | [
"def",
"get_version",
"(",
")",
":",
"with",
"open",
"(",
"REPLACE_FILES",
"[",
"\"init\"",
"]",
",",
"\"r\"",
")",
"as",
"f",
":",
"code",
"=",
"f",
".",
"read",
"(",
")",
"default_version",
"=",
"REPLACE_PATTERNS",
"[",
"\"init\"",
"]",
"[",
"0",
"... | [
100,
0
] | [
105,
51
] | python | en | ['en', 'en', 'en'] | True |
pre_release_work | (patch=False) | Do all the necessary pre-release steps. | Do all the necessary pre-release steps. | def pre_release_work(patch=False):
"""Do all the necessary pre-release steps."""
# First let's get the default version: base version if we are in dev, bump minor otherwise.
default_version = get_version()
if patch and default_version.is_devrelease:
raise ValueError("Can't create a patch version ... | [
"def",
"pre_release_work",
"(",
"patch",
"=",
"False",
")",
":",
"# First let's get the default version: base version if we are in dev, bump minor otherwise.",
"default_version",
"=",
"get_version",
"(",
")",
"if",
"patch",
"and",
"default_version",
".",
"is_devrelease",
":",... | [
108,
0
] | [
130,
40
] | python | en | ['en', 'en', 'en'] | True |
update_custom_js | (version, patch=False) | Update the version table in the custom.js file. | Update the version table in the custom.js file. | def update_custom_js(version, patch=False):
"""Update the version table in the custom.js file."""
with open(CUSTOM_JS_FILE, "r", encoding="utf-8", newline="\n") as f:
lines = f.readlines()
index = 0
# First let's put the right version
while not lines[index].startswith("const stableVersion =... | [
"def",
"update_custom_js",
"(",
"version",
",",
"patch",
"=",
"False",
")",
":",
"with",
"open",
"(",
"CUSTOM_JS_FILE",
",",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"newline",
"=",
"\"\\n\"",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readl... | [
133,
0
] | [
164,
35
] | python | en | ['en', 'en', 'en'] | True |
post_release_work | () | Do all the necesarry post-release steps. | Do all the necesarry post-release steps. | def post_release_work():
"""Do all the necesarry post-release steps."""
# First let's get the current version
current_version = get_version()
dev_version = f"{current_version.major}.{current_version.minor + 1}.0.dev0"
current_version = current_version.base_version
# Get the current commit hash
... | [
"def",
"post_release_work",
"(",
")",
":",
"# First let's get the current version",
"current_version",
"=",
"get_version",
"(",
")",
"dev_version",
"=",
"f\"{current_version.major}.{current_version.minor + 1}.0.dev0\"",
"current_version",
"=",
"current_version",
".",
"base_versio... | [
185,
0
] | [
208,
45
] | python | en | ['en', 'en', 'en'] | True |
post_patch_work | () | Do all the necesarry post-patch steps. | Do all the necesarry post-patch steps. | def post_patch_work():
"""Do all the necesarry post-patch steps."""
# Try to guess the right info: last patch in the minor release before current version and its commit hash.
current_version = get_version()
repo = git.Repo(".", search_parent_directories=True)
repo_tags = repo.tags
default_versio... | [
"def",
"post_patch_work",
"(",
")",
":",
"# Try to guess the right info: last patch in the minor release before current version and its commit hash.",
"current_version",
"=",
"get_version",
"(",
")",
"repo",
"=",
"git",
".",
"Repo",
"(",
"\".\"",
",",
"search_parent_directories... | [
211,
0
] | [
242,
37
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: Config) | Set up configured IPMA. | Set up configured IPMA. | async def async_setup(hass: HomeAssistant, config: Config) -> bool:
"""Set up configured IPMA."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"Config",
")",
"->",
"bool",
":",
"return",
"True"
] | [
9,
0
] | [
11,
15
] | python | en | ['en', 'ky', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up IPMA station as config entry. | Set up IPMA station as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up IPMA station as config entry."""
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, "weather")
)
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"config_entry",
",",
"\"weather\"",
")",
")",
"return",
"True"
] | [
14,
0
] | [
19,
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."""
await hass.config_entries.async_forward_entry_unload(config_entry, "weather")
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"config_entry",
",",
"\"weather\"",
")",
"return",
"True"
] | [
22,
0
] | [
25,
15
] | python | en | ['en', 'es', '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\"",
")"
] | [
11,
0
] | [
13,
57
] | python | en | ['en', 'en', 'en'] | True |
test_template_state | (hass) | Test template. | Test template. | async def test_template_state(hass):
"""Test template."""
with assert_setup_component(1, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
"name": "Tes... | [
"async",
"def",
"test_template_state",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{",
"\"... | [
16,
0
] | [
53,
45
] | python | en | ['en', 'en', 'en'] | False |
test_template_state_boolean_on | (hass) | Test the setting of the state with boolean on. | Test the setting of the state with boolean on. | async def test_template_state_boolean_on(hass):
"""Test the setting of the state with boolean on."""
with assert_setup_component(1, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "... | [
"async",
"def",
"test_template_state_boolean_on",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
... | [
56,
0
] | [
83,
43
] | python | en | ['en', 'en', 'en'] | True |
test_template_state_boolean_off | (hass) | Test the setting of the state with off. | Test the setting of the state with off. | async def test_template_state_boolean_off(hass):
"""Test the setting of the state with off."""
with assert_setup_component(1, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "templa... | [
"async",
"def",
"test_template_state_boolean_off",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
... | [
86,
0
] | [
113,
45
] | python | en | ['en', 'en', 'en'] | True |
test_template_syntax_error | (hass) | Test templating syntax error. | Test templating syntax error. | async def test_template_syntax_error(hass):
"""Test templating syntax error."""
with assert_setup_component(0, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
... | [
"async",
"def",
"test_template_syntax_error",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{"... | [
116,
0
] | [
142,
40
] | python | ca | ['ca', 'de', 'en'] | False |
test_invalid_name_does_not_create | (hass) | Test invalid name. | Test invalid name. | async def test_invalid_name_does_not_create(hass):
"""Test invalid name."""
with assert_setup_component(0, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"switch": {
"platform": "lock",
... | [
"async",
"def",
"test_invalid_name_does_not_create",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
","... | [
145,
0
] | [
172,
40
] | python | en | ['en', 'et', 'en'] | True |
test_invalid_lock_does_not_create | (hass) | Test invalid lock. | Test invalid lock. | async def test_invalid_lock_does_not_create(hass):
"""Test invalid lock."""
with assert_setup_component(0, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{"lock": {"platform": "template", "value_template": "Invalid"}},
)
await ... | [
"async",
"def",
"test_invalid_lock_does_not_create",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
","... | [
175,
0
] | [
188,
40
] | python | en | ['en', 'et', 'en'] | True |
test_missing_template_does_not_create | (hass) | Test missing template. | Test missing template. | async def test_missing_template_does_not_create(hass):
"""Test missing template."""
with assert_setup_component(0, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
... | [
"async",
"def",
"test_missing_template_does_not_create",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
... | [
191,
0
] | [
217,
40
] | python | en | ['en', 'en', 'en'] | True |
test_template_static | (hass, caplog) | Test that we allow static templates. | Test that we allow static templates. | async def test_template_static(hass, caplog):
"""Test that we allow static templates."""
with assert_setup_component(1, lock.DOMAIN):
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
... | [
"async",
"def",
"test_template_static",
"(",
"hass",
",",
"caplog",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"lock",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",... | [
220,
0
] | [
252,
43
] | python | en | ['en', 'en', 'en'] | True |
test_lock_action | (hass, calls) | Test lock action. | Test lock action. | async def test_lock_action(hass, calls):
"""Test lock action."""
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
"value_template": "{{ states.switch.test_state.state }}",
"lock": ... | [
"async",
"def",
"test_lock_action",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{",
"\"lock\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"value_tem... | [
255,
0
] | [
288,
26
] | python | en | ['en', 'de', 'en'] | True |
test_unlock_action | (hass, calls) | Test unlock action. | Test unlock action. | async def test_unlock_action(hass, calls):
"""Test unlock action."""
assert await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
"value_template": "{{ states.switch.test_state.state }}",
"loc... | [
"async",
"def",
"test_unlock_action",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{",
"\"lock\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"value_t... | [
291,
0
] | [
324,
26
] | python | de | ['de', 'fi', 'en'] | False |
test_available_template_with_entities | (hass) | Test availability templates with values from other entities. | Test availability templates with values from other entities. | async def test_available_template_with_entities(hass):
"""Test availability templates with values from other entities."""
await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
"value_template": "{{ states('s... | [
"async",
"def",
"test_available_template_with_entities",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{",
"\"lock\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"value_template\"",... | [
327,
0
] | [
363,
75
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_availability_template_keeps_component_available | (hass, caplog) | Test that an invalid availability keeps the device available. | Test that an invalid availability keeps the device available. | async def test_invalid_availability_template_keeps_component_available(hass, caplog):
"""Test that an invalid availability keeps the device available."""
await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
... | [
"async",
"def",
"test_invalid_availability_template_keeps_component_available",
"(",
"hass",
",",
"caplog",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{",
"\"lock\"",
":",
"{",
"\"platform\"",
":",
"\"t... | [
366,
0
] | [
390,
62
] | python | en | ['en', 'en', 'en'] | True |
test_unique_id | (hass) | Test unique_id option only creates one lock per id. | Test unique_id option only creates one lock per id. | async def test_unique_id(hass):
"""Test unique_id option only creates one lock per id."""
await setup.async_setup_component(
hass,
lock.DOMAIN,
{
"lock": {
"platform": "template",
"name": "test_template_lock_01",
"unique_id": "n... | [
"async",
"def",
"test_unique_id",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"lock",
".",
"DOMAIN",
",",
"{",
"\"lock\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"name\"",
":",
"\"test_template_lock_0... | [
393,
0
] | [
435,
44
] | python | en | ['en', 'en', 'en'] | True |
test_binary_sensor | (
hass: HomeAssistant, vera_component_factory: ComponentFactory
) | Test function. | Test function. | async def test_binary_sensor(
hass: HomeAssistant, vera_component_factory: ComponentFactory
) -> None:
"""Test function."""
vera_device = MagicMock(spec=pv.VeraBinarySensor) # type: pv.VeraBinarySensor
vera_device.device_id = 1
vera_device.vera_device_id = vera_device.device_id
vera_device.name... | [
"async",
"def",
"test_binary_sensor",
"(",
"hass",
":",
"HomeAssistant",
",",
"vera_component_factory",
":",
"ComponentFactory",
")",
"->",
"None",
":",
"vera_device",
"=",
"MagicMock",
"(",
"spec",
"=",
"pv",
".",
"VeraBinarySensor",
")",
"# type: pv.VeraBinarySens... | [
10,
0
] | [
35,
51
] | python | en | ['en', 'en', 'en'] | False |
SingleImageViz.__init__ | (
self,
img,
scale=1.2,
edgecolor="g",
alpha=0.5,
linestyle="-",
saveas="test_out.jpg",
rgb=True,
pynb=False,
id2obj=None,
id2attr=None,
pad=0.7,
) |
img: an RGB image of shape (H, W, 3).
|
img: an RGB image of shape (H, W, 3).
| def __init__(
self,
img,
scale=1.2,
edgecolor="g",
alpha=0.5,
linestyle="-",
saveas="test_out.jpg",
rgb=True,
pynb=False,
id2obj=None,
id2attr=None,
pad=0.7,
):
"""
img: an RGB image of shape (H, W, 3).
... | [
"def",
"__init__",
"(",
"self",
",",
"img",
",",
"scale",
"=",
"1.2",
",",
"edgecolor",
"=",
"\"g\"",
",",
"alpha",
"=",
"0.5",
",",
"linestyle",
"=",
"\"-\"",
",",
"saveas",
"=",
"\"test_out.jpg\"",
",",
"rgb",
"=",
"True",
",",
"pynb",
"=",
"False"... | [
35,
4
] | [
85,
42
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
controller_data = get_controller_data(hass, entry)
async_add_entities(
[VeraScene(device, controller_data) for ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
15,
0
] | [
24,
5
] | python | en | ['en', 'pt', 'en'] | True |
VeraScene.__init__ | (self, vera_scene: veraApi.VeraScene, controller_data: ControllerData) | Initialize the scene. | Initialize the scene. | def __init__(self, vera_scene: veraApi.VeraScene, controller_data: ControllerData):
"""Initialize the scene."""
self.vera_scene = vera_scene
self.controller = controller_data.controller
self._name = self.vera_scene.name
# Append device id to prevent name clashes in HA.
s... | [
"def",
"__init__",
"(",
"self",
",",
"vera_scene",
":",
"veraApi",
".",
"VeraScene",
",",
"controller_data",
":",
"ControllerData",
")",
":",
"self",
".",
"vera_scene",
"=",
"vera_scene",
"self",
".",
"controller",
"=",
"controller_data",
".",
"controller",
"s... | [
30,
4
] | [
39,
9
] | python | en | ['en', 'it', 'en'] | True |
VeraScene.update | (self) | Update the scene status. | Update the scene status. | def update(self) -> None:
"""Update the scene status."""
self.vera_scene.refresh() | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"vera_scene",
".",
"refresh",
"(",
")"
] | [
41,
4
] | [
43,
33
] | python | en | ['en', 'sn', 'en'] | True |
VeraScene.activate | (self, **kwargs: Any) | Activate the scene. | Activate the scene. | def activate(self, **kwargs: Any) -> None:
"""Activate the scene."""
self.vera_scene.activate() | [
"def",
"activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"vera_scene",
".",
"activate",
"(",
")"
] | [
45,
4
] | [
47,
34
] | python | en | ['en', 'it', 'en'] | True |
VeraScene.name | (self) | Return the name of the scene. | Return the name of the scene. | def name(self) -> str:
"""Return the name of the scene."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
50,
4
] | [
52,
25
] | python | en | ['en', 'ig', 'en'] | True |
VeraScene.device_state_attributes | (self) | Return the state attributes of the scene. | Return the state attributes of the scene. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the scene."""
return {"vera_scene_id": self.vera_scene.vera_scene_id} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"{",
"\"vera_scene_id\"",
":",
"self",
".",
"vera_scene",
".",
"vera_scene_id",
"}"
] | [
55,
4
] | [
57,
63
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities_callback, discovery_info=None) | Set up S20 switches. | Set up S20 switches. | def setup_platform(hass, config, add_entities_callback, discovery_info=None):
"""Set up S20 switches."""
switch_data = {}
switches = []
switch_conf = config.get(CONF_SWITCHES, [config])
if config.get(CONF_DISCOVERY):
_LOGGER.info("Discovering S20 switches ...")
switch_data.update(d... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"switch_data",
"=",
"{",
"}",
"switches",
"=",
"[",
"]",
"switch_conf",
"=",
"config",
".",
"get",
"(",
"CONF_SWITCHES",
",",
"... | [
38,
0
] | [
61,
35
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.__init__ | (self, name, s20) | Initialize the S20 device. | Initialize the S20 device. | def __init__(self, name, s20):
"""Initialize the S20 device."""
self._name = name
self._s20 = s20
self._state = False
self._exc = S20Exception | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"s20",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_s20",
"=",
"s20",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_exc",
"=",
"S20Exception"
] | [
67,
4
] | [
73,
32
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
76,
4
] | [
78,
25
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
81,
4
] | [
83,
26
] | python | en | ['en', 'fy', 'en'] | True |
S20Switch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
try:
self._state = self._s20.on
except self._exc:
_LOGGER.exception("Error while fetching S20 state") | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_s20",
".",
"on",
"except",
"self",
".",
"_exc",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Error while fetching S20 state\"",
")"
] | [
85,
4
] | [
90,
63
] | python | en | ['fr', 'en', 'en'] | True |
S20Switch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
try:
self._s20.on = True
except self._exc:
_LOGGER.exception("Error while turning on S20") | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_s20",
".",
"on",
"=",
"True",
"except",
"self",
".",
"_exc",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Error while turning on S20\"",
")"
] | [
92,
4
] | [
97,
59
] | python | en | ['en', 'en', 'en'] | True |
S20Switch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
try:
self._s20.on = False
except self._exc:
_LOGGER.exception("Error while turning off S20") | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_s20",
".",
"on",
"=",
"False",
"except",
"self",
".",
"_exc",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Error while turning off S20\"",
")"
] | [
99,
4
] | [
104,
60
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the NOAA Tides and Currents sensor. | Set up the NOAA Tides and Currents sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the NOAA Tides and Currents sensor."""
station_id = config[CONF_STATION_ID]
name = config.get(CONF_NAME)
timezone = config.get(CONF_TIME_ZONE)
if CONF_UNIT_SYSTEM in config:
unit_system = config[CONF_UNIT_SYSTEM]... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"station_id",
"=",
"config",
"[",
"CONF_STATION_ID",
"]",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"timezone",
"=",
"co... | [
42,
0
] | [
71,
37
] | python | en | ['en', 'ca', 'en'] | True |
NOAATidesAndCurrentsSensor.__init__ | (self, name, station_id, timezone, unit_system, station) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, station_id, timezone, unit_system, station):
"""Initialize the sensor."""
self._name = name
self._station_id = station_id
self._timezone = timezone
self._unit_system = unit_system
self._station = station
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"station_id",
",",
"timezone",
",",
"unit_system",
",",
"station",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_station_id",
"=",
"station_id",
"self",
".",
"_timezone",
"=",
"timezone",
"s... | [
77,
4
] | [
84,
24
] | python | en | ['en', 'en', 'en'] | True |
NOAATidesAndCurrentsSensor.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"
] | [
87,
4
] | [
89,
25
] | python | en | ['en', 'mi', 'en'] | True |
NOAATidesAndCurrentsSensor.device_state_attributes | (self) | Return the state attributes of this device. | Return the state attributes of this device. | def device_state_attributes(self):
"""Return the state attributes of this device."""
attr = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
if self.data is None:
return attr
if self.data["hi_lo"][1] == "H":
attr["high_tide_time"] = self.data.index[1].strftime("%Y-%m-%dT%H... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"DEFAULT_ATTRIBUTION",
"}",
"if",
"self",
".",
"data",
"is",
"None",
":",
"return",
"attr",
"if",
"self",
".",
"data",
"[",
"\"hi_lo\"",
"]",
"[",
"1",
"]... | [
92,
4
] | [
107,
19
] | python | en | ['en', 'en', 'en'] | True |
NOAATidesAndCurrentsSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
if self.data is None:
return None
api_time = self.data.index[0]
if self.data["hi_lo"][0] == "H":
tidetime = api_time.strftime("%-I:%M %p")
return f"High tide at {tidetime}"
if self.data["hi... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"data",
"is",
"None",
":",
"return",
"None",
"api_time",
"=",
"self",
".",
"data",
".",
"index",
"[",
"0",
"]",
"if",
"self",
".",
"data",
"[",
"\"hi_lo\"",
"]",
"[",
"0",
"]",
"==",
"\"... | [
110,
4
] | [
121,
19
] | python | en | ['en', 'en', 'en'] | True |
NOAATidesAndCurrentsSensor.update | (self) | Get the latest data from NOAA Tides and Currents API. | Get the latest data from NOAA Tides and Currents API. | def update(self):
"""Get the latest data from NOAA Tides and Currents API."""
begin = datetime.now()
delta = timedelta(days=2)
end = begin + delta
try:
df_predictions = self._station.get_data(
begin_date=begin.strftime("%Y%m%d %H:%M"),
... | [
"def",
"update",
"(",
"self",
")",
":",
"begin",
"=",
"datetime",
".",
"now",
"(",
")",
"delta",
"=",
"timedelta",
"(",
"days",
"=",
"2",
")",
"end",
"=",
"begin",
"+",
"delta",
"try",
":",
"df_predictions",
"=",
"self",
".",
"_station",
".",
"get_... | [
123,
4
] | [
146,
28
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Perform the setup for Switchmate devices. | Perform the setup for Switchmate devices. | def setup_platform(hass, config, add_entities, discovery_info=None) -> None:
"""Perform the setup for Switchmate devices."""
name = config.get(CONF_NAME)
mac_addr = config[CONF_MAC]
flip_on_off = config[CONF_FLIP_ON_OFF]
add_entities([SwitchmateEntity(mac_addr, name, flip_on_off)], True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
"->",
"None",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"mac_addr",
"=",
"config",
"[",
"CONF_MAC",
"]",
"flip_on_off",
... | [
25,
0
] | [
30,
71
] | python | en | ['en', 'en', 'en'] | True |
SwitchmateEntity.__init__ | (self, mac, name, flip_on_off) | Initialize the Switchmate. | Initialize the Switchmate. | def __init__(self, mac, name, flip_on_off) -> None:
"""Initialize the Switchmate."""
self._mac = mac
self._name = name
self._device = switchmate.Switchmate(mac=mac, flip_on_off=flip_on_off) | [
"def",
"__init__",
"(",
"self",
",",
"mac",
",",
"name",
",",
"flip_on_off",
")",
"->",
"None",
":",
"self",
".",
"_mac",
"=",
"mac",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_device",
"=",
"switchmate",
".",
"Switchmate",
"(",
"mac",
"=",
... | [
36,
4
] | [
41,
78
] | python | en | ['en', 'en', 'en'] | True |
SwitchmateEntity.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self) -> str:
"""Return a unique, Home Assistant friendly identifier for this entity."""
return self._mac.replace(":", "") | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac",
".",
"replace",
"(",
"\":\"",
",",
"\"\"",
")"
] | [
44,
4
] | [
46,
41
] | python | en | ['en', 'en', 'en'] | True |
SwitchmateEntity.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._device.available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_device",
".",
"available"
] | [
49,
4
] | [
51,
37
] | python | en | ['en', 'en', 'en'] | True |
SwitchmateEntity.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self) -> str:
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
54,
4
] | [
56,
25
] | 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.