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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
setup_mock_discovery | (
mock_discovery, with_name=False, with_mac=False, two_devices=False
) | Prepare mock discovery result. | Prepare mock discovery result. | def setup_mock_discovery(
mock_discovery, with_name=False, with_mac=False, two_devices=False
):
"""Prepare mock discovery result."""
services = []
for item in DISCOVERY:
service = MagicMock()
service.getXAddrs = MagicMock(
return_value=[
f"http://{item[config_... | [
"def",
"setup_mock_discovery",
"(",
"mock_discovery",
",",
"with_name",
"=",
"False",
",",
"with_mac",
"=",
"False",
",",
"two_devices",
"=",
"False",
")",
":",
"services",
"=",
"[",
"]",
"for",
"item",
"in",
"DISCOVERY",
":",
"service",
"=",
"MagicMock",
... | [
97,
0
] | [
125,
42
] | python | en | ['en', 'en', 'en'] | True |
setup_mock_device | (mock_device) | Prepare mock ONVIFDevice. | Prepare mock ONVIFDevice. | def setup_mock_device(mock_device):
"""Prepare mock ONVIFDevice."""
mock_device.async_setup = AsyncMock(return_value=True)
def mock_constructor(hass, config):
"""Fake the controller constructor."""
return mock_device
mock_device.side_effect = mock_constructor | [
"def",
"setup_mock_device",
"(",
"mock_device",
")",
":",
"mock_device",
".",
"async_setup",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"def",
"mock_constructor",
"(",
"hass",
",",
"config",
")",
":",
"\"\"\"Fake the controller constructor.\"\"\"",
"re... | [
128,
0
] | [
136,
46
] | python | en | ['en', 'sl', 'it'] | False |
setup_onvif_integration | (
hass,
config=None,
options=None,
unique_id=MAC,
entry_id="1",
source=config_entries.SOURCE_USER,
) | Create an ONVIF config entry. | Create an ONVIF config entry. | async def setup_onvif_integration(
hass,
config=None,
options=None,
unique_id=MAC,
entry_id="1",
source=config_entries.SOURCE_USER,
):
"""Create an ONVIF config entry."""
if not config:
config = {
config_flow.CONF_NAME: NAME,
config_flow.CONF_HOST: HOST,
... | [
"async",
"def",
"setup_onvif_integration",
"(",
"hass",
",",
"config",
"=",
"None",
",",
"options",
"=",
"None",
",",
"unique_id",
"=",
"MAC",
",",
"entry_id",
"=",
"\"1\"",
",",
"source",
"=",
"config_entries",
".",
"SOURCE_USER",
",",
")",
":",
"if",
"... | [
139,
0
] | [
180,
23
] | python | en | ['en', 'gd', 'en'] | True |
test_flow_discovered_devices | (hass) | Test that config flow works for discovered devices. | Test that config flow works for discovered devices. | async def test_flow_discovered_devices(hass):
"""Test that config flow works for discovered devices."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert ... | [
"async",
"def",
"test_flow_discovered_devices",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",... | [
183,
0
] | [
244,
9
] | python | en | ['en', 'en', 'en'] | True |
test_flow_discovered_devices_ignore_configured_manual_input | (hass) | Test that config flow discovery ignores configured devices. | Test that config flow discovery ignores configured devices. | async def test_flow_discovered_devices_ignore_configured_manual_input(hass):
"""Test that config flow discovery ignores configured devices."""
await setup_onvif_integration(hass)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
... | [
"async",
"def",
"test_flow_discovered_devices_ignore_configured_manual_input",
"(",
"hass",
")",
":",
"await",
"setup_onvif_integration",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
... | [
247,
0
] | [
283,
47
] | python | en | ['en', 'en', 'en'] | True |
test_flow_discovered_no_device | (hass) | Test that config flow discovery no device. | Test that config flow discovery no device. | async def test_flow_discovered_no_device(hass):
"""Test that config flow discovery no device."""
await setup_onvif_integration(hass)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_... | [
"async",
"def",
"test_flow_discovered_no_device",
"(",
"hass",
")",
":",
"await",
"setup_onvif_integration",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
"DOMAIN",
",",
"context... | [
286,
0
] | [
313,
47
] | python | en | ['en', 'en', 'en'] | True |
test_flow_discovery_ignore_existing_and_abort | (hass) | Test that config flow discovery ignores setup devices. | Test that config flow discovery ignores setup devices. | async def test_flow_discovery_ignore_existing_and_abort(hass):
"""Test that config flow discovery ignores setup devices."""
await setup_onvif_integration(hass)
await setup_onvif_integration(
hass,
config={
config_flow.CONF_NAME: DISCOVERY[1]["EPR"],
config_flow.CONF_H... | [
"async",
"def",
"test_flow_discovery_ignore_existing_and_abort",
"(",
"hass",
")",
":",
"await",
"setup_onvif_integration",
"(",
"hass",
")",
"await",
"setup_onvif_integration",
"(",
"hass",
",",
"config",
"=",
"{",
"config_flow",
".",
"CONF_NAME",
":",
"DISCOVERY",
... | [
316,
0
] | [
370,
66
] | python | en | ['en', 'en', 'en'] | True |
test_flow_manual_entry | (hass) | Test that config flow works for discovered devices. | Test that config flow works for discovered devices. | async def test_flow_manual_entry(hass):
"""Test that config flow works for discovered devices."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result[... | [
"async",
"def",
"test_flow_manual_entry",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SO... | [
373,
0
] | [
430,
9
] | python | en | ['en', 'en', 'en'] | True |
test_flow_import_not_implemented | (hass) | Test that config flow uses Serial Number when no MAC available. | Test that config flow uses Serial Number when no MAC available. | async def test_flow_import_not_implemented(hass):
"""Test that config flow uses Serial Number when no MAC available."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera, patch(
"homeassistant.components.onvif.ONVIFDevice"
) as mock_device, patch(... | [
"async",
"def",
"test_flow_import_not_implemented",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
",",
"patch",
"(",
"\"homeassistant.components.onvif.ONVIFDevice\"",
")",
"as",
"mock_... | [
433,
0
] | [
471,
9
] | python | en | ['en', 'en', 'en'] | True |
test_flow_import_no_mac | (hass) | Test that config flow uses Serial Number when no MAC available. | Test that config flow uses Serial Number when no MAC available. | async def test_flow_import_no_mac(hass):
"""Test that config flow uses Serial Number when no MAC available."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera, patch(
"homeassistant.components.onvif.ONVIFDevice"
) as mock_device, patch(
... | [
"async",
"def",
"test_flow_import_no_mac",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
",",
"patch",
"(",
"\"homeassistant.components.onvif.ONVIFDevice\"",
")",
"as",
"mock_device",
... | [
474,
0
] | [
512,
9
] | python | en | ['en', 'en', 'en'] | True |
test_flow_import_no_mac_or_serial | (hass) | Test that config flow fails when no MAC or Serial Number available. | Test that config flow fails when no MAC or Serial Number available. | async def test_flow_import_no_mac_or_serial(hass):
"""Test that config flow fails when no MAC or Serial Number available."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(
mock_onvif_camera, with_interfaces=Fal... | [
"async",
"def",
"test_flow_import_no_mac_or_serial",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
",",
"with_interfaces",
"="... | [
515,
0
] | [
537,
43
] | python | en | ['en', 'en', 'en'] | True |
test_flow_import_no_h264 | (hass) | Test that config flow fails when no MAC available. | Test that config flow fails when no MAC available. | async def test_flow_import_no_h264(hass):
"""Test that config flow fails when no MAC available."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(mock_onvif_camera, with_h264=False)
result = await hass.config_entri... | [
"async",
"def",
"test_flow_import_no_h264",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
",",
"with_h264",
"=",
"False",
... | [
540,
0
] | [
560,
44
] | python | en | ['en', 'en', 'en'] | True |
test_flow_import_onvif_api_error | (hass) | Test that config flow fails when ONVIF API fails. | Test that config flow fails when ONVIF API fails. | async def test_flow_import_onvif_api_error(hass):
"""Test that config flow fails when ONVIF API fails."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(mock_onvif_camera)
mock_onvif_camera.create_devicemgmt_service... | [
"async",
"def",
"test_flow_import_onvif_api_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
")",
"mock_onvif_camera",
".... | [
563,
0
] | [
586,
48
] | python | en | ['en', 'fr', 'en'] | True |
test_flow_import_onvif_auth_error | (hass) | Test that config flow fails when ONVIF API fails. | Test that config flow fails when ONVIF API fails. | async def test_flow_import_onvif_auth_error(hass):
"""Test that config flow fails when ONVIF API fails."""
with patch(
"homeassistant.components.onvif.config_flow.get_device"
) as mock_onvif_camera:
setup_mock_onvif_camera(mock_onvif_camera)
mock_onvif_camera.create_devicemgmt_servic... | [
"async",
"def",
"test_flow_import_onvif_auth_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.onvif.config_flow.get_device\"",
")",
"as",
"mock_onvif_camera",
":",
"setup_mock_onvif_camera",
"(",
"mock_onvif_camera",
")",
"mock_onvif_camera",
"... | [
589,
0
] | [
613,
59
] | python | en | ['en', 'fr', 'en'] | True |
test_option_flow | (hass) | Test config flow options. | Test config flow options. | async def test_option_flow(hass):
"""Test config flow options."""
entry = await setup_onvif_integration(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "onvif_devices"
result = aw... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"setup_onvif_integration",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"options",
".",
"async_init",
"(",
"entry",
".",
"entry_id",
")",
"asse... | [
616,
0
] | [
637,
5
] | python | en | ['en', 'fr', 'en'] | True |
TestAppleReq.testAppleReq | (self) | Test AppleReq | Test AppleReq | def testAppleReq(self):
"""Test AppleReq"""
# FIXME: construct object with mandatory attributes with example values
# model = AppleReq() # noqa: E501
pass | [
"def",
"testAppleReq",
"(",
"self",
")",
":",
"# FIXME: construct object with mandatory attributes with example values",
"# model = AppleReq() # noqa: E501",
"pass"
] | [
28,
4
] | [
32,
12
] | python | bg-Latn | ['en', 'bg-Latn', 'ur'] | False |
hass_hue | (loop, hass) | Set up a Home Assistant instance for these tests. | Set up a Home Assistant instance for these tests. | def hass_hue(loop, hass):
"""Set up a Home Assistant instance for these tests."""
# We need to do this to get access to homeassistant/turn_(on,off)
loop.run_until_complete(setup.async_setup_component(hass, "homeassistant", {}))
loop.run_until_complete(
setup.async_setup_component(
h... | [
"def",
"hass_hue",
"(",
"loop",
",",
"hass",
")",
":",
"# We need to do this to get access to homeassistant/turn_(on,off)",
"loop",
".",
"run_until_complete",
"(",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
")",
... | [
101,
0
] | [
207,
15
] | python | en | ['en', 'en', 'en'] | True |
hue_client | (loop, hass_hue, hass_client_no_auth) | Create web client for emulated hue api. | Create web client for emulated hue api. | def hue_client(loop, hass_hue, hass_client_no_auth):
"""Create web client for emulated hue api."""
web_app = hass_hue.http.app
config = Config(
None,
{
emulated_hue.CONF_ENTITIES: {
"light.bed_light": {emulated_hue.CONF_ENTITY_HIDDEN: True},
# Kitc... | [
"def",
"hue_client",
"(",
"loop",
",",
"hass_hue",
",",
"hass_client_no_auth",
")",
":",
"web_app",
"=",
"hass_hue",
".",
"http",
".",
"app",
"config",
"=",
"Config",
"(",
"None",
",",
"{",
"emulated_hue",
".",
"CONF_ENTITIES",
":",
"{",
"\"light.bed_light\"... | [
211,
0
] | [
258,
57
] | python | en | ['en', 'pt', 'en'] | True |
test_discover_lights | (hue_client) | Test the discovery of lights. | Test the discovery of lights. | async def test_discover_lights(hue_client):
"""Test the discovery of lights."""
result = await hue_client.get("/api/username/lights")
assert result.status == HTTP_OK
assert CONTENT_TYPE_JSON in result.headers["content-type"]
result_json = await result.json()
devices = {val["uniqueid"] for val... | [
"async",
"def",
"test_discover_lights",
"(",
"hue_client",
")",
":",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"\"/api/username/lights\"",
")",
"assert",
"result",
".",
"status",
"==",
"HTTP_OK",
"assert",
"CONTENT_TYPE_JSON",
"in",
"result",
".",
"... | [
261,
0
] | [
292,
50
] | python | en | ['en', 'en', 'en'] | True |
test_light_without_brightness_supported | (hass_hue, hue_client) | Test that light without brightness is supported. | Test that light without brightness is supported. | async def test_light_without_brightness_supported(hass_hue, hue_client):
"""Test that light without brightness is supported."""
light_without_brightness_json = await perform_get_light_state(
hue_client, "light.no_brightness", HTTP_OK
)
assert light_without_brightness_json["state"][HUE_API_STATE... | [
"async",
"def",
"test_light_without_brightness_supported",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"light_without_brightness_json",
"=",
"await",
"perform_get_light_state",
"(",
"hue_client",
",",
"\"light.no_brightness\"",
",",
"HTTP_OK",
")",
"assert",
"light_withou... | [
295,
0
] | [
302,
66
] | python | en | ['en', 'en', 'en'] | True |
test_lights_all_dimmable | (hass, hass_client_no_auth) | Test CONF_LIGHTS_ALL_DIMMABLE. | Test CONF_LIGHTS_ALL_DIMMABLE. | async def test_lights_all_dimmable(hass, hass_client_no_auth):
"""Test CONF_LIGHTS_ALL_DIMMABLE."""
# create a lamp without brightness support
hass.states.async_set("light.no_brightness", "on", {})
await setup.async_setup_component(
hass, http.DOMAIN, {http.DOMAIN: {http.CONF_SERVER_PORT: HTTP_S... | [
"async",
"def",
"test_lights_all_dimmable",
"(",
"hass",
",",
"hass_client_no_auth",
")",
":",
"# create a lamp without brightness support",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.no_brightness\"",
",",
"\"on\"",
",",
"{",
"}",
")",
"await",
"setup",
... | [
305,
0
] | [
338,
5
] | python | en | ['en', 'en', 'en'] | False |
test_light_without_brightness_can_be_turned_off | (hass_hue, hue_client) | Test that light without brightness can be turned off. | Test that light without brightness can be turned off. | async def test_light_without_brightness_can_be_turned_off(hass_hue, hue_client):
"""Test that light without brightness can be turned off."""
hass_hue.states.async_set("light.no_brightness", "on", {})
turn_off_calls = []
# Check if light can be turned off
@callback
def mock_service_call(call):
... | [
"async",
"def",
"test_light_without_brightness_can_be_turned_off",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"hass_hue",
".",
"states",
".",
"async_set",
"(",
"\"light.no_brightness\"",
",",
"\"on\"",
",",
"{",
"}",
")",
"turn_off_calls",
"=",
"[",
"]",
"# Che... | [
341,
0
] | [
373,
61
] | python | en | ['en', 'en', 'en'] | True |
test_light_without_brightness_can_be_turned_on | (hass_hue, hue_client) | Test that light without brightness can be turned on. | Test that light without brightness can be turned on. | async def test_light_without_brightness_can_be_turned_on(hass_hue, hue_client):
"""Test that light without brightness can be turned on."""
hass_hue.states.async_set("light.no_brightness", "off", {})
# Check if light can be turned on
turn_on_calls = []
@callback
def mock_service_call(call):
... | [
"async",
"def",
"test_light_without_brightness_can_be_turned_on",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"hass_hue",
".",
"states",
".",
"async_set",
"(",
"\"light.no_brightness\"",
",",
"\"off\"",
",",
"{",
"}",
")",
"# Check if light can be turned on",
"turn_on... | [
376,
0
] | [
415,
61
] | python | en | ['en', 'en', 'en'] | True |
test_reachable_for_state | (hass_hue, hue_client, state, is_reachable) | Test that an entity is reported as unreachable if in unavailable state. | Test that an entity is reported as unreachable if in unavailable state. | async def test_reachable_for_state(hass_hue, hue_client, state, is_reachable):
"""Test that an entity is reported as unreachable if in unavailable state."""
entity_id = "light.ceiling_lights"
hass_hue.states.async_set(entity_id, state)
state_json = await perform_get_light_state(hue_client, entity_id, ... | [
"async",
"def",
"test_reachable_for_state",
"(",
"hass_hue",
",",
"hue_client",
",",
"state",
",",
"is_reachable",
")",
":",
"entity_id",
"=",
"\"light.ceiling_lights\"",
"hass_hue",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"state",
")",
"state_json... | [
426,
0
] | [
434,
71
] | python | en | ['en', 'en', 'en'] | True |
test_discover_full_state | (hue_client) | Test the discovery of full state. | Test the discovery of full state. | async def test_discover_full_state(hue_client):
"""Test the discovery of full state."""
result = await hue_client.get(f"/api/{HUE_API_USERNAME}")
assert result.status == HTTP_OK
assert CONTENT_TYPE_JSON in result.headers["content-type"]
result_json = await result.json()
# Make sure array has ... | [
"async",
"def",
"test_discover_full_state",
"(",
"hue_client",
")",
":",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"f\"/api/{HUE_API_USERNAME}\"",
")",
"assert",
"result",
".",
"status",
"==",
"HTTP_OK",
"assert",
"CONTENT_TYPE_JSON",
"in",
"result",
... | [
437,
0
] | [
484,
44
] | python | en | ['en', 'en', 'en'] | True |
test_discover_config | (hue_client) | Test the discovery of configuration. | Test the discovery of configuration. | async def test_discover_config(hue_client):
"""Test the discovery of configuration."""
result = await hue_client.get(f"/api/{HUE_API_USERNAME}/config")
assert result.status == 200
assert CONTENT_TYPE_JSON in result.headers["content-type"]
config_json = await result.json()
# Make sure array is... | [
"async",
"def",
"test_discover_config",
"(",
"hue_client",
")",
":",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"f\"/api/{HUE_API_USERNAME}/config\"",
")",
"assert",
"result",
".",
"status",
"==",
"200",
"assert",
"CONTENT_TYPE_JSON",
"in",
"result",
"... | [
487,
0
] | [
541,
37
] | python | en | ['en', 'en', 'en'] | True |
test_get_light_state | (hass_hue, hue_client) | Test the getting of light state. | Test the getting of light state. | async def test_get_light_state(hass_hue, hue_client):
"""Test the getting of light state."""
# Turn ceiling lights on and set to 127 brightness, and set light color
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_ON,
{
const.ATTR_ENTITY_ID: "light.cei... | [
"async",
"def",
"test_get_light_state",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn ceiling lights on and set to 127 brightness, and set light color",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
",",
"const",
".",
"SER... | [
544,
0
] | [
604,
88
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state | (hass, hass_hue, hue_client) | Test the setting of light states. | Test the setting of light states. | async def test_put_light_state(hass, hass_hue, hue_client):
"""Test the setting of light states."""
await perform_put_test_on_ceiling_lights(hass_hue, hue_client)
# Turn the bedroom light on first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_ON,
{const.AT... | [
"async",
"def",
"test_put_light_state",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"await",
"perform_put_test_on_ceiling_lights",
"(",
"hass_hue",
",",
"hue_client",
")",
"# Turn the bedroom light on first",
"await",
"hass_hue",
".",
"services",
".",
"... | [
607,
0
] | [
773,
59
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state_script | (hass, hass_hue, hue_client) | Test the setting of script variables. | Test the setting of script variables. | async def test_put_light_state_script(hass, hass_hue, hue_client):
"""Test the setting of script variables."""
# Turn the kitchen light off first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "light.kitchen_lights"},
blocking... | [
"async",
"def",
"test_put_light_state_script",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the kitchen light off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TURN_OFF... | [
776,
0
] | [
805,
5
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state_climate_set_temperature | (hass_hue, hue_client) | Test setting climate temperature. | Test setting climate temperature. | async def test_put_light_state_climate_set_temperature(hass_hue, hue_client):
"""Test setting climate temperature."""
brightness = 19
temperature = round(brightness / 254 * 100)
hvac_result = await perform_put_light_state(
hass_hue, hue_client, "climate.hvac", True, brightness
)
hvac_r... | [
"async",
"def",
"test_put_light_state_climate_set_temperature",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"brightness",
"=",
"19",
"temperature",
"=",
"round",
"(",
"brightness",
"/",
"254",
"*",
"100",
")",
"hvac_result",
"=",
"await",
"perform_put_light_state"... | [
808,
0
] | [
830,
52
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state_humidifier_set_humidity | (hass_hue, hue_client) | Test setting humidifier target humidity. | Test setting humidifier target humidity. | async def test_put_light_state_humidifier_set_humidity(hass_hue, hue_client):
"""Test setting humidifier target humidity."""
# Turn the humidifier off first
await hass_hue.services.async_call(
humidifier.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "humidifier.humidifier"},... | [
"async",
"def",
"test_put_light_state_humidifier_set_humidity",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the humidifier off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"humidifier",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TURN_O... | [
833,
0
] | [
863,
55
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state_media_player | (hass_hue, hue_client) | Test turning on media player and setting volume. | Test turning on media player and setting volume. | async def test_put_light_state_media_player(hass_hue, hue_client):
"""Test turning on media player and setting volume."""
# Turn the music player off first
await hass_hue.services.async_call(
media_player.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "media_player.walkman"},... | [
"async",
"def",
"test_put_light_state_media_player",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the music player off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"media_player",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TURN_OFF",
... | [
866,
0
] | [
891,
76
] | python | en | ['en', 'en', 'en'] | True |
test_open_cover_without_position | (hass_hue, hue_client) | Test opening cover . | Test opening cover . | async def test_open_cover_without_position(hass_hue, hue_client):
"""Test opening cover ."""
cover_id = "cover.living_room_window"
# Close cover first
await hass_hue.services.async_call(
cover.DOMAIN,
const.SERVICE_CLOSE_COVER,
{const.ATTR_ENTITY_ID: cover_id},
blocking=T... | [
"async",
"def",
"test_open_cover_without_position",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"cover_id",
"=",
"\"cover.living_room_window\"",
"# Close cover first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"cover",
".",
"DOMAIN",
",",
"const"... | [
894,
0
] | [
954,
63
] | python | en | ['nl', 'en', 'en'] | True |
test_set_position_cover | (hass_hue, hue_client) | Test setting position cover . | Test setting position cover . | async def test_set_position_cover(hass_hue, hue_client):
"""Test setting position cover ."""
cover_id = "cover.living_room_window"
cover_number = ENTITY_NUMBERS_BY_ID[cover_id]
# Turn the office light off first
await hass_hue.services.async_call(
cover.DOMAIN,
const.SERVICE_CLOSE_COV... | [
"async",
"def",
"test_set_position_cover",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"cover_id",
"=",
"\"cover.living_room_window\"",
"cover_number",
"=",
"ENTITY_NUMBERS_BY_ID",
"[",
"cover_id",
"]",
"# Turn the office light off first",
"await",
"hass_hue",
".",
"ser... | [
957,
0
] | [
1005,
67
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state_fan | (hass_hue, hue_client) | Test turning on fan and setting speed. | Test turning on fan and setting speed. | async def test_put_light_state_fan(hass_hue, hue_client):
"""Test turning on fan and setting speed."""
# Turn the fan off first
await hass_hue.services.async_call(
fan.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "fan.living_room_fan"},
blocking=True,
)
# E... | [
"async",
"def",
"test_put_light_state_fan",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the fan off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"fan",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TURN_OFF",
",",
"{",
"const",
".... | [
1008,
0
] | [
1098,
77
] | python | en | ['en', 'en', 'en'] | True |
test_put_with_form_urlencoded_content_type | (hass_hue, hue_client) | Test the form with urlencoded content. | Test the form with urlencoded content. | async def test_put_with_form_urlencoded_content_type(hass_hue, hue_client):
"""Test the form with urlencoded content."""
entity_number = ENTITY_NUMBERS_BY_ID["light.ceiling_lights"]
# Needed for Alexa
await perform_put_test_on_ceiling_lights(
hass_hue, hue_client, "application/x-www-form-urlenco... | [
"async",
"def",
"test_put_with_form_urlencoded_content_type",
"(",
"hass_hue",
",",
"hue_client",
")",
":",
"entity_number",
"=",
"ENTITY_NUMBERS_BY_ID",
"[",
"\"light.ceiling_lights\"",
"]",
"# Needed for Alexa",
"await",
"perform_put_test_on_ceiling_lights",
"(",
"hass_hue",
... | [
1102,
0
] | [
1118,
31
] | python | en | ['en', 'en', 'en'] | True |
test_entity_not_found | (hue_client) | Test for entity which are not found. | Test for entity which are not found. | async def test_entity_not_found(hue_client):
"""Test for entity which are not found."""
result = await hue_client.get("/api/username/lights/98")
assert result.status == HTTP_NOT_FOUND
result = await hue_client.put("/api/username/lights/98/state")
assert result.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_entity_not_found",
"(",
"hue_client",
")",
":",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"\"/api/username/lights/98\"",
")",
"assert",
"result",
".",
"status",
"==",
"HTTP_NOT_FOUND",
"result",
"=",
"await",
"hue_client",
".",
... | [
1121,
0
] | [
1129,
42
] | python | en | ['en', 'en', 'en'] | True |
test_allowed_methods | (hue_client) | Test the allowed methods. | Test the allowed methods. | async def test_allowed_methods(hue_client):
"""Test the allowed methods."""
result = await hue_client.get(
"/api/username/lights/ENTITY_NUMBERS_BY_ID[light.ceiling_lights]/state"
)
assert result.status == 405
result = await hue_client.put(
"/api/username/lights/ENTITY_NUMBERS_BY_ID... | [
"async",
"def",
"test_allowed_methods",
"(",
"hue_client",
")",
":",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"\"/api/username/lights/ENTITY_NUMBERS_BY_ID[light.ceiling_lights]/state\"",
")",
"assert",
"result",
".",
"status",
"==",
"405",
"result",
"=",
... | [
1132,
0
] | [
1148,
31
] | python | en | ['en', 'en', 'en'] | True |
test_proper_put_state_request | (hue_client) | Test the request to set the state. | Test the request to set the state. | async def test_proper_put_state_request(hue_client):
"""Test the request to set the state."""
# Test proper on value parsing
result = await hue_client.put(
"/api/username/lights/{}/state".format(
ENTITY_NUMBERS_BY_ID["light.ceiling_lights"]
),
data=json.dumps({HUE_API_STA... | [
"async",
"def",
"test_proper_put_state_request",
"(",
"hue_client",
")",
":",
"# Test proper on value parsing",
"result",
"=",
"await",
"hue_client",
".",
"put",
"(",
"\"/api/username/lights/{}/state\"",
".",
"format",
"(",
"ENTITY_NUMBERS_BY_ID",
"[",
"\"light.ceiling_ligh... | [
1151,
0
] | [
1171,
31
] | python | en | ['en', 'en', 'en'] | True |
test_get_empty_groups_state | (hue_client) | Test the request to get groups endpoint. | Test the request to get groups endpoint. | async def test_get_empty_groups_state(hue_client):
"""Test the request to get groups endpoint."""
# Test proper on value parsing
result = await hue_client.get("/api/username/groups")
assert result.status == HTTP_OK
result_json = await result.json()
assert result_json == {} | [
"async",
"def",
"test_get_empty_groups_state",
"(",
"hue_client",
")",
":",
"# Test proper on value parsing",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"\"/api/username/groups\"",
")",
"assert",
"result",
".",
"status",
"==",
"HTTP_OK",
"result_json",
"="... | [
1174,
0
] | [
1183,
28
] | python | en | ['en', 'en', 'en'] | True |
perform_put_test_on_ceiling_lights | (
hass_hue, hue_client, content_type=CONTENT_TYPE_JSON
) | Test the setting of a light. | Test the setting of a light. | async def perform_put_test_on_ceiling_lights(
hass_hue, hue_client, content_type=CONTENT_TYPE_JSON
):
"""Test the setting of a light."""
# Turn the office light off first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "light.ceili... | [
"async",
"def",
"perform_put_test_on_ceiling_lights",
"(",
"hass_hue",
",",
"hue_client",
",",
"content_type",
"=",
"CONTENT_TYPE_JSON",
")",
":",
"# Turn the office light off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
... | [
1187,
0
] | [
1217,
65
] | python | en | ['en', 'en', 'en'] | True |
perform_get_light_state_by_number | (client, entity_number, expected_status) | Test the getting of a light state. | Test the getting of a light state. | async def perform_get_light_state_by_number(client, entity_number, expected_status):
"""Test the getting of a light state."""
result = await client.get(f"/api/username/lights/{entity_number}")
assert result.status == expected_status
if expected_status == HTTP_OK:
assert CONTENT_TYPE_JSON in re... | [
"async",
"def",
"perform_get_light_state_by_number",
"(",
"client",
",",
"entity_number",
",",
"expected_status",
")",
":",
"result",
"=",
"await",
"client",
".",
"get",
"(",
"f\"/api/username/lights/{entity_number}\"",
")",
"assert",
"result",
".",
"status",
"==",
... | [
1220,
0
] | [
1231,
15
] | python | en | ['en', 'en', 'en'] | True |
perform_get_light_state | (client, entity_id, expected_status) | Test the getting of a light state. | Test the getting of a light state. | async def perform_get_light_state(client, entity_id, expected_status):
"""Test the getting of a light state."""
entity_number = ENTITY_NUMBERS_BY_ID[entity_id]
return await perform_get_light_state_by_number(
client, entity_number, expected_status
) | [
"async",
"def",
"perform_get_light_state",
"(",
"client",
",",
"entity_id",
",",
"expected_status",
")",
":",
"entity_number",
"=",
"ENTITY_NUMBERS_BY_ID",
"[",
"entity_id",
"]",
"return",
"await",
"perform_get_light_state_by_number",
"(",
"client",
",",
"entity_number"... | [
1234,
0
] | [
1239,
5
] | python | en | ['en', 'en', 'en'] | True |
perform_put_light_state | (
hass_hue,
client,
entity_id,
is_on,
brightness=None,
content_type=CONTENT_TYPE_JSON,
hue=None,
saturation=None,
color_temp=None,
with_state=True,
xy=None,
transitiontime=None,
) | Test the setting of a light state. | Test the setting of a light state. | async def perform_put_light_state(
hass_hue,
client,
entity_id,
is_on,
brightness=None,
content_type=CONTENT_TYPE_JSON,
hue=None,
saturation=None,
color_temp=None,
with_state=True,
xy=None,
transitiontime=None,
):
"""Test the setting of a light state."""
req_heade... | [
"async",
"def",
"perform_put_light_state",
"(",
"hass_hue",
",",
"client",
",",
"entity_id",
",",
"is_on",
",",
"brightness",
"=",
"None",
",",
"content_type",
"=",
"CONTENT_TYPE_JSON",
",",
"hue",
"=",
"None",
",",
"saturation",
"=",
"None",
",",
"color_temp"... | [
1242,
0
] | [
1287,
17
] | python | en | ['en', 'en', 'en'] | True |
test_external_ip_blocked | (hue_client) | Test external IP blocked. | Test external IP blocked. | async def test_external_ip_blocked(hue_client):
"""Test external IP blocked."""
getUrls = [
"/api/username/groups",
"/api/username",
"/api/username/config",
"/api/username/lights",
"/api/username/lights/light.ceiling_lights",
]
postUrls = ["/api"]
putUrls = ["... | [
"async",
"def",
"test_external_ip_blocked",
"(",
"hue_client",
")",
":",
"getUrls",
"=",
"[",
"\"/api/username/groups\"",
",",
"\"/api/username\"",
",",
"\"/api/username/config\"",
",",
"\"/api/username/lights\"",
",",
"\"/api/username/lights/light.ceiling_lights\"",
",",
"]"... | [
1290,
0
] | [
1315,
53
] | python | en | ['en', 'hu', 'en'] | True |
test_unauthorized_user_blocked | (hue_client) | Test unauthorized_user blocked. | Test unauthorized_user blocked. | async def test_unauthorized_user_blocked(hue_client):
"""Test unauthorized_user blocked."""
getUrls = [
"/api/wronguser",
]
for getUrl in getUrls:
result = await hue_client.get(getUrl)
assert result.status == HTTP_OK
result_json = await result.json()
assert resul... | [
"async",
"def",
"test_unauthorized_user_blocked",
"(",
"hue_client",
")",
":",
"getUrls",
"=",
"[",
"\"/api/wronguser\"",
",",
"]",
"for",
"getUrl",
"in",
"getUrls",
":",
"result",
"=",
"await",
"hue_client",
".",
"get",
"(",
"getUrl",
")",
"assert",
"result",... | [
1318,
0
] | [
1328,
76
] | python | ca | ['ca', 'zu', 'it'] | False |
test_put_then_get_cached_properly | (hass, hass_hue, hue_client) | Test the setting of light states and an immediate readback reads the same values. | Test the setting of light states and an immediate readback reads the same values. | async def test_put_then_get_cached_properly(hass, hass_hue, hue_client):
"""Test the setting of light states and an immediate readback reads the same values."""
# Turn the bedroom light on first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_ON,
{const.ATTR_ENT... | [
"async",
"def",
"test_put_then_get_cached_properly",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the bedroom light on first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TUR... | [
1331,
0
] | [
1451,
62
] | python | en | ['en', 'en', 'en'] | True |
test_put_than_get_when_service_call_fails | (hass, hass_hue, hue_client) | Test putting and getting the light state when the service call fails. | Test putting and getting the light state when the service call fails. | async def test_put_than_get_when_service_call_fails(hass, hass_hue, hue_client):
"""Test putting and getting the light state when the service call fails."""
# Turn the bedroom light off first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTIT... | [
"async",
"def",
"test_put_than_get_when_service_call_fails",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the bedroom light off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
",",
"const",
".",
"SE... | [
1454,
0
] | [
1501,
59
] | python | en | ['en', 'en', 'en'] | True |
test_get_invalid_entity | (hass, hass_hue, hue_client) | Test the setting of light states and an immediate readback reads the same values. | Test the setting of light states and an immediate readback reads the same values. | async def test_get_invalid_entity(hass, hass_hue, hue_client):
"""Test the setting of light states and an immediate readback reads the same values."""
# Check that we get an error with an invalid entity number.
await perform_get_light_state_by_number(hue_client, 999, HTTP_NOT_FOUND) | [
"async",
"def",
"test_get_invalid_entity",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# Check that we get an error with an invalid entity number.",
"await",
"perform_get_light_state_by_number",
"(",
"hue_client",
",",
"999",
",",
"HTTP_NOT_FOUND",
")"
] | [
1504,
0
] | [
1508,
76
] | python | en | ['en', 'en', 'en'] | True |
test_put_light_state_scene | (hass, hass_hue, hue_client) | Test the setting of scene variables. | Test the setting of scene variables. | async def test_put_light_state_scene(hass, hass_hue, hue_client):
"""Test the setting of scene variables."""
# Turn the kitchen lights off first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "light.kitchen_lights"},
blocking=... | [
"async",
"def",
"test_put_light_state_scene",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the kitchen lights off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TURN_OFF... | [
1511,
0
] | [
1550,
73
] | python | en | ['en', 'en', 'en'] | True |
test_only_change_contrast | (hass, hass_hue, hue_client) | Test when only changing the contrast of a light state. | Test when only changing the contrast of a light state. | async def test_only_change_contrast(hass, hass_hue, hue_client):
"""Test when only changing the contrast of a light state."""
# Turn the kitchen lights off first
await hass_hue.services.async_call(
light.DOMAIN,
const.SERVICE_TURN_OFF,
{const.ATTR_ENTITY_ID: "light.ceiling_lights"},... | [
"async",
"def",
"test_only_change_contrast",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# Turn the kitchen lights off first",
"await",
"hass_hue",
".",
"services",
".",
"async_call",
"(",
"light",
".",
"DOMAIN",
",",
"const",
".",
"SERVICE_TURN_OFF"... | [
1553,
0
] | [
1579,
66
] | python | en | ['en', 'en', 'en'] | True |
test_only_change_hue_or_saturation | (hass, hass_hue, hue_client) | Test setting either the hue or the saturation but not both. | Test setting either the hue or the saturation but not both. | async def test_only_change_hue_or_saturation(hass, hass_hue, hue_client):
"""Test setting either the hue or the saturation but not both."""
# TODO: The handling of this appears wrong, as setting only one will set the other to 0.
# The return values also appear wrong.
# Turn the ceiling lights on first... | [
"async",
"def",
"test_only_change_hue_or_saturation",
"(",
"hass",
",",
"hass_hue",
",",
"hue_client",
")",
":",
"# TODO: The handling of this appears wrong, as setting only one will set the other to 0.",
"# The return values also appear wrong.",
"# Turn the ceiling lights on first and set... | [
1582,
0
] | [
1616,
15
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Find and return switches controlled by telnet commands. | Find and return switches controlled by telnet commands. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Find and return switches controlled by telnet commands."""
devices = config.get(CONF_SWITCHES, {})
switches = []
for object_id, device_config in devices.items():
value_template = device_config.get(CONF_VALUE_TEMPLATE)
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"devices",
"=",
"config",
".",
"get",
"(",
"CONF_SWITCHES",
",",
"{",
"}",
")",
"switches",
"=",
"[",
"]",
"for",
"object_id",
",",
... | [
50,
0
] | [
80,
26
] | python | en | ['en', 'en', 'en'] | True |
TelnetSwitch.__init__ | (
self,
hass,
object_id,
resource,
port,
friendly_name,
command_on,
command_off,
command_state,
value_template,
timeout,
) | Initialize the switch. | Initialize the switch. | def __init__(
self,
hass,
object_id,
resource,
port,
friendly_name,
command_on,
command_off,
command_state,
value_template,
timeout,
):
"""Initialize the switch."""
self._hass = hass
self.entity_id = ENTI... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"object_id",
",",
"resource",
",",
"port",
",",
"friendly_name",
",",
"command_on",
",",
"command_off",
",",
"command_state",
",",
"value_template",
",",
"timeout",
",",
")",
":",
"self",
".",
"_hass",
"=",... | [
86,
4
] | [
110,
31
] | python | en | ['en', 'en', 'en'] | True |
TelnetSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
126,
4
] | [
128,
25
] | python | en | ['en', 'en', 'en'] | True |
TelnetSwitch.should_poll | (self) | Only poll if we have state command. | Only poll if we have state command. | def should_poll(self):
"""Only poll if we have state command."""
return self._command_state is not None | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"self",
".",
"_command_state",
"is",
"not",
"None"
] | [
131,
4
] | [
133,
46
] | python | en | ['en', 'en', 'en'] | True |
TelnetSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
136,
4
] | [
138,
26
] | python | en | ['en', 'fy', 'en'] | True |
TelnetSwitch.assumed_state | (self) | Return true if no state command is defined, false otherwise. | Return true if no state command is defined, false otherwise. | def assumed_state(self):
"""Return true if no state command is defined, false otherwise."""
return self._command_state is None | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_command_state",
"is",
"None"
] | [
141,
4
] | [
143,
42
] | python | en | ['en', 'en', 'en'] | True |
TelnetSwitch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
response = self._telnet_command(self._command_state)
if response:
rendered = self._value_template.render_with_possible_json_value(response)
self._state = rendered == "True"
else:
_LOGGER.warning("Empty respo... | [
"def",
"update",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_telnet_command",
"(",
"self",
".",
"_command_state",
")",
"if",
"response",
":",
"rendered",
"=",
"self",
".",
"_value_template",
".",
"render_with_possible_json_value",
"(",
"response",
"... | [
145,
4
] | [
152,
82
] | python | en | ['fr', 'en', 'en'] | True |
TelnetSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
self._telnet_command(self._command_on)
if self.assumed_state:
self._state = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_telnet_command",
"(",
"self",
".",
"_command_on",
")",
"if",
"self",
".",
"assumed_state",
":",
"self",
".",
"_state",
"=",
"True"
] | [
154,
4
] | [
158,
30
] | python | en | ['en', 'en', 'en'] | True |
TelnetSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
self._telnet_command(self._command_off)
if self.assumed_state:
self._state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_telnet_command",
"(",
"self",
".",
"_command_off",
")",
"if",
"self",
".",
"assumed_state",
":",
"self",
".",
"_state",
"=",
"False"
] | [
160,
4
] | [
164,
31
] | python | en | ['en', 'en', 'en'] | True |
test_show_set_form | (hass: HomeAssistant) | Test that the setup form is served. | Test that the setup form is served. | async def test_show_set_form(hass: HomeAssistant) -> None:
"""Test that the setup form is served."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user" | [
"async",
"def",
"test_show_set_form",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",... | [
25,
0
] | [
32,
38
] | python | en | ['en', 'en', 'en'] | True |
test_connection_error | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we show user form on Twente Milieu connection error. | Test we show user form on Twente Milieu connection error. | async def test_connection_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we show user form on Twente Milieu connection error."""
aioclient_mock.post(
"https://twentemilieuapi.ximmio.com/api/FetchAdress", exc=aiohttp.ClientError
)
result = await hass.confi... | [
"async",
"def",
"test_connection_error",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"post",
"(",
"\"https://twentemilieuapi.ximmio.com/api/FetchAdress\"",
",",
"exc",
"=",
"aiohttp... | [
35,
0
] | [
49,
57
] | python | en | ['en', 'fr', 'en'] | True |
test_invalid_address | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we show user form on Twente Milieu invalid address error. | Test we show user form on Twente Milieu invalid address error. | async def test_invalid_address(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we show user form on Twente Milieu invalid address error."""
aioclient_mock.post(
"https://twentemilieuapi.ximmio.com/api/FetchAdress",
json={"dataList": []},
headers={"Content... | [
"async",
"def",
"test_invalid_address",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"post",
"(",
"\"https://twentemilieuapi.ximmio.com/api/FetchAdress\"",
",",
"json",
"=",
"{",
"... | [
52,
0
] | [
68,
58
] | python | en | ['en', 'da', 'en'] | True |
test_address_already_set_up | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort if address has already been set up. | Test we abort if address has already been set up. | async def test_address_already_set_up(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort if address has already been set up."""
MockConfigEntry(
domain=DOMAIN, data={**FIXTURE_USER_INPUT, CONF_ID: "12345"}, title="12345"
).add_to_hass(hass)
aioclient_mock.... | [
"async",
"def",
"test_address_already_set_up",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"*",
"*",
"FIXTURE_USER_INPUT",
"... | [
71,
0
] | [
92,
51
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow_implementation | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test registering an integration and finishing flow works. | Test registering an integration and finishing flow works. | async def test_full_flow_implementation(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test registering an integration and finishing flow works."""
aioclient_mock.post(
"https://twentemilieuapi.ximmio.com/api/FetchAdress",
json={"dataList": [{"UniqueId": "12345"}]},
... | [
"async",
"def",
"test_full_flow_implementation",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"post",
"(",
"\"https://twentemilieuapi.ximmio.com/api/FetchAdress\"",
",",
"json",
"=",
... | [
95,
0
] | [
121,
85
] | python | en | ['en', 'en', 'en'] | True |
TestStringBooleanMap.testStringBooleanMap | (self) | Test StringBooleanMap | Test StringBooleanMap | def testStringBooleanMap(self):
"""Test StringBooleanMap"""
# FIXME: construct object with mandatory attributes with example values
# model = StringBooleanMap() # noqa: E501
pass | [
"def",
"testStringBooleanMap",
"(",
"self",
")",
":",
"# FIXME: construct object with mandatory attributes with example values",
"# model = StringBooleanMap() # noqa: E501",
"pass"
] | [
28,
4
] | [
32,
12
] | python | en | ['en', 'af', 'en'] | False |
test_empty_config | (hass) | Test a default config will be create for empty config. | Test a default config will be create for empty config. | async def test_empty_config(hass):
"""Test a default config will be create for empty config."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(hass, "aws", {"aws": {}})
await hass.async_block_till_done()
sessions = hass.data[aws.DATA_SESSIONS]
... | [
"async",
"def",
"test_empty_config",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",
"{",
"}"... | [
32,
0
] | [
44,
41
] | python | en | ['en', 'en', 'en'] | True |
test_empty_credential | (hass) | Test a default config will be create for empty credential section. | Test a default config will be create for empty credential section. | async def test_empty_credential(hass):
"""Test a default config will be create for empty credential section."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(
hass,
"aws",
{
"aws": {
"no... | [
"async",
"def",
"test_empty_credential",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",
"{",
... | [
47,
0
] | [
77,
40
] | python | en | ['en', 'en', 'en'] | True |
test_profile_credential | (hass) | Test credentials with profile name. | Test credentials with profile name. | async def test_profile_credential(hass):
"""Test credentials with profile name."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(
hass,
"aws",
{
"aws": {
"credentials": {"name": "test", ... | [
"async",
"def",
"test_profile_credential",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",
"{",... | [
80,
0
] | [
115,
41
] | python | en | ['en', 'en', 'en'] | True |
test_access_key_credential | (hass) | Test credentials with access key. | Test credentials with access key. | async def test_access_key_credential(hass):
"""Test credentials with access key."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(
hass,
"aws",
{
"aws": {
"credentials": [
... | [
"async",
"def",
"test_access_key_credential",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",
"... | [
118,
0
] | [
160,
41
] | python | en | ['en', 'en', 'en'] | True |
test_notify_credential | (hass) | Test notify service can use access key directly. | Test notify service can use access key directly. | async def test_notify_credential(hass):
"""Test notify service can use access key directly."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(
hass,
"aws",
{
"aws": {
"notify": [
... | [
"async",
"def",
"test_notify_credential",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",
"{",
... | [
163,
0
] | [
194,
5
] | python | en | ['en', 'en', 'en'] | True |
test_notify_credential_profile | (hass) | Test notify service can use profile directly. | Test notify service can use profile directly. | async def test_notify_credential_profile(hass):
"""Test notify service can use profile directly."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(
hass,
"aws",
{
"aws": {
"notify": [
... | [
"async",
"def",
"test_notify_credential_profile",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",... | [
197,
0
] | [
226,
5
] | python | en | ['en', 'en', 'en'] | True |
test_credential_skip_validate | (hass) | Test credential can skip validate. | Test credential can skip validate. | async def test_credential_skip_validate(hass):
"""Test credential can skip validate."""
with async_patch("aiobotocore.AioSession", new=MockAioSession):
await async_setup_component(
hass,
"aws",
{
"aws": {
"credentials": [
... | [
"async",
"def",
"test_credential_skip_validate",
"(",
"hass",
")",
":",
"with",
"async_patch",
"(",
"\"aiobotocore.AioSession\"",
",",
"new",
"=",
"MockAioSession",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"aws\"",
",",
"{",
"\"aws\"",
":",
... | [
229,
0
] | [
255,
41
] | python | en | ['en', 'en', 'en'] | True |
MockAioSession.__init__ | (self, *args, **kwargs) | Init a mock session. | Init a mock session. | def __init__(self, *args, **kwargs):
"""Init a mock session."""
self.get_user = AsyncMock()
self.invoke = AsyncMock()
self.publish = AsyncMock()
self.send_message = AsyncMock() | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"get_user",
"=",
"AsyncMock",
"(",
")",
"self",
".",
"invoke",
"=",
"AsyncMock",
"(",
")",
"self",
".",
"publish",
"=",
"AsyncMock",
"(",
")",
"self",... | [
10,
4
] | [
15,
39
] | python | en | ['en', 'bg', 'en'] | True |
MockAioSession.create_client | (self, *args, **kwargs) | Create a mocked client. | Create a mocked client. | def create_client(self, *args, **kwargs): # pylint: disable=no-self-use
"""Create a mocked client."""
return MagicMock(
__aenter__=AsyncMock(
return_value=AsyncMock(
get_user=self.get_user, # iam
invoke=self.invoke, # lambda
... | [
"def",
"create_client",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=no-self-use",
"return",
"MagicMock",
"(",
"__aenter__",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"AsyncMock",
"(",
"get_user",
"=",
"self",
".",
"... | [
17,
4
] | [
29,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) | Set up Ambient PWS binary sensors based on a config entry. | Set up Ambient PWS binary sensors based on a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up Ambient PWS binary sensors based on a config entry."""
ambient = hass.data[DOMAIN][DATA_CLIENT][entry.entry_id]
async_add_entities(
[
AmbientWeatherBina... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
")",
"->",
"None",
":",
"ambient",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CLIENT"... | [
208,
0
] | [
223,
5
] | python | en | ['en', 'en', 'en'] | True |
AmbientWeatherBinarySensor.update_from_latest_data | (self) | Fetch new state data for the entity. | Fetch new state data for the entity. | def update_from_latest_data(self) -> None:
"""Fetch new state data for the entity."""
self._attr_is_on = (
self._ambient.stations[self._mac_address][ATTR_LAST_DATA][
self.entity_description.key
]
== self.entity_description.on_state
) | [
"def",
"update_from_latest_data",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_attr_is_on",
"=",
"(",
"self",
".",
"_ambient",
".",
"stations",
"[",
"self",
".",
"_mac_address",
"]",
"[",
"ATTR_LAST_DATA",
"]",
"[",
"self",
".",
"entity_description",
... | [
232,
4
] | [
239,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up Freedompro sensor. | Set up Freedompro sensor. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up Freedompro sensor."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
Device(device, coordinator)
for device in coordinator.data
if device["type"] in SUPPORTED_SENSORS
) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"async_add_entities",
"(",
"Device",
"(",
"device",
",",
"... | [
37,
0
] | [
44,
5
] | python | en | ['es', 'zu', 'en'] | False |
Device.__init__ | (self, device, coordinator) | Initialize the Freedompro sensor. | Initialize the Freedompro sensor. | def __init__(self, device, coordinator):
"""Initialize the Freedompro sensor."""
super().__init__(coordinator)
self._attr_name = device["name"]
self._attr_unique_id = device["uid"]
self._type = device["type"]
self._attr_device_info = {
"name": self.name,
... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"coordinator",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_attr_name",
"=",
"device",
"[",
"\"name\"",
"]",
"self",
".",
"_attr_unique_id",
"=",
"device",
"[",
... | [
50,
4
] | [
67,
35
] | python | en | ['en', 'zu', 'en'] | True |
Device._handle_coordinator_update | (self) | Handle updated data from the coordinator. | Handle updated data from the coordinator. | def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
device = next(
(
device
for device in self.coordinator.data
if device["uid"] == self.unique_id
),
None,
)
if d... | [
"def",
"_handle_coordinator_update",
"(",
"self",
")",
"->",
"None",
":",
"device",
"=",
"next",
"(",
"(",
"device",
"for",
"device",
"in",
"self",
".",
"coordinator",
".",
"data",
"if",
"device",
"[",
"\"uid\"",
"]",
"==",
"self",
".",
"unique_id",
")",... | [
70,
4
] | [
83,
44
] | python | en | ['en', 'en', 'en'] | True |
Device.async_added_to_hass | (self) | When entity is added to hass. | When entity is added to hass. | async def async_added_to_hass(self) -> None:
"""When entity is added to hass."""
await super().async_added_to_hass()
self._handle_coordinator_update() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"_handle_coordinator_update",
"(",
")"
] | [
85,
4
] | [
88,
41
] | python | en | ['en', 'en', 'en'] | True |
SpeedTestFlowHandler.async_get_options_flow | (
config_entry: config_entries.ConfigEntry,
) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
"""Get the options flow for this handler."""
return SpeedTestOptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
",",
")",
"->",
"config_entries",
".",
"OptionsFlow",
":",
"return",
"SpeedTestOptionsFlowHandler",
"(",
"config_entry",
")"
] | [
31,
4
] | [
35,
56
] | python | en | ['en', 'en', 'en'] | True |
SpeedTestFlowHandler.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle a flow initialized by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
if user_input is None:
return s... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"return",
"self",
".",
"asy... | [
37,
4
] | [
47,
75
] | python | en | ['en', 'en', 'en'] | True |
SpeedTestFlowHandler.async_step_import | (self, import_config) | Import from config. | Import from config. | async def async_step_import(self, import_config):
"""Import from config."""
if (
CONF_SERVER_ID in import_config
and not await self.hass.async_add_executor_job(
server_id_valid, import_config[CONF_SERVER_ID]
)
):
return self.async_a... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_config",
")",
":",
"if",
"(",
"CONF_SERVER_ID",
"in",
"import_config",
"and",
"not",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"server_id_valid",
",",
"import_config",
"[",
"C... | [
49,
4
] | [
64,
67
] | python | en | ['en', 'en', 'en'] | True |
SpeedTestOptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
self._servers: dict = {} | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"_servers",
":",
"dict",
"=",
"{",
"}"
] | [
70,
4
] | [
73,
32
] | python | en | ['en', 'en', 'en'] | True |
SpeedTestOptionsFlowHandler.async_step_init | (
self, user_input: dict[str, Any] | None = None
) | Manage the options. | Manage the options. | async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Manage the options."""
errors: dict[str, str] = {}
if user_input is not None:
server_name = user_input[CONF_SERVER_NAME]
if server_name != "*Auto Detect":
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"errors",
":",
"dict",
"[",
"str",
",",
"str",
"]",
"=",
"{",
"}",
"if",
"user_inpu... | [
75,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
config.check_type | (self, type_name, headers=None, include_dirs=None,
library_dirs=None) | Check type availability. Return True if the type can be compiled,
False otherwise | Check type availability. Return True if the type can be compiled,
False otherwise | def check_type(self, type_name, headers=None, include_dirs=None,
library_dirs=None):
"""Check type availability. Return True if the type can be compiled,
False otherwise"""
self._check_compiler()
# First check the type can be compiled
body = textwrap.dedent(r"""
... | [
"def",
"check_type",
"(",
"self",
",",
"type_name",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"library_dirs",
"=",
"None",
")",
":",
"self",
".",
"_check_compiler",
"(",
")",
"# First check the type can be compiled",
"body",
"=",
"tex... | [
201,
4
] | [
228,
17
] | python | en | ['en', 'en', 'en'] | True |
config.check_type_size | (self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None) | Check size of a given type. | Check size of a given type. | def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None):
"""Check size of a given type."""
self._check_compiler()
# First check the type can be compiled
body = textwrap.dedent(r"""
typedef %(type)s npy_check_sizeof_type;
... | [
"def",
"check_type_size",
"(",
"self",
",",
"type_name",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"expected",
"=",
"None",
")",
":",
"self",
".",
"_check_compiler",
"(",
")",
"# First check the typ... | [
230,
4
] | [
311,
18
] | python | en | ['en', 'en', 'en'] | True |
config.check_funcs_once | (self, funcs,
headers=None, include_dirs=None,
libraries=None, library_dirs=None,
decl=False, call=False, call_args=None) | Check a list of functions at once.
This is useful to speed up things, since all the functions in the funcs
list will be put in one compilation unit.
Arguments
---------
funcs : seq
list of functions to test
include_dirs : seq
list of header paths... | Check a list of functions at once. | def check_funcs_once(self, funcs,
headers=None, include_dirs=None,
libraries=None, library_dirs=None,
decl=False, call=False, call_args=None):
"""Check a list of functions at once.
This is useful to speed up things, since all the functions in the... | [
"def",
"check_funcs_once",
"(",
"self",
",",
"funcs",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"decl",
"=",
"False",
",",
"call",
"=",
"False",
",",
"call_args",
... | [
347,
4
] | [
406,
53
] | python | en | ['en', 'en', 'en'] | True |
config.check_inline | (self) | Return the inline keyword recognized by the compiler, empty string
otherwise. | Return the inline keyword recognized by the compiler, empty string
otherwise. | def check_inline(self):
"""Return the inline keyword recognized by the compiler, empty string
otherwise."""
return check_inline(self) | [
"def",
"check_inline",
"(",
"self",
")",
":",
"return",
"check_inline",
"(",
"self",
")"
] | [
408,
4
] | [
411,
33
] | python | en | ['en', 'en', 'en'] | True |
config.check_restrict | (self) | Return the restrict keyword recognized by the compiler, empty string
otherwise. | Return the restrict keyword recognized by the compiler, empty string
otherwise. | def check_restrict(self):
"""Return the restrict keyword recognized by the compiler, empty string
otherwise."""
return check_restrict(self) | [
"def",
"check_restrict",
"(",
"self",
")",
":",
"return",
"check_restrict",
"(",
"self",
")"
] | [
413,
4
] | [
416,
35
] | python | en | ['en', 'en', 'en'] | True |
config.check_compiler_gcc4 | (self) | Return True if the C compiler is gcc >= 4. | Return True if the C compiler is gcc >= 4. | def check_compiler_gcc4(self):
"""Return True if the C compiler is gcc >= 4."""
return check_compiler_gcc4(self) | [
"def",
"check_compiler_gcc4",
"(",
"self",
")",
":",
"return",
"check_compiler_gcc4",
"(",
"self",
")"
] | [
418,
4
] | [
420,
40
] | python | en | ['en', 'la', 'en'] | True |
config.get_output | (self, body, headers=None, include_dirs=None,
libraries=None, library_dirs=None,
lang="c", use_tee=None) | Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Returns the exit status code
of the program and its output.
| Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Returns the exit status code
of the program and its output.
| def get_output(self, body, headers=None, include_dirs=None,
libraries=None, library_dirs=None,
lang="c", use_tee=None):
"""Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Returns the exit status code
of the program a... | [
"def",
"get_output",
"(",
"self",
",",
"body",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
",",
"use_tee",
"=",
"None",
")",
":",
"# 2008-11-... | [
433,
4
] | [
492,
31
] | python | en | ['en', 'en', 'en'] | True |
with_metaclass | (meta, *bases) |
Create a base class with a metaclass.
|
Create a base class with a metaclass.
| def with_metaclass(meta, *bases):
# type: (Type[Any], Tuple[Type[Any], ...]) -> Any
"""
Create a base class with a metaclass.
"""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual me... | [
"def",
"with_metaclass",
"(",
"meta",
",",
"*",
"bases",
")",
":",
"# type: (Type[Any], Tuple[Type[Any], ...]) -> Any",
"# This requires a bit of explanation: the basic idea is to make a dummy",
"# metaclass for one level of class instantiation that replaces itself with",
"# the actual metac... | [
24,
0
] | [
37,
61
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) | Set up WiLight lights from a config entry. | Set up WiLight lights from a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
):
"""Set up WiLight lights from a config entry."""
parent = hass.data[DOMAIN][entry.entry_id]
# Handle a discovered WiLight device.
entities = []
for item in parent.api.items:
if item["type"] != IT... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
":",
"parent",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"# Handle a discovered Wi... | [
34,
0
] | [
52,
32
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.__init__ | (self, api_device, index, item_name) | Initialize the device. | Initialize the device. | def __init__(self, api_device, index, item_name):
"""Initialize the device."""
super().__init__(api_device, index, item_name)
# Initialize the WiLights fan.
self._direction = WL_DIRECTION_FORWARD | [
"def",
"__init__",
"(",
"self",
",",
"api_device",
",",
"index",
",",
"item_name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"api_device",
",",
"index",
",",
"item_name",
")",
"# Initialize the WiLights fan.",
"self",
".",
"_direction",
"=",
"WL_DIR... | [
58,
4
] | [
62,
46
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORTED_FEATURES | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORTED_FEATURES"
] | [
65,
4
] | [
67,
33
] | python | en | ['da', 'en', 'en'] | True |
WiLightFan.icon | (self) | Return the icon of device based on its type. | Return the icon of device based on its type. | def icon(self):
"""Return the icon of device based on its type."""
return "mdi:fan" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:fan\""
] | [
70,
4
] | [
72,
24
] | python | en | ['en', 'en', 'en'] | True |
WiLightFan.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._status.get("direction", WL_DIRECTION_OFF) != WL_DIRECTION_OFF | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status",
".",
"get",
"(",
"\"direction\"",
",",
"WL_DIRECTION_OFF",
")",
"!=",
"WL_DIRECTION_OFF"
] | [
75,
4
] | [
77,
82
] | python | en | ['en', 'fy', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.