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_empty_update | (hass) | Test updating with no state from monoprice. | Test updating with no state from monoprice. | async def test_empty_update(hass):
"""Test updating with no state from monoprice."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
# Changing media player to new state
await _call_media_player_service(
hass, SERVICE_VOLUME_SET, {"entity_id": ZONE_1_ID, "volume_level": ... | [
"async",
"def",
"test_empty_update",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"# Changing media player to new state",
"await",
"_call_media_player_service",
"(",
"hass",
",",
... | [
333,
0
] | [
356,
55
] | python | en | ['en', 'en', 'en'] | True |
test_supported_features | (hass) | Test supported features property. | Test supported features property. | async def test_supported_features(hass):
"""Test supported features property."""
await _setup_monoprice(hass, MockMonoprice())
state = hass.states.get(ZONE_1_ID)
assert (
SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET
| SUPPORT_VOLUME_STEP
| SUPPORT_TURN_ON
| SUPPORT_T... | [
"async",
"def",
"test_supported_features",
"(",
"hass",
")",
":",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"MockMonoprice",
"(",
")",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ZONE_1_ID",
")",
"assert",
"(",
"SUPPORT_VOLUME_MUTE",
"|"... | [
359,
0
] | [
372,
5
] | python | en | ['en', 'en', 'en'] | True |
test_source_list | (hass) | Test source list property. | Test source list property. | async def test_source_list(hass):
"""Test source list property."""
await _setup_monoprice(hass, MockMonoprice())
state = hass.states.get(ZONE_1_ID)
# Note, the list is sorted!
assert state.attributes[ATTR_INPUT_SOURCE_LIST] == ["one", "three"] | [
"async",
"def",
"test_source_list",
"(",
"hass",
")",
":",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"MockMonoprice",
"(",
")",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ZONE_1_ID",
")",
"# Note, the list is sorted!",
"assert",
"state",
... | [
375,
0
] | [
381,
71
] | python | en | ['fr', 'en', 'en'] | True |
test_source_list_with_options | (hass) | Test source list property. | Test source list property. | async def test_source_list_with_options(hass):
"""Test source list property."""
await _setup_monoprice_with_options(hass, MockMonoprice())
state = hass.states.get(ZONE_1_ID)
# Note, the list is sorted!
assert state.attributes[ATTR_INPUT_SOURCE_LIST] == ["two", "four"] | [
"async",
"def",
"test_source_list_with_options",
"(",
"hass",
")",
":",
"await",
"_setup_monoprice_with_options",
"(",
"hass",
",",
"MockMonoprice",
"(",
")",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ZONE_1_ID",
")",
"# Note, the list is sorted!... | [
384,
0
] | [
390,
70
] | python | en | ['fr', 'en', 'en'] | True |
test_select_source | (hass) | Test source selection methods. | Test source selection methods. | async def test_select_source(hass):
"""Test source selection methods."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
await _call_media_player_service(
hass,
SERVICE_SELECT_SOURCE,
{"entity_id": ZONE_1_ID, ATTR_INPUT_SOURCE: "three"},
)
assert mono... | [
"async",
"def",
"test_select_source",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"await",
"_call_media_player_service",
"(",
"hass",
",",
"SERVICE_SELECT_SOURCE",
",",
"{",
... | [
393,
0
] | [
411,
42
] | python | en | ['fr', 'en', 'en'] | True |
test_unknown_source | (hass) | Test behavior when device has unknown source. | Test behavior when device has unknown source. | async def test_unknown_source(hass):
"""Test behavior when device has unknown source."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
monoprice.set_source(11, 5)
await async_update_entity(hass, ZONE_1_ID)
await hass.async_block_till_done()
state = hass.states.get(ZO... | [
"async",
"def",
"test_unknown_source",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"monoprice",
".",
"set_source",
"(",
"11",
",",
"5",
")",
"await",
"async_update_entity"... | [
414,
0
] | [
426,
58
] | python | en | ['en', 'de', 'en'] | True |
test_turn_on_off | (hass) | Test turning on the zone. | Test turning on the zone. | async def test_turn_on_off(hass):
"""Test turning on the zone."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
await _call_media_player_service(hass, SERVICE_TURN_OFF, {"entity_id": ZONE_1_ID})
assert not monoprice.zones[11].power
await _call_media_player_service(hass, S... | [
"async",
"def",
"test_turn_on_off",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"await",
"_call_media_player_service",
"(",
"hass",
",",
"SERVICE_TURN_OFF",
",",
"{",
"\"ent... | [
429,
0
] | [
438,
36
] | python | en | ['en', 'en', 'en'] | True |
test_mute_volume | (hass) | Test mute functionality. | Test mute functionality. | async def test_mute_volume(hass):
"""Test mute functionality."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
await _call_media_player_service(
hass, SERVICE_VOLUME_SET, {"entity_id": ZONE_1_ID, "volume_level": 0.5}
)
await _call_media_player_service(
hass... | [
"async",
"def",
"test_mute_volume",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"await",
"_call_media_player_service",
"(",
"hass",
",",
"SERVICE_VOLUME_SET",
",",
"{",
"\"e... | [
441,
0
] | [
457,
35
] | python | en | ['en', 'en', 'en'] | True |
test_volume_up_down | (hass) | Test increasing volume by one. | Test increasing volume by one. | async def test_volume_up_down(hass):
"""Test increasing volume by one."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
await _call_media_player_service(
hass, SERVICE_VOLUME_SET, {"entity_id": ZONE_1_ID, "volume_level": 0.0}
)
assert monoprice.zones[11].volume == ... | [
"async",
"def",
"test_volume_up_down",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"await",
"_call_media_player_service",
"(",
"hass",
",",
"SERVICE_VOLUME_SET",
",",
"{",
"... | [
460,
0
] | [
491,
43
] | python | en | ['en', 'en', 'en'] | True |
test_first_run_with_available_zones | (hass) | Test first run with all zones available. | Test first run with all zones available. | async def test_first_run_with_available_zones(hass):
"""Test first run with all zones available."""
monoprice = MockMonoprice()
await _setup_monoprice(hass, monoprice)
registry = await hass.helpers.entity_registry.async_get_registry()
entry = registry.async_get(ZONE_7_ID)
assert not entry.disa... | [
"async",
"def",
"test_first_run_with_available_zones",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"await",
"_setup_monoprice",
"(",
"hass",
",",
"monoprice",
")",
"registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
... | [
494,
0
] | [
502,
29
] | python | en | ['en', 'en', 'en'] | True |
test_first_run_with_failing_zones | (hass) | Test first run with failed zones. | Test first run with failed zones. | async def test_first_run_with_failing_zones(hass):
"""Test first run with failed zones."""
monoprice = MockMonoprice()
with patch.object(MockMonoprice, "zone_status", side_effect=SerialException):
await _setup_monoprice(hass, monoprice)
registry = await hass.helpers.entity_registry.async_get_r... | [
"async",
"def",
"test_first_run_with_failing_zones",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"with",
"patch",
".",
"object",
"(",
"MockMonoprice",
",",
"\"zone_status\"",
",",
"side_effect",
"=",
"SerialException",
")",
":",
"await",
... | [
505,
0
] | [
519,
45
] | python | en | ['en', 'en', 'en'] | True |
test_not_first_run_with_failing_zone | (hass) | Test first run with failed zones. | Test first run with failed zones. | async def test_not_first_run_with_failing_zone(hass):
"""Test first run with failed zones."""
monoprice = MockMonoprice()
with patch.object(MockMonoprice, "zone_status", side_effect=SerialException):
await _setup_monoprice_not_first_run(hass, monoprice)
registry = await hass.helpers.entity_reg... | [
"async",
"def",
"test_not_first_run_with_failing_zone",
"(",
"hass",
")",
":",
"monoprice",
"=",
"MockMonoprice",
"(",
")",
"with",
"patch",
".",
"object",
"(",
"MockMonoprice",
",",
"\"zone_status\"",
",",
"side_effect",
"=",
"SerialException",
")",
":",
"await",... | [
522,
0
] | [
535,
29
] | python | en | ['en', 'en', 'en'] | True |
AttrDict.__setattr__ | (self, name, value) | Set attribute. | Set attribute. | def __setattr__(self, name, value):
"""Set attribute."""
self[name] = value | [
"def",
"__setattr__",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
"[",
"name",
"]",
"=",
"value"
] | [
50,
4
] | [
52,
26
] | python | en | ['en', 'la', 'en'] | False |
AttrDict.__getattr__ | (self, item) | Get attribute. | Get attribute. | def __getattr__(self, item):
"""Get attribute."""
return self[item] | [
"def",
"__getattr__",
"(",
"self",
",",
"item",
")",
":",
"return",
"self",
"[",
"item",
"]"
] | [
54,
4
] | [
56,
25
] | python | en | ['en', 'de', 'en'] | False |
MockMonoprice.__init__ | (self) | Init mock object. | Init mock object. | def __init__(self):
"""Init mock object."""
self.zones = defaultdict(
lambda: AttrDict(power=True, volume=0, mute=True, source=1)
) | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"zones",
"=",
"defaultdict",
"(",
"lambda",
":",
"AttrDict",
"(",
"power",
"=",
"True",
",",
"volume",
"=",
"0",
",",
"mute",
"=",
"True",
",",
"source",
"=",
"1",
")",
")"
] | [
62,
4
] | [
66,
9
] | python | en | ['pl', 'fy', 'en'] | False |
MockMonoprice.zone_status | (self, zone_id) | Get zone status. | Get zone status. | def zone_status(self, zone_id):
"""Get zone status."""
status = self.zones[zone_id]
status.zone = zone_id
return AttrDict(status) | [
"def",
"zone_status",
"(",
"self",
",",
"zone_id",
")",
":",
"status",
"=",
"self",
".",
"zones",
"[",
"zone_id",
"]",
"status",
".",
"zone",
"=",
"zone_id",
"return",
"AttrDict",
"(",
"status",
")"
] | [
68,
4
] | [
72,
31
] | python | en | ['pl', 'la', 'en'] | False |
MockMonoprice.set_source | (self, zone_id, source_idx) | Set source for zone. | Set source for zone. | def set_source(self, zone_id, source_idx):
"""Set source for zone."""
self.zones[zone_id].source = source_idx | [
"def",
"set_source",
"(",
"self",
",",
"zone_id",
",",
"source_idx",
")",
":",
"self",
".",
"zones",
"[",
"zone_id",
"]",
".",
"source",
"=",
"source_idx"
] | [
74,
4
] | [
76,
47
] | python | en | ['en', 'en', 'en'] | True |
MockMonoprice.set_power | (self, zone_id, power) | Turn zone on/off. | Turn zone on/off. | def set_power(self, zone_id, power):
"""Turn zone on/off."""
self.zones[zone_id].power = power | [
"def",
"set_power",
"(",
"self",
",",
"zone_id",
",",
"power",
")",
":",
"self",
".",
"zones",
"[",
"zone_id",
"]",
".",
"power",
"=",
"power"
] | [
78,
4
] | [
80,
41
] | python | en | ['nl', 'en', 'en'] | True |
MockMonoprice.set_mute | (self, zone_id, mute) | Mute/unmute zone. | Mute/unmute zone. | def set_mute(self, zone_id, mute):
"""Mute/unmute zone."""
self.zones[zone_id].mute = mute | [
"def",
"set_mute",
"(",
"self",
",",
"zone_id",
",",
"mute",
")",
":",
"self",
".",
"zones",
"[",
"zone_id",
"]",
".",
"mute",
"=",
"mute"
] | [
82,
4
] | [
84,
39
] | python | it | ['pl', 'la', 'it'] | False |
MockMonoprice.set_volume | (self, zone_id, volume) | Set volume for zone. | Set volume for zone. | def set_volume(self, zone_id, volume):
"""Set volume for zone."""
self.zones[zone_id].volume = volume | [
"def",
"set_volume",
"(",
"self",
",",
"zone_id",
",",
"volume",
")",
":",
"self",
".",
"zones",
"[",
"zone_id",
"]",
".",
"volume",
"=",
"volume"
] | [
86,
4
] | [
88,
43
] | python | en | ['nl', 'no', 'en'] | False |
MockMonoprice.restore_zone | (self, zone) | Restore zone status. | Restore zone status. | def restore_zone(self, zone):
"""Restore zone status."""
self.zones[zone.zone] = AttrDict(zone) | [
"def",
"restore_zone",
"(",
"self",
",",
"zone",
")",
":",
"self",
".",
"zones",
"[",
"zone",
".",
"zone",
"]",
"=",
"AttrDict",
"(",
"zone",
")"
] | [
90,
4
] | [
92,
46
] | python | en | ['sk', 'sn', 'en'] | False |
train_model | (path, model, saveto=None, cv=12) |
Trains model from corpus at specified path; constructing cross-validation
scores using the cv parameter, then fitting the model on the full data and
writing it to disk at the saveto path if specified. Returns the scores.
|
Trains model from corpus at specified path; constructing cross-validation
scores using the cv parameter, then fitting the model on the full data and
writing it to disk at the saveto path if specified. Returns the scores.
| def train_model(path, model, saveto=None, cv=12):
"""
Trains model from corpus at specified path; constructing cross-validation
scores using the cv parameter, then fitting the model on the full data and
writing it to disk at the saveto path if specified. Returns the scores.
"""
# Load the corpus... | [
"def",
"train_model",
"(",
"path",
",",
"model",
",",
"saveto",
"=",
"None",
",",
"cv",
"=",
"12",
")",
":",
"# Load the corpus data and labels for classification",
"corpus",
"=",
"PickledCorpusReader",
"(",
"path",
")",
"X",
"=",
"documents",
"(",
"corpus",
"... | [
68,
0
] | [
90,
17
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Islamic prayer times sensor platform. | Set up the Islamic prayer times sensor platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Islamic prayer times sensor platform."""
client = hass.data[DOMAIN]
entities = []
for sensor_type in SENSOR_TYPES:
entities.append(IslamicPrayerTimeSensor(sensor_type, client))
async_add_entities(entities, ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"entities",
"=",
"[",
"]",
"for",
"sensor_type",
"in",
"SENSOR_TYPES",
":",
"entities",
".",
... | [
10,
0
] | [
19,
38
] | python | en | ['en', 'hi-Latn', 'en'] | True |
IslamicPrayerTimeSensor.__init__ | (self, sensor_type, client) | Initialize the Islamic prayer time sensor. | Initialize the Islamic prayer time sensor. | def __init__(self, sensor_type, client):
"""Initialize the Islamic prayer time sensor."""
self.sensor_type = sensor_type
self.client = client | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"client",
")",
":",
"self",
".",
"sensor_type",
"=",
"sensor_type",
"self",
".",
"client",
"=",
"client"
] | [
25,
4
] | [
28,
28
] | python | en | ['en', 'sq', 'en'] | True |
IslamicPrayerTimeSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.sensor_type} {SENSOR_TYPES[self.sensor_type]}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.sensor_type} {SENSOR_TYPES[self.sensor_type]}\""
] | [
31,
4
] | [
33,
69
] | python | en | ['en', 'mi', 'en'] | True |
IslamicPrayerTimeSensor.unique_id | (self) | Return the unique id of the entity. | Return the unique id of the entity. | def unique_id(self):
"""Return the unique id of the entity."""
return self.sensor_type | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"sensor_type"
] | [
36,
4
] | [
38,
31
] | python | en | ['en', 'en', 'en'] | True |
IslamicPrayerTimeSensor.icon | (self) | Icon to display in the front end. | Icon to display in the front end. | def icon(self):
"""Icon to display in the front end."""
return PRAYER_TIMES_ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"PRAYER_TIMES_ICON"
] | [
41,
4
] | [
43,
32
] | python | en | ['en', 'en', 'en'] | True |
IslamicPrayerTimeSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return (
self.client.prayer_times_info.get(self.sensor_type)
.astimezone(dt_util.UTC)
.isoformat()
) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"client",
".",
"prayer_times_info",
".",
"get",
"(",
"self",
".",
"sensor_type",
")",
".",
"astimezone",
"(",
"dt_util",
".",
"UTC",
")",
".",
"isoformat",
"(",
")",
")"
] | [
46,
4
] | [
52,
9
] | python | en | ['en', 'en', 'en'] | True |
IslamicPrayerTimeSensor.should_poll | (self) | Disable polling. | Disable polling. | def should_poll(self):
"""Disable polling."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
55,
4
] | [
57,
20
] | python | en | ['fr', 'en', 'en'] | False |
IslamicPrayerTimeSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
60,
4
] | [
62,
37
] | python | en | ['en', 'en', 'en'] | True |
IslamicPrayerTimeSensor.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
self.async_on_remove(
async_dispatcher_connect(self.hass, DATA_UPDATED, self.async_write_ha_state)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DATA_UPDATED",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
64,
4
] | [
68,
9
] | python | en | ['en', 'en', 'en'] | True |
value_changed | (value) | Fire a value changed. | Fire a value changed. | def value_changed(value):
"""Fire a value changed."""
dispatcher.send(
MockNetwork.SIGNAL_VALUE_CHANGED,
value=value,
node=value.node,
network=value.node._network,
) | [
"def",
"value_changed",
"(",
"value",
")",
":",
"dispatcher",
".",
"send",
"(",
"MockNetwork",
".",
"SIGNAL_VALUE_CHANGED",
",",
"value",
"=",
"value",
",",
"node",
"=",
"value",
".",
"node",
",",
"network",
"=",
"value",
".",
"node",
".",
"_network",
",... | [
6,
0
] | [
13,
5
] | python | en | ['en', 'en', 'en'] | True |
node_changed | (node) | Fire a node changed. | Fire a node changed. | def node_changed(node):
"""Fire a node changed."""
dispatcher.send(MockNetwork.SIGNAL_NODE, node=node, network=node._network) | [
"def",
"node_changed",
"(",
"node",
")",
":",
"dispatcher",
".",
"send",
"(",
"MockNetwork",
".",
"SIGNAL_NODE",
",",
"node",
"=",
"node",
",",
"network",
"=",
"node",
".",
"_network",
")"
] | [
16,
0
] | [
18,
78
] | python | en | ['en', 'lb', 'en'] | True |
notification | (node_id, network=None) | Fire a notification. | Fire a notification. | def notification(node_id, network=None):
"""Fire a notification."""
dispatcher.send(
MockNetwork.SIGNAL_NOTIFICATION, args={"nodeId": node_id}, network=network
) | [
"def",
"notification",
"(",
"node_id",
",",
"network",
"=",
"None",
")",
":",
"dispatcher",
".",
"send",
"(",
"MockNetwork",
".",
"SIGNAL_NOTIFICATION",
",",
"args",
"=",
"{",
"\"nodeId\"",
":",
"node_id",
"}",
",",
"network",
"=",
"network",
")"
] | [
21,
0
] | [
25,
5
] | python | en | ['en', 'lb', 'en'] | True |
MockOption.__init__ | (self, device=None, config_path=None, user_path=None, cmd_line=None) | Initialize a Z-Wave mock options. | Initialize a Z-Wave mock options. | def __init__(self, device=None, config_path=None, user_path=None, cmd_line=None):
"""Initialize a Z-Wave mock options."""
super().__init__()
self.device = device
self.config_path = config_path
self.user_path = user_path
self.cmd_line = cmd_line | [
"def",
"__init__",
"(",
"self",
",",
"device",
"=",
"None",
",",
"config_path",
"=",
"None",
",",
"user_path",
"=",
"None",
",",
"cmd_line",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"device",
"=",
"device",
... | [
31,
4
] | [
37,
32
] | python | en | ['en', 'cs', 'en'] | True |
MockOption._get_child_mock | (self, **kw) | Create child mocks with right MagicMock class. | Create child mocks with right MagicMock class. | def _get_child_mock(self, **kw):
"""Create child mocks with right MagicMock class."""
return MagicMock(**kw) | [
"def",
"_get_child_mock",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"return",
"MagicMock",
"(",
"*",
"*",
"kw",
")"
] | [
39,
4
] | [
41,
30
] | python | en | ['en', 'en', 'en'] | True |
MockNetwork.__init__ | (self, options=None, *args, **kwargs) | Initialize a Z-Wave mock network. | Initialize a Z-Wave mock network. | def __init__(self, options=None, *args, **kwargs):
"""Initialize a Z-Wave mock network."""
super().__init__()
self.options = options
self.state = MockNetwork.STATE_STOPPED | [
"def",
"__init__",
"(",
"self",
",",
"options",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"options",
"=",
"options",
"self",
".",
"state",
"=",
"MockNetwork",
".",
... | [
95,
4
] | [
99,
46
] | python | en | ['en', 'cs', 'en'] | True |
MockNode.__init__ | (
self,
*,
node_id=567,
name="Mock Node",
manufacturer_id="ABCD",
product_id="123",
product_type="678",
command_classes=None,
can_wake_up_value=True,
manufacturer_name="Test Manufacturer",
product_name="Test Product",
networ... | Initialize a Z-Wave mock node. | Initialize a Z-Wave mock node. | def __init__(
self,
*,
node_id=567,
name="Mock Node",
manufacturer_id="ABCD",
product_id="123",
product_type="678",
command_classes=None,
can_wake_up_value=True,
manufacturer_name="Test Manufacturer",
product_name="Test Product",
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"node_id",
"=",
"567",
",",
"name",
"=",
"\"Mock Node\"",
",",
"manufacturer_id",
"=",
"\"ABCD\"",
",",
"product_id",
"=",
"\"123\"",
",",
"product_type",
"=",
"\"678\"",
",",
"command_classes",
"=",
"None",
"... | [
105,
4
] | [
134,
55
] | python | cs | ['en', 'cs', 'it'] | False |
MockNode.has_command_class | (self, command_class) | Test if mock has a command class. | Test if mock has a command class. | def has_command_class(self, command_class):
"""Test if mock has a command class."""
return command_class in self._command_classes | [
"def",
"has_command_class",
"(",
"self",
",",
"command_class",
")",
":",
"return",
"command_class",
"in",
"self",
".",
"_command_classes"
] | [
136,
4
] | [
138,
53
] | python | en | ['en', 'en', 'en'] | True |
MockNode.get_battery_level | (self) | Return mock battery level. | Return mock battery level. | def get_battery_level(self):
"""Return mock battery level."""
return 42 | [
"def",
"get_battery_level",
"(",
"self",
")",
":",
"return",
"42"
] | [
140,
4
] | [
142,
17
] | python | en | ['en', 'no', 'en'] | True |
MockNode.can_wake_up | (self) | Return whether the node can wake up. | Return whether the node can wake up. | def can_wake_up(self):
"""Return whether the node can wake up."""
return self.can_wake_up_value | [
"def",
"can_wake_up",
"(",
"self",
")",
":",
"return",
"self",
".",
"can_wake_up_value"
] | [
144,
4
] | [
146,
37
] | python | en | ['en', 'en', 'en'] | True |
MockNode._get_child_mock | (self, **kw) | Create child mocks with right MagicMock class. | Create child mocks with right MagicMock class. | def _get_child_mock(self, **kw):
"""Create child mocks with right MagicMock class."""
return MagicMock(**kw) | [
"def",
"_get_child_mock",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"return",
"MagicMock",
"(",
"*",
"*",
"kw",
")"
] | [
148,
4
] | [
150,
30
] | python | en | ['en', 'en', 'en'] | True |
MockValue.__init__ | (
self,
*,
label="Mock Value",
node=None,
instance=0,
index=0,
value_id=None,
**kwargs,
) | Initialize a Z-Wave mock value. | Initialize a Z-Wave mock value. | def __init__(
self,
*,
label="Mock Value",
node=None,
instance=0,
index=0,
value_id=None,
**kwargs,
):
"""Initialize a Z-Wave mock value."""
super().__init__()
self.label = label
self.node = node
self.instance = ... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"label",
"=",
"\"Mock Value\"",
",",
"node",
"=",
"None",
",",
"instance",
"=",
"0",
",",
"index",
"=",
"0",
",",
"value_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
",",
")",
":",
"super",
"(",
")",
... | [
158,
4
] | [
180,
55
] | python | en | ['en', 'cs', 'en'] | True |
MockValue._get_child_mock | (self, **kw) | Create child mocks with right MagicMock class. | Create child mocks with right MagicMock class. | def _get_child_mock(self, **kw):
"""Create child mocks with right MagicMock class."""
return MagicMock(**kw) | [
"def",
"_get_child_mock",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"return",
"MagicMock",
"(",
"*",
"*",
"kw",
")"
] | [
182,
4
] | [
184,
30
] | python | en | ['en', 'en', 'en'] | True |
MockValue.refresh | (self) | Mock refresh of node value. | Mock refresh of node value. | def refresh(self):
"""Mock refresh of node value."""
value_changed(self) | [
"def",
"refresh",
"(",
"self",
")",
":",
"value_changed",
"(",
"self",
")"
] | [
186,
4
] | [
188,
27
] | python | en | ['en', 'da', 'en'] | True |
MockEntityValues.__init__ | (self, **kwargs) | Initialize the mock zwave values. | Initialize the mock zwave values. | def __init__(self, **kwargs):
"""Initialize the mock zwave values."""
self.primary = None
self.wakeup = None
self.battery = None
self.power = None
for name in kwargs:
setattr(self, name, kwargs[name]) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"primary",
"=",
"None",
"self",
".",
"wakeup",
"=",
"None",
"self",
".",
"battery",
"=",
"None",
"self",
".",
"power",
"=",
"None",
"for",
"name",
"in",
"kwargs",
":",
... | [
194,
4
] | [
201,
45
] | python | en | ['en', 'en', 'en'] | True |
MockEntityValues.__iter__ | (self) | Allow iteration over all values. | Allow iteration over all values. | def __iter__(self):
"""Allow iteration over all values."""
return iter(self.__dict__.values()) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"__dict__",
".",
"values",
"(",
")",
")"
] | [
203,
4
] | [
205,
43
] | python | en | ['en', 'en', 'en'] | True |
mock_client | () | Mock APIClient. | Mock APIClient. | def mock_client():
"""Mock APIClient."""
with patch("homeassistant.components.esphome.config_flow.APIClient") as mock_client:
def mock_constructor(loop, host, port, password, zeroconf_instance=None):
"""Fake the client constructor."""
mock_client.host = host
mock_cli... | [
"def",
"mock_client",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.esphome.config_flow.APIClient\"",
")",
"as",
"mock_client",
":",
"def",
"mock_constructor",
"(",
"loop",
",",
"host",
",",
"port",
",",
"password",
",",
"zeroconf_instance",
"=",
... | [
20,
0
] | [
36,
25
] | python | en | ['en', 'fr', 'en'] | False |
mock_api_connection_error | () | Mock out the try login method. | Mock out the try login method. | def mock_api_connection_error():
"""Mock out the try login method."""
with patch(
"homeassistant.components.esphome.config_flow.APIConnectionError",
new_callable=lambda: OSError,
) as mock_error:
yield mock_error | [
"def",
"mock_api_connection_error",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.esphome.config_flow.APIConnectionError\"",
",",
"new_callable",
"=",
"lambda",
":",
"OSError",
",",
")",
"as",
"mock_error",
":",
"yield",
"mock_error"
] | [
40,
0
] | [
46,
24
] | python | en | ['en', 'en', 'en'] | True |
test_user_connection_works | (hass, mock_client) | Test we can finish a config flow. | Test we can finish a config flow. | async def test_user_connection_works(hass, mock_client):
"""Test we can finish a config flow."""
result = await hass.config_entries.flow.async_init(
"esphome",
context={"source": "user"},
data=None,
)
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "use... | [
"async",
"def",
"test_user_connection_works",
"(",
"hass",
",",
"mock_client",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"\"esphome\"",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"user\"",
"}",
... | [
49,
0
] | [
77,
37
] | python | en | ['en', 'en', 'en'] | True |
test_user_resolve_error | (hass, mock_api_connection_error, mock_client) | Test user step with IP resolve error. | Test user step with IP resolve error. | async def test_user_resolve_error(hass, mock_api_connection_error, mock_client):
"""Test user step with IP resolve error."""
class MockResolveError(mock_api_connection_error):
"""Create an exception with a specific error message."""
def __init__(self):
"""Initialize."""
... | [
"async",
"def",
"test_user_resolve_error",
"(",
"hass",
",",
"mock_api_connection_error",
",",
"mock_client",
")",
":",
"class",
"MockResolveError",
"(",
"mock_api_connection_error",
")",
":",
"\"\"\"Create an exception with a specific error message.\"\"\"",
"def",
"__init__",
... | [
80,
0
] | [
107,
54
] | python | en | ['en', 'de', 'en'] | True |
test_user_connection_error | (hass, mock_api_connection_error, mock_client) | Test user step with connection error. | Test user step with connection error. | async def test_user_connection_error(hass, mock_api_connection_error, mock_client):
"""Test user step with connection error."""
mock_client.device_info.side_effect = mock_api_connection_error
result = await hass.config_entries.flow.async_init(
"esphome",
context={"source": "user"},
... | [
"async",
"def",
"test_user_connection_error",
"(",
"hass",
",",
"mock_api_connection_error",
",",
"mock_client",
")",
":",
"mock_client",
".",
"device_info",
".",
"side_effect",
"=",
"mock_api_connection_error",
"result",
"=",
"await",
"hass",
".",
"config_entries",
"... | [
110,
0
] | [
126,
54
] | python | en | ['en', 'en', 'en'] | True |
test_user_with_password | (hass, mock_client) | Test user step with password. | Test user step with password. | async def test_user_with_password(hass, mock_client):
"""Test user step with password."""
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(True, "test"))
result = await hass.config_entries.flow.async_init(
"esphome",
context={"source": "user"},
data={CONF_HOST: "127.0... | [
"async",
"def",
"test_user_with_password",
"(",
"hass",
",",
"mock_client",
")",
":",
"mock_client",
".",
"device_info",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"MockDeviceInfo",
"(",
"True",
",",
"\"test\"",
")",
")",
"result",
"=",
"await",
"hass",
".",
... | [
129,
0
] | [
152,
46
] | python | en | ['en', 'en', 'en'] | True |
test_user_invalid_password | (hass, mock_api_connection_error, mock_client) | Test user step with invalid password. | Test user step with invalid password. | async def test_user_invalid_password(hass, mock_api_connection_error, mock_client):
"""Test user step with invalid password."""
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(True, "test"))
result = await hass.config_entries.flow.async_init(
"esphome",
context={"source": "u... | [
"async",
"def",
"test_user_invalid_password",
"(",
"hass",
",",
"mock_api_connection_error",
",",
"mock_client",
")",
":",
"mock_client",
".",
"device_info",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"MockDeviceInfo",
"(",
"True",
",",
"\"test\"",
")",
")",
"res... | [
155,
0
] | [
176,
55
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_initiation | (hass, mock_client) | Test discovery importing works. | Test discovery importing works. | async def test_discovery_initiation(hass, mock_client):
"""Test discovery importing works."""
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(False, "test8266"))
service_info = {
"host": "192.168.43.183",
"port": 6053,
"hostname": "test8266.local.",
"properti... | [
"async",
"def",
"test_discovery_initiation",
"(",
"hass",
",",
"mock_client",
")",
":",
"mock_client",
".",
"device_info",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"MockDeviceInfo",
"(",
"False",
",",
"\"test8266\"",
")",
")",
"service_info",
"=",
"{",
"\"hos... | [
179,
0
] | [
203,
51
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_already_configured_hostname | (hass, mock_client) | Test discovery aborts if already configured via hostname. | Test discovery aborts if already configured via hostname. | async def test_discovery_already_configured_hostname(hass, mock_client):
"""Test discovery aborts if already configured via hostname."""
entry = MockConfigEntry(
domain="esphome",
data={CONF_HOST: "test8266.local", CONF_PORT: 6053, CONF_PASSWORD: ""},
)
entry.add_to_hass(hass)
serv... | [
"async",
"def",
"test_discovery_already_configured_hostname",
"(",
"hass",
",",
"mock_client",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"esphome\"",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"test8266.local\"",
",",
"CONF_PORT",
":",
"6053... | [
206,
0
] | [
228,
40
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_already_configured_ip | (hass, mock_client) | Test discovery aborts if already configured via static IP. | Test discovery aborts if already configured via static IP. | async def test_discovery_already_configured_ip(hass, mock_client):
"""Test discovery aborts if already configured via static IP."""
entry = MockConfigEntry(
domain="esphome",
data={CONF_HOST: "192.168.43.183", CONF_PORT: 6053, CONF_PASSWORD: ""},
)
entry.add_to_hass(hass)
service_i... | [
"async",
"def",
"test_discovery_already_configured_ip",
"(",
"hass",
",",
"mock_client",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"esphome\"",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"192.168.43.183\"",
",",
"CONF_PORT",
":",
"6053",
"... | [
231,
0
] | [
253,
40
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_already_configured_name | (hass, mock_client) | Test discovery aborts if already configured via name. | Test discovery aborts if already configured via name. | async def test_discovery_already_configured_name(hass, mock_client):
"""Test discovery aborts if already configured via name."""
entry = MockConfigEntry(
domain="esphome",
data={CONF_HOST: "192.168.43.183", CONF_PORT: 6053, CONF_PASSWORD: ""},
)
entry.add_to_hass(hass)
mock_entry_da... | [
"async",
"def",
"test_discovery_already_configured_name",
"(",
"hass",
",",
"mock_client",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"esphome\"",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"192.168.43.183\"",
",",
"CONF_PORT",
":",
"6053",
... | [
256,
0
] | [
282,
52
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_duplicate_data | (hass, mock_client) | Test discovery aborts if same mDNS packet arrives. | Test discovery aborts if same mDNS packet arrives. | async def test_discovery_duplicate_data(hass, mock_client):
"""Test discovery aborts if same mDNS packet arrives."""
service_info = {
"host": "192.168.43.183",
"port": 6053,
"hostname": "test8266.local.",
"properties": {"address": "test8266.local"},
}
mock_client.device_... | [
"async",
"def",
"test_discovery_duplicate_data",
"(",
"hass",
",",
"mock_client",
")",
":",
"service_info",
"=",
"{",
"\"host\"",
":",
"\"192.168.43.183\"",
",",
"\"port\"",
":",
"6053",
",",
"\"hostname\"",
":",
"\"test8266.local.\"",
",",
"\"properties\"",
":",
... | [
285,
0
] | [
306,
52
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_updates_unique_id | (hass, mock_client) | Test a duplicate discovery host aborts and updates existing entry. | Test a duplicate discovery host aborts and updates existing entry. | async def test_discovery_updates_unique_id(hass, mock_client):
"""Test a duplicate discovery host aborts and updates existing entry."""
entry = MockConfigEntry(
domain="esphome",
data={CONF_HOST: "192.168.43.183", CONF_PORT: 6053, CONF_PASSWORD: ""},
)
entry.add_to_hass(hass)
servi... | [
"async",
"def",
"test_discovery_updates_unique_id",
"(",
"hass",
",",
"mock_client",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"esphome\"",
",",
"data",
"=",
"{",
"CONF_HOST",
":",
"\"192.168.43.183\"",
",",
"CONF_PORT",
":",
"6053",
",",
... | [
309,
0
] | [
331,
40
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the IOTA component. | Set up the IOTA component. | def setup(hass, config):
"""Set up the IOTA component."""
iota_config = config[DOMAIN]
for platform in IOTA_PLATFORMS:
load_platform(hass, platform, DOMAIN, iota_config, config)
return True | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"iota_config",
"=",
"config",
"[",
"DOMAIN",
"]",
"for",
"platform",
"in",
"IOTA_PLATFORMS",
":",
"load_platform",
"(",
"hass",
",",
"platform",
",",
"DOMAIN",
",",
"iota_config",
",",
"config",
")",
... | [
43,
0
] | [
50,
15
] | python | en | ['en', 'sr', 'en'] | True |
IotaDevice.__init__ | (self, name, seed, iri, is_testnet=False) | Initialise the IOTA device. | Initialise the IOTA device. | def __init__(self, name, seed, iri, is_testnet=False):
"""Initialise the IOTA device."""
self._name = name
self._seed = seed
self.iri = iri
self.is_testnet = is_testnet | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"seed",
",",
"iri",
",",
"is_testnet",
"=",
"False",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_seed",
"=",
"seed",
"self",
".",
"iri",
"=",
"iri",
"self",
".",
"is_testnet",
"=",
... | [
56,
4
] | [
61,
36
] | python | en | ['en', 'sr', 'en'] | True |
IotaDevice.name | (self) | Return the default name of the device. | Return the default name of the device. | def name(self):
"""Return the default name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
64,
4
] | [
66,
25
] | python | en | ['en', 'en', 'en'] | True |
IotaDevice.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
return {CONF_WALLET_NAME: self._name} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"CONF_WALLET_NAME",
":",
"self",
".",
"_name",
"}"
] | [
69,
4
] | [
71,
45
] | python | en | ['en', 'en', 'en'] | True |
IotaDevice.api | (self) | Construct API object for interaction with the IRI node. | Construct API object for interaction with the IRI node. | def api(self):
"""Construct API object for interaction with the IRI node."""
return Iota(adapter=self.iri, seed=self._seed) | [
"def",
"api",
"(",
"self",
")",
":",
"return",
"Iota",
"(",
"adapter",
"=",
"self",
".",
"iri",
",",
"seed",
"=",
"self",
".",
"_seed",
")"
] | [
74,
4
] | [
77,
54
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler._create_entry | (self, username: str, token: str) | Register new entry. | Register new entry. | async def _create_entry(self, username: str, token: str):
"""Register new entry."""
await self.async_set_unique_id(username)
self._abort_if_unique_id_configured({CONF_TOKEN: token})
return self.async_create_entry(
title=username, data={CONF_USERNAME: username, CONF_TOKEN: tok... | [
"async",
"def",
"_create_entry",
"(",
"self",
",",
"username",
":",
"str",
",",
"token",
":",
"str",
")",
":",
"await",
"self",
".",
"async_set_unique_id",
"(",
"username",
")",
"self",
".",
"_abort_if_unique_id_configured",
"(",
"{",
"CONF_TOKEN",
":",
"tok... | [
27,
4
] | [
33,
9
] | python | en | ['en', 'no', 'en'] | True |
FlowHandler._create_client | (
self,
username: str,
*,
password: Optional[str] = None,
token: Optional[str] = None,
) | Create client. | Create client. | async def _create_client(
self,
username: str,
*,
password: Optional[str] = None,
token: Optional[str] = None,
):
"""Create client."""
if password is None and token is None:
raise ValueError(
"Invalid internal state. Called without ... | [
"async",
"def",
"_create_client",
"(",
"self",
",",
"username",
":",
"str",
",",
"*",
",",
"password",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"token",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
":",
"if",
"password",
"is"... | [
35,
4
] | [
68,
65
] | python | en | ['en', 'la', 'en'] | False |
FlowHandler.async_step_user | (self, user_input=None) | User initiated config flow. | User initiated config flow. | async def async_step_user(self, user_input=None):
"""User initiated config flow."""
if user_input is None:
return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): ... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
... | [
70,
4
] | [
80,
86
] | python | en | ['en', 'en', 'en'] | True |
FlowHandler.async_step_import | (self, user_input) | Import a config entry. | Import a config entry. | async def async_step_import(self, user_input):
"""Import a config entry."""
return await self._create_client(
user_input[CONF_USERNAME], token=user_input[CONF_TOKEN]
) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"return",
"await",
"self",
".",
"_create_client",
"(",
"user_input",
"[",
"CONF_USERNAME",
"]",
",",
"token",
"=",
"user_input",
"[",
"CONF_TOKEN",
"]",
")"
] | [
82,
4
] | [
86,
9
] | python | en | ['en', 'en', 'en'] | True |
get_split | (split_name, dataset_dir, file_pattern=None, reader=None) | Gets a dataset tuple with instructions for reading ImageNet.
Args:
split_name: A train/test split name.
dataset_dir: The base directory of the dataset sources.
file_pattern: The file pattern to use when matching the dataset sources. It
is assumed that the pattern contains a '%s' string so that the ... | Gets a dataset tuple with instructions for reading ImageNet. | def get_split(split_name, dataset_dir, file_pattern=None, reader=None):
"""Gets a dataset tuple with instructions for reading ImageNet.
Args:
split_name: A train/test split name.
dataset_dir: The base directory of the dataset sources.
file_pattern: The file pattern to use when matching the dataset sour... | [
"def",
"get_split",
"(",
"split_name",
",",
"dataset_dir",
",",
"file_pattern",
"=",
"None",
",",
"reader",
"=",
"None",
")",
":",
"if",
"split_name",
"not",
"in",
"_SPLITS_TO_SIZES",
":",
"raise",
"ValueError",
"(",
"'split name %s was not recognized.'",
"%",
"... | [
58,
0
] | [
128,
38
] | python | en | ['en', 'en', 'en'] | True |
mock_finish_setup | () | Mock out the finish setup method. | Mock out the finish setup method. | def mock_finish_setup():
"""Mock out the finish setup method."""
with patch(
"homeassistant.components.mqtt.MQTT.async_connect", return_value=True
) as mock_finish:
yield mock_finish | [
"def",
"mock_finish_setup",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.mqtt.MQTT.async_connect\"",
",",
"return_value",
"=",
"True",
")",
"as",
"mock_finish",
":",
"yield",
"mock_finish"
] | [
14,
0
] | [
19,
25
] | python | en | ['en', 'zu', 'en'] | True |
mock_try_connection | () | Mock the try connection method. | Mock the try connection method. | def mock_try_connection():
"""Mock the try connection method."""
with patch("homeassistant.components.mqtt.config_flow.try_connection") as mock_try:
yield mock_try | [
"def",
"mock_try_connection",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.mqtt.config_flow.try_connection\"",
")",
"as",
"mock_try",
":",
"yield",
"mock_try"
] | [
23,
0
] | [
26,
22
] | python | en | ['en', 'en', 'en'] | True |
test_user_connection_works | (hass, mock_try_connection, mock_finish_setup) | Test we can finish a config flow. | Test we can finish a config flow. | async def test_user_connection_works(hass, mock_try_connection, mock_finish_setup):
"""Test we can finish a config flow."""
mock_try_connection.return_value = True
result = await hass.config_entries.flow.async_init(
"mqtt", context={"source": "user"}
)
assert result["type"] == "form"
r... | [
"async",
"def",
"test_user_connection_works",
"(",
"hass",
",",
"mock_try_connection",
",",
"mock_finish_setup",
")",
":",
"mock_try_connection",
".",
"return_value",
"=",
"True",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",... | [
29,
0
] | [
51,
49
] | python | en | ['en', 'en', 'en'] | True |
test_user_connection_fails | (hass, mock_try_connection, mock_finish_setup) | Test if connection cannot be made. | Test if connection cannot be made. | async def test_user_connection_fails(hass, mock_try_connection, mock_finish_setup):
"""Test if connection cannot be made."""
mock_try_connection.return_value = False
result = await hass.config_entries.flow.async_init(
"mqtt", context={"source": "user"}
)
assert result["type"] == "form"
... | [
"async",
"def",
"test_user_connection_fails",
"(",
"hass",
",",
"mock_try_connection",
",",
"mock_finish_setup",
")",
":",
"mock_try_connection",
".",
"return_value",
"=",
"False",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init"... | [
54,
0
] | [
73,
49
] | python | en | ['en', 'en', 'en'] | True |
test_manual_config_set | (hass, mock_try_connection, mock_finish_setup) | Test we ignore entry if manual config available. | Test we ignore entry if manual config available. | async def test_manual_config_set(hass, mock_try_connection, mock_finish_setup):
"""Test we ignore entry if manual config available."""
assert await async_setup_component(hass, "mqtt", {"mqtt": {"broker": "bla"}})
await hass.async_block_till_done()
assert len(mock_finish_setup.mock_calls) == 1
mock_... | [
"async",
"def",
"test_manual_config_set",
"(",
"hass",
",",
"mock_try_connection",
",",
"mock_finish_setup",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"mqtt\"",
",",
"{",
"\"mqtt\"",
":",
"{",
"\"broker\"",
":",
"\"bla\"",
"}",
"}... | [
76,
0
] | [
87,
36
] | python | en | ['en', 'en', 'en'] | True |
test_user_single_instance | (hass) | Test we only allow a single config flow. | Test we only allow a single config flow. | async def test_user_single_instance(hass):
"""Test we only allow a single config flow."""
MockConfigEntry(domain="mqtt").add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
"mqtt", context={"source": "user"}
)
assert result["type"] == "abort"
assert result["reason"] ==... | [
"async",
"def",
"test_user_single_instance",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"mqtt\"",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"\"m... | [
90,
0
] | [
98,
56
] | python | en | ['en', 'en', 'en'] | True |
test_hassio_single_instance | (hass) | Test we only allow a single config flow. | Test we only allow a single config flow. | async def test_hassio_single_instance(hass):
"""Test we only allow a single config flow."""
MockConfigEntry(domain="mqtt").add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
"mqtt", context={"source": "hassio"}
)
assert result["type"] == "abort"
assert result["reason"... | [
"async",
"def",
"test_hassio_single_instance",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"mqtt\"",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"\... | [
101,
0
] | [
109,
56
] | python | en | ['en', 'en', 'en'] | True |
test_hassio_confirm | (hass, mock_try_connection, mock_finish_setup) | Test we can finish a config flow. | Test we can finish a config flow. | async def test_hassio_confirm(hass, mock_try_connection, mock_finish_setup):
"""Test we can finish a config flow."""
mock_try_connection.return_value = True
result = await hass.config_entries.flow.async_init(
"mqtt",
data={
"addon": "Mock Addon",
"host": "mock-broker... | [
"async",
"def",
"test_hassio_confirm",
"(",
"hass",
",",
"mock_try_connection",
",",
"mock_finish_setup",
")",
":",
"mock_try_connection",
".",
"return_value",
"=",
"True",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",... | [
112,
0
] | [
148,
49
] | python | en | ['en', 'en', 'en'] | True |
test_option_flow | (hass, mqtt_mock, mock_try_connection) | Test config flow options. | Test config flow options. | async def test_option_flow(hass, mqtt_mock, mock_try_connection):
"""Test config flow options."""
mock_try_connection.return_value = True
config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
config_entry.data = {
mqtt.CONF_BROKER: "test-broker",
mqtt.CONF_PORT: 1234,
}
... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
",",
"mqtt_mock",
",",
"mock_try_connection",
")",
":",
"mock_try_connection",
".",
"return_value",
"=",
"True",
"config_entry",
"=",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"mqtt",
".",
"DOMAIN",
... | [
151,
0
] | [
220,
50
] | python | en | ['en', 'fr', 'en'] | True |
test_disable_birth_will | (hass, mqtt_mock, mock_try_connection) | Test disabling birth and will. | Test disabling birth and will. | async def test_disable_birth_will(hass, mqtt_mock, mock_try_connection):
"""Test disabling birth and will."""
mock_try_connection.return_value = True
config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
config_entry.data = {
mqtt.CONF_BROKER: "test-broker",
mqtt.CONF_PORT: 12... | [
"async",
"def",
"test_disable_birth_will",
"(",
"hass",
",",
"mqtt_mock",
",",
"mock_try_connection",
")",
":",
"mock_try_connection",
".",
"return_value",
"=",
"True",
"config_entry",
"=",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"mqtt",
".",
"DO... | [
223,
0
] | [
282,
50
] | python | en | ['en', 'en', 'en'] | True |
get_default | (schema, key) | Get default value for key in voluptuous schema. | Get default value for key in voluptuous schema. | def get_default(schema, key):
"""Get default value for key in voluptuous schema."""
for k in schema.keys():
if k == key:
if k.default == vol.UNDEFINED:
return None
return k.default() | [
"def",
"get_default",
"(",
"schema",
",",
"key",
")",
":",
"for",
"k",
"in",
"schema",
".",
"keys",
"(",
")",
":",
"if",
"k",
"==",
"key",
":",
"if",
"k",
".",
"default",
"==",
"vol",
".",
"UNDEFINED",
":",
"return",
"None",
"return",
"k",
".",
... | [
285,
0
] | [
291,
30
] | python | de | ['nl', 'de', 'en'] | False |
get_suggested | (schema, key) | Get suggested value for key in voluptuous schema. | Get suggested value for key in voluptuous schema. | def get_suggested(schema, key):
"""Get suggested value for key in voluptuous schema."""
for k in schema.keys():
if k == key:
if k.description is None or "suggested_value" not in k.description:
return None
return k.description["suggested_value"] | [
"def",
"get_suggested",
"(",
"schema",
",",
"key",
")",
":",
"for",
"k",
"in",
"schema",
".",
"keys",
"(",
")",
":",
"if",
"k",
"==",
"key",
":",
"if",
"k",
".",
"description",
"is",
"None",
"or",
"\"suggested_value\"",
"not",
"in",
"k",
".",
"desc... | [
294,
0
] | [
300,
51
] | python | en | ['en', 'en', 'en'] | True |
test_option_flow_default_suggested_values | (
hass, mqtt_mock, mock_try_connection
) | Test config flow options has default/suggested values. | Test config flow options has default/suggested values. | async def test_option_flow_default_suggested_values(
hass, mqtt_mock, mock_try_connection
):
"""Test config flow options has default/suggested values."""
mock_try_connection.return_value = True
config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
config_entry.data = {
mqtt.CONF_B... | [
"async",
"def",
"test_option_flow_default_suggested_values",
"(",
"hass",
",",
"mqtt_mock",
",",
"mock_try_connection",
")",
":",
"mock_try_connection",
".",
"return_value",
"=",
"True",
"config_entry",
"=",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"m... | [
303,
0
] | [
446,
69
] | python | en | ['en', 'en', 'en'] | True |
test_options_user_connection_fails | (hass, mock_try_connection) | Test if connection cannot be made. | Test if connection cannot be made. | async def test_options_user_connection_fails(hass, mock_try_connection):
"""Test if connection cannot be made."""
config_entry = MockConfigEntry(domain=mqtt.DOMAIN)
config_entry.add_to_hass(hass)
config_entry.data = {
mqtt.CONF_BROKER: "test-broker",
mqtt.CONF_PORT: 1234,
}
mock... | [
"async",
"def",
"test_options_user_connection_fails",
"(",
"hass",
",",
"mock_try_connection",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"mqtt",
".",
"DOMAIN",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"config_entry",
"... | [
449,
0
] | [
477,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_bad_birth_message_fails | (hass, mock_try_connection) | Test bad birth message. | Test bad birth message. | async def test_options_bad_birth_message_fails(hass, mock_try_connection):
"""Test bad birth message."""
config_entry = MockConfigEntry(domain=mqtt.DOMAIN)
config_entry.add_to_hass(hass)
config_entry.data = {
mqtt.CONF_BROKER: "test-broker",
mqtt.CONF_PORT: 1234,
}
mock_try_conn... | [
"async",
"def",
"test_options_bad_birth_message_fails",
"(",
"hass",
",",
"mock_try_connection",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"mqtt",
".",
"DOMAIN",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"config_entry",
... | [
480,
0
] | [
513,
5
] | python | en | ['en', 'de', 'en'] | True |
test_options_bad_will_message_fails | (hass, mock_try_connection) | Test bad will message. | Test bad will message. | async def test_options_bad_will_message_fails(hass, mock_try_connection):
"""Test bad will message."""
config_entry = MockConfigEntry(domain=mqtt.DOMAIN)
config_entry.add_to_hass(hass)
config_entry.data = {
mqtt.CONF_BROKER: "test-broker",
mqtt.CONF_PORT: 1234,
}
mock_try_connec... | [
"async",
"def",
"test_options_bad_will_message_fails",
"(",
"hass",
",",
"mock_try_connection",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"mqtt",
".",
"DOMAIN",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"config_entry",
... | [
516,
0
] | [
549,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Greenwave Reality Platform. | Set up the Greenwave Reality Platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Greenwave Reality Platform."""
host = config.get(CONF_HOST)
tokenfile = hass.config.path(".greenwave")
if config.get(CONF_VERSION) == 3:
if os.path.exists(tokenfile):
with open(tokenfile) as tokenfile:... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"tokenfile",
"=",
"hass",
".",
"config",
".",
"path",
"(",
"\".greenwave\"",
... | [
31,
0
] | [
53,
5
] | python | en | ['en', 'da', 'en'] | True |
GreenwaveLight.__init__ | (self, light, host, token, gatewaydata) | Initialize a Greenwave Reality Light. | Initialize a Greenwave Reality Light. | def __init__(self, light, host, token, gatewaydata):
"""Initialize a Greenwave Reality Light."""
self._did = int(light["did"])
self._name = light["name"]
self._state = int(light["state"])
self._brightness = greenwave.hass_brightness(light)
self._host = host
self._... | [
"def",
"__init__",
"(",
"self",
",",
"light",
",",
"host",
",",
"token",
",",
"gatewaydata",
")",
":",
"self",
".",
"_did",
"=",
"int",
"(",
"light",
"[",
"\"did\"",
"]",
")",
"self",
".",
"_name",
"=",
"light",
"[",
"\"name\"",
"]",
"self",
".",
... | [
59,
4
] | [
68,
39
] | python | en | ['en', 'en', 'en'] | True |
GreenwaveLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORTED_FEATURES | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORTED_FEATURES"
] | [
71,
4
] | [
73,
33
] | python | en | ['da', 'en', 'en'] | True |
GreenwaveLight.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._online | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_online"
] | [
76,
4
] | [
78,
27
] | python | en | ['en', 'en', 'en'] | True |
GreenwaveLight.name | (self) | Return the display name of this light. | Return the display name of this light. | def name(self):
"""Return the display name of this light."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
81,
4
] | [
83,
25
] | python | en | ['en', 'en', 'en'] | True |
GreenwaveLight.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self):
"""Return the brightness of the light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
86,
4
] | [
88,
31
] | python | en | ['en', 'no', 'en'] | True |
GreenwaveLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self):
"""Return true if light is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
91,
4
] | [
93,
26
] | python | en | ['en', 'et', 'en'] | True |
GreenwaveLight.turn_on | (self, **kwargs) | Instruct the light to turn on. | Instruct the light to turn on. | def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
temp_brightness = int((kwargs.get(ATTR_BRIGHTNESS, 255) / 255) * 100)
greenwave.set_brightness(self._host, self._did, temp_brightness, self._token)
greenwave.turn_on(self._host, self._did, self._token) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temp_brightness",
"=",
"int",
"(",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
",",
"255",
")",
"/",
"255",
")",
"*",
"100",
")",
"greenwave",
".",
"set_brightness",
"(",
"self... | [
95,
4
] | [
99,
61
] | python | en | ['en', 'en', 'en'] | True |
GreenwaveLight.turn_off | (self, **kwargs) | Instruct the light to turn off. | Instruct the light to turn off. | def turn_off(self, **kwargs):
"""Instruct the light to turn off."""
greenwave.turn_off(self._host, self._did, self._token) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"greenwave",
".",
"turn_off",
"(",
"self",
".",
"_host",
",",
"self",
".",
"_did",
",",
"self",
".",
"_token",
")"
] | [
101,
4
] | [
103,
62
] | python | en | ['en', 'en', 'en'] | True |
GreenwaveLight.update | (self) | Fetch new state data for this light. | Fetch new state data for this light. | def update(self):
"""Fetch new state data for this light."""
self._gatewaydata.update()
bulbs = self._gatewaydata.greenwave
self._state = int(bulbs[self._did]["state"])
self._brightness = greenwave.hass_brightness(bulbs[self._did])
self._online = greenwave.check_online(b... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_gatewaydata",
".",
"update",
"(",
")",
"bulbs",
"=",
"self",
".",
"_gatewaydata",
".",
"greenwave",
"self",
".",
"_state",
"=",
"int",
"(",
"bulbs",
"[",
"self",
".",
"_did",
"]",
"[",
"\"state\"... | [
105,
4
] | [
113,
45
] | python | en | ['en', 'en', 'en'] | True |
GatewayData.__init__ | (self, host, token) | Initialize the data object. | Initialize the data object. | def __init__(self, host, token):
"""Initialize the data object."""
self._host = host
self._token = token
self._greenwave = greenwave.grab_bulbs(host, token) | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"token",
")",
":",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_token",
"=",
"token",
"self",
".",
"_greenwave",
"=",
"greenwave",
".",
"grab_bulbs",
"(",
"host",
",",
"token",
")"
] | [
119,
4
] | [
123,
59
] | python | en | ['en', 'en', 'en'] | True |
GatewayData.greenwave | (self) | Return Gateway API object. | Return Gateway API object. | def greenwave(self):
"""Return Gateway API object."""
return self._greenwave | [
"def",
"greenwave",
"(",
"self",
")",
":",
"return",
"self",
".",
"_greenwave"
] | [
126,
4
] | [
128,
30
] | python | en | ['en', 'pl', 'en'] | True |
GatewayData.update | (self) | Get the latest data from the gateway. | Get the latest data from the gateway. | def update(self):
"""Get the latest data from the gateway."""
self._greenwave = greenwave.grab_bulbs(self._host, self._token)
return self._greenwave | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_greenwave",
"=",
"greenwave",
".",
"grab_bulbs",
"(",
"self",
".",
"_host",
",",
"self",
".",
"_token",
")",
"return",
"self",
".",
"_greenwave"
] | [
131,
4
] | [
134,
30
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Add binary sensors for a config entry. | Add binary sensors for a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add binary sensors for a config entry."""
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
sensors = []
for device in broker.devices.values():
for capability in broker.get_assigned(device.device_id, "binary_se... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"broker",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_BROKERS",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"sensors",
"=",
"[",
"]... | [
43,
0
] | [
51,
31
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.