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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
CmusDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
99,
4
] | [
101,
25
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.state | (self) | Return the media state. | Return the media state. | def state(self):
"""Return the media state."""
if self.status.get("status") == "playing":
return STATE_PLAYING
if self.status.get("status") == "paused":
return STATE_PAUSED
return STATE_OFF | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
".",
"get",
"(",
"\"status\"",
")",
"==",
"\"playing\"",
":",
"return",
"STATE_PLAYING",
"if",
"self",
".",
"status",
".",
"get",
"(",
"\"status\"",
")",
"==",
"\"paused\"",
":",
"retu... | [
104,
4
] | [
110,
24
] | python | en | ['en', 'ig', 'en'] | True |
CmusDevice.media_content_id | (self) | Content ID of current playing media. | Content ID of current playing media. | def media_content_id(self):
"""Content ID of current playing media."""
return self.status.get("file") | [
"def",
"media_content_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
".",
"get",
"(",
"\"file\"",
")"
] | [
113,
4
] | [
115,
38
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.content_type | (self) | Content type of the current playing media. | Content type of the current playing media. | def content_type(self):
"""Content type of the current playing media."""
return MEDIA_TYPE_MUSIC | [
"def",
"content_type",
"(",
"self",
")",
":",
"return",
"MEDIA_TYPE_MUSIC"
] | [
118,
4
] | [
120,
31
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_duration | (self) | Duration of current playing media in seconds. | Duration of current playing media in seconds. | def media_duration(self):
"""Duration of current playing media in seconds."""
return self.status.get("duration") | [
"def",
"media_duration",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
".",
"get",
"(",
"\"duration\"",
")"
] | [
123,
4
] | [
125,
42
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_title | (self) | Title of current playing media. | Title of current playing media. | def media_title(self):
"""Title of current playing media."""
return self.status["tag"].get("title") | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"[",
"\"tag\"",
"]",
".",
"get",
"(",
"\"title\"",
")"
] | [
128,
4
] | [
130,
46
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_artist | (self) | Artist of current playing media, music track only. | Artist of current playing media, music track only. | def media_artist(self):
"""Artist of current playing media, music track only."""
return self.status["tag"].get("artist") | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"[",
"\"tag\"",
"]",
".",
"get",
"(",
"\"artist\"",
")"
] | [
133,
4
] | [
135,
47
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_track | (self) | Track number of current playing media, music track only. | Track number of current playing media, music track only. | def media_track(self):
"""Track number of current playing media, music track only."""
return self.status["tag"].get("tracknumber") | [
"def",
"media_track",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"[",
"\"tag\"",
"]",
".",
"get",
"(",
"\"tracknumber\"",
")"
] | [
138,
4
] | [
140,
52
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_album_name | (self) | Album name of current playing media, music track only. | Album name of current playing media, music track only. | def media_album_name(self):
"""Album name of current playing media, music track only."""
return self.status["tag"].get("album") | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"[",
"\"tag\"",
"]",
".",
"get",
"(",
"\"album\"",
")"
] | [
143,
4
] | [
145,
46
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_album_artist | (self) | Album artist of current playing media, music track only. | Album artist of current playing media, music track only. | def media_album_artist(self):
"""Album artist of current playing media, music track only."""
return self.status["tag"].get("albumartist") | [
"def",
"media_album_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"[",
"\"tag\"",
"]",
".",
"get",
"(",
"\"albumartist\"",
")"
] | [
148,
4
] | [
150,
52
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.volume_level | (self) | Return the volume level. | Return the volume level. | def volume_level(self):
"""Return the volume level."""
left = self.status["set"].get("vol_left")[0]
right = self.status["set"].get("vol_right")[0]
if left != right:
volume = float(left + right) / 2
else:
volume = left
return int(volume) / 100 | [
"def",
"volume_level",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"status",
"[",
"\"set\"",
"]",
".",
"get",
"(",
"\"vol_left\"",
")",
"[",
"0",
"]",
"right",
"=",
"self",
".",
"status",
"[",
"\"set\"",
"]",
".",
"get",
"(",
"\"vol_right\"",
... | [
153,
4
] | [
161,
32
] | python | en | ['en', 'no', 'en'] | True |
CmusDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_CMUS | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_CMUS"
] | [
164,
4
] | [
166,
27
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.turn_off | (self) | Service to send the CMUS the command to stop playing. | Service to send the CMUS the command to stop playing. | def turn_off(self):
"""Service to send the CMUS the command to stop playing."""
self.cmus.player_stop() | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"player_stop",
"(",
")"
] | [
168,
4
] | [
170,
31
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.turn_on | (self) | Service to send the CMUS the command to start playing. | Service to send the CMUS the command to start playing. | def turn_on(self):
"""Service to send the CMUS the command to start playing."""
self.cmus.player_play() | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"player_play",
"(",
")"
] | [
172,
4
] | [
174,
31
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
self.cmus.set_volume(int(volume * 100)) | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"self",
".",
"cmus",
".",
"set_volume",
"(",
"int",
"(",
"volume",
"*",
"100",
")",
")"
] | [
176,
4
] | [
178,
47
] | python | en | ['fr', 'zu', 'en'] | False |
CmusDevice.volume_up | (self) | Set the volume up. | Set the volume up. | def volume_up(self):
"""Set the volume up."""
left = self.status["set"].get("vol_left")
right = self.status["set"].get("vol_right")
if left != right:
current_volume = float(left + right) / 2
else:
current_volume = left
if current_volume <= 100:
... | [
"def",
"volume_up",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"status",
"[",
"\"set\"",
"]",
".",
"get",
"(",
"\"vol_left\"",
")",
"right",
"=",
"self",
".",
"status",
"[",
"\"set\"",
"]",
".",
"get",
"(",
"\"vol_right\"",
")",
"if",
"left",
... | [
180,
4
] | [
190,
57
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.volume_down | (self) | Set the volume down. | Set the volume down. | def volume_down(self):
"""Set the volume down."""
left = self.status["set"].get("vol_left")
right = self.status["set"].get("vol_right")
if left != right:
current_volume = float(left + right) / 2
else:
current_volume = left
if current_volume <= 100... | [
"def",
"volume_down",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"status",
"[",
"\"set\"",
"]",
".",
"get",
"(",
"\"vol_left\"",
")",
"right",
"=",
"self",
".",
"status",
"[",
"\"set\"",
"]",
".",
"get",
"(",
"\"vol_right\"",
")",
"if",
"left",... | [
192,
4
] | [
202,
57
] | python | en | ['en', 'el-Latn', 'en'] | True |
CmusDevice.play_media | (self, media_type, media_id, **kwargs) | Send the play command. | Send the play command. | def play_media(self, media_type, media_id, **kwargs):
"""Send the play command."""
if media_type in [MEDIA_TYPE_MUSIC, MEDIA_TYPE_PLAYLIST]:
self.cmus.player_play_file(media_id)
else:
_LOGGER.error(
"Invalid media type %s. Only %s and %s are supported",
... | [
"def",
"play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"media_type",
"in",
"[",
"MEDIA_TYPE_MUSIC",
",",
"MEDIA_TYPE_PLAYLIST",
"]",
":",
"self",
".",
"cmus",
".",
"player_play_file",
"(",
"media_id",
... | [
204,
4
] | [
214,
13
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_pause | (self) | Send the pause command. | Send the pause command. | def media_pause(self):
"""Send the pause command."""
self.cmus.player_pause() | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"player_pause",
"(",
")"
] | [
216,
4
] | [
218,
32
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_next_track | (self) | Send next track command. | Send next track command. | def media_next_track(self):
"""Send next track command."""
self.cmus.player_next() | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"player_next",
"(",
")"
] | [
220,
4
] | [
222,
31
] | python | en | ['en', 'pt', 'en'] | True |
CmusDevice.media_previous_track | (self) | Send next track command. | Send next track command. | def media_previous_track(self):
"""Send next track command."""
self.cmus.player_prev() | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"player_prev",
"(",
")"
] | [
224,
4
] | [
226,
31
] | python | en | ['en', 'pt', 'en'] | True |
CmusDevice.media_seek | (self, position) | Send seek command. | Send seek command. | def media_seek(self, position):
"""Send seek command."""
self.cmus.seek(position) | [
"def",
"media_seek",
"(",
"self",
",",
"position",
")",
":",
"self",
".",
"cmus",
".",
"seek",
"(",
"position",
")"
] | [
228,
4
] | [
230,
32
] | python | en | ['en', 'ig', 'en'] | True |
CmusDevice.media_play | (self) | Send the play command. | Send the play command. | def media_play(self):
"""Send the play command."""
self.cmus.player_play() | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"player_play",
"(",
")"
] | [
232,
4
] | [
234,
31
] | python | en | ['en', 'en', 'en'] | True |
CmusDevice.media_stop | (self) | Send the stop command. | Send the stop command. | def media_stop(self):
"""Send the stop command."""
self.cmus.stop() | [
"def",
"media_stop",
"(",
"self",
")",
":",
"self",
".",
"cmus",
".",
"stop",
"(",
")"
] | [
236,
4
] | [
238,
24
] | python | en | ['en', 'en', 'en'] | True |
worker | (group_name) |
The main worker logic includes initialize proxy and handle jobs from the master.
Args:
group_name (str): Identifier for the group of all communication components
|
The main worker logic includes initialize proxy and handle jobs from the master. | def worker(group_name):
"""
The main worker logic includes initialize proxy and handle jobs from the master.
Args:
group_name (str): Identifier for the group of all communication components
"""
proxy = Proxy(group_name=group_name,
component_type="worker",
... | [
"def",
"worker",
"(",
"group_name",
")",
":",
"proxy",
"=",
"Proxy",
"(",
"group_name",
"=",
"group_name",
",",
"component_type",
"=",
"\"worker\"",
",",
"expected_peers",
"=",
"{",
"\"master\"",
":",
"1",
"}",
")",
"# Nonrecurring receive the message from the pro... | [
11,
0
] | [
28,
72
] | python | en | ['en', 'error', 'th'] | False |
master | (group_name: str, is_immediate: bool = False) |
The main master logic includes initialize proxy and allocate jobs to workers.
Args:
group_name (str): Identifier for the group of all communication components,
is_immediate (bool): If True, it will be an async mode; otherwise, it will be an sync mode.
Async Mode: The proxy only ret... |
The main master logic includes initialize proxy and allocate jobs to workers. | def master(group_name: str, is_immediate: bool = False):
"""
The main master logic includes initialize proxy and allocate jobs to workers.
Args:
group_name (str): Identifier for the group of all communication components,
is_immediate (bool): If True, it will be an async mode; otherwise, it ... | [
"def",
"master",
"(",
"group_name",
":",
"str",
",",
"is_immediate",
":",
"bool",
"=",
"False",
")",
":",
"proxy",
"=",
"Proxy",
"(",
"group_name",
"=",
"group_name",
",",
"component_type",
"=",
"\"master\"",
",",
"expected_peers",
"=",
"{",
"\"worker\"",
... | [
31,
0
] | [
63,
90
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Verisure Camera. | Set up the Verisure Camera. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Verisure Camera."""
if not int(hub.config.get(CONF_SMARTCAM, 1)):
return False
directory_path = hass.config.config_dir
if not os.access(directory_path, os.R_OK):
_LOGGER.error("file path %s is not readable... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"not",
"int",
"(",
"hub",
".",
"config",
".",
"get",
"(",
"CONF_SMARTCAM",
",",
"1",
")",
")",
":",
"return",
"False",
"direct... | [
13,
0
] | [
29,
27
] | python | en | ['en', 'bs', 'en'] | True |
VerisureSmartcam.__init__ | (self, hass, device_label, directory_path) | Initialize Verisure File Camera component. | Initialize Verisure File Camera component. | def __init__(self, hass, device_label, directory_path):
"""Initialize Verisure File Camera component."""
super().__init__()
self._device_label = device_label
self._directory_path = directory_path
self._image = None
self._image_id = None
hass.bus.listen_once(EVENT... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"device_label",
",",
"directory_path",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_device_label",
"=",
"device_label",
"self",
".",
"_directory_path",
"=",
"directory_path",
"self",... | [
35,
4
] | [
43,
73
] | python | co | ['es', 'co', 'it'] | False |
VerisureSmartcam.camera_image | (self) | Return image response. | Return image response. | def camera_image(self):
"""Return image response."""
self.check_imagelist()
if not self._image:
_LOGGER.debug("No image to display")
return
_LOGGER.debug("Trying to open %s", self._image)
with open(self._image, "rb") as file:
return file.read() | [
"def",
"camera_image",
"(",
"self",
")",
":",
"self",
".",
"check_imagelist",
"(",
")",
"if",
"not",
"self",
".",
"_image",
":",
"_LOGGER",
".",
"debug",
"(",
"\"No image to display\"",
")",
"return",
"_LOGGER",
".",
"debug",
"(",
"\"Trying to open %s\"",
",... | [
45,
4
] | [
53,
30
] | python | en | ['en', 'jv', 'en'] | True |
VerisureSmartcam.check_imagelist | (self) | Check the contents of the image list. | Check the contents of the image list. | def check_imagelist(self):
"""Check the contents of the image list."""
hub.update_smartcam_imageseries()
image_ids = hub.get_image_info(
"$.imageSeries[?(@.deviceLabel=='%s')].image[0].imageId", self._device_label
)
if not image_ids:
return
new_ima... | [
"def",
"check_imagelist",
"(",
"self",
")",
":",
"hub",
".",
"update_smartcam_imageseries",
"(",
")",
"image_ids",
"=",
"hub",
".",
"get_image_info",
"(",
"\"$.imageSeries[?(@.deviceLabel=='%s')].image[0].imageId\"",
",",
"self",
".",
"_device_label",
")",
"if",
"not"... | [
55,
4
] | [
76,
36
] | python | en | ['en', 'en', 'en'] | True |
VerisureSmartcam.delete_image | (self, event) | Delete an old image. | Delete an old image. | def delete_image(self, event):
"""Delete an old image."""
remove_image = os.path.join(
self._directory_path, "{}{}".format(self._image_id, ".jpg")
)
try:
os.remove(remove_image)
_LOGGER.debug("Deleting old image %s", remove_image)
except OSErro... | [
"def",
"delete_image",
"(",
"self",
",",
"event",
")",
":",
"remove_image",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_directory_path",
",",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"_image_id",
",",
"\".jpg\"",
")",
")",
"try",
":",
... | [
78,
4
] | [
88,
21
] | python | en | ['en', 'en', 'en'] | True |
VerisureSmartcam.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self):
"""Return the name of this camera."""
return hub.get_first(
"$.customerImageCameras[?(@.deviceLabel=='%s')].area", self._device_label
) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"hub",
".",
"get_first",
"(",
"\"$.customerImageCameras[?(@.deviceLabel=='%s')].area\"",
",",
"self",
".",
"_device_label",
")"
] | [
91,
4
] | [
95,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the ZoneMinder binary sensor platform. | Set up the ZoneMinder binary sensor platform. | async def async_setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the ZoneMinder binary sensor platform."""
sensors = []
for host_name, zm_client in hass.data[ZONEMINDER_DOMAIN].items():
sensors.append(ZMAvailabilitySensor(host_name, zm_client))
add_entities(sensors)
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"host_name",
",",
"zm_client",
"in",
"hass",
".",
"data",
"[",
"ZONEMINDER_DOMAIN",
"]",
... | [
9,
0
] | [
15,
15
] | python | en | ['en', 'da', 'en'] | True |
ZMAvailabilitySensor.__init__ | (self, host_name, client) | Initialize availability sensor. | Initialize availability sensor. | def __init__(self, host_name, client):
"""Initialize availability sensor."""
self._state = None
self._name = host_name
self._client = client | [
"def",
"__init__",
"(",
"self",
",",
"host_name",
",",
"client",
")",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_name",
"=",
"host_name",
"self",
".",
"_client",
"=",
"client"
] | [
21,
4
] | [
25,
29
] | python | en | ['en', 'zu', 'en'] | True |
ZMAvailabilitySensor.name | (self) | Return the name of this binary sensor. | Return the name of this binary sensor. | def name(self):
"""Return the name of this binary sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
28,
4
] | [
30,
25
] | python | en | ['en', 'mi', 'en'] | True |
ZMAvailabilitySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
33,
4
] | [
35,
26
] | python | en | ['en', 'fy', 'en'] | True |
ZMAvailabilitySensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_CONNECTIVITY | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_CONNECTIVITY"
] | [
38,
4
] | [
40,
40
] | python | en | ['en', 'en', 'en'] | True |
ZMAvailabilitySensor.update | (self) | Update the state of this sensor (availability of ZoneMinder). | Update the state of this sensor (availability of ZoneMinder). | def update(self):
"""Update the state of this sensor (availability of ZoneMinder)."""
self._state = self._client.is_available | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_client",
".",
"is_available"
] | [
42,
4
] | [
44,
47
] | python | en | ['en', 'en', 'en'] | True |
get_board | (data: dict) | Create a Pymata board object. | Create a Pymata board object. | async def get_board(data: dict) -> PymataExpress:
"""Create a Pymata board object."""
board_data = {}
if CONF_SERIAL_PORT in data:
board_data["com_port"] = data[CONF_SERIAL_PORT]
if CONF_SERIAL_BAUD_RATE in data:
board_data["baud_rate"] = data[CONF_SERIAL_BAUD_RATE]
if CONF_ARDUINO_... | [
"async",
"def",
"get_board",
"(",
"data",
":",
"dict",
")",
"->",
"PymataExpress",
":",
"board_data",
"=",
"{",
"}",
"if",
"CONF_SERIAL_PORT",
"in",
"data",
":",
"board_data",
"[",
"\"com_port\"",
"]",
"=",
"data",
"[",
"CONF_SERIAL_PORT",
"]",
"if",
"CONF... | [
132,
0
] | [
155,
16
] | python | en | ['en', 'ha', 'en'] | True |
FirmataBoard.__init__ | (self, config: dict) | Initialize the board. | Initialize the board. | def __init__(self, config: dict):
"""Initialize the board."""
self.config = config
self.api = None
self.firmware_version = None
self.protocol_version = None
self.name = self.config[CONF_NAME]
self.switches = []
self.lights = []
self.binary_sensors ... | [
"def",
"__init__",
"(",
"self",
",",
"config",
":",
"dict",
")",
":",
"self",
".",
"config",
"=",
"config",
"self",
".",
"api",
"=",
"None",
"self",
".",
"firmware_version",
"=",
"None",
"self",
".",
"protocol_version",
"=",
"None",
"self",
".",
"name"... | [
34,
4
] | [
54,
52
] | python | en | ['en', 'en', 'en'] | True |
FirmataBoard.async_setup | (self, tries=0) | Set up a Firmata instance. | Set up a Firmata instance. | async def async_setup(self, tries=0) -> bool:
"""Set up a Firmata instance."""
try:
_LOGGER.debug("Connecting to Firmata %s", self.name)
self.api = await get_board(self.config)
except RuntimeError as err:
_LOGGER.error("Error connecting to PyMata board %s: %s"... | [
"async",
"def",
"async_setup",
"(",
"self",
",",
"tries",
"=",
"0",
")",
"->",
"bool",
":",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Connecting to Firmata %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"api",
"=",
"await",
"get_board",
"(",
"se... | [
56,
4
] | [
99,
19
] | python | en | ['en', 'lb', 'en'] | True |
FirmataBoard.async_reset | (self) | Reset the board to default state. | Reset the board to default state. | async def async_reset(self) -> bool:
"""Reset the board to default state."""
_LOGGER.debug("Shutting down board %s", self.name)
# If the board was never setup, continue.
if self.api is None:
return True
await self.api.shutdown()
self.api = None
retur... | [
"async",
"def",
"async_reset",
"(",
"self",
")",
"->",
"bool",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Shutting down board %s\"",
",",
"self",
".",
"name",
")",
"# If the board was never setup, continue.",
"if",
"self",
".",
"api",
"is",
"None",
":",
"return",
"... | [
101,
4
] | [
111,
19
] | python | en | ['en', 'en', 'en'] | True |
FirmataBoard.mark_pin_used | (self, pin: FirmataPinType) | Test if a pin is used already on the board or mark as used. | Test if a pin is used already on the board or mark as used. | def mark_pin_used(self, pin: FirmataPinType) -> bool:
"""Test if a pin is used already on the board or mark as used."""
if pin in self.used_pins:
return False
self.used_pins.append(pin)
return True | [
"def",
"mark_pin_used",
"(",
"self",
",",
"pin",
":",
"FirmataPinType",
")",
"->",
"bool",
":",
"if",
"pin",
"in",
"self",
".",
"used_pins",
":",
"return",
"False",
"self",
".",
"used_pins",
".",
"append",
"(",
"pin",
")",
"return",
"True"
] | [
113,
4
] | [
118,
19
] | python | en | ['en', 'en', 'en'] | True |
FirmataBoard.get_pin_type | (self, pin: FirmataPinType) | Return the type and Firmata location of a pin on the board. | Return the type and Firmata location of a pin on the board. | def get_pin_type(self, pin: FirmataPinType) -> tuple:
"""Return the type and Firmata location of a pin on the board."""
if isinstance(pin, str):
pin_type = PIN_TYPE_ANALOG
firmata_pin = int(pin[1:])
firmata_pin += self.api.first_analog_pin
else:
pi... | [
"def",
"get_pin_type",
"(",
"self",
",",
"pin",
":",
"FirmataPinType",
")",
"->",
"tuple",
":",
"if",
"isinstance",
"(",
"pin",
",",
"str",
")",
":",
"pin_type",
"=",
"PIN_TYPE_ANALOG",
"firmata_pin",
"=",
"int",
"(",
"pin",
"[",
"1",
":",
"]",
")",
... | [
120,
4
] | [
129,
38
] | python | en | ['en', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
24,
0
] | [
26,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
30,
0
] | [
32,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
36,
0
] | [
38,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_triggers | (hass, device_reg, entity_reg) | Test we get the expected triggers from a remote. | Test we get the expected triggers from a remote. | async def test_get_triggers(hass, device_reg, entity_reg):
"""Test we get the expected triggers from a remote."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
co... | [
"async",
"def",
"test_get_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
41,
0
] | [
67,
40
] | python | en | ['en', 'en', 'en'] | True |
test_get_trigger_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a remote trigger. | Test we get the expected capabilities from a remote trigger. | async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a remote trigger."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_en... | [
"async",
"def",
"test_get_trigger_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"has... | [
70,
0
] | [
89,
52
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change | (hass, calls) | Test for turn_on and turn_off triggers firing. | Test for turn_on and turn_off triggers firing. | async def test_if_fires_on_state_change(hass, calls):
"""Test for turn_on and turn_off triggers firing."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_state_change",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
... | [
92,
0
] | [
174,
5
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change_with_for | (hass, calls) | Test for triggers firing with delay. | Test for triggers firing with delay. | async def test_if_fires_on_state_change_with_for(hass, calls):
"""Test for triggers firing with delay."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_state_change_with_for",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component"... | [
177,
0
] | [
233,
5
] | python | en | ['en', 'en', 'en'] | True |
docid | (fileid) |
Returns the docid parsed from the file id
|
Returns the docid parsed from the file id
| def docid(fileid):
"""
Returns the docid parsed from the file id
"""
fname = os.path.basename(fileid)
return os.path.splitext(fname)[0] | [
"def",
"docid",
"(",
"fileid",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fileid",
")",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"fname",
")",
"[",
"0",
"]"
] | [
23,
0
] | [
28,
37
] | python | en | ['en', 'error', 'th'] | False |
parse_date | (ts) |
Helper function to handle weird mongo datetime output.
|
Helper function to handle weird mongo datetime output.
| def parse_date(ts):
"""
Helper function to handle weird mongo datetime output.
"""
return datetime.strptime(ts.split()[0], DATEFMT) | [
"def",
"parse_date",
"(",
"ts",
")",
":",
"return",
"datetime",
".",
"strptime",
"(",
"ts",
".",
"split",
"(",
")",
"[",
"0",
"]",
",",
"DATEFMT",
")"
] | [
31,
0
] | [
35,
52
] | python | en | ['en', 'error', 'th'] | False |
WordSeries.load | (klass, path) |
Load the word series from disk.
|
Load the word series from disk.
| def load(klass, path):
"""
Load the word series from disk.
"""
obj = klass()
with open(path, 'r') as f:
for line in f:
data = json.loads(line.strip())
word = data['word']
for dt, val in data['series'].items():
... | [
"def",
"load",
"(",
"klass",
",",
"path",
")",
":",
"obj",
"=",
"klass",
"(",
")",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"line",
".",
"strip",
"(",... | [
53,
4
] | [
67,
18
] | python | en | ['en', 'error', 'th'] | False |
WordSeries.read | (self, corpus, pubdates=PUBDATES) |
Creates a time series for each unique word in the corpus, normalizing
the words and filtering out stopwords, etc.
|
Creates a time series for each unique word in the corpus, normalizing
the words and filtering out stopwords, etc.
| def read(self, corpus, pubdates=PUBDATES):
"""
Creates a time series for each unique word in the corpus, normalizing
the words and filtering out stopwords, etc.
"""
normalize = TextNormalizer().normalize
pubdates = load_pubdates(corpus.fileids(), pubdates)
# coun... | [
"def",
"read",
"(",
"self",
",",
"corpus",
",",
"pubdates",
"=",
"PUBDATES",
")",
":",
"normalize",
"=",
"TextNormalizer",
"(",
")",
".",
"normalize",
"pubdates",
"=",
"load_pubdates",
"(",
"corpus",
".",
"fileids",
"(",
")",
",",
"pubdates",
")",
"# cou... | [
90,
4
] | [
106,
47
] | python | en | ['en', 'error', 'th'] | False |
WordSeries.dump | (self, path) |
Dump the word series to disk an easily parseable manner (jsonl).
|
Dump the word series to disk an easily parseable manner (jsonl).
| def dump(self, path):
"""
Dump the word series to disk an easily parseable manner (jsonl).
"""
with open(path, 'w') as f:
for word, counts in self.words.items():
obj = {
'word': word,
'series': {
... | [
"def",
"dump",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"for",
"word",
",",
"counts",
"in",
"self",
".",
"words",
".",
"items",
"(",
")",
":",
"obj",
"=",
"{",
"'word'",
":",
"word",
",... | [
108,
4
] | [
122,
29
] | python | en | ['en', 'error', 'th'] | False |
WordSeries.plot | (self, *terms) |
Plot the word series for each term in the terms list
|
Plot the word series for each term in the terms list
| def plot(self, *terms):
"""
Plot the word series for each term in the terms list
"""
fig, ax = plt.subplots(figsize=(9,6))
for term in terms:
self[term].plot(ax=ax)
ax.set_title("Token Frequency over Time")
ax.set_ylabel("word count")
ax.set_x... | [
"def",
"plot",
"(",
"self",
",",
"*",
"terms",
")",
":",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
"figsize",
"=",
"(",
"9",
",",
"6",
")",
")",
"for",
"term",
"in",
"terms",
":",
"self",
"[",
"term",
"]",
".",
"plot",
"(",
"ax",
... | [
124,
4
] | [
137,
17
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, entry, async_add_entities) | Set up Velbus binary sensor based on config_entry. | Set up Velbus binary sensor based on config_entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up Velbus binary sensor based on config_entry."""
cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"]
modules_data = hass.data[DOMAIN][entry.entry_id]["binary_sensor"]
entities = []
for address, channel in modules_data:
modu... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"cntrl",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"[",
"\"cntrl\"",
"]",
"modules_data",
"=",
"hass",
".",
"data... | [
7,
0
] | [
15,
32
] | python | en | ['en', 'zu', 'en'] | True |
VelbusBinarySensor.is_on | (self) | Return true if the sensor is on. | Return true if the sensor is on. | def is_on(self):
"""Return true if the sensor is on."""
return self._module.is_closed(self._channel) | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_module",
".",
"is_closed",
"(",
"self",
".",
"_channel",
")"
] | [
22,
4
] | [
24,
52
] | python | en | ['en', 'et', 'en'] | True |
test_show_user_form | (hass) | Test that the user set up form is served. | Test that the user set up form is served. | async def test_show_user_form(hass):
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM | [
"async",
"def",
"test_show_user_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
",",
")",
"assert",
"result... | [
21,
0
] | [
29,
61
] | python | en | ['en', 'en', 'en'] | True |
test_show_user_host_form | (hass) | Test that the host form is served after choosing the local option. | Test that the host form is served after choosing the local option. | async def test_show_user_host_form(hass):
"""Test that the host form is served after choosing the local option."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "environment"
assert result["type"] == data_en... | [
"async",
"def",
"test_show_user_host_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
",",
")",
"assert",
"r... | [
32,
0
] | [
46,
61
] | python | en | ['en', 'en', 'en'] | True |
test_show_zeroconf_connection_error_form | (hass) | Test that the zeroconf confirmation form is served. | Test that the zeroconf confirmation form is served. | async def test_show_zeroconf_connection_error_form(hass):
"""Test that the zeroconf confirmation form is served."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value=None):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_ZEROCONF... | [
"async",
"def",
"test_show_zeroconf_connection_error_form",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"None",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
... | [
49,
0
] | [
75,
66
] | python | en | ['en', 'en', 'en'] | True |
test_connection_error | (hass) | Test we show user form on Smappee connection error. | Test we show user form on Smappee connection error. | async def test_connection_error(hass):
"""Test we show user form on Smappee connection error."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value=None):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
)
as... | [
"async",
"def",
"test_connection_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"None",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
78,
0
] | [
98,
66
] | python | en | ['en', 'en', 'en'] | True |
test_zeroconf_wrong_mdns | (hass) | Test we abort if unsupported mDNS name is discovered. | Test we abort if unsupported mDNS name is discovered. | async def test_zeroconf_wrong_mdns(hass):
"""Test we abort if unsupported mDNS name is discovered."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_ZEROCONF},
data={
"host": "1.2.3.4",
"port": 22,
CONF_HOSTNAME: ... | [
"async",
"def",
"test_zeroconf_wrong_mdns",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_ZEROCONF",
"}",
",",
"data",
"=",
... | [
101,
0
] | [
117,
62
] | python | en | ['en', 'en', 'en'] | True |
test_full_user_wrong_mdns | (hass) | Test we abort user flow if unsupported mDNS name got resolved. | Test we abort user flow if unsupported mDNS name got resolved. | async def test_full_user_wrong_mdns(hass):
"""Test we abort user flow if unsupported mDNS name got resolved."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
return_value=[{"key": "mdnsHostName", "value": "Smappee... | [
"async",
"def",
"test_full_user_wrong_mdns",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"{",
"}",
")",
",",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.load_advanced_config\"",
",",
"return_value",
... | [
120,
0
] | [
148,
49
] | python | en | ['en', 'en', 'en'] | True |
test_user_device_exists_abort | (hass) | Test we abort user flow if Smappee device already configured. | Test we abort user flow if Smappee device already configured. | async def test_user_device_exists_abort(hass):
"""Test we abort user flow if Smappee device already configured."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
return_value=[{"key": "mdnsHostName", "value": "Smap... | [
"async",
"def",
"test_user_device_exists_abort",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"{",
"}",
")",
",",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.load_advanced_config\"",
",",
"return_valu... | [
151,
0
] | [
189,
66
] | python | en | ['en', 'en', 'en'] | True |
test_zeroconf_device_exists_abort | (hass) | Test we abort zeroconf flow if Smappee device already configured. | Test we abort zeroconf flow if Smappee device already configured. | async def test_zeroconf_device_exists_abort(hass):
"""Test we abort zeroconf flow if Smappee device already configured."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
return_value=[{"key": "mdnsHostName", "value... | [
"async",
"def",
"test_zeroconf_device_exists_abort",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"{",
"}",
")",
",",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.load_advanced_config\"",
",",
"return_... | [
192,
0
] | [
227,
66
] | python | de | ['de', 'sr', 'en'] | False |
test_cloud_device_exists_abort | (hass) | Test we abort cloud flow if Smappee Cloud device already configured. | Test we abort cloud flow if Smappee Cloud device already configured. | async def test_cloud_device_exists_abort(hass):
"""Test we abort cloud flow if Smappee Cloud device already configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id="smappeeCloud",
source=SOURCE_USER,
)
config_entry.add_to_hass(hass)
assert len(hass.config_ent... | [
"async",
"def",
"test_cloud_device_exists_abort",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"smappeeCloud\"",
",",
"source",
"=",
"SOURCE_USER",
",",
")",
"config_entry",
".",
"add_to_hass... | [
230,
0
] | [
248,
62
] | python | en | ['en', 'en', 'en'] | True |
test_zeroconf_abort_if_cloud_device_exists | (hass) | Test we abort zeroconf flow if Smappee Cloud device already configured. | Test we abort zeroconf flow if Smappee Cloud device already configured. | async def test_zeroconf_abort_if_cloud_device_exists(hass):
"""Test we abort zeroconf flow if Smappee Cloud device already configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id="smappeeCloud",
source=SOURCE_USER,
)
config_entry.add_to_hass(hass)
assert len(... | [
"async",
"def",
"test_zeroconf_abort_if_cloud_device_exists",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"smappeeCloud\"",
",",
"source",
"=",
"SOURCE_USER",
",",
")",
"config_entry",
".",
... | [
251,
0
] | [
276,
62
] | python | en | ['nl', 'sr', 'en'] | False |
test_zeroconf_confirm_abort_if_cloud_device_exists | (hass) | Test we abort zeroconf confirm flow if Smappee Cloud device already configured. | Test we abort zeroconf confirm flow if Smappee Cloud device already configured. | async def test_zeroconf_confirm_abort_if_cloud_device_exists(hass):
"""Test we abort zeroconf confirm flow if Smappee Cloud device already configured."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_ZEROCONF},
data={
"host": "1.2.3.4",... | [
"async",
"def",
"test_zeroconf_confirm_abort_if_cloud_device_exists",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_ZEROCONF",
"}",
... | [
279,
0
] | [
307,
62
] | python | en | ['nl', 'en', 'en'] | True |
test_abort_cloud_flow_if_local_device_exists | (hass) | Test we abort the cloud flow if a Smappee local device already configured. | Test we abort the cloud flow if a Smappee local device already configured. | async def test_abort_cloud_flow_if_local_device_exists(hass):
"""Test we abort the cloud flow if a Smappee local device already configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"host": "1.2.3.4"},
unique_id="1006000212",
source=SOURCE_USER,
)
config_ent... | [
"async",
"def",
"test_abort_cloud_flow_if_local_device_exists",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"1.2.3.4\"",
"}",
",",
"unique_id",
"=",
"\"1006000212\"",
",",
... | [
310,
0
] | [
332,
62
] | python | en | ['en', 'en', 'en'] | True |
test_full_user_flow | (hass, aiohttp_client, aioclient_mock, current_request) | Check full flow. | Check full flow. | async def test_full_user_flow(hass, aiohttp_client, aioclient_mock, current_request):
"""Check full flow."""
assert await setup.async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {CONF_CLIENT_ID: CLIENT_ID, CONF_CLIENT_SECRET: CLIENT_SECRET},
"http": {"base_url": "htt... | [
"async",
"def",
"test_full_user_flow",
"(",
"hass",
",",
"aiohttp_client",
",",
"aioclient_mock",
",",
"current_request",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"CONF_CLIENT_I... | [
335,
0
] | [
376,
42
] | python | en | ['sv', 'no', 'en'] | False |
test_full_zeroconf_flow | (hass) | Test the full zeroconf flow. | Test the full zeroconf flow. | async def test_full_zeroconf_flow(hass):
"""Test the full zeroconf flow."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
return_value=[{"key": "mdnsHostName", "value": "Smappee1006000212"}],
), patch(
... | [
"async",
"def",
"test_full_zeroconf_flow",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"{",
"}",
")",
",",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.load_advanced_config\"",
",",
"return_value",
... | [
379,
0
] | [
417,
46
] | python | en | ['en', 'sr', 'en'] | True |
test_full_user_local_flow | (hass) | Test the full zeroconf flow. | Test the full zeroconf flow. | async def test_full_user_local_flow(hass):
"""Test the full zeroconf flow."""
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
return_value=[{"key": "mdnsHostName", "value": "Smappee1006000212"}],
), patch(
... | [
"async",
"def",
"test_full_user_local_flow",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.logon\"",
",",
"return_value",
"=",
"{",
"}",
")",
",",
"patch",
"(",
"\"pysmappee.api.SmappeeLocalApi.load_advanced_config\"",
",",
"return_value",
... | [
420,
0
] | [
456,
46
] | python | en | ['en', 'sr', 'en'] | True |
_generate_mock_feed_entry | (
external_id,
title,
distance_to_home,
coordinates,
category=None,
attribution=None,
published=None,
updated=None,
status=None,
) | Construct a mock feed entry for testing purposes. | Construct a mock feed entry for testing purposes. | def _generate_mock_feed_entry(
external_id,
title,
distance_to_home,
coordinates,
category=None,
attribution=None,
published=None,
updated=None,
status=None,
):
"""Construct a mock feed entry for testing purposes."""
feed_entry = MagicMock()
feed_entry.external_id = exter... | [
"def",
"_generate_mock_feed_entry",
"(",
"external_id",
",",
"title",
",",
"distance_to_home",
",",
"coordinates",
",",
"category",
"=",
"None",
",",
"attribution",
"=",
"None",
",",
"published",
"=",
"None",
",",
"updated",
"=",
"None",
",",
"status",
"=",
... | [
46,
0
] | [
68,
21
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass) | Test the general setup of the platform. | Test the general setup of the platform. | async def test_setup(hass):
"""Test the general setup of the platform."""
# Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry(
"1234",
"Title 1",
15.5,
(38.0, -3.0),
category="Category 1",
attribution="Attribution 1",
... | [
"async",
"def",
"test_setup",
"(",
"hass",
")",
":",
"# Set up some mock feed entries for this test.",
"mock_entry_1",
"=",
"_generate_mock_feed_entry",
"(",
"\"1234\"",
",",
"\"Title 1\"",
",",
"15.5",
",",
"(",
"38.0",
",",
"-",
"3.0",
")",
",",
"category",
"=",... | [
71,
0
] | [
187,
39
] | python | en | ['en', 'da', 'en'] | True |
test_setup_with_custom_location | (hass) | Test the setup with a custom location. | Test the setup with a custom location. | async def test_setup_with_custom_location(hass):
"""Test the setup with a custom location."""
# Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry(
"1234", "Title 1", 20.5, (38.1, -3.1), category="Category 1"
)
with patch("georss_qld_bushfire_alert_client.... | [
"async",
"def",
"test_setup_with_custom_location",
"(",
"hass",
")",
":",
"# Set up some mock feed entries for this test.",
"mock_entry_1",
"=",
"_generate_mock_feed_entry",
"(",
"\"1234\"",
",",
"\"Title 1\"",
",",
"20.5",
",",
"(",
"38.1",
",",
"-",
"3.1",
")",
",",... | [
190,
0
] | [
216,
13
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the PJLink platform. | Set up the PJLink platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the PJLink platform."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
name = config.get(CONF_NAME)
encoding = config.get(CONF_ENCODING)
password = config.get(CONF_PASSWORD)
if "pjlink" not in hass.dat... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"name",
"=",
"co... | [
43,
0
] | [
61,
32
] | python | en | ['en', 'da', 'en'] | True |
format_input_source | (input_source_name, input_source_number) | Format input source for display in UI. | Format input source for display in UI. | def format_input_source(input_source_name, input_source_number):
"""Format input source for display in UI."""
return f"{input_source_name} {input_source_number}" | [
"def",
"format_input_source",
"(",
"input_source_name",
",",
"input_source_number",
")",
":",
"return",
"f\"{input_source_name} {input_source_number}\""
] | [
64,
0
] | [
66,
55
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.__init__ | (self, host, port, name, encoding, password) | Iinitialize the PJLink device. | Iinitialize the PJLink device. | def __init__(self, host, port, name, encoding, password):
"""Iinitialize the PJLink device."""
self._host = host
self._port = port
self._name = name
self._password = password
self._encoding = encoding
self._muted = False
self._pwstate = STATE_OFF
s... | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"port",
",",
"name",
",",
"encoding",
",",
"password",
")",
":",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_port",
"=",
"port",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_password",
"=... | [
72,
4
] | [
87,
68
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.projector | (self) | Create PJLink Projector instance. | Create PJLink Projector instance. | def projector(self):
"""Create PJLink Projector instance."""
projector = Projector.from_address(
self._host, self._port, self._encoding, DEFAULT_TIMEOUT
)
projector.authenticate(self._password)
return projector | [
"def",
"projector",
"(",
"self",
")",
":",
"projector",
"=",
"Projector",
".",
"from_address",
"(",
"self",
".",
"_host",
",",
"self",
".",
"_port",
",",
"self",
".",
"_encoding",
",",
"DEFAULT_TIMEOUT",
")",
"projector",
".",
"authenticate",
"(",
"self",
... | [
89,
4
] | [
96,
24
] | python | en | ['en', 'ro', 'en'] | True |
PjLinkDevice.update | (self) | Get the latest state from the device. | Get the latest state from the device. | def update(self):
"""Get the latest state from the device."""
with self.projector() as projector:
try:
pwstate = projector.get_power()
if pwstate in ("on", "warm-up"):
self._pwstate = STATE_ON
self._muted = projector.ge... | [
"def",
"update",
"(",
"self",
")",
":",
"with",
"self",
".",
"projector",
"(",
")",
"as",
"projector",
":",
"try",
":",
"pwstate",
"=",
"projector",
".",
"get_power",
"(",
")",
"if",
"pwstate",
"in",
"(",
"\"on\"",
",",
"\"warm-up\"",
")",
":",
"self... | [
98,
4
] | [
125,
25
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
128,
4
] | [
130,
25
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._pwstate | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_pwstate"
] | [
133,
4
] | [
135,
28
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.is_volume_muted | (self) | Return boolean indicating mute status. | Return boolean indicating mute status. | def is_volume_muted(self):
"""Return boolean indicating mute status."""
return self._muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_muted"
] | [
138,
4
] | [
140,
26
] | python | en | ['en', 'id', 'en'] | True |
PjLinkDevice.source | (self) | Return current input source. | Return current input source. | def source(self):
"""Return current input source."""
return self._current_source | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_current_source"
] | [
143,
4
] | [
145,
35
] | python | co | ['fr', 'co', 'en'] | False |
PjLinkDevice.source_list | (self) | Return all available input sources. | Return all available input sources. | def source_list(self):
"""Return all available input sources."""
return self._source_list | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_source_list"
] | [
148,
4
] | [
150,
32
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.supported_features | (self) | Return projector supported features. | Return projector supported features. | def supported_features(self):
"""Return projector supported features."""
return SUPPORT_PJLINK | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_PJLINK"
] | [
153,
4
] | [
155,
29
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.turn_off | (self) | Turn projector off. | Turn projector off. | def turn_off(self):
"""Turn projector off."""
if self._pwstate == STATE_ON:
with self.projector() as projector:
projector.set_power("off") | [
"def",
"turn_off",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pwstate",
"==",
"STATE_ON",
":",
"with",
"self",
".",
"projector",
"(",
")",
"as",
"projector",
":",
"projector",
".",
"set_power",
"(",
"\"off\"",
")"
] | [
157,
4
] | [
161,
42
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.turn_on | (self) | Turn projector on. | Turn projector on. | def turn_on(self):
"""Turn projector on."""
if self._pwstate == STATE_OFF:
with self.projector() as projector:
projector.set_power("on") | [
"def",
"turn_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pwstate",
"==",
"STATE_OFF",
":",
"with",
"self",
".",
"projector",
"(",
")",
"as",
"projector",
":",
"projector",
".",
"set_power",
"(",
"\"on\"",
")"
] | [
163,
4
] | [
167,
41
] | python | en | ['en', 'en', 'en'] | True |
PjLinkDevice.mute_volume | (self, mute) | Mute (true) of unmute (false) media player. | Mute (true) of unmute (false) media player. | def mute_volume(self, mute):
"""Mute (true) of unmute (false) media player."""
with self.projector() as projector:
projector.set_mute(MUTE_AUDIO, mute) | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"with",
"self",
".",
"projector",
"(",
")",
"as",
"projector",
":",
"projector",
".",
"set_mute",
"(",
"MUTE_AUDIO",
",",
"mute",
")"
] | [
169,
4
] | [
172,
48
] | python | en | ['en', 'la', 'en'] | True |
PjLinkDevice.select_source | (self, source) | Set the input source. | Set the input source. | def select_source(self, source):
"""Set the input source."""
source = self._source_name_mapping[source]
with self.projector() as projector:
projector.set_input(*source) | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"source",
"=",
"self",
".",
"_source_name_mapping",
"[",
"source",
"]",
"with",
"self",
".",
"projector",
"(",
")",
"as",
"projector",
":",
"projector",
".",
"set_input",
"(",
"*",
"source",
"... | [
174,
4
] | [
178,
40
] | python | en | ['en', 'su', 'en'] | True |
get_measures | (station_data) | Force measure key to always be a list. | Force measure key to always be a list. | def get_measures(station_data):
"""Force measure key to always be a list."""
if "measures" not in station_data:
return []
if isinstance(station_data["measures"], dict):
return [station_data["measures"]]
return station_data["measures"] | [
"def",
"get_measures",
"(",
"station_data",
")",
":",
"if",
"\"measures\"",
"not",
"in",
"station_data",
":",
"return",
"[",
"]",
"if",
"isinstance",
"(",
"station_data",
"[",
"\"measures\"",
"]",
",",
"dict",
")",
":",
"return",
"[",
"station_data",
"[",
... | [
23,
0
] | [
29,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up UK Flood Monitoring Sensors. | Set up UK Flood Monitoring Sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up UK Flood Monitoring Sensors."""
station_key = config_entry.data["station"]
session = async_get_clientsession(hass=hass)
measurements = set()
async def async_update_data():
# DataUpdateCoordinator will handle aio... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"station_key",
"=",
"config_entry",
".",
"data",
"[",
"\"station\"",
"]",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
"=",
"hass",
")",
"measu... | [
32,
0
] | [
76,
37
] | python | en | ['en', 'zu', 'en'] | True |
Measurement.__init__ | (self, coordinator, key) | Initialise the gauge with a data instance and station. | Initialise the gauge with a data instance and station. | def __init__(self, coordinator, key):
"""Initialise the gauge with a data instance and station."""
super().__init__(coordinator)
self.key = key | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"key",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"key",
"=",
"key"
] | [
84,
4
] | [
87,
22
] | python | en | ['en', 'en', 'en'] | True |
Measurement.station_name | (self) | Return the station name for the measure. | Return the station name for the measure. | def station_name(self):
"""Return the station name for the measure."""
return self.coordinator.data["label"] | [
"def",
"station_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"label\"",
"]"
] | [
90,
4
] | [
92,
45
] | python | en | ['en', 'en', 'en'] | True |
Measurement.station_id | (self) | Return the station id for the measure. | Return the station id for the measure. | def station_id(self):
"""Return the station id for the measure."""
return self.coordinator.data["measures"][self.key]["stationReference"] | [
"def",
"station_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"measures\"",
"]",
"[",
"self",
".",
"key",
"]",
"[",
"\"stationReference\"",
"]"
] | [
95,
4
] | [
97,
78
] | python | en | ['en', 'en', 'en'] | True |
Measurement.qualifier | (self) | Return the qualifier for the station. | Return the qualifier for the station. | def qualifier(self):
"""Return the qualifier for the station."""
return self.coordinator.data["measures"][self.key]["qualifier"] | [
"def",
"qualifier",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"measures\"",
"]",
"[",
"self",
".",
"key",
"]",
"[",
"\"qualifier\"",
"]"
] | [
100,
4
] | [
102,
71
] | python | en | ['en', 'en', 'en'] | True |
Measurement.parameter_name | (self) | Return the parameter name for the station. | Return the parameter name for the station. | def parameter_name(self):
"""Return the parameter name for the station."""
return self.coordinator.data["measures"][self.key]["parameterName"] | [
"def",
"parameter_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"measures\"",
"]",
"[",
"self",
".",
"key",
"]",
"[",
"\"parameterName\"",
"]"
] | [
105,
4
] | [
107,
75
] | python | en | ['en', 'en', 'en'] | True |
Measurement.name | (self) | Return the name of the gauge. | Return the name of the gauge. | def name(self):
"""Return the name of the gauge."""
return f"{self.station_name} {self.parameter_name} {self.qualifier}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.station_name} {self.parameter_name} {self.qualifier}\""
] | [
110,
4
] | [
112,
76
] | 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.