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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
PlexMediaPlayer.__init__ | (self, plex_server, device, player_source, session=None) | Initialize the Plex device. | Initialize the Plex device. | def __init__(self, plex_server, device, player_source, session=None):
"""Initialize the Plex device."""
self.plex_server = plex_server
self.device = device
self.session = session
self.player_source = player_source
self._app_name = ""
self._available = False
... | [
"def",
"__init__",
"(",
"self",
",",
"plex_server",
",",
"device",
",",
"player_source",
",",
"session",
"=",
"None",
")",
":",
"self",
".",
"plex_server",
"=",
"plex_server",
"self",
".",
"device",
"=",
"device",
"self",
".",
"session",
"=",
"session",
... | [
102,
4
] | [
144,
39
] | python | en | ['en', 'pl', 'en'] | True |
PlexMediaPlayer.async_added_to_hass | (self) | Run when about to be added to hass. | Run when about to be added to hass. | async def async_added_to_hass(self):
"""Run when about to be added to hass."""
server_id = self.plex_server.machine_identifier
_LOGGER.debug("Added %s [%s]", self.entity_id, self.unique_id)
unsub = async_dispatcher_connect(
self.hass,
PLEX_UPDATE_MEDIA_PLAYER_SIG... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"server_id",
"=",
"self",
".",
"plex_server",
".",
"machine_identifier",
"_LOGGER",
".",
"debug",
"(",
"\"Added %s [%s]\"",
",",
"self",
".",
"entity_id",
",",
"self",
".",
"unique_id",
")",
"unsub"... | [
146,
4
] | [
156,
73
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.async_refresh_media_player | (self, device, session) | Set instance objects and trigger an entity state update. | Set instance objects and trigger an entity state update. | def async_refresh_media_player(self, device, session):
"""Set instance objects and trigger an entity state update."""
_LOGGER.debug("Refreshing %s [%s / %s]", self.entity_id, device, session)
self.device = device
self.session = session
self.async_schedule_update_ha_state(True) | [
"def",
"async_refresh_media_player",
"(",
"self",
",",
"device",
",",
"session",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Refreshing %s [%s / %s]\"",
",",
"self",
".",
"entity_id",
",",
"device",
",",
"session",
")",
"self",
".",
"device",
"=",
"device",
"... | [
159,
4
] | [
164,
49
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer._clear_media_details | (self) | Set all Media Items to None. | Set all Media Items to None. | def _clear_media_details(self):
"""Set all Media Items to None."""
# General
self._media_content_id = None
self._media_content_rating = None
self._media_content_type = None
self._media_duration = None
self._media_image_url = None
self._media_summary = None... | [
"def",
"_clear_media_details",
"(",
"self",
")",
":",
"# General",
"self",
".",
"_media_content_id",
"=",
"None",
"self",
".",
"_media_content_rating",
"=",
"None",
"self",
".",
"_media_content_type",
"=",
"None",
"self",
".",
"_media_duration",
"=",
"None",
"se... | [
166,
4
] | [
187,
27
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.update | (self) | Refresh key device data. | Refresh key device data. | def update(self):
"""Refresh key device data."""
self._clear_media_details()
self._available = self.device or self.session
if self.device:
try:
device_url = self.device.url("/")
except plexapi.exceptions.BadRequest:
device_url = "... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_clear_media_details",
"(",
")",
"self",
".",
"_available",
"=",
"self",
".",
"device",
"or",
"self",
".",
"session",
"if",
"self",
".",
"device",
":",
"try",
":",
"device_url",
"=",
"self",
".",
... | [
189,
4
] | [
280,
37
] | python | en | ['fr', 'ru-Latn', 'en'] | False |
PlexMediaPlayer.force_idle | (self) | Force client to idle. | Force client to idle. | def force_idle(self):
"""Force client to idle."""
self._player_state = STATE_IDLE
self._state = STATE_IDLE
self.session = None
self._clear_media_details() | [
"def",
"force_idle",
"(",
"self",
")",
":",
"self",
".",
"_player_state",
"=",
"STATE_IDLE",
"self",
".",
"_state",
"=",
"STATE_IDLE",
"self",
".",
"session",
"=",
"None",
"self",
".",
"_clear_media_details",
"(",
")"
] | [
352,
4
] | [
357,
35
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.should_poll | (self) | Return True if entity has to be polled for state. | Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
360,
4
] | [
362,
20
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.unique_id | (self) | Return the id of this plex client. | Return the id of this plex client. | def unique_id(self):
"""Return the id of this plex client."""
return f"{self.plex_server.machine_identifier}:{self._machine_identifier}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.plex_server.machine_identifier}:{self._machine_identifier}\""
] | [
365,
4
] | [
367,
82
] | python | en | ['en', 'la', 'en'] | True |
PlexMediaPlayer.machine_identifier | (self) | Return the Plex-provided identifier of this plex client. | Return the Plex-provided identifier of this plex client. | def machine_identifier(self):
"""Return the Plex-provided identifier of this plex client."""
return self._machine_identifier | [
"def",
"machine_identifier",
"(",
"self",
")",
":",
"return",
"self",
".",
"_machine_identifier"
] | [
370,
4
] | [
372,
39
] | python | en | ['en', 'mt', 'en'] | True |
PlexMediaPlayer.available | (self) | Return the availability of the client. | Return the availability of the client. | def available(self):
"""Return the availability of the client."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
375,
4
] | [
377,
30
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.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"
] | [
380,
4
] | [
382,
25
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.username | (self) | Return the username of the client owner. | Return the username of the client owner. | def username(self):
"""Return the username of the client owner."""
return self._session_username | [
"def",
"username",
"(",
"self",
")",
":",
"return",
"self",
".",
"_session_username"
] | [
385,
4
] | [
387,
37
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.app_name | (self) | Return the library name of playing media. | Return the library name of playing media. | def app_name(self):
"""Return the library name of playing media."""
return self._app_name | [
"def",
"app_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_app_name"
] | [
390,
4
] | [
392,
29
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.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._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
395,
4
] | [
397,
26
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer._active_media_plexapi_type | (self) | Get the active media type required by PlexAPI commands. | Get the active media type required by PlexAPI commands. | def _active_media_plexapi_type(self):
"""Get the active media type required by PlexAPI commands."""
if self.media_content_type is MEDIA_TYPE_MUSIC:
return "music"
return "video" | [
"def",
"_active_media_plexapi_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"media_content_type",
"is",
"MEDIA_TYPE_MUSIC",
":",
"return",
"\"music\"",
"return",
"\"video\""
] | [
400,
4
] | [
405,
22
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_content_id | (self) | Return the content ID of current playing media. | Return the content ID of current playing media. | def media_content_id(self):
"""Return the content ID of current playing media."""
return self._media_content_id | [
"def",
"media_content_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_content_id"
] | [
408,
4
] | [
410,
37
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_content_type | (self) | Return the content type of current playing media. | Return the content type of current playing media. | def media_content_type(self):
"""Return the content type of current playing media."""
return self._media_content_type | [
"def",
"media_content_type",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_content_type"
] | [
413,
4
] | [
415,
39
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_artist | (self) | Return the artist of current playing media, music track only. | Return the artist of current playing media, music track only. | def media_artist(self):
"""Return the artist of current playing media, music track only."""
return self._media_artist | [
"def",
"media_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_artist"
] | [
418,
4
] | [
420,
33
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_album_name | (self) | Return the album name of current playing media, music track only. | Return the album name of current playing media, music track only. | def media_album_name(self):
"""Return the album name of current playing media, music track only."""
return self._media_album_name | [
"def",
"media_album_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_album_name"
] | [
423,
4
] | [
425,
37
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_album_artist | (self) | Return the album artist of current playing media, music only. | Return the album artist of current playing media, music only. | def media_album_artist(self):
"""Return the album artist of current playing media, music only."""
return self._media_album_artist | [
"def",
"media_album_artist",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_album_artist"
] | [
428,
4
] | [
430,
39
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_track | (self) | Return the track number of current playing media, music only. | Return the track number of current playing media, music only. | def media_track(self):
"""Return the track number of current playing media, music only."""
return self._media_track | [
"def",
"media_track",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_track"
] | [
433,
4
] | [
435,
32
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_duration | (self) | Return the duration of current playing media in seconds. | Return the duration of current playing media in seconds. | def media_duration(self):
"""Return the duration of current playing media in seconds."""
return self._media_duration | [
"def",
"media_duration",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_duration"
] | [
438,
4
] | [
440,
35
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_position | (self) | Return the duration of current playing media in seconds. | Return the duration of current playing media in seconds. | def media_position(self):
"""Return the duration of current playing media in seconds."""
return self._media_position | [
"def",
"media_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_position"
] | [
443,
4
] | [
445,
35
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_position_updated_at | (self) | When was the position of the current playing media valid. | When was the position of the current playing media valid. | def media_position_updated_at(self):
"""When was the position of the current playing media valid."""
return self._media_position_updated_at | [
"def",
"media_position_updated_at",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_position_updated_at"
] | [
448,
4
] | [
450,
46
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_image_url | (self) | Return the image URL of current playing media. | Return the image URL of current playing media. | def media_image_url(self):
"""Return the image URL of current playing media."""
return self._media_image_url | [
"def",
"media_image_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_image_url"
] | [
453,
4
] | [
455,
36
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_summary | (self) | Return the summary of current playing media. | Return the summary of current playing media. | def media_summary(self):
"""Return the summary of current playing media."""
return self._media_summary | [
"def",
"media_summary",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_summary"
] | [
458,
4
] | [
460,
34
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_title | (self) | Return the title of current playing media. | Return the title of current playing media. | def media_title(self):
"""Return the title of current playing media."""
return self._media_title | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_title"
] | [
463,
4
] | [
465,
32
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_season | (self) | Return the season of current playing media (TV Show only). | Return the season of current playing media (TV Show only). | def media_season(self):
"""Return the season of current playing media (TV Show only)."""
return self._media_season | [
"def",
"media_season",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_season"
] | [
468,
4
] | [
470,
33
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_series_title | (self) | Return the title of the series of current playing media. | Return the title of the series of current playing media. | def media_series_title(self):
"""Return the title of the series of current playing media."""
return self._media_series_title | [
"def",
"media_series_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_series_title"
] | [
473,
4
] | [
475,
39
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_episode | (self) | Return the episode of current playing media (TV Show only). | Return the episode of current playing media (TV Show only). | def media_episode(self):
"""Return the episode of current playing media (TV Show only)."""
return self._media_episode | [
"def",
"media_episode",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_episode"
] | [
478,
4
] | [
480,
34
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.make | (self) | Return the make of the device (ex. SHIELD Android TV). | Return the make of the device (ex. SHIELD Android TV). | def make(self):
"""Return the make of the device (ex. SHIELD Android TV)."""
return self._make | [
"def",
"make",
"(",
"self",
")",
":",
"return",
"self",
".",
"_make"
] | [
483,
4
] | [
485,
25
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.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."""
if self.device and "playback" in self._device_protocol_capabilities:
return (
SUPPORT_PAUSE
| SUPPORT_PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK
| SUPPO... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"return",
"(",
"SUPPORT_PAUSE",
"|",
"SUPPORT_PREVIOUS_TRACK",
"|",
"SUPPORT_NEXT_TRACK",
"|",
"SUPPORT_S... | [
488,
4
] | [
503,
56
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.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."""
if self.device and "playback" in self._device_protocol_capabilities:
self.device.setVolume(int(volume * 100), self._active_media_plexapi_type)
self._volume_level = volume | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"self",
".",
"device",
".",
"setVolume",
"(",
"int",
"(",
"volume",
"*",
"100",
")... | [
505,
4
] | [
509,
39
] | python | en | ['fr', 'zu', 'en'] | False |
PlexMediaPlayer.volume_level | (self) | Return the volume level of the client (0..1). | Return the volume level of the client (0..1). | def volume_level(self):
"""Return the volume level of the client (0..1)."""
if (
self._is_player_active
and self.device
and "playback" in self._device_protocol_capabilities
):
return self._volume_level | [
"def",
"volume_level",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_is_player_active",
"and",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
")",
":",
"return",
"self",
".",
"_volume_level"
] | [
512,
4
] | [
519,
37
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.is_volume_muted | (self) | Return boolean if volume is currently muted. | Return boolean if volume is currently muted. | def is_volume_muted(self):
"""Return boolean if volume is currently muted."""
if self._is_player_active and self.device:
return self._volume_muted | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_player_active",
"and",
"self",
".",
"device",
":",
"return",
"self",
".",
"_volume_muted"
] | [
522,
4
] | [
525,
37
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.mute_volume | (self, mute) | Mute the volume.
Since we can't actually mute, we'll:
- On mute, store volume and set volume to 0
- On unmute, set volume to previously stored volume
| Mute the volume. | def mute_volume(self, mute):
"""Mute the volume.
Since we can't actually mute, we'll:
- On mute, store volume and set volume to 0
- On unmute, set volume to previously stored volume
"""
if not (self.device and "playback" in self._device_protocol_capabilities):
... | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"if",
"not",
"(",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
")",
":",
"return",
"self",
".",
"_volume_muted",
"=",
"mute",
"if",
"mute",
":",
... | [
527,
4
] | [
542,
62
] | python | en | ['en', 'sn', 'en'] | True |
PlexMediaPlayer.media_play | (self) | Send play command. | Send play command. | def media_play(self):
"""Send play command."""
if self.device and "playback" in self._device_protocol_capabilities:
self.device.play(self._active_media_plexapi_type) | [
"def",
"media_play",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"self",
".",
"device",
".",
"play",
"(",
"self",
".",
"_active_media_plexapi_type",
")"
] | [
544,
4
] | [
547,
61
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_pause | (self) | Send pause command. | Send pause command. | def media_pause(self):
"""Send pause command."""
if self.device and "playback" in self._device_protocol_capabilities:
self.device.pause(self._active_media_plexapi_type) | [
"def",
"media_pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"self",
".",
"device",
".",
"pause",
"(",
"self",
".",
"_active_media_plexapi_type",
")"
] | [
549,
4
] | [
552,
62
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_stop | (self) | Send stop command. | Send stop command. | def media_stop(self):
"""Send stop command."""
if self.device and "playback" in self._device_protocol_capabilities:
self.device.stop(self._active_media_plexapi_type) | [
"def",
"media_stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"self",
".",
"device",
".",
"stop",
"(",
"self",
".",
"_active_media_plexapi_type",
")"
] | [
554,
4
] | [
557,
61
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.media_next_track | (self) | Send next track command. | Send next track command. | def media_next_track(self):
"""Send next track command."""
if self.device and "playback" in self._device_protocol_capabilities:
self.device.skipNext(self._active_media_plexapi_type) | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"self",
".",
"device",
".",
"skipNext",
"(",
"self",
".",
"_active_media_plexapi_type",
")"
] | [
559,
4
] | [
562,
65
] | python | en | ['en', 'pt', 'en'] | True |
PlexMediaPlayer.media_previous_track | (self) | Send previous track command. | Send previous track command. | def media_previous_track(self):
"""Send previous track command."""
if self.device and "playback" in self._device_protocol_capabilities:
self.device.skipPrevious(self._active_media_plexapi_type) | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
":",
"self",
".",
"device",
".",
"skipPrevious",
"(",
"self",
".",
"_active_media_plexapi_type",
")"
] | [
564,
4
] | [
567,
69
] | python | en | ['en', 'it', 'en'] | True |
PlexMediaPlayer.play_media | (self, media_type, media_id, **kwargs) | Play a piece of media. | Play a piece of media. | def play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
if not (self.device and "playback" in self._device_protocol_capabilities):
_LOGGER.debug(
"Client is not currently accepting playback controls: %s", self.name
)
return
... | [
"def",
"play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"(",
"self",
".",
"device",
"and",
"\"playback\"",
"in",
"self",
".",
"_device_protocol_capabilities",
")",
":",
"_LOGGER",
".",
"debug",
... | [
569,
4
] | [
594,
63
] | python | en | ['en', 'en', 'en'] | True |
PlexMediaPlayer.device_state_attributes | (self) | Return the scene state attributes. | Return the scene state attributes. | def device_state_attributes(self):
"""Return the scene state attributes."""
return {
"media_content_rating": self._media_content_rating,
"session_username": self.username,
"media_library_name": self._app_name,
"summary": self.media_summary,
"pl... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"media_content_rating\"",
":",
"self",
".",
"_media_content_rating",
",",
"\"session_username\"",
":",
"self",
".",
"username",
",",
"\"media_library_name\"",
":",
"self",
".",
"_app_name",
",... | [
597,
4
] | [
605,
9
] | python | en | ['en', 'it', 'en'] | True |
PlexMediaPlayer.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
if self.machine_identifier is None:
return None
return {
"identifiers": {(PLEX_DOMAIN, self.machine_identifier)},
"manufacturer": self._device_platform or "Plex",
"model... | [
"def",
"device_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"machine_identifier",
"is",
"None",
":",
"return",
"None",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"PLEX_DOMAIN",
",",
"self",
".",
"machine_identifier",
")",
"}",
",",
"\"manufacturer\... | [
608,
4
] | [
620,
9
] | python | en | ['ro', 'fr', 'en'] | False |
PlexMediaPlayer.async_browse_media | (self, media_content_type=None, media_content_id=None) | Implement the websocket media browsing helper. | Implement the websocket media browsing helper. | async def async_browse_media(self, media_content_type=None, media_content_id=None):
"""Implement the websocket media browsing helper."""
return await self.hass.async_add_executor_job(
browse_media,
self.entity_id,
self.plex_server,
media_content_type,
... | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"media_content_type",
"=",
"None",
",",
"media_content_id",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"browse_media",
",",
"self",
".",
"entity_id",
... | [
622,
4
] | [
630,
9
] | python | en | ['en', 'af', 'en'] | True |
normalize_answer | (s) | Lower text and remove punctuation, articles and extra whitespace. | Lower text and remove punctuation, articles and extra whitespace. | def normalize_answer(s):
"""Lower text and remove punctuation, articles and extra whitespace."""
def remove_articles(text):
regex = re.compile(r"\b(a|an|the)\b", re.UNICODE)
return re.sub(regex, " ", text)
def white_space_fix(text):
return " ".join(text.split())
def remove_pun... | [
"def",
"normalize_answer",
"(",
"s",
")",
":",
"def",
"remove_articles",
"(",
"text",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"\\b(a|an|the)\\b\"",
",",
"re",
".",
"UNICODE",
")",
"return",
"re",
".",
"sub",
"(",
"regex",
",",
"\" \"",
",... | [
36,
0
] | [
53,
66
] | python | en | ['en', 'en', 'en'] | True |
get_raw_scores | (examples, preds) |
Computes the exact and f1 scores from the examples and the model predictions
|
Computes the exact and f1 scores from the examples and the model predictions
| def get_raw_scores(examples, preds):
"""
Computes the exact and f1 scores from the examples and the model predictions
"""
exact_scores = {}
f1_scores = {}
for example in examples:
qas_id = example.qas_id
gold_answers = [answer["text"] for answer in example.answers if normalize_a... | [
"def",
"get_raw_scores",
"(",
"examples",
",",
"preds",
")",
":",
"exact_scores",
"=",
"{",
"}",
"f1_scores",
"=",
"{",
"}",
"for",
"example",
"in",
"examples",
":",
"qas_id",
"=",
"example",
".",
"qas_id",
"gold_answers",
"=",
"[",
"answer",
"[",
"\"tex... | [
82,
0
] | [
105,
34
] | python | en | ['en', 'error', 'th'] | False |
get_final_text | (pred_text, orig_text, do_lower_case, verbose_logging=False) | Project the tokenized prediction back to the original text. | Project the tokenized prediction back to the original text. | def get_final_text(pred_text, orig_text, do_lower_case, verbose_logging=False):
"""Project the tokenized prediction back to the original text."""
# When we created the data, we kept track of the alignment between original
# (whitespace tokenized) tokens and our WordPiece tokenized tokens. So
# now `ori... | [
"def",
"get_final_text",
"(",
"pred_text",
",",
"orig_text",
",",
"do_lower_case",
",",
"verbose_logging",
"=",
"False",
")",
":",
"# When we created the data, we kept track of the alignment between original",
"# (whitespace tokenized) tokens and our WordPiece tokenized tokens. So",
... | [
254,
0
] | [
345,
22
] | python | en | ['en', 'en', 'en'] | True |
_get_best_indexes | (logits, n_best_size) | Get the n-best logits from a list. | Get the n-best logits from a list. | def _get_best_indexes(logits, n_best_size):
"""Get the n-best logits from a list."""
index_and_score = sorted(enumerate(logits), key=lambda x: x[1], reverse=True)
best_indexes = []
for i in range(len(index_and_score)):
if i >= n_best_size:
break
best_indexes.append(index_and... | [
"def",
"_get_best_indexes",
"(",
"logits",
",",
"n_best_size",
")",
":",
"index_and_score",
"=",
"sorted",
"(",
"enumerate",
"(",
"logits",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"1",
"]",
",",
"reverse",
"=",
"True",
")",
"best_indexes",
... | [
348,
0
] | [
357,
23
] | python | en | ['en', 'en', 'en'] | True |
_compute_softmax | (scores) | Compute softmax probability over raw logits. | Compute softmax probability over raw logits. | def _compute_softmax(scores):
"""Compute softmax probability over raw logits."""
if not scores:
return []
max_score = None
for score in scores:
if max_score is None or score > max_score:
max_score = score
exp_scores = []
total_sum = 0.0
for score in scores:
... | [
"def",
"_compute_softmax",
"(",
"scores",
")",
":",
"if",
"not",
"scores",
":",
"return",
"[",
"]",
"max_score",
"=",
"None",
"for",
"score",
"in",
"scores",
":",
"if",
"max_score",
"is",
"None",
"or",
"score",
">",
"max_score",
":",
"max_score",
"=",
... | [
360,
0
] | [
380,
16
] | python | en | ['en', 'en', 'en'] | True |
compute_predictions_logits | (
all_examples,
all_features,
all_results,
n_best_size,
max_answer_length,
do_lower_case,
output_prediction_file,
output_nbest_file,
output_null_log_odds_file,
verbose_logging,
version_2_with_negative,
null_score_diff_threshold,
tokenizer,
) | Write final predictions to the json file and log-odds of null if needed. | Write final predictions to the json file and log-odds of null if needed. | def compute_predictions_logits(
all_examples,
all_features,
all_results,
n_best_size,
max_answer_length,
do_lower_case,
output_prediction_file,
output_nbest_file,
output_null_log_odds_file,
verbose_logging,
version_2_with_negative,
null_score_diff_threshold,
tokenizer... | [
"def",
"compute_predictions_logits",
"(",
"all_examples",
",",
"all_features",
",",
"all_results",
",",
"n_best_size",
",",
"max_answer_length",
",",
"do_lower_case",
",",
"output_prediction_file",
",",
"output_nbest_file",
",",
"output_null_log_odds_file",
",",
"verbose_lo... | [
383,
0
] | [
585,
26
] | python | en | ['en', 'en', 'en'] | True |
compute_predictions_log_probs | (
all_examples,
all_features,
all_results,
n_best_size,
max_answer_length,
output_prediction_file,
output_nbest_file,
output_null_log_odds_file,
start_n_top,
end_n_top,
version_2_with_negative,
tokenizer,
verbose_logging,
) |
XLNet write prediction logic (more complex than Bert's). Write final predictions to the json file and log-odds of
null if needed.
Requires utils_squad_evaluate.py
|
XLNet write prediction logic (more complex than Bert's). Write final predictions to the json file and log-odds of
null if needed. | def compute_predictions_log_probs(
all_examples,
all_features,
all_results,
n_best_size,
max_answer_length,
output_prediction_file,
output_nbest_file,
output_null_log_odds_file,
start_n_top,
end_n_top,
version_2_with_negative,
tokenizer,
verbose_logging,
):
"""
... | [
"def",
"compute_predictions_log_probs",
"(",
"all_examples",
",",
"all_features",
",",
"all_results",
",",
"n_best_size",
",",
"max_answer_length",
",",
"output_prediction_file",
",",
"output_nbest_file",
",",
"output_null_log_odds_file",
",",
"start_n_top",
",",
"end_n_top... | [
588,
0
] | [
776,
26
] | python | en | ['en', 'error', 'th'] | False |
default_data_collator | (features: List[InputDataClass]) |
Very simple data collator that simply collates batches of dict-like objects and performs special handling for
potential keys named:
- ``label``: handles a single value (int or float) per object
- ``label_ids``: handles a list of values per object
Does not do any additional preprocessing: ... |
Very simple data collator that simply collates batches of dict-like objects and performs special handling for
potential keys named: | def default_data_collator(features: List[InputDataClass]) -> Dict[str, torch.Tensor]:
"""
Very simple data collator that simply collates batches of dict-like objects and performs special handling for
potential keys named:
- ``label``: handles a single value (int or float) per object
- ``lab... | [
"def",
"default_data_collator",
"(",
"features",
":",
"List",
"[",
"InputDataClass",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"# In this function we'll make the assumption that all `features` in the batch",
"# have the same attributes.",
... | [
36,
0
] | [
81,
16
] | python | en | ['en', 'error', 'th'] | False |
_collate_batch | (examples, tokenizer) | Collate `examples` into a batch, using the information in `tokenizer` for padding if necessary. | Collate `examples` into a batch, using the information in `tokenizer` for padding if necessary. | def _collate_batch(examples, tokenizer):
"""Collate `examples` into a batch, using the information in `tokenizer` for padding if necessary."""
# Tensorize if necessary.
if isinstance(examples[0], (list, tuple)):
examples = [torch.tensor(e, dtype=torch.long) for e in examples]
# Check if padding... | [
"def",
"_collate_batch",
"(",
"examples",
",",
"tokenizer",
")",
":",
"# Tensorize if necessary.",
"if",
"isinstance",
"(",
"examples",
"[",
"0",
"]",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"examples",
"=",
"[",
"torch",
".",
"tensor",
"(",
"e",
... | [
194,
0
] | [
221,
17
] | python | en | ['en', 'en', 'en'] | True |
validate_input | (hass, host, port) | Validate the user input allows us to connect. | Validate the user input allows us to connect. | async def validate_input(hass, host, port):
"""Validate the user input allows us to connect."""
volumio = Volumio(host, port, async_get_clientsession(hass))
try:
return await volumio.get_system_info()
except CannotConnectError as error:
raise CannotConnect from error | [
"async",
"def",
"validate_input",
"(",
"hass",
",",
"host",
",",
"port",
")",
":",
"volumio",
"=",
"Volumio",
"(",
"host",
",",
"port",
",",
"async_get_clientsession",
"(",
"hass",
")",
")",
"try",
":",
"return",
"await",
"volumio",
".",
"get_system_info",... | [
23,
0
] | [
30,
38
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.__init__ | (self) | Initialize flow. | Initialize flow. | def __init__(self):
"""Initialize flow."""
self._host: Optional[str] = None
self._port: Optional[int] = None
self._name: Optional[str] = None
self._uuid: Optional[str] = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_host",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
"self",
".",
"_port",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
"self",
".",
"_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None... | [
39,
4
] | [
44,
40
] | python | en | ['en', 'pl', 'en'] | False |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
info = None
self._host = user_input[CONF_HOST]
self._port = user_input[CONF_PORT]
try:
info = await validate_inp... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"info",
"=",
"None",
"self",
".",
"_host",
"=",
"user_input",
"[",
"CONF_HOST",
"]",
"self"... | [
68,
4
] | [
93,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_zeroconf | (self, discovery_info: DiscoveryInfoType) | Handle zeroconf discovery. | Handle zeroconf discovery. | async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType):
"""Handle zeroconf discovery."""
self._host = discovery_info["host"]
self._port = int(discovery_info["port"])
self._name = discovery_info["properties"]["volumioName"]
self._uuid = discovery_info["properties"]... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
":",
"DiscoveryInfoType",
")",
":",
"self",
".",
"_host",
"=",
"discovery_info",
"[",
"\"host\"",
"]",
"self",
".",
"_port",
"=",
"int",
"(",
"discovery_info",
"[",
"\"port\"",
"]",
"... | [
95,
4
] | [
104,
56
] | python | de | ['de', 'sr', 'en'] | False |
ConfigFlow.async_step_discovery_confirm | (self, user_input=None) | Handle user-confirmation of discovered node. | Handle user-confirmation of discovered node. | async def async_step_discovery_confirm(self, user_input=None):
"""Handle user-confirmation of discovered node."""
if user_input is not None:
try:
await validate_input(self.hass, self._host, self._port)
return self._async_get_entry()
except CannotCo... | [
"async",
"def",
"async_step_discovery_confirm",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"try",
":",
"await",
"validate_input",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_host",
",",
"self",
... | [
106,
4
] | [
117,
9
] | 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",
")"
] | [
20,
0
] | [
22,
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",
")"
] | [
26,
0
] | [
28,
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\"",
")"
] | [
32,
0
] | [
34,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_conditions | (hass, device_reg, entity_reg) | Test we get the expected conditions from a device_tracker. | Test we get the expected conditions from a device_tracker. | async def test_get_conditions(hass, device_reg, entity_reg):
"""Test we get the expected conditions from a device_tracker."""
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... | [
"async",
"def",
"test_get_conditions",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",... | [
37,
0
] | [
63,
54
] | python | en | ['en', 'en', 'en'] | True |
test_if_state | (hass, calls) | Test for turn_on and turn_off conditions. | Test for turn_on and turn_off conditions. | async def test_if_state(hass, calls):
"""Test for turn_on and turn_off conditions."""
hass.states.async_set("device_tracker.entity", STATE_HOME)
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
"tri... | [
"async",
"def",
"test_if_state",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"device_tracker.entity\"",
",",
"STATE_HOME",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
... | [
66,
0
] | [
125,
71
] | python | en | ['en', 'en', 'en'] | True |
gen_matrices_node_definition | (station_num: int) | Function to generate adj node definition, due to we need the numbers at runtime.
Args:
station_num (int): Total stations of current simulation.
Returns:
type: Node definition class for matrices.
| Function to generate adj node definition, due to we need the numbers at runtime. | def gen_matrices_node_definition(station_num: int):
"""Function to generate adj node definition, due to we need the numbers at runtime.
Args:
station_num (int): Total stations of current simulation.
Returns:
type: Node definition class for matrices.
"""
@node("matrices")
class... | [
"def",
"gen_matrices_node_definition",
"(",
"station_num",
":",
"int",
")",
":",
"@",
"node",
"(",
"\"matrices\"",
")",
"class",
"Matrices",
"(",
"NodeBase",
")",
":",
"trips_adj",
"=",
"NodeAttribute",
"(",
"\"i\"",
",",
"station_num",
"*",
"station_num",
")"... | [
77,
0
] | [
94,
19
] | python | en | ['en', 'en', 'en'] | True |
test_media_player_set_state | (hass, hk_driver, events) | Test if accessory and HA are updated accordingly. | Test if accessory and HA are updated accordingly. | async def test_media_player_set_state(hass, hk_driver, events):
"""Test if accessory and HA are updated accordingly."""
config = {
CONF_FEATURE_LIST: {
FEATURE_ON_OFF: None,
FEATURE_PLAY_PAUSE: None,
FEATURE_PLAY_STOP: None,
FEATURE_TOGGLE_MUTE: None,
... | [
"async",
"def",
"test_media_player_set_state",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"config",
"=",
"{",
"CONF_FEATURE_LIST",
":",
"{",
"FEATURE_ON_OFF",
":",
"None",
",",
"FEATURE_PLAY_PAUSE",
":",
"None",
",",
"FEATURE_PLAY_STOP",
":",
"None"... | [
44,
0
] | [
184,
46
] | python | en | ['en', 'en', 'en'] | True |
test_media_player_television | (hass, hk_driver, events, caplog) | Test if television accessory and HA are updated accordingly. | Test if television accessory and HA are updated accordingly. | async def test_media_player_television(hass, hk_driver, events, caplog):
"""Test if television accessory and HA are updated accordingly."""
entity_id = "media_player.television"
# Supports 'select_source', 'volume_step', 'turn_on', 'turn_off',
# 'volume_mute', 'volume_set', 'pause'
hass.state... | [
"async",
"def",
"test_media_player_television",
"(",
"hass",
",",
"hk_driver",
",",
"events",
",",
"caplog",
")",
":",
"entity_id",
"=",
"\"media_player.television\"",
"# Supports 'select_source', 'volume_step', 'turn_on', 'turn_off',",
"# 'volume_mute', 'volume_set', 'pause'... | [
187,
0
] | [
362,
59
] | python | en | ['en', 'en', 'en'] | True |
test_media_player_television_basic | (hass, hk_driver, events, caplog) | Test if basic television accessory and HA are updated accordingly. | Test if basic television accessory and HA are updated accordingly. | async def test_media_player_television_basic(hass, hk_driver, events, caplog):
"""Test if basic television accessory and HA are updated accordingly."""
entity_id = "media_player.television"
# Supports turn_on', 'turn_off'
hass.states.async_set(
entity_id,
None,
{ATTR_DEVICE_CLAS... | [
"async",
"def",
"test_media_player_television_basic",
"(",
"hass",
",",
"hk_driver",
",",
"events",
",",
"caplog",
")",
":",
"entity_id",
"=",
"\"media_player.television\"",
"# Supports turn_on', 'turn_off'",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
... | [
365,
0
] | [
396,
68
] | python | en | ['en', 'en', 'en'] | True |
test_media_player_television_supports_source_select_no_sources | (
hass, hk_driver, events, caplog
) | Test if basic tv that supports source select but is missing a source list. | Test if basic tv that supports source select but is missing a source list. | async def test_media_player_television_supports_source_select_no_sources(
hass, hk_driver, events, caplog
):
"""Test if basic tv that supports source select but is missing a source list."""
entity_id = "media_player.television"
# Supports turn_on', 'turn_off'
hass.states.async_set(
entity_i... | [
"async",
"def",
"test_media_player_television_supports_source_select_no_sources",
"(",
"hass",
",",
"hk_driver",
",",
"events",
",",
"caplog",
")",
":",
"entity_id",
"=",
"\"media_player.television\"",
"# Supports turn_on', 'turn_off'",
"hass",
".",
"states",
".",
"async_se... | [
399,
0
] | [
416,
45
] | python | en | ['en', 'en', 'en'] | True |
test_tv_restore | (hass, hk_driver, events) | Test setting up an entity from state in the event registry. | Test setting up an entity from state in the event registry. | async def test_tv_restore(hass, hk_driver, events):
"""Test setting up an entity from state in the event registry."""
hass.state = CoreState.not_running
registry = await entity_registry.async_get_registry(hass)
registry.async_get_or_create(
"media_player",
"generic",
"1234",
... | [
"async",
"def",
"test_tv_restore",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"registry",
".",
... | [
419,
0
] | [
469,
44
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Pushover notification service. | Get the Pushover notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Pushover notification service."""
return PushoverNotificationService(
hass, config[CONF_USER_KEY], config[CONF_API_KEY]
) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"PushoverNotificationService",
"(",
"hass",
",",
"config",
"[",
"CONF_USER_KEY",
"]",
",",
"config",
"[",
"CONF_API_KEY",
"]",
")"
] | [
37,
0
] | [
41,
5
] | python | en | ['en', 'en', 'en'] | True |
PushoverNotificationService.__init__ | (self, hass, user_key, api_token) | Initialize the service. | Initialize the service. | def __init__(self, hass, user_key, api_token):
"""Initialize the service."""
self._hass = hass
self._user_key = user_key
self._api_token = api_token
self.pushover = PushoverAPI(self._api_token) | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"user_key",
",",
"api_token",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_user_key",
"=",
"user_key",
"self",
".",
"_api_token",
"=",
"api_token",
"self",
".",
"pushover",
"=",
"PushoverAP... | [
47,
4
] | [
52,
52
] | python | en | ['en', 'en', 'en'] | True |
PushoverNotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
# Extract params from data dict
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
data = dict(kwargs.get(ATTR_DATA) or {})
url = data.get(ATTR_URL)
url_title = data.get(ATTR_URL_TITLE)
... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"# Extract params from data dict",
"title",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
",",
"ATTR_TITLE_DEFAULT",
")",
"data",
"=",
"dict",
"(",
"kwargs",
... | [
54,
4
] | [
113,
38
] | python | en | ['en', 'en', 'en'] | True |
mock_simple_manager_fail | () | Mock datapoint Manager with default values for testing in config_flow. | Mock datapoint Manager with default values for testing in config_flow. | def mock_simple_manager_fail():
"""Mock datapoint Manager with default values for testing in config_flow."""
with patch("datapoint.Manager") as mock_manager:
instance = mock_manager.return_value
instance.get_nearest_forecast_site.side_effect = APIException()
instance.get_forecast_for_sit... | [
"def",
"mock_simple_manager_fail",
"(",
")",
":",
"with",
"patch",
"(",
"\"datapoint.Manager\"",
")",
"as",
"mock_manager",
":",
"instance",
"=",
"mock_manager",
".",
"return_value",
"instance",
".",
"get_nearest_forecast_site",
".",
"side_effect",
"=",
"APIException"... | [
8,
0
] | [
21,
26
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up a Vivotek IP Camera. | Set up a Vivotek IP Camera. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a Vivotek IP Camera."""
creds = f"{config[CONF_USERNAME]}:{config[CONF_PASSWORD]}"
args = {
"config": config,
"cam": VivotekCamera(
host=config[CONF_IP_ADDRESS],
port=(443 if config[CONF_SS... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"creds",
"=",
"f\"{config[CONF_USERNAME]}:{config[CONF_PASSWORD]}\"",
"args",
"=",
"{",
"\"config\"",
":",
"config",
",",
"\"cam\"",
":",
"Vivot... | [
46,
0
] | [
62,
44
] | python | en | ['en', 'lv', 'en'] | True |
VivotekCam.__init__ | (self, config, cam, stream_source) | Initialize a Vivotek camera. | Initialize a Vivotek camera. | def __init__(self, config, cam, stream_source):
"""Initialize a Vivotek camera."""
super().__init__()
self._cam = cam
self._frame_interval = 1 / config[CONF_FRAMERATE]
self._motion_detection_enabled = False
self._model_name = None
self._name = config[CONF_NAME]
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"cam",
",",
"stream_source",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_cam",
"=",
"cam",
"self",
".",
"_frame_interval",
"=",
"1",
"/",
"config",
"[",
"CONF_FRAMERATE",
... | [
68,
4
] | [
77,
43
] | python | cs | ['es', 'cs', 'it'] | False |
VivotekCam.supported_features | (self) | Return supported features for this camera. | Return supported features for this camera. | def supported_features(self):
"""Return supported features for this camera."""
return SUPPORT_STREAM | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_STREAM"
] | [
80,
4
] | [
82,
29
] | python | en | ['en', 'en', 'en'] | True |
VivotekCam.frame_interval | (self) | Return the interval between frames of the mjpeg stream. | Return the interval between frames of the mjpeg stream. | def frame_interval(self):
"""Return the interval between frames of the mjpeg stream."""
return self._frame_interval | [
"def",
"frame_interval",
"(",
"self",
")",
":",
"return",
"self",
".",
"_frame_interval"
] | [
85,
4
] | [
87,
35
] | python | en | ['en', 'en', 'en'] | True |
VivotekCam.camera_image | (self) | Return bytes of camera image. | Return bytes of camera image. | def camera_image(self):
"""Return bytes of camera image."""
return self._cam.snapshot() | [
"def",
"camera_image",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cam",
".",
"snapshot",
"(",
")"
] | [
89,
4
] | [
91,
35
] | python | en | ['en', 'zu', 'en'] | True |
VivotekCam.name | (self) | Return the name of this device. | Return the name of this device. | def name(self):
"""Return the name of this device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
94,
4
] | [
96,
25
] | python | en | ['en', 'en', 'en'] | True |
VivotekCam.stream_source | (self) | Return the source of the stream. | Return the source of the stream. | async def stream_source(self):
"""Return the source of the stream."""
return self._stream_source | [
"async",
"def",
"stream_source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_stream_source"
] | [
98,
4
] | [
100,
34
] | python | en | ['en', 'en', 'en'] | True |
VivotekCam.motion_detection_enabled | (self) | Return the camera motion detection status. | Return the camera motion detection status. | def motion_detection_enabled(self):
"""Return the camera motion detection status."""
return self._motion_detection_enabled | [
"def",
"motion_detection_enabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"_motion_detection_enabled"
] | [
103,
4
] | [
105,
45
] | python | en | ['en', 'en', 'en'] | True |
VivotekCam.disable_motion_detection | (self) | Disable motion detection in camera. | Disable motion detection in camera. | def disable_motion_detection(self):
"""Disable motion detection in camera."""
response = self._cam.set_param(DEFAULT_EVENT_0_KEY, 0)
self._motion_detection_enabled = int(response) == 1 | [
"def",
"disable_motion_detection",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_cam",
".",
"set_param",
"(",
"DEFAULT_EVENT_0_KEY",
",",
"0",
")",
"self",
".",
"_motion_detection_enabled",
"=",
"int",
"(",
"response",
")",
"==",
"1"
] | [
107,
4
] | [
110,
59
] | python | en | ['it', 'en', 'en'] | True |
VivotekCam.enable_motion_detection | (self) | Enable motion detection in camera. | Enable motion detection in camera. | def enable_motion_detection(self):
"""Enable motion detection in camera."""
response = self._cam.set_param(DEFAULT_EVENT_0_KEY, 1)
self._motion_detection_enabled = int(response) == 1 | [
"def",
"enable_motion_detection",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_cam",
".",
"set_param",
"(",
"DEFAULT_EVENT_0_KEY",
",",
"1",
")",
"self",
".",
"_motion_detection_enabled",
"=",
"int",
"(",
"response",
")",
"==",
"1"
] | [
112,
4
] | [
115,
59
] | python | en | ['it', 'en', 'en'] | True |
VivotekCam.brand | (self) | Return the camera brand. | Return the camera brand. | def brand(self):
"""Return the camera brand."""
return DEFAULT_CAMERA_BRAND | [
"def",
"brand",
"(",
"self",
")",
":",
"return",
"DEFAULT_CAMERA_BRAND"
] | [
118,
4
] | [
120,
35
] | python | en | ['en', 'bs', 'en'] | True |
VivotekCam.model | (self) | Return the camera model. | Return the camera model. | def model(self):
"""Return the camera model."""
return self._model_name | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"self",
".",
"_model_name"
] | [
123,
4
] | [
125,
31
] | python | en | ['en', 'co', 'en'] | True |
VivotekCam.update | (self) | Update entity status. | Update entity status. | def update(self):
"""Update entity status."""
self._model_name = self._cam.model_name | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_model_name",
"=",
"self",
".",
"_cam",
".",
"model_name"
] | [
127,
4
] | [
129,
47
] | python | en | ['en', 'la', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up device tracker for Ruckus Unleashed component. | Set up device tracker for Ruckus Unleashed component. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up device tracker for Ruckus Unleashed component."""
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
tracked = set()
@callback
def router_update():
"""Update the ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
... | [
23,
0
] | [
43,
79
] | python | en | ['en', 'en', 'en'] | True |
add_new_entities | (coordinator, async_add_entities, tracked) | Add new tracker entities from the router. | Add new tracker entities from the router. | def add_new_entities(coordinator, async_add_entities, tracked):
"""Add new tracker entities from the router."""
new_tracked = []
for mac in coordinator.data[API_CLIENTS]:
if mac in tracked:
continue
device = coordinator.data[API_CLIENTS][mac]
new_tracked.append(RuckusUn... | [
"def",
"add_new_entities",
"(",
"coordinator",
",",
"async_add_entities",
",",
"tracked",
")",
":",
"new_tracked",
"=",
"[",
"]",
"for",
"mac",
"in",
"coordinator",
".",
"data",
"[",
"API_CLIENTS",
"]",
":",
"if",
"mac",
"in",
"tracked",
":",
"continue",
"... | [
47,
0
] | [
60,
39
] | python | en | ['en', 'en', 'en'] | True |
restore_entities | (registry, coordinator, entry, async_add_entities, tracked) | Restore clients that are not a part of active clients list. | Restore clients that are not a part of active clients list. | def restore_entities(registry, coordinator, entry, async_add_entities, tracked):
"""Restore clients that are not a part of active clients list."""
missing = []
for entity in registry.entities.values():
if entity.config_entry_id == entry.entry_id and entity.platform == DOMAIN:
if entity.... | [
"def",
"restore_entities",
"(",
"registry",
",",
"coordinator",
",",
"entry",
",",
"async_add_entities",
",",
"tracked",
")",
":",
"missing",
"=",
"[",
"]",
"for",
"entity",
"in",
"registry",
".",
"entities",
".",
"values",
"(",
")",
":",
"if",
"entity",
... | [
64,
0
] | [
79,
35
] | python | en | ['en', 'en', 'en'] | True |
RuckusUnleashedDevice.__init__ | (self, coordinator, mac, name) | Initialize a Ruckus Unleashed client. | Initialize a Ruckus Unleashed client. | def __init__(self, coordinator, mac, name) -> None:
"""Initialize a Ruckus Unleashed client."""
super().__init__(coordinator)
self._mac = mac
self._name = name | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"mac",
",",
"name",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_mac",
"=",
"mac",
"self",
".",
"_name",
"=",
"name"
] | [
85,
4
] | [
89,
25
] | python | en | ['en', 'en', 'en'] | True |
RuckusUnleashedDevice.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._mac | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_mac"
] | [
92,
4
] | [
94,
24
] | python | ca | ['fr', 'ca', 'en'] | False |
RuckusUnleashedDevice.name | (self) | Return the name. | Return the name. | def name(self) -> str:
"""Return the name."""
if self.is_connected:
return (
self.coordinator.data[API_CLIENTS][self._mac][API_NAME]
or f"{MANUFACTURER} {self._mac}"
)
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"is_connected",
":",
"return",
"(",
"self",
".",
"coordinator",
".",
"data",
"[",
"API_CLIENTS",
"]",
"[",
"self",
".",
"_mac",
"]",
"[",
"API_NAME",
"]",
"or",
"f\"{MANUFACTURER} {s... | [
97,
4
] | [
104,
25
] | python | en | ['en', 'ig', 'en'] | True |
RuckusUnleashedDevice.is_connected | (self) | Return true if the device is connected to the network. | Return true if the device is connected to the network. | def is_connected(self) -> bool:
"""Return true if the device is connected to the network."""
return self._mac in self.coordinator.data[API_CLIENTS] | [
"def",
"is_connected",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_mac",
"in",
"self",
".",
"coordinator",
".",
"data",
"[",
"API_CLIENTS",
"]"
] | [
107,
4
] | [
109,
62
] | python | en | ['en', 'en', 'en'] | True |
RuckusUnleashedDevice.source_type | (self) | Return the source type. | Return the source type. | def source_type(self) -> str:
"""Return the source type."""
return SOURCE_TYPE_ROUTER | [
"def",
"source_type",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SOURCE_TYPE_ROUTER"
] | [
112,
4
] | [
114,
33
] | python | en | ['en', 'en', 'en'] | True |
RuckusUnleashedDevice.device_info | (self) | Return the device information. | Return the device information. | def device_info(self) -> Optional[dict]:
"""Return the device information."""
if self.is_connected:
return {
"name": self.name,
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
"via_device": (
CONNECTION_NETWORK_MAC,
... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Optional",
"[",
"dict",
"]",
":",
"if",
"self",
".",
"is_connected",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".... | [
117,
4
] | [
128,
19
] | python | en | ['en', 'en', '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_service_data_not_a_dict | (hass, calls) | Test service data not dict. | Test service data not dict. | async def test_service_data_not_a_dict(hass, calls):
"""Test service data not dict."""
with assert_setup_component(0, automation.DOMAIN):
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger":... | [
"async",
"def",
"test_service_data_not_a_dict",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"automation",
".",
"DOMAIN",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN"... | [
41,
0
] | [
53,
9
] | python | en | ['en', 'en', 'en'] | True |
test_service_specify_data | (hass, calls) | Test service data. | Test service data. | async def test_service_specify_data(hass, calls):
"""Test service data."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"alias": "hello",
"trigger": {"platform": "event", "event_type": "test_event"},
... | [
"async",
"def",
"test_service_specify_data",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"alias\"",
":",
"\"hello\"",
",",
... | [
56,
0
] | [
86,
57
] | python | de | ['fr', 'de', 'en'] | False |
test_service_specify_entity_id | (hass, calls) | Test service data. | Test service data. | async def test_service_specify_entity_id(hass, calls):
"""Test service data."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
"action": {"servic... | [
"async",
"def",
"test_service_specify_entity_id",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platf... | [
89,
0
] | [
105,
63
] | python | de | ['fr', 'de', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.