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_render_template_with_delayed_error | (hass, websocket_client, caplog) | Test a template with an error that only happens after a state change. | Test a template with an error that only happens after a state change. | async def test_render_template_with_delayed_error(hass, websocket_client, caplog):
"""Test a template with an error that only happens after a state change."""
hass.states.async_set("sensor.test", "on")
await hass.async_block_till_done()
template_str = """
{% if states.sensor.test.state %}
on
{% else... | [
"async",
"def",
"test_render_template_with_delayed_error",
"(",
"hass",
",",
"websocket_client",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.test\"",
",",
"\"on\"",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
... | [
542,
0
] | [
589,
45
] | python | en | ['en', 'en', 'en'] | True |
test_render_template_with_timeout | (hass, websocket_client, caplog) | Test a template that will timeout. | Test a template that will timeout. | async def test_render_template_with_timeout(hass, websocket_client, caplog):
"""Test a template that will timeout."""
slow_template_str = """
{% for var in range(1000) -%}
{% for var in range(1000) -%}
{{ var }}
{%- endfor %}
{%- endfor %}
"""
await websocket_client.send_json(
{
... | [
"async",
"def",
"test_render_template_with_timeout",
"(",
"hass",
",",
"websocket_client",
",",
"caplog",
")",
":",
"slow_template_str",
"=",
"\"\"\"\n{% for var in range(1000) -%}\n {% for var in range(1000) -%}\n {{ var }}\n {%- endfor %}\n{%- endfor %}\n\"\"\"",
"await",
"webso... | [
592,
0
] | [
618,
45
] | python | en | ['en', 'en', 'en'] | True |
test_render_template_returns_with_match_all | (hass, websocket_client) | Test that a template that would match with all entities still return success. | Test that a template that would match with all entities still return success. | async def test_render_template_returns_with_match_all(hass, websocket_client):
"""Test that a template that would match with all entities still return success."""
await websocket_client.send_json(
{"id": 5, "type": "render_template", "template": "State is: {{ 42 }}"}
)
msg = await websocket_cli... | [
"async",
"def",
"test_render_template_returns_with_match_all",
"(",
"hass",
",",
"websocket_client",
")",
":",
"await",
"websocket_client",
".",
"send_json",
"(",
"{",
"\"id\"",
":",
"5",
",",
"\"type\"",
":",
"\"render_template\"",
",",
"\"template\"",
":",
"\"Stat... | [
621,
0
] | [
630,
25
] | python | en | ['en', 'en', 'en'] | True |
test_manifest_list | (hass, websocket_client) | Test loading manifests. | Test loading manifests. | async def test_manifest_list(hass, websocket_client):
"""Test loading manifests."""
http = await async_get_integration(hass, "http")
websocket_api = await async_get_integration(hass, "websocket_api")
await websocket_client.send_json({"id": 5, "type": "manifest/list"})
msg = await websocket_client.... | [
"async",
"def",
"test_manifest_list",
"(",
"hass",
",",
"websocket_client",
")",
":",
"http",
"=",
"await",
"async_get_integration",
"(",
"hass",
",",
"\"http\"",
")",
"websocket_api",
"=",
"await",
"async_get_integration",
"(",
"hass",
",",
"\"websocket_api\"",
"... | [
633,
0
] | [
647,
5
] | python | en | ['en', 'da', 'en'] | True |
test_manifest_get | (hass, websocket_client) | Test getting a manifest. | Test getting a manifest. | async def test_manifest_get(hass, websocket_client):
"""Test getting a manifest."""
hue = await async_get_integration(hass, "hue")
await websocket_client.send_json(
{"id": 6, "type": "manifest/get", "integration": "hue"}
)
msg = await websocket_client.receive_json()
assert msg["id"] ==... | [
"async",
"def",
"test_manifest_get",
"(",
"hass",
",",
"websocket_client",
")",
":",
"hue",
"=",
"await",
"async_get_integration",
"(",
"hass",
",",
"\"hue\"",
")",
"await",
"websocket_client",
".",
"send_json",
"(",
"{",
"\"id\"",
":",
"6",
",",
"\"type\"",
... | [
650,
0
] | [
673,
46
] | python | en | ['en', 'cy', 'en'] | True |
test_entity_source_admin | (hass, websocket_client, hass_admin_user) | Check that we fetch sources correctly. | Check that we fetch sources correctly. | async def test_entity_source_admin(hass, websocket_client, hass_admin_user):
"""Check that we fetch sources correctly."""
platform = MockEntityPlatform(hass)
await platform.async_add_entities(
[MockEntity(name="Entity 1"), MockEntity(name="Entity 2")]
)
# Fetch all
await websocket_clie... | [
"async",
"def",
"test_entity_source_admin",
"(",
"hass",
",",
"websocket_client",
",",
"hass_admin_user",
")",
":",
"platform",
"=",
"MockEntityPlatform",
"(",
"hass",
")",
"await",
"platform",
".",
"async_add_entities",
"(",
"[",
"MockEntity",
"(",
"name",
"=",
... | [
676,
0
] | [
786,
57
] | python | en | ['en', 'en', 'en'] | True |
test_subscribe_trigger | (hass, websocket_client) | Test subscribing to a trigger. | Test subscribing to a trigger. | async def test_subscribe_trigger(hass, websocket_client):
"""Test subscribing to a trigger."""
init_count = sum(hass.bus.async_listeners().values())
await websocket_client.send_json(
{
"id": 5,
"type": "subscribe_trigger",
"trigger": {"platform": "event", "event_... | [
"async",
"def",
"test_subscribe_trigger",
"(",
"hass",
",",
"websocket_client",
")",
":",
"init_count",
"=",
"sum",
"(",
"hass",
".",
"bus",
".",
"async_listeners",
"(",
")",
".",
"values",
"(",
")",
")",
"await",
"websocket_client",
".",
"send_json",
"(",
... | [
789,
0
] | [
840,
65
] | python | en | ['en', 'en', 'en'] | True |
test_test_condition | (hass, websocket_client) | Test testing a condition. | Test testing a condition. | async def test_test_condition(hass, websocket_client):
"""Test testing a condition."""
hass.states.async_set("hello.world", "paulus")
await websocket_client.send_json(
{
"id": 5,
"type": "test_condition",
"condition": {
"condition": "state",
... | [
"async",
"def",
"test_test_condition",
"(",
"hass",
",",
"websocket_client",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"hello.world\"",
",",
"\"paulus\"",
")",
"await",
"websocket_client",
".",
"send_json",
"(",
"{",
"\"id\"",
":",
"5",
",",
... | [
843,
0
] | [
864,
42
] | python | en | ['en', 'en', 'en'] | True |
load_rocstories_dataset | (dataset_path) | Output a list of tuples(story, 1st continuation, 2nd continuation, label) | Output a list of tuples(story, 1st continuation, 2nd continuation, label) | def load_rocstories_dataset(dataset_path):
""" Output a list of tuples(story, 1st continuation, 2nd continuation, label) """
with open(dataset_path, encoding="utf_8") as f:
f = csv.reader(f)
output = []
next(f) # skip the first line
for line in tqdm(f):
output.append... | [
"def",
"load_rocstories_dataset",
"(",
"dataset_path",
")",
":",
"with",
"open",
"(",
"dataset_path",
",",
"encoding",
"=",
"\"utf_8\"",
")",
"as",
"f",
":",
"f",
"=",
"csv",
".",
"reader",
"(",
"f",
")",
"output",
"=",
"[",
"]",
"next",
"(",
"f",
")... | [
62,
0
] | [
70,
17
] | python | en | ['en', 'en', 'en'] | True |
pre_process_datasets | (encoded_datasets, input_len, cap_length, start_token, delimiter_token, clf_token) | Pre-process datasets containing lists of tuples(story, 1st continuation, 2nd continuation, label)
To Transformer inputs of shape (n_batch, n_alternative, length) comprising for each batch, continuation:
input_ids[batch, alternative, :] = [start_token] + story[:cap_length] + [delimiter_token] + cont1[:cap_lengt... | Pre-process datasets containing lists of tuples(story, 1st continuation, 2nd continuation, label) | def pre_process_datasets(encoded_datasets, input_len, cap_length, start_token, delimiter_token, clf_token):
"""Pre-process datasets containing lists of tuples(story, 1st continuation, 2nd continuation, label)
To Transformer inputs of shape (n_batch, n_alternative, length) comprising for each batch, continuatio... | [
"def",
"pre_process_datasets",
"(",
"encoded_datasets",
",",
"input_len",
",",
"cap_length",
",",
"start_token",
",",
"delimiter_token",
",",
"clf_token",
")",
":",
"tensor_datasets",
"=",
"[",
"]",
"for",
"dataset",
"in",
"encoded_datasets",
":",
"n_batch",
"=",
... | [
73,
0
] | [
101,
26
] | python | en | ['en', 'en', 'en'] | True |
mock_get_stations | () | Mock aioeafm.get_stations. | Mock aioeafm.get_stations. | def mock_get_stations():
"""Mock aioeafm.get_stations."""
with patch("homeassistant.components.eafm.config_flow.get_stations") as patched:
yield patched | [
"def",
"mock_get_stations",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.eafm.config_flow.get_stations\"",
")",
"as",
"patched",
":",
"yield",
"patched"
] | [
8,
0
] | [
11,
21
] | python | en | ['en', 'en', 'en'] | False |
mock_get_station | () | Mock aioeafm.get_station. | Mock aioeafm.get_station. | def mock_get_station():
"""Mock aioeafm.get_station."""
with patch("homeassistant.components.eafm.sensor.get_station") as patched:
yield patched | [
"def",
"mock_get_station",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.eafm.sensor.get_station\"",
")",
"as",
"patched",
":",
"yield",
"patched"
] | [
15,
0
] | [
18,
21
] | python | da | ['it', 'da', 'nl'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Connect to Sony projector using network. | Connect to Sony projector using network. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Connect to Sony projector using network."""
host = config[CONF_HOST]
name = config[CONF_NAME]
sdcp_connection = pysdcp.Projector(host)
# Sanity check the connection
try:
sdcp_connection.get_power()
except Conne... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"sdcp_connection",
"=",
"pysdcp",
".",
"Proj... | [
22,
0
] | [
37,
15
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.__init__ | (self, sdcp_connection, name) | Init of the Sony projector. | Init of the Sony projector. | def __init__(self, sdcp_connection, name):
"""Init of the Sony projector."""
self._sdcp = sdcp_connection
self._name = name
self._state = None
self._available = False
self._attributes = {} | [
"def",
"__init__",
"(",
"self",
",",
"sdcp_connection",
",",
"name",
")",
":",
"self",
".",
"_sdcp",
"=",
"sdcp_connection",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_available",
"=",
"False",
"self",
".",
"_... | [
43,
4
] | [
49,
29
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.available | (self) | Return if projector is available. | Return if projector is available. | def available(self):
"""Return if projector is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
52,
4
] | [
54,
30
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.name | (self) | Return name of the projector. | Return name of the projector. | def name(self):
"""Return name of the projector."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
57,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.is_on | (self) | Return if the projector is turned on. | Return if the projector is turned on. | def is_on(self):
"""Return if the projector is turned on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
62,
4
] | [
64,
26
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.state_attributes | (self) | Return state attributes. | Return state attributes. | def state_attributes(self):
"""Return state attributes."""
return self._attributes | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
67,
4
] | [
69,
31
] | python | en | ['en', 'co', 'en'] | True |
SonyProjector.update | (self) | Get the latest state from the projector. | Get the latest state from the projector. | def update(self):
"""Get the latest state from the projector."""
try:
self._state = self._sdcp.get_power()
self._available = True
except ConnectionRefusedError:
_LOGGER.error("Projector connection refused")
self._available = False | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_sdcp",
".",
"get_power",
"(",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"ConnectionRefusedError",
":",
"_LOGGER",
".",
"error",
"(",
"\"Projector ... | [
71,
4
] | [
78,
35
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.turn_on | (self, **kwargs) | Turn the projector on. | Turn the projector on. | def turn_on(self, **kwargs):
"""Turn the projector on."""
_LOGGER.debug("Powering on projector '%s'", self.name)
if self._sdcp.set_power(True):
_LOGGER.debug("Powered on successfully")
self._state = STATE_ON
else:
_LOGGER.error("Power on command was no... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Powering on projector '%s'\"",
",",
"self",
".",
"name",
")",
"if",
"self",
".",
"_sdcp",
".",
"set_power",
"(",
"True",
")",
":",
"_LOGGER",
".",
"debug... | [
80,
4
] | [
87,
64
] | python | en | ['en', 'en', 'en'] | True |
SonyProjector.turn_off | (self, **kwargs) | Turn the projector off. | Turn the projector off. | def turn_off(self, **kwargs):
"""Turn the projector off."""
_LOGGER.debug("Powering off projector '%s'", self.name)
if self._sdcp.set_power(False):
_LOGGER.debug("Powered off successfully")
self._state = STATE_OFF
else:
_LOGGER.error("Power off command... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Powering off projector '%s'\"",
",",
"self",
".",
"name",
")",
"if",
"self",
".",
"_sdcp",
".",
"set_power",
"(",
"False",
")",
":",
"_LOGGER",
".",
"de... | [
89,
4
] | [
96,
65
] | python | en | ['en', 'en', 'en'] | True |
test_http_handle_intent | (hass, hass_client, hass_admin_user) | Test handle intent via HTTP API. | Test handle intent via HTTP API. | async def test_http_handle_intent(hass, hass_client, hass_admin_user):
"""Test handle intent via HTTP API."""
class TestIntentHandler(intent.IntentHandler):
"""Test Intent Handler."""
intent_type = "OrderBeer"
async def async_handle(self, intent):
"""Handle the intent."""
... | [
"async",
"def",
"test_http_handle_intent",
"(",
"hass",
",",
"hass_client",
",",
"hass_admin_user",
")",
":",
"class",
"TestIntentHandler",
"(",
"intent",
".",
"IntentHandler",
")",
":",
"\"\"\"Test Intent Handler.\"\"\"",
"intent_type",
"=",
"\"OrderBeer\"",
"async",
... | [
11,
0
] | [
49,
5
] | python | en | ['en', 'pt', 'en'] | True |
test_cover_intents_loading | (hass) | Test Cover Intents Loading. | Test Cover Intents Loading. | async def test_cover_intents_loading(hass):
"""Test Cover Intents Loading."""
assert await async_setup_component(hass, "intent", {})
with pytest.raises(intent.UnknownIntent):
await intent.async_handle(
hass, "test", "HassOpenCover", {"name": {"value": "garage door"}}
)
asse... | [
"async",
"def",
"test_cover_intents_loading",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"intent\"",
",",
"{",
"}",
")",
"with",
"pytest",
".",
"raises",
"(",
"intent",
".",
"UnknownIntent",
")",
":",
"await",
"int... | [
52,
0
] | [
76,
58
] | python | en | ['en', 'en', 'it'] | True |
test_turn_on_intent | (hass) | Test HassTurnOn intent. | Test HassTurnOn intent. | async def test_turn_on_intent(hass):
"""Test HassTurnOn intent."""
result = await async_setup_component(hass, "homeassistant", {})
result = await async_setup_component(hass, "intent", {})
assert result
hass.states.async_set("light.test_light", "off")
calls = async_mock_service(hass, "light", SE... | [
"async",
"def",
"test_turn_on_intent",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"intent\"",
",",
"{",... | [
79,
0
] | [
98,
59
] | python | en | ['en', 'la', 'en'] | True |
test_turn_off_intent | (hass) | Test HassTurnOff intent. | Test HassTurnOff intent. | async def test_turn_off_intent(hass):
"""Test HassTurnOff intent."""
result = await async_setup_component(hass, "homeassistant", {})
result = await async_setup_component(hass, "intent", {})
assert result
hass.states.async_set("light.test_light", "on")
calls = async_mock_service(hass, "light", S... | [
"async",
"def",
"test_turn_off_intent",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"intent\"",
",",
"{"... | [
101,
0
] | [
120,
59
] | python | en | ['en', 'de', 'en'] | True |
test_toggle_intent | (hass) | Test HassToggle intent. | Test HassToggle intent. | async def test_toggle_intent(hass):
"""Test HassToggle intent."""
result = await async_setup_component(hass, "homeassistant", {})
result = await async_setup_component(hass, "intent", {})
assert result
hass.states.async_set("light.test_light", "off")
calls = async_mock_service(hass, "light", SER... | [
"async",
"def",
"test_toggle_intent",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"intent\"",
",",
"{",
... | [
123,
0
] | [
142,
59
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_multiple_intent | (hass) | Test HassTurnOn intent with multiple similar entities.
This tests that matching finds the proper entity among similar names.
| Test HassTurnOn intent with multiple similar entities. | async def test_turn_on_multiple_intent(hass):
"""Test HassTurnOn intent with multiple similar entities.
This tests that matching finds the proper entity among similar names.
"""
result = await async_setup_component(hass, "homeassistant", {})
result = await async_setup_component(hass, "intent", {})
... | [
"async",
"def",
"test_turn_on_multiple_intent",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"intent\"",
",... | [
145,
0
] | [
169,
62
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Add Brother entities from a config_entry. | Add Brother entities from a config_entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add Brother entities from a config_entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
sensors = []
device_info = {
"identifiers": {(DOMAIN, coordinator.data[ATTR_SERIAL])},
"name": coordinator.data[AT... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"sensors",
"=",
"[",
"]",
"device_info",
"=",
... | [
39,
0
] | [
56,
38
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.__init__ | (self, coordinator, kind, device_info) | Initialize. | Initialize. | def __init__(self, coordinator, kind, device_info):
"""Initialize."""
super().__init__(coordinator)
self._name = f"{coordinator.data[ATTR_MODEL]} {SENSOR_TYPES[kind][ATTR_LABEL]}"
self._unique_id = f"{coordinator.data[ATTR_SERIAL].lower()}_{kind}"
self._device_info = device_info
... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"kind",
",",
"device_info",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_name",
"=",
"f\"{coordinator.data[ATTR_MODEL]} {SENSOR_TYPES[kind][ATTR_LABEL]}\"",
"self",
"... | [
62,
4
] | [
69,
24
] | python | en | ['en', 'en', 'it'] | False |
BrotherPrinterSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
72,
4
] | [
74,
25
] | python | en | ['en', 'ig', 'en'] | True |
BrotherPrinterSensor.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
if self.kind == ATTR_UPTIME:
uptime = utcnow() - timedelta(seconds=self.coordinator.data.get(self.kind))
return uptime.replace(microsecond=0).isoformat()
return self.coordinator.data.get(self.kind) | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"kind",
"==",
"ATTR_UPTIME",
":",
"uptime",
"=",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"get",
"(",
"self",
".",
"kind",
")"... | [
77,
4
] | [
82,
51
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
if self.kind == ATTR_UPTIME:
return DEVICE_CLASS_TIMESTAMP
return None | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"kind",
"==",
"ATTR_UPTIME",
":",
"return",
"DEVICE_CLASS_TIMESTAMP",
"return",
"None"
] | [
85,
4
] | [
89,
19
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
remaining_pages = None
drum_counter = None
if self.kind == ATTR_DRUM_REMAINING_LIFE:
remaining_pages = ATTR_DRUM_REMAINING_PAGES
drum_counter = ATTR_DRUM_COUNTER
elif self.kind == ATTR_B... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"remaining_pages",
"=",
"None",
"drum_counter",
"=",
"None",
"if",
"self",
".",
"kind",
"==",
"ATTR_DRUM_REMAINING_LIFE",
":",
"remaining_pages",
"=",
"ATTR_DRUM_REMAINING_PAGES",
"drum_counter",
"=",
"ATTR_DRUM... | [
92,
4
] | [
116,
26
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
return SENSOR_TYPES[self.kind][ATTR_ICON] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"kind",
"]",
"[",
"ATTR_ICON",
"]"
] | [
119,
4
] | [
121,
49
] | python | en | ['en', 'sr', 'en'] | True |
BrotherPrinterSensor.unique_id | (self) | Return a unique_id for this entity. | Return a unique_id for this entity. | def unique_id(self):
"""Return a unique_id for this entity."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
124,
4
] | [
126,
30
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return SENSOR_TYPES[self.kind][ATTR_UNIT] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"kind",
"]",
"[",
"ATTR_UNIT",
"]"
] | [
129,
4
] | [
131,
49
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return self._device_info | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_info"
] | [
134,
4
] | [
136,
32
] | python | en | ['en', 'en', 'en'] | True |
BrotherPrinterSensor.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self):
"""Return if the entity should be enabled when first added to the entity registry."""
return True | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
":",
"return",
"True"
] | [
139,
4
] | [
141,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Gree HVAC device from a config entry. | Set up the Gree HVAC device from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Gree HVAC device from a config entry."""
async_add_entities(
GreeClimateEntity(device) for device in hass.data[DOMAIN].pop("pending")
) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async_add_entities",
"(",
"GreeClimateEntity",
"(",
"device",
")",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"... | [
100,
0
] | [
104,
5
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.__init__ | (self, device) | Initialize the Gree device. | Initialize the Gree device. | def __init__(self, device):
"""Initialize the Gree device."""
self._device = device
self._name = device.device_info.name
self._mac = device.device_info.mac
self._available = False
self._error_count = 0 | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_name",
"=",
"device",
".",
"device_info",
".",
"name",
"self",
".",
"_mac",
"=",
"device",
".",
"device_info",
".",
"mac",
"self",
".",
"_a... | [
110,
4
] | [
116,
29
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.async_update | (self) | Update the state of the device. | Update the state of the device. | async def async_update(self):
"""Update the state of the device."""
try:
await self._device.update_state()
if not self._available and self._error_count:
_LOGGER.warning(
"Device is available: %s (%s)",
self._name,
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"await",
"self",
".",
"_device",
".",
"update_state",
"(",
")",
"if",
"not",
"self",
".",
"_available",
"and",
"self",
".",
"_error_count",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Device ... | [
118,
4
] | [
151,
17
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity._push_state_update | (self) | Send state updates to the physical device. | Send state updates to the physical device. | async def _push_state_update(self):
"""Send state updates to the physical device."""
try:
return await self._device.push_state_update()
except DeviceTimeoutError:
self._error_count += 1
# Under normal conditions GREE units timeout every once in a while
... | [
"async",
"def",
"_push_state_update",
"(",
"self",
")",
":",
"try",
":",
"return",
"await",
"self",
".",
"_device",
".",
"push_state_update",
"(",
")",
"except",
"DeviceTimeoutError",
":",
"self",
".",
"_error_count",
"+=",
"1",
"# Under normal conditions GREE uni... | [
153,
4
] | [
176,
17
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.available | (self) | Return if the device is available. | Return if the device is available. | def available(self) -> bool:
"""Return if the device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
179,
4
] | [
181,
30
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self) -> str:
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
184,
4
] | [
186,
25
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.unique_id | (self) | Return a unique id for the device. | Return a unique id for the device. | def unique_id(self) -> str:
"""Return a unique id for the device."""
return self._mac | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac"
] | [
189,
4
] | [
191,
24
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.device_info | (self) | Return device specific attributes. | Return device specific attributes. | def device_info(self):
"""Return device specific attributes."""
return {
"name": self._name,
"identifiers": {(DOMAIN, self._mac)},
"manufacturer": "Gree",
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_mac",
")",
"}",
",",
"\"manufacturer\"",
":",
"\"Gree\"",
",",
"\"connections\"",
":",... | [
194,
4
] | [
201,
9
] | python | en | ['fr', 'it', 'en'] | False |
GreeClimateEntity.temperature_unit | (self) | Return the temperature units for the device. | Return the temperature units for the device. | def temperature_unit(self) -> str:
"""Return the temperature units for the device."""
units = self._device.temperature_units
return TEMP_CELSIUS if units == TemperatureUnits.C else TEMP_FAHRENHEIT | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"units",
"=",
"self",
".",
"_device",
".",
"temperature_units",
"return",
"TEMP_CELSIUS",
"if",
"units",
"==",
"TemperatureUnits",
".",
"C",
"else",
"TEMP_FAHRENHEIT"
] | [
204,
4
] | [
207,
79
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.precision | (self) | Return the precision of temperature for the device. | Return the precision of temperature for the device. | def precision(self) -> float:
"""Return the precision of temperature for the device."""
return PRECISION_WHOLE | [
"def",
"precision",
"(",
"self",
")",
"->",
"float",
":",
"return",
"PRECISION_WHOLE"
] | [
210,
4
] | [
212,
30
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.current_temperature | (self) | Return the target temperature, gree devices don't provide internal temp. | Return the target temperature, gree devices don't provide internal temp. | def current_temperature(self) -> float:
"""Return the target temperature, gree devices don't provide internal temp."""
return self.target_temperature | [
"def",
"current_temperature",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"target_temperature"
] | [
215,
4
] | [
217,
38
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.target_temperature | (self) | Return the target temperature for the device. | Return the target temperature for the device. | def target_temperature(self) -> float:
"""Return the target temperature for the device."""
return self._device.target_temperature | [
"def",
"target_temperature",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_device",
".",
"target_temperature"
] | [
220,
4
] | [
222,
46
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.async_set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | async def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
if ATTR_TEMPERATURE not in kwargs:
raise ValueError(f"Missing parameter {ATTR_TEMPERATURE}")
temperature = kwargs[ATTR_TEMPERATURE]
_LOGGER.debug(
"Setting temperature to %d for %s... | [
"async",
"def",
"async_set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_TEMPERATURE",
"not",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"f\"Missing parameter {ATTR_TEMPERATURE}\"",
")",
"temperature",
"=",
"kwargs",
"[",
"ATTR_TE... | [
224,
4
] | [
237,
39
] | python | en | ['en', 'ca', 'en'] | True |
GreeClimateEntity.min_temp | (self) | Return the minimum temperature supported by the device. | Return the minimum temperature supported by the device. | def min_temp(self) -> float:
"""Return the minimum temperature supported by the device."""
return MIN_TEMP | [
"def",
"min_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"MIN_TEMP"
] | [
240,
4
] | [
242,
23
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.max_temp | (self) | Return the maximum temperature supported by the device. | Return the maximum temperature supported by the device. | def max_temp(self) -> float:
"""Return the maximum temperature supported by the device."""
return MAX_TEMP | [
"def",
"max_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"MAX_TEMP"
] | [
245,
4
] | [
247,
23
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.target_temperature_step | (self) | Return the target temperature step support by the device. | Return the target temperature step support by the device. | def target_temperature_step(self) -> float:
"""Return the target temperature step support by the device."""
return TARGET_TEMPERATURE_STEP | [
"def",
"target_temperature_step",
"(",
"self",
")",
"->",
"float",
":",
"return",
"TARGET_TEMPERATURE_STEP"
] | [
250,
4
] | [
252,
38
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.hvac_mode | (self) | Return the current HVAC mode for the device. | Return the current HVAC mode for the device. | def hvac_mode(self) -> str:
"""Return the current HVAC mode for the device."""
if not self._device.power:
return HVAC_MODE_OFF
return HVAC_MODES.get(self._device.mode) | [
"def",
"hvac_mode",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"_device",
".",
"power",
":",
"return",
"HVAC_MODE_OFF",
"return",
"HVAC_MODES",
".",
"get",
"(",
"self",
".",
"_device",
".",
"mode",
")"
] | [
255,
4
] | [
260,
48
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.async_set_hvac_mode | (self, hvac_mode) | Set new target hvac mode. | Set new target hvac mode. | async def async_set_hvac_mode(self, hvac_mode):
"""Set new target hvac mode."""
if hvac_mode not in self.hvac_modes:
raise ValueError(f"Invalid hvac_mode: {hvac_mode}")
_LOGGER.debug(
"Setting HVAC mode to %s for device %s",
hvac_mode,
self._name,... | [
"async",
"def",
"async_set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"if",
"hvac_mode",
"not",
"in",
"self",
".",
"hvac_modes",
":",
"raise",
"ValueError",
"(",
"f\"Invalid hvac_mode: {hvac_mode}\"",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Setting HVAC mo... | [
262,
4
] | [
282,
39
] | python | da | ['da', 'su', 'en'] | False |
GreeClimateEntity.hvac_modes | (self) | Return the HVAC modes support by the device. | Return the HVAC modes support by the device. | def hvac_modes(self) -> List[str]:
"""Return the HVAC modes support by the device."""
modes = [*HVAC_MODES_REVERSE]
modes.append(HVAC_MODE_OFF)
return modes | [
"def",
"hvac_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"modes",
"=",
"[",
"*",
"HVAC_MODES_REVERSE",
"]",
"modes",
".",
"append",
"(",
"HVAC_MODE_OFF",
")",
"return",
"modes"
] | [
285,
4
] | [
289,
20
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.preset_mode | (self) | Return the current preset mode for the device. | Return the current preset mode for the device. | def preset_mode(self) -> str:
"""Return the current preset mode for the device."""
if self._device.steady_heat:
return PRESET_AWAY
if self._device.power_save:
return PRESET_ECO
if self._device.sleep:
return PRESET_SLEEP
if self._device.turbo:
... | [
"def",
"preset_mode",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_device",
".",
"steady_heat",
":",
"return",
"PRESET_AWAY",
"if",
"self",
".",
"_device",
".",
"power_save",
":",
"return",
"PRESET_ECO",
"if",
"self",
".",
"_device",
".",
"sl... | [
292,
4
] | [
302,
26
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.async_set_preset_mode | (self, preset_mode) | Set new preset mode. | Set new preset mode. | async def async_set_preset_mode(self, preset_mode):
"""Set new preset mode."""
if preset_mode not in PRESET_MODES:
raise ValueError(f"Invalid preset mode: {preset_mode}")
_LOGGER.debug(
"Setting preset mode to %s for device %s",
preset_mode,
self.... | [
"async",
"def",
"async_set_preset_mode",
"(",
"self",
",",
"preset_mode",
")",
":",
"if",
"preset_mode",
"not",
"in",
"PRESET_MODES",
":",
"raise",
"ValueError",
"(",
"f\"Invalid preset mode: {preset_mode}\"",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Setting preset mode ... | [
304,
4
] | [
329,
39
] | python | en | ['en', 'sr', 'en'] | True |
GreeClimateEntity.preset_modes | (self) | Return the preset modes support by the device. | Return the preset modes support by the device. | def preset_modes(self) -> List[str]:
"""Return the preset modes support by the device."""
return PRESET_MODES | [
"def",
"preset_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"PRESET_MODES"
] | [
332,
4
] | [
334,
27
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.fan_mode | (self) | Return the current fan mode for the device. | Return the current fan mode for the device. | def fan_mode(self) -> str:
"""Return the current fan mode for the device."""
speed = self._device.fan_speed
return FAN_MODES.get(speed) | [
"def",
"fan_mode",
"(",
"self",
")",
"->",
"str",
":",
"speed",
"=",
"self",
".",
"_device",
".",
"fan_speed",
"return",
"FAN_MODES",
".",
"get",
"(",
"speed",
")"
] | [
337,
4
] | [
340,
35
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.async_set_fan_mode | (self, fan_mode) | Set new target fan mode. | Set new target fan mode. | async def async_set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
if fan_mode not in FAN_MODES_REVERSE:
raise ValueError(f"Invalid fan mode: {fan_mode}")
self._device.fan_speed = FAN_MODES_REVERSE.get(fan_mode)
await self._push_state_update() | [
"async",
"def",
"async_set_fan_mode",
"(",
"self",
",",
"fan_mode",
")",
":",
"if",
"fan_mode",
"not",
"in",
"FAN_MODES_REVERSE",
":",
"raise",
"ValueError",
"(",
"f\"Invalid fan mode: {fan_mode}\"",
")",
"self",
".",
"_device",
".",
"fan_speed",
"=",
"FAN_MODES_R... | [
342,
4
] | [
348,
39
] | python | en | ['sv', 'fy', 'en'] | False |
GreeClimateEntity.fan_modes | (self) | Return the fan modes support by the device. | Return the fan modes support by the device. | def fan_modes(self) -> List[str]:
"""Return the fan modes support by the device."""
return [*FAN_MODES_REVERSE] | [
"def",
"fan_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"*",
"FAN_MODES_REVERSE",
"]"
] | [
351,
4
] | [
353,
35
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.swing_mode | (self) | Return the current swing mode for the device. | Return the current swing mode for the device. | def swing_mode(self) -> str:
"""Return the current swing mode for the device."""
h_swing = self._device.horizontal_swing == HorizontalSwing.FullSwing
v_swing = self._device.vertical_swing == VerticalSwing.FullSwing
if h_swing and v_swing:
return SWING_BOTH
if h_swing... | [
"def",
"swing_mode",
"(",
"self",
")",
"->",
"str",
":",
"h_swing",
"=",
"self",
".",
"_device",
".",
"horizontal_swing",
"==",
"HorizontalSwing",
".",
"FullSwing",
"v_swing",
"=",
"self",
".",
"_device",
".",
"vertical_swing",
"==",
"VerticalSwing",
".",
"F... | [
356,
4
] | [
367,
24
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.async_set_swing_mode | (self, swing_mode) | Set new target swing operation. | Set new target swing operation. | async def async_set_swing_mode(self, swing_mode):
"""Set new target swing operation."""
if swing_mode not in SWING_MODES:
raise ValueError(f"Invalid swing mode: {swing_mode}")
_LOGGER.debug(
"Setting swing mode to %s for device %s",
swing_mode,
se... | [
"async",
"def",
"async_set_swing_mode",
"(",
"self",
",",
"swing_mode",
")",
":",
"if",
"swing_mode",
"not",
"in",
"SWING_MODES",
":",
"raise",
"ValueError",
"(",
"f\"Invalid swing mode: {swing_mode}\"",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Setting swing mode to %s f... | [
369,
4
] | [
387,
39
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.swing_modes | (self) | Return the swing modes currently supported for this device. | Return the swing modes currently supported for this device. | def swing_modes(self) -> List[str]:
"""Return the swing modes currently supported for this device."""
return SWING_MODES | [
"def",
"swing_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"SWING_MODES"
] | [
390,
4
] | [
392,
26
] | python | en | ['en', 'en', 'en'] | True |
GreeClimateEntity.supported_features | (self) | Return the supported features for this device integration. | Return the supported features for this device integration. | def supported_features(self) -> int:
"""Return the supported features for this device integration."""
return SUPPORTED_FEATURES | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORTED_FEATURES"
] | [
395,
4
] | [
397,
33
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_request_get | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_request_get(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.get(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1]),
text="test",
)
resp = await hassio_client.get(
"/api/hassio_ingress/{}/{}".fo... | [
"async",
"def",
"test_ingress_request_get",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
"[",
... | [
16,
0
] | [
42,
62
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_request_post | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_request_post(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.post(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1]),
text="test",
)
resp = await hassio_client.post(
"/api/hassio_ingress/{}/{}"... | [
"async",
"def",
"test_ingress_request_post",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
"[",
... | [
55,
0
] | [
81,
62
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_request_put | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_request_put(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.put(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1]),
text="test",
)
resp = await hassio_client.put(
"/api/hassio_ingress/{}/{}".fo... | [
"async",
"def",
"test_ingress_request_put",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"put",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
"[",
... | [
94,
0
] | [
120,
62
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_request_delete | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_request_delete(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.delete(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1]),
text="test",
)
resp = await hassio_client.delete(
"/api/hassio_ingress/... | [
"async",
"def",
"test_ingress_request_delete",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"delete",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
"... | [
133,
0
] | [
159,
62
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_request_patch | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_request_patch(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.patch(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1]),
text="test",
)
resp = await hassio_client.patch(
"/api/hassio_ingress/{}/... | [
"async",
"def",
"test_ingress_request_patch",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"patch",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
"["... | [
172,
0
] | [
198,
62
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_request_options | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_request_options(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.options(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1]),
text="test",
)
resp = await hassio_client.options(
"/api/hassio_ingre... | [
"async",
"def",
"test_ingress_request_options",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"options",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
... | [
211,
0
] | [
237,
62
] | python | en | ['en', 'en', 'en'] | True |
test_ingress_websocket | (hassio_client, build_type, aioclient_mock) | Test no auth needed for . | Test no auth needed for . | async def test_ingress_websocket(hassio_client, build_type, aioclient_mock):
"""Test no auth needed for ."""
aioclient_mock.get(
"http://127.0.0.1/ingress/{}/{}".format(build_type[0], build_type[1])
)
# Ignore error because we can setup a full IO infrastructure
await hassio_client.ws_connec... | [
"async",
"def",
"test_ingress_websocket",
"(",
"hassio_client",
",",
"build_type",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://127.0.0.1/ingress/{}/{}\"",
".",
"format",
"(",
"build_type",
"[",
"0",
"]",
",",
"build_type",
"[",
"1... | [
250,
0
] | [
271,
62
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, store_result) | Component to allow users to login. | Component to allow users to login. | async def async_setup(hass, store_result):
"""Component to allow users to login."""
hass.http.register_view(AuthProvidersView)
hass.http.register_view(LoginFlowIndexView(hass.auth.login_flow, store_result))
hass.http.register_view(LoginFlowResourceView(hass.auth.login_flow, store_result)) | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"store_result",
")",
":",
"hass",
".",
"http",
".",
"register_view",
"(",
"AuthProvidersView",
")",
"hass",
".",
"http",
".",
"register_view",
"(",
"LoginFlowIndexView",
"(",
"hass",
".",
"auth",
".",
"login_f... | [
91,
0
] | [
95,
86
] | python | en | ['en', 'en', 'en'] | True |
_prepare_result_json | (result) | Convert result to JSON. | Convert result to JSON. | def _prepare_result_json(result):
"""Convert result to JSON."""
if result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY:
data = result.copy()
data.pop("result")
data.pop("data")
return data
if result["type"] != data_entry_flow.RESULT_TYPE_FORM:
return result
... | [
"def",
"_prepare_result_json",
"(",
"result",
")",
":",
"if",
"result",
"[",
"\"type\"",
"]",
"==",
"data_entry_flow",
".",
"RESULT_TYPE_CREATE_ENTRY",
":",
"data",
"=",
"result",
".",
"copy",
"(",
")",
"data",
".",
"pop",
"(",
"\"result\"",
")",
"data",
"... | [
123,
0
] | [
142,
15
] | python | en | ['en', 'en', 'en'] | True |
AuthProvidersView.get | (self, request) | Get available auth providers. | Get available auth providers. | async def get(self, request):
"""Get available auth providers."""
hass = request.app["hass"]
if not hass.components.onboarding.async_is_user_onboarded():
return self.json_message(
message="Onboarding not finished",
status_code=HTTP_BAD_REQUEST,
... | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"hass",
"=",
"request",
".",
"app",
"[",
"\"hass\"",
"]",
"if",
"not",
"hass",
".",
"components",
".",
"onboarding",
".",
"async_is_user_onboarded",
"(",
")",
":",
"return",
"self",
".",
"js... | [
105,
4
] | [
120,
9
] | python | en | ['fr', 'en', 'en'] | True |
LoginFlowIndexView.__init__ | (self, flow_mgr, store_result) | Initialize the flow manager index view. | Initialize the flow manager index view. | def __init__(self, flow_mgr, store_result):
"""Initialize the flow manager index view."""
self._flow_mgr = flow_mgr
self._store_result = store_result | [
"def",
"__init__",
"(",
"self",
",",
"flow_mgr",
",",
"store_result",
")",
":",
"self",
".",
"_flow_mgr",
"=",
"flow_mgr",
"self",
".",
"_store_result",
"=",
"store_result"
] | [
152,
4
] | [
155,
41
] | python | en | ['en', 'en', 'en'] | True |
LoginFlowIndexView.get | (self, request) | Do not allow index of flows in progress. | Do not allow index of flows in progress. | async def get(self, request):
"""Do not allow index of flows in progress."""
return web.Response(status=HTTP_METHOD_NOT_ALLOWED) | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"return",
"web",
".",
"Response",
"(",
"status",
"=",
"HTTP_METHOD_NOT_ALLOWED",
")"
] | [
157,
4
] | [
159,
59
] | python | en | ['en', 'en', 'en'] | True |
LoginFlowIndexView.post | (self, request, data) | Create a new login flow. | Create a new login flow. | async def post(self, request, data):
"""Create a new login flow."""
if not await indieauth.verify_redirect_uri(
request.app["hass"], data["client_id"], data["redirect_uri"]
):
return self.json_message(
"invalid client id or redirect uri", HTTP_BAD_REQUEST
... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
",",
"data",
")",
":",
"if",
"not",
"await",
"indieauth",
".",
"verify_redirect_uri",
"(",
"request",
".",
"app",
"[",
"\"hass\"",
"]",
",",
"data",
"[",
"\"client_id\"",
"]",
",",
"data",
"[",
"\"re... | [
172,
4
] | [
205,
54
] | python | en | ['en', 'lb', 'en'] | True |
LoginFlowResourceView.__init__ | (self, flow_mgr, store_result) | Initialize the login flow resource view. | Initialize the login flow resource view. | def __init__(self, flow_mgr, store_result):
"""Initialize the login flow resource view."""
self._flow_mgr = flow_mgr
self._store_result = store_result | [
"def",
"__init__",
"(",
"self",
",",
"flow_mgr",
",",
"store_result",
")",
":",
"self",
".",
"_flow_mgr",
"=",
"flow_mgr",
"self",
".",
"_store_result",
"=",
"store_result"
] | [
215,
4
] | [
218,
41
] | python | en | ['en', 'en', 'en'] | True |
LoginFlowResourceView.get | (self, request) | Do not allow getting status of a flow in progress. | Do not allow getting status of a flow in progress. | async def get(self, request):
"""Do not allow getting status of a flow in progress."""
return self.json_message("Invalid flow specified", HTTP_NOT_FOUND) | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Invalid flow specified\"",
",",
"HTTP_NOT_FOUND",
")"
] | [
220,
4
] | [
222,
74
] | python | en | ['en', 'en', 'en'] | True |
LoginFlowResourceView.post | (self, request, flow_id, data) | Handle progressing a login flow request. | Handle progressing a login flow request. | async def post(self, request, flow_id, data):
"""Handle progressing a login flow request."""
client_id = data.pop("client_id")
if not indieauth.verify_client_id(client_id):
return self.json_message("Invalid client id", HTTP_BAD_REQUEST)
try:
# do not allow chang... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
",",
"flow_id",
",",
"data",
")",
":",
"client_id",
"=",
"data",
".",
"pop",
"(",
"\"client_id\"",
")",
"if",
"not",
"indieauth",
".",
"verify_client_id",
"(",
"client_id",
")",
":",
"return",
"self",
... | [
226,
4
] | [
260,
32
] | python | en | ['en', 'ca', 'en'] | True |
LoginFlowResourceView.delete | (self, request, flow_id) | Cancel a flow in progress. | Cancel a flow in progress. | async def delete(self, request, flow_id):
"""Cancel a flow in progress."""
try:
self._flow_mgr.async_abort(flow_id)
except data_entry_flow.UnknownFlow:
return self.json_message("Invalid flow specified", HTTP_NOT_FOUND)
return self.json_message("Flow aborted") | [
"async",
"def",
"delete",
"(",
"self",
",",
"request",
",",
"flow_id",
")",
":",
"try",
":",
"self",
".",
"_flow_mgr",
".",
"async_abort",
"(",
"flow_id",
")",
"except",
"data_entry_flow",
".",
"UnknownFlow",
":",
"return",
"self",
".",
"json_message",
"("... | [
262,
4
] | [
269,
48
] | python | en | ['en', 'fy', 'en'] | True |
get_and_apply_next_architecture | (model) |
Wrapper of :class:`~nni.nas.pytorch.classic_nas.mutator.ClassicMutator` to make it more meaningful,
similar to ``get_next_parameter`` for HPO.
It will generate search space based on ``model``.
If env ``NNI_GEN_SEARCH_SPACE`` exists, this is in dry run mode for
generating search space for the exper... |
Wrapper of :class:`~nni.nas.pytorch.classic_nas.mutator.ClassicMutator` to make it more meaningful,
similar to ``get_next_parameter`` for HPO. | def get_and_apply_next_architecture(model):
"""
Wrapper of :class:`~nni.nas.pytorch.classic_nas.mutator.ClassicMutator` to make it more meaningful,
similar to ``get_next_parameter`` for HPO.
It will generate search space based on ``model``.
If env ``NNI_GEN_SEARCH_SPACE`` exists, this is in dry run... | [
"def",
"get_and_apply_next_architecture",
"(",
"model",
")",
":",
"ClassicMutator",
"(",
"model",
")"
] | [
22,
0
] | [
40,
25
] | python | en | ['en', 'error', 'th'] | False |
ClassicMutator._sample_layer_choice | (self, mutable, idx, value, search_space_item) |
Convert layer choice to tensor representation.
Parameters
----------
mutable : Mutable
idx : int
Number `idx` of list will be selected.
value : str
The verbose representation of the selected value.
search_space_item : list
The... |
Convert layer choice to tensor representation. | def _sample_layer_choice(self, mutable, idx, value, search_space_item):
"""
Convert layer choice to tensor representation.
Parameters
----------
mutable : Mutable
idx : int
Number `idx` of list will be selected.
value : str
The verbose rep... | [
"def",
"_sample_layer_choice",
"(",
"self",
",",
"mutable",
",",
"idx",
",",
"value",
",",
"search_space_item",
")",
":",
"# doesn't support multihot for layer choice yet",
"onehot_list",
"=",
"[",
"False",
"]",
"*",
"len",
"(",
"mutable",
")",
"assert",
"0",
"<... | [
79,
4
] | [
98,
58
] | python | en | ['en', 'error', 'th'] | False |
ClassicMutator._sample_input_choice | (self, mutable, idx, value, search_space_item) |
Convert input choice to tensor representation.
Parameters
----------
mutable : Mutable
idx : int
Number `idx` of list will be selected.
value : str
The verbose representation of the selected value.
search_space_item : list
The... |
Convert input choice to tensor representation. | def _sample_input_choice(self, mutable, idx, value, search_space_item):
"""
Convert input choice to tensor representation.
Parameters
----------
mutable : Mutable
idx : int
Number `idx` of list will be selected.
value : str
The verbose rep... | [
"def",
"_sample_input_choice",
"(",
"self",
",",
"mutable",
",",
"idx",
",",
"value",
",",
"search_space_item",
")",
":",
"candidate_repr",
"=",
"search_space_item",
"[",
"\"candidates\"",
"]",
"multihot_list",
"=",
"[",
"False",
"]",
"*",
"mutable",
".",
"n_c... | [
100,
4
] | [
121,
60
] | python | en | ['en', 'error', 'th'] | False |
ClassicMutator.sample_search | (self) |
See :meth:`sample_final`.
|
See :meth:`sample_final`.
| def sample_search(self):
"""
See :meth:`sample_final`.
"""
return self.sample_final() | [
"def",
"sample_search",
"(",
"self",
")",
":",
"return",
"self",
".",
"sample_final",
"(",
")"
] | [
123,
4
] | [
127,
34
] | python | en | ['en', 'error', 'th'] | False |
ClassicMutator.sample_final | (self) |
Convert the chosen arch and apply it on model.
|
Convert the chosen arch and apply it on model.
| def sample_final(self):
"""
Convert the chosen arch and apply it on model.
"""
assert set(self._chosen_arch.keys()) == set(self._search_space.keys()), \
"Unmatched keys, expected keys '{}' from search space, found '{}'.".format(self._search_space.keys(),
... | [
"def",
"sample_final",
"(",
"self",
")",
":",
"assert",
"set",
"(",
"self",
".",
"_chosen_arch",
".",
"keys",
"(",
")",
")",
"==",
"set",
"(",
"self",
".",
"_search_space",
".",
"keys",
"(",
")",
")",
",",
"\"Unmatched keys, expected keys '{}' from search sp... | [
129,
4
] | [
154,
21
] | python | en | ['en', 'error', 'th'] | False |
ClassicMutator._standalone_generate_chosen | (self) |
Generate the chosen architecture for standalone mode,
i.e., choose the first one(s) for LayerChoice and InputChoice.
::
{ key_name: {"_value": "conv1",
"_idx": 0} }
{ key_name: {"_value": ["in1"],
"_idx": [0]} }
R... |
Generate the chosen architecture for standalone mode,
i.e., choose the first one(s) for LayerChoice and InputChoice.
::
{ key_name: {"_value": "conv1",
"_idx": 0} }
{ key_name: {"_value": ["in1"],
"_idx": [0]} }
R... | def _standalone_generate_chosen(self):
"""
Generate the chosen architecture for standalone mode,
i.e., choose the first one(s) for LayerChoice and InputChoice.
::
{ key_name: {"_value": "conv1",
"_idx": 0} }
{ key_name: {"_value": ["in1"],... | [
"def",
"_standalone_generate_chosen",
"(",
"self",
")",
":",
"chosen_arch",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"self",
".",
"_search_space",
".",
"items",
"(",
")",
":",
"if",
"val",
"[",
"\"_type\"",
"]",
"==",
"LAYER_CHOICE",
":",
"choices"... | [
156,
4
] | [
183,
26
] | python | en | ['en', 'error', 'th'] | False |
ClassicMutator._generate_search_space | (self) |
Generate search space from mutables.
Here is the search space format:
::
{ key_name: {"_type": "layer_choice",
"_value": ["conv1", "conv2"]} }
{ key_name: {"_type": "input_choice",
"_value": {"candidates": ["in1", "in2"],... |
Generate search space from mutables.
Here is the search space format:
::
{ key_name: {"_type": "layer_choice",
"_value": ["conv1", "conv2"]} }
{ key_name: {"_type": "input_choice",
"_value": {"candidates": ["in1", "in2"],... | def _generate_search_space(self):
"""
Generate search space from mutables.
Here is the search space format:
::
{ key_name: {"_type": "layer_choice",
"_value": ["conv1", "conv2"]} }
{ key_name: {"_type": "input_choice",
... | [
"def",
"_generate_search_space",
"(",
"self",
")",
":",
"search_space",
"=",
"{",
"}",
"for",
"mutable",
"in",
"self",
".",
"mutables",
":",
"# for now we only generate flattened search space",
"if",
"isinstance",
"(",
"mutable",
",",
"LayerChoice",
")",
":",
"key... | [
185,
4
] | [
216,
27
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Load Tradfri covers based on a config entry. | Load Tradfri covers based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Load Tradfri covers based on a config entry."""
gateway_id = config_entry.data[CONF_GATEWAY_ID]
tradfri_data = hass.data[DOMAIN][config_entry.entry_id]
api = tradfri_data[KEY_API]
devices = tradfri_data[DEVICES]
covers = [d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"gateway_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_GATEWAY_ID",
"]",
"tradfri_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_... | [
8,
0
] | [
17,
84
] | python | en | ['en', 'en', 'en'] | True |
TradfriCover.__init__ | (self, device, api, gateway_id) | Initialize a cover. | Initialize a cover. | def __init__(self, device, api, gateway_id):
"""Initialize a cover."""
super().__init__(device, api, gateway_id)
self._unique_id = f"{gateway_id}-{device.id}"
self._refresh(device) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"api",
",",
"gateway_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"api",
",",
"gateway_id",
")",
"self",
".",
"_unique_id",
"=",
"f\"{gateway_id}-{device.id}\"",
"self",
".",
"... | [
23,
4
] | [
28,
29
] | python | en | ['es', 'en', 'en'] | True |
TradfriCover.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_MODEL: self._device.device_info.model_number} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_MODEL",
":",
"self",
".",
"_device",
".",
"device_info",
".",
"model_number",
"}"
] | [
31,
4
] | [
33,
66
] | python | en | ['en', 'en', 'en'] | True |
TradfriCover.current_cover_position | (self) | Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
| Return current position of cover. | def current_cover_position(self):
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open.
"""
return 100 - self._device_data.current_cover_position | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"return",
"100",
"-",
"self",
".",
"_device_data",
".",
"current_cover_position"
] | [
36,
4
] | [
41,
61
] | python | en | ['en', 'en', 'en'] | True |
TradfriCover.async_set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
await self._api(self._device_control.set_state(100 - kwargs[ATTR_POSITION])) | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device_control",
".",
"set_state",
"(",
"100",
"-",
"kwargs",
"[",
"ATTR_POSITION",
"]",
")",
")"
] | [
43,
4
] | [
45,
84
] | python | en | ['en', 'en', 'en'] | True |
TradfriCover.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
await self._api(self._device_control.set_state(0)) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device_control",
".",
"set_state",
"(",
"0",
")",
")"
] | [
47,
4
] | [
49,
58
] | python | en | ['en', 'en', 'en'] | True |
TradfriCover.async_close_cover | (self, **kwargs) | Close cover. | Close cover. | async def async_close_cover(self, **kwargs):
"""Close cover."""
await self._api(self._device_control.set_state(100)) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device_control",
".",
"set_state",
"(",
"100",
")",
")"
] | [
51,
4
] | [
53,
60
] | python | en | ['en', 'la', 'en'] | False |
TradfriCover.async_stop_cover | (self, **kwargs) | Close cover. | Close cover. | async def async_stop_cover(self, **kwargs):
"""Close cover."""
await self._api(self._device_control.trigger_blind()) | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device_control",
".",
"trigger_blind",
"(",
")",
")"
] | [
55,
4
] | [
57,
61
] | python | en | ['en', 'la', 'en'] | False |
TradfriCover.is_closed | (self) | Return if the cover is closed or not. | Return if the cover is closed or not. | def is_closed(self):
"""Return if the cover is closed or not."""
return self.current_cover_position == 0 | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"current_cover_position",
"==",
"0"
] | [
60,
4
] | [
62,
47
] | 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.