Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_discover_bad_tag | (hass, device_reg, entity_reg, mqtt_mock, tag_mock) | Test bad discovery message. | Test bad discovery message. | async def test_discover_bad_tag(hass, device_reg, entity_reg, mqtt_mock, tag_mock):
"""Test bad discovery message."""
config1 = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
# Test sending bad data
data0 = '{ "device":{"identifiers":["0AFFD2"]}, "topics": "foobar/tag_scanned" }'
async_fire_mqtt_message(hass... | [
"async",
"def",
"test_discover_bad_tag",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config1",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_DEVICE",
")",
"# Test sending bad data",
"data0",
"=",
"'{ \"devi... | [
58,
0
] | [
76,
74
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_mqtt_message_with_device | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning, with device. | Test tag scanning, with device. | async def test_if_fires_on_mqtt_message_with_device(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning, with device."""
config = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_mqtt_message_with_device",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_DEVICE",
")",
"async_fire_mqtt_message",
"(",
"hass",
",",
"\"homea... | [
79,
0
] | [
92,
74
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_mqtt_message_without_device | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning, without device. | Test tag scanning, without device. | async def test_if_fires_on_mqtt_message_without_device(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning, without device."""
config = copy.deepcopy(DEFAULT_CONFIG)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_mqtt_message_without_device",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"async_fire_mqtt_message",
"(",
"hass",
",",
"\"homeassis... | [
95,
0
] | [
107,
63
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_mqtt_message_with_template | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning, with device. | Test tag scanning, with device. | async def test_if_fires_on_mqtt_message_with_template(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning, with device."""
config = copy.deepcopy(DEFAULT_CONFIG_JSON)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_mqtt_message_with_template",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_JSON",
")",
"async_fire_mqtt_message",
"(",
"hass",
",",
"\"homea... | [
110,
0
] | [
123,
74
] | python | en | ['en', 'en', 'en'] | True |
test_strip_tag_id | (hass, device_reg, mqtt_mock, tag_mock) | Test strip whitespace from tag_id. | Test strip whitespace from tag_id. | async def test_strip_tag_id(hass, device_reg, mqtt_mock, tag_mock):
"""Test strip whitespace from tag_id."""
config = copy.deepcopy(DEFAULT_CONFIG)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await hass.async_block_till_done()
# Fake tag scan.
async_fire_... | [
"async",
"def",
"test_strip_tag_id",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"async_fire_mqtt_message",
"(",
"hass",
",",
"\"homeassistant/tag/bla1/config\"",
... | [
126,
0
] | [
136,
57
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_mqtt_message_after_update_with_device | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning after update. | Test tag scanning after update. | async def test_if_fires_on_mqtt_message_after_update_with_device(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning after update."""
config1 = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
config2 = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
config2["topic"] = "foobar/tag_scanned2"
async_fire_mqtt... | [
"async",
"def",
"test_if_fires_on_mqtt_message_after_update_with_device",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config1",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_DEVICE",
")",
"config2",
"=",
"copy",
".",
"deepcopy"... | [
139,
0
] | [
180,
74
] | python | en | ['da', 'en', 'en'] | True |
test_if_fires_on_mqtt_message_after_update_without_device | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning after update. | Test tag scanning after update. | async def test_if_fires_on_mqtt_message_after_update_without_device(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning after update."""
config1 = copy.deepcopy(DEFAULT_CONFIG)
config2 = copy.deepcopy(DEFAULT_CONFIG)
config2["topic"] = "foobar/tag_scanned2"
async_fire_mqtt_message(ha... | [
"async",
"def",
"test_if_fires_on_mqtt_message_after_update_without_device",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config1",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"config2",
"=",
"copy",
".",
"deepcopy",
... | [
183,
0
] | [
223,
63
] | python | en | ['da', 'en', 'en'] | True |
test_if_fires_on_mqtt_message_after_update_with_template | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning after update. | Test tag scanning after update. | async def test_if_fires_on_mqtt_message_after_update_with_template(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning after update."""
config1 = copy.deepcopy(DEFAULT_CONFIG_JSON)
config2 = copy.deepcopy(DEFAULT_CONFIG_JSON)
config2["value_template"] = "{{ value_json.RDM6300.UID }}"
... | [
"async",
"def",
"test_if_fires_on_mqtt_message_after_update_with_template",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config1",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_JSON",
")",
"config2",
"=",
"copy",
".",
"deepcopy"... | [
226,
0
] | [
268,
74
] | python | en | ['da', 'en', 'en'] | True |
test_no_resubscribe_same_topic | (hass, device_reg, mqtt_mock) | Test subscription to topics without change. | Test subscription to topics without change. | async def test_no_resubscribe_same_topic(hass, device_reg, mqtt_mock):
"""Test subscription to topics without change."""
config = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await hass.async_block_till_done()
assert device_... | [
"async",
"def",
"test_no_resubscribe_same_topic",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_DEVICE",
")",
"async_fire_mqtt_message",
"(",
"hass",
",",
"\"homeassistant/tag/bla1/config\"",
"... | [
271,
0
] | [
282,
61
] | python | en | ['en', 'en', 'en'] | True |
test_not_fires_on_mqtt_message_after_remove_by_mqtt_with_device | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning after removal. | Test tag scanning after removal. | async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_with_device(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning after removal."""
config = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await hass.asyn... | [
"async",
"def",
"test_not_fires_on_mqtt_message_after_remove_by_mqtt_with_device",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_DEVICE",
")",
"async_fire_mqtt_message",
"(",
"ha... | [
285,
0
] | [
315,
74
] | python | en | ['da', 'en', 'en'] | True |
test_not_fires_on_mqtt_message_after_remove_by_mqtt_without_device | (
hass, device_reg, mqtt_mock, tag_mock
) | Test tag scanning not firing after removal. | Test tag scanning not firing after removal. | async def test_not_fires_on_mqtt_message_after_remove_by_mqtt_without_device(
hass, device_reg, mqtt_mock, tag_mock
):
"""Test tag scanning not firing after removal."""
config = copy.deepcopy(DEFAULT_CONFIG)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await ha... | [
"async",
"def",
"test_not_fires_on_mqtt_message_after_remove_by_mqtt_without_device",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG",
")",
"async_fire_mqtt_message",
"(",
"hass",... | [
318,
0
] | [
347,
63
] | python | en | ['en', 'en', 'en'] | True |
test_not_fires_on_mqtt_message_after_remove_from_registry | (
hass,
device_reg,
mqtt_mock,
tag_mock,
) | Test tag scanning after removal. | Test tag scanning after removal. | async def test_not_fires_on_mqtt_message_after_remove_from_registry(
hass,
device_reg,
mqtt_mock,
tag_mock,
):
"""Test tag scanning after removal."""
config = copy.deepcopy(DEFAULT_CONFIG_DEVICE)
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", json.dumps(config))
await ha... | [
"async",
"def",
"test_not_fires_on_mqtt_message_after_remove_from_registry",
"(",
"hass",
",",
"device_reg",
",",
"mqtt_mock",
",",
"tag_mock",
",",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_CONFIG_DEVICE",
")",
"async_fire_mqtt_message",
"(",
"h... | [
350,
0
] | [
375,
32
] | python | en | ['da', 'en', 'en'] | True |
test_entity_device_info_with_connection | (hass, mqtt_mock) | Test MQTT device registry integration. | Test MQTT device registry integration. | async def test_entity_device_info_with_connection(hass, mqtt_mock):
"""Test MQTT device registry integration."""
registry = await hass.helpers.device_registry.async_get_registry()
data = json.dumps(
{
"topic": "test-topic",
"device": {
"connections": [["mac",... | [
"async",
"def",
"test_entity_device_info_with_connection",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"t... | [
378,
0
] | [
403,
42
] | python | en | ['en', 'sv', 'en'] | True |
test_entity_device_info_with_identifier | (hass, mqtt_mock) | Test MQTT device registry integration. | Test MQTT device registry integration. | async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT device registry integration."""
registry = await hass.helpers.device_registry.async_get_registry()
data = json.dumps(
{
"topic": "test-topic",
"device": {
"identifiers": ["hellow... | [
"async",
"def",
"test_entity_device_info_with_identifier",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"t... | [
406,
0
] | [
431,
42
] | python | en | ['en', 'sv', 'en'] | True |
test_entity_device_info_update | (hass, mqtt_mock) | Test device registry update. | Test device registry update. | async def test_entity_device_info_update(hass, mqtt_mock):
"""Test device registry update."""
registry = await hass.helpers.device_registry.async_get_registry()
config = {
"topic": "test-topic",
"device": {
"identifiers": ["helloworld"],
"connections": [["mac", "02:5... | [
"async",
"def",
"test_entity_device_info_update",
"(",
"hass",
",",
"mqtt_mock",
")",
":",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"config",
"=",
"{",
"\"topic\"",
":",
"\"test-topic\"",
",",... | [
434,
0
] | [
465,
32
] | python | en | ['fr', 'fy', 'en'] | False |
test_cleanup_tag | (hass, device_reg, entity_reg, mqtt_mock) | Test tag discovery topic is cleaned when device is removed from registry. | Test tag discovery topic is cleaned when device is removed from registry. | async def test_cleanup_tag(hass, device_reg, entity_reg, mqtt_mock):
"""Test tag discovery topic is cleaned when device is removed from registry."""
config = {
"topic": "test-topic",
"device": {"identifiers": ["helloworld"]},
}
data = json.dumps(config)
async_fire_mqtt_message(hass,... | [
"async",
"def",
"test_cleanup_tag",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config",
"=",
"{",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"device\"",
":",
"{",
"\"identifiers\"",
":",
"[",
"\"helloworld\"",
"]",
"}",
"... | [
468,
0
] | [
494,
5
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device | (hass, device_reg, entity_reg, mqtt_mock) | Test removal from device registry when tag is removed. | Test removal from device registry when tag is removed. | async def test_cleanup_device(hass, device_reg, entity_reg, mqtt_mock):
"""Test removal from device registry when tag is removed."""
config = {
"topic": "test-topic",
"device": {"identifiers": ["helloworld"]},
}
data = json.dumps(config)
async_fire_mqtt_message(hass, "homeassistant/... | [
"async",
"def",
"test_cleanup_device",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config",
"=",
"{",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"device\"",
":",
"{",
"\"identifiers\"",
":",
"[",
"\"helloworld\"",
"]",
"}",
... | [
497,
0
] | [
517,
31
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device_several_tags | (
hass, device_reg, entity_reg, mqtt_mock, tag_mock
) | Test removal from device registry when the last tag is removed. | Test removal from device registry when the last tag is removed. | async def test_cleanup_device_several_tags(
hass, device_reg, entity_reg, mqtt_mock, tag_mock
):
"""Test removal from device registry when the last tag is removed."""
config1 = {
"topic": "test-topic1",
"device": {"identifiers": ["helloworld"]},
}
config2 = {
"topic": "test-... | [
"async",
"def",
"test_cleanup_device_several_tags",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
",",
"tag_mock",
")",
":",
"config1",
"=",
"{",
"\"topic\"",
":",
"\"test-topic1\"",
",",
"\"device\"",
":",
"{",
"\"identifiers\"",
":",
"["... | [
520,
0
] | [
561,
31
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device_with_entity_and_trigger_1 | (
hass, device_reg, entity_reg, mqtt_mock
) | Test removal from device registry for device with tag, entity and trigger.
Tag removed first, then trigger and entity.
| Test removal from device registry for device with tag, entity and trigger. | async def test_cleanup_device_with_entity_and_trigger_1(
hass, device_reg, entity_reg, mqtt_mock
):
"""Test removal from device registry for device with tag, entity and trigger.
Tag removed first, then trigger and entity.
"""
config1 = {
"topic": "test-topic",
"device": {"identifier... | [
"async",
"def",
"test_cleanup_device_with_entity_and_trigger_1",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config1",
"=",
"{",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"device\"",
":",
"{",
"\"identifiers\"",
":",
"[",
"\"he... | [
564,
0
] | [
623,
31
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device_with_entity2 | (hass, device_reg, entity_reg, mqtt_mock) | Test removal from device registry for device with tag, entity and trigger.
Trigger and entity removed first, then tag.
| Test removal from device registry for device with tag, entity and trigger. | async def test_cleanup_device_with_entity2(hass, device_reg, entity_reg, mqtt_mock):
"""Test removal from device registry for device with tag, entity and trigger.
Trigger and entity removed first, then tag.
"""
config1 = {
"topic": "test-topic",
"device": {"identifiers": ["helloworld"]}... | [
"async",
"def",
"test_cleanup_device_with_entity2",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
",",
"mqtt_mock",
")",
":",
"config1",
"=",
"{",
"\"topic\"",
":",
"\"test-topic\"",
",",
"\"device\"",
":",
"{",
"\"identifiers\"",
":",
"[",
"\"helloworld\"",
... | [
626,
0
] | [
683,
31
] | python | en | ['en', 'en', 'en'] | True |
async_is_onboarded | (hass) | Return if Home Assistant has been onboarded. | Return if Home Assistant has been onboarded. | def async_is_onboarded(hass):
"""Return if Home Assistant has been onboarded."""
data = hass.data.get(DOMAIN)
return data is None or data is True | [
"def",
"async_is_onboarded",
"(",
"hass",
")",
":",
"data",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DOMAIN",
")",
"return",
"data",
"is",
"None",
"or",
"data",
"is",
"True"
] | [
27,
0
] | [
30,
39
] | python | en | ['en', 'en', 'en'] | True |
async_is_user_onboarded | (hass) | Return if a user has been created as part of onboarding. | Return if a user has been created as part of onboarding. | def async_is_user_onboarded(hass):
"""Return if a user has been created as part of onboarding."""
return async_is_onboarded(hass) or STEP_USER in hass.data[DOMAIN]["done"] | [
"def",
"async_is_user_onboarded",
"(",
"hass",
")",
":",
"return",
"async_is_onboarded",
"(",
"hass",
")",
"or",
"STEP_USER",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"done\"",
"]"
] | [
35,
0
] | [
37,
77
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the onboarding component. | Set up the onboarding component. | async def async_setup(hass, config):
"""Set up the onboarding component."""
store = OnboadingStorage(hass, STORAGE_VERSION, STORAGE_KEY, private=True)
data = await store.async_load()
if data is None:
data = {"done": []}
if STEP_USER not in data["done"]:
# Users can already have cre... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"store",
"=",
"OnboadingStorage",
"(",
"hass",
",",
"STORAGE_VERSION",
",",
"STORAGE_KEY",
",",
"private",
"=",
"True",
")",
"data",
"=",
"await",
"store",
".",
"async_load",
"(",
")",
... | [
40,
0
] | [
69,
15
] | python | en | ['en', 'en', 'en'] | True |
OnboadingStorage._async_migrate_func | (self, old_version, old_data) | Migrate to the new version. | Migrate to the new version. | async def _async_migrate_func(self, old_version, old_data):
"""Migrate to the new version."""
# From version 1 -> 2, we automatically mark the integration step done
if old_version < 2:
old_data["done"].append(STEP_INTEGRATION)
if old_version < 3:
old_data["done"].... | [
"async",
"def",
"_async_migrate_func",
"(",
"self",
",",
"old_version",
",",
"old_data",
")",
":",
"# From version 1 -> 2, we automatically mark the integration step done",
"if",
"old_version",
"<",
"2",
":",
"old_data",
"[",
"\"done\"",
"]",
".",
"append",
"(",
"STEP... | [
15,
4
] | [
22,
23
] | python | en | ['en', 'en', 'en'] | True |
hans_convert_examples_to_features | (
examples: List[InputExample],
label_list: List[str],
max_length: int,
tokenizer: PreTrainedTokenizer,
) |
Loads a data file into a list of ``InputFeatures``
Args:
examples: List of ``InputExamples`` containing the examples.
label_list: List of labels. Can be obtained from the processor using the ``processor.get_labels()`` method.
max_length: Maximum example length.
tokenizer: Insta... |
Loads a data file into a list of ``InputFeatures`` | def hans_convert_examples_to_features(
examples: List[InputExample],
label_list: List[str],
max_length: int,
tokenizer: PreTrainedTokenizer,
):
"""
Loads a data file into a list of ``InputFeatures``
Args:
examples: List of ``InputExamples`` containing the examples.
label_lis... | [
"def",
"hans_convert_examples_to_features",
"(",
"examples",
":",
"List",
"[",
"InputExample",
"]",
",",
"label_list",
":",
"List",
"[",
"str",
"]",
",",
"max_length",
":",
"int",
",",
"tokenizer",
":",
"PreTrainedTokenizer",
",",
")",
":",
"label_map",
"=",
... | [
282,
0
] | [
330,
19
] | python | en | ['en', 'error', 'th'] | False |
HansProcessor.get_train_examples | (self, data_dir) | See base class. | See base class. | def get_train_examples(self, data_dir):
"""See base class."""
return self._create_examples(self._read_tsv(os.path.join(data_dir, "heuristics_train_set.txt")), "train") | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_tsv",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"heuristics_train_set.txt\"",
")",
")",
",",
"\"train\... | [
251,
4
] | [
253,
113
] | python | en | ['en', 'en', 'en'] | True |
HansProcessor.get_dev_examples | (self, data_dir) | See base class. | See base class. | def get_dev_examples(self, data_dir):
"""See base class."""
return self._create_examples(self._read_tsv(os.path.join(data_dir, "heuristics_evaluation_set.txt")), "dev") | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_tsv",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"heuristics_evaluation_set.txt\"",
")",
")",
",",
"\"dev... | [
255,
4
] | [
257,
116
] | python | en | ['en', 'en', 'en'] | True |
HansProcessor.get_labels | (self) | See base class.
Note that we follow the standard three labels for MNLI
(see :class:`~transformers.data.processors.utils.MnliProcessor`)
but the HANS evaluation groups `contradiction` and `neutral` into `non-entailment` (label 0) while
`entailment` is label 1. | See base class.
Note that we follow the standard three labels for MNLI
(see :class:`~transformers.data.processors.utils.MnliProcessor`)
but the HANS evaluation groups `contradiction` and `neutral` into `non-entailment` (label 0) while
`entailment` is label 1. | def get_labels(self):
"""See base class.
Note that we follow the standard three labels for MNLI
(see :class:`~transformers.data.processors.utils.MnliProcessor`)
but the HANS evaluation groups `contradiction` and `neutral` into `non-entailment` (label 0) while
`entailment` is labe... | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"\"contradiction\"",
",",
"\"entailment\"",
",",
"\"neutral\"",
"]"
] | [
259,
4
] | [
265,
57
] | python | en | ['en', 'en', 'en'] | True |
HansProcessor._create_examples | (self, lines, set_type) | Creates examples for the training and dev sets. | Creates examples for the training and dev sets. | def _create_examples(self, lines, set_type):
"""Creates examples for the training and dev sets."""
examples = []
for (i, line) in enumerate(lines):
if i == 0:
continue
guid = "%s-%s" % (set_type, line[0])
text_a = line[5]
text_b = l... | [
"def",
"_create_examples",
"(",
"self",
",",
"lines",
",",
"set_type",
")",
":",
"examples",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"line",
")",
"in",
"enumerate",
"(",
"lines",
")",
":",
"if",
"i",
"==",
"0",
":",
"continue",
"guid",
"=",
"\"%s-%s\"... | [
267,
4
] | [
279,
23
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up an InComfort/InTouch binary_sensor device. | Set up an InComfort/InTouch binary_sensor device. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up an InComfort/InTouch binary_sensor device."""
if discovery_info is None:
return
client = hass.data[DOMAIN]["client"]
heaters = hass.data[DOMAIN]["heaters"]
async_add_entities([IncomfortFailed(c... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"... | [
11,
0
] | [
19,
69
] | python | en | ['en', 'en', 'en'] | True |
IncomfortFailed.__init__ | (self, client, heater) | Initialize the binary sensor. | Initialize the binary sensor. | def __init__(self, client, heater) -> None:
"""Initialize the binary sensor."""
super().__init__()
self._unique_id = f"{heater.serial_no}_failed"
self.entity_id = f"{BINARY_SENSOR_DOMAIN}.{DOMAIN}_failed"
self._name = "Boiler Fault"
self._client = client
self._h... | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"heater",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_unique_id",
"=",
"f\"{heater.serial_no}_failed\"",
"self",
".",
"entity_id",
"=",
"f\"{BINARY_SENSOR_DOMAIN}.{DOM... | [
25,
4
] | [
34,
29
] | python | en | ['en', 'haw', 'en'] | True |
IncomfortFailed.is_on | (self) | Return the status of the sensor. | Return the status of the sensor. | def is_on(self) -> bool:
"""Return the status of the sensor."""
return self._heater.status["is_failed"] | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_heater",
".",
"status",
"[",
"\"is_failed\"",
"]"
] | [
37,
4
] | [
39,
47
] | python | en | ['en', 'id', 'en'] | True |
IncomfortFailed.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the device state attributes."""
return {"fault_code": self._heater.status["fault_code"]} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"{",
"\"fault_code\"",
":",
"self",
".",
"_heater",
".",
"status",
"[",
"\"fault_code\"",
"]",
"}"
] | [
42,
4
] | [
44,
64
] | python | en | ['en', 'en', 'en'] | True |
test_init_entry | (hass, generic_data) | Test setting up config entry. | Test setting up config entry. | async def test_init_entry(hass, generic_data):
"""Test setting up config entry."""
await setup_ozw(hass, fixture=generic_data)
# Verify integration + platform loaded.
assert "ozw" in hass.config.components
for platform in PLATFORMS:
assert platform in hass.config.components, platform
... | [
"async",
"def",
"test_init_entry",
"(",
"hass",
",",
"generic_data",
")",
":",
"await",
"setup_ozw",
"(",
"hass",
",",
"fixture",
"=",
"generic_data",
")",
"# Verify integration + platform loaded.",
"assert",
"\"ozw\"",
"in",
"hass",
".",
"config",
".",
"component... | [
10,
0
] | [
22,
71
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass, generic_data, switch_msg, caplog) | Test unload the config entry. | Test unload the config entry. | async def test_unload_entry(hass, generic_data, switch_msg, caplog):
"""Test unload the config entry."""
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
)
entry.add_to_hass(hass)
assert entry.state == config_entri... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
",",
"generic_data",
",",
"switch_msg",
",",
"caplog",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"Z-Wave\"",
",",
"connection_class",
"=",
"config_entries",
"... | [
25,
0
] | [
62,
42
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry | (hass, stop_addon, uninstall_addon, caplog) | Test remove the config entry. | Test remove the config entry. | async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
"""Test remove the config entry."""
# test successful remove without created add-on
entry = MockConfigEntry(
domain=DOMAIN,
title="Z-Wave",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
data={"in... | [
"async",
"def",
"test_remove_entry",
"(",
"hass",
",",
"stop_addon",
",",
"uninstall_addon",
",",
"caplog",
")",
":",
"# test successful remove without created add-on",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"Z-Wave\"",
"... | [
65,
0
] | [
129,
68
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set the tankerkoenig component up. | Set the tankerkoenig component up. | async def async_setup(hass, config):
"""Set the tankerkoenig component up."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
_LOGGER.debug("Setting up integration")
tankerkoenig = TankerkoenigData(hass, conf)
latitude = conf.get(CONF_LATITUDE, hass.config.latitude)
lo... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"_LOGGER",
".",
"debug",
"(",
"\"Setting up integration\"",
")",
"tankerkoenig",
"... | [
63,
0
] | [
98,
15
] | python | en | ['en', 'da', 'en'] | True |
TankerkoenigData.__init__ | (self, hass, conf) | Initialize the data object. | Initialize the data object. | def __init__(self, hass, conf):
"""Initialize the data object."""
self._api_key = conf[CONF_API_KEY]
self.stations = {}
self.fuel_types = conf[CONF_FUEL_TYPES]
self.update_interval = conf[CONF_SCAN_INTERVAL]
self.show_on_map = conf[CONF_SHOW_ON_MAP]
self._hass = h... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"conf",
")",
":",
"self",
".",
"_api_key",
"=",
"conf",
"[",
"CONF_API_KEY",
"]",
"self",
".",
"stations",
"=",
"{",
"}",
"self",
".",
"fuel_types",
"=",
"conf",
"[",
"CONF_FUEL_TYPES",
"]",
"self",
"... | [
104,
4
] | [
111,
25
] | python | en | ['en', 'en', 'en'] | True |
TankerkoenigData.setup | (self, latitude, longitude, radius, additional_stations) | Set up the tankerkoenig API.
Read the initial data from the server, to initialize the list of fuel stations to monitor.
| Set up the tankerkoenig API. | def setup(self, latitude, longitude, radius, additional_stations):
"""Set up the tankerkoenig API.
Read the initial data from the server, to initialize the list of fuel stations to monitor.
"""
_LOGGER.debug("Fetching data for (%s, %s) rad: %s", latitude, longitude, radius)
try:... | [
"def",
"setup",
"(",
"self",
",",
"latitude",
",",
"longitude",
",",
"radius",
",",
"additional_stations",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Fetching data for (%s, %s) rad: %s\"",
",",
"latitude",
",",
"longitude",
",",
"radius",
")",
"try",
":",
"dat... | [
113,
4
] | [
176,
19
] | python | en | ['en', 'da', 'en'] | True |
TankerkoenigData.fetch_data | (self) | Get the latest data from tankerkoenig.de. | Get the latest data from tankerkoenig.de. | async def fetch_data(self):
"""Get the latest data from tankerkoenig.de."""
_LOGGER.debug("Fetching new data from tankerkoenig.de")
station_ids = list(self.stations)
prices = {}
# The API seems to only return at most 10 results, so split the list in chunks of 10
# and m... | [
"async",
"def",
"fetch_data",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Fetching new data from tankerkoenig.de\"",
")",
"station_ids",
"=",
"list",
"(",
"self",
".",
"stations",
")",
"prices",
"=",
"{",
"}",
"# The API seems to only return at most 10 r... | [
178,
4
] | [
204,
21
] | python | en | ['en', 'nl', 'en'] | True |
TankerkoenigData.add_station | (self, station: dict) | Add fuel station to the entity list. | Add fuel station to the entity list. | def add_station(self, station: dict):
"""Add fuel station to the entity list."""
station_id = station["id"]
if station_id in self.stations:
_LOGGER.warning(
"Sensor for station with id %s was already created", station_id
)
return
self.... | [
"def",
"add_station",
"(",
"self",
",",
"station",
":",
"dict",
")",
":",
"station_id",
"=",
"station",
"[",
"\"id\"",
"]",
"if",
"station_id",
"in",
"self",
".",
"stations",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Sensor for station with id %s was already creat... | [
206,
4
] | [
216,
68
] | python | en | ['en', 'en', 'en'] | True |
Speech2TextTokenizer.set_tgt_lang_special_tokens | (self, tgt_lang: str) | Reset the special tokens to the target language setting. prefix=[eos, tgt_lang_code] and suffix=[eos]. | Reset the special tokens to the target language setting. prefix=[eos, tgt_lang_code] and suffix=[eos]. | def set_tgt_lang_special_tokens(self, tgt_lang: str) -> None:
"""Reset the special tokens to the target language setting. prefix=[eos, tgt_lang_code] and suffix=[eos]."""
lang_code_id = self.lang_code_to_id[tgt_lang]
self.prefix_tokens = [lang_code_id] | [
"def",
"set_tgt_lang_special_tokens",
"(",
"self",
",",
"tgt_lang",
":",
"str",
")",
"->",
"None",
":",
"lang_code_id",
"=",
"self",
".",
"lang_code_to_id",
"[",
"tgt_lang",
"]",
"self",
".",
"prefix_tokens",
"=",
"[",
"lang_code_id",
"]"
] | [
151,
4
] | [
154,
43
] | python | en | ['en', 'en', 'en'] | True |
Speech2TextTokenizer._convert_id_to_token | (self, index: int) | Converts an index (integer) in a token (str) using the decoder. | Converts an index (integer) in a token (str) using the decoder. | def _convert_id_to_token(self, index: int) -> str:
"""Converts an index (integer) in a token (str) using the decoder."""
return self.decoder.get(index, self.unk_token) | [
"def",
"_convert_id_to_token",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"return",
"self",
".",
"decoder",
".",
"get",
"(",
"index",
",",
"self",
".",
"unk_token",
")"
] | [
162,
4
] | [
164,
54
] | python | en | ['en', 'en', 'en'] | True |
Speech2TextTokenizer.convert_tokens_to_string | (self, tokens: List[str]) | Converts a sequence of tokens (strings for sub-words) in a single string. | Converts a sequence of tokens (strings for sub-words) in a single string. | def convert_tokens_to_string(self, tokens: List[str]) -> str:
"""Converts a sequence of tokens (strings for sub-words) in a single string."""
out_string = "".join(tokens).replace(SPIECE_UNDERLINE, " ").strip()
if self.do_upper_case:
out_string = out_string.upper()
return out... | [
"def",
"convert_tokens_to_string",
"(",
"self",
",",
"tokens",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"out_string",
"=",
"\"\"",
".",
"join",
"(",
"tokens",
")",
".",
"replace",
"(",
"SPIECE_UNDERLINE",
",",
"\" \"",
")",
".",
"strip",
"(... | [
166,
4
] | [
172,
25
] | python | en | ['en', 'en', 'en'] | True |
Speech2TextTokenizer.build_inputs_with_special_tokens | (self, token_ids_0, token_ids_1=None) | Build model inputs from a sequence by appending eos_token_id. | Build model inputs from a sequence by appending eos_token_id. | def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None) -> List[int]:
"""Build model inputs from a sequence by appending eos_token_id."""
if token_ids_1 is None:
return self.prefix_tokens + token_ids_0 + [self.eos_token_id]
# We don't expect to process pairs, but le... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
",",
"token_ids_1",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",
"token_ids_1",
"is",
"None",
":",
"return",
"self",
".",
"prefix_tokens",
"+",
"token_ids_0",
"+",
"["... | [
174,
4
] | [
179,
83
] | python | en | ['en', 'en', 'en'] | True |
Speech2TextTokenizer.get_special_tokens_mask | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:obj:`List[int]`,... |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method. | def get_special_tokens_mask(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens ... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
... | [
181,
4
] | [
211,
94
] | python | en | ['en', 'error', 'th'] | False |
test_creating_entry_sets_up_climate_discovery | (hass) | Test setting up Hisense AEH-W4A1 loads the climate component. | Test setting up Hisense AEH-W4A1 loads the climate component. | async def test_creating_entry_sets_up_climate_discovery(hass):
"""Test setting up Hisense AEH-W4A1 loads the climate component."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.discovery",
return_value=["1.2.3.4"],
):
with patch(
"homeassistant... | [
"async",
"def",
"test_creating_entry_sets_up_climate_discovery",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.discovery\"",
",",
"return_value",
"=",
"[",
"\"1.2.3.4\"",
"]",
",",
")",
":",
"with",
"patch",
"... | [
10,
0
] | [
34,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configuring_hisense_w4a1_create_entry | (hass) | Test that specifying config will create an entry. | Test that specifying config will create an entry. | async def test_configuring_hisense_w4a1_create_entry(hass):
"""Test that specifying config will create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check",
return_value=True,
):
with patch(
"homeassistant.components.hisense_aehw4a... | [
"async",
"def",
"test_configuring_hisense_w4a1_create_entry",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check\"",
",",
"return_value",
"=",
"True",
",",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.compo... | [
37,
0
] | [
54,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found | (hass) | Test that specifying config will not create an entry. | Test that specifying config will not create an entry. | async def test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found(hass):
"""Test that specifying config will not create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check",
side_effect=exceptions.ConnectionError,
):
with patch(
... | [
"async",
"def",
"test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check\"",
",",
"side_effect",
"=",
"exceptions",
".",
"ConnectionError",
",",
")",
... | [
57,
0
] | [
74,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configuring_hisense_w4a1_not_creates_entry_for_empty_import | (hass) | Test that specifying config will not create an entry. | Test that specifying config will not create an entry. | async def test_configuring_hisense_w4a1_not_creates_entry_for_empty_import(hass):
"""Test that specifying config will not create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.async_setup_entry",
return_value=True,
) as mock_setup:
await async_setup_component(hass... | [
"async",
"def",
"test_configuring_hisense_w4a1_not_creates_entry_for_empty_import",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.async_setup_entry\"",
",",
"return_value",
"=",
"True",
",",
")",
"as",
"mock_setup",
":",
"await",
"... | [
77,
0
] | [
86,
42
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the FFmpeg component. | Set up the FFmpeg component. | async def async_setup(hass, config):
"""Set up the FFmpeg component."""
conf = config.get(DOMAIN, {})
manager = FFmpegManager(hass, conf.get(CONF_FFMPEG_BIN, DEFAULT_BINARY))
await manager.async_get_version()
# Register service
async def async_service_handle(service):
"""Handle servic... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"manager",
"=",
"FFmpegManager",
"(",
"hass",
",",
"conf",
".",
"get",
"(",
"CONF_FFMPEG_BIN",
",",
"DEFAULT_BINA... | [
55,
0
] | [
88,
15
] | python | en | ['en', 'en', 'en'] | True |
async_get_image | (
hass: HomeAssistantType,
input_source: str,
output_format: str = IMAGE_JPEG,
extra_cmd: Optional[str] = None,
) | Get an image from a frame of an RTSP stream. | Get an image from a frame of an RTSP stream. | async def async_get_image(
hass: HomeAssistantType,
input_source: str,
output_format: str = IMAGE_JPEG,
extra_cmd: Optional[str] = None,
):
"""Get an image from a frame of an RTSP stream."""
manager = hass.data[DATA_FFMPEG]
ffmpeg = ImageFrame(manager.binary, loop=hass.loop)
image = awai... | [
"async",
"def",
"async_get_image",
"(",
"hass",
":",
"HomeAssistantType",
",",
"input_source",
":",
"str",
",",
"output_format",
":",
"str",
"=",
"IMAGE_JPEG",
",",
"extra_cmd",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
":",
"manager",
"=",
... | [
91,
0
] | [
103,
16
] | python | en | ['en', 'en', 'en'] | True |
FFmpegManager.__init__ | (self, hass, ffmpeg_bin) | Initialize helper. | Initialize helper. | def __init__(self, hass, ffmpeg_bin):
"""Initialize helper."""
self.hass = hass
self._cache = {}
self._bin = ffmpeg_bin
self._version = None
self._major_version = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"ffmpeg_bin",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_cache",
"=",
"{",
"}",
"self",
".",
"_bin",
"=",
"ffmpeg_bin",
"self",
".",
"_version",
"=",
"None",
"self",
".",
"_major_versi... | [
109,
4
] | [
115,
34
] | python | en | ['en', 'co', 'en'] | False |
FFmpegManager.binary | (self) | Return ffmpeg binary from config. | Return ffmpeg binary from config. | def binary(self):
"""Return ffmpeg binary from config."""
return self._bin | [
"def",
"binary",
"(",
"self",
")",
":",
"return",
"self",
".",
"_bin"
] | [
118,
4
] | [
120,
24
] | python | en | ['en', 'en', 'en'] | True |
FFmpegManager.async_get_version | (self) | Return ffmpeg version. | Return ffmpeg version. | async def async_get_version(self):
"""Return ffmpeg version."""
ffversion = FFVersion(self._bin, self.hass.loop)
self._version = await ffversion.get_version()
self._major_version = None
if self._version is not None:
result = re.search(r"(\d+)\.", self._version)
... | [
"async",
"def",
"async_get_version",
"(",
"self",
")",
":",
"ffversion",
"=",
"FFVersion",
"(",
"self",
".",
"_bin",
",",
"self",
".",
"hass",
".",
"loop",
")",
"self",
".",
"_version",
"=",
"await",
"ffversion",
".",
"get_version",
"(",
")",
"self",
"... | [
122,
4
] | [
134,
49
] | python | en | ['nl', 'is', 'en'] | False |
FFmpegManager.ffmpeg_stream_content_type | (self) | Return HTTP content type for ffmpeg stream. | Return HTTP content type for ffmpeg stream. | def ffmpeg_stream_content_type(self):
"""Return HTTP content type for ffmpeg stream."""
if self._major_version is not None and self._major_version > 3:
return CONTENT_TYPE_MULTIPART.format("ffmpeg")
return CONTENT_TYPE_MULTIPART.format("ffserver") | [
"def",
"ffmpeg_stream_content_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"_major_version",
"is",
"not",
"None",
"and",
"self",
".",
"_major_version",
">",
"3",
":",
"return",
"CONTENT_TYPE_MULTIPART",
".",
"format",
"(",
"\"ffmpeg\"",
")",
"return",
"CON... | [
137,
4
] | [
142,
56
] | python | en | ['no', 'en', 'en'] | True |
FFmpegBase.__init__ | (self, initial_state=True) | Initialize ffmpeg base object. | Initialize ffmpeg base object. | def __init__(self, initial_state=True):
"""Initialize ffmpeg base object."""
self.ffmpeg = None
self.initial_state = initial_state | [
"def",
"__init__",
"(",
"self",
",",
"initial_state",
"=",
"True",
")",
":",
"self",
".",
"ffmpeg",
"=",
"None",
"self",
".",
"initial_state",
"=",
"initial_state"
] | [
148,
4
] | [
151,
42
] | python | en | ['hu', 'en', 'it'] | False |
FFmpegBase.async_added_to_hass | (self) | Register dispatcher & events.
This method is a coroutine.
| Register dispatcher & events. | async def async_added_to_hass(self):
"""Register dispatcher & events.
This method is a coroutine.
"""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_FFMPEG_START, self._async_start_ffmpeg
)
)
self.async_on_remove... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_FFMPEG_START",
",",
"self",
".",
"_async_start_ffmpeg",
")",
")",
"self",
".",
"async_on_remove",
... | [
153,
4
] | [
175,
37
] | python | da | ['de', 'da', 'en'] | False |
FFmpegBase.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self.ffmpeg.is_running | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"ffmpeg",
".",
"is_running"
] | [
178,
4
] | [
180,
37
] | python | en | ['en', 'en', 'en'] | True |
FFmpegBase.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
183,
4
] | [
185,
20
] | python | en | ['en', 'en', 'en'] | True |
FFmpegBase._async_start_ffmpeg | (self, entity_ids) | Start a FFmpeg process.
This method is a coroutine.
| Start a FFmpeg process. | async def _async_start_ffmpeg(self, entity_ids):
"""Start a FFmpeg process.
This method is a coroutine.
"""
raise NotImplementedError() | [
"async",
"def",
"_async_start_ffmpeg",
"(",
"self",
",",
"entity_ids",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
187,
4
] | [
192,
35
] | python | en | ['hu', 'lb', 'en'] | False |
FFmpegBase._async_stop_ffmpeg | (self, entity_ids) | Stop a FFmpeg process.
This method is a coroutine.
| Stop a FFmpeg process. | async def _async_stop_ffmpeg(self, entity_ids):
"""Stop a FFmpeg process.
This method is a coroutine.
"""
if entity_ids is None or self.entity_id in entity_ids:
await self.ffmpeg.close() | [
"async",
"def",
"_async_stop_ffmpeg",
"(",
"self",
",",
"entity_ids",
")",
":",
"if",
"entity_ids",
"is",
"None",
"or",
"self",
".",
"entity_id",
"in",
"entity_ids",
":",
"await",
"self",
".",
"ffmpeg",
".",
"close",
"(",
")"
] | [
194,
4
] | [
200,
37
] | python | en | ['hu', 'en', 'en'] | True |
FFmpegBase._async_restart_ffmpeg | (self, entity_ids) | Stop a FFmpeg process.
This method is a coroutine.
| Stop a FFmpeg process. | async def _async_restart_ffmpeg(self, entity_ids):
"""Stop a FFmpeg process.
This method is a coroutine.
"""
if entity_ids is None or self.entity_id in entity_ids:
await self._async_stop_ffmpeg(None)
await self._async_start_ffmpeg(None) | [
"async",
"def",
"_async_restart_ffmpeg",
"(",
"self",
",",
"entity_ids",
")",
":",
"if",
"entity_ids",
"is",
"None",
"or",
"self",
".",
"entity_id",
"in",
"entity_ids",
":",
"await",
"self",
".",
"_async_stop_ffmpeg",
"(",
"None",
")",
"await",
"self",
".",
... | [
202,
4
] | [
209,
48
] | python | en | ['hu', 'en', 'en'] | True |
FFmpegBase._async_register_events | (self) | Register a FFmpeg process/device. | Register a FFmpeg process/device. | def _async_register_events(self):
"""Register a FFmpeg process/device."""
async def async_shutdown_handle(event):
"""Stop FFmpeg process."""
await self._async_stop_ffmpeg(None)
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_shutdown_handle)
# s... | [
"def",
"_async_register_events",
"(",
"self",
")",
":",
"async",
"def",
"async_shutdown_handle",
"(",
"event",
")",
":",
"\"\"\"Stop FFmpeg process.\"\"\"",
"await",
"self",
".",
"_async_stop_ffmpeg",
"(",
"None",
")",
"self",
".",
"hass",
".",
"bus",
".",
"asyn... | [
212,
4
] | [
230,
86
] | python | en | ['hu', 'en', 'en'] | True |
AutoTokenizer.from_pretrained | (cls, pretrained_model_name_or_path, *inputs, **kwargs) | r"""
Instantiate one of the tokenizer classes of the library from a pretrained model vocabulary.
The tokenizer class to instantiate is selected based on the :obj:`model_type` property of the config object
(either passed as an argument or loaded from :obj:`pretrained_model_name_or_path` if possi... | r"""
Instantiate one of the tokenizer classes of the library from a pretrained model vocabulary. | def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs):
r"""
Instantiate one of the tokenizer classes of the library from a pretrained model vocabulary.
The tokenizer class to instantiate is selected based on the :obj:`model_type` property of the config object
(eithe... | [
"def",
"from_pretrained",
"(",
"cls",
",",
"pretrained_model_name_or_path",
",",
"*",
"inputs",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"kwargs",
".",
"pop",
"(",
"\"config\"",
",",
"None",
")",
"if",
"not",
"isinstance",
"(",
"config",
",",
"P... | [
313,
4
] | [
430,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
fix_threading_exception_logging | () | Fix threads passing uncaught exceptions to our exception hook.
https://bugs.python.org/issue1230540
Fixed in Python 3.8.
| Fix threads passing uncaught exceptions to our exception hook. | def fix_threading_exception_logging() -> None:
"""Fix threads passing uncaught exceptions to our exception hook.
https://bugs.python.org/issue1230540
Fixed in Python 3.8.
"""
if sys.version_info[:2] >= (3, 8):
return
run_old = threading.Thread.run
def run(*args: Any, **kwargs: Any... | [
"def",
"fix_threading_exception_logging",
"(",
")",
"->",
"None",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
">=",
"(",
"3",
",",
"8",
")",
":",
"return",
"run_old",
"=",
"threading",
".",
"Thread",
".",
"run",
"def",
"run",
"(",
"*",... | [
8,
0
] | [
27,
30
] | python | en | ['en', 'en', 'en'] | True |
_async_raise | (tid: int, exctype: Any) | Raise an exception in the threads with id tid. | Raise an exception in the threads with id tid. | def _async_raise(tid: int, exctype: Any) -> None:
"""Raise an exception in the threads with id tid."""
if not inspect.isclass(exctype):
raise TypeError("Only types can be raised (not instances)")
c_tid = ctypes.c_long(tid)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(c_tid, ctypes.py_object... | [
"def",
"_async_raise",
"(",
"tid",
":",
"int",
",",
"exctype",
":",
"Any",
")",
"->",
"None",
":",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"exctype",
")",
":",
"raise",
"TypeError",
"(",
"\"Only types can be raised (not instances)\"",
")",
"c_tid",
"=",... | [
30,
0
] | [
44,
57
] | python | en | ['en', 'en', 'en'] | True |
ThreadWithException.raise_exc | (self, exctype: Any) | Raise the given exception type in the context of this thread. | Raise the given exception type in the context of this thread. | def raise_exc(self, exctype: Any) -> None:
"""Raise the given exception type in the context of this thread."""
assert self.ident
_async_raise(self.ident, exctype) | [
"def",
"raise_exc",
"(",
"self",
",",
"exctype",
":",
"Any",
")",
"->",
"None",
":",
"assert",
"self",
".",
"ident",
"_async_raise",
"(",
"self",
".",
"ident",
",",
"exctype",
")"
] | [
55,
4
] | [
58,
41
] | python | en | ['en', 'en', 'en'] | True |
_async_reproduce_state | (
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce a single state. | Reproduce a single state. | async def _async_reproduce_state(
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce a single state."""
cur_state = hass.states.get(state.entity_id)
# Return if we can't find entity
... | [
"async",
"def",
"_async_reproduce_state",
"(",
"hass",
":",
"HomeAssistantType",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",... | [
23,
0
] | [
66,
5
] | python | en | ['en', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce Input select states. | Reproduce Input select states. | async def async_reproduce_states(
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce Input select states."""
# Reproduce states in parallel.
await asyncio.gather(
*(
... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
... | [
69,
0
] | [
85,
5
] | python | en | ['en', 'en', 'en'] | True |
check_attr_equal | (
attr1: MappingProxyType, attr2: MappingProxyType, attr_str: str
) | Return true if the given attributes are equal. | Return true if the given attributes are equal. | def check_attr_equal(
attr1: MappingProxyType, attr2: MappingProxyType, attr_str: str
) -> bool:
"""Return true if the given attributes are equal."""
return attr1.get(attr_str) == attr2.get(attr_str) | [
"def",
"check_attr_equal",
"(",
"attr1",
":",
"MappingProxyType",
",",
"attr2",
":",
"MappingProxyType",
",",
"attr_str",
":",
"str",
")",
"->",
"bool",
":",
"return",
"attr1",
".",
"get",
"(",
"attr_str",
")",
"==",
"attr2",
".",
"get",
"(",
"attr_str",
... | [
88,
0
] | [
92,
53
] | python | en | ['en', 'en', 'en'] | True |
async_setup_forwarded | (app, trusted_proxies) | Create forwarded middleware for the app.
Process IP addresses, proto and host information in the forwarded for headers.
`X-Forwarded-For: <client>, <proxy1>, <proxy2>`
e.g., `X-Forwarded-For: 203.0.113.195, 70.41.3.18, 150.172.238.178`
We go through the list from the right side, and skip all entries ... | Create forwarded middleware for the app. | def async_setup_forwarded(app, trusted_proxies):
"""Create forwarded middleware for the app.
Process IP addresses, proto and host information in the forwarded for headers.
`X-Forwarded-For: <client>, <proxy1>, <proxy2>`
e.g., `X-Forwarded-For: 203.0.113.195, 70.41.3.18, 150.172.238.178`
We go thr... | [
"def",
"async_setup_forwarded",
"(",
"app",
",",
"trusted_proxies",
")",
":",
"@",
"middleware",
"async",
"def",
"forwarded_middleware",
"(",
"request",
",",
"handler",
")",
":",
"\"\"\"Process forwarded data by a reverse proxy.\"\"\"",
"overrides",
"=",
"{",
"}",
"# ... | [
15,
0
] | [
173,
48
] | python | en | ['en', 'en', 'en'] | True |
two_part_alarm | () | Fixture to mock alarm with two partitions. | Fixture to mock alarm with two partitions. | def two_part_alarm():
"""Fixture to mock alarm with two partitions."""
partition_mocks = {0: _partition_mock(), 1: _partition_mock()}
alarm_mock = MagicMock()
with patch.object(
partition_mocks[0], "id", new_callable=PropertyMock(return_value=0)
), patch.object(
partition_mocks[1], "... | [
"def",
"two_part_alarm",
"(",
")",
":",
"partition_mocks",
"=",
"{",
"0",
":",
"_partition_mock",
"(",
")",
",",
"1",
":",
"_partition_mock",
"(",
")",
"}",
"alarm_mock",
"=",
"MagicMock",
"(",
")",
"with",
"patch",
".",
"object",
"(",
"partition_mocks",
... | [
85,
0
] | [
101,
24
] | python | en | ['en', 'en', 'en'] | True |
test_cannot_connect | (hass) | Test connection error. | Test connection error. | async def test_cannot_connect(hass):
"""Test connection error."""
with patch(
"homeassistant.components.risco.RiscoAPI.login",
side_effect=CannotConnectError,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG)
config_entry.add_to_hass(hass)
await hass... | [
"async",
"def",
"test_cannot_connect",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.risco.RiscoAPI.login\"",
",",
"side_effect",
"=",
"CannotConnectError",
",",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",... | [
104,
0
] | [
117,
65
] | python | de | ['eu', 'de', 'en'] | False |
test_unauthorized | (hass) | Test unauthorized error. | Test unauthorized error. | async def test_unauthorized(hass):
"""Test unauthorized error."""
with patch(
"homeassistant.components.risco.RiscoAPI.login",
side_effect=UnauthorizedError,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG)
config_entry.add_to_hass(hass)
await hass.... | [
"async",
"def",
"test_unauthorized",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.risco.RiscoAPI.login\"",
",",
"side_effect",
"=",
"UnauthorizedError",
",",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
... | [
120,
0
] | [
133,
65
] | python | ca | ['ca', 'de', 'it'] | False |
test_setup | (hass, two_part_alarm) | Test entity setup. | Test entity setup. | async def test_setup(hass, two_part_alarm):
"""Test entity setup."""
registry = await hass.helpers.entity_registry.async_get_registry()
assert not registry.async_is_registered(FIRST_ENTITY_ID)
assert not registry.async_is_registered(SECOND_ENTITY_ID)
await setup_risco(hass)
assert registry.as... | [
"async",
"def",
"test_setup",
"(",
"hass",
",",
"two_part_alarm",
")",
":",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"assert",
"not",
"registry",
".",
"async_is_registered",
"(",
"FIRST_ENTITY... | [
136,
0
] | [
155,
41
] | python | en | ['en', 'zu', 'en'] | True |
test_states | (hass, two_part_alarm) | Test the various alarm states. | Test the various alarm states. | async def test_states(hass, two_part_alarm):
"""Test the various alarm states."""
await setup_risco(hass, CUSTOM_MAPPING_OPTIONS)
assert hass.states.get(FIRST_ENTITY_ID).state == STATE_UNKNOWN
for partition_id, entity_id in {0: FIRST_ENTITY_ID, 1: SECOND_ENTITY_ID}.items():
await _check_state(
... | [
"async",
"def",
"test_states",
"(",
"hass",
",",
"two_part_alarm",
")",
":",
"await",
"setup_risco",
"(",
"hass",
",",
"CUSTOM_MAPPING_OPTIONS",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"FIRST_ENTITY_ID",
")",
".",
"state",
"==",
"STATE_UNKNOWN",... | [
166,
0
] | [
221,
13
] | python | en | ['en', 'el-Latn', 'en'] | True |
test_sets_custom_mapping | (hass, two_part_alarm) | Test settings the various modes when mapping some states. | Test settings the various modes when mapping some states. | async def test_sets_custom_mapping(hass, two_part_alarm):
"""Test settings the various modes when mapping some states."""
await setup_risco(hass, CUSTOM_MAPPING_OPTIONS)
registry = await hass.helpers.entity_registry.async_get_registry()
entity = registry.async_get(FIRST_ENTITY_ID)
assert entity.sup... | [
"async",
"def",
"test_sets_custom_mapping",
"(",
"hass",
",",
"two_part_alarm",
")",
":",
"await",
"setup_risco",
"(",
"hass",
",",
"CUSTOM_MAPPING_OPTIONS",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
... | [
248,
0
] | [
271,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sets_full_custom_mapping | (hass, two_part_alarm) | Test settings the various modes when mapping all states. | Test settings the various modes when mapping all states. | async def test_sets_full_custom_mapping(hass, two_part_alarm):
"""Test settings the various modes when mapping all states."""
await setup_risco(hass, FULL_CUSTOM_MAPPING)
registry = await hass.helpers.entity_registry.async_get_registry()
entity = registry.async_get(FIRST_ENTITY_ID)
assert (
... | [
"async",
"def",
"test_sets_full_custom_mapping",
"(",
"hass",
",",
"two_part_alarm",
")",
":",
"await",
"setup_risco",
"(",
"hass",
",",
"FULL_CUSTOM_MAPPING",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
... | [
274,
0
] | [
305,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sets_with_correct_code | (hass, two_part_alarm) | Test settings the various modes when code is required. | Test settings the various modes when code is required. | async def test_sets_with_correct_code(hass, two_part_alarm):
"""Test settings the various modes when code is required."""
await setup_risco(hass, {**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS})
code = {"code": 1234}
await _test_service_call(
hass, SERVICE_ALARM_DISARM, "disarm", FIRST_ENT... | [
"async",
"def",
"test_sets_with_correct_code",
"(",
"hass",
",",
"two_part_alarm",
")",
":",
"await",
"setup_risco",
"(",
"hass",
",",
"{",
"*",
"*",
"CUSTOM_MAPPING_OPTIONS",
",",
"*",
"*",
"CODES_REQUIRED_OPTIONS",
"}",
")",
"code",
"=",
"{",
"\"code\"",
":"... | [
308,
0
] | [
347,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sets_with_incorrect_code | (hass, two_part_alarm) | Test settings the various modes when code is required and incorrect. | Test settings the various modes when code is required and incorrect. | async def test_sets_with_incorrect_code(hass, two_part_alarm):
"""Test settings the various modes when code is required and incorrect."""
await setup_risco(hass, {**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS})
code = {"code": 4321}
await _test_no_service_call(
hass, SERVICE_ALARM_DISARM, ... | [
"async",
"def",
"test_sets_with_incorrect_code",
"(",
"hass",
",",
"two_part_alarm",
")",
":",
"await",
"setup_risco",
"(",
"hass",
",",
"{",
"*",
"*",
"CUSTOM_MAPPING_OPTIONS",
",",
"*",
"*",
"CODES_REQUIRED_OPTIONS",
"}",
")",
"code",
"=",
"{",
"\"code\"",
"... | [
350,
0
] | [
389,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_comp | (hass) | Set up demo component. | Set up demo component. | async def setup_comp(hass):
"""Set up demo component."""
assert await async_setup_component(
hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": DOMAIN}}
)
await hass.async_block_till_done() | [
"async",
"def",
"setup_comp",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"{",
"LOCK_DOMAIN",
":",
"{",
"\"platform\"",
":",
"DOMAIN",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
... | [
23,
0
] | [
28,
38
] | python | en | ['en', 'da', 'en'] | True |
test_locking | (hass) | Test the locking of a lock. | Test the locking of a lock. | async def test_locking(hass):
"""Test the locking of a lock."""
state = hass.states.get(KITCHEN)
assert state.state == STATE_UNLOCKED
await hass.services.async_call(
LOCK_DOMAIN, SERVICE_LOCK, {ATTR_ENTITY_ID: KITCHEN}, blocking=True
)
state = hass.states.get(KITCHEN)
assert state.... | [
"async",
"def",
"test_locking",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"KITCHEN",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_UNLOCKED",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"LOCK_DOMAIN",
... | [
31,
0
] | [
41,
38
] | python | en | ['en', 'en', 'en'] | True |
test_unlocking | (hass) | Test the unlocking of a lock. | Test the unlocking of a lock. | async def test_unlocking(hass):
"""Test the unlocking of a lock."""
state = hass.states.get(FRONT)
assert state.state == STATE_LOCKED
await hass.services.async_call(
LOCK_DOMAIN, SERVICE_UNLOCK, {ATTR_ENTITY_ID: FRONT}, blocking=True
)
state = hass.states.get(FRONT)
assert state.st... | [
"async",
"def",
"test_unlocking",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"FRONT",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_LOCKED",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"LOCK_DOMAIN",
"... | [
44,
0
] | [
54,
40
] | python | en | ['en', 'en', 'en'] | True |
test_opening | (hass) | Test the opening of a lock. | Test the opening of a lock. | async def test_opening(hass):
"""Test the opening of a lock."""
calls = async_mock_service(hass, LOCK_DOMAIN, SERVICE_OPEN)
await hass.services.async_call(
LOCK_DOMAIN, SERVICE_OPEN, {ATTR_ENTITY_ID: OPENABLE_LOCK}, blocking=True
)
assert len(calls) == 1 | [
"async",
"def",
"test_opening",
"(",
"hass",
")",
":",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"LOCK_DOMAIN",
",",
"SERVICE_OPEN",
")",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"LOCK_DOMAIN",
",",
"SERVICE_OPEN",
",",
"{",
"ATT... | [
57,
0
] | [
63,
26
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the LIRC capability. | Set up the LIRC capability. | def setup(hass, config):
"""Set up the LIRC capability."""
# blocking=True gives unexpected behavior (multiple responses for 1 press)
# also by not blocking, we allow hass to shut down the thread gracefully
# on exit.
lirc.init("home-assistant", blocking=False)
lirc_interface = LircInterface(has... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"# blocking=True gives unexpected behavior (multiple responses for 1 press)",
"# also by not blocking, we allow hass to shut down the thread gracefully",
"# on exit.",
"lirc",
".",
"init",
"(",
"\"home-assistant\"",
",",
"blocki... | [
24,
0
] | [
41,
15
] | python | en | ['en', 'en', 'en'] | True |
LircInterface.__init__ | (self, hass) | Construct a LIRC interface object. | Construct a LIRC interface object. | def __init__(self, hass):
"""Construct a LIRC interface object."""
threading.Thread.__init__(self)
self.daemon = True
self.stopped = threading.Event()
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"threading",
".",
"Thread",
".",
"__init__",
"(",
"self",
")",
"self",
".",
"daemon",
"=",
"True",
"self",
".",
"stopped",
"=",
"threading",
".",
"Event",
"(",
")",
"self",
".",
"hass",
"=",
"h... | [
53,
4
] | [
58,
24
] | python | en | ['en', 'en', 'en'] | True |
LircInterface.run | (self) | Run the loop of the LIRC interface thread. | Run the loop of the LIRC interface thread. | def run(self):
"""Run the loop of the LIRC interface thread."""
_LOGGER.debug("LIRC interface thread started")
while not self.stopped.isSet():
try:
code = lirc.nextcode() # list; empty if no buttons pressed
except lirc.NextCodeError:
_LOGG... | [
"def",
"run",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"LIRC interface thread started\"",
")",
"while",
"not",
"self",
".",
"stopped",
".",
"isSet",
"(",
")",
":",
"try",
":",
"code",
"=",
"lirc",
".",
"nextcode",
"(",
")",
"# list; empty i... | [
60,
4
] | [
77,
54
] | python | en | ['en', 'yo', 'en'] | True |
test_message_includes_default_emoji | () | Tests that default icon is used when no message icon is given. | Tests that default icon is used when no message icon is given. | async def test_message_includes_default_emoji():
"""Tests that default icon is used when no message icon is given."""
mock_client = Mock()
mock_client.chat_postMessage = AsyncMock()
expected_icon = ":robot_face:"
service = SlackNotificationService(None, mock_client, "_", "_", expected_icon)
awa... | [
"async",
"def",
"test_message_includes_default_emoji",
"(",
")",
":",
"mock_client",
"=",
"Mock",
"(",
")",
"mock_client",
".",
"chat_postMessage",
"=",
"AsyncMock",
"(",
")",
"expected_icon",
"=",
"\":robot_face:\"",
"service",
"=",
"SlackNotificationService",
"(",
... | [
8,
0
] | [
20,
48
] | python | en | ['en', 'en', 'en'] | True |
test_message_emoji_overrides_default | () | Tests that overriding the default icon emoji when sending a message works. | Tests that overriding the default icon emoji when sending a message works. | async def test_message_emoji_overrides_default():
"""Tests that overriding the default icon emoji when sending a message works."""
mock_client = Mock()
mock_client.chat_postMessage = AsyncMock()
service = SlackNotificationService(None, mock_client, "_", "_", "default_icon")
expected_icon = ":new:"
... | [
"async",
"def",
"test_message_emoji_overrides_default",
"(",
")",
":",
"mock_client",
"=",
"Mock",
"(",
")",
"mock_client",
".",
"chat_postMessage",
"=",
"AsyncMock",
"(",
")",
"service",
"=",
"SlackNotificationService",
"(",
"None",
",",
"mock_client",
",",
"\"_\... | [
23,
0
] | [
35,
48
] | python | en | ['en', 'en', 'en'] | True |
test_message_includes_default_icon_url | () | Tests that overriding the default icon url when sending a message works. | Tests that overriding the default icon url when sending a message works. | async def test_message_includes_default_icon_url():
"""Tests that overriding the default icon url when sending a message works."""
mock_client = Mock()
mock_client.chat_postMessage = AsyncMock()
expected_icon = "https://example.com/hass.png"
service = SlackNotificationService(None, mock_client, "_",... | [
"async",
"def",
"test_message_includes_default_icon_url",
"(",
")",
":",
"mock_client",
"=",
"Mock",
"(",
")",
"mock_client",
".",
"chat_postMessage",
"=",
"AsyncMock",
"(",
")",
"expected_icon",
"=",
"\"https://example.com/hass.png\"",
"service",
"=",
"SlackNotificatio... | [
38,
0
] | [
50,
46
] | python | en | ['en', 'en', 'en'] | True |
test_message_icon_url_overrides_default | () | Tests that overriding the default icon url when sending a message works. | Tests that overriding the default icon url when sending a message works. | async def test_message_icon_url_overrides_default():
"""Tests that overriding the default icon url when sending a message works."""
mock_client = Mock()
mock_client.chat_postMessage = AsyncMock()
service = SlackNotificationService(None, mock_client, "_", "_", "default_icon")
expected_icon = "https:... | [
"async",
"def",
"test_message_icon_url_overrides_default",
"(",
")",
":",
"mock_client",
"=",
"Mock",
"(",
")",
"mock_client",
".",
"chat_postMessage",
"=",
"AsyncMock",
"(",
")",
"service",
"=",
"SlackNotificationService",
"(",
"None",
",",
"mock_client",
",",
"\... | [
53,
0
] | [
65,
46
] | python | en | ['en', 'en', 'en'] | True |
create_file | (path) | Create an empty file. | Create an empty file. | def create_file(path):
"""Create an empty file."""
with open(path, "w"):
pass | [
"def",
"create_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"\"w\"",
")",
":",
"pass"
] | [
50,
0
] | [
53,
12
] | python | en | ['en', 'ro', 'en'] | True |
test_create_default_config | (hass) | Test creation of default config. | Test creation of default config. | async def test_create_default_config(hass):
"""Test creation of default config."""
await config_util.async_create_default_config(hass)
assert os.path.isfile(YAML_PATH)
assert os.path.isfile(SECRET_PATH)
assert os.path.isfile(VERSION_PATH)
assert os.path.isfile(GROUP_PATH)
assert os.path.isf... | [
"async",
"def",
"test_create_default_config",
"(",
"hass",
")",
":",
"await",
"config_util",
".",
"async_create_default_config",
"(",
"hass",
")",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"YAML_PATH",
")",
"assert",
"os",
".",
"path",
".",
"isfile",
... | [
82,
0
] | [
90,
43
] | python | en | ['en', 'da', 'en'] | True |
test_ensure_config_exists_creates_config | (hass) | Test that calling ensure_config_exists.
If not creates a new config file.
| Test that calling ensure_config_exists. | async def test_ensure_config_exists_creates_config(hass):
"""Test that calling ensure_config_exists.
If not creates a new config file.
"""
with patch("builtins.print") as mock_print:
await config_util.async_ensure_config_exists(hass)
assert os.path.isfile(YAML_PATH)
assert mock_print.c... | [
"async",
"def",
"test_ensure_config_exists_creates_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"builtins.print\"",
")",
"as",
"mock_print",
":",
"await",
"config_util",
".",
"async_ensure_config_exists",
"(",
"hass",
")",
"assert",
"os",
".",
"path",
"... | [
93,
0
] | [
102,
28
] | python | en | ['en', 'en', 'en'] | True |
test_ensure_config_exists_uses_existing_config | (hass) | Test that calling ensure_config_exists uses existing config. | Test that calling ensure_config_exists uses existing config. | async def test_ensure_config_exists_uses_existing_config(hass):
"""Test that calling ensure_config_exists uses existing config."""
create_file(YAML_PATH)
await config_util.async_ensure_config_exists(hass)
with open(YAML_PATH) as fp:
content = fp.read()
# File created with create_file are e... | [
"async",
"def",
"test_ensure_config_exists_uses_existing_config",
"(",
"hass",
")",
":",
"create_file",
"(",
"YAML_PATH",
")",
"await",
"config_util",
".",
"async_ensure_config_exists",
"(",
"hass",
")",
"with",
"open",
"(",
"YAML_PATH",
")",
"as",
"fp",
":",
"con... | [
105,
0
] | [
114,
24
] | python | en | ['en', 'en', 'en'] | True |
test_load_yaml_config_converts_empty_files_to_dict | () | Test that loading an empty file returns an empty dict. | Test that loading an empty file returns an empty dict. | def test_load_yaml_config_converts_empty_files_to_dict():
"""Test that loading an empty file returns an empty dict."""
create_file(YAML_PATH)
assert isinstance(config_util.load_yaml_config_file(YAML_PATH), dict) | [
"def",
"test_load_yaml_config_converts_empty_files_to_dict",
"(",
")",
":",
"create_file",
"(",
"YAML_PATH",
")",
"assert",
"isinstance",
"(",
"config_util",
".",
"load_yaml_config_file",
"(",
"YAML_PATH",
")",
",",
"dict",
")"
] | [
117,
0
] | [
121,
73
] | python | en | ['en', 'en', 'en'] | True |
test_load_yaml_config_raises_error_if_not_dict | () | Test error raised when YAML file is not a dict. | Test error raised when YAML file is not a dict. | def test_load_yaml_config_raises_error_if_not_dict():
"""Test error raised when YAML file is not a dict."""
with open(YAML_PATH, "w") as fp:
fp.write("5")
with pytest.raises(HomeAssistantError):
config_util.load_yaml_config_file(YAML_PATH) | [
"def",
"test_load_yaml_config_raises_error_if_not_dict",
"(",
")",
":",
"with",
"open",
"(",
"YAML_PATH",
",",
"\"w\"",
")",
"as",
"fp",
":",
"fp",
".",
"write",
"(",
"\"5\"",
")",
"with",
"pytest",
".",
"raises",
"(",
"HomeAssistantError",
")",
":",
"config... | [
124,
0
] | [
130,
52
] | python | en | ['en', 'en', 'en'] | True |
test_load_yaml_config_raises_error_if_malformed_yaml | () | Test error raised if invalid YAML. | Test error raised if invalid YAML. | def test_load_yaml_config_raises_error_if_malformed_yaml():
"""Test error raised if invalid YAML."""
with open(YAML_PATH, "w") as fp:
fp.write(":")
with pytest.raises(HomeAssistantError):
config_util.load_yaml_config_file(YAML_PATH) | [
"def",
"test_load_yaml_config_raises_error_if_malformed_yaml",
"(",
")",
":",
"with",
"open",
"(",
"YAML_PATH",
",",
"\"w\"",
")",
"as",
"fp",
":",
"fp",
".",
"write",
"(",
"\":\"",
")",
"with",
"pytest",
".",
"raises",
"(",
"HomeAssistantError",
")",
":",
"... | [
133,
0
] | [
139,
52
] | python | en | ['en', 'et', 'en'] | True |
test_load_yaml_config_raises_error_if_unsafe_yaml | () | Test error raised if unsafe YAML. | Test error raised if unsafe YAML. | def test_load_yaml_config_raises_error_if_unsafe_yaml():
"""Test error raised if unsafe YAML."""
with open(YAML_PATH, "w") as fp:
fp.write("hello: !!python/object/apply:os.system")
with pytest.raises(HomeAssistantError):
config_util.load_yaml_config_file(YAML_PATH) | [
"def",
"test_load_yaml_config_raises_error_if_unsafe_yaml",
"(",
")",
":",
"with",
"open",
"(",
"YAML_PATH",
",",
"\"w\"",
")",
"as",
"fp",
":",
"fp",
".",
"write",
"(",
"\"hello: !!python/object/apply:os.system\"",
")",
"with",
"pytest",
".",
"raises",
"(",
"Home... | [
142,
0
] | [
148,
52
] | python | en | ['en', 'de', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.