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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TrainerCallback.on_epoch_end | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called at the end of an epoch.
|
Event called at the end of an epoch.
| def on_epoch_end(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called at the end of an epoch.
"""
pass | [
"def",
"on_epoch_end",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
231,
4
] | [
235,
12
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallback.on_step_begin | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called at the beginning of a training step. If using gradient accumulation, one training step might take
several inputs.
|
Event called at the beginning of a training step. If using gradient accumulation, one training step might take
several inputs.
| def on_step_begin(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called at the beginning of a training step. If using gradient accumulation, one training step might take
several inputs.
"""
pass | [
"def",
"on_step_begin",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
237,
4
] | [
242,
12
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallback.on_step_end | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called at the end of a training step. If using gradient accumulation, one training step might take
several inputs.
|
Event called at the end of a training step. If using gradient accumulation, one training step might take
several inputs.
| def on_step_end(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called at the end of a training step. If using gradient accumulation, one training step might take
several inputs.
"""
pass | [
"def",
"on_step_end",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
244,
4
] | [
249,
12
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallback.on_evaluate | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called after an evaluation phase.
|
Event called after an evaluation phase.
| def on_evaluate(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called after an evaluation phase.
"""
pass | [
"def",
"on_evaluate",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
251,
4
] | [
255,
12
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallback.on_save | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called after a checkpoint save.
|
Event called after a checkpoint save.
| def on_save(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called after a checkpoint save.
"""
pass | [
"def",
"on_save",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
257,
4
] | [
261,
12
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallback.on_log | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called after logging the last logs.
|
Event called after logging the last logs.
| def on_log(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called after logging the last logs.
"""
pass | [
"def",
"on_log",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
263,
4
] | [
267,
12
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallback.on_prediction_step | (self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs) |
Event called after a prediction step.
|
Event called after a prediction step.
| def on_prediction_step(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, **kwargs):
"""
Event called after a prediction step.
"""
pass | [
"def",
"on_prediction_step",
"(",
"self",
",",
"args",
":",
"TrainingArguments",
",",
"state",
":",
"TrainerState",
",",
"control",
":",
"TrainerControl",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
269,
4
] | [
273,
12
] | python | en | ['en', 'error', 'th'] | False |
test_remote_setup_works | (hass) | Test a successful setup with all remotes. | Test a successful setup with all remotes. | async def test_remote_setup_works(hass):
"""Test a successful setup with all remotes."""
for device in map(get_device, REMOTE_DEVICES):
device_registry = mock_device_registry(hass)
entity_registry = mock_registry(hass)
mock_api, mock_entry = await device.setup_entry(hass)
device... | [
"async",
"def",
"test_remote_setup_works",
"(",
"hass",
")",
":",
"for",
"device",
"in",
"map",
"(",
"get_device",
",",
"REMOTE_DEVICES",
")",
":",
"device_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"entity_registry",
"=",
"mock_registry",
"(",
"h... | [
25,
0
] | [
42,
44
] | python | en | ['en', 'en', 'en'] | True |
test_remote_send_command | (hass) | Test sending a command with all remotes. | Test sending a command with all remotes. | async def test_remote_send_command(hass):
"""Test sending a command with all remotes."""
for device in map(get_device, REMOTE_DEVICES):
device_registry = mock_device_registry(hass)
entity_registry = mock_registry(hass)
mock_api, mock_entry = await device.setup_entry(hass)
device... | [
"async",
"def",
"test_remote_send_command",
"(",
"hass",
")",
":",
"for",
"device",
"in",
"map",
"(",
"get_device",
",",
"REMOTE_DEVICES",
")",
":",
"device_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"entity_registry",
"=",
"mock_registry",
"(",
"... | [
45,
0
] | [
69,
44
] | python | en | ['en', 'en', 'en'] | True |
test_remote_turn_off_turn_on | (hass) | Test we do not send commands if the remotes are off. | Test we do not send commands if the remotes are off. | async def test_remote_turn_off_turn_on(hass):
"""Test we do not send commands if the remotes are off."""
for device in map(get_device, REMOTE_DEVICES):
device_registry = mock_device_registry(hass)
entity_registry = mock_registry(hass)
mock_api, mock_entry = await device.setup_entry(hass)... | [
"async",
"def",
"test_remote_turn_off_turn_on",
"(",
"hass",
")",
":",
"for",
"device",
"in",
"map",
"(",
"get_device",
",",
"REMOTE_DEVICES",
")",
":",
"device_registry",
"=",
"mock_device_registry",
"(",
"hass",
")",
"entity_registry",
"=",
"mock_registry",
"(",... | [
72,
0
] | [
119,
44
] | python | en | ['en', 'en', 'en'] | True |
test_sensors | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test the creation and values of the sensors. | Test the creation and values of the sensors. | async def test_sensors(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the creation and values of the sensors."""
entry = await setup_integration(hass, aioclient_mock, skip_entry_setup=True)
registry = await hass.helpers.entity_registry.async_get_registry()
# Pre-cr... | [
"async",
"def",
"test_sensors",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"entry",
"=",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"skip_entry_setup",
"=",
"True",
... | [
24,
0
] | [
91,
29
] | python | en | ['en', 'en', 'en'] | True |
test_disabled_by_default_sensors | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker, entity_id: str
) | Test the disabled by default sensors. | Test the disabled by default sensors. | async def test_disabled_by_default_sensors(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker, entity_id: str
) -> None:
"""Test the disabled by default sensors."""
await setup_integration(hass, aioclient_mock)
registry = await hass.helpers.entity_registry.async_get_registry()
print(regis... | [
"async",
"def",
"test_disabled_by_default_sensors",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"entity_id",
":",
"str",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",... | [
104,
0
] | [
118,
45
] | python | en | ['en', 'en', 'en'] | True |
test_availability | (
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) | Test entity availability. | Test entity availability. | async def test_availability(
hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test entity availability."""
now = dt_util.utcnow()
with patch("homeassistant.util.dt.utcnow", return_value=now):
await setup_integration(hass, aioclient_mock)
assert hass.states.get(UPC... | [
"async",
"def",
"test_availability",
"(",
"hass",
":",
"HomeAssistantType",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.util.dt.utcnow\"",
",",
... | [
121,
0
] | [
174,
59
] | python | en | ['en', 'ga', 'en'] | True |
mock_yaml_devices | (hass) | Get a path for storing yaml devices. | Get a path for storing yaml devices. | def mock_yaml_devices(hass):
"""Get a path for storing yaml devices."""
yaml_devices = hass.config.path(legacy.YAML_DEVICES)
if os.path.isfile(yaml_devices):
os.remove(yaml_devices)
yield yaml_devices
if os.path.isfile(yaml_devices):
os.remove(yaml_devices) | [
"def",
"mock_yaml_devices",
"(",
"hass",
")",
":",
"yaml_devices",
"=",
"hass",
".",
"config",
".",
"path",
"(",
"legacy",
".",
"YAML_DEVICES",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"yaml_devices",
")",
":",
"os",
".",
"remove",
"(",
"yaml_... | [
45,
0
] | [
52,
31
] | python | en | ['en', 'en', 'en'] | True |
test_is_on | (hass) | Test is_on method. | Test is_on method. | async def test_is_on(hass):
"""Test is_on method."""
entity_id = f"{const.DOMAIN}.test"
hass.states.async_set(entity_id, STATE_HOME)
assert device_tracker.is_on(hass, entity_id)
hass.states.async_set(entity_id, STATE_NOT_HOME)
assert not device_tracker.is_on(hass, entity_id) | [
"async",
"def",
"test_is_on",
"(",
"hass",
")",
":",
"entity_id",
"=",
"f\"{const.DOMAIN}.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_HOME",
")",
"assert",
"device_tracker",
".",
"is_on",
"(",
"hass",
",",
"entity_id",
")",
... | [
55,
0
] | [
65,
52
] | python | en | ['en', 'et', 'en'] | True |
test_reading_broken_yaml_config | (hass) | Test when known devices contains invalid data. | Test when known devices contains invalid data. | async def test_reading_broken_yaml_config(hass):
"""Test when known devices contains invalid data."""
files = {
"empty.yaml": "",
"nodict.yaml": "100",
"badkey.yaml": "@:\n name: Device",
"noname.yaml": "my_device:\n",
"allok.yaml": "My Device:\n name: Device",
... | [
"async",
"def",
"test_reading_broken_yaml_config",
"(",
"hass",
")",
":",
"files",
"=",
"{",
"\"empty.yaml\"",
":",
"\"\"",
",",
"\"nodict.yaml\"",
":",
"\"100\"",
",",
"\"badkey.yaml\"",
":",
"\"@:\\n name: Device\"",
",",
"\"noname.yaml\"",
":",
"\"my_device:\\n\""... | [
68,
0
] | [
93,
43
] | python | en | ['en', 'en', 'en'] | True |
test_reading_yaml_config | (hass, yaml_devices) | Test the rendering of the YAML configuration. | Test the rendering of the YAML configuration. | async def test_reading_yaml_config(hass, yaml_devices):
"""Test the rendering of the YAML configuration."""
dev_id = "test"
device = legacy.Device(
hass,
timedelta(seconds=180),
True,
dev_id,
"AB:CD:EF:GH:IJ",
"Test name",
picture="http://test.picture"... | [
"async",
"def",
"test_reading_yaml_config",
"(",
"hass",
",",
"yaml_devices",
")",
":",
"dev_id",
"=",
"\"test\"",
"device",
"=",
"legacy",
".",
"Device",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"180",
")",
",",
"True",
",",
"dev_id",
",",
"\... | [
96,
0
] | [
121,
37
] | python | en | ['en', 'en', 'en'] | True |
test_duplicate_mac_dev_id | (mock_warning, hass) | Test adding duplicate MACs or device IDs to DeviceTracker. | Test adding duplicate MACs or device IDs to DeviceTracker. | async def test_duplicate_mac_dev_id(mock_warning, hass):
"""Test adding duplicate MACs or device IDs to DeviceTracker."""
devices = [
legacy.Device(
hass, True, True, "my_device", "AB:01", "My device", None, None, False
),
legacy.Device(
hass, True, True, "your_de... | [
"async",
"def",
"test_duplicate_mac_dev_id",
"(",
"mock_warning",
",",
"hass",
")",
":",
"devices",
"=",
"[",
"legacy",
".",
"Device",
"(",
"hass",
",",
"True",
",",
"True",
",",
"\"my_device\"",
",",
"\"AB:01\"",
",",
"\"My device\"",
",",
"None",
",",
"N... | [
125,
0
] | [
159,
85
] | python | en | ['en', 'en', 'en'] | True |
test_setup_without_yaml_file | (hass) | Test with no YAML file. | Test with no YAML file. | async def test_setup_without_yaml_file(hass):
"""Test with no YAML file."""
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM) | [
"async",
"def",
"test_setup_without_yaml_file",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"device_tracker",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"device_tracker",
".",
"DOMAIN",
",",
... | [
162,
0
] | [
165,
86
] | python | en | ['en', 'en', 'en'] | True |
test_gravatar | (hass) | Test the Gravatar generation. | Test the Gravatar generation. | async def test_gravatar(hass):
"""Test the Gravatar generation."""
dev_id = "test"
device = legacy.Device(
hass,
timedelta(seconds=180),
True,
dev_id,
"AB:CD:EF:GH:IJ",
"Test name",
gravatar="test@example.com",
)
gravatar_url = (
"https... | [
"async",
"def",
"test_gravatar",
"(",
"hass",
")",
":",
"dev_id",
"=",
"\"test\"",
"device",
"=",
"legacy",
".",
"Device",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"180",
")",
",",
"True",
",",
"dev_id",
",",
"\"AB:CD:EF:GH:IJ\"",
",",
"\"Test... | [
168,
0
] | [
184,
48
] | python | en | ['en', 'de', 'en'] | True |
test_gravatar_and_picture | (hass) | Test that Gravatar overrides picture. | Test that Gravatar overrides picture. | async def test_gravatar_and_picture(hass):
"""Test that Gravatar overrides picture."""
dev_id = "test"
device = legacy.Device(
hass,
timedelta(seconds=180),
True,
dev_id,
"AB:CD:EF:GH:IJ",
"Test name",
picture="http://test.picture",
gravatar="t... | [
"async",
"def",
"test_gravatar_and_picture",
"(",
"hass",
")",
":",
"dev_id",
"=",
"\"test\"",
"device",
"=",
"legacy",
".",
"Device",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"180",
")",
",",
"True",
",",
"dev_id",
",",
"\"AB:CD:EF:GH:IJ\"",
",... | [
187,
0
] | [
204,
48
] | python | en | ['en', 'la', 'en'] | True |
test_discover_platform | (mock_demo_setup_scanner, mock_see, hass) | Test discovery of device_tracker demo platform. | Test discovery of device_tracker demo platform. | async def test_discover_platform(mock_demo_setup_scanner, mock_see, hass):
"""Test discovery of device_tracker demo platform."""
await discovery.async_load_platform(
hass, device_tracker.DOMAIN, "demo", {"test_key": "test_val"}, {"bla": {}}
)
await hass.async_block_till_done()
assert device_... | [
"async",
"def",
"test_discover_platform",
"(",
"mock_demo_setup_scanner",
",",
"mock_see",
",",
"hass",
")",
":",
"await",
"discovery",
".",
"async_load_platform",
"(",
"hass",
",",
"device_tracker",
".",
"DOMAIN",
",",
"\"demo\"",
",",
"{",
"\"test_key\"",
":",
... | [
209,
0
] | [
222,
5
] | python | en | ['en', 'en', 'en'] | True |
test_update_stale | (hass, mock_device_tracker_conf) | Test stalled update. | Test stalled update. | async def test_update_stale(hass, mock_device_tracker_conf):
"""Test stalled update."""
scanner = getattr(hass.components, "test.device_tracker").SCANNER
scanner.reset()
scanner.come_home("DEV1")
now = dt_util.utcnow()
register_time = datetime(now.year + 1, 9, 15, 23, tzinfo=dt_util.UTC)
s... | [
"async",
"def",
"test_update_stale",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"scanner",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"\"test.device_tracker\"",
")",
".",
"SCANNER",
"scanner",
".",
"reset",
"(",
")",
"scanner",
".",
"com... | [
225,
0
] | [
264,
73
] | python | en | ['en', 'de', 'en'] | True |
test_entity_attributes | (hass, mock_device_tracker_conf) | Test the entity attributes. | Test the entity attributes. | async def test_entity_attributes(hass, mock_device_tracker_conf):
"""Test the entity attributes."""
devices = mock_device_tracker_conf
dev_id = "test_entity"
entity_id = f"{const.DOMAIN}.{dev_id}"
friendly_name = "Paulus"
picture = "http://placehold.it/200x200"
icon = "mdi:kettle"
devic... | [
"async",
"def",
"test_entity_attributes",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"devices",
"=",
"mock_device_tracker_conf",
"dev_id",
"=",
"\"test_entity\"",
"entity_id",
"=",
"f\"{const.DOMAIN}.{dev_id}\"",
"friendly_name",
"=",
"\"Paulus\"",
"picture",
... | [
267,
0
] | [
295,
52
] | python | en | ['en', 'en', 'en'] | True |
test_see_service | (mock_see, hass) | Test the see service with a unicode dev_id and NO MAC. | Test the see service with a unicode dev_id and NO MAC. | async def test_see_service(mock_see, hass):
"""Test the see service with a unicode dev_id and NO MAC."""
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
params = {
"dev_id": "some_device",
"host_nam... | [
"async",
"def",
"test_see_service",
"(",
"mock_see",
",",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"device_tracker",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"device_tracker",
".",
"DOMAIN",... | [
299,
0
] | [
323,
47
] | python | en | ['en', 'en', 'en'] | True |
test_see_service_guard_config_entry | (hass, mock_device_tracker_conf) | Test the guard if the device is registered in the entity registry. | Test the guard if the device is registered in the entity registry. | async def test_see_service_guard_config_entry(hass, mock_device_tracker_conf):
"""Test the guard if the device is registered in the entity registry."""
mock_entry = Mock()
dev_id = "test"
entity_id = f"{const.DOMAIN}.{dev_id}"
mock_registry(hass, {entity_id: mock_entry})
devices = mock_device_tr... | [
"async",
"def",
"test_see_service_guard_config_entry",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"mock_entry",
"=",
"Mock",
"(",
")",
"dev_id",
"=",
"\"test\"",
"entity_id",
"=",
"f\"{const.DOMAIN}.{dev_id}\"",
"mock_registry",
"(",
"hass",
",",
"{",
"... | [
326,
0
] | [
339,
22
] | python | en | ['en', 'en', 'en'] | True |
test_new_device_event_fired | (hass, mock_device_tracker_conf) | Test that the device tracker will fire an event. | Test that the device tracker will fire an event. | async def test_new_device_event_fired(hass, mock_device_tracker_conf):
"""Test that the device tracker will fire an event."""
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
test_events = []
@callback
def ... | [
"async",
"def",
"test_new_device_event_fired",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"device_tracker",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"device_t... | [
342,
0
] | [
369,
5
] | python | en | ['en', 'en', 'en'] | True |
test_duplicate_yaml_keys | (hass, mock_device_tracker_conf) | Test that the device tracker will not generate invalid YAML. | Test that the device tracker will not generate invalid YAML. | async def test_duplicate_yaml_keys(hass, mock_device_tracker_conf):
"""Test that the device tracker will not generate invalid YAML."""
devices = mock_device_tracker_conf
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFO... | [
"async",
"def",
"test_duplicate_yaml_keys",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"devices",
"=",
"mock_device_tracker_conf",
"with",
"assert_setup_component",
"(",
"1",
",",
"device_tracker",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"async_setup_... | [
372,
0
] | [
384,
49
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_dev_id | (hass, mock_device_tracker_conf) | Test that the device tracker will not allow invalid dev ids. | Test that the device tracker will not allow invalid dev ids. | async def test_invalid_dev_id(hass, mock_device_tracker_conf):
"""Test that the device tracker will not allow invalid dev ids."""
devices = mock_device_tracker_conf
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
... | [
"async",
"def",
"test_invalid_dev_id",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"devices",
"=",
"mock_device_tracker_conf",
"with",
"assert_setup_component",
"(",
"1",
",",
"device_tracker",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"async_setup_compo... | [
387,
0
] | [
396,
22
] | python | en | ['en', 'en', 'en'] | True |
test_see_state | (hass, yaml_devices) | Test device tracker see records state correctly. | Test device tracker see records state correctly. | async def test_see_state(hass, yaml_devices):
"""Test device tracker see records state correctly."""
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
params = {
"mac": "AA:BB:CC:DD:EE:FF",
"dev_id": "some_device",
"host_name": "example.com",
"lo... | [
"async",
"def",
"test_see_state",
"(",
"hass",
",",
"yaml_devices",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"device_tracker",
".",
"DOMAIN",
",",
"TEST_PLATFORM",
")",
"params",
"=",
"{",
"\"mac\"",
":",
"\"AA:BB:CC:DD:EE:FF\"",
"... | [
399,
0
] | [
432,
31
] | python | en | ['en', 'en', 'en'] | True |
test_see_passive_zone_state | (hass, mock_device_tracker_conf) | Test that the device tracker sets gps for passive trackers. | Test that the device tracker sets gps for passive trackers. | async def test_see_passive_zone_state(hass, mock_device_tracker_conf):
"""Test that the device tracker sets gps for passive trackers."""
now = dt_util.utcnow()
register_time = datetime(now.year + 1, 9, 15, 23, tzinfo=dt_util.UTC)
scan_time = datetime(now.year + 1, 9, 15, 23, 1, tzinfo=dt_util.UTC)
... | [
"async",
"def",
"test_see_passive_zone_state",
"(",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"register_time",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"9",
",",
"15",
",",
"23",
",... | [
435,
0
] | [
503,
72
] | python | en | ['en', 'en', 'en'] | True |
test_see_failures | (mock_warning, hass, mock_device_tracker_conf) | Test that the device tracker see failures. | Test that the device tracker see failures. | async def test_see_failures(mock_warning, hass, mock_device_tracker_conf):
"""Test that the device tracker see failures."""
devices = mock_device_tracker_conf
tracker = legacy.DeviceTracker(hass, timedelta(seconds=60), 0, {}, [])
# MAC is not a string (but added)
await tracker.async_see(mac=567, ho... | [
"async",
"def",
"test_see_failures",
"(",
"mock_warning",
",",
"hass",
",",
"mock_device_tracker_conf",
")",
":",
"devices",
"=",
"mock_device_tracker_conf",
"tracker",
"=",
"legacy",
".",
"DeviceTracker",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"60",
... | [
507,
0
] | [
527,
28
] | python | en | ['en', 'en', 'en'] | True |
test_async_added_to_hass | (hass) | Test restoring state. | Test restoring state. | async def test_async_added_to_hass(hass):
"""Test restoring state."""
attr = {
ATTR_LONGITUDE: 18,
ATTR_LATITUDE: -33,
const.ATTR_SOURCE_TYPE: "gps",
ATTR_GPS_ACCURACY: 2,
const.ATTR_BATTERY: 100,
}
mock_restore_cache(hass, [State("device_tracker.jk", "home", attr... | [
"async",
"def",
"test_async_added_to_hass",
"(",
"hass",
")",
":",
"attr",
"=",
"{",
"ATTR_LONGITUDE",
":",
"18",
",",
"ATTR_LATITUDE",
":",
"-",
"33",
",",
"const",
".",
"ATTR_SOURCE_TYPE",
":",
"\"gps\"",
",",
"ATTR_GPS_ACCURACY",
":",
"2",
",",
"const",
... | [
530,
0
] | [
553,
57
] | python | en | ['en', 'da', 'en'] | True |
test_bad_platform | (hass) | Test bad platform. | Test bad platform. | async def test_bad_platform(hass):
"""Test bad platform."""
config = {"device_tracker": [{"platform": "bad_platform"}]}
with assert_setup_component(0, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, config) | [
"async",
"def",
"test_bad_platform",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"device_tracker\"",
":",
"[",
"{",
"\"platform\"",
":",
"\"bad_platform\"",
"}",
"]",
"}",
"with",
"assert_setup_component",
"(",
"0",
",",
"device_tracker",
".",
"DOMAIN",
")",
... | [
556,
0
] | [
560,
79
] | python | en | ['en', 'da', 'en'] | True |
test_adding_unknown_device_to_config | (mock_device_tracker_conf, hass) | Test the adding of unknown devices to configuration file. | Test the adding of unknown devices to configuration file. | async def test_adding_unknown_device_to_config(mock_device_tracker_conf, hass):
"""Test the adding of unknown devices to configuration file."""
scanner = getattr(hass.components, "test.device_tracker").SCANNER
scanner.reset()
scanner.come_home("DEV1")
await async_setup_component(
hass, devi... | [
"async",
"def",
"test_adding_unknown_device_to_config",
"(",
"mock_device_tracker_conf",
",",
"hass",
")",
":",
"scanner",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"\"test.device_tracker\"",
")",
".",
"SCANNER",
"scanner",
".",
"reset",
"(",
")",
"scan... | [
563,
0
] | [
578,
23
] | python | en | ['en', 'en', 'en'] | True |
test_picture_and_icon_on_see_discovery | (mock_device_tracker_conf, hass) | Test that picture and icon are set in initial see. | Test that picture and icon are set in initial see. | async def test_picture_and_icon_on_see_discovery(mock_device_tracker_conf, hass):
"""Test that picture and icon are set in initial see."""
tracker = legacy.DeviceTracker(hass, timedelta(seconds=60), False, {}, [])
await tracker.async_see(dev_id=11, picture="pic_url", icon="mdi:icon")
await hass.async_bl... | [
"async",
"def",
"test_picture_and_icon_on_see_discovery",
"(",
"mock_device_tracker_conf",
",",
"hass",
")",
":",
"tracker",
"=",
"legacy",
".",
"DeviceTracker",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"60",
")",
",",
"False",
",",
"{",
"}",
",",
... | [
581,
0
] | [
588,
66
] | python | en | ['en', 'en', 'en'] | True |
test_backward_compatibility_for_track_new | (mock_device_tracker_conf, hass) | Test backward compatibility for track new. | Test backward compatibility for track new. | async def test_backward_compatibility_for_track_new(mock_device_tracker_conf, hass):
"""Test backward compatibility for track new."""
tracker = legacy.DeviceTracker(
hass, timedelta(seconds=60), False, {device_tracker.CONF_TRACK_NEW: True}, []
)
await tracker.async_see(dev_id=13)
await hass.... | [
"async",
"def",
"test_backward_compatibility_for_track_new",
"(",
"mock_device_tracker_conf",
",",
"hass",
")",
":",
"tracker",
"=",
"legacy",
".",
"DeviceTracker",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"60",
")",
",",
"False",
",",
"{",
"device_tr... | [
591,
0
] | [
599,
53
] | python | en | ['en', 'en', 'en'] | True |
test_old_style_track_new_is_skipped | (mock_device_tracker_conf, hass) | Test old style config is skipped. | Test old style config is skipped. | async def test_old_style_track_new_is_skipped(mock_device_tracker_conf, hass):
"""Test old style config is skipped."""
tracker = legacy.DeviceTracker(
hass, timedelta(seconds=60), None, {device_tracker.CONF_TRACK_NEW: False}, []
)
await tracker.async_see(dev_id=14)
await hass.async_block_til... | [
"async",
"def",
"test_old_style_track_new_is_skipped",
"(",
"mock_device_tracker_conf",
",",
"hass",
")",
":",
"tracker",
"=",
"legacy",
".",
"DeviceTracker",
"(",
"hass",
",",
"timedelta",
"(",
"seconds",
"=",
"60",
")",
",",
"None",
",",
"{",
"device_tracker",... | [
602,
0
] | [
610,
53
] | python | en | ['en', 'en', 'en'] | True |
test_see_schema_allowing_ios_calls | () | Test SEE service schema allows extra keys.
Temp work around because the iOS app sends incorrect data.
| Test SEE service schema allows extra keys. | def test_see_schema_allowing_ios_calls():
"""Test SEE service schema allows extra keys.
Temp work around because the iOS app sends incorrect data.
"""
device_tracker.SERVICE_SEE_PAYLOAD_SCHEMA(
{
"dev_id": "Test",
"battery": 35,
"battery_status": "Not Chargin... | [
"def",
"test_see_schema_allowing_ios_calls",
"(",
")",
":",
"device_tracker",
".",
"SERVICE_SEE_PAYLOAD_SCHEMA",
"(",
"{",
"\"dev_id\"",
":",
"\"Test\"",
",",
"\"battery\"",
":",
"35",
",",
"\"battery_status\"",
":",
"\"Not Charging\"",
",",
"\"gps\"",
":",
"[",
"10... | [
613,
0
] | [
627,
5
] | python | en | ['de', 'en', 'en'] | True |
handle_unmute_tts | (event) | enable tts execution | enable tts execution | def handle_unmute_tts(event):
""" enable tts execution """
global speak_muted
speak_muted = False
bus.emit(Message("mycroft.tts.mute_status", {"muted": speak_muted})) | [
"def",
"handle_unmute_tts",
"(",
"event",
")",
":",
"global",
"speak_muted",
"speak_muted",
"=",
"False",
"bus",
".",
"emit",
"(",
"Message",
"(",
"\"mycroft.tts.mute_status\"",
",",
"{",
"\"muted\"",
":",
"speak_muted",
"}",
")",
")"
] | [
46,
0
] | [
50,
72
] | python | en | ['en', 'en', 'en'] | True |
handle_mute_tts | (event) | disable tts execution | disable tts execution | def handle_mute_tts(event):
""" disable tts execution """
global speak_muted
speak_muted = True
bus.emit(Message("mycroft.tts.mute_status", {"muted": speak_muted})) | [
"def",
"handle_mute_tts",
"(",
"event",
")",
":",
"global",
"speak_muted",
"speak_muted",
"=",
"True",
"bus",
".",
"emit",
"(",
"Message",
"(",
"\"mycroft.tts.mute_status\"",
",",
"{",
"\"muted\"",
":",
"speak_muted",
"}",
")",
")"
] | [
53,
0
] | [
57,
72
] | python | en | ['en', 'en', 'en'] | True |
handle_mute_status | (event) | emit tts mute status to bus | emit tts mute status to bus | def handle_mute_status(event):
""" emit tts mute status to bus """
bus.emit(Message("mycroft.tts.mute_status", {"muted": speak_muted})) | [
"def",
"handle_mute_status",
"(",
"event",
")",
":",
"bus",
".",
"emit",
"(",
"Message",
"(",
"\"mycroft.tts.mute_status\"",
",",
"{",
"\"muted\"",
":",
"speak_muted",
"}",
")",
")"
] | [
60,
0
] | [
62,
72
] | python | en | ['en', 'sn', 'sw'] | False |
handle_get_tts | (message) |
Handle a request to get TTS only
:param message: Message associated with request
|
Handle a request to get TTS only
:param message: Message associated with request
| def handle_get_tts(message):
"""
Handle a request to get TTS only
:param message: Message associated with request
"""
global tts
text = message.data.get("text")
ident = message.context.get("ident") or "neon.get_tts.response"
if not message.data.get("speaker"):
LOG.warning(f"No sp... | [
"def",
"handle_get_tts",
"(",
"message",
")",
":",
"global",
"tts",
"text",
"=",
"message",
".",
"data",
".",
"get",
"(",
"\"text\"",
")",
"ident",
"=",
"message",
".",
"context",
".",
"get",
"(",
"\"ident\"",
")",
"or",
"\"neon.get_tts.response\"",
"if",
... | [
65,
0
] | [
88,
75
] | python | en | ['en', 'error', 'th'] | False |
handle_speak | (message) | Handle "speak" message
Parse sentences and invoke text to speech service.
| Handle "speak" message | def handle_speak(message):
"""Handle "speak" message
Parse sentences and invoke text to speech service.
"""
# Configuration.set_config_update_handlers(bus)
global _last_stop_signal
message.context = message.context or {}
# if the message is targeted and audio is not the target don't
#... | [
"def",
"handle_speak",
"(",
"message",
")",
":",
"# Configuration.set_config_update_handlers(bus)",
"global",
"_last_stop_signal",
"message",
".",
"context",
"=",
"message",
".",
"context",
"or",
"{",
"}",
"# if the message is targeted and audio is not the target don't",
"# d... | [
91,
0
] | [
116,
74
] | python | en | ['en', 'nl', 'en'] | True |
mute_and_speak | (utterance, message) | Mute mic and start speaking the utterance using selected tts backend.
Arguments:
utterance: The sentence to be spoken
message: Message associated with request
| Mute mic and start speaking the utterance using selected tts backend. | def mute_and_speak(utterance, message):
"""Mute mic and start speaking the utterance using selected tts backend.
Arguments:
utterance: The sentence to be spoken
message: Message associated with request
"""
global tts_hash, speak_muted, tts
LOG.info("Speak: " + utterance)
if ... | [
"def",
"mute_and_speak",
"(",
"utterance",
",",
"message",
")",
":",
"global",
"tts_hash",
",",
"speak_muted",
",",
"tts",
"LOG",
".",
"info",
"(",
"\"Speak: \"",
"+",
"utterance",
")",
"if",
"speak_muted",
":",
"LOG",
".",
"warning",
"(",
"\"Tried to speak,... | [
119,
0
] | [
150,
62
] | python | en | ['en', 'en', 'en'] | True |
handle_stop | (event) | Handle stop message.
Shutdown any speech.
| Handle stop message. | def handle_stop(event):
"""Handle stop message.
Shutdown any speech.
"""
global _last_stop_signal
if check_for_signal("isSpeaking", -1):
_last_stop_signal = time.time()
tts.playback.clear() # Clear here to get instant stop
bus.emit(Message("mycroft.stop.handled", {"by": "TT... | [
"def",
"handle_stop",
"(",
"event",
")",
":",
"global",
"_last_stop_signal",
"if",
"check_for_signal",
"(",
"\"isSpeaking\"",
",",
"-",
"1",
")",
":",
"_last_stop_signal",
"=",
"time",
".",
"time",
"(",
")",
"tts",
".",
"playback",
".",
"clear",
"(",
")",
... | [
168,
0
] | [
177,
64
] | python | en | ['en', 'en', 'en'] | True |
init | (messagebus, conf=None) | Start speech related handlers.
Arguments:
messagebus: Connection to the Mycroft messagebus
conf: configuration override
| Start speech related handlers. | def init(messagebus, conf=None):
"""Start speech related handlers.
Arguments:
messagebus: Connection to the Mycroft messagebus
conf: configuration override
"""
global bus
global tts
global tts_hash
global config
bus = messagebus
# Configuration.set_config_update_ha... | [
"def",
"init",
"(",
"messagebus",
",",
"conf",
"=",
"None",
")",
":",
"global",
"bus",
"global",
"tts",
"global",
"tts_hash",
"global",
"config",
"bus",
"=",
"messagebus",
"# Configuration.set_config_update_handlers(bus)",
"# config = Configuration.get()",
"config",
"... | [
180,
0
] | [
209,
47
] | python | en | ['en', 'lb', 'en'] | True |
shutdown | () | Shutdown the audio service cleanly.
Stop any playing audio and make sure threads are joined correctly.
| Shutdown the audio service cleanly. | def shutdown():
"""Shutdown the audio service cleanly.
Stop any playing audio and make sure threads are joined correctly.
"""
if tts:
tts.playback.stop()
tts.playback.join()
if mimic_fallback_obj:
mimic_fallback_obj.playback.stop()
mimic_fallback_obj.playback.join() | [
"def",
"shutdown",
"(",
")",
":",
"if",
"tts",
":",
"tts",
".",
"playback",
".",
"stop",
"(",
")",
"tts",
".",
"playback",
".",
"join",
"(",
")",
"if",
"mimic_fallback_obj",
":",
"mimic_fallback_obj",
".",
"playback",
".",
"stop",
"(",
")",
"mimic_fall... | [
212,
0
] | [
222,
42
] | python | en | ['en', 'en', 'en'] | True |
assert_tensors_close | (a, b, atol=1e-12, prefix="") | If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error. | If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error. | def assert_tensors_close(a, b, atol=1e-12, prefix=""):
"""If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error."""
if a is None and b is None:
return True
try:
if torch.allclose(a, b, atol=atol):
return True
rais... | [
"def",
"assert_tensors_close",
"(",
"a",
",",
"b",
",",
"atol",
"=",
"1e-12",
",",
"prefix",
"=",
"\"\"",
")",
":",
"if",
"a",
"is",
"None",
"and",
"b",
"is",
"None",
":",
"return",
"True",
"try",
":",
"if",
"torch",
".",
"allclose",
"(",
"a",
",... | [
290,
0
] | [
306,
33
] | python | en | ['en', 'en', 'en'] | True |
idfn | (val) | Provide IDs for pytest parametrize. | Provide IDs for pytest parametrize. | def idfn(val):
"""Provide IDs for pytest parametrize."""
if isinstance(val, (datetime)):
return val.strftime("%Y%m%d") | [
"def",
"idfn",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"(",
"datetime",
")",
")",
":",
"return",
"val",
".",
"strftime",
"(",
"\"%Y%m%d\"",
")"
] | [
61,
0
] | [
64,
37
] | python | en | ['en', 'no', 'en'] | True |
test_season_northern_hemisphere | (hass, type, day, expected) | Test that season should be summer. | Test that season should be summer. | async def test_season_northern_hemisphere(hass, type, day, expected):
"""Test that season should be summer."""
hass.config.latitude = HEMISPHERE_NORTHERN["homeassistant"]["latitude"]
config = {
**HEMISPHERE_NORTHERN,
"sensor": {"platform": "season", "type": type},
}
with patch("hom... | [
"async",
"def",
"test_season_northern_hemisphere",
"(",
"hass",
",",
"type",
",",
"day",
",",
"expected",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"HEMISPHERE_NORTHERN",
"[",
"\"homeassistant\"",
"]",
"[",
"\"latitude\"",
"]",
"config",
"=",
"{",... | [
68,
0
] | [
83,
34
] | python | en | ['en', 'en', 'en'] | True |
test_season_southern_hemisphere | (hass, type, day, expected) | Test that season should be summer. | Test that season should be summer. | async def test_season_southern_hemisphere(hass, type, day, expected):
"""Test that season should be summer."""
hass.config.latitude = HEMISPHERE_SOUTHERN["homeassistant"]["latitude"]
config = {
**HEMISPHERE_SOUTHERN,
"sensor": {"platform": "season", "type": type},
}
with patch("hom... | [
"async",
"def",
"test_season_southern_hemisphere",
"(",
"hass",
",",
"type",
",",
"day",
",",
"expected",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"HEMISPHERE_SOUTHERN",
"[",
"\"homeassistant\"",
"]",
"[",
"\"latitude\"",
"]",
"config",
"=",
"{",... | [
87,
0
] | [
102,
34
] | python | en | ['en', 'en', 'en'] | True |
test_season_equator | (hass) | Test that season should be unknown for equator. | Test that season should be unknown for equator. | async def test_season_equator(hass):
"""Test that season should be unknown for equator."""
hass.config.latitude = HEMISPHERE_EQUATOR["homeassistant"]["latitude"]
day = datetime(2017, 9, 3, 0, 0)
with patch("homeassistant.components.season.sensor.utcnow", return_value=day):
assert await async_se... | [
"async",
"def",
"test_season_equator",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"HEMISPHERE_EQUATOR",
"[",
"\"homeassistant\"",
"]",
"[",
"\"latitude\"",
"]",
"day",
"=",
"datetime",
"(",
"2017",
",",
"9",
",",
"3",
",",
"0",
"... | [
105,
0
] | [
116,
39
] | python | en | ['en', 'en', 'en'] | True |
test_setup_hemisphere_empty | (hass) | Test platform setup of missing latlong. | Test platform setup of missing latlong. | async def test_setup_hemisphere_empty(hass):
"""Test platform setup of missing latlong."""
hass.config.latitude = None
assert await async_setup_component(hass, "sensor", HEMISPHERE_EMPTY)
await hass.async_block_till_done()
assert hass.config.as_dict()["latitude"] is None | [
"async",
"def",
"test_setup_hemisphere_empty",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"None",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"HEMISPHERE_EMPTY",
")",
"await",
"hass",
".",
"async_bloc... | [
119,
0
] | [
124,
52
] | python | en | ['en', 'da', 'en'] | True |
test_get_image | (hass, hass_ws_client, caplog) | Test get image via WS command. | Test get image via WS command. | async def test_get_image(hass, hass_ws_client, caplog):
"""Test get image via WS command."""
await async_setup_component(
hass, "media_player", {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
client = await hass_ws_client(hass)
with patch(
"homeassis... | [
"async",
"def",
"test_get_image",
"(",
"hass",
",",
"hass_ws_client",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"media_player\"",
",",
"{",
"\"media_player\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"awai... | [
10,
0
] | [
40,
64
] | python | en | ['nl', 'pt', 'en'] | False |
test_get_image_http | (hass, aiohttp_client) | Test get image via http command. | Test get image via http command. | async def test_get_image_http(hass, aiohttp_client):
"""Test get image via http command."""
await async_setup_component(
hass, "media_player", {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
state = hass.states.get("media_player.bedroom")
assert "entity_pictu... | [
"async",
"def",
"test_get_image_http",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"media_player\"",
",",
"{",
"\"media_player\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
... | [
43,
0
] | [
63,
30
] | python | en | ['nl', 'en', 'en'] | True |
test_get_image_http_remote | (hass, aiohttp_client) | Test get image url via http command. | Test get image url via http command. | async def test_get_image_http_remote(hass, aiohttp_client):
"""Test get image url via http command."""
with patch(
"homeassistant.components.media_player.MediaPlayerEntity."
"media_image_remotely_accessible",
return_value=True,
):
await async_setup_component(
hass... | [
"async",
"def",
"test_get_image_http_remote",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.media_player.MediaPlayerEntity.\"",
"\"media_image_remotely_accessible\"",
",",
"return_value",
"=",
"True",
",",
")",
":",
"await",... | [
66,
0
] | [
91,
34
] | python | en | ['nl', 'pt', 'en'] | False |
test_get_async_get_browse_image | (hass, aiohttp_client, hass_ws_client) | Test get browse image. | Test get browse image. | async def test_get_async_get_browse_image(hass, aiohttp_client, hass_ws_client):
"""Test get browse image."""
await async_setup_component(
hass, "media_player", {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
entity_comp = hass.data.get("entity_components", {}).g... | [
"async",
"def",
"test_get_async_get_browse_image",
"(",
"hass",
",",
"aiohttp_client",
",",
"hass_ws_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"media_player\"",
",",
"{",
"\"media_player\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"... | [
94,
0
] | [
118,
30
] | python | en | ['nl', 'en', 'en'] | True |
test_deprecated_base_class | (caplog) | Test deprecated base class. | Test deprecated base class. | def test_deprecated_base_class(caplog):
"""Test deprecated base class."""
class CustomMediaPlayer(media_player.MediaPlayerDevice):
pass
CustomMediaPlayer()
assert "MediaPlayerDevice is deprecated, modify CustomMediaPlayer" in caplog.text | [
"def",
"test_deprecated_base_class",
"(",
"caplog",
")",
":",
"class",
"CustomMediaPlayer",
"(",
"media_player",
".",
"MediaPlayerDevice",
")",
":",
"pass",
"CustomMediaPlayer",
"(",
")",
"assert",
"\"MediaPlayerDevice is deprecated, modify CustomMediaPlayer\"",
"in",
"capl... | [
121,
0
] | [
128,
85
] | python | en | ['en', 'en', 'en'] | True |
test_media_browse | (hass, hass_ws_client) | Test browsing media. | Test browsing media. | async def test_media_browse(hass, hass_ws_client):
"""Test browsing media."""
await async_setup_component(
hass, "media_player", {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
client = await hass_ws_client(hass)
with patch(
"homeassistant.components... | [
"async",
"def",
"test_media_browse",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"media_player\"",
",",
"{",
"\"media_player\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
... | [
131,
0
] | [
185,
41
] | python | en | ['en', 'jv', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up MQTT tag scan dynamically through MQTT discovery. | Set up MQTT tag scan dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry):
"""Set up MQTT tag scan dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add MQTT tag scan."""
discovery_data = discovery_payload.discovery_data
try:
config = PLATFORM_SCHEMA(... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add MQTT tag scan.\"\"\"",
"discovery_data",
"=",
"discovery_payload",
".",
"discovery_data",
"try",
... | [
42,
0
] | [
57,
5
] | python | en | ['en', 'vi', 'en'] | True |
async_setup_tag | (hass, config, config_entry, discovery_data) | Set up the MQTT tag scanner. | Set up the MQTT tag scanner. | async def async_setup_tag(hass, config, config_entry, discovery_data):
"""Set up the MQTT tag scanner."""
discovery_hash = discovery_data[ATTR_DISCOVERY_HASH]
discovery_id = discovery_hash[1]
device_id = None
if CONF_DEVICE in config:
await _update_device(hass, config_entry, config)
... | [
"async",
"def",
"async_setup_tag",
"(",
"hass",
",",
"config",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"discovery_hash",
"=",
"discovery_data",
"[",
"ATTR_DISCOVERY_HASH",
"]",
"discovery_id",
"=",
"discovery_hash",
"[",
"1",
"]",
"device_id",
"=",
... | [
60,
0
] | [
95,
62
] | python | en | ['en', 'en', 'en'] | True |
async_has_tags | (hass, device_id) | Device has tag scanners. | Device has tag scanners. | def async_has_tags(hass, device_id):
"""Device has tag scanners."""
if TAGS not in hass.data or device_id not in hass.data[TAGS]:
return False
return hass.data[TAGS][device_id] != {} | [
"def",
"async_has_tags",
"(",
"hass",
",",
"device_id",
")",
":",
"if",
"TAGS",
"not",
"in",
"hass",
".",
"data",
"or",
"device_id",
"not",
"in",
"hass",
".",
"data",
"[",
"TAGS",
"]",
":",
"return",
"False",
"return",
"hass",
".",
"data",
"[",
"TAGS... | [
98,
0
] | [
102,
43
] | python | en | ['en', 'en', 'en'] | True |
_update_device | (hass, config_entry, config) | Update device registry. | Update device registry. | async def _update_device(hass, config_entry, config):
"""Update device registry."""
device_registry = await hass.helpers.device_registry.async_get_registry()
config_entry_id = config_entry.entry_id
device_info = mqtt.device_info_from_config(config[CONF_DEVICE])
if config_entry_id is not None and de... | [
"async",
"def",
"_update_device",
"(",
"hass",
",",
"config_entry",
",",
"config",
")",
":",
"device_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"config_entry_id",
"=",
"config_entry",
".",
"entry... | [
215,
0
] | [
223,
58
] | python | en | ['fr', 'fy', 'en'] | False |
MQTTTagScanner.__init__ | (self, hass, config, device_id, discovery_data, config_entry) | Initialize. | Initialize. | def __init__(self, hass, config, device_id, discovery_data, config_entry):
"""Initialize."""
self._config = config
self._config_entry = config_entry
self.device_id = device_id
self.discovery_data = discovery_data
self.hass = hass
self._remove_discovery = None
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
",",
"device_id",
",",
"discovery_data",
",",
"config_entry",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_config_entry",
"=",
"config_entry",
"self",
".",
"device_id",
"=",
"de... | [
108,
4
] | [
120,
39
] | python | en | ['en', 'en', 'it'] | False |
MQTTTagScanner.discovery_update | (self, payload) | Handle discovery update. | Handle discovery update. | async def discovery_update(self, payload):
"""Handle discovery update."""
discovery_hash = self.discovery_data[ATTR_DISCOVERY_HASH]
_LOGGER.info(
"Got update for tag scanner with hash: %s '%s'", discovery_hash, payload
)
if not payload:
# Empty payload: Re... | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"payload",
")",
":",
"discovery_hash",
"=",
"self",
".",
"discovery_data",
"[",
"ATTR_DISCOVERY_HASH",
"]",
"_LOGGER",
".",
"info",
"(",
"\"Got update for tag scanner with hash: %s '%s'\"",
",",
"discovery_hash",
"... | [
122,
4
] | [
142,
41
] | python | en | ['it', 'en', 'en'] | True |
MQTTTagScanner.setup | (self) | Set up the MQTT tag scanner. | Set up the MQTT tag scanner. | async def setup(self):
"""Set up the MQTT tag scanner."""
discovery_hash = self.discovery_data[ATTR_DISCOVERY_HASH]
await self.subscribe_topics()
if self.device_id:
self._remove_device_updated = self.hass.bus.async_listen(
EVENT_DEVICE_REGISTRY_UPDATED, self.d... | [
"async",
"def",
"setup",
"(",
"self",
")",
":",
"discovery_hash",
"=",
"self",
".",
"discovery_data",
"[",
"ATTR_DISCOVERY_HASH",
"]",
"await",
"self",
".",
"subscribe_topics",
"(",
")",
"if",
"self",
".",
"device_id",
":",
"self",
".",
"_remove_device_updated... | [
152,
4
] | [
164,
9
] | python | en | ['en', 'en', 'en'] | True |
MQTTTagScanner.subscribe_topics | (self) | Subscribe to MQTT topics. | Subscribe to MQTT topics. | async def subscribe_topics(self):
"""Subscribe to MQTT topics."""
async def tag_scanned(msg):
tag_id = self._value_template(msg.payload, error_value="").strip()
if not tag_id: # No output from template, ignore
return
await self.hass.components.tag.a... | [
"async",
"def",
"subscribe_topics",
"(",
"self",
")",
":",
"async",
"def",
"tag_scanned",
"(",
"msg",
")",
":",
"tag_id",
"=",
"self",
".",
"_value_template",
"(",
"msg",
".",
"payload",
",",
"error_value",
"=",
"\"\"",
")",
".",
"strip",
"(",
")",
"if... | [
166,
4
] | [
186,
9
] | python | en | ['en', 'en', 'en'] | True |
MQTTTagScanner.device_removed | (self, event) | Handle the removal of a device. | Handle the removal of a device. | async def device_removed(self, event):
"""Handle the removal of a device."""
device_id = event.data["device_id"]
if event.data["action"] != "remove" or device_id != self.device_id:
return
await self.tear_down() | [
"async",
"def",
"device_removed",
"(",
"self",
",",
"event",
")",
":",
"device_id",
"=",
"event",
".",
"data",
"[",
"\"device_id\"",
"]",
"if",
"event",
".",
"data",
"[",
"\"action\"",
"]",
"!=",
"\"remove\"",
"or",
"device_id",
"!=",
"self",
".",
"devic... | [
188,
4
] | [
194,
30
] | python | en | ['en', 'en', 'en'] | True |
MQTTTagScanner.tear_down | (self) | Cleanup tag scanner. | Cleanup tag scanner. | async def tear_down(self):
"""Cleanup tag scanner."""
discovery_hash = self.discovery_data[ATTR_DISCOVERY_HASH]
discovery_id = discovery_hash[1]
discovery_topic = self.discovery_data[ATTR_DISCOVERY_TOPIC]
clear_discovery_hash(self.hass, discovery_hash)
if self.device_id:... | [
"async",
"def",
"tear_down",
"(",
"self",
")",
":",
"discovery_hash",
"=",
"self",
".",
"discovery_data",
"[",
"ATTR_DISCOVERY_HASH",
"]",
"discovery_id",
"=",
"discovery_hash",
"[",
"1",
"]",
"discovery_topic",
"=",
"self",
".",
"discovery_data",
"[",
"ATTR_DIS... | [
196,
4
] | [
212,
66
] | python | en | ['en', 'en', 'en'] | True |
AgentFlowHandler.__init__ | (self) | Initialize the Agent config flow. | Initialize the Agent config flow. | def __init__(self):
"""Initialize the Agent config flow."""
self.device_config = {} | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"device_config",
"=",
"{",
"}"
] | [
21,
4
] | [
23,
31
] | python | en | ['en', 'en', 'en'] | True |
AgentFlowHandler.async_step_user | (self, user_input=None) | Handle an Agent config flow. | Handle an Agent config flow. | async def async_step_user(self, user_input=None):
"""Handle an Agent config flow."""
errors = {}
if user_input is not None:
host = user_input[CONF_HOST]
port = user_input[CONF_PORT]
server_origin = generate_url(host, port)
agent_client = Agent(se... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"host",
"=",
"user_input",
"[",
"CONF_HOST",
"]",
"port",
"=",
"user_input",
"[",
"CONF_PORT"... | [
25,
4
] | [
76,
9
] | python | en | ['en', 'en', 'en'] | True |
AgentFlowHandler._create_entry | (self, server_name) | Create entry for device. | Create entry for device. | async def _create_entry(self, server_name):
"""Create entry for device."""
return self.async_create_entry(title=server_name, data=self.device_config) | [
"async",
"def",
"_create_entry",
"(",
"self",
",",
"server_name",
")",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"server_name",
",",
"data",
"=",
"self",
".",
"device_config",
")"
] | [
78,
4
] | [
80,
82
] | python | en | ['da', 'en', 'en'] | True |
emcee_flatchain | (chain, nburnin, nthin) | flattening of the emcee chains with removal of burn-in | flattening of the emcee chains with removal of burn-in | def emcee_flatchain(chain, nburnin, nthin):
"""flattening of the emcee chains with removal of burn-in"""
nburn, _ = emcee_burnin_check(chain, nburnin, nthin)
s = chain[:, nburn:, :].shape
return chain[:, nburn:, :].reshape(s[0] * s[1], s[2]) | [
"def",
"emcee_flatchain",
"(",
"chain",
",",
"nburnin",
",",
"nthin",
")",
":",
"nburn",
",",
"_",
"=",
"emcee_burnin_check",
"(",
"chain",
",",
"nburnin",
",",
"nthin",
")",
"s",
"=",
"chain",
"[",
":",
",",
"nburn",
":",
",",
":",
"]",
".",
"shap... | [
178,
0
] | [
182,
57
] | python | en | ['en', 'en', 'en'] | True |
GelmanRubin_v2 | (sampler_chain) |
:param chain_T:
:return:
|
:param chain_T:
:return:
| def GelmanRubin_v2(sampler_chain):
"""
:param chain_T:
:return:
"""
"""
from http://joergdietrich.github.io/emcee-convergence.html
"""
ssq = np.var(sampler_chain, axis=1, ddof=1)
W = np.mean(ssq, axis=0)
theta_b = np.mean(sampler_chain, axis=1)
theta_bb = np.mean(theta_b, ax... | [
"def",
"GelmanRubin_v2",
"(",
"sampler_chain",
")",
":",
"\"\"\"\n from http://joergdietrich.github.io/emcee-convergence.html\n \"\"\"",
"ssq",
"=",
"np",
".",
"var",
"(",
"sampler_chain",
",",
"axis",
"=",
"1",
",",
"ddof",
"=",
"1",
")",
"W",
"=",
"np",
".... | [
219,
0
] | [
237,
15
] | python | en | ['en', 'error', 'th'] | False |
test_plex_tv_clients | (hass, entry, mock_plex_account, setup_plex_server) | Test getting Plex clients from plex.tv. | Test getting Plex clients from plex.tv. | async def test_plex_tv_clients(hass, entry, mock_plex_account, setup_plex_server):
"""Test getting Plex clients from plex.tv."""
mock_plex_server = await setup_plex_server()
server_id = mock_plex_server.machineIdentifier
plex_server = hass.data[DOMAIN][SERVERS][server_id]
resource = next(
x... | [
"async",
"def",
"test_plex_tv_clients",
"(",
"hass",
",",
"entry",
",",
"mock_plex_account",
",",
"setup_plex_server",
")",
":",
"mock_plex_server",
"=",
"await",
"setup_plex_server",
"(",
")",
"server_id",
"=",
"mock_plex_server",
".",
"machineIdentifier",
"plex_serv... | [
8,
0
] | [
55,
65
] | python | en | ['en', 'mt', 'en'] | True |
test_binary_sensors | (hass, surepetcare) | Test the generation of unique ids. | Test the generation of unique ids. | async def test_binary_sensors(hass, surepetcare) -> None:
"""Test the generation of unique ids."""
instance = surepetcare.return_value
instance.data = MOCK_API_DATA
instance.get_data.return_value = MOCK_API_DATA
with _patch_sensor_setup():
assert await async_setup_component(hass, DOMAIN, MO... | [
"async",
"def",
"test_binary_sensors",
"(",
"hass",
",",
"surepetcare",
")",
"->",
"None",
":",
"instance",
"=",
"surepetcare",
".",
"return_value",
"instance",
".",
"data",
"=",
"MOCK_API_DATA",
"instance",
".",
"get_data",
".",
"return_value",
"=",
"MOCK_API_D... | [
15,
0
] | [
31,
44
] | python | en | ['en', 'fr', 'en'] | True |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up the Withings component. | Set up the Withings component. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Withings component."""
conf = config.get(DOMAIN, {})
if not conf:
return True
# Make the config available to the oauth2 config flow.
hass.data[DOMAIN] = {const.CONFIG: conf}
# Setup the oauth2 config ... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"if",
"not",
"conf",
":",
"return",
"True",
"# Make the co... | [
64,
0
] | [
86,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Withings from a config entry. | Set up Withings from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Withings from a config entry."""
config_updates = {}
# Add a unique id if it's an older config entry.
if entry.unique_id != entry.data["token"]["userid"] or not isinstance(
entry.unique_id, str
):
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"config_updates",
"=",
"{",
"}",
"# Add a unique id if it's an older config entry.",
"if",
"entry",
".",
"unique_id",
"!=",
"entry",
"... | [
89,
0
] | [
154,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload Withings config entry. | Unload Withings config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Withings config entry."""
data_manager = await async_get_data_manager(hass, entry)
data_manager.async_stop_polling_webhook_subscriptions()
async_unregister_webhook(hass, data_manager.webhook_config.id)
await a... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"data_manager",
"=",
"await",
"async_get_data_manager",
"(",
"hass",
",",
"entry",
")",
"data_manager",
".",
"async_stop_polling_webh... | [
157,
0
] | [
172,
15
] | python | en | ['en', 'en', 'en'] | True |
async_webhook_handler | (
hass: HomeAssistant, webhook_id: str, request: Request
) | Handle webhooks calls. | Handle webhooks calls. | async def async_webhook_handler(
hass: HomeAssistant, webhook_id: str, request: Request
) -> Optional[Response]:
"""Handle webhooks calls."""
# Handle http head calls to the path.
# When creating a notify subscription, Withings will check that the endpoint is running by sending a HEAD request.
if re... | [
"async",
"def",
"async_webhook_handler",
"(",
"hass",
":",
"HomeAssistant",
",",
"webhook_id",
":",
"str",
",",
"request",
":",
"Request",
")",
"->",
"Optional",
"[",
"Response",
"]",
":",
"# Handle http head calls to the path.",
"# When creating a notify subscription, ... | [
175,
0
] | [
214,
59
] | python | en | ['en', 'xh', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Command Line notification service. | Get the Command Line notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Command Line notification service."""
command = config[CONF_COMMAND]
timeout = config[CONF_COMMAND_TIMEOUT]
return CommandLineNotificationService(command, timeout) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"command",
"=",
"config",
"[",
"CONF_COMMAND",
"]",
"timeout",
"=",
"config",
"[",
"CONF_COMMAND_TIMEOUT",
"]",
"return",
"CommandLineNotificationService",
"(",
"comm... | [
23,
0
] | [
28,
59
] | python | en | ['en', 'en', 'en'] | True |
CommandLineNotificationService.__init__ | (self, command, timeout) | Initialize the service. | Initialize the service. | def __init__(self, command, timeout):
"""Initialize the service."""
self.command = command
self._timeout = timeout | [
"def",
"__init__",
"(",
"self",
",",
"command",
",",
"timeout",
")",
":",
"self",
".",
"command",
"=",
"command",
"self",
".",
"_timeout",
"=",
"timeout"
] | [
34,
4
] | [
37,
31
] | python | en | ['en', 'en', 'en'] | True |
CommandLineNotificationService.send_message | (self, message="", **kwargs) | Send a message to a command line. | Send a message to a command line. | def send_message(self, message="", **kwargs):
"""Send a message to a command line."""
try:
proc = subprocess.Popen(
self.command,
universal_newlines=True,
stdin=subprocess.PIPE,
shell=True, # nosec # shell by design
... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"self",
".",
"command",
",",
"universal_newlines",
"=",
"True",
",",
"stdin",
"=",
"subprocess... | [
39,
4
] | [
54,
75
] | python | en | ['en', 'en', 'en'] | True |
check_feasibility | (x_bounds, lowerbound, upperbound) |
This can have false positives.
For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7.
|
This can have false positives.
For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7.
| def check_feasibility(x_bounds, lowerbound, upperbound):
'''
This can have false positives.
For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7.
'''
# x_bounds should be sorted, so even for "discrete_int" type,
# the smallest and the largest number should... | [
"def",
"check_feasibility",
"(",
"x_bounds",
",",
"lowerbound",
",",
"upperbound",
")",
":",
"# x_bounds should be sorted, so even for \"discrete_int\" type,",
"# the smallest and the largest number should the first and the last element",
"x_bounds_lowerbound",
"=",
"sum",
"(",
"[",
... | [
13,
0
] | [
26,
69
] | python | en | ['en', 'error', 'th'] | False |
rand | (x_bounds, x_types, lowerbound, upperbound, max_retries=100) |
Key idea is that we try to move towards upperbound, by randomly choose one
value for each parameter. However, for the last parameter,
we need to make sure that its value can help us get above lowerbound
|
Key idea is that we try to move towards upperbound, by randomly choose one
value for each parameter. However, for the last parameter,
we need to make sure that its value can help us get above lowerbound
| def rand(x_bounds, x_types, lowerbound, upperbound, max_retries=100):
'''
Key idea is that we try to move towards upperbound, by randomly choose one
value for each parameter. However, for the last parameter,
we need to make sure that its value can help us get above lowerbound
'''
outputs = None
... | [
"def",
"rand",
"(",
"x_bounds",
",",
"x_types",
",",
"lowerbound",
",",
"upperbound",
",",
"max_retries",
"=",
"100",
")",
":",
"outputs",
"=",
"None",
"if",
"check_feasibility",
"(",
"x_bounds",
",",
"lowerbound",
",",
"upperbound",
")",
"is",
"True",
":"... | [
29,
0
] | [
107,
18
] | python | en | ['en', 'error', 'th'] | False |
services_to_strings | (services, service_to_string) | Convert SUPPORT_* service bitmask to list of service strings. | Convert SUPPORT_* service bitmask to list of service strings. | def services_to_strings(services, service_to_string):
"""Convert SUPPORT_* service bitmask to list of service strings."""
strings = []
for service in service_to_string:
if service & services:
strings.append(service_to_string[service])
return strings | [
"def",
"services_to_strings",
"(",
"services",
",",
"service_to_string",
")",
":",
"strings",
"=",
"[",
"]",
"for",
"service",
"in",
"service_to_string",
":",
"if",
"service",
"&",
"services",
":",
"strings",
".",
"append",
"(",
"service_to_string",
"[",
"serv... | [
16,
0
] | [
22,
18
] | python | en | ['en', 'en', 'en'] | True |
strings_to_services | (strings, string_to_service) | Convert service strings to SUPPORT_* service bitmask. | Convert service strings to SUPPORT_* service bitmask. | def strings_to_services(strings, string_to_service):
"""Convert service strings to SUPPORT_* service bitmask."""
services = 0
for string in strings:
services |= string_to_service[string]
return services | [
"def",
"strings_to_services",
"(",
"strings",
",",
"string_to_service",
")",
":",
"services",
"=",
"0",
"for",
"string",
"in",
"strings",
":",
"services",
"|=",
"string_to_service",
"[",
"string",
"]",
"return",
"services"
] | [
25,
0
] | [
30,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the VeSync component. | Set up the VeSync component. | async def async_setup(hass, config):
"""Set up the VeSync component."""
conf = config.get(DOMAIN)
if conf is None:
return True
if not configured_instances(hass):
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"s... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"if",
"conf",
"is",
"None",
":",
"return",
"True",
"if",
"not",
"configured_instances",
"(",
"hass",
")",
":",
"hass",
".",
"a... | [
41,
0
] | [
60,
15
] | python | en | ['en', 'ca', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up Vesync as config entry. | Set up Vesync as config entry. | async def async_setup_entry(hass, config_entry):
"""Set up Vesync as config entry."""
username = config_entry.data[CONF_USERNAME]
password = config_entry.data[CONF_PASSWORD]
time_zone = str(hass.config.time_zone)
manager = VeSync(username, password, time_zone)
login = await hass.async_add_exe... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"username",
"=",
"config_entry",
".",
"data",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"config_entry",
".",
"data",
"[",
"CONF_PASSWORD",
"]",
"time_zone",
"=",
"str",
"(",
"... | [
63,
0
] | [
132,
15
] | python | en | ['en', 'es', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)
if unload_ok:
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"component",
")",
... | [
135,
0
] | [
148,
20
] | python | en | ['en', 'es', 'en'] | True |
is_loopback | (address: Union[IPv4Address, IPv6Address]) | Check if an address is a loopback address. | Check if an address is a loopback address. | def is_loopback(address: Union[IPv4Address, IPv6Address]) -> bool:
"""Check if an address is a loopback address."""
return any(address in network for network in LOOPBACK_NETWORKS) | [
"def",
"is_loopback",
"(",
"address",
":",
"Union",
"[",
"IPv4Address",
",",
"IPv6Address",
"]",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"address",
"in",
"network",
"for",
"network",
"in",
"LOOPBACK_NETWORKS",
")"
] | [
25,
0
] | [
27,
67
] | python | en | ['en', 'en', 'en'] | True |
is_private | (address: Union[IPv4Address, IPv6Address]) | Check if an address is a private address. | Check if an address is a private address. | def is_private(address: Union[IPv4Address, IPv6Address]) -> bool:
"""Check if an address is a private address."""
return any(address in network for network in PRIVATE_NETWORKS) | [
"def",
"is_private",
"(",
"address",
":",
"Union",
"[",
"IPv4Address",
",",
"IPv6Address",
"]",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"address",
"in",
"network",
"for",
"network",
"in",
"PRIVATE_NETWORKS",
")"
] | [
30,
0
] | [
32,
66
] | python | en | ['en', 'en', 'en'] | True |
is_link_local | (address: Union[IPv4Address, IPv6Address]) | Check if an address is link local. | Check if an address is link local. | def is_link_local(address: Union[IPv4Address, IPv6Address]) -> bool:
"""Check if an address is link local."""
return address in LINK_LOCAL_NETWORK | [
"def",
"is_link_local",
"(",
"address",
":",
"Union",
"[",
"IPv4Address",
",",
"IPv6Address",
"]",
")",
"->",
"bool",
":",
"return",
"address",
"in",
"LINK_LOCAL_NETWORK"
] | [
35,
0
] | [
37,
40
] | python | en | ['en', 'en', 'en'] | True |
is_local | (address: Union[IPv4Address, IPv6Address]) | Check if an address is loopback or private. | Check if an address is loopback or private. | def is_local(address: Union[IPv4Address, IPv6Address]) -> bool:
"""Check if an address is loopback or private."""
return is_loopback(address) or is_private(address) | [
"def",
"is_local",
"(",
"address",
":",
"Union",
"[",
"IPv4Address",
",",
"IPv6Address",
"]",
")",
"->",
"bool",
":",
"return",
"is_loopback",
"(",
"address",
")",
"or",
"is_private",
"(",
"address",
")"
] | [
40,
0
] | [
42,
54
] | python | en | ['en', 'en', 'en'] | True |
is_ip_address | (address: str) | Check if a given string is an IP address. | Check if a given string is an IP address. | def is_ip_address(address: str) -> bool:
"""Check if a given string is an IP address."""
try:
ip_address(address)
except ValueError:
return False
return True | [
"def",
"is_ip_address",
"(",
"address",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"ip_address",
"(",
"address",
")",
"except",
"ValueError",
":",
"return",
"False",
"return",
"True"
] | [
45,
0
] | [
52,
15
] | python | en | ['en', 'en', 'en'] | True |
normalize_url | (address: str) | Normalize a given URL. | Normalize a given URL. | def normalize_url(address: str) -> str:
"""Normalize a given URL."""
url = yarl.URL(address.rstrip("/"))
if url.is_default_port():
return str(url.with_port(None))
return str(url) | [
"def",
"normalize_url",
"(",
"address",
":",
"str",
")",
"->",
"str",
":",
"url",
"=",
"yarl",
".",
"URL",
"(",
"address",
".",
"rstrip",
"(",
"\"/\"",
")",
")",
"if",
"url",
".",
"is_default_port",
"(",
")",
":",
"return",
"str",
"(",
"url",
".",
... | [
55,
0
] | [
60,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Safe Mode component. | Set up the Safe Mode component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Safe Mode component."""
persistent_notification.async_create(
hass,
"Home Assistant is running in safe mode. Check [the error log](/config/logs) to see what went wrong.",
"Safe Mode",
)
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"persistent_notification",
".",
"async_create",
"(",
"hass",
",",
"\"Home Assistant is running in safe mode. Check [the error log](/config/logs) to see what went wrong.\"",
... | [
7,
0
] | [
14,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Plex media_player from a config entry. | Set up Plex media_player from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Plex media_player from a config entry."""
server_id = config_entry.data[CONF_SERVER_IDENTIFIER]
registry = await async_get_registry(hass)
@callback
def async_new_media_players(new_entities):
_async_add_entities(
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"server_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_SERVER_IDENTIFIER",
"]",
"registry",
"=",
"await",
"async_get_registry",
"(",
"hass",
")",
"@",
... | [
53,
0
] | [
68,
48
] | python | en | ['en', 'en', 'en'] | True |
_async_add_entities | (
hass, registry, config_entry, async_add_entities, server_id, new_entities
) | Set up Plex media_player entities. | Set up Plex media_player entities. | def _async_add_entities(
hass, registry, config_entry, async_add_entities, server_id, new_entities
):
"""Set up Plex media_player entities."""
_LOGGER.debug("New entities: %s", new_entities)
entities = []
plexserver = hass.data[PLEX_DOMAIN][SERVERS][server_id]
for entity_params in new_entities:
... | [
"def",
"_async_add_entities",
"(",
"hass",
",",
"registry",
",",
"config_entry",
",",
"async_add_entities",
",",
"server_id",
",",
"new_entities",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"New entities: %s\"",
",",
"new_entities",
")",
"entities",
"=",
"[",
"]"... | [
72,
0
] | [
96,
38
] | python | en | ['en', 'lv', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.