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
find_matching_config_entries_for_host
(hass, host)
Search existing config entries for one matching the host.
Search existing config entries for one matching the host.
def find_matching_config_entries_for_host(hass, host): """Search existing config entries for one matching the host.""" for entry in hass.config_entries.async_entries(DOMAIN): if entry.data[CONF_HOST] == host: return entry return None
[ "def", "find_matching_config_entries_for_host", "(", "hass", ",", "host", ")", ":", "for", "entry", "in", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ":", "if", "entry", ".", "data", "[", "CONF_HOST", "]", "==", "host", ":", "r...
[ 184, 0 ]
[ 189, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Kodi platform.
Set up the Kodi platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Kodi platform.""" if discovery_info: # Now handled by zeroconf in the config flow return host = config[CONF_HOST] if find_matching_config_entries_for_host(hass, host): return ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", ":", "# Now handled by zeroconf in the config flow", "return", "host", "=", "config", "[", "CONF_HOST",...
[ 192, 0 ]
[ 220, 5 ]
python
en
['en', 'cs', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Kodi media player platform.
Set up the Kodi media player platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Kodi media player platform.""" platform = entity_platform.current_platform.get() platform.async_register_entity_service( SERVICE_ADD_MEDIA, KODI_ADD_MEDIA_SCHEMA, "async_add_media_to_playlist" ) platform.async...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "platform", "=", "entity_platform", ".", "current_platform", ".", "get", "(", ")", "platform", ".", "async_register_entity_service", "(", "SERVICE_ADD_MEDIA", ...
[ 223, 0 ]
[ 242, 32 ]
python
en
['en', 'cs', 'en']
True
cmd
(func)
Catch command exceptions.
Catch command exceptions.
def cmd(func): """Catch command exceptions.""" @wraps(func) async def wrapper(obj, *args, **kwargs): """Wrap all command methods.""" try: await func(obj, *args, **kwargs) except jsonrpc_base.jsonrpc.TransportError as exc: # If Kodi is off, we expect calls to ...
[ "def", "cmd", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "async", "def", "wrapper", "(", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap all command methods.\"\"\"", "try", ":", "await", "func", "(", "obj", ",", "*...
[ 245, 0 ]
[ 263, 18 ]
python
en
['en', 'en', 'en']
True
KodiEntity.__init__
(self, connection, kodi, name, uid)
Initialize the Kodi entity.
Initialize the Kodi entity.
def __init__(self, connection, kodi, name, uid): """Initialize the Kodi entity.""" self._connection = connection self._kodi = kodi self._name = name self._unique_id = uid self._players = None self._properties = {} self._item = {} self._app_properti...
[ "def", "__init__", "(", "self", ",", "connection", ",", "kodi", ",", "name", ",", "uid", ")", ":", "self", ".", "_connection", "=", "connection", "self", ".", "_kodi", "=", "kodi", "self", ".", "_name", "=", "name", "self", ".", "_unique_id", "=", "u...
[ 269, 4 ]
[ 280, 35 ]
python
en
['en', 'pl', 'en']
True
KodiEntity.async_on_speed_event
(self, sender, data)
Handle player changes between playing and paused.
Handle player changes between playing and paused.
def async_on_speed_event(self, sender, data): """Handle player changes between playing and paused.""" self._properties["speed"] = data["player"]["speed"] if not hasattr(data["item"], "id"): # If no item id is given, perform a full update force_refresh = True else...
[ "def", "async_on_speed_event", "(", "self", ",", "sender", ",", "data", ")", ":", "self", ".", "_properties", "[", "\"speed\"", "]", "=", "data", "[", "\"player\"", "]", "[", "\"speed\"", "]", "if", "not", "hasattr", "(", "data", "[", "\"item\"", "]", ...
[ 299, 4 ]
[ 310, 58 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_on_stop
(self, sender, data)
Handle the stop of the player playback.
Handle the stop of the player playback.
def async_on_stop(self, sender, data): """Handle the stop of the player playback.""" # Prevent stop notifications which are sent after quit notification if self._kodi_is_off: return self._reset_state([]) self.async_write_ha_state()
[ "def", "async_on_stop", "(", "self", ",", "sender", ",", "data", ")", ":", "# Prevent stop notifications which are sent after quit notification", "if", "self", ".", "_kodi_is_off", ":", "return", "self", ".", "_reset_state", "(", "[", "]", ")", "self", ".", "async...
[ 313, 4 ]
[ 320, 35 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_on_volume_changed
(self, sender, data)
Handle the volume changes.
Handle the volume changes.
def async_on_volume_changed(self, sender, data): """Handle the volume changes.""" self._app_properties["volume"] = data["volume"] self._app_properties["muted"] = data["muted"] self.async_write_ha_state()
[ "def", "async_on_volume_changed", "(", "self", ",", "sender", ",", "data", ")", ":", "self", ".", "_app_properties", "[", "\"volume\"", "]", "=", "data", "[", "\"volume\"", "]", "self", ".", "_app_properties", "[", "\"muted\"", "]", "=", "data", "[", "\"mu...
[ 323, 4 ]
[ 327, 35 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_on_quit
(self, sender, data)
Reset the player state on quit action.
Reset the player state on quit action.
async def async_on_quit(self, sender, data): """Reset the player state on quit action.""" await self._clear_connection()
[ "async", "def", "async_on_quit", "(", "self", ",", "sender", ",", "data", ")", ":", "await", "self", ".", "_clear_connection", "(", ")" ]
[ 329, 4 ]
[ 331, 38 ]
python
en
['en', 'en', 'en']
True
KodiEntity.unique_id
(self)
Return the unique id of the device.
Return the unique id of the device.
def unique_id(self): """Return the unique id of the device.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 340, 4 ]
[ 342, 30 ]
python
en
['en', 'en', 'en']
True
KodiEntity.device_info
(self)
Return device info for this device.
Return device info for this device.
def device_info(self): """Return device info for this device.""" return { "identifiers": {(DOMAIN, self.unique_id)}, "name": self.name, "manufacturer": "Kodi", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "unique_id", ")", "}", ",", "\"name\"", ":", "self", ".", "name", ",", "\"manufacturer\"", ":", "\"Kodi\"", ",", "}" ]
[ 345, 4 ]
[ 351, 9 ]
python
en
['en', 'en', 'en']
True
KodiEntity.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self._kodi_is_off: return STATE_OFF if self._no_active_players: return STATE_IDLE if self._properties["speed"] == 0: return STATE_PAUSED return STATE_PLAYING
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_kodi_is_off", ":", "return", "STATE_OFF", "if", "self", ".", "_no_active_players", ":", "return", "STATE_IDLE", "if", "self", ".", "_properties", "[", "\"speed\"", "]", "==", "0", ":", "return", ...
[ 354, 4 ]
[ 365, 28 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_added_to_hass
(self)
Connect the websocket if needed.
Connect the websocket if needed.
async def async_added_to_hass(self): """Connect the websocket if needed.""" if not self._connection.can_subscribe: return if self._connection.connected: await self._on_ws_connected() async def start_watchdog(event=None): """Start websocket watchdog."...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "if", "not", "self", ".", "_connection", ".", "can_subscribe", ":", "return", "if", "self", ".", "_connection", ".", "connected", ":", "await", "self", ".", "_on_ws_connected", "(", ")", "async", ...
[ 367, 4 ]
[ 391, 88 ]
python
en
['en', 'en', 'en']
True
KodiEntity._on_ws_connected
(self)
Call after ws is connected.
Call after ws is connected.
async def _on_ws_connected(self): """Call after ws is connected.""" self._register_ws_callbacks() version = (await self._kodi.get_application_properties(["version"]))["version"] sw_version = f"{version['major']}.{version['minor']}" dev_reg = await device_registry.async_get_regis...
[ "async", "def", "_on_ws_connected", "(", "self", ")", ":", "self", ".", "_register_ws_callbacks", "(", ")", "version", "=", "(", "await", "self", ".", "_kodi", ".", "get_application_properties", "(", "[", "\"version\"", "]", ")", ")", "[", "\"version\"", "]"...
[ 393, 4 ]
[ 403, 49 ]
python
en
['en', 'en', 'en']
True
KodiEntity._async_ws_connect
(self)
Connect to Kodi via websocket protocol.
Connect to Kodi via websocket protocol.
async def _async_ws_connect(self): """Connect to Kodi via websocket protocol.""" try: await self._connection.connect() await self._on_ws_connected() except (jsonrpc_base.jsonrpc.TransportError, CannotConnectError): _LOGGER.debug("Unable to connect to Kodi via ...
[ "async", "def", "_async_ws_connect", "(", "self", ")", ":", "try", ":", "await", "self", ".", "_connection", ".", "connect", "(", ")", "await", "self", ".", "_on_ws_connected", "(", ")", "except", "(", "jsonrpc_base", ".", "jsonrpc", ".", "TransportError", ...
[ 405, 4 ]
[ 412, 47 ]
python
en
['en', 'haw', 'it']
False
KodiEntity._async_connect_websocket_if_disconnected
(self, *_)
Reconnect the websocket if it fails.
Reconnect the websocket if it fails.
async def _async_connect_websocket_if_disconnected(self, *_): """Reconnect the websocket if it fails.""" if not self._connection.connected: await self._async_ws_connect() else: await self._ping()
[ "async", "def", "_async_connect_websocket_if_disconnected", "(", "self", ",", "*", "_", ")", ":", "if", "not", "self", ".", "_connection", ".", "connected", ":", "await", "self", ".", "_async_ws_connect", "(", ")", "else", ":", "await", "self", ".", "_ping",...
[ 421, 4 ]
[ 426, 30 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self): """Retrieve latest state.""" if not self._connection.connected: self._reset_state() return self._players = await self._kodi.get_players() if self._kodi_is_off: self._reset_state() return if self._pla...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "not", "self", ".", "_connection", ".", "connected", ":", "self", ".", "_reset_state", "(", ")", "return", "self", ".", "_players", "=", "await", "self", ".", "_kodi", ".", "get_players", "(", ...
[ 446, 4 ]
[ 488, 33 ]
python
en
['es', 'sk', 'en']
False
KodiEntity.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" ]
[ 491, 4 ]
[ 493, 25 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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 not self._connection.can_subscribe
[ "def", "should_poll", "(", "self", ")", ":", "return", "not", "self", ".", "_connection", ".", "can_subscribe" ]
[ 496, 4 ]
[ 498, 49 ]
python
en
['en', 'en', 'en']
True
KodiEntity.volume_level
(self)
Volume level of the media player (0..1).
Volume level of the media player (0..1).
def volume_level(self): """Volume level of the media player (0..1).""" if "volume" in self._app_properties: return int(self._app_properties["volume"]) / 100.0
[ "def", "volume_level", "(", "self", ")", ":", "if", "\"volume\"", "in", "self", ".", "_app_properties", ":", "return", "int", "(", "self", ".", "_app_properties", "[", "\"volume\"", "]", ")", "/", "100.0" ]
[ 501, 4 ]
[ 504, 62 ]
python
en
['en', 'en', 'en']
True
KodiEntity.is_volume_muted
(self)
Boolean if volume is currently muted.
Boolean if volume is currently muted.
def is_volume_muted(self): """Boolean if volume is currently muted.""" return self._app_properties.get("muted")
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_app_properties", ".", "get", "(", "\"muted\"", ")" ]
[ 507, 4 ]
[ 509, 48 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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._item.get("uniqueid", None)
[ "def", "media_content_id", "(", "self", ")", ":", "return", "self", ".", "_item", ".", "get", "(", "\"uniqueid\"", ",", "None", ")" ]
[ 512, 4 ]
[ 514, 47 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_content_type
(self)
Content type of current playing media. If the media type cannot be detected, the player type is used.
Content type of current playing media.
def media_content_type(self): """Content type of current playing media. If the media type cannot be detected, the player type is used. """ item_type = MEDIA_TYPES.get(self._item.get("type")) if (item_type is None or item_type == "channel") and self._players: return M...
[ "def", "media_content_type", "(", "self", ")", ":", "item_type", "=", "MEDIA_TYPES", ".", "get", "(", "self", ".", "_item", ".", "get", "(", "\"type\"", ")", ")", "if", "(", "item_type", "is", "None", "or", "item_type", "==", "\"channel\"", ")", "and", ...
[ 517, 4 ]
[ 525, 24 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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.""" if self._properties.get("live"): return None total_time = self._properties.get("totaltime") if total_time is None: return None return ( total_time["hours"] * 3600 ...
[ "def", "media_duration", "(", "self", ")", ":", "if", "self", ".", "_properties", ".", "get", "(", "\"live\"", ")", ":", "return", "None", "total_time", "=", "self", ".", "_properties", ".", "get", "(", "\"totaltime\"", ")", "if", "total_time", "is", "No...
[ 528, 4 ]
[ 542, 9 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_position
(self)
Position of current playing media in seconds.
Position of current playing media in seconds.
def media_position(self): """Position of current playing media in seconds.""" time = self._properties.get("time") if time is None: return None return time["hours"] * 3600 + time["minutes"] * 60 + time["seconds"]
[ "def", "media_position", "(", "self", ")", ":", "time", "=", "self", ".", "_properties", ".", "get", "(", "\"time\"", ")", "if", "time", "is", "None", ":", "return", "None", "return", "time", "[", "\"hours\"", "]", "*", "3600", "+", "time", "[", "\"m...
[ 545, 4 ]
[ 552, 76 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_position_updated_at
(self)
Last valid time of media position.
Last valid time of media position.
def media_position_updated_at(self): """Last valid time of media position.""" return self._media_position_updated_at
[ "def", "media_position_updated_at", "(", "self", ")", ":", "return", "self", ".", "_media_position_updated_at" ]
[ 555, 4 ]
[ 557, 46 ]
python
en
['en', 'et', 'en']
True
KodiEntity.media_image_url
(self)
Image url of current playing media.
Image url of current playing media.
def media_image_url(self): """Image url of current playing media.""" thumbnail = self._item.get("thumbnail") if thumbnail is None: return None return self._kodi.thumbnail_url(thumbnail)
[ "def", "media_image_url", "(", "self", ")", ":", "thumbnail", "=", "self", ".", "_item", ".", "get", "(", "\"thumbnail\"", ")", "if", "thumbnail", "is", "None", ":", "return", "None", "return", "self", ".", "_kodi", ".", "thumbnail_url", "(", "thumbnail", ...
[ 560, 4 ]
[ 566, 50 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" # find a string we can use as a title item = self._item return item.get("title") or item.get("label") or item.get("file")
[ "def", "media_title", "(", "self", ")", ":", "# find a string we can use as a title", "item", "=", "self", ".", "_item", "return", "item", ".", "get", "(", "\"title\"", ")", "or", "item", ".", "get", "(", "\"label\"", ")", "or", "item", ".", "get", "(", ...
[ 569, 4 ]
[ 573, 73 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_series_title
(self)
Title of series of current playing media, TV show only.
Title of series of current playing media, TV show only.
def media_series_title(self): """Title of series of current playing media, TV show only.""" return self._item.get("showtitle")
[ "def", "media_series_title", "(", "self", ")", ":", "return", "self", ".", "_item", ".", "get", "(", "\"showtitle\"", ")" ]
[ 576, 4 ]
[ 578, 42 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_season
(self)
Season of current playing media, TV show only.
Season of current playing media, TV show only.
def media_season(self): """Season of current playing media, TV show only.""" return self._item.get("season")
[ "def", "media_season", "(", "self", ")", ":", "return", "self", ".", "_item", ".", "get", "(", "\"season\"", ")" ]
[ 581, 4 ]
[ 583, 39 ]
python
en
['en', 'en', 'en']
True
KodiEntity.media_episode
(self)
Episode of current playing media, TV show only.
Episode of current playing media, TV show only.
def media_episode(self): """Episode of current playing media, TV show only.""" return self._item.get("episode")
[ "def", "media_episode", "(", "self", ")", ":", "return", "self", ".", "_item", ".", "get", "(", "\"episode\"", ")" ]
[ 586, 4 ]
[ 588, 40 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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._item.get("album")
[ "def", "media_album_name", "(", "self", ")", ":", "return", "self", ".", "_item", ".", "get", "(", "\"album\"", ")" ]
[ 591, 4 ]
[ 593, 38 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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.""" artists = self._item.get("artist", []) if artists: return artists[0] return None
[ "def", "media_artist", "(", "self", ")", ":", "artists", "=", "self", ".", "_item", ".", "get", "(", "\"artist\"", ",", "[", "]", ")", "if", "artists", ":", "return", "artists", "[", "0", "]", "return", "None" ]
[ 596, 4 ]
[ 602, 19 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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.""" artists = self._item.get("albumartist", []) if artists: return artists[0] return None
[ "def", "media_album_artist", "(", "self", ")", ":", "artists", "=", "self", ".", "_item", ".", "get", "(", "\"albumartist\"", ",", "[", "]", ")", "if", "artists", ":", "return", "artists", "[", "0", "]", "return", "None" ]
[ 605, 4 ]
[ 611, 19 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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_KODI
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_KODI" ]
[ 614, 4 ]
[ 616, 27 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_turn_on
(self)
Turn the media player on.
Turn the media player on.
async def async_turn_on(self): """Turn the media player on.""" _LOGGER.debug("Firing event to turn on device") self.hass.bus.async_fire(EVENT_TURN_ON, {ATTR_ENTITY_ID: self.entity_id})
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Firing event to turn on device\"", ")", "self", ".", "hass", ".", "bus", ".", "async_fire", "(", "EVENT_TURN_ON", ",", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_id"...
[ 618, 4 ]
[ 621, 81 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_turn_off
(self)
Turn the media player off.
Turn the media player off.
async def async_turn_off(self): """Turn the media player off.""" _LOGGER.debug("Firing event to turn off device") self.hass.bus.async_fire(EVENT_TURN_OFF, {ATTR_ENTITY_ID: self.entity_id})
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Firing event to turn off device\"", ")", "self", ".", "hass", ".", "bus", ".", "async_fire", "(", "EVENT_TURN_OFF", ",", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_...
[ 623, 4 ]
[ 626, 82 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_volume_up
(self)
Volume up the media player.
Volume up the media player.
async def async_volume_up(self): """Volume up the media player.""" await self._kodi.volume_up()
[ "async", "def", "async_volume_up", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "volume_up", "(", ")" ]
[ 629, 4 ]
[ 631, 36 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_volume_down
(self)
Volume down the media player.
Volume down the media player.
async def async_volume_down(self): """Volume down the media player.""" await self._kodi.volume_down()
[ "async", "def", "async_volume_down", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "volume_down", "(", ")" ]
[ 634, 4 ]
[ 636, 38 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_set_volume_level
(self, volume)
Set volume level, range 0..1.
Set volume level, range 0..1.
async def async_set_volume_level(self, volume): """Set volume level, range 0..1.""" await self._kodi.set_volume_level(int(volume * 100))
[ "async", "def", "async_set_volume_level", "(", "self", ",", "volume", ")", ":", "await", "self", ".", "_kodi", ".", "set_volume_level", "(", "int", "(", "volume", "*", "100", ")", ")" ]
[ 639, 4 ]
[ 641, 60 ]
python
en
['fr', 'zu', 'en']
False
KodiEntity.async_mute_volume
(self, mute)
Mute (true) or unmute (false) media player.
Mute (true) or unmute (false) media player.
async def async_mute_volume(self, mute): """Mute (true) or unmute (false) media player.""" await self._kodi.mute(mute)
[ "async", "def", "async_mute_volume", "(", "self", ",", "mute", ")", ":", "await", "self", ".", "_kodi", ".", "mute", "(", "mute", ")" ]
[ 644, 4 ]
[ 646, 35 ]
python
en
['en', 'la', 'it']
False
KodiEntity.async_media_play_pause
(self)
Pause media on media player.
Pause media on media player.
async def async_media_play_pause(self): """Pause media on media player.""" await self._kodi.play_pause()
[ "async", "def", "async_media_play_pause", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "play_pause", "(", ")" ]
[ 649, 4 ]
[ 651, 37 ]
python
en
['en', 'et', 'en']
True
KodiEntity.async_media_play
(self)
Play media.
Play media.
async def async_media_play(self): """Play media.""" await self._kodi.play()
[ "async", "def", "async_media_play", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "play", "(", ")" ]
[ 654, 4 ]
[ 656, 31 ]
python
en
['en', 'sv', 'en']
False
KodiEntity.async_media_pause
(self)
Pause the media player.
Pause the media player.
async def async_media_pause(self): """Pause the media player.""" await self._kodi.pause()
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "pause", "(", ")" ]
[ 659, 4 ]
[ 661, 32 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_media_stop
(self)
Stop the media player.
Stop the media player.
async def async_media_stop(self): """Stop the media player.""" await self._kodi.stop()
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "stop", "(", ")" ]
[ 664, 4 ]
[ 666, 31 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_media_next_track
(self)
Send next track command.
Send next track command.
async def async_media_next_track(self): """Send next track command.""" await self._kodi.next_track()
[ "async", "def", "async_media_next_track", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "next_track", "(", ")" ]
[ 669, 4 ]
[ 671, 37 ]
python
en
['en', 'pt', 'en']
True
KodiEntity.async_media_previous_track
(self)
Send next track command.
Send next track command.
async def async_media_previous_track(self): """Send next track command.""" await self._kodi.previous_track()
[ "async", "def", "async_media_previous_track", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "previous_track", "(", ")" ]
[ 674, 4 ]
[ 676, 41 ]
python
en
['en', 'pt', 'en']
True
KodiEntity.async_media_seek
(self, position)
Send seek command.
Send seek command.
async def async_media_seek(self, position): """Send seek command.""" await self._kodi.media_seek(position)
[ "async", "def", "async_media_seek", "(", "self", ",", "position", ")", ":", "await", "self", ".", "_kodi", ".", "media_seek", "(", "position", ")" ]
[ 679, 4 ]
[ 681, 45 ]
python
en
['en', 'ig', 'en']
True
KodiEntity.async_play_media
(self, media_type, media_id, **kwargs)
Send the play_media command to the media player.
Send the play_media command to the media player.
async def async_play_media(self, media_type, media_id, **kwargs): """Send the play_media command to the media player.""" media_type_lower = media_type.lower() if media_type_lower == MEDIA_TYPE_CHANNEL: await self._kodi.play_channel(int(media_id)) elif media_type_lower == MED...
[ "async", "def", "async_play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "media_type_lower", "=", "media_type", ".", "lower", "(", ")", "if", "media_type_lower", "==", "MEDIA_TYPE_CHANNEL", ":", "await", "self", ...
[ 684, 4 ]
[ 712, 53 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_set_shuffle
(self, shuffle)
Set shuffle mode, for the first player.
Set shuffle mode, for the first player.
async def async_set_shuffle(self, shuffle): """Set shuffle mode, for the first player.""" if self._no_active_players: raise RuntimeError("Error: No active player.") await self._kodi.set_shuffle(shuffle)
[ "async", "def", "async_set_shuffle", "(", "self", ",", "shuffle", ")", ":", "if", "self", ".", "_no_active_players", ":", "raise", "RuntimeError", "(", "\"Error: No active player.\"", ")", "await", "self", ".", "_kodi", ".", "set_shuffle", "(", "shuffle", ")" ]
[ 715, 4 ]
[ 719, 45 ]
python
en
['en', 'en', 'en']
True
KodiEntity.async_call_method
(self, method, **kwargs)
Run Kodi JSONRPC API method with params.
Run Kodi JSONRPC API method with params.
async def async_call_method(self, method, **kwargs): """Run Kodi JSONRPC API method with params.""" _LOGGER.debug("Run API method %s, kwargs=%s", method, kwargs) result_ok = False try: result = await self._kodi.call_method(method, **kwargs) result_ok = True ...
[ "async", "def", "async_call_method", "(", "self", ",", "method", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Run API method %s, kwargs=%s\"", ",", "method", ",", "kwargs", ")", "result_ok", "=", "False", "try", ":", "result", "=", "...
[ 721, 4 ]
[ 757, 21 ]
python
en
['en', 'su', 'en']
True
KodiEntity.async_clear_playlist
(self)
Clear default playlist (i.e. playlistid=0).
Clear default playlist (i.e. playlistid=0).
async def async_clear_playlist(self): """Clear default playlist (i.e. playlistid=0).""" await self._kodi.clear_playlist()
[ "async", "def", "async_clear_playlist", "(", "self", ")", ":", "await", "self", ".", "_kodi", ".", "clear_playlist", "(", ")" ]
[ 759, 4 ]
[ 761, 41 ]
python
da
['da', 'ga', 'ur']
False
KodiEntity.async_add_to_playlist
(self, media_type, media_id)
Add media item to default playlist (i.e. playlistid=0).
Add media item to default playlist (i.e. playlistid=0).
async def async_add_to_playlist(self, media_type, media_id): """Add media item to default playlist (i.e. playlistid=0).""" if media_type == MEDIA_TYPE_ARTIST: await self._kodi.add_artist_to_playlist(int(media_id)) elif media_type == MEDIA_TYPE_ALBUM: await self._kodi.add_...
[ "async", "def", "async_add_to_playlist", "(", "self", ",", "media_type", ",", "media_id", ")", ":", "if", "media_type", "==", "MEDIA_TYPE_ARTIST", ":", "await", "self", ".", "_kodi", ".", "add_artist_to_playlist", "(", "int", "(", "media_id", ")", ")", "elif",...
[ 763, 4 ]
[ 770, 64 ]
python
en
['it', 'pl', 'en']
False
KodiEntity.async_add_media_to_playlist
( self, media_type, media_id=None, media_name="ALL", artist_name="" )
Add a media to default playlist. First the media type must be selected, then the media can be specified in terms of id or name and optionally artist name. All the albums of an artist can be added with media_name="ALL"
Add a media to default playlist.
async def async_add_media_to_playlist( self, media_type, media_id=None, media_name="ALL", artist_name="" ): """Add a media to default playlist. First the media type must be selected, then the media can be specified in terms of id or name and optionally artist name. A...
[ "async", "def", "async_add_media_to_playlist", "(", "self", ",", "media_type", ",", "media_id", "=", "None", ",", "media_name", "=", "\"ALL\"", ",", "artist_name", "=", "\"\"", ")", ":", "if", "media_type", "==", "\"SONG\"", ":", "if", "media_id", "is", "Non...
[ 772, 4 ]
[ 803, 65 ]
python
cy
['it', 'cy', 'en']
False
KodiEntity._async_add_all_albums
(self, artist_name)
Add all albums of an artist to default playlist (i.e. playlistid=0). The artist is specified in terms of name.
Add all albums of an artist to default playlist (i.e. playlistid=0).
async def _async_add_all_albums(self, artist_name): """Add all albums of an artist to default playlist (i.e. playlistid=0). The artist is specified in terms of name. """ artist_id = await self._async_find_artist(artist_name) albums = await self._kodi.get_albums(artist_id) ...
[ "async", "def", "_async_add_all_albums", "(", "self", ",", "artist_name", ")", ":", "artist_id", "=", "await", "self", ".", "_async_find_artist", "(", "artist_name", ")", "albums", "=", "await", "self", ".", "_kodi", ".", "get_albums", "(", "artist_id", ")", ...
[ 805, 4 ]
[ 815, 71 ]
python
en
['en', 'cy', 'en']
True
KodiEntity._async_find_artist
(self, artist_name)
Find artist by name.
Find artist by name.
async def _async_find_artist(self, artist_name): """Find artist by name.""" artists = await self._kodi.get_artists() try: out = self._find(artist_name, [a["artist"] for a in artists["artists"]]) return artists["artists"][out[0][0]]["artistid"] except KeyError: ...
[ "async", "def", "_async_find_artist", "(", "self", ",", "artist_name", ")", ":", "artists", "=", "await", "self", ".", "_kodi", ".", "get_artists", "(", ")", "try", ":", "out", "=", "self", ".", "_find", "(", "artist_name", ",", "[", "a", "[", "\"artis...
[ 817, 4 ]
[ 825, 23 ]
python
en
['en', 'en', 'en']
True
KodiEntity._async_find_song
(self, song_name, artist_name="")
Find song by name and optionally artist name.
Find song by name and optionally artist name.
async def _async_find_song(self, song_name, artist_name=""): """Find song by name and optionally artist name.""" artist_id = None if artist_name != "": artist_id = await self._async_find_artist(artist_name) songs = await self._kodi.get_songs(artist_id) if songs["limi...
[ "async", "def", "_async_find_song", "(", "self", ",", "song_name", ",", "artist_name", "=", "\"\"", ")", ":", "artist_id", "=", "None", "if", "artist_name", "!=", "\"\"", ":", "artist_id", "=", "await", "self", ".", "_async_find_artist", "(", "artist_name", ...
[ 827, 4 ]
[ 838, 50 ]
python
en
['en', 'en', 'en']
True
KodiEntity._async_find_album
(self, album_name, artist_name="")
Find album by name and optionally artist name.
Find album by name and optionally artist name.
async def _async_find_album(self, album_name, artist_name=""): """Find album by name and optionally artist name.""" artist_id = None if artist_name != "": artist_id = await self._async_find_artist(artist_name) albums = await self._kodi.get_albums(artist_id) try: ...
[ "async", "def", "_async_find_album", "(", "self", ",", "album_name", ",", "artist_name", "=", "\"\"", ")", ":", "artist_id", "=", "None", "if", "artist_name", "!=", "\"\"", ":", "artist_id", "=", "await", "self", ".", "_async_find_artist", "(", "artist_name", ...
[ 840, 4 ]
[ 856, 23 ]
python
en
['en', 'en', 'en']
True
KodiEntity.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.""" if media_content_type in [None, "library"]: return await self.hass.async_add_executor_job(library_payload, self._kodi) payload = { "se...
[ "async", "def", "async_browse_media", "(", "self", ",", "media_content_type", "=", "None", ",", "media_content_id", "=", "None", ")", ":", "if", "media_content_type", "in", "[", "None", ",", "\"library\"", "]", ":", "return", "await", "self", ".", "hass", "....
[ 871, 4 ]
[ 885, 23 ]
python
en
['en', 'af', 'en']
True
OVOEnergyFlowHandler.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" errors = {} if user_input is not None: client = OVOEnergy() try: authenticated = await client.authenticate( user_input[CONF_USERNAME], user_inp...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "client", "=", "OVOEnergy", "(", ")", "try", ":", "authenticated", "=", "await", "client", ...
[ 22, 4 ]
[ 51, 9 ]
python
en
['en', 'en', 'en']
True
HfApi.login
(self, username: str, password: str)
Call HF API to sign in a user and get a token if credentials are valid. Outputs: token if credentials are valid Throws: requests.exceptions.HTTPError if credentials are invalid
Call HF API to sign in a user and get a token if credentials are valid.
def login(self, username: str, password: str) -> str: """ Call HF API to sign in a user and get a token if credentials are valid. Outputs: token if credentials are valid Throws: requests.exceptions.HTTPError if credentials are invalid """ path = "{}/api/login".format(se...
[ "def", "login", "(", "self", ",", "username", ":", "str", ",", "password", ":", "str", ")", "->", "str", ":", "path", "=", "\"{}/api/login\"", ".", "format", "(", "self", ".", "endpoint", ")", "r", "=", "requests", ".", "post", "(", "path", ",", "j...
[ 77, 4 ]
[ 89, 25 ]
python
en
['en', 'error', 'th']
False
HfApi.whoami
(self, token: str)
Call HF API to know "whoami"
Call HF API to know "whoami"
def whoami(self, token: str) -> Tuple[str, List[str]]: """ Call HF API to know "whoami" """ path = "{}/api/whoami".format(self.endpoint) r = requests.get(path, headers={"authorization": "Bearer {}".format(token)}) r.raise_for_status() d = r.json() return d...
[ "def", "whoami", "(", "self", ",", "token", ":", "str", ")", "->", "Tuple", "[", "str", ",", "List", "[", "str", "]", "]", ":", "path", "=", "\"{}/api/whoami\"", ".", "format", "(", "self", ".", "endpoint", ")", "r", "=", "requests", ".", "get", ...
[ 91, 4 ]
[ 99, 35 ]
python
en
['en', 'error', 'th']
False
HfApi.logout
(self, token: str)
Call HF API to log out.
Call HF API to log out.
def logout(self, token: str) -> None: """ Call HF API to log out. """ path = "{}/api/logout".format(self.endpoint) r = requests.post(path, headers={"authorization": "Bearer {}".format(token)}) r.raise_for_status()
[ "def", "logout", "(", "self", ",", "token", ":", "str", ")", "->", "None", ":", "path", "=", "\"{}/api/logout\"", ".", "format", "(", "self", ".", "endpoint", ")", "r", "=", "requests", ".", "post", "(", "path", ",", "headers", "=", "{", "\"authoriza...
[ 101, 4 ]
[ 107, 28 ]
python
en
['en', 'error', 'th']
False
HfApi.model_list
(self)
Get the public list of all the models on huggingface.co
Get the public list of all the models on huggingface.co
def model_list(self) -> List[ModelInfo]: """ Get the public list of all the models on huggingface.co """ path = "{}/api/models".format(self.endpoint) r = requests.get(path) r.raise_for_status() d = r.json() return [ModelInfo(**x) for x in d]
[ "def", "model_list", "(", "self", ")", "->", "List", "[", "ModelInfo", "]", ":", "path", "=", "\"{}/api/models\"", ".", "format", "(", "self", ".", "endpoint", ")", "r", "=", "requests", ".", "get", "(", "path", ")", "r", ".", "raise_for_status", "(", ...
[ 109, 4 ]
[ 117, 42 ]
python
en
['en', 'error', 'th']
False
HfApi.list_repos_objs
(self, token: str, organization: Optional[str] = None)
HuggingFace git-based system, used for models. Call HF API to list all stored files for user (or one of their organizations).
HuggingFace git-based system, used for models.
def list_repos_objs(self, token: str, organization: Optional[str] = None) -> List[RepoObj]: """ HuggingFace git-based system, used for models. Call HF API to list all stored files for user (or one of their organizations). """ path = "{}/api/repos/ls".format(self.endpoint) ...
[ "def", "list_repos_objs", "(", "self", ",", "token", ":", "str", ",", "organization", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "List", "[", "RepoObj", "]", ":", "path", "=", "\"{}/api/repos/ls\"", ".", "format", "(", "self", ".", "endp...
[ 119, 4 ]
[ 130, 40 ]
python
en
['en', 'error', 'th']
False
HfApi.create_repo
( self, token: str, name: str, organization: Optional[str] = None, private: Optional[bool] = None, exist_ok=False, lfsmultipartthresh: Optional[int] = None, )
HuggingFace git-based system, used for models. Call HF API to create a whole repo. Params: private: Whether the model repo should be private (requires a paid huggingface.co account) exist_ok: Do not raise an error if repo already exists lfsmultipartthresh...
HuggingFace git-based system, used for models.
def create_repo( self, token: str, name: str, organization: Optional[str] = None, private: Optional[bool] = None, exist_ok=False, lfsmultipartthresh: Optional[int] = None, ) -> str: """ HuggingFace git-based system, used for models. Ca...
[ "def", "create_repo", "(", "self", ",", "token", ":", "str", ",", "name", ":", "str", ",", "organization", ":", "Optional", "[", "str", "]", "=", "None", ",", "private", ":", "Optional", "[", "bool", "]", "=", "None", ",", "exist_ok", "=", "False", ...
[ 132, 4 ]
[ 166, 23 ]
python
en
['en', 'error', 'th']
False
HfApi.delete_repo
(self, token: str, name: str, organization: Optional[str] = None)
HuggingFace git-based system, used for models. Call HF API to delete a whole repo. CAUTION(this is irreversible).
HuggingFace git-based system, used for models.
def delete_repo(self, token: str, name: str, organization: Optional[str] = None): """ HuggingFace git-based system, used for models. Call HF API to delete a whole repo. CAUTION(this is irreversible). """ path = "{}/api/repos/delete".format(self.endpoint) r = req...
[ "def", "delete_repo", "(", "self", ",", "token", ":", "str", ",", "name", ":", "str", ",", "organization", ":", "Optional", "[", "str", "]", "=", "None", ")", ":", "path", "=", "\"{}/api/repos/delete\"", ".", "format", "(", "self", ".", "endpoint", ")"...
[ 168, 4 ]
[ 182, 28 ]
python
en
['en', 'error', 'th']
False
HfFolder.save_token
(cls, token)
Save token, creating folder as needed.
Save token, creating folder as needed.
def save_token(cls, token): """ Save token, creating folder as needed. """ os.makedirs(os.path.dirname(cls.path_token), exist_ok=True) with open(cls.path_token, "w+") as f: f.write(token)
[ "def", "save_token", "(", "cls", ",", "token", ")", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "cls", ".", "path_token", ")", ",", "exist_ok", "=", "True", ")", "with", "open", "(", "cls", ".", "path_token", ",", "\"w+...
[ 212, 4 ]
[ 218, 26 ]
python
en
['en', 'error', 'th']
False
HfFolder.get_token
(cls)
Get token or None if not existent.
Get token or None if not existent.
def get_token(cls): """ Get token or None if not existent. """ try: with open(cls.path_token, "r") as f: return f.read() except FileNotFoundError: pass
[ "def", "get_token", "(", "cls", ")", ":", "try", ":", "with", "open", "(", "cls", ".", "path_token", ",", "\"r\"", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")", "except", "FileNotFoundError", ":", "pass" ]
[ 221, 4 ]
[ 229, 16 ]
python
en
['en', 'error', 'th']
False
HfFolder.delete_token
(cls)
Delete token. Do not fail if token does not exist.
Delete token. Do not fail if token does not exist.
def delete_token(cls): """ Delete token. Do not fail if token does not exist. """ try: os.remove(cls.path_token) except FileNotFoundError: pass
[ "def", "delete_token", "(", "cls", ")", ":", "try", ":", "os", ".", "remove", "(", "cls", ".", "path_token", ")", "except", "FileNotFoundError", ":", "pass" ]
[ 232, 4 ]
[ 239, 16 ]
python
en
['en', 'error', 'th']
False
GiosFlowHandler.async_step_user
(self, user_input=None)
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" errors = {} if user_input is not None: try: await self.async_set_unique_id( user_input[CONF_STATION_ID], raise_on_progress=False ) ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "try", ":", "await", "self", ".", "async_set_unique_id", "(", "user_input", "[", "CONF_STATION_...
[ 28, 4 ]
[ 58, 9 ]
python
en
['en', 'en', 'en']
True
_async_has_devices
(hass)
Return if there are devices that can be discovered. This function will be called if no devices are already found through the zeroconf integration.
Return if there are devices that can be discovered.
async def _async_has_devices(hass): """ Return if there are devices that can be discovered. This function will be called if no devices are already found through the zeroconf integration. """ zeroconf_instance = ChromeCastZeroconf.get_zeroconf() if zeroconf_instance is None: zerocon...
[ "async", "def", "_async_has_devices", "(", "hass", ")", ":", "zeroconf_instance", "=", "ChromeCastZeroconf", ".", "get_zeroconf", "(", ")", "if", "zeroconf_instance", "is", "None", ":", "zeroconf_instance", "=", "await", "zeroconf", ".", "async_get_instance", "(", ...
[ 13, 0 ]
[ 29, 16 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass: HomeAssistant, config: dict)
Set up the HVV component.
Set up the HVV component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the HVV component.""" return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "return", "True" ]
[ 16, 0 ]
[ 18, 15 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up HVV from a config entry.
Set up HVV from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up HVV from a config entry.""" hub = GTIHub( entry.data[CONF_HOST], entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], aiohttp_client.async_get_clientsession(hass), ) hass.data.setdefault(DO...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "hub", "=", "GTIHub", "(", "entry", ".", "data", "[", "CONF_HOST", "]", ",", "entry", ".", "data", "[", "CONF_USERNAME", "]", ",", "entry"...
[ 21, 0 ]
[ 39, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload...
[ 42, 0 ]
[ 52, 20 ]
python
en
['en', 'es', 'en']
True
test_form_zeroconf
(hass)
Test we can setup from zeroconf.
Test we can setup from zeroconf.
async def test_form_zeroconf(hass): """Test we can setup from zeroconf.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data={"host": "192.168.1.5", "port": 1234}, ) assert result["type"] == data_entry_flow.RESULT...
[ "async", "def", "test_form_zeroconf", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_ZEROCONF", "}", ","...
[ 19, 0 ]
[ 72, 48 ]
python
en
['en', 'en', 'en']
True
test_form_user_one_ups
(hass)
Test we get the form.
Test we get the form.
async def test_form_user_one_ups(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert r...
[ "async", "def", "test_form_user_one_ups", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "asyn...
[ 75, 0 ]
[ 130, 48 ]
python
en
['en', 'en', 'en']
True
test_form_user_multiple_ups
(hass)
Test we get the form.
Test we get the form.
async def test_form_user_multiple_ups(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) config_entry = MockConfigEntry( domain=DOMAIN, data={"host": "2.2.2.2", "port": 123, "resources": ["battery.charge"]}, options={CONF_RESOUR...
[ "async", "def", "test_form_user_multiple_ups", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ...
[ 133, 0 ]
[ 210, 48 ]
python
en
['en', 'en', 'en']
True
test_form_import
(hass)
Test we get the form with import source.
Test we get the form with import source.
async def test_form_import(hass): """Test we get the form with import source.""" await setup.async_setup_component(hass, "persistent_notification", {}) mock_pynut = _get_mock_pynutclient( list_vars={"battery.voltage": "serial"}, list_ups={"ups1": "UPS 1", "ups2": "UPS2"}, ) with pa...
[ "async", "def", "test_form_import", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "mock_pynut", "=", "_get_mock_pynutclient", "(", "list_vars", "=", "{", "\"battery.volta...
[ 213, 0 ]
[ 252, 48 ]
python
en
['en', 'en', 'en']
True
test_form_import_dupe
(hass)
Test we get abort on duplicate import.
Test we get abort on duplicate import.
async def test_form_import_dupe(hass): """Test we get abort on duplicate import.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( D...
[ "async", "def", "test_form_import_dupe", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "="...
[ 255, 0 ]
[ 266, 51 ]
python
en
['nl', 'en', 'en']
True
test_form_import_with_ignored_entry
(hass)
Test we get abort on duplicate import when there is an ignored one.
Test we get abort on duplicate import when there is an ignored one.
async def test_form_import_with_ignored_entry(hass): """Test we get abort on duplicate import when there is an ignored one.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG) entry.add_to_hass(hass) ignored_entry = Moc...
[ "async", "def", "test_form_import_with_ignored_entry", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ...
[ 269, 0 ]
[ 284, 51 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) mock_pynut = _get_mock_pynutclient() with patch( "homeassistant.components.nut.PyNUTClie...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 287, 0 ]
[ 310, 58 ]
python
en
['en', 'en', 'en']
True
test_options_flow
(hass)
Test config flow options.
Test config flow options.
async def test_options_flow(hass): """Test config flow options.""" config_entry = MockConfigEntry( domain=DOMAIN, unique_id="abcde12345", data=VALID_CONFIG, options={CONF_RESOURCES: ["battery.charge"]}, ) config_entry.add_to_hass(hass) mock_pynut = _get_mock_pynutcl...
[ "async", "def", "test_options_flow", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"abcde12345\"", ",", "data", "=", "VALID_CONFIG", ",", "options", "=", "{", "CONF_RESOURCES", ":", "[", ...
[ 313, 0 ]
[ 365, 9 ]
python
en
['en', 'fr', 'en']
True
test_user_form
(hass, canary_config_flow)
Test we get the user initiated form.
Test we get the user initiated form.
async def test_user_form(hass, canary_config_flow): """Test we get the user initiated form.""" await async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == RESULT_TYPE_...
[ "async", "def", "test_user_form", "(", "hass", ",", "canary_config_flow", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", ...
[ 23, 0 ]
[ 45, 48 ]
python
en
['en', 'en', 'en']
True
test_user_form_cannot_connect
(hass, canary_config_flow)
Test we handle errors that should trigger the cannot connect error.
Test we handle errors that should trigger the cannot connect error.
async def test_user_form_cannot_connect(hass, canary_config_flow): """Test we handle errors that should trigger the cannot connect error.""" canary_config_flow.side_effect = HTTPError() result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) result = a...
[ "async", "def", "test_user_form_cannot_connect", "(", "hass", ",", "canary_config_flow", ")", ":", "canary_config_flow", ".", "side_effect", "=", "HTTPError", "(", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "...
[ 48, 0 ]
[ 72, 57 ]
python
en
['en', 'en', 'en']
True
test_user_form_unexpected_exception
(hass, canary_config_flow)
Test we handle unexpected exception.
Test we handle unexpected exception.
async def test_user_form_unexpected_exception(hass, canary_config_flow): """Test we handle unexpected exception.""" canary_config_flow.side_effect = Exception() result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) result = await hass.config_entries....
[ "async", "def", "test_user_form_unexpected_exception", "(", "hass", ",", "canary_config_flow", ")", ":", "canary_config_flow", ".", "side_effect", "=", "Exception", "(", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 75, 0 ]
[ 89, 40 ]
python
en
['de', 'en', 'en']
True
test_user_form_single_instance_allowed
(hass, canary_config_flow)
Test that configuring more than one instance is rejected.
Test that configuring more than one instance is rejected.
async def test_user_form_single_instance_allowed(hass, canary_config_flow): """Test that configuring more than one instance is rejected.""" await init_integration(hass, skip_entry_setup=True) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, ...
[ "async", "def", "test_user_form_single_instance_allowed", "(", "hass", ",", "canary_config_flow", ")", ":", "await", "init_integration", "(", "hass", ",", "skip_entry_setup", "=", "True", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", "."...
[ 92, 0 ]
[ 102, 56 ]
python
en
['en', 'en', 'en']
True
test_options_flow
(hass, canary)
Test updating options.
Test updating options.
async def test_options_flow(hass, canary): """Test updating options.""" with patch("homeassistant.components.canary.PLATFORMS", []): entry = await init_integration(hass) assert entry.options[CONF_FFMPEG_ARGUMENTS] == DEFAULT_FFMPEG_ARGUMENTS assert entry.options[CONF_TIMEOUT] == DEFAULT_TIMEOUT...
[ "async", "def", "test_options_flow", "(", "hass", ",", "canary", ")", ":", "with", "patch", "(", "\"homeassistant.components.canary.PLATFORMS\"", ",", "[", "]", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "assert", "entry", ".", "opt...
[ 105, 0 ]
[ 126, 44 ]
python
en
['en', 'en', 'en']
True
test_test_all
()
Test if we can test the all group.
Test if we can test the all group.
def test_test_all(): """Test if we can test the all group.""" for val in (None, {}, {"all": None}, {"all": {}}): assert util.test_all(val, "read") is False for val in (True, {"all": True}, {"all": {"read": True}}): assert util.test_all(val, "read") is True
[ "def", "test_test_all", "(", ")", ":", "for", "val", "in", "(", "None", ",", "{", "}", ",", "{", "\"all\"", ":", "None", "}", ",", "{", "\"all\"", ":", "{", "}", "}", ")", ":", "assert", "util", ".", "test_all", "(", "val", ",", "\"read\"", ")"...
[ 5, 0 ]
[ 11, 49 ]
python
en
['en', 'en', 'en']
True
prox_owl
(v, w)
Proximal operator of the OWL norm dot(w, reversed(sort(v))) Follows description and notation from: X. Zeng, M. Figueiredo, The ordered weighted L1 norm: Atomic formulation, dual norm, and projections. eprint http://arxiv.org/abs/1409.4271
Proximal operator of the OWL norm dot(w, reversed(sort(v)))
def prox_owl(v, w): """Proximal operator of the OWL norm dot(w, reversed(sort(v))) Follows description and notation from: X. Zeng, M. Figueiredo, The ordered weighted L1 norm: Atomic formulation, dual norm, and projections. eprint http://arxiv.org/abs/1409.4271 """ # wlog operate on ab...
[ "def", "prox_owl", "(", "v", ",", "w", ")", ":", "# wlog operate on absolute values", "v_abs", "=", "np", ".", "abs", "(", "v", ")", "ix", "=", "np", ".", "argsort", "(", "v_abs", ")", "[", ":", ":", "-", "1", "]", "v_abs", "=", "v_abs", "[", "ix...
[ 39, 0 ]
[ 61, 29 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the World clock sensor.
Set up the World clock sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the World clock sensor.""" name = config.get(CONF_NAME) time_zone = dt_util.get_time_zone(config.get(CONF_TIME_ZONE)) async_add_entities( [ WorldClockSensor( time_zone, ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "time_zone", "=", "dt_util", ".", "get_time_zone", "(", "co...
[ 24, 0 ]
[ 38, 5 ]
python
en
['en', 'su', 'en']
True
WorldClockSensor.__init__
(self, time_zone, name, time_format)
Initialize the sensor.
Initialize the sensor.
def __init__(self, time_zone, name, time_format): """Initialize the sensor.""" self._name = name self._time_zone = time_zone self._state = None self._time_format = time_format
[ "def", "__init__", "(", "self", ",", "time_zone", ",", "name", ",", "time_format", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_time_zone", "=", "time_zone", "self", ".", "_state", "=", "None", "self", ".", "_time_format", "=", "time_forma...
[ 44, 4 ]
[ 49, 39 ]
python
en
['en', 'en', 'en']
True
WorldClockSensor.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" ]
[ 52, 4 ]
[ 54, 25 ]
python
en
['en', 'en', 'en']
True
WorldClockSensor.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" ]
[ 57, 4 ]
[ 59, 26 ]
python
en
['en', 'en', 'en']
True
WorldClockSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 62, 4 ]
[ 64, 19 ]
python
en
['en', 'en', 'en']
True
WorldClockSensor.async_update
(self)
Get the time and updates the states.
Get the time and updates the states.
async def async_update(self): """Get the time and updates the states.""" self._state = dt_util.now(time_zone=self._time_zone).strftime(self._time_format)
[ "async", "def", "async_update", "(", "self", ")", ":", "self", ".", "_state", "=", "dt_util", ".", "now", "(", "time_zone", "=", "self", ".", "_time_zone", ")", ".", "strftime", "(", "self", ".", "_time_format", ")" ]
[ 66, 4 ]
[ 68, 88 ]
python
en
['en', 'en', 'en']
True
test_create_new
(hass)
Test creating a new config file.
Test creating a new config file.
def test_create_new(hass): """Test creating a new config file.""" with patch("builtins.open", mock_open()), patch( "os.path.isfile", Mock(return_value=False) ), patch.object(rtm.RememberTheMilkConfiguration, "save_config"): config = rtm.RememberTheMilkConfiguration(hass) config.set_t...
[ "def", "test_create_new", "(", "hass", ")", ":", "with", "patch", "(", "\"builtins.open\"", ",", "mock_open", "(", ")", ")", ",", "patch", "(", "\"os.path.isfile\"", ",", "Mock", "(", "return_value", "=", "False", ")", ")", ",", "patch", ".", "object", "...
[ 8, 0 ]
[ 15, 45 ]
python
en
['en', 'en', 'en']
True
test_load_config
(hass)
Test loading an existing token from the file.
Test loading an existing token from the file.
def test_load_config(hass): """Test loading an existing token from the file.""" with patch("builtins.open", mock_open(read_data=JSON_STRING)), patch( "os.path.isfile", Mock(return_value=True) ): config = rtm.RememberTheMilkConfiguration(hass) assert config.get_token(PROFILE) == TOKEN
[ "def", "test_load_config", "(", "hass", ")", ":", "with", "patch", "(", "\"builtins.open\"", ",", "mock_open", "(", "read_data", "=", "JSON_STRING", ")", ")", ",", "patch", "(", "\"os.path.isfile\"", ",", "Mock", "(", "return_value", "=", "True", ")", ")", ...
[ 18, 0 ]
[ 24, 45 ]
python
en
['en', 'en', 'en']
True
test_invalid_data
(hass)
Test starts with invalid data and should not raise an exception.
Test starts with invalid data and should not raise an exception.
def test_invalid_data(hass): """Test starts with invalid data and should not raise an exception.""" with patch("builtins.open", mock_open(read_data="random characters")), patch( "os.path.isfile", Mock(return_value=True) ): config = rtm.RememberTheMilkConfiguration(hass) assert config is ...
[ "def", "test_invalid_data", "(", "hass", ")", ":", "with", "patch", "(", "\"builtins.open\"", ",", "mock_open", "(", "read_data", "=", "\"random characters\"", ")", ")", ",", "patch", "(", "\"os.path.isfile\"", ",", "Mock", "(", "return_value", "=", "True", ")...
[ 27, 0 ]
[ 33, 29 ]
python
en
['en', 'en', 'en']
True
test_id_map
(hass)
Test the hass to rtm task is mapping.
Test the hass to rtm task is mapping.
def test_id_map(hass): """Test the hass to rtm task is mapping.""" hass_id = "hass-id-1234" list_id = "mylist" timeseries_id = "my_timeseries" rtm_id = "rtm-id-4567" with patch("builtins.open", mock_open()), patch( "os.path.isfile", Mock(return_value=False) ), patch.object(rtm.Rememb...
[ "def", "test_id_map", "(", "hass", ")", ":", "hass_id", "=", "\"hass-id-1234\"", "list_id", "=", "\"mylist\"", "timeseries_id", "=", "\"my_timeseries\"", "rtm_id", "=", "\"rtm-id-4567\"", "with", "patch", "(", "\"builtins.open\"", ",", "mock_open", "(", ")", ")", ...
[ 36, 0 ]
[ 51, 58 ]
python
en
['en', 'en', 'en']
True