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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_device_properties | (
hass: HomeAssistant, device_property: str, target_value: str
) | Test device properties. | Test device properties. | async def test_device_properties(
hass: HomeAssistant, device_property: str, target_value: str
):
"""Test device properties."""
registry = await hass.helpers.device_registry.async_get_registry()
device = registry.async_get_device({(DOMAIN, "AC000Wxxxxxxxxx")}, [])
assert getattr(device, device_prope... | [
"async",
"def",
"test_device_properties",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_property",
":",
"str",
",",
"target_value",
":",
"str",
")",
":",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
... | [
197,
0
] | [
203,
59
] | python | en | ['fr', 'en', 'en'] | True |
test_locate | (hass) | Test that the locate command works. | Test that the locate command works. | async def test_locate(hass):
"""Test that the locate command works."""
with patch.object(SharkIqVacuum, "async_find_device") as mock_locate:
data = {ATTR_ENTITY_ID: VAC_ENTITY_ID}
await hass.services.async_call("vacuum", SERVICE_LOCATE, data, blocking=True)
mock_locate.assert_called_once... | [
"async",
"def",
"test_locate",
"(",
"hass",
")",
":",
"with",
"patch",
".",
"object",
"(",
"SharkIqVacuum",
",",
"\"async_find_device\"",
")",
"as",
"mock_locate",
":",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"VAC_ENTITY_ID",
"}",
"await",
"hass",
".",
"ser... | [
206,
0
] | [
211,
40
] | python | en | ['en', 'en', 'en'] | True |
test_coordinator_updates | (
hass: HomeAssistant, side_effect: Optional[Exception], success: bool
) | Test the update coordinator update functions. | Test the update coordinator update functions. | async def test_coordinator_updates(
hass: HomeAssistant, side_effect: Optional[Exception], success: bool
) -> None:
"""Test the update coordinator update functions."""
coordinator = hass.data[DOMAIN][ENTRY_ID]
await async_setup_component(hass, "homeassistant", {})
with patch.object(
MockSh... | [
"async",
"def",
"test_coordinator_updates",
"(",
"hass",
":",
"HomeAssistant",
",",
"side_effect",
":",
"Optional",
"[",
"Exception",
"]",
",",
"success",
":",
"bool",
")",
"->",
"None",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"["... | [
224,
0
] | [
243,
56
] | python | en | ['en', 'nl', 'en'] | True |
MockAyla.async_sign_in | (self) | Instead of signing in, just return. | Instead of signing in, just return. | async def async_sign_in(self):
"""Instead of signing in, just return.""" | [
"async",
"def",
"async_sign_in",
"(",
"self",
")",
":"
] | [
78,
4
] | [
79,
49
] | python | en | ['en', 'en', 'en'] | True |
MockAyla.async_list_devices | (self) | Return the device list. | Return the device list. | async def async_list_devices(self) -> List[dict]:
"""Return the device list."""
return [SHARK_DEVICE_DICT] | [
"async",
"def",
"async_list_devices",
"(",
"self",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"return",
"[",
"SHARK_DEVICE_DICT",
"]"
] | [
81,
4
] | [
83,
34
] | python | en | ['en', 'en', 'en'] | True |
MockAyla.async_get_devices | (self, update: bool = True) | Get the list of devices. | Get the list of devices. | async def async_get_devices(self, update: bool = True) -> List[SharkIqVacuum]:
"""Get the list of devices."""
shark = MockShark(self, SHARK_DEVICE_DICT)
shark.properties_full = deepcopy(SHARK_PROPERTIES_DICT)
shark._update_metadata(SHARK_METADATA_DICT) # pylint: disable=protected-access... | [
"async",
"def",
"async_get_devices",
"(",
"self",
",",
"update",
":",
"bool",
"=",
"True",
")",
"->",
"List",
"[",
"SharkIqVacuum",
"]",
":",
"shark",
"=",
"MockShark",
"(",
"self",
",",
"SHARK_DEVICE_DICT",
")",
"shark",
".",
"properties_full",
"=",
"deep... | [
85,
4
] | [
90,
22
] | python | en | ['en', 'en', 'en'] | True |
MockAyla.async_request | (self, http_method: str, url: str, **kwargs) | Don't make an HTTP request. | Don't make an HTTP request. | async def async_request(self, http_method: str, url: str, **kwargs):
"""Don't make an HTTP request.""" | [
"async",
"def",
"async_request",
"(",
"self",
",",
"http_method",
":",
"str",
",",
"url",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
92,
4
] | [
93,
41
] | python | en | ['en', 'en', 'en'] | True |
MockShark.async_update | (self, property_list: Optional[Iterable[str]] = None) | Don't do anything. | Don't do anything. | async def async_update(self, property_list: Optional[Iterable[str]] = None):
"""Don't do anything.""" | [
"async",
"def",
"async_update",
"(",
"self",
",",
"property_list",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
":"
] | [
99,
4
] | [
100,
32
] | python | en | ['en', 'en', 'en'] | True |
MockShark.set_property_value | (self, property_name, value) | Set a property locally without hitting the API. | Set a property locally without hitting the API. | def set_property_value(self, property_name, value):
"""Set a property locally without hitting the API."""
if isinstance(property_name, enum.Enum):
property_name = property_name.value
if isinstance(value, enum.Enum):
value = value.value
self.properties_full[propert... | [
"def",
"set_property_value",
"(",
"self",
",",
"property_name",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"property_name",
",",
"enum",
".",
"Enum",
")",
":",
"property_name",
"=",
"property_name",
".",
"value",
"if",
"isinstance",
"(",
"value",
",",
... | [
102,
4
] | [
108,
60
] | python | en | ['en', 'en', 'en'] | True |
MockShark.async_set_property_value | (self, property_name, value) | Set a property locally without hitting the API. | Set a property locally without hitting the API. | async def async_set_property_value(self, property_name, value):
"""Set a property locally without hitting the API."""
self.set_property_value(property_name, value) | [
"async",
"def",
"async_set_property_value",
"(",
"self",
",",
"property_name",
",",
"value",
")",
":",
"self",
".",
"set_property_value",
"(",
"property_name",
",",
"value",
")"
] | [
110,
4
] | [
112,
53
] | python | en | ['en', 'en', 'en'] | True |
k_shortest_paths | (G, source, target, k=1, weight='weight') | Returns the k-shortest paths from source to target in a weighted graph flux_graph.
Parameters
----------
flux_graph : NetworkX graph
source : node
Starting node
target : node
Ending node
k : integer, optional (default=1)
The number of shortest paths to find
... | Returns the k-shortest paths from source to target in a weighted graph flux_graph. | def k_shortest_paths(G, source, target, k=1, weight='weight'):
"""Returns the k-shortest paths from source to target in a weighted graph flux_graph.
Parameters
----------
flux_graph : NetworkX graph
source : node
Starting node
target : node
Ending node
k : integer, o... | [
"def",
"k_shortest_paths",
"(",
"G",
",",
"source",
",",
"target",
",",
"k",
"=",
"1",
",",
"weight",
"=",
"'weight'",
")",
":",
"if",
"source",
"==",
"target",
":",
"return",
"(",
"[",
"0",
"]",
",",
"[",
"[",
"source",
"]",
"]",
")",
"length",
... | [
17,
0
] | [
118,
27
] | python | en | ['en', 'en', 'en'] | True |
validate | (integrations: Dict[str, Integration], config: Config) | Validate coverage. | Validate coverage. | def validate(integrations: Dict[str, Integration], config: Config):
"""Validate coverage."""
coverage_path = config.root / ".coveragerc"
not_found = []
checking = False
with coverage_path.open("rt") as fp:
for line in fp:
line = line.strip()
if not line or line.sta... | [
"def",
"validate",
"(",
"integrations",
":",
"Dict",
"[",
"str",
",",
"Integration",
"]",
",",
"config",
":",
"Config",
")",
":",
"coverage_path",
"=",
"config",
".",
"root",
"/",
"\".coveragerc\"",
"not_found",
"=",
"[",
"]",
"checking",
"=",
"False",
"... | [
71,
0
] | [
136,
40
] | python | en | ['en', 'et', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up modem caller ID sensor platform. | Set up modem caller ID sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up modem caller ID sensor platform."""
name = config.get(CONF_NAME)
port = config.get(CONF_DEVICE)
modem = bm(port)
if modem.state == modem.STATE_FAILED:
_LOGGER.error("Unable to initialize modem")
return
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_DEVICE",
")",
"modem",
"=",
... | [
32,
0
] | [
43,
64
] | python | en | ['en', 'da', 'en'] | True |
ModemCalleridSensor.__init__ | (self, hass, name, port, modem) | Initialize the sensor. | Initialize the sensor. | def __init__(self, hass, name, port, modem):
"""Initialize the sensor."""
self._attributes = {"cid_time": 0, "cid_number": "", "cid_name": ""}
self._name = name
self.port = port
self.modem = modem
self._state = STATE_IDLE
modem.registercallback(self._incomingcallc... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"port",
",",
"modem",
")",
":",
"self",
".",
"_attributes",
"=",
"{",
"\"cid_time\"",
":",
"0",
",",
"\"cid_number\"",
":",
"\"\"",
",",
"\"cid_name\"",
":",
"\"\"",
"}",
"self",
".",
"_n... | [
49,
4
] | [
57,
72
] | python | en | ['en', 'en', 'en'] | True |
ModemCalleridSensor.set_state | (self, state) | Set the state. | Set the state. | def set_state(self, state):
"""Set the state."""
self._state = state | [
"def",
"set_state",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_state",
"=",
"state"
] | [
59,
4
] | [
61,
27
] | python | en | ['en', 'en', 'en'] | True |
ModemCalleridSensor.set_attributes | (self, attributes) | Set the state attributes. | Set the state attributes. | def set_attributes(self, attributes):
"""Set the state attributes."""
self._attributes = attributes | [
"def",
"set_attributes",
"(",
"self",
",",
"attributes",
")",
":",
"self",
".",
"_attributes",
"=",
"attributes"
] | [
63,
4
] | [
65,
37
] | python | en | ['en', 'en', 'en'] | True |
ModemCalleridSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
68,
4
] | [
70,
20
] | python | en | ['en', 'en', 'en'] | True |
ModemCalleridSensor.icon | (self) | Return icon. | Return icon. | def icon(self):
"""Return icon."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
73,
4
] | [
75,
19
] | python | en | ['en', 'la', 'en'] | False |
ModemCalleridSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
78,
4
] | [
80,
26
] | python | en | ['en', 'en', 'en'] | True |
ModemCalleridSensor.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"
] | [
83,
4
] | [
85,
25
] | python | en | ['en', 'mi', 'en'] | True |
ModemCalleridSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
88,
4
] | [
90,
31
] | python | en | ['en', 'en', 'en'] | True |
ModemCalleridSensor._stop_modem | (self, event) | HA is shutting down, close modem port. | HA is shutting down, close modem port. | def _stop_modem(self, event):
"""HA is shutting down, close modem port."""
if self.modem:
self.modem.close()
self.modem = None | [
"def",
"_stop_modem",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"modem",
":",
"self",
".",
"modem",
".",
"close",
"(",
")",
"self",
".",
"modem",
"=",
"None"
] | [
92,
4
] | [
96,
29
] | python | en | ['en', 'bg', 'en'] | True |
ModemCalleridSensor._incomingcallcallback | (self, newstate) | Handle new states. | Handle new states. | def _incomingcallcallback(self, newstate):
"""Handle new states."""
if newstate == self.modem.STATE_RING:
if self.state == self.modem.STATE_IDLE:
att = {
"cid_time": self.modem.get_cidtime,
"cid_number": "",
"cid_nam... | [
"def",
"_incomingcallcallback",
"(",
"self",
",",
"newstate",
")",
":",
"if",
"newstate",
"==",
"self",
".",
"modem",
".",
"STATE_RING",
":",
"if",
"self",
".",
"state",
"==",
"self",
".",
"modem",
".",
"STATE_IDLE",
":",
"att",
"=",
"{",
"\"cid_time\"",... | [
98,
4
] | [
121,
43
] | python | en | ['pl', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Panasonic Viera TV from a config entry. | Set up Panasonic Viera TV from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Panasonic Viera TV from a config entry."""
config = config_entry.data
remote = hass.data[DOMAIN][config_entry.entry_id][ATTR_REMOTE]
name = config[CONF_NAME]
device_info = config[ATTR_DEVICE_INFO]
tv_device = Panas... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"config",
"=",
"config_entry",
".",
"data",
"remote",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
... | [
50,
0
] | [
60,
35
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.__init__ | (self, remote, name, device_info) | Initialize the entity. | Initialize the entity. | def __init__(self, remote, name, device_info):
"""Initialize the entity."""
self._remote = remote
self._name = name
self._device_info = device_info | [
"def",
"__init__",
"(",
"self",
",",
"remote",
",",
"name",
",",
"device_info",
")",
":",
"self",
".",
"_remote",
"=",
"remote",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_device_info",
"=",
"device_info"
] | [
66,
4
] | [
70,
39
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.unique_id | (self) | Return the unique ID of the device. | Return the unique ID of the device. | def unique_id(self):
"""Return the unique ID of the device."""
if self._device_info is None:
return None
return self._device_info[ATTR_UDN] | [
"def",
"unique_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_info",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"_device_info",
"[",
"ATTR_UDN",
"]"
] | [
73,
4
] | [
77,
42
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.device_info | (self) | Return device specific attributes. | Return device specific attributes. | def device_info(self):
"""Return device specific attributes."""
if self._device_info is None:
return None
return {
"name": self._name,
"identifiers": {(DOMAIN, self._device_info[ATTR_UDN])},
"manufacturer": self._device_info.get(
AT... | [
"def",
"device_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_info",
"is",
"None",
":",
"return",
"None",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_info",
... | [
80,
4
] | [
91,
9
] | python | en | ['fr', 'it', 'en'] | False |
PanasonicVieraTVEntity.device_class | (self) | Return the device class of the device. | Return the device class of the device. | def device_class(self):
"""Return the device class of the device."""
return DEVICE_CLASS_TV | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TV"
] | [
94,
4
] | [
96,
30
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
99,
4
] | [
101,
25
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._remote.state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_remote",
".",
"state"
] | [
104,
4
] | [
106,
33
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.available | (self) | Return True if the device is available. | Return True if the device is available. | def available(self):
"""Return True if the device is available."""
return self._remote.available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_remote",
".",
"available"
] | [
109,
4
] | [
111,
37
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.volume_level | (self) | Volume level of the media player (0..1). | Volume level of the media player (0..1). | def volume_level(self):
"""Volume level of the media player (0..1)."""
return self._remote.volume | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_remote",
".",
"volume"
] | [
114,
4
] | [
116,
34
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.is_volume_muted | (self) | Boolean if volume is currently muted. | Boolean if volume is currently muted. | def is_volume_muted(self):
"""Boolean if volume is currently muted."""
return self._remote.muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_remote",
".",
"muted"
] | [
119,
4
] | [
121,
33
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_VIERATV | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_VIERATV"
] | [
124,
4
] | [
126,
30
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_update | (self) | Retrieve the latest data. | Retrieve the latest data. | async def async_update(self):
"""Retrieve the latest data."""
await self._remote.async_update() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_update",
"(",
")"
] | [
128,
4
] | [
130,
41
] | python | en | ['en', 'ga', 'en'] | True |
PanasonicVieraTVEntity.async_turn_on | (self) | Turn on the media player. | Turn on the media player. | async def async_turn_on(self):
"""Turn on the media player."""
await self._remote.async_turn_on(context=self._context) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_turn_on",
"(",
"context",
"=",
"self",
".",
"_context",
")"
] | [
132,
4
] | [
134,
63
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_turn_off | (self) | Turn off media player. | Turn off media player. | async def async_turn_off(self):
"""Turn off media player."""
await self._remote.async_turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_turn_off",
"(",
")"
] | [
136,
4
] | [
138,
43
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_volume_up | (self) | Volume up the media player. | Volume up the media player. | async def async_volume_up(self):
"""Volume up the media player."""
await self._remote.async_send_key(Keys.volume_up) | [
"async",
"def",
"async_volume_up",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"volume_up",
")"
] | [
140,
4
] | [
142,
57
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_volume_down | (self) | Volume down media player. | Volume down media player. | async def async_volume_down(self):
"""Volume down media player."""
await self._remote.async_send_key(Keys.volume_down) | [
"async",
"def",
"async_volume_down",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"volume_down",
")"
] | [
144,
4
] | [
146,
59
] | python | en | ['en', 'sl', 'en'] | True |
PanasonicVieraTVEntity.async_mute_volume | (self, mute) | Send mute command. | Send mute command. | async def async_mute_volume(self, mute):
"""Send mute command."""
await self._remote.async_set_mute(mute) | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_set_mute",
"(",
"mute",
")"
] | [
148,
4
] | [
150,
47
] | python | en | ['en', 'co', 'en'] | True |
PanasonicVieraTVEntity.async_set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | async def async_set_volume_level(self, volume):
"""Set volume level, range 0..1."""
await self._remote.async_set_volume(volume) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_set_volume",
"(",
"volume",
")"
] | [
152,
4
] | [
154,
51
] | python | en | ['fr', 'zu', 'en'] | False |
PanasonicVieraTVEntity.async_media_play_pause | (self) | Simulate play pause media player. | Simulate play pause media player. | async def async_media_play_pause(self):
"""Simulate play pause media player."""
if self._remote.playing:
await self._remote.async_send_key(Keys.pause)
self._remote.playing = False
else:
await self._remote.async_send_key(Keys.play)
self._remote.play... | [
"async",
"def",
"async_media_play_pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"_remote",
".",
"playing",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"pause",
")",
"self",
".",
"_remote",
".",
"playing",
"=",
"Fals... | [
156,
4
] | [
163,
39
] | python | en | ['en', 'en', 'it'] | True |
PanasonicVieraTVEntity.async_media_play | (self) | Send play command. | Send play command. | async def async_media_play(self):
"""Send play command."""
await self._remote.async_send_key(Keys.play)
self._remote.playing = True | [
"async",
"def",
"async_media_play",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"play",
")",
"self",
".",
"_remote",
".",
"playing",
"=",
"True"
] | [
165,
4
] | [
168,
35
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_media_pause | (self) | Send pause command. | Send pause command. | async def async_media_pause(self):
"""Send pause command."""
await self._remote.async_send_key(Keys.pause)
self._remote.playing = False | [
"async",
"def",
"async_media_pause",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"pause",
")",
"self",
".",
"_remote",
".",
"playing",
"=",
"False"
] | [
170,
4
] | [
173,
36
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_media_stop | (self) | Stop playback. | Stop playback. | async def async_media_stop(self):
"""Stop playback."""
await self._remote.async_send_key(Keys.stop) | [
"async",
"def",
"async_media_stop",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"stop",
")"
] | [
175,
4
] | [
177,
52
] | python | en | ['en', 'en', 'en'] | False |
PanasonicVieraTVEntity.async_media_next_track | (self) | Send the fast forward command. | Send the fast forward command. | async def async_media_next_track(self):
"""Send the fast forward command."""
await self._remote.async_send_key(Keys.fast_forward) | [
"async",
"def",
"async_media_next_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"fast_forward",
")"
] | [
179,
4
] | [
181,
60
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_media_previous_track | (self) | Send the rewind command. | Send the rewind command. | async def async_media_previous_track(self):
"""Send the rewind command."""
await self._remote.async_send_key(Keys.rewind) | [
"async",
"def",
"async_media_previous_track",
"(",
"self",
")",
":",
"await",
"self",
".",
"_remote",
".",
"async_send_key",
"(",
"Keys",
".",
"rewind",
")"
] | [
183,
4
] | [
185,
54
] | python | en | ['en', 'en', 'en'] | True |
PanasonicVieraTVEntity.async_play_media | (self, media_type, media_id, **kwargs) | Play media. | Play media. | async def async_play_media(self, media_type, media_id, **kwargs):
"""Play media."""
if media_type != MEDIA_TYPE_URL:
_LOGGER.warning("Unsupported media_type: %s", media_type)
return
await self._remote.async_play_media(media_type, media_id) | [
"async",
"def",
"async_play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"media_type",
"!=",
"MEDIA_TYPE_URL",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Unsupported media_type: %s\"",
",",
"media_type",
")",
"... | [
187,
4
] | [
193,
65
] | python | en | ['en', 'sv', 'en'] | False |
test_auth_success | (hass, hassio_client_supervisor) | Test no auth needed for . | Test no auth needed for . | async def test_auth_success(hass, hassio_client_supervisor):
"""Test no auth needed for ."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
) as mock_login:
resp = await hassio_client_supervisor.post(
"/api/hassio_auth",... | [
"async",
"def",
"test_auth_success",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
")",
"as",
"mock_login",
":",
"resp",
"=",
"await",
"has... | [
7,
0
] | [
20,
55
] | python | en | ['en', 'en', 'en'] | True |
test_auth_fails_no_supervisor | (hass, hassio_client) | Test if only supervisor can access. | Test if only supervisor can access. | async def test_auth_fails_no_supervisor(hass, hassio_client):
"""Test if only supervisor can access."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
) as mock_login:
resp = await hassio_client.post(
"/api/hassio_auth",... | [
"async",
"def",
"test_auth_fails_no_supervisor",
"(",
"hass",
",",
"hassio_client",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
")",
"as",
"mock_login",
":",
"resp",
"=",
"await",
"ha... | [
23,
0
] | [
36,
36
] | python | en | ['en', 'en', 'en'] | True |
test_auth_fails_no_auth | (hass, hassio_noauth_client) | Test if only supervisor can access. | Test if only supervisor can access. | async def test_auth_fails_no_auth(hass, hassio_noauth_client):
"""Test if only supervisor can access."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
) as mock_login:
resp = await hassio_noauth_client.post(
"/api/hassi... | [
"async",
"def",
"test_auth_fails_no_auth",
"(",
"hass",
",",
"hassio_noauth_client",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
")",
"as",
"mock_login",
":",
"resp",
"=",
"await",
"h... | [
39,
0
] | [
52,
36
] | python | en | ['en', 'en', 'en'] | True |
test_login_error | (hass, hassio_client_supervisor) | Test no auth needed for error. | Test no auth needed for error. | async def test_login_error(hass, hassio_client_supervisor):
"""Test no auth needed for error."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
Mock(side_effect=InvalidAuth()),
) as mock_login:
resp = await hassio_client_sup... | [
"async",
"def",
"test_login_error",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
"Mock",
"(",
"side_effect",
"=",
"InvalidAuth",
"(",
")",
... | [
55,
0
] | [
69,
55
] | python | en | ['en', 'en', 'en'] | True |
test_login_no_data | (hass, hassio_client_supervisor) | Test auth with no data -> error. | Test auth with no data -> error. | async def test_login_no_data(hass, hassio_client_supervisor):
"""Test auth with no data -> error."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
Mock(side_effect=InvalidAuth()),
) as mock_login:
resp = await hassio_client... | [
"async",
"def",
"test_login_no_data",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
"Mock",
"(",
"side_effect",
"=",
"InvalidAuth",
"(",
")",... | [
72,
0
] | [
83,
36
] | python | en | ['en', 'en', 'en'] | True |
test_login_no_username | (hass, hassio_client_supervisor) | Test auth with no username in data -> error. | Test auth with no username in data -> error. | async def test_login_no_username(hass, hassio_client_supervisor):
"""Test auth with no username in data -> error."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
Mock(side_effect=InvalidAuth()),
) as mock_login:
resp = awa... | [
"async",
"def",
"test_login_no_username",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
"Mock",
"(",
"side_effect",
"=",
"InvalidAuth",
"(",
... | [
86,
0
] | [
99,
36
] | python | en | ['en', 'en', 'en'] | True |
test_login_success_extra | (hass, hassio_client_supervisor) | Test auth with extra data. | Test auth with extra data. | async def test_login_success_extra(hass, hassio_client_supervisor):
"""Test auth with extra data."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_validate_login",
) as mock_login:
resp = await hassio_client_supervisor.post(
"/api/hassi... | [
"async",
"def",
"test_login_success_extra",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_validate_login\"",
",",
")",
"as",
"mock_login",
":",
"resp",
"=",
"await",... | [
102,
0
] | [
120,
55
] | python | en | ['en', 'en', 'en'] | True |
test_password_success | (hass, hassio_client_supervisor) | Test no auth needed for . | Test no auth needed for . | async def test_password_success(hass, hassio_client_supervisor):
"""Test no auth needed for ."""
with patch(
"homeassistant.auth.providers.homeassistant."
"HassAuthProvider.async_change_password",
) as mock_change:
resp = await hassio_client_supervisor.post(
"/api/hassio_... | [
"async",
"def",
"test_password_success",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.auth.providers.homeassistant.\"",
"\"HassAuthProvider.async_change_password\"",
",",
")",
"as",
"mock_change",
":",
"resp",
"=",
"await",
... | [
123,
0
] | [
136,
56
] | python | en | ['en', 'en', 'en'] | True |
test_password_fails_no_supervisor | (hass, hassio_client) | Test if only supervisor can access. | Test if only supervisor can access. | async def test_password_fails_no_supervisor(hass, hassio_client):
"""Test if only supervisor can access."""
resp = await hassio_client.post(
"/api/hassio_auth/password_reset",
json={"username": "test", "password": "123456"},
)
# Check we got right response
assert resp.status == 401 | [
"async",
"def",
"test_password_fails_no_supervisor",
"(",
"hass",
",",
"hassio_client",
")",
":",
"resp",
"=",
"await",
"hassio_client",
".",
"post",
"(",
"\"/api/hassio_auth/password_reset\"",
",",
"json",
"=",
"{",
"\"username\"",
":",
"\"test\"",
",",
"\"password... | [
139,
0
] | [
147,
29
] | python | en | ['en', 'en', 'en'] | True |
test_password_fails_no_auth | (hass, hassio_noauth_client) | Test if only supervisor can access. | Test if only supervisor can access. | async def test_password_fails_no_auth(hass, hassio_noauth_client):
"""Test if only supervisor can access."""
resp = await hassio_noauth_client.post(
"/api/hassio_auth/password_reset",
json={"username": "test", "password": "123456"},
)
# Check we got right response
assert resp.status... | [
"async",
"def",
"test_password_fails_no_auth",
"(",
"hass",
",",
"hassio_noauth_client",
")",
":",
"resp",
"=",
"await",
"hassio_noauth_client",
".",
"post",
"(",
"\"/api/hassio_auth/password_reset\"",
",",
"json",
"=",
"{",
"\"username\"",
":",
"\"test\"",
",",
"\"... | [
150,
0
] | [
158,
29
] | python | en | ['en', 'en', 'en'] | True |
test_password_no_user | (hass, hassio_client_supervisor) | Test changing password for invalid user. | Test changing password for invalid user. | async def test_password_no_user(hass, hassio_client_supervisor):
"""Test changing password for invalid user."""
resp = await hassio_client_supervisor.post(
"/api/hassio_auth/password_reset",
json={"username": "test", "password": "123456"},
)
# Check we got right response
assert resp... | [
"async",
"def",
"test_password_no_user",
"(",
"hass",
",",
"hassio_client_supervisor",
")",
":",
"resp",
"=",
"await",
"hassio_client_supervisor",
".",
"post",
"(",
"\"/api/hassio_auth/password_reset\"",
",",
"json",
"=",
"{",
"\"username\"",
":",
"\"test\"",
",",
"... | [
161,
0
] | [
169,
29
] | python | en | ['en', 'en', 'en'] | True |
add_newline_to_end_of_each_sentence | (x: str) | This was added to get rougeLsum scores matching published rougeL scores for BART and PEGASUS. | This was added to get rougeLsum scores matching published rougeL scores for BART and PEGASUS. | def add_newline_to_end_of_each_sentence(x: str) -> str:
"""This was added to get rougeLsum scores matching published rougeL scores for BART and PEGASUS."""
re.sub("<n>", "", x) # remove pegasus newline char
assert NLTK_AVAILABLE, "nltk must be installed to separate newlines between sentences. (pip install ... | [
"def",
"add_newline_to_end_of_each_sentence",
"(",
"x",
":",
"str",
")",
"->",
"str",
":",
"re",
".",
"sub",
"(",
"\"<n>\"",
",",
"\"\"",
",",
"x",
")",
"# remove pegasus newline char",
"assert",
"NLTK_AVAILABLE",
",",
"\"nltk must be installed to separate newlines be... | [
17,
0
] | [
21,
43
] | python | en | ['en', 'en', 'en'] | True |
get_model_file | (name, root=os.path.join('~', '.insightface', 'models')) | r"""Return location for the pretrained on local file system.
This function will download from online model zoo when model cannot be found or has mismatch.
The root directory will be created if it doesn't exist.
Parameters
----------
name : str
Name of the model.
root : str, default '~/... | r"""Return location for the pretrained on local file system. | def get_model_file(name, root=os.path.join('~', '.insightface', 'models')):
r"""Return location for the pretrained on local file system.
This function will download from online model zoo when model cannot be found or has mismatch.
The root directory will be created if it doesn't exist.
Parameters
... | [
"def",
"get_model_file",
"(",
"name",
",",
"root",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'~'",
",",
"'.insightface'",
",",
"'models'",
")",
")",
":",
"file_name",
"=",
"name",
"root",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"root",
")",
... | [
41,
0
] | [
94,
81
] | python | en | ['en', 'en', 'en'] | True |
_get_question_end_index | (input_ids, sep_token_id) |
Computes the index of the first occurance of `sep_token_id`.
|
Computes the index of the first occurance of `sep_token_id`.
| def _get_question_end_index(input_ids, sep_token_id):
"""
Computes the index of the first occurance of `sep_token_id`.
"""
sep_token_indices = (input_ids == sep_token_id).nonzero()
batch_size = input_ids.shape[0]
assert sep_token_indices.shape[1] == 2, "`input_ids` should have two dimensions"
... | [
"def",
"_get_question_end_index",
"(",
"input_ids",
",",
"sep_token_id",
")",
":",
"sep_token_indices",
"=",
"(",
"input_ids",
"==",
"sep_token_id",
")",
".",
"nonzero",
"(",
")",
"batch_size",
"=",
"input_ids",
".",
"shape",
"[",
"0",
"]",
"assert",
"sep_toke... | [
393,
0
] | [
405,
60
] | python | en | ['en', 'error', 'th'] | False |
_compute_global_attention_mask | (input_ids, sep_token_id, before_sep_token=True) |
Computes global attention mask by putting attention on all tokens before `sep_token_id` if `before_sep_token is
True` else after `sep_token_id`.
|
Computes global attention mask by putting attention on all tokens before `sep_token_id` if `before_sep_token is
True` else after `sep_token_id`.
| def _compute_global_attention_mask(input_ids, sep_token_id, before_sep_token=True):
"""
Computes global attention mask by putting attention on all tokens before `sep_token_id` if `before_sep_token is
True` else after `sep_token_id`.
"""
question_end_index = _get_question_end_index(input_ids, sep_tok... | [
"def",
"_compute_global_attention_mask",
"(",
"input_ids",
",",
"sep_token_id",
",",
"before_sep_token",
"=",
"True",
")",
":",
"question_end_index",
"=",
"_get_question_end_index",
"(",
"input_ids",
",",
"sep_token_id",
")",
"question_end_index",
"=",
"question_end_index... | [
408,
0
] | [
425,
25
] | python | en | ['en', 'error', 'th'] | False |
create_position_ids_from_input_ids | (input_ids, padding_idx) |
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`.
Args:
x: torch.Tensor x:
Returns: torch.Tensor
|
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`. | def create_position_ids_from_input_ids(input_ids, padding_idx):
"""
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`.
Args:
x: torch.Tensor x:
Returns: torch... | [
"def",
"create_position_ids_from_input_ids",
"(",
"input_ids",
",",
"padding_idx",
")",
":",
"# The series of casts and type-conversions here are carefully balanced to both work with ONNX export and XLA.",
"mask",
"=",
"input_ids",
".",
"ne",
"(",
"padding_idx",
")",
".",
"int",
... | [
428,
0
] | [
441,
51
] | python | en | ['en', 'error', 'th'] | False |
LongformerEmbeddings.create_position_ids_from_inputs_embeds | (self, inputs_embeds) |
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
Args:
inputs_embeds: torch.Tensor inputs_embeds:
Returns: torch.Tensor
|
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids. | def create_position_ids_from_inputs_embeds(self, inputs_embeds):
"""
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.
Args:
inputs_embeds: torch.Tensor inputs_embeds:
Returns: torch.Tensor
"""
in... | [
"def",
"create_position_ids_from_inputs_embeds",
"(",
"self",
",",
"inputs_embeds",
")",
":",
"input_shape",
"=",
"inputs_embeds",
".",
"size",
"(",
")",
"[",
":",
"-",
"1",
"]",
"sequence_length",
"=",
"input_shape",
"[",
"1",
"]",
"position_ids",
"=",
"torch... | [
500,
4
] | [
515,
60
] | python | en | ['en', 'error', 'th'] | False |
LongformerSelfAttention.forward | (
self,
hidden_states,
attention_mask=None,
layer_head_mask=None,
is_index_masked=None,
is_index_global_attn=None,
is_global_attn=None,
output_attentions=False,
) |
:class:`LongformerSelfAttention` expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in :meth:`LongformerModel.forward` to avoid redoing the padding on each layer.
The `attention_mask` is changed in :meth:`LongformerModel.forward` from 0, 1,... |
:class:`LongformerSelfAttention` expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in :meth:`LongformerModel.forward` to avoid redoing the padding on each layer. | def forward(
self,
hidden_states,
attention_mask=None,
layer_head_mask=None,
is_index_masked=None,
is_index_global_attn=None,
is_global_attn=None,
output_attentions=False,
):
"""
:class:`LongformerSelfAttention` expects `len(hidden_stat... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
",",
"attention_mask",
"=",
"None",
",",
"layer_head_mask",
"=",
"None",
",",
"is_index_masked",
"=",
"None",
",",
"is_index_global_attn",
"=",
"None",
",",
"is_global_attn",
"=",
"None",
",",
"output_attentio... | [
552,
4
] | [
713,
100
] | python | en | ['en', 'error', 'th'] | False |
LongformerSelfAttention._pad_and_transpose_last_two_dims | (hidden_states_padded, padding) | pads rows and then flips rows and columns | pads rows and then flips rows and columns | def _pad_and_transpose_last_two_dims(hidden_states_padded, padding):
"""pads rows and then flips rows and columns"""
hidden_states_padded = F.pad(
hidden_states_padded, padding
) # padding value is not important because it will be overwritten
hidden_states_padded = hidden_st... | [
"def",
"_pad_and_transpose_last_two_dims",
"(",
"hidden_states_padded",
",",
"padding",
")",
":",
"hidden_states_padded",
"=",
"F",
".",
"pad",
"(",
"hidden_states_padded",
",",
"padding",
")",
"# padding value is not important because it will be overwritten",
"hidden_states_pa... | [
716,
4
] | [
724,
35
] | python | en | ['en', 'en', 'en'] | True |
LongformerSelfAttention._pad_and_diagonalize | (chunked_hidden_states) |
shift every row 1 step right, converting columns into diagonals.
Example::
chunked_hidden_states: [ 0.4983, 2.6918, -0.0071, 1.0492,
-1.8348, 0.7672, 0.2986, 0.0285,
-0.7584, 0.4206, -0.0405, 0.1599,
... |
shift every row 1 step right, converting columns into diagonals. | def _pad_and_diagonalize(chunked_hidden_states):
"""
shift every row 1 step right, converting columns into diagonals.
Example::
chunked_hidden_states: [ 0.4983, 2.6918, -0.0071, 1.0492,
-1.8348, 0.7672, 0.2986, 0.0285,
... | [
"def",
"_pad_and_diagonalize",
"(",
"chunked_hidden_states",
")",
":",
"total_num_heads",
",",
"num_chunks",
",",
"window_overlap",
",",
"hidden_dim",
"=",
"chunked_hidden_states",
".",
"size",
"(",
")",
"chunked_hidden_states",
"=",
"F",
".",
"pad",
"(",
"chunked_h... | [
727,
4
] | [
758,
36
] | python | en | ['en', 'error', 'th'] | False |
LongformerSelfAttention._chunk | (hidden_states, window_overlap) | convert into overlapping chunks. Chunk size = 2w, overlap size = w | convert into overlapping chunks. Chunk size = 2w, overlap size = w | def _chunk(hidden_states, window_overlap):
"""convert into overlapping chunks. Chunk size = 2w, overlap size = w"""
# non-overlapping chunks of size = 2w
hidden_states = hidden_states.view(
hidden_states.size(0),
hidden_states.size(1) // (window_overlap * 2),
... | [
"def",
"_chunk",
"(",
"hidden_states",
",",
"window_overlap",
")",
":",
"# non-overlapping chunks of size = 2w",
"hidden_states",
"=",
"hidden_states",
".",
"view",
"(",
"hidden_states",
".",
"size",
"(",
"0",
")",
",",
"hidden_states",
".",
"size",
"(",
"1",
")... | [
761,
4
] | [
778,
77
] | python | en | ['en', 'en', 'en'] | True |
LongformerSelfAttention._sliding_chunks_query_key_matmul | (self, query: torch.Tensor, key: torch.Tensor, window_overlap: int) |
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
overlap of size window_overlap
|
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
overlap of size window_overlap
| def _sliding_chunks_query_key_matmul(self, query: torch.Tensor, key: torch.Tensor, window_overlap: int):
"""
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrai... | [
"def",
"_sliding_chunks_query_key_matmul",
"(",
"self",
",",
"query",
":",
"torch",
".",
"Tensor",
",",
"key",
":",
"torch",
".",
"Tensor",
",",
"window_overlap",
":",
"int",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_dim",
"=",
"... | [
792,
4
] | [
856,
40
] | python | en | ['en', 'error', 'th'] | False |
LongformerSelfAttention._sliding_chunks_matmul_attn_probs_value | (
self, attn_probs: torch.Tensor, value: torch.Tensor, window_overlap: int
) |
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
|
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
| def _sliding_chunks_matmul_attn_probs_value(
self, attn_probs: torch.Tensor, value: torch.Tensor, window_overlap: int
):
"""
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
"""
ba... | [
"def",
"_sliding_chunks_matmul_attn_probs_value",
"(",
"self",
",",
"attn_probs",
":",
"torch",
".",
"Tensor",
",",
"value",
":",
"torch",
".",
"Tensor",
",",
"window_overlap",
":",
"int",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_di... | [
858,
4
] | [
897,
85
] | python | en | ['en', 'error', 'th'] | False |
LongformerSelfAttention._get_global_attn_indices | (is_index_global_attn) | compute global attn indices required throughout forward pass | compute global attn indices required throughout forward pass | def _get_global_attn_indices(is_index_global_attn):
""" compute global attn indices required throughout forward pass """
# helper variable
num_global_attn_indices = is_index_global_attn.long().sum(dim=1)
# max number of global attn indices in batch
max_num_global_attn_indices = ... | [
"def",
"_get_global_attn_indices",
"(",
"is_index_global_attn",
")",
":",
"# helper variable",
"num_global_attn_indices",
"=",
"is_index_global_attn",
".",
"long",
"(",
")",
".",
"sum",
"(",
"dim",
"=",
"1",
")",
"# max number of global attn indices in batch",
"max_num_gl... | [
900,
4
] | [
926,
9
] | python | en | ['en', 'en', 'en'] | True |
LongformerPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
1364,
4
] | [
1378,
41
] | python | en | ['en', 'en', 'en'] | True |
test_registration | (hass, hass_client, hass_admin_user) | Test that registrations happen. | Test that registrations happen. | async def test_registration(hass, hass_client, hass_admin_user):
"""Test that registrations happen."""
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
api_client = await hass_client()
with patch(
"homeassistant.components.person.async_add_user_device_tracker",
spec=True,
... | [
"async",
"def",
"test_registration",
"(",
"hass",
",",
"hass_client",
",",
"hass_admin_user",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"}",
"}",
")",
"api_client",
"=",
"await",
"hass_client",
"(",... | [
15,
0
] | [
55,
5
] | python | en | ['en', 'fr', 'en'] | True |
test_registration_encryption | (hass, hass_client) | Test that registrations happen. | Test that registrations happen. | async def test_registration_encryption(hass, hass_client):
"""Test that registrations happen."""
try:
from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed")
return
await a... | [
"async",
"def",
"test_registration_encryption",
"(",
"hass",
",",
"hass_client",
")",
":",
"try",
":",
"from",
"nacl",
".",
"encoding",
"import",
"Base64Encoder",
"from",
"nacl",
".",
"secret",
"import",
"SecretBox",
"except",
"(",
"ImportError",
",",
"OSError",... | [
58,
0
] | [
101,
63
] | python | en | ['en', 'fr', 'en'] | True |
_create_abort_data | (
flow_id: str,
handler: str,
reason: str,
description_placeholders: Optional[Dict] = None,
) | Return the definition of an external step for the user to take. | Return the definition of an external step for the user to take. | def _create_abort_data(
flow_id: str,
handler: str,
reason: str,
description_placeholders: Optional[Dict] = None,
) -> Dict[str, Any]:
"""Return the definition of an external step for the user to take."""
return {
"type": RESULT_TYPE_ABORT,
"flow_id": flow_id,
"handler": ... | [
"def",
"_create_abort_data",
"(",
"flow_id",
":",
"str",
",",
"handler",
":",
"str",
",",
"reason",
":",
"str",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
... | [
396,
0
] | [
409,
5
] | python | en | ['en', 'en', 'en'] | True |
AbortFlow.__init__ | (self, reason: str, description_placeholders: Optional[Dict] = None) | Initialize an abort flow exception. | Initialize an abort flow exception. | def __init__(self, reason: str, description_placeholders: Optional[Dict] = None):
"""Initialize an abort flow exception."""
super().__init__(f"Flow aborted: {reason}")
self.reason = reason
self.description_placeholders = description_placeholders | [
"def",
"__init__",
"(",
"self",
",",
"reason",
":",
"str",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"f\"Flow aborted: {reason}\"",
")",
"self",
".",
"reason",
"=",
... | [
42,
4
] | [
46,
64
] | python | en | ['en', 'en', 'en'] | True |
FlowManager.__init__ | (
self,
hass: HomeAssistant,
) | Initialize the flow manager. | Initialize the flow manager. | def __init__(
self,
hass: HomeAssistant,
) -> None:
"""Initialize the flow manager."""
self.hass = hass
self._initializing: Dict[str, List[asyncio.Future]] = {}
self._progress: Dict[str, Any] = {} | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_initializing",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"asyncio",
".",
"Future",
"]",
"]",
"=",
"{",... | [
52,
4
] | [
59,
43
] | python | en | ['en', 'en', 'en'] | True |
FlowManager.async_wait_init_flow_finish | (self, handler: str) | Wait till all flows in progress are initialized. | Wait till all flows in progress are initialized. | async def async_wait_init_flow_finish(self, handler: str) -> None:
"""Wait till all flows in progress are initialized."""
current = self._initializing.get(handler)
if not current:
return
await asyncio.wait(current) | [
"async",
"def",
"async_wait_init_flow_finish",
"(",
"self",
",",
"handler",
":",
"str",
")",
"->",
"None",
":",
"current",
"=",
"self",
".",
"_initializing",
".",
"get",
"(",
"handler",
")",
"if",
"not",
"current",
":",
"return",
"await",
"asyncio",
".",
... | [
61,
4
] | [
68,
35
] | python | en | ['en', 'en', 'en'] | True |
FlowManager.async_create_flow | (
self,
handler_key: Any,
*,
context: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
) | Create a flow for specified handler.
Handler key is the domain of the component that we want to set up.
| Create a flow for specified handler. | async def async_create_flow(
self,
handler_key: Any,
*,
context: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
) -> "FlowHandler":
"""Create a flow for specified handler.
Handler key is the domain of the component that we want to set... | [
"async",
"def",
"async_create_flow",
"(",
"self",
",",
"handler_key",
":",
"Any",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"data",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"An... | [
71,
4
] | [
81,
11
] | python | en | ['en', 'en', 'en'] | True |
FlowManager.async_finish_flow | (
self, flow: "FlowHandler", result: Dict[str, Any]
) | Finish a config flow and add an entry. | Finish a config flow and add an entry. | async def async_finish_flow(
self, flow: "FlowHandler", result: Dict[str, Any]
) -> Dict[str, Any]:
"""Finish a config flow and add an entry.""" | [
"async",
"def",
"async_finish_flow",
"(",
"self",
",",
"flow",
":",
"\"FlowHandler\"",
",",
"result",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":"
] | [
84,
4
] | [
87,
52
] | python | en | ['en', 'en', 'en'] | True |
FlowManager.async_post_init | (
self, flow: "FlowHandler", result: Dict[str, Any]
) | Entry has finished executing its first step asynchronously. | Entry has finished executing its first step asynchronously. | async def async_post_init(
self, flow: "FlowHandler", result: Dict[str, Any]
) -> None:
"""Entry has finished executing its first step asynchronously.""" | [
"async",
"def",
"async_post_init",
"(",
"self",
",",
"flow",
":",
"\"FlowHandler\"",
",",
"result",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":"
] | [
89,
4
] | [
92,
73
] | python | en | ['en', 'en', 'en'] | True |
FlowManager.async_progress | (self) | Return the flows in progress. | Return the flows in progress. | def async_progress(self) -> List[Dict]:
"""Return the flows in progress."""
return [
{
"flow_id": flow.flow_id,
"handler": flow.handler,
"context": flow.context,
"step_id": flow.cur_step["step_id"],
}
for... | [
"def",
"async_progress",
"(",
"self",
")",
"->",
"List",
"[",
"Dict",
"]",
":",
"return",
"[",
"{",
"\"flow_id\"",
":",
"flow",
".",
"flow_id",
",",
"\"handler\"",
":",
"flow",
".",
"handler",
",",
"\"context\"",
":",
"flow",
".",
"context",
",",
"\"st... | [
95,
4
] | [
106,
9
] | python | en | ['en', 'fy', 'en'] | True |
FlowManager.async_init | (
self, handler: str, *, context: Optional[Dict] = None, data: Any = None
) | Start a configuration flow. | Start a configuration flow. | async def async_init(
self, handler: str, *, context: Optional[Dict] = None, data: Any = None
) -> Any:
"""Start a configuration flow."""
if context is None:
context = {}
init_done: asyncio.Future = asyncio.Future()
self._initializing.setdefault(handler, []).appe... | [
"async",
"def",
"async_init",
"(",
"self",
",",
"handler",
":",
"str",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"data",
":",
"Any",
"=",
"None",
")",
"->",
"Any",
":",
"if",
"context",
"is",
"None",
":",
"con... | [
108,
4
] | [
138,
21
] | python | en | ['es', 'fr', 'en'] | False |
FlowManager.async_configure | (
self, flow_id: str, user_input: Optional[Dict] = None
) | Continue a configuration flow. | Continue a configuration flow. | async def async_configure(
self, flow_id: str, user_input: Optional[Dict] = None
) -> Any:
"""Continue a configuration flow."""
flow = self._progress.get(flow_id)
if flow is None:
raise UnknownFlow
cur_step = flow.cur_step
if cur_step.get("data_schema")... | [
"async",
"def",
"async_configure",
"(",
"self",
",",
"flow_id",
":",
"str",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Any",
":",
"flow",
"=",
"self",
".",
"_progress",
".",
"get",
"(",
"flow_id",
")",
"if",
"flow"... | [
140,
4
] | [
185,
21
] | python | en | ['pt', 'fr', 'en'] | False |
FlowManager.async_abort | (self, flow_id: str) | Abort a flow. | Abort a flow. | def async_abort(self, flow_id: str) -> None:
"""Abort a flow."""
if self._progress.pop(flow_id, None) is None:
raise UnknownFlow | [
"def",
"async_abort",
"(",
"self",
",",
"flow_id",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"_progress",
".",
"pop",
"(",
"flow_id",
",",
"None",
")",
"is",
"None",
":",
"raise",
"UnknownFlow"
] | [
188,
4
] | [
191,
29
] | python | en | ['en', 'de', 'en'] | True |
FlowManager._async_handle_step | (
self,
flow: Any,
step_id: str,
user_input: Optional[Dict],
step_done: Optional[asyncio.Future] = None,
) | Handle a step of a flow. | Handle a step of a flow. | async def _async_handle_step(
self,
flow: Any,
step_id: str,
user_input: Optional[Dict],
step_done: Optional[asyncio.Future] = None,
) -> Dict:
"""Handle a step of a flow."""
method = f"async_step_{step_id}"
if not hasattr(flow, method):
s... | [
"async",
"def",
"_async_handle_step",
"(",
"self",
",",
"flow",
":",
"Any",
",",
"step_id",
":",
"str",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"]",
",",
"step_done",
":",
"Optional",
"[",
"asyncio",
".",
"Future",
"]",
"=",
"None",
",",
")",
... | [
193,
4
] | [
257,
21
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.source | (self) | Source that initialized the flow. | Source that initialized the flow. | def source(self) -> Optional[str]:
"""Source that initialized the flow."""
if not hasattr(self, "context"):
return None
return self.context.get("source", None) | [
"def",
"source",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"context\"",
")",
":",
"return",
"None",
"return",
"self",
".",
"context",
".",
"get",
"(",
"\"source\"",
",",
"None",
")"
] | [
277,
4
] | [
282,
47
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.show_advanced_options | (self) | If we should show advanced options. | If we should show advanced options. | def show_advanced_options(self) -> bool:
"""If we should show advanced options."""
if not hasattr(self, "context"):
return False
return self.context.get("show_advanced_options", False) | [
"def",
"show_advanced_options",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"context\"",
")",
":",
"return",
"False",
"return",
"self",
".",
"context",
".",
"get",
"(",
"\"show_advanced_options\"",
",",
"False",
")"
] | [
285,
4
] | [
290,
63
] | python | en | ['en', 'bg', 'en'] | True |
FlowHandler.async_show_form | (
self,
*,
step_id: str,
data_schema: vol.Schema = None,
errors: Optional[Dict] = None,
description_placeholders: Optional[Dict] = None,
) | Return the definition of a form to gather user input. | Return the definition of a form to gather user input. | def async_show_form(
self,
*,
step_id: str,
data_schema: vol.Schema = None,
errors: Optional[Dict] = None,
description_placeholders: Optional[Dict] = None,
) -> Dict[str, Any]:
"""Return the definition of a form to gather user input."""
return {
... | [
"def",
"async_show_form",
"(",
"self",
",",
"*",
",",
"step_id",
":",
"str",
",",
"data_schema",
":",
"vol",
".",
"Schema",
"=",
"None",
",",
"errors",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"description_placeholders",
":",
"Optional",
"[",... | [
293,
4
] | [
310,
9
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_create_entry | (
self,
*,
title: str,
data: Dict,
description: Optional[str] = None,
description_placeholders: Optional[Dict] = None,
) | Finish config flow and create a config entry. | Finish config flow and create a config entry. | def async_create_entry(
self,
*,
title: str,
data: Dict,
description: Optional[str] = None,
description_placeholders: Optional[Dict] = None,
) -> Dict[str, Any]:
"""Finish config flow and create a config entry."""
return {
"version": self.V... | [
"def",
"async_create_entry",
"(",
"self",
",",
"*",
",",
"title",
":",
"str",
",",
"data",
":",
"Dict",
",",
"description",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
... | [
313,
4
] | [
331,
9
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_abort | (
self, *, reason: str, description_placeholders: Optional[Dict] = None
) | Abort the config flow. | Abort the config flow. | def async_abort(
self, *, reason: str, description_placeholders: Optional[Dict] = None
) -> Dict[str, Any]:
"""Abort the config flow."""
return _create_abort_data(
self.flow_id, cast(str, self.handler), reason, description_placeholders
) | [
"def",
"async_abort",
"(",
"self",
",",
"*",
",",
"reason",
":",
"str",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"_create_abort_data",
"(",
"self",
"... | [
334,
4
] | [
340,
9
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_external_step | (
self, *, step_id: str, url: str, description_placeholders: Optional[Dict] = None
) | Return the definition of an external step for the user to take. | Return the definition of an external step for the user to take. | def async_external_step(
self, *, step_id: str, url: str, description_placeholders: Optional[Dict] = None
) -> Dict[str, Any]:
"""Return the definition of an external step for the user to take."""
return {
"type": RESULT_TYPE_EXTERNAL_STEP,
"flow_id": self.flow_id,
... | [
"def",
"async_external_step",
"(",
"self",
",",
"*",
",",
"step_id",
":",
"str",
",",
"url",
":",
"str",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"... | [
343,
4
] | [
354,
9
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_external_step_done | (self, *, next_step_id: str) | Return the definition of an external step for the user to take. | Return the definition of an external step for the user to take. | def async_external_step_done(self, *, next_step_id: str) -> Dict[str, Any]:
"""Return the definition of an external step for the user to take."""
return {
"type": RESULT_TYPE_EXTERNAL_STEP_DONE,
"flow_id": self.flow_id,
"handler": self.handler,
"step_id": ... | [
"def",
"async_external_step_done",
"(",
"self",
",",
"*",
",",
"next_step_id",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"type\"",
":",
"RESULT_TYPE_EXTERNAL_STEP_DONE",
",",
"\"flow_id\"",
":",
"self",
".",
"flow_id",... | [
357,
4
] | [
364,
9
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_show_progress | (
self,
*,
step_id: str,
progress_action: str,
description_placeholders: Optional[Dict] = None,
) | Show a progress message to the user, without user input allowed. | Show a progress message to the user, without user input allowed. | def async_show_progress(
self,
*,
step_id: str,
progress_action: str,
description_placeholders: Optional[Dict] = None,
) -> Dict[str, Any]:
"""Show a progress message to the user, without user input allowed."""
return {
"type": RESULT_TYPE_SHOW_PRO... | [
"def",
"async_show_progress",
"(",
"self",
",",
"*",
",",
"step_id",
":",
"str",
",",
"progress_action",
":",
"str",
",",
"description_placeholders",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
"... | [
367,
4
] | [
382,
9
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_show_progress_done | (self, *, next_step_id: str) | Mark the progress done. | Mark the progress done. | def async_show_progress_done(self, *, next_step_id: str) -> Dict[str, Any]:
"""Mark the progress done."""
return {
"type": RESULT_TYPE_SHOW_PROGRESS_DONE,
"flow_id": self.flow_id,
"handler": self.handler,
"step_id": next_step_id,
} | [
"def",
"async_show_progress_done",
"(",
"self",
",",
"*",
",",
"next_step_id",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"type\"",
":",
"RESULT_TYPE_SHOW_PROGRESS_DONE",
",",
"\"flow_id\"",
":",
"self",
".",
"flow_id",... | [
385,
4
] | [
392,
9
] | python | en | ['en', 'mg', 'en'] | True |
setup | (hass, config) | Set up the Xiaomi component. | Set up the Xiaomi component. | def setup(hass, config):
"""Set up the Xiaomi component."""
def play_ringtone_service(call):
"""Service to play ringtone through Gateway."""
ring_id = call.data.get(ATTR_RINGTONE_ID)
gateway = call.data.get(ATTR_GW_MAC)
kwargs = {"mid": ring_id}
ring_vol = call.data.ge... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"def",
"play_ringtone_service",
"(",
"call",
")",
":",
"\"\"\"Service to play ringtone through Gateway.\"\"\"",
"ring_id",
"=",
"call",
".",
"data",
".",
"get",
"(",
"ATTR_RINGTONE_ID",
")",
"gateway",
"=",
"... | [
69,
0
] | [
130,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
) | Set up the xiaomi aqara components from a config entry. | Set up the xiaomi aqara components from a config entry. | async def async_setup_entry(
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
):
"""Set up the xiaomi aqara components from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN].setdefault(GATEWAYS_KEY, {})
# Connect to Xiaomi Aqara Gateway
xiaomi_gateway = await hass... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"hass",
".",
"data",
"[",
... | [
133,
0
] | [
195,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
):
"""Unload a config entry."""
if entry.data[CONF_KEY] is not None:
platforms = GATEWAY_PLATFORMS
else:
platforms = GATEWAY_PLATFORMS_NO_KEY
unload_ok = all(
await asyncio.gather(
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"if",
"entry",
".",
"data",
"[",
"CONF_KEY",
"]",
"is",
"not",
"None",
":",
"platforms",
"=",
"GATEWAY_... | [
198,
0
] | [
225,
20
] | python | en | ['en', 'es', 'en'] | True |
_add_gateway_to_schema | (hass, schema) | Extend a voluptuous schema with a gateway validator. | Extend a voluptuous schema with a gateway validator. | def _add_gateway_to_schema(hass, schema):
"""Extend a voluptuous schema with a gateway validator."""
def gateway(sid):
"""Convert sid to a gateway."""
sid = str(sid).replace(":", "").lower()
for gateway in hass.data[DOMAIN][GATEWAYS_KEY].values():
if gateway.sid == sid:
... | [
"def",
"_add_gateway_to_schema",
"(",
"hass",
",",
"schema",
")",
":",
"def",
"gateway",
"(",
"sid",
")",
":",
"\"\"\"Convert sid to a gateway.\"\"\"",
"sid",
"=",
"str",
"(",
"sid",
")",
".",
"replace",
"(",
"\":\"",
",",
"\"\"",
")",
".",
"lower",
"(",
... | [
378,
0
] | [
400,
72
] | python | en | ['en', 'de', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.