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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WiLightParent.host | (self) | Return the host of this parent. | Return the host of this parent. | def host(self):
"""Return the host of this parent."""
return self._host | [
"def",
"host",
"(",
"self",
")",
":",
"return",
"self",
".",
"_host"
] | [
24,
4
] | [
26,
25
] | python | en | ['en', 'en', 'en'] | True |
WiLightParent.api | (self) | Return the api of this parent. | Return the api of this parent. | def api(self):
"""Return the api of this parent."""
return self._api | [
"def",
"api",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api"
] | [
29,
4
] | [
31,
24
] | python | en | ['en', 'la', 'en'] | True |
WiLightParent.async_setup | (self) | Set up a WiLight Parent Device based on host parameter. | Set up a WiLight Parent Device based on host parameter. | async def async_setup(self):
"""Set up a WiLight Parent Device based on host parameter."""
host = self._host
hass = self._hass
api_device = await hass.async_add_executor_job(create_api_device, host)
if api_device is None:
return False
@callback
def ... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
":",
"host",
"=",
"self",
".",
"_host",
"hass",
"=",
"self",
".",
"_hass",
"api_device",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"create_api_device",
",",
"host",
")",
"if",
"api_device",
"... | [
33,
4
] | [
81,
19
] | python | en | ['en', 'en', 'en'] | True |
hue_setup_fixture | () | Mock hue entry setup. | Mock hue entry setup. | def hue_setup_fixture():
"""Mock hue entry setup."""
with patch("homeassistant.components.hue.async_setup_entry", return_value=True):
yield | [
"def",
"hue_setup_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hue.async_setup_entry\"",
",",
"return_value",
"=",
"True",
")",
":",
"yield"
] | [
18,
0
] | [
21,
13
] | python | en | ['en', 'st', 'en'] | True |
get_mock_bridge | (
bridge_id="aabbccddeeff", host="1.2.3.4", mock_create_user=None, username=None
) | Return a mock bridge. | Return a mock bridge. | def get_mock_bridge(
bridge_id="aabbccddeeff", host="1.2.3.4", mock_create_user=None, username=None
):
"""Return a mock bridge."""
mock_bridge = Mock()
mock_bridge.host = host
mock_bridge.username = username
mock_bridge.config.name = "Mock Bridge"
mock_bridge.id = bridge_id
if not mock_... | [
"def",
"get_mock_bridge",
"(",
"bridge_id",
"=",
"\"aabbccddeeff\"",
",",
"host",
"=",
"\"1.2.3.4\"",
",",
"mock_create_user",
"=",
"None",
",",
"username",
"=",
"None",
")",
":",
"mock_bridge",
"=",
"Mock",
"(",
")",
"mock_bridge",
".",
"host",
"=",
"host",... | [
24,
0
] | [
44,
22
] | python | en | ['en', 'ms', 'en'] | True |
test_flow_works | (hass) | Test config flow . | Test config flow . | async def test_flow_works(hass):
"""Test config flow ."""
mock_bridge = get_mock_bridge()
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
return_value=[mock_bridge],
):
result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={... | [
"async",
"def",
"test_flow_works",
"(",
"hass",
")",
":",
"mock_bridge",
"=",
"get_mock_bridge",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.hue.config_flow.discover_nupnp\"",
",",
"return_value",
"=",
"[",
"mock_bridge",
"]",
",",
")",
":",
"result"... | [
47,
0
] | [
87,
54
] | python | en | ['en', 'da', 'en'] | True |
test_manual_flow_works | (hass, aioclient_mock) | Test config flow discovers only already configured bridges. | Test config flow discovers only already configured bridges. | async def test_manual_flow_works(hass, aioclient_mock):
"""Test config flow discovers only already configured bridges."""
mock_bridge = get_mock_bridge()
MockConfigEntry(
domain="hue", source=config_entries.SOURCE_IGNORE, unique_id="bla"
).add_to_hass(hass)
with patch(
"homeassista... | [
"async",
"def",
"test_manual_flow_works",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"mock_bridge",
"=",
"get_mock_bridge",
"(",
")",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"source",
"=",
"config_entries",
".",
"SOURCE_IGNORE",
",",
"unique_id",... | [
90,
0
] | [
145,
39
] | python | en | ['en', 'en', 'en'] | True |
test_manual_flow_bridge_exist | (hass, aioclient_mock) | Test config flow discovers only already configured bridges. | Test config flow discovers only already configured bridges. | async def test_manual_flow_bridge_exist(hass, aioclient_mock):
"""Test config flow discovers only already configured bridges."""
MockConfigEntry(
domain="hue", unique_id="id-1234", data={"host": "2.2.2.2"}
).add_to_hass(hass)
with patch(
"homeassistant.components.hue.config_flow.discove... | [
"async",
"def",
"test_manual_flow_bridge_exist",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"unique_id",
"=",
"\"id-1234\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"2.2.2.2\"",
"}",
")",
".",
"add_to... | [
148,
0
] | [
178,
51
] | python | en | ['en', 'en', 'en'] | True |
test_manual_flow_no_discovered_bridges | (hass, aioclient_mock) | Test config flow discovers no bridges. | Test config flow discovers no bridges. | async def test_manual_flow_no_discovered_bridges(hass, aioclient_mock):
"""Test config flow discovers no bridges."""
aioclient_mock.get(URL_NUPNP, json=[])
result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": "user"}
)
assert result["type"] == "form"
asse... | [
"async",
"def",
"test_manual_flow_no_discovered_bridges",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"URL_NUPNP",
",",
"json",
"=",
"[",
"]",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
... | [
181,
0
] | [
189,
40
] | python | en | ['en', 'fr', 'en'] | True |
test_flow_all_discovered_bridges_exist | (hass, aioclient_mock) | Test config flow discovers only already configured bridges. | Test config flow discovers only already configured bridges. | async def test_flow_all_discovered_bridges_exist(hass, aioclient_mock):
"""Test config flow discovers only already configured bridges."""
aioclient_mock.get(URL_NUPNP, json=[{"internalipaddress": "1.2.3.4", "id": "bla"}])
MockConfigEntry(
domain="hue", unique_id="bla", data={"host": "1.2.3.4"}
)... | [
"async",
"def",
"test_flow_all_discovered_bridges_exist",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"URL_NUPNP",
",",
"json",
"=",
"[",
"{",
"\"internalipaddress\"",
":",
"\"1.2.3.4\"",
",",
"\"id\"",
":",
"\"bla\"",
"}",
"... | [
192,
0
] | [
204,
40
] | python | en | ['en', 'en', 'en'] | True |
test_flow_bridges_discovered | (hass, aioclient_mock) | Test config flow discovers two bridges. | Test config flow discovers two bridges. | async def test_flow_bridges_discovered(hass, aioclient_mock):
"""Test config flow discovers two bridges."""
# Add ignored config entry. Should still show up as option.
MockConfigEntry(
domain="hue", source=config_entries.SOURCE_IGNORE, unique_id="bla"
).add_to_hass(hass)
aioclient_mock.get(... | [
"async",
"def",
"test_flow_bridges_discovered",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"# Add ignored config entry. Should still show up as option.",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"source",
"=",
"config_entries",
".",
"SOURCE_IGNORE",
",",
... | [
207,
0
] | [
233,
43
] | python | en | ['en', 'fr', 'en'] | True |
test_flow_two_bridges_discovered_one_new | (hass, aioclient_mock) | Test config flow discovers two bridges. | Test config flow discovers two bridges. | async def test_flow_two_bridges_discovered_one_new(hass, aioclient_mock):
"""Test config flow discovers two bridges."""
aioclient_mock.get(
URL_NUPNP,
json=[
{"internalipaddress": "1.2.3.4", "id": "bla"},
{"internalipaddress": "5.6.7.8", "id": "beer"},
],
)
... | [
"async",
"def",
"test_flow_two_bridges_discovered_one_new",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"URL_NUPNP",
",",
"json",
"=",
"[",
"{",
"\"internalipaddress\"",
":",
"\"1.2.3.4\"",
",",
"\"id\"",
":",
"\"bla\"",
"}",
... | [
236,
0
] | [
258,
55
] | python | en | ['en', 'fr', 'en'] | True |
test_flow_timeout_discovery | (hass) | Test config flow . | Test config flow . | async def test_flow_timeout_discovery(hass):
"""Test config flow ."""
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
side_effect=asyncio.TimeoutError,
):
result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": "user"}
... | [
"async",
"def",
"test_flow_timeout_discovery",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hue.config_flow.discover_nupnp\"",
",",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
",",
")",
":",
"result",
"=",
"await",
"hass",
".",
"c... | [
261,
0
] | [
272,
49
] | python | en | ['en', 'da', 'en'] | True |
test_flow_link_timeout | (hass) | Test config flow. | Test config flow. | async def test_flow_link_timeout(hass):
"""Test config flow."""
mock_bridge = get_mock_bridge(
mock_create_user=AsyncMock(side_effect=asyncio.TimeoutError),
)
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
return_value=[mock_bridge],
):
result ... | [
"async",
"def",
"test_flow_link_timeout",
"(",
"hass",
")",
":",
"mock_bridge",
"=",
"get_mock_bridge",
"(",
"mock_create_user",
"=",
"AsyncMock",
"(",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
")",
",",
")",
"with",
"patch",
"(",
"\"homeassistant.compon... | [
275,
0
] | [
297,
47
] | python | da | ['de', 'da', 'en'] | False |
test_flow_link_unknown_error | (hass) | Test if a unknown error happened during the linking processes. | Test if a unknown error happened during the linking processes. | async def test_flow_link_unknown_error(hass):
"""Test if a unknown error happened during the linking processes."""
mock_bridge = get_mock_bridge(
mock_create_user=AsyncMock(side_effect=OSError),
)
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
return_value... | [
"async",
"def",
"test_flow_link_unknown_error",
"(",
"hass",
")",
":",
"mock_bridge",
"=",
"get_mock_bridge",
"(",
"mock_create_user",
"=",
"AsyncMock",
"(",
"side_effect",
"=",
"OSError",
")",
",",
")",
"with",
"patch",
"(",
"\"homeassistant.components.hue.config_flo... | [
300,
0
] | [
323,
50
] | python | en | ['en', 'en', 'en'] | True |
test_flow_link_button_not_pressed | (hass) | Test config flow . | Test config flow . | async def test_flow_link_button_not_pressed(hass):
"""Test config flow ."""
mock_bridge = get_mock_bridge(
mock_create_user=AsyncMock(side_effect=aiohue.LinkButtonNotPressed),
)
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
return_value=[mock_bridge],
... | [
"async",
"def",
"test_flow_link_button_not_pressed",
"(",
"hass",
")",
":",
"mock_bridge",
"=",
"get_mock_bridge",
"(",
"mock_create_user",
"=",
"AsyncMock",
"(",
"side_effect",
"=",
"aiohue",
".",
"LinkButtonNotPressed",
")",
",",
")",
"with",
"patch",
"(",
"\"ho... | [
326,
0
] | [
349,
58
] | python | en | ['en', 'da', 'en'] | True |
test_flow_link_unknown_host | (hass) | Test config flow . | Test config flow . | async def test_flow_link_unknown_host(hass):
"""Test config flow ."""
mock_bridge = get_mock_bridge(
mock_create_user=AsyncMock(side_effect=client_exceptions.ClientOSError),
)
with patch(
"homeassistant.components.hue.config_flow.discover_nupnp",
return_value=[mock_bridge],
)... | [
"async",
"def",
"test_flow_link_unknown_host",
"(",
"hass",
")",
":",
"mock_bridge",
"=",
"get_mock_bridge",
"(",
"mock_create_user",
"=",
"AsyncMock",
"(",
"side_effect",
"=",
"client_exceptions",
".",
"ClientOSError",
")",
",",
")",
"with",
"patch",
"(",
"\"home... | [
352,
0
] | [
374,
47
] | python | en | ['en', 'da', 'en'] | True |
test_bridge_ssdp | (hass) | Test a bridge being discovered. | Test a bridge being discovered. | async def test_bridge_ssdp(hass):
"""Test a bridge being discovered."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "ssdp"},
data={
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HU... | [
"async",
"def",
"test_bridge_ssdp",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"ssdp\"",
"}",
",",
"data",
"=",... | [
377,
0
] | [
390,
38
] | python | en | ['de', 'en', 'en'] | True |
test_bridge_ssdp_discover_other_bridge | (hass) | Test that discovery ignores other bridges. | Test that discovery ignores other bridges. | async def test_bridge_ssdp_discover_other_bridge(hass):
"""Test that discovery ignores other bridges."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "ssdp"},
data={ssdp.ATTR_UPNP_MANUFACTURER_URL: "http://www.notphilips.com"},
)
assert re... | [
"async",
"def",
"test_bridge_ssdp_discover_other_bridge",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"ssdp\"",
"}",
... | [
393,
0
] | [
402,
47
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_ssdp_emulated_hue | (hass) | Test if discovery info is from an emulated hue instance. | Test if discovery info is from an emulated hue instance. | async def test_bridge_ssdp_emulated_hue(hass):
"""Test if discovery info is from an emulated hue instance."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "ssdp"},
data={
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
ssdp.ATTR... | [
"async",
"def",
"test_bridge_ssdp_emulated_hue",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"ssdp\"",
"}",
",",
"... | [
405,
0
] | [
419,
47
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_ssdp_missing_location | (hass) | Test if discovery info is missing a location attribute. | Test if discovery info is missing a location attribute. | async def test_bridge_ssdp_missing_location(hass):
"""Test if discovery info is missing a location attribute."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "ssdp"},
data={
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERU... | [
"async",
"def",
"test_bridge_ssdp_missing_location",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"ssdp\"",
"}",
",",... | [
422,
0
] | [
434,
47
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_ssdp_missing_serial | (hass) | Test if discovery info is a serial attribute. | Test if discovery info is a serial attribute. | async def test_bridge_ssdp_missing_serial(hass):
"""Test if discovery info is a serial attribute."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "ssdp"},
data={
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
ssdp.ATTR_UPNP_MAN... | [
"async",
"def",
"test_bridge_ssdp_missing_serial",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"ssdp\"",
"}",
",",
... | [
437,
0
] | [
449,
47
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_ssdp_espalexa | (hass) | Test if discovery info is from an Espalexa based device. | Test if discovery info is from an Espalexa based device. | async def test_bridge_ssdp_espalexa(hass):
"""Test if discovery info is from an Espalexa based device."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "ssdp"},
data={
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
ssdp.ATTR_UPN... | [
"async",
"def",
"test_bridge_ssdp_espalexa",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"ssdp\"",
"}",
",",
"data... | [
452,
0
] | [
466,
47
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_ssdp_already_configured | (hass) | Test if a discovered bridge has already been configured. | Test if a discovered bridge has already been configured. | async def test_bridge_ssdp_already_configured(hass):
"""Test if a discovered bridge has already been configured."""
MockConfigEntry(
domain="hue", unique_id="1234", data={"host": "0.0.0.0"}
).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
con... | [
"async",
"def",
"test_bridge_ssdp_already_configured",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"unique_id",
"=",
"\"1234\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
"}",
")",
".",
"add_to_hass",
"(",
"hass",... | [
469,
0
] | [
486,
51
] | python | en | ['en', 'en', 'en'] | True |
test_import_with_no_config | (hass) | Test importing a host without an existing config file. | Test importing a host without an existing config file. | async def test_import_with_no_config(hass):
"""Test importing a host without an existing config file."""
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "import"},
data={"host": "0.0.0.0"},
)
assert result["type"] == "form"
assert result[... | [
"async",
"def",
"test_import_with_no_config",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"const",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"import\"",
"}",
",",
"d... | [
489,
0
] | [
498,
38
] | python | en | ['en', 'en', 'en'] | True |
test_creating_entry_removes_entries_for_same_host_or_bridge | (hass) | Test that we clean up entries for same host and bridge.
An IP can only hold a single bridge and a single bridge can only be
accessible via a single IP. So when we create a new entry, we'll remove
all existing entries that either have same IP or same bridge_id.
| Test that we clean up entries for same host and bridge. | async def test_creating_entry_removes_entries_for_same_host_or_bridge(hass):
"""Test that we clean up entries for same host and bridge.
An IP can only hold a single bridge and a single bridge can only be
accessible via a single IP. So when we create a new entry, we'll remove
all existing entries that e... | [
"async",
"def",
"test_creating_entry_removes_entries_for_same_host_or_bridge",
"(",
"hass",
")",
":",
"orig_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
",",
"\"username\"",
":",
"\"aaaa\"",
"}... | [
501,
0
] | [
553,
43
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_homekit | (hass, aioclient_mock) | Test a bridge being discovered via HomeKit. | Test a bridge being discovered via HomeKit. | async def test_bridge_homekit(hass, aioclient_mock):
"""Test a bridge being discovered via HomeKit."""
aioclient_mock.get(URL_NUPNP, json=[{"internalipaddress": "1.2.3.4", "id": "bla"}])
result = await hass.config_entries.flow.async_init(
const.DOMAIN,
context={"source": "homekit"},
... | [
"async",
"def",
"test_bridge_homekit",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"URL_NUPNP",
",",
"json",
"=",
"[",
"{",
"\"internalipaddress\"",
":",
"\"1.2.3.4\"",
",",
"\"id\"",
":",
"\"bla\"",
"}",
"]",
")",
"resul... | [
556,
0
] | [
572,
38
] | python | de | ['de', 'mi', 'en'] | False |
test_bridge_import_already_configured | (hass) | Test if a import flow aborts if host is already configured. | Test if a import flow aborts if host is already configured. | async def test_bridge_import_already_configured(hass):
"""Test if a import flow aborts if host is already configured."""
MockConfigEntry(
domain="hue", unique_id="aabbccddeeff", data={"host": "0.0.0.0"}
).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
const.DOMAIN... | [
"async",
"def",
"test_bridge_import_already_configured",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"unique_id",
"=",
"\"aabbccddeeff\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
"}",
")",
".",
"add_to_hass",
"(",... | [
575,
0
] | [
588,
51
] | python | en | ['en', 'en', 'en'] | True |
test_bridge_homekit_already_configured | (hass) | Test if a HomeKit discovered bridge has already been configured. | Test if a HomeKit discovered bridge has already been configured. | async def test_bridge_homekit_already_configured(hass):
"""Test if a HomeKit discovered bridge has already been configured."""
MockConfigEntry(
domain="hue", unique_id="aabbccddeeff", data={"host": "0.0.0.0"}
).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
const.... | [
"async",
"def",
"test_bridge_homekit_already_configured",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"unique_id",
"=",
"\"aabbccddeeff\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
"}",
")",
".",
"add_to_hass",
"("... | [
591,
0
] | [
604,
51
] | python | en | ['en', 'en', 'en'] | True |
test_ssdp_discovery_update_configuration | (hass) | Test if a discovered bridge is configured and updated with new host. | Test if a discovered bridge is configured and updated with new host. | async def test_ssdp_discovery_update_configuration(hass):
"""Test if a discovered bridge is configured and updated with new host."""
entry = MockConfigEntry(
domain="hue", unique_id="aabbccddeeff", data={"host": "0.0.0.0"}
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.as... | [
"async",
"def",
"test_ssdp_discovery_update_configuration",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"unique_id",
"=",
"\"aabbccddeeff\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
"}",
")",
"entry"... | [
607,
0
] | [
626,
42
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow | (hass) | Test options config flow. | Test options config flow. | async def test_options_flow(hass):
"""Test options config flow."""
entry = MockConfigEntry(
domain="hue",
unique_id="aabbccddeeff",
data={"host": "0.0.0.0"},
)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["t... | [
"async",
"def",
"test_options_flow",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
",",
"unique_id",
"=",
"\"aabbccddeeff\"",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"0.0.0.0\"",
"}",
",",
")",
"entry",
".",
"add_... | [
629,
0
] | [
655,
5
] | python | en | ['en', 'fr', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
entities = await async_create_entities(
hass,
entry,
WithingsHealthSensor,
SENSOR_DOMAIN,
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
11,
0
] | [
25,
38
] | python | en | ['en', 'pt', 'en'] | True |
WithingsHealthSensor.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self) -> Union[None, str, int, float]:
"""Return the state of the entity."""
return self._state_data | [
"def",
"state",
"(",
"self",
")",
"->",
"Union",
"[",
"None",
",",
"str",
",",
"int",
",",
"float",
"]",
":",
"return",
"self",
".",
"_state_data"
] | [
32,
4
] | [
34,
31
] | python | en | ['en', 'en', 'en'] | True |
EvalMetric.update | (self, outputs) | Updates the internal evaluation result.
Args
labels (list of `NDArray`): The labels of the data.
preds (list of `NDArray`): Predicted values.
| Updates the internal evaluation result.
Args
labels (list of `NDArray`): The labels of the data.
preds (list of `NDArray`): Predicted values.
| def update(self, outputs):
"""Updates the internal evaluation result.
Args
labels (list of `NDArray`): The labels of the data.
preds (list of `NDArray`): Predicted values.
"""
raise NotImplementedError() | [
"def",
"update",
"(",
"self",
",",
"outputs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
24,
4
] | [
30,
35
] | python | en | ['en', 'en', 'en'] | True |
EvalMetric.reset | (self) | Resets the internal evaluation result to initial state. | Resets the internal evaluation result to initial state. | def reset(self):
"""Resets the internal evaluation result to initial state."""
self.num_inst = torch.tensor(0.)
self.sum_metric = torch.tensor(0.) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"num_inst",
"=",
"torch",
".",
"tensor",
"(",
"0.",
")",
"self",
".",
"sum_metric",
"=",
"torch",
".",
"tensor",
"(",
"0.",
")"
] | [
32,
4
] | [
35,
42
] | python | en | ['en', 'en', 'en'] | True |
EvalMetric.get | (self) | Returns the current evaluation result.
Returns:
names (list of str): Name of the metrics.
values (list of float): Value of the evaluations.
| Returns the current evaluation result.
Returns:
names (list of str): Name of the metrics.
values (list of float): Value of the evaluations.
| def get(self):
"""Returns the current evaluation result.
Returns:
names (list of str): Name of the metrics.
values (list of float): Value of the evaluations.
"""
if self.num_inst.item() == 0:
return (self.name, float('nan'))
else:
i... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"num_inst",
".",
"item",
"(",
")",
"==",
"0",
":",
"return",
"(",
"self",
".",
"name",
",",
"float",
"(",
"'nan'",
")",
")",
"else",
":",
"if",
"self",
".",
"allreduce",
":",
"num_inst",
"... | [
37,
4
] | [
55,
52
] | python | en | ['en', 'da', 'en'] | True |
EvalMetric.get_name_value | (self) | Returns zipped name and value pairs.
Returns
A (list of tuples): (name, value) tuple list.
| Returns zipped name and value pairs.
Returns
A (list of tuples): (name, value) tuple list.
| def get_name_value(self):
"""Returns zipped name and value pairs.
Returns
A (list of tuples): (name, value) tuple list.
"""
name, value = self.get()
if not isinstance(name, list):
name = [name]
if not isinstance(value, list):
value = [v... | [
"def",
"get_name_value",
"(",
"self",
")",
":",
"name",
",",
"value",
"=",
"self",
".",
"get",
"(",
")",
"if",
"not",
"isinstance",
"(",
"name",
",",
"list",
")",
":",
"name",
"=",
"[",
"name",
"]",
"if",
"not",
"isinstance",
"(",
"value",
",",
"... | [
57,
4
] | [
67,
37
] | python | en | ['en', 'en', 'en'] | True |
test_user_form | (hass) | Test we get the user initiated form. | Test we get the user initiated form. | async def test_user_form(hass):
"""Test we get the user initiated form."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == RESULT_TYPE_FORM
assert resu... | [
"async",
"def",
"test_user_form",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN"... | [
27,
0
] | [
49,
48
] | python | en | ['en', 'en', 'en'] | True |
test_user_form_show_advanced_options | (hass) | Test we get the user initiated form with advanced options shown. | Test we get the user initiated form with advanced options shown. | async def test_user_form_show_advanced_options(hass):
"""Test we get the user initiated form with advanced options shown."""
await async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER, "show_advanced_op... | [
"async",
"def",
"test_user_form_show_advanced_options",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_in... | [
52,
0
] | [
79,
48
] | python | en | ['en', 'en', 'en'] | True |
test_user_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_user_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
with patch(
"homeassistant.components.nzbget.coordinator.NZBGetAPI.version",
side_effect=NZBGet... | [
"async",
"def",
"test_user_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"with",
"patch... | [
82,
0
] | [
98,
57
] | python | en | ['en', 'en', 'en'] | True |
test_user_form_unexpected_exception | (hass) | Test we handle unexpected exception. | Test we handle unexpected exception. | async def test_user_form_unexpected_exception(hass):
"""Test we handle unexpected exception."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
with patch(
"homeassistant.components.nzbget.coordinator.NZBGetAPI.version",
side_effect=... | [
"async",
"def",
"test_user_form_unexpected_exception",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"with",
... | [
101,
0
] | [
117,
40
] | python | en | ['de', 'en', 'en'] | True |
test_user_form_single_instance_allowed | (hass) | Test that configuring more than one instance is rejected. | Test that configuring more than one instance is rejected. | async def test_user_form_single_instance_allowed(hass):
"""Test that configuring more than one instance is rejected."""
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE... | [
"async",
"def",
"test_user_form_single_instance_allowed",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"ENTRY_CONFIG",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",
"await",
"hass"... | [
120,
0
] | [
131,
56
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow | (hass, nzbget_api) | Test updating options. | Test updating options. | async def test_options_flow(hass, nzbget_api):
"""Test updating options."""
entry = MockConfigEntry(
domain=DOMAIN,
data=ENTRY_CONFIG,
options={CONF_SCAN_INTERVAL: 5},
)
entry.add_to_hass(hass)
with patch("homeassistant.components.nzbget.PLATFORMS", []):
await hass.c... | [
"async",
"def",
"test_options_flow",
"(",
"hass",
",",
"nzbget_api",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"ENTRY_CONFIG",
",",
"options",
"=",
"{",
"CONF_SCAN_INTERVAL",
":",
"5",
"}",
",",
")",
"entry"... | [
134,
0
] | [
161,
51
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discover_info=None) | Set up Homeworks lights. | Set up Homeworks lights. | def setup_platform(hass, config, add_entities, discover_info=None):
"""Set up Homeworks lights."""
if discover_info is None:
return
controller = hass.data[HOMEWORKS_CONTROLLER]
devs = []
for dimmer in discover_info[CONF_DIMMERS]:
dev = HomeworksLight(
controller, dimmer[... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discover_info",
"=",
"None",
")",
":",
"if",
"discover_info",
"is",
"None",
":",
"return",
"controller",
"=",
"hass",
".",
"data",
"[",
"HOMEWORKS_CONTROLLER",
"]",
"devs",
"=",
... | [
19,
0
] | [
31,
28
] | python | en | ['en', 'da', 'en'] | True |
HomeworksLight.__init__ | (self, controller, addr, name, rate) | Create device with Addr, name, and rate. | Create device with Addr, name, and rate. | def __init__(self, controller, addr, name, rate):
"""Create device with Addr, name, and rate."""
super().__init__(controller, addr, name)
self._rate = rate
self._level = 0
self._prev_level = 0 | [
"def",
"__init__",
"(",
"self",
",",
"controller",
",",
"addr",
",",
"name",
",",
"rate",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"controller",
",",
"addr",
",",
"name",
")",
"self",
".",
"_rate",
"=",
"rate",
"self",
".",
"_level",
"=",... | [
37,
4
] | [
42,
28
] | python | en | ['en', 'en', 'en'] | True |
HomeworksLight.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
signal = f"homeworks_entity_{self._addr}"
_LOGGER.debug("connecting %s", signal)
self.async_on_remove(
async_dispatcher_connect(self.hass, signal, self._update_callback)
)
self._cont... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"signal",
"=",
"f\"homeworks_entity_{self._addr}\"",
"_LOGGER",
".",
"debug",
"(",
"\"connecting %s\"",
",",
"signal",
")",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".... | [
44,
4
] | [
51,
57
] | python | en | ['en', 'en', 'en'] | True |
HomeworksLight.supported_features | (self) | Supported features. | Supported features. | def supported_features(self):
"""Supported features."""
return SUPPORT_BRIGHTNESS | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BRIGHTNESS"
] | [
54,
4
] | [
56,
33
] | python | en | ['en', 'en', 'en'] | False |
HomeworksLight.turn_on | (self, **kwargs) | Turn on the light. | Turn on the light. | def turn_on(self, **kwargs):
"""Turn on the light."""
if ATTR_BRIGHTNESS in kwargs:
new_level = kwargs[ATTR_BRIGHTNESS]
elif self._prev_level == 0:
new_level = 255
else:
new_level = self._prev_level
self._set_brightness(new_level) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"new_level",
"=",
"kwargs",
"[",
"ATTR_BRIGHTNESS",
"]",
"elif",
"self",
".",
"_prev_level",
"==",
"0",
":",
"new_level",
"=",
"255",
"else",
... | [
58,
4
] | [
66,
39
] | python | en | ['en', 'et', 'en'] | True |
HomeworksLight.turn_off | (self, **kwargs) | Turn off the light. | Turn off the light. | def turn_off(self, **kwargs):
"""Turn off the light."""
self._set_brightness(0) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_set_brightness",
"(",
"0",
")"
] | [
68,
4
] | [
70,
31
] | python | en | ['en', 'zh', 'en'] | True |
HomeworksLight.brightness | (self) | Control the brightness. | Control the brightness. | def brightness(self):
"""Control the brightness."""
return self._level | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_level"
] | [
73,
4
] | [
75,
26
] | python | en | ['en', 'zh', 'en'] | True |
HomeworksLight._set_brightness | (self, level) | Send the brightness level to the device. | Send the brightness level to the device. | def _set_brightness(self, level):
"""Send the brightness level to the device."""
self._controller.fade_dim(
float((level * 100.0) / 255.0), self._rate, 0, self._addr
) | [
"def",
"_set_brightness",
"(",
"self",
",",
"level",
")",
":",
"self",
".",
"_controller",
".",
"fade_dim",
"(",
"float",
"(",
"(",
"level",
"*",
"100.0",
")",
"/",
"255.0",
")",
",",
"self",
".",
"_rate",
",",
"0",
",",
"self",
".",
"_addr",
")"
] | [
77,
4
] | [
81,
9
] | python | en | ['en', 'en', 'en'] | True |
HomeworksLight.device_state_attributes | (self) | Supported attributes. | Supported attributes. | def device_state_attributes(self):
"""Supported attributes."""
return {"homeworks_address": self._addr} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"homeworks_address\"",
":",
"self",
".",
"_addr",
"}"
] | [
84,
4
] | [
86,
48
] | python | en | ['en', 'en', 'en'] | False |
HomeworksLight.is_on | (self) | Is the light on/off. | Is the light on/off. | def is_on(self):
"""Is the light on/off."""
return self._level != 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_level",
"!=",
"0"
] | [
89,
4
] | [
91,
31
] | python | en | ['en', 'en', 'en'] | True |
HomeworksLight._update_callback | (self, msg_type, values) | Process device specific messages. | Process device specific messages. | def _update_callback(self, msg_type, values):
"""Process device specific messages."""
if msg_type == HW_LIGHT_CHANGED:
self._level = int((values[1] * 255.0) / 100.0)
if self._level != 0:
self._prev_level = self._level
self.async_write_ha_state() | [
"def",
"_update_callback",
"(",
"self",
",",
"msg_type",
",",
"values",
")",
":",
"if",
"msg_type",
"==",
"HW_LIGHT_CHANGED",
":",
"self",
".",
"_level",
"=",
"int",
"(",
"(",
"values",
"[",
"1",
"]",
"*",
"255.0",
")",
"/",
"100.0",
")",
"if",
"self... | [
94,
4
] | [
101,
39
] | python | en | ['ca', 'en', 'en'] | True |
RegistrationsView.post | (self, request: Request, data: Dict) | Handle the POST request for registration. | Handle the POST request for registration. | async def post(self, request: Request, data: Dict) -> Response:
"""Handle the POST request for registration."""
hass = request.app["hass"]
webhook_id = secrets.token_hex()
if hass.components.cloud.async_active_subscription():
data[
CONF_CLOUDHOOK_URL
... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
":",
"Request",
",",
"data",
":",
"Dict",
")",
"->",
"Response",
":",
"hass",
"=",
"request",
".",
"app",
"[",
"\"hass\"",
"]",
"webhook_id",
"=",
"secrets",
".",
"token_hex",
"(",
")",
"if",
"hass... | [
61,
4
] | [
113,
9
] | python | en | ['en', 'en', 'en'] | True |
consistency | (func, args, expected, n=10**4) | Analyze and report on the consistency of a function. | Analyze and report on the consistency of a function. | def consistency(func, args, expected, n=10**4):
"""Analyze and report on the consistency of a function."""
print('\n[CONSISTENCY TEST] {0}'.format(func.__doc__.format(*args)))
def show(num, den, t, p, end='\r'):
print('{3}|{4:.3f}: {0}/{1} = {2}'.format(num, den, num/den, str(timedelta(seconds=t)),... | [
"def",
"consistency",
"(",
"func",
",",
"args",
",",
"expected",
",",
"n",
"=",
"10",
"**",
"4",
")",
":",
"print",
"(",
"'\\n[CONSISTENCY TEST] {0}'",
".",
"format",
"(",
"func",
".",
"__doc__",
".",
"format",
"(",
"*",
"args",
")",
")",
")",
"def",... | [
5,
0
] | [
22,
54
] | python | en | ['en', 'en', 'en'] | True |
max_over | (n, func, args=None) | Compute the maximum value returned by func(args) in n runs. | Compute the maximum value returned by func(args) in n runs. | def max_over(n, func, args=None):
"""Compute the maximum value returned by func(args) in n runs."""
m = 0
for i in range(n):
v = func(*args) if args else func()
if v > m:
m = v
return m | [
"def",
"max_over",
"(",
"n",
",",
"func",
",",
"args",
"=",
"None",
")",
":",
"m",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"v",
"=",
"func",
"(",
"*",
"args",
")",
"if",
"args",
"else",
"func",
"(",
")",
"if",
"v",
">",
"... | [
25,
0
] | [
32,
12
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass) | Set up the script config API. | Set up the script config API. | async def async_setup(hass):
"""Set up the script config API."""
async def hook(action, config_key):
"""post_write_hook for Config View that reloads scripts."""
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
hass.http.register_view(
EditKeyBasedConfigView(
DOMAI... | [
"async",
"def",
"async_setup",
"(",
"hass",
")",
":",
"async",
"def",
"hook",
"(",
"action",
",",
"config_key",
")",
":",
"\"\"\"post_write_hook for Config View that reloads scripts.\"\"\"",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
... | [
10,
0
] | [
28,
15
] | python | en | ['en', 'ca', 'en'] | True |
async_get_actions | (hass: HomeAssistant, device_id: str) | List device actions for Fan devices. | List device actions for Fan devices. | async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device actions for Fan devices."""
registry = await entity_registry.async_get_registry(hass)
actions = []
# Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device... | [
"async",
"def",
"async_get_actions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"actions",
"=",
"[",
"... | [
30,
0
] | [
57,
18
] | python | en | ['fr', 'en', 'en'] | True |
async_call_action_from_config | (
hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context]
) | Execute a device action. | Execute a device action. | async def async_call_action_from_config(
hass: HomeAssistant, config: dict, variables: dict, context: Optional[Context]
) -> None:
"""Execute a device action."""
config = ACTION_SCHEMA(config)
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
if config[CONF_TYPE] == "turn_on":
servic... | [
"async",
"def",
"async_call_action_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
",",
"variables",
":",
"dict",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
")",
"->",
"None",
":",
"config",
"=",
"ACTION_SCHEMA",
"(",
... | [
60,
0
] | [
75,
5
] | python | en | ['ro', 'en', 'en'] | True |
parse_args | () | Definite the arguments users need to follow and input | Definite the arguments users need to follow and input | def parse_args():
logging.getLogger().setLevel(logging.ERROR)
'''Definite the arguments users need to follow and input'''
parser = argparse.ArgumentParser(prog='nnictl', description='use nnictl command to control nni experiments')
parser.add_argument('--version', '-v', action='store_true')
parser.s... | [
"def",
"parse_args",
"(",
")",
":",
"logging",
".",
"getLogger",
"(",
")",
".",
"setLevel",
"(",
"logging",
".",
"ERROR",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"'nnictl'",
",",
"description",
"=",
"'use nnictl command to co... | [
35,
0
] | [
277,
19
] | python | en | ['en', 'en', 'en'] | True |
ZeroLayer.forward | (self, x) | n, c, h, w = x.size()
h //= self.stride
w //= self.stride
device = x.get_device() if x.is_cuda else torch.device('cpu')
# noinspection PyUnresolvedReferences
padding = torch.zeros(n, c, h, w, device=device, requires_grad=False)
return padding | n, c, h, w = x.size()
h //= self.stride
w //= self.stride
device = x.get_device() if x.is_cuda else torch.device('cpu')
# noinspection PyUnresolvedReferences
padding = torch.zeros(n, c, h, w, device=device, requires_grad=False)
return padding | def forward(self, x):
'''n, c, h, w = x.size()
h //= self.stride
w //= self.stride
device = x.get_device() if x.is_cuda else torch.device('cpu')
# noinspection PyUnresolvedReferences
padding = torch.zeros(n, c, h, w, device=device, requires_grad=False)
return padd... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"return",
"x",
"*",
"0"
] | [
310,
4
] | [
318,
20
] | python | cy | ['en', 'cy', 'pl'] | False |
BuiltinTunersTestCase.import_data_test_for_pbt | (self) |
test1: import data with complete epoch
test2: import data with incomplete epoch
|
test1: import data with complete epoch
test2: import data with incomplete epoch
| def import_data_test_for_pbt(self):
"""
test1: import data with complete epoch
test2: import data with incomplete epoch
"""
search_space = {
"choice_str": {
"_type": "choice",
"_value": ["cat", "dog", "elephant", "cow", "sheep", "panda"... | [
"def",
"import_data_test_for_pbt",
"(",
"self",
")",
":",
"search_space",
"=",
"{",
"\"choice_str\"",
":",
"{",
"\"_type\"",
":",
"\"choice\"",
",",
"\"_value\"",
":",
"[",
"\"cat\"",
",",
"\"dog\"",
",",
"\"elephant\"",
",",
"\"cow\"",
",",
"\"sheep\"",
",",
... | [
195,
4
] | [
249,
41
] | python | en | ['en', 'error', 'th'] | False |
BuiltinTunersTestCase.import_data_test | (self, tuner_factory, stype="choice_str") |
import data at the beginning with number value and dict value
import data in the middle also with number value and dict value, and duplicate data record
generate parameters after data import
Parameters
----------
tuner_factory : lambda
a lambda for instantia... |
import data at the beginning with number value and dict value
import data in the middle also with number value and dict value, and duplicate data record
generate parameters after data import | def import_data_test(self, tuner_factory, stype="choice_str"):
"""
import data at the beginning with number value and dict value
import data in the middle also with number value and dict value, and duplicate data record
generate parameters after data import
Parameters
--... | [
"def",
"import_data_test",
"(",
"self",
",",
"tuner_factory",
",",
"stype",
"=",
"\"choice_str\"",
")",
":",
"if",
"stype",
"==",
"\"choice_str\"",
":",
"search_space",
"=",
"{",
"\"choice_str\"",
":",
"{",
"\"_type\"",
":",
"\"choice\"",
",",
"\"_value\"",
":... | [
251,
4
] | [
309,
79
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the CO2signal sensor. | Set up the CO2signal sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the CO2signal sensor."""
token = config[CONF_TOKEN]
lat = config.get(CONF_LATITUDE, hass.config.latitude)
lon = config.get(CONF_LONGITUDE, hass.config.longitude)
country_code = config.get(CONF_COUNTRY_CODE)
_LOGGER.d... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"token",
"=",
"config",
"[",
"CONF_TOKEN",
"]",
"lat",
"=",
"config",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
".",
"config",
".... | [
39,
0
] | [
51,
28
] | python | en | ['en', 'su', 'en'] | True |
CO2Sensor.__init__ | (self, token, country_code, lat, lon) | Initialize the sensor. | Initialize the sensor. | def __init__(self, token, country_code, lat, lon):
"""Initialize the sensor."""
self._token = token
self._country_code = country_code
self._latitude = lat
self._longitude = lon
self._data = None
if country_code is not None:
device_name = country_code
... | [
"def",
"__init__",
"(",
"self",
",",
"token",
",",
"country_code",
",",
"lat",
",",
"lon",
")",
":",
"self",
".",
"_token",
"=",
"token",
"self",
".",
"_country_code",
"=",
"country_code",
"self",
".",
"_latitude",
"=",
"lat",
"self",
".",
"_longitude",
... | [
57,
4
] | [
70,
62
] | python | en | ['en', 'en', 'en'] | True |
CO2Sensor.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._friendly_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_friendly_name"
] | [
73,
4
] | [
75,
34
] | python | en | ['en', 'mi', 'en'] | True |
CO2Sensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return "mdi:molecule-co2" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:molecule-co2\""
] | [
78,
4
] | [
80,
33
] | python | en | ['en', 'en', 'en'] | True |
CO2Sensor.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._data | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data"
] | [
83,
4
] | [
85,
25
] | python | en | ['en', 'en', 'en'] | True |
CO2Sensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return CO2_INTENSITY_UNIT | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"CO2_INTENSITY_UNIT"
] | [
88,
4
] | [
90,
33
] | python | en | ['en', 'en', 'en'] | True |
CO2Sensor.device_state_attributes | (self) | Return the state attributes of the last update. | Return the state attributes of the last update. | def device_state_attributes(self):
"""Return the state attributes of the last update."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
93,
4
] | [
95,
46
] | python | en | ['en', 'en', 'en'] | True |
CO2Sensor.update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | def update(self):
"""Get the latest data and updates the states."""
_LOGGER.debug("Update data for %s", self._friendly_name)
if self._country_code is not None:
self._data = CO2Signal.get_latest_carbon_intensity(
self._token, country_code=self._country_code
... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Update data for %s\"",
",",
"self",
".",
"_friendly_name",
")",
"if",
"self",
".",
"_country_code",
"is",
"not",
"None",
":",
"self",
".",
"_data",
"=",
"CO2Signal",
".",
"get_latest_... | [
97,
4
] | [
111,
41
] | python | en | ['en', 'en', 'en'] | True |
deprecated_substitute | (substitute_name: str) | Help migrate properties to new names.
When a property is added to replace an older property, this decorator can
be added to the new property, listing the old property as the substitute.
If the old property is defined, its value will be used instead, and a log
warning will be issued alerting the user of... | Help migrate properties to new names. | def deprecated_substitute(substitute_name: str) -> Callable[..., Callable]:
"""Help migrate properties to new names.
When a property is added to replace an older property, this decorator can
be added to the new property, listing the old property as the substitute.
If the old property is defined, its va... | [
"def",
"deprecated_substitute",
"(",
"substitute_name",
":",
"str",
")",
"->",
"Callable",
"[",
"...",
",",
"Callable",
"]",
":",
"def",
"decorator",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"\"\"\"Decorate function as deprecated.\"\"\"",
"def",
... | [
6,
0
] | [
44,
20
] | python | en | ['en', 'en', 'en'] | True |
get_deprecated | (
config: Dict[str, Any], new_name: str, old_name: str, default: Optional[Any] = None
) | Allow an old config name to be deprecated with a replacement.
If the new config isn't found, but the old one is, the old value is used
and a warning is issued to the user.
| Allow an old config name to be deprecated with a replacement. | def get_deprecated(
config: Dict[str, Any], new_name: str, old_name: str, default: Optional[Any] = None
) -> Optional[Any]:
"""Allow an old config name to be deprecated with a replacement.
If the new config isn't found, but the old one is, the old value is used
and a warning is issued to the user.
... | [
"def",
"get_deprecated",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"new_name",
":",
"str",
",",
"old_name",
":",
"str",
",",
"default",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"Any",
"]",
":",
... | [
47,
0
] | [
74,
40
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Pushbullet notification service. | Get the Pushbullet notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Pushbullet notification service."""
try:
pushbullet = PushBullet(config[CONF_API_KEY])
except InvalidKeyError:
_LOGGER.error("Wrong API key supplied")
return None
return PushBulletNotificationService(pushbullet) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"try",
":",
"pushbullet",
"=",
"PushBullet",
"(",
"config",
"[",
"CONF_API_KEY",
"]",
")",
"except",
"InvalidKeyError",
":",
"_LOGGER",
".",
"error",
"(",
"\"Wr... | [
28,
0
] | [
37,
52
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationService.__init__ | (self, pb) | Initialize the service. | Initialize the service. | def __init__(self, pb):
"""Initialize the service."""
self.pushbullet = pb
self.pbtargets = {}
self.refresh() | [
"def",
"__init__",
"(",
"self",
",",
"pb",
")",
":",
"self",
".",
"pushbullet",
"=",
"pb",
"self",
".",
"pbtargets",
"=",
"{",
"}",
"self",
".",
"refresh",
"(",
")"
] | [
43,
4
] | [
47,
22
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationService.refresh | (self) | Refresh devices, contacts, etc.
pbtargets stores all targets available from this Pushbullet instance
into a dict. These are Pushbullet objects!. It sacrifices a bit of
memory for faster processing at send_message.
As of sept 2015, contacts were replaced by chats. This is not
im... | Refresh devices, contacts, etc. | def refresh(self):
"""Refresh devices, contacts, etc.
pbtargets stores all targets available from this Pushbullet instance
into a dict. These are Pushbullet objects!. It sacrifices a bit of
memory for faster processing at send_message.
As of sept 2015, contacts were replaced by... | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"pushbullet",
".",
"refresh",
"(",
")",
"self",
".",
"pbtargets",
"=",
"{",
"\"device\"",
":",
"{",
"tgt",
".",
"nickname",
".",
"lower",
"(",
")",
":",
"tgt",
"for",
"tgt",
"in",
"self",
".",
... | [
49,
4
] | [
65,
9
] | python | en | ['fr', 'en', 'en'] | True |
PushBulletNotificationService.send_message | (self, message=None, **kwargs) | Send a message to a specified target.
If no target specified, a 'normal' push will be sent to all devices
linked to the Pushbullet account.
Email is special, these are assumed to always exist. We use a special
call which doesn't require a push object.
| Send a message to a specified target. | def send_message(self, message=None, **kwargs):
"""Send a message to a specified target.
If no target specified, a 'normal' push will be sent to all devices
linked to the Pushbullet account.
Email is special, these are assumed to always exist. We use a special
call which doesn't... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"targets",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TARGET",
")",
"title",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
",",
"ATTR_TITLE_DEFAULT",
")",
"d... | [
67,
4
] | [
128,
24
] | python | en | ['en', 'en', 'en'] | True |
PushBulletNotificationService._push_data | (self, message, title, data, pusher, email=None, phonenumber=None) | Create the message content. | Create the message content. | def _push_data(self, message, title, data, pusher, email=None, phonenumber=None):
"""Create the message content."""
if data is None:
data = {}
data_list = data.get(ATTR_LIST)
url = data.get(ATTR_URL)
filepath = data.get(ATTR_FILE)
file_url = data.get(ATTR_FIL... | [
"def",
"_push_data",
"(",
"self",
",",
"message",
",",
"title",
",",
"data",
",",
"pusher",
",",
"email",
"=",
"None",
",",
"phonenumber",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"{",
"}",
"data_list",
"=",
"data",
".",... | [
130,
4
] | [
176,
51
] | python | en | ['en', 'en', 'en'] | True |
get_devices_response | () | Define a fixture for a successful /devices response. | Define a fixture for a successful /devices response. | def get_devices_response():
"""Define a fixture for a successful /devices response."""
return mock_coro() | [
"def",
"get_devices_response",
"(",
")",
":",
"return",
"mock_coro",
"(",
")"
] | [
16,
0
] | [
18,
22
] | python | en | ['en', 'en', 'en'] | True |
mock_aioambient | (get_devices_response) | Mock the aioambient library. | Mock the aioambient library. | def mock_aioambient(get_devices_response):
"""Mock the aioambient library."""
with patch("homeassistant.components.ambient_station.config_flow.Client") as Client:
Client().api.get_devices.return_value = get_devices_response
yield Client | [
"def",
"mock_aioambient",
"(",
"get_devices_response",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ambient_station.config_flow.Client\"",
")",
"as",
"Client",
":",
"Client",
"(",
")",
".",
"api",
".",
"get_devices",
".",
"return_value",
"=",
"get_devic... | [
22,
0
] | [
26,
20
] | python | en | ['en', 'en', 'en'] | True |
test_duplicate_error | (hass) | Test that errors are shown when duplicates are added. | Test that errors are shown when duplicates are added. | async def test_duplicate_error(hass):
"""Test that errors are shown when duplicates are added."""
conf = {CONF_API_KEY: "12345abcde12345abcde", CONF_APP_KEY: "67890fghij67890fghij"}
MockConfigEntry(
domain=DOMAIN, unique_id="67890fghij67890fghij", data=conf
).add_to_hass(hass)
result = awa... | [
"async",
"def",
"test_duplicate_error",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"12345abcde12345abcde\"",
",",
"CONF_APP_KEY",
":",
"\"67890fghij67890fghij\"",
"}",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"... | [
29,
0
] | [
42,
51
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_api_key | (hass, mock_aioambient) | Test that an invalid API/App Key throws an error. | Test that an invalid API/App Key throws an error. | async def test_invalid_api_key(hass, mock_aioambient):
"""Test that an invalid API/App Key throws an error."""
conf = {CONF_API_KEY: "12345abcde12345abcde", CONF_APP_KEY: "67890fghij67890fghij"}
flow = config_flow.AmbientStationFlowHandler()
flow.hass = hass
flow.context = {"source": SOURCE_USER}
... | [
"async",
"def",
"test_invalid_api_key",
"(",
"hass",
",",
"mock_aioambient",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"12345abcde12345abcde\"",
",",
"CONF_APP_KEY",
":",
"\"67890fghij67890fghij\"",
"}",
"flow",
"=",
"config_flow",
".",
"AmbientStationFlowHan... | [
48,
0
] | [
57,
54
] | python | en | ['en', 'gd', 'en'] | True |
test_no_devices | (hass, mock_aioambient) | Test that an account with no associated devices throws an error. | Test that an account with no associated devices throws an error. | async def test_no_devices(hass, mock_aioambient):
"""Test that an account with no associated devices throws an error."""
conf = {CONF_API_KEY: "12345abcde12345abcde", CONF_APP_KEY: "67890fghij67890fghij"}
flow = config_flow.AmbientStationFlowHandler()
flow.hass = hass
flow.context = {"source": SOUR... | [
"async",
"def",
"test_no_devices",
"(",
"hass",
",",
"mock_aioambient",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"12345abcde12345abcde\"",
",",
"CONF_APP_KEY",
":",
"\"67890fghij67890fghij\"",
"}",
"flow",
"=",
"config_flow",
".",
"AmbientStationFlowHandler"... | [
61,
0
] | [
70,
53
] | python | en | ['en', 'en', 'en'] | True |
test_show_form | (hass) | Test that the form is served with no input. | Test that the form is served with no input. | async def test_show_form(hass):
"""Test that the form is served with no input."""
flow = config_flow.AmbientStationFlowHandler()
flow.hass = hass
flow.context = {"source": SOURCE_USER}
result = await flow.async_step_user(user_input=None)
assert result["type"] == data_entry_flow.RESULT_TYPE_FOR... | [
"async",
"def",
"test_show_form",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"AmbientStationFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
"result",
"=",
"awai... | [
73,
0
] | [
82,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import | (hass, mock_aioambient) | Test that the import step works. | Test that the import step works. | async def test_step_import(hass, mock_aioambient):
"""Test that the import step works."""
conf = {CONF_API_KEY: "12345abcde12345abcde", CONF_APP_KEY: "67890fghij67890fghij"}
flow = config_flow.AmbientStationFlowHandler()
flow.hass = hass
flow.context = {"source": SOURCE_USER}
result = await fl... | [
"async",
"def",
"test_step_import",
"(",
"hass",
",",
"mock_aioambient",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"12345abcde12345abcde\"",
",",
"CONF_APP_KEY",
":",
"\"67890fghij67890fghij\"",
"}",
"flow",
"=",
"config_flow",
".",
"AmbientStationFlowHandler... | [
89,
0
] | [
103,
5
] | python | en | ['en', 'en', 'en'] | True |
test_step_user | (hass, mock_aioambient) | Test that the user step works. | Test that the user step works. | async def test_step_user(hass, mock_aioambient):
"""Test that the user step works."""
conf = {CONF_API_KEY: "12345abcde12345abcde", CONF_APP_KEY: "67890fghij67890fghij"}
flow = config_flow.AmbientStationFlowHandler()
flow.hass = hass
flow.context = {"source": SOURCE_USER}
result = await flow.a... | [
"async",
"def",
"test_step_user",
"(",
"hass",
",",
"mock_aioambient",
")",
":",
"conf",
"=",
"{",
"CONF_API_KEY",
":",
"\"12345abcde12345abcde\"",
",",
"CONF_APP_KEY",
":",
"\"67890fghij67890fghij\"",
"}",
"flow",
"=",
"config_flow",
".",
"AmbientStationFlowHandler",... | [
110,
0
] | [
124,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Defer sensor setup to the shared sensor module. | Defer sensor setup to the shared sensor module. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Defer sensor setup to the shared sensor module."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
sensors_list = []
for sensor in SENSORS:
sensors_list.append(
PoolSenseSensor(coordinator, config_entry.d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"sensors_list",
"=",
"[",
"]",
"for",
"sensor"... | [
68,
0
] | [
78,
43
] | python | en | ['en', 'pt', 'en'] | True |
PoolSenseSensor.name | (self) | Return the name of the particular component. | Return the name of the particular component. | def name(self):
"""Return the name of the particular component."""
return f"PoolSense {SENSORS[self.info_type]['name']}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"PoolSense {SENSORS[self.info_type]['name']}\""
] | [
85,
4
] | [
87,
61
] | python | en | ['en', 'en', 'en'] | True |
PoolSenseSensor.state | (self) | State of the sensor. | State of the sensor. | def state(self):
"""State of the sensor."""
return self.coordinator.data[self.info_type] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"info_type",
"]"
] | [
90,
4
] | [
92,
52
] | python | en | ['en', 'en', 'en'] | True |
PoolSenseSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return SENSORS[self.info_type]["device_class"] | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"SENSORS",
"[",
"self",
".",
"info_type",
"]",
"[",
"\"device_class\"",
"]"
] | [
95,
4
] | [
97,
54
] | python | en | ['en', 'en', 'en'] | True |
PoolSenseSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
return SENSORS[self.info_type]["icon"] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSORS",
"[",
"self",
".",
"info_type",
"]",
"[",
"\"icon\"",
"]"
] | [
100,
4
] | [
102,
46
] | python | en | ['en', 'sr', 'en'] | True |
PoolSenseSensor.unit_of_measurement | (self) | Return unit of measurement. | Return unit of measurement. | def unit_of_measurement(self):
"""Return unit of measurement."""
return SENSORS[self.info_type]["unit"] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSORS",
"[",
"self",
".",
"info_type",
"]",
"[",
"\"unit\"",
"]"
] | [
105,
4
] | [
107,
46
] | python | en | ['en', 'la', 'en'] | True |
PoolSenseSensor.device_state_attributes | (self) | Return device attributes. | Return device attributes. | def device_state_attributes(self):
"""Return device attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
110,
4
] | [
112,
46
] | python | en | ['es', 'mt', 'en'] | False |
is_virtual_env | () | Return if we run in a virtual environment. | Return if we run in a virtual environment. | def is_virtual_env() -> bool:
"""Return if we run in a virtual environment."""
# Check supports venv && virtualenv
return getattr(sys, "base_prefix", sys.prefix) != sys.prefix or hasattr(
sys, "real_prefix"
) | [
"def",
"is_virtual_env",
"(",
")",
"->",
"bool",
":",
"# Check supports venv && virtualenv",
"return",
"getattr",
"(",
"sys",
",",
"\"base_prefix\"",
",",
"sys",
".",
"prefix",
")",
"!=",
"sys",
".",
"prefix",
"or",
"hasattr",
"(",
"sys",
",",
"\"real_prefix\"... | [
26,
0
] | [
31,
5
] | python | en | ['en', 'gd', 'en'] | True |
is_docker_env | () | Return True if we run in a docker env. | Return True if we run in a docker env. | def is_docker_env() -> bool:
"""Return True if we run in a docker env."""
return Path("/.dockerenv").exists() | [
"def",
"is_docker_env",
"(",
")",
"->",
"bool",
":",
"return",
"Path",
"(",
"\"/.dockerenv\"",
")",
".",
"exists",
"(",
")"
] | [
34,
0
] | [
36,
39
] | python | en | ['en', 'fy', 'en'] | True |
is_installed | (package: str) | Check if a package is installed and will be loaded when we import it.
Returns True when the requirement is met.
Returns False when the package is not installed or doesn't meet req.
| Check if a package is installed and will be loaded when we import it. | def is_installed(package: str) -> bool:
"""Check if a package is installed and will be loaded when we import it.
Returns True when the requirement is met.
Returns False when the package is not installed or doesn't meet req.
"""
try:
req = pkg_resources.Requirement.parse(package)
except ... | [
"def",
"is_installed",
"(",
"package",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"req",
"=",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"package",
")",
"except",
"ValueError",
":",
"# This is a zip file. We no longer use this in Home Assistant,",
... | [
39,
0
] | [
55,
20
] | python | en | ['en', 'en', 'en'] | True |
install_package | (
package: str,
upgrade: bool = True,
target: Optional[str] = None,
constraints: Optional[str] = None,
find_links: Optional[str] = None,
no_cache_dir: Optional[bool] = False,
) | Install a package on PyPi. Accepts pip compatible package strings.
Return boolean if install successful.
| Install a package on PyPi. Accepts pip compatible package strings. | def install_package(
package: str,
upgrade: bool = True,
target: Optional[str] = None,
constraints: Optional[str] = None,
find_links: Optional[str] = None,
no_cache_dir: Optional[bool] = False,
) -> bool:
"""Install a package on PyPi. Accepts pip compatible package strings.
Return boole... | [
"def",
"install_package",
"(",
"package",
":",
"str",
",",
"upgrade",
":",
"bool",
"=",
"True",
",",
"target",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"constraints",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"find_links",
":",
"... | [
58,
0
] | [
101,
15
] | python | en | ['en', 'en', 'en'] | True |
async_get_user_site | (deps_dir: str) | Return user local library path.
This function is a coroutine.
| Return user local library path. | async def async_get_user_site(deps_dir: str) -> str:
"""Return user local library path.
This function is a coroutine.
"""
env = os.environ.copy()
env["PYTHONUSERBASE"] = os.path.abspath(deps_dir)
args = [sys.executable, "-m", "site", "--user-site"]
process = await asyncio.create_subprocess_... | [
"async",
"def",
"async_get_user_site",
"(",
"deps_dir",
":",
"str",
")",
"->",
"str",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"env",
"[",
"\"PYTHONUSERBASE\"",
"]",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"deps_dir",
")",
"... | [
104,
0
] | [
121,
18
] | python | en | ['en', 'en', 'en'] | True |
ConfigEntrySomfyApi.__init__ | (
self,
hass: core.HomeAssistant,
config_entry: config_entries.ConfigEntry,
implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation,
) | Initialize the Config Entry Somfy API. | Initialize the Config Entry Somfy API. | def __init__(
self,
hass: core.HomeAssistant,
config_entry: config_entries.ConfigEntry,
implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation,
):
"""Initialize the Config Entry Somfy API."""
self.hass = hass
self.config_entry = config_entry
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
",",
"implementation",
":",
"config_entry_oauth2_flow",
".",
"AbstractOAuth2Implementation",
",",
")",
":",
"self",
".",... | [
13,
4
] | [
25,
62
] | 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.