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
SpcBinarySensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return _get_device_class(self._zone.type)
[ "def", "device_class", "(", "self", ")", ":", "return", "_get_device_class", "(", "self", ".", "_zone", ".", "type", ")" ]
[ 76, 4 ]
[ 78, 49 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the LG webOS Smart TV platform.
Set up the LG webOS Smart TV platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the LG webOS Smart TV platform.""" if discovery_info is None: return host = discovery_info[CONF_HOST] name = discovery_info[CONF_NAME] customize = discovery_info[CONF_CUSTOMIZE] turn_on_act...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "host", "=", "discovery_info", "[", "CONF_HOST", "]", "name", "=",...
[ 65, 0 ]
[ 81, 57 ]
python
en
['en', 'da', '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 ( asyncio.TimeoutError, asyncio.CancelledError, PyLGTVCmd...
[ "def", "cmd", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "async", "def", "wrapper", "(", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap all command methods.\"\"\"", "try", ":", "await", "func", "(", "obj", ",", "*...
[ 84, 0 ]
[ 110, 18 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.__init__
(self, client: WebOsClient, name: str, customize, on_script=None)
Initialize the webos device.
Initialize the webos device.
def __init__(self, client: WebOsClient, name: str, customize, on_script=None): """Initialize the webos device.""" self._client = client self._name = name self._unique_id = client.client_key self._customize = customize self._on_script = on_script # Assume that the...
[ "def", "__init__", "(", "self", ",", "client", ":", "WebOsClient", ",", "name", ":", "str", ",", "customize", ",", "on_script", "=", "None", ")", ":", "self", ".", "_client", "=", "client", "self", ".", "_name", "=", "name", "self", ".", "_unique_id", ...
[ 116, 4 ]
[ 128, 30 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_added_to_hass
(self)
Connect and subscribe to dispatcher signals and state updates.
Connect and subscribe to dispatcher signals and state updates.
async def async_added_to_hass(self): """Connect and subscribe to dispatcher signals and state updates.""" async_dispatcher_connect(self.hass, DOMAIN, self.async_signal_handler) await self._client.register_state_update_callback( self.async_handle_state_update )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "DOMAIN", ",", "self", ".", "async_signal_handler", ")", "await", "self", ".", "_client", ".", "register_state_update_callback", "(", "self", ...
[ 130, 4 ]
[ 136, 9 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_will_remove_from_hass
(self)
Call disconnect on removal.
Call disconnect on removal.
async def async_will_remove_from_hass(self): """Call disconnect on removal.""" self._client.unregister_state_update_callback(self.async_handle_state_update)
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "self", ".", "_client", ".", "unregister_state_update_callback", "(", "self", ".", "async_handle_state_update", ")" ]
[ 138, 4 ]
[ 140, 85 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_signal_handler
(self, data)
Handle domain-specific signal by calling appropriate method.
Handle domain-specific signal by calling appropriate method.
async def async_signal_handler(self, data): """Handle domain-specific signal by calling appropriate method.""" entity_ids = data[ATTR_ENTITY_ID] if entity_ids == ENTITY_MATCH_NONE: return if entity_ids == ENTITY_MATCH_ALL or self.entity_id in entity_ids: params =...
[ "async", "def", "async_signal_handler", "(", "self", ",", "data", ")", ":", "entity_ids", "=", "data", "[", "ATTR_ENTITY_ID", "]", "if", "entity_ids", "==", "ENTITY_MATCH_NONE", ":", "return", "if", "entity_ids", "==", "ENTITY_MATCH_ALL", "or", "self", ".", "e...
[ 142, 4 ]
[ 154, 57 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_handle_state_update
(self)
Update state from WebOsClient.
Update state from WebOsClient.
async def async_handle_state_update(self): """Update state from WebOsClient.""" self.update_sources() self.async_write_ha_state()
[ "async", "def", "async_handle_state_update", "(", "self", ")", ":", "self", ".", "update_sources", "(", ")", "self", ".", "async_write_ha_state", "(", ")" ]
[ 156, 4 ]
[ 160, 35 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.update_sources
(self)
Update list of sources from current source, apps, inputs and configured list.
Update list of sources from current source, apps, inputs and configured list.
def update_sources(self): """Update list of sources from current source, apps, inputs and configured list.""" source_list = self._source_list self._source_list = {} conf_sources = self._customize[CONF_SOURCES] found_live_tv = False for app in self._client.apps.values(): ...
[ "def", "update_sources", "(", "self", ")", ":", "source_list", "=", "self", ".", "_source_list", "self", ".", "_source_list", "=", "{", "}", "conf_sources", "=", "self", ".", "_customize", "[", "CONF_SOURCES", "]", "found_live_tv", "=", "False", "for", "app"...
[ 162, 4 ]
[ 210, 43 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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" ]
[ 230, 4 ]
[ 232, 30 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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" ]
[ 235, 4 ]
[ 237, 25 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.device_class
(self)
Return the device class of the device.
Return the device class of the device.
def device_class(self): """Return the device class of the device.""" return DEVICE_CLASS_TV
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TV" ]
[ 240, 4 ]
[ 242, 30 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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._client.is_on: return STATE_ON return STATE_OFF
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "is_on", ":", "return", "STATE_ON", "return", "STATE_OFF" ]
[ 245, 4 ]
[ 250, 24 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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._client.muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_client", ".", "muted" ]
[ 253, 4 ]
[ 255, 33 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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 self._client.volume is not None: return self._client.volume / 100.0 return None
[ "def", "volume_level", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "volume", "is", "not", "None", ":", "return", "self", ".", "_client", ".", "volume", "/", "100.0", "return", "None" ]
[ 258, 4 ]
[ 263, 19 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.source
(self)
Return the current input source.
Return the current input source.
def source(self): """Return the current input source.""" return self._current_source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_current_source" ]
[ 266, 4 ]
[ 268, 35 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.source_list
(self)
List of available input sources.
List of available input sources.
def source_list(self): """List of available input sources.""" return sorted(list(self._source_list))
[ "def", "source_list", "(", "self", ")", ":", "return", "sorted", "(", "list", "(", "self", ".", "_source_list", ")", ")" ]
[ 271, 4 ]
[ 273, 46 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.media_content_type
(self)
Content type of current playing media.
Content type of current playing media.
def media_content_type(self): """Content type of current playing media.""" if self._client.current_appId == LIVE_TV_APP_ID: return MEDIA_TYPE_CHANNEL return None
[ "def", "media_content_type", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "current_appId", "==", "LIVE_TV_APP_ID", ":", "return", "MEDIA_TYPE_CHANNEL", "return", "None" ]
[ 276, 4 ]
[ 281, 19 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" if (self._client.current_appId == LIVE_TV_APP_ID) and ( self._client.current_channel is not None ): return self._client.current_channel.get("channelName") return None
[ "def", "media_title", "(", "self", ")", ":", "if", "(", "self", ".", "_client", ".", "current_appId", "==", "LIVE_TV_APP_ID", ")", "and", "(", "self", ".", "_client", ".", "current_channel", "is", "not", "None", ")", ":", "return", "self", ".", "_client"...
[ 284, 4 ]
[ 290, 19 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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.""" if self._client.current_appId in self._client.apps: icon = self._client.apps[self._client.current_appId]["largeIcon"] if not icon.startswith("http"): icon = self._client.apps[self._client.current...
[ "def", "media_image_url", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "current_appId", "in", "self", ".", "_client", ".", "apps", ":", "icon", "=", "self", ".", "_client", ".", "apps", "[", "self", ".", "_client", ".", "current_appId", "]...
[ 293, 4 ]
[ 300, 19 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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.""" supported = SUPPORT_WEBOSTV if (self._client.sound_output == "external_arc") or ( self._client.sound_output == "external_speaker" ): supported = supported | SUPPORT_WEBOSTV_VOLUME ...
[ "def", "supported_features", "(", "self", ")", ":", "supported", "=", "SUPPORT_WEBOSTV", "if", "(", "self", ".", "_client", ".", "sound_output", "==", "\"external_arc\"", ")", "or", "(", "self", ".", "_client", ".", "sound_output", "==", "\"external_speaker\"", ...
[ 303, 4 ]
[ 317, 24 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self): """Return device specific state attributes.""" if self._client.sound_output is None and self.state == STATE_OFF: return {} return {ATTR_SOUND_OUTPUT: self._client.sound_output}
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_client", ".", "sound_output", "is", "None", "and", "self", ".", "state", "==", "STATE_OFF", ":", "return", "{", "}", "return", "{", "ATTR_SOUND_OUTPUT", ":", "self", ".", "_clien...
[ 320, 4 ]
[ 324, 61 ]
python
en
['fr', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_turn_off
(self)
Turn off media player.
Turn off media player.
async def async_turn_off(self): """Turn off media player.""" await self._client.power_off()
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "await", "self", ".", "_client", ".", "power_off", "(", ")" ]
[ 327, 4 ]
[ 329, 38 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_turn_on
(self)
Turn on the media player.
Turn on the media player.
async def async_turn_on(self): """Turn on the media player.""" if self._on_script: await self._on_script.async_run(context=self._context)
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "if", "self", ".", "_on_script", ":", "await", "self", ".", "_on_script", ".", "async_run", "(", "context", "=", "self", ".", "_context", ")" ]
[ 331, 4 ]
[ 334, 66 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.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._client.volume_up()
[ "async", "def", "async_volume_up", "(", "self", ")", ":", "await", "self", ".", "_client", ".", "volume_up", "(", ")" ]
[ 337, 4 ]
[ 339, 38 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_volume_down
(self)
Volume down media player.
Volume down media player.
async def async_volume_down(self): """Volume down media player.""" await self._client.volume_down()
[ "async", "def", "async_volume_down", "(", "self", ")", ":", "await", "self", ".", "_client", ".", "volume_down", "(", ")" ]
[ 342, 4 ]
[ 344, 40 ]
python
en
['en', 'sl', 'en']
True
LgWebOSMediaPlayerEntity.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.""" tv_volume = int(round(volume * 100)) await self._client.set_volume(tv_volume)
[ "async", "def", "async_set_volume_level", "(", "self", ",", "volume", ")", ":", "tv_volume", "=", "int", "(", "round", "(", "volume", "*", "100", ")", ")", "await", "self", ".", "_client", ".", "set_volume", "(", "tv_volume", ")" ]
[ 347, 4 ]
[ 350, 48 ]
python
en
['fr', 'zu', 'en']
False
LgWebOSMediaPlayerEntity.async_mute_volume
(self, mute)
Send mute command.
Send mute command.
async def async_mute_volume(self, mute): """Send mute command.""" await self._client.set_mute(mute)
[ "async", "def", "async_mute_volume", "(", "self", ",", "mute", ")", ":", "await", "self", ".", "_client", ".", "set_mute", "(", "mute", ")" ]
[ 353, 4 ]
[ 355, 41 ]
python
en
['en', 'co', 'en']
True
LgWebOSMediaPlayerEntity.async_select_sound_output
(self, sound_output)
Select the sound output.
Select the sound output.
async def async_select_sound_output(self, sound_output): """Select the sound output.""" await self._client.change_sound_output(sound_output)
[ "async", "def", "async_select_sound_output", "(", "self", ",", "sound_output", ")", ":", "await", "self", ".", "_client", ".", "change_sound_output", "(", "sound_output", ")" ]
[ 358, 4 ]
[ 360, 60 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_media_play_pause
(self)
Simulate play pause media player.
Simulate play pause media player.
async def async_media_play_pause(self): """Simulate play pause media player.""" if self._paused: await self.async_media_play() else: await self.async_media_pause()
[ "async", "def", "async_media_play_pause", "(", "self", ")", ":", "if", "self", ".", "_paused", ":", "await", "self", ".", "async_media_play", "(", ")", "else", ":", "await", "self", ".", "async_media_pause", "(", ")" ]
[ 363, 4 ]
[ 368, 42 ]
python
en
['en', 'en', 'it']
True
LgWebOSMediaPlayerEntity.async_select_source
(self, source)
Select input source.
Select input source.
async def async_select_source(self, source): """Select input source.""" source_dict = self._source_list.get(source) if source_dict is None: _LOGGER.warning("Source %s not found for %s", source, self.name) return if source_dict.get("title"): await self....
[ "async", "def", "async_select_source", "(", "self", ",", "source", ")", ":", "source_dict", "=", "self", ".", "_source_list", ".", "get", "(", "source", ")", "if", "source_dict", "is", "None", ":", "_LOGGER", ".", "warning", "(", "\"Source %s not found for %s\...
[ 371, 4 ]
[ 380, 59 ]
python
en
['fr', 'su', 'en']
False
LgWebOSMediaPlayerEntity.async_play_media
(self, media_type, media_id, **kwargs)
Play a piece of media.
Play a piece of media.
async def async_play_media(self, media_type, media_id, **kwargs): """Play a piece of media.""" _LOGGER.debug("Call play media type <%s>, Id <%s>", media_type, media_id) if media_type == MEDIA_TYPE_CHANNEL: _LOGGER.debug("Searching channel...") partial_match_channel_id = ...
[ "async", "def", "async_play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Call play media type <%s>, Id <%s>\"", ",", "media_type", ",", "media_id", ")", "if", "media_type", "==", "...
[ 383, 4 ]
[ 415, 72 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_media_play
(self)
Send play command.
Send play command.
async def async_media_play(self): """Send play command.""" self._paused = False await self._client.play()
[ "async", "def", "async_media_play", "(", "self", ")", ":", "self", ".", "_paused", "=", "False", "await", "self", ".", "_client", ".", "play", "(", ")" ]
[ 418, 4 ]
[ 421, 33 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_media_pause
(self)
Send media pause command to media player.
Send media pause command to media player.
async def async_media_pause(self): """Send media pause command to media player.""" self._paused = True await self._client.pause()
[ "async", "def", "async_media_pause", "(", "self", ")", ":", "self", ".", "_paused", "=", "True", "await", "self", ".", "_client", ".", "pause", "(", ")" ]
[ 424, 4 ]
[ 427, 34 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_media_stop
(self)
Send stop command to media player.
Send stop command to media player.
async def async_media_stop(self): """Send stop command to media player.""" await self._client.stop()
[ "async", "def", "async_media_stop", "(", "self", ")", ":", "await", "self", ".", "_client", ".", "stop", "(", ")" ]
[ 430, 4 ]
[ 432, 33 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_media_next_track
(self)
Send next track command.
Send next track command.
async def async_media_next_track(self): """Send next track command.""" current_input = self._client.get_input() if current_input == LIVE_TV_APP_ID: await self._client.channel_up() else: await self._client.fast_forward()
[ "async", "def", "async_media_next_track", "(", "self", ")", ":", "current_input", "=", "self", ".", "_client", ".", "get_input", "(", ")", "if", "current_input", "==", "LIVE_TV_APP_ID", ":", "await", "self", ".", "_client", ".", "channel_up", "(", ")", "else...
[ 435, 4 ]
[ 441, 45 ]
python
en
['en', 'pt', 'en']
True
LgWebOSMediaPlayerEntity.async_media_previous_track
(self)
Send the previous track command.
Send the previous track command.
async def async_media_previous_track(self): """Send the previous track command.""" current_input = self._client.get_input() if current_input == LIVE_TV_APP_ID: await self._client.channel_down() else: await self._client.rewind()
[ "async", "def", "async_media_previous_track", "(", "self", ")", ":", "current_input", "=", "self", ".", "_client", ".", "get_input", "(", ")", "if", "current_input", "==", "LIVE_TV_APP_ID", ":", "await", "self", ".", "_client", ".", "channel_down", "(", ")", ...
[ 444, 4 ]
[ 450, 39 ]
python
en
['en', 'en', 'en']
True
LgWebOSMediaPlayerEntity.async_button
(self, button)
Send a button press.
Send a button press.
async def async_button(self, button): """Send a button press.""" await self._client.button(button)
[ "async", "def", "async_button", "(", "self", ",", "button", ")", ":", "await", "self", ".", "_client", ".", "button", "(", "button", ")" ]
[ 453, 4 ]
[ 455, 41 ]
python
en
['en', 'ht', 'en']
True
LgWebOSMediaPlayerEntity.async_command
(self, command, **kwargs)
Send a command.
Send a command.
async def async_command(self, command, **kwargs): """Send a command.""" await self._client.request(command, payload=kwargs.get(ATTR_PAYLOAD))
[ "async", "def", "async_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_client", ".", "request", "(", "command", ",", "payload", "=", "kwargs", ".", "get", "(", "ATTR_PAYLOAD", ")", ")" ]
[ 458, 4 ]
[ 460, 77 ]
python
en
['en', 'en', 'en']
True
GumbelVectorQuantizer.__init__
(self, dim, num_vars, min_temperature, max_temperature, temperature_decay, num_groups, vq_dim)
Vector quantization using gumbel softmax Args: dim: input dimension (channels) num_vars: number of quantized vectors per group temperature: temperature for training. this should be a tuple of 3 elements: (start, stop, decay factor) groups: number of groups for ve...
Vector quantization using gumbel softmax
def __init__(self, dim, num_vars, min_temperature, max_temperature, temperature_decay, num_groups, vq_dim): """Vector quantization using gumbel softmax Args: dim: input dimension (channels) num_vars: number of quantized vectors per group temperature: temperature for ...
[ "def", "__init__", "(", "self", ",", "dim", ",", "num_vars", ",", "min_temperature", ",", "max_temperature", ",", "temperature_decay", ",", "num_groups", ",", "vq_dim", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "num_groups", "=",...
[ 459, 4 ]
[ 492, 36 ]
python
en
['es', 'la', 'en']
False
GumbelVectorQuantizer.targets_for
(self, x)
Get the output of the gumbel softmax or hard estimator and convert to one-hots :param x: [B, T, GxV] :return: y [B, T, G]
Get the output of the gumbel softmax or hard estimator and convert to one-hots
def targets_for(self, x): """Get the output of the gumbel softmax or hard estimator and convert to one-hots :param x: [B, T, GxV] :return: y [B, T, G] """ bsz = x.shape[0] tsz = x.shape[1] x = x.view(bsz * tsz, -1) targets = x.view(bsz * tsz * self.num_gr...
[ "def", "targets_for", "(", "self", ",", "x", ")", ":", "bsz", "=", "x", ".", "shape", "[", "0", "]", "tsz", "=", "x", ".", "shape", "[", "1", "]", "x", "=", "x", ".", "view", "(", "bsz", "*", "tsz", ",", "-", "1", ")", "targets", "=", "x"...
[ 534, 4 ]
[ 544, 22 ]
python
en
['en', 'en', 'en']
True
Wav2Vec2PooledEncoder._reduction_1
(self, encoded, pad_mask)
Do a reduction using just the lengths and input
Do a reduction using just the lengths and input
def _reduction_1(self, encoded, pad_mask): """Do a reduction using just the lengths and input""" lengths = pad_mask.sum(-1) return self.reduction_layer((encoded, lengths))
[ "def", "_reduction_1", "(", "self", ",", "encoded", ",", "pad_mask", ")", ":", "lengths", "=", "pad_mask", ".", "sum", "(", "-", "1", ")", "return", "self", ".", "reduction_layer", "(", "(", "encoded", ",", "lengths", ")", ")" ]
[ 847, 4 ]
[ 850, 55 ]
python
en
['en', 'en', 'en']
True
Wav2Vec2PooledEncoder._reduction_3
(self, encoded, pad_mask)
Do a reduction using an attention layer with encoder as KQ and V
Do a reduction using an attention layer with encoder as KQ and V
def _reduction_3(self, encoded, pad_mask): """Do a reduction using an attention layer with encoder as KQ and V""" encoded_query = self.reduction_layer((encoded, encoded, encoded, pad_mask.unsqueeze(1).unsqueeze(1))) return encoded_query
[ "def", "_reduction_3", "(", "self", ",", "encoded", ",", "pad_mask", ")", ":", "encoded_query", "=", "self", ".", "reduction_layer", "(", "(", "encoded", ",", "encoded", ",", "encoded", ",", "pad_mask", ".", "unsqueeze", "(", "1", ")", ".", "unsqueeze", ...
[ 852, 4 ]
[ 855, 28 ]
python
en
['en', 'en', 'en']
True
Wav2Vec2PooledEncoder._no_reduction_mask
(self, encoded, pad_mask)
Do no reduction and return the tensor and the pad vector
Do no reduction and return the tensor and the pad vector
def _no_reduction_mask(self, encoded, pad_mask): """Do no reduction and return the tensor and the pad vector""" return (encoded, pad_mask.unsqueeze(1).unsqueeze(1),)
[ "def", "_no_reduction_mask", "(", "self", ",", "encoded", ",", "pad_mask", ")", ":", "return", "(", "encoded", ",", "pad_mask", ".", "unsqueeze", "(", "1", ")", ".", "unsqueeze", "(", "1", ")", ",", ")" ]
[ 857, 4 ]
[ 859, 61 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Home Connect binary sensor.
Set up the Home Connect binary sensor.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Home Connect binary sensor.""" def get_entities(): entities = [] hc_api = hass.data[DOMAIN][config_entry.entry_id] for device_dict in hc_api.devices: entity_dicts = device_dict.get("entities",...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "def", "get_entities", "(", ")", ":", "entities", "=", "[", "]", "hc_api", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", ...
[ 11, 0 ]
[ 22, 77 ]
python
en
['en', 'en', 'en']
True
HomeConnectBinarySensor.__init__
(self, device, desc, device_class)
Initialize the entity.
Initialize the entity.
def __init__(self, device, desc, device_class): """Initialize the entity.""" super().__init__(device, desc) self._device_class = device_class self._state = None
[ "def", "__init__", "(", "self", ",", "device", ",", "desc", ",", "device_class", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "desc", ")", "self", ".", "_device_class", "=", "device_class", "self", ".", "_state", "=", "None" ]
[ 28, 4 ]
[ 32, 26 ]
python
en
['en', 'en', 'en']
True
HomeConnectBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return bool(self._state)
[ "def", "is_on", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "_state", ")" ]
[ 35, 4 ]
[ 37, 32 ]
python
en
['en', 'fy', 'en']
True
HomeConnectBinarySensor.available
(self)
Return true if the binary sensor is available.
Return true if the binary sensor is available.
def available(self): """Return true if the binary sensor is available.""" return self._state is not None
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_state", "is", "not", "None" ]
[ 40, 4 ]
[ 42, 38 ]
python
en
['en', 'en', 'en']
True
HomeConnectBinarySensor.async_update
(self)
Update the binary sensor's status.
Update the binary sensor's status.
async def async_update(self): """Update the binary sensor's status.""" state = self.device.appliance.status.get(BSH_DOOR_STATE, {}) if not state: self._state = None elif state.get("value") in [ "BSH.Common.EnumType.DoorState.Closed", "BSH.Common.EnumTy...
[ "async", "def", "async_update", "(", "self", ")", ":", "state", "=", "self", ".", "device", ".", "appliance", ".", "status", ".", "get", "(", "BSH_DOOR_STATE", ",", "{", "}", ")", "if", "not", "state", ":", "self", ".", "_state", "=", "None", "elif",...
[ 44, 4 ]
[ 59, 60 ]
python
en
['en', 'sn', 'en']
True
HomeConnectBinarySensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 62, 4 ]
[ 64, 33 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Channels platform.
Set up the Channels platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Channels platform.""" device = ChannelsPlayer(config[CONF_NAME], config[CONF_HOST], config[CONF_PORT]) async_add_entities([device], True) platform = entity_platform.current_platform.get() platform....
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "device", "=", "ChannelsPlayer", "(", "config", "[", "CONF_NAME", "]", ",", "config", "[", "CONF_HOST", "]", ",", "co...
[ 59, 0 ]
[ 80, 5 ]
python
en
['en', 'da', 'en']
True
ChannelsPlayer.__init__
(self, name, host, port)
Initialize the Channels app.
Initialize the Channels app.
def __init__(self, name, host, port): """Initialize the Channels app.""" self._name = name self._host = host self._port = port self.client = Channels(self._host, self._port) self.status = None self.muted = None self.channel_number = None self.c...
[ "def", "__init__", "(", "self", ",", "name", ",", "host", ",", "port", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_host", "=", "host", "self", ".", "_port", "=", "port", "self", ".", "client", "=", "Channels", "(", "self", ".", "_...
[ 86, 4 ]
[ 109, 35 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.update_favorite_channels
(self)
Update the favorite channels from the client.
Update the favorite channels from the client.
def update_favorite_channels(self): """Update the favorite channels from the client.""" self.favorite_channels = self.client.favorite_channels()
[ "def", "update_favorite_channels", "(", "self", ")", ":", "self", ".", "favorite_channels", "=", "self", ".", "client", ".", "favorite_channels", "(", ")" ]
[ 111, 4 ]
[ 113, 64 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.update_state
(self, state_hash)
Update all the state properties with the passed in dictionary.
Update all the state properties with the passed in dictionary.
def update_state(self, state_hash): """Update all the state properties with the passed in dictionary.""" self.status = state_hash.get("status", "stopped") self.muted = state_hash.get("muted", False) channel_hash = state_hash.get("channel") np_hash = state_hash.get("now_playing")...
[ "def", "update_state", "(", "self", ",", "state_hash", ")", ":", "self", ".", "status", "=", "state_hash", ".", "get", "(", "\"status\"", ",", "\"stopped\"", ")", "self", ".", "muted", "=", "state_hash", ".", "get", "(", "\"muted\"", ",", "False", ")", ...
[ 115, 4 ]
[ 145, 45 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.name
(self)
Return the name of the player.
Return the name of the player.
def name(self): """Return the name of the player.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 148, 4 ]
[ 150, 25 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.state
(self)
Return the state of the player.
Return the state of the player.
def state(self): """Return the state of the player.""" if self.status == "stopped": return STATE_IDLE if self.status == "paused": return STATE_PAUSED if self.status == "playing": return STATE_PLAYING return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "status", "==", "\"stopped\"", ":", "return", "STATE_IDLE", "if", "self", ".", "status", "==", "\"paused\"", ":", "return", "STATE_PAUSED", "if", "self", ".", "status", "==", "\"playing\"", ":", "...
[ 153, 4 ]
[ 164, 19 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.update
(self)
Retrieve latest state.
Retrieve latest state.
def update(self): """Retrieve latest state.""" self.update_favorite_channels() self.update_state(self.client.status())
[ "def", "update", "(", "self", ")", ":", "self", ".", "update_favorite_channels", "(", ")", "self", ".", "update_state", "(", "self", ".", "client", ".", "status", "(", ")", ")" ]
[ 166, 4 ]
[ 169, 47 ]
python
en
['es', 'sk', 'en']
False
ChannelsPlayer.source_list
(self)
List of favorite channels.
List of favorite channels.
def source_list(self): """List of favorite channels.""" sources = [channel["name"] for channel in self.favorite_channels] return sources
[ "def", "source_list", "(", "self", ")", ":", "sources", "=", "[", "channel", "[", "\"name\"", "]", "for", "channel", "in", "self", ".", "favorite_channels", "]", "return", "sources" ]
[ 172, 4 ]
[ 175, 22 ]
python
en
['en', 'fy', 'en']
True
ChannelsPlayer.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.muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "muted" ]
[ 178, 4 ]
[ 180, 25 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.media_content_id
(self)
Content ID of current playing channel.
Content ID of current playing channel.
def media_content_id(self): """Content ID of current playing channel.""" return self.channel_number
[ "def", "media_content_id", "(", "self", ")", ":", "return", "self", ".", "channel_number" ]
[ 183, 4 ]
[ 185, 34 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.media_content_type
(self)
Content type of current playing media.
Content type of current playing media.
def media_content_type(self): """Content type of current playing media.""" return MEDIA_TYPE_CHANNEL
[ "def", "media_content_type", "(", "self", ")", ":", "return", "MEDIA_TYPE_CHANNEL" ]
[ 188, 4 ]
[ 190, 33 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.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.""" if self.now_playing_image_url: return self.now_playing_image_url if self.channel_image_url: return self.channel_image_url return "https://getchannels.com/assets/img/icon-1024.png"
[ "def", "media_image_url", "(", "self", ")", ":", "if", "self", ".", "now_playing_image_url", ":", "return", "self", ".", "now_playing_image_url", "if", "self", ".", "channel_image_url", ":", "return", "self", ".", "channel_image_url", "return", "\"https://getchannel...
[ 193, 4 ]
[ 200, 65 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" if self.state: return self.now_playing_title return None
[ "def", "media_title", "(", "self", ")", ":", "if", "self", ".", "state", ":", "return", "self", ".", "now_playing_title", "return", "None" ]
[ 203, 4 ]
[ 208, 19 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.supported_features
(self)
Flag of media commands that are supported.
Flag of media commands that are supported.
def supported_features(self): """Flag of media commands that are supported.""" return FEATURE_SUPPORT
[ "def", "supported_features", "(", "self", ")", ":", "return", "FEATURE_SUPPORT" ]
[ 211, 4 ]
[ 213, 30 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.mute_volume
(self, mute)
Mute (true) or unmute (false) player.
Mute (true) or unmute (false) player.
def mute_volume(self, mute): """Mute (true) or unmute (false) player.""" if mute != self.muted: response = self.client.toggle_muted() self.update_state(response)
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "if", "mute", "!=", "self", ".", "muted", ":", "response", "=", "self", ".", "client", ".", "toggle_muted", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 215, 4 ]
[ 219, 39 ]
python
en
['en', 'la', 'it']
False
ChannelsPlayer.media_stop
(self)
Send media_stop command to player.
Send media_stop command to player.
def media_stop(self): """Send media_stop command to player.""" self.status = "stopped" response = self.client.stop() self.update_state(response)
[ "def", "media_stop", "(", "self", ")", ":", "self", ".", "status", "=", "\"stopped\"", "response", "=", "self", ".", "client", ".", "stop", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 221, 4 ]
[ 225, 35 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.media_play
(self)
Send media_play command to player.
Send media_play command to player.
def media_play(self): """Send media_play command to player.""" response = self.client.resume() self.update_state(response)
[ "def", "media_play", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "resume", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 227, 4 ]
[ 230, 35 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.media_pause
(self)
Send media_pause command to player.
Send media_pause command to player.
def media_pause(self): """Send media_pause command to player.""" response = self.client.pause() self.update_state(response)
[ "def", "media_pause", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "pause", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 232, 4 ]
[ 235, 35 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.media_next_track
(self)
Seek ahead.
Seek ahead.
def media_next_track(self): """Seek ahead.""" response = self.client.skip_forward() self.update_state(response)
[ "def", "media_next_track", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "skip_forward", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 237, 4 ]
[ 240, 35 ]
python
af
['et', 'af', 'en']
False
ChannelsPlayer.select_source
(self, source)
Select a channel to tune to.
Select a channel to tune to.
def select_source(self, source): """Select a channel to tune to.""" for channel in self.favorite_channels: if channel["name"] == source: response = self.client.play_channel(channel["number"]) self.update_state(response) break
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "for", "channel", "in", "self", ".", "favorite_channels", ":", "if", "channel", "[", "\"name\"", "]", "==", "source", ":", "response", "=", "self", ".", "client", ".", "play_channel", "(", "ch...
[ 247, 4 ]
[ 253, 21 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.play_media
(self, media_type, media_id, **kwargs)
Send the play_media command to the player.
Send the play_media command to the player.
def play_media(self, media_type, media_id, **kwargs): """Send the play_media command to the player.""" if media_type == MEDIA_TYPE_CHANNEL: response = self.client.play_channel(media_id) self.update_state(response) elif media_type in [MEDIA_TYPE_MOVIE, MEDIA_TYPE_EPISODE, ...
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "if", "media_type", "==", "MEDIA_TYPE_CHANNEL", ":", "response", "=", "self", ".", "client", ".", "play_channel", "(", "media_id", ")", "self", ".", ...
[ 255, 4 ]
[ 262, 39 ]
python
en
['en', 'en', 'en']
True
ChannelsPlayer.seek_forward
(self)
Seek forward in the timeline.
Seek forward in the timeline.
def seek_forward(self): """Seek forward in the timeline.""" response = self.client.seek_forward() self.update_state(response)
[ "def", "seek_forward", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "seek_forward", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 264, 4 ]
[ 267, 35 ]
python
en
['en', 'af', 'en']
True
ChannelsPlayer.seek_backward
(self)
Seek backward in the timeline.
Seek backward in the timeline.
def seek_backward(self): """Seek backward in the timeline.""" response = self.client.seek_backward() self.update_state(response)
[ "def", "seek_backward", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "seek_backward", "(", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 269, 4 ]
[ 272, 35 ]
python
en
['en', 'fy', 'en']
True
ChannelsPlayer.seek_by
(self, seconds)
Seek backward in the timeline.
Seek backward in the timeline.
def seek_by(self, seconds): """Seek backward in the timeline.""" response = self.client.seek(seconds) self.update_state(response)
[ "def", "seek_by", "(", "self", ",", "seconds", ")", ":", "response", "=", "self", ".", "client", ".", "seek", "(", "seconds", ")", "self", ".", "update_state", "(", "response", ")" ]
[ 274, 4 ]
[ 277, 35 ]
python
en
['en', 'fy', 'en']
True
get_device_platforms
(device)
Return the HA platforms for a device type.
Return the HA platforms for a device type.
def get_device_platforms(device): """Return the HA platforms for a device type.""" return DEVICE_PLATFORM.get(type(device), {}).keys()
[ "def", "get_device_platforms", "(", "device", ")", ":", "return", "DEVICE_PLATFORM", ".", "get", "(", "type", "(", "device", ")", ",", "{", "}", ")", ".", "keys", "(", ")" ]
[ 105, 0 ]
[ 107, 55 ]
python
en
['en', 'en', 'en']
True
get_platform_groups
(device, domain)
Return the platforms that a device belongs in.
Return the platforms that a device belongs in.
def get_platform_groups(device, domain) -> dict: """Return the platforms that a device belongs in.""" return DEVICE_PLATFORM.get(type(device), {}).get(domain, {})
[ "def", "get_platform_groups", "(", "device", ",", "domain", ")", "->", "dict", ":", "return", "DEVICE_PLATFORM", ".", "get", "(", "type", "(", "device", ")", ",", "{", "}", ")", ".", "get", "(", "domain", ",", "{", "}", ")" ]
[ 110, 0 ]
[ 112, 64 ]
python
en
['en', 'en', 'en']
True
DevoloMultiLevelSwitchDeviceEntity.__init__
(self, homecontrol, device_instance, element_uid)
Initialize a multi level switch within devolo Home Control.
Initialize a multi level switch within devolo Home Control.
def __init__(self, homecontrol, device_instance, element_uid): """Initialize a multi level switch within devolo Home Control.""" super().__init__( homecontrol=homecontrol, device_instance=device_instance, element_uid=element_uid, ) self._multi_level_sw...
[ "def", "__init__", "(", "self", ",", "homecontrol", ",", "device_instance", ",", "element_uid", ")", ":", "super", "(", ")", ".", "__init__", "(", "homecontrol", "=", "homecontrol", ",", "device_instance", "=", "device_instance", ",", "element_uid", "=", "elem...
[ 7, 4 ]
[ 18, 61 ]
python
en
['en', 'en', 'en']
True
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect.""" for entry in hass.config_entries.async_entries(DOMAIN): if entry.data[CONF_HOST] == data[CONF_HOST]: raise AlreadyConfigured if data[CONF_VERSION] not in SUPPORTED_VERSIONS: ...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "for", "entry", "in", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ":", "if", "entry", ".", "data", "[", "CONF_HOST", "]"...
[ 43, 0 ]
[ 55, 36 ]
python
en
['en', 'en', 'en']
True
GlancesFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return GlancesOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "GlancesOptionsFlowHandler", "(", "config_entry", ")" ]
[ 66, 4 ]
[ 68, 54 ]
python
en
['en', 'en', 'en']
True
GlancesFlowHandler.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: try: await validate_input(self.hass, user_input) return self.async_create_entry( title=user_input[CONF_NAME], da...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "try", ":", "await", "validate_input", "(", "self", ".", "hass", ",", "user_input", ")", "r...
[ 70, 4 ]
[ 88, 9 ]
python
en
['en', 'en', 'en']
True
GlancesFlowHandler.async_step_import
(self, import_config)
Import from Glances sensor config.
Import from Glances sensor config.
async def async_step_import(self, import_config): """Import from Glances sensor config.""" return await self.async_step_user(user_input=import_config)
[ "async", "def", "async_step_import", "(", "self", ",", "import_config", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", "=", "import_config", ")" ]
[ 90, 4 ]
[ 93, 67 ]
python
en
['en', 'pt', 'en']
True
GlancesOptionsFlowHandler.__init__
(self, config_entry)
Initialize Glances options flow.
Initialize Glances options flow.
def __init__(self, config_entry): """Initialize Glances options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 99, 4 ]
[ 101, 40 ]
python
en
['en', 'fr', 'en']
True
GlancesOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the Glances options.
Manage the Glances options.
async def async_step_init(self, user_input=None): """Manage the Glances options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) options = { vol.Optional( CONF_SCAN_INTERVAL, default=self.config_entr...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "options", ...
[ 103, 4 ]
[ 117, 84 ]
python
en
['en', 'en', 'en']
True
Blueprint.__init__
( self, data: dict, *, path: Optional[str] = None, expected_domain: Optional[str] = None, )
Initialize a blueprint.
Initialize a blueprint.
def __init__( self, data: dict, *, path: Optional[str] = None, expected_domain: Optional[str] = None, ) -> None: """Initialize a blueprint.""" try: data = self.data = BLUEPRINT_SCHEMA(data) except vol.Invalid as err: raise Inval...
[ "def", "__init__", "(", "self", ",", "data", ":", "dict", ",", "*", ",", "path", ":", "Optional", "[", "str", "]", "=", "None", ",", "expected_domain", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "None", ":", "try", ":", "data"...
[ 40, 4 ]
[ 75, 13 ]
python
en
['en', 'fr', 'en']
True
Blueprint.name
(self)
Return blueprint name.
Return blueprint name.
def name(self) -> str: """Return blueprint name.""" return self.data[CONF_BLUEPRINT][CONF_NAME]
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "data", "[", "CONF_BLUEPRINT", "]", "[", "CONF_NAME", "]" ]
[ 78, 4 ]
[ 80, 51 ]
python
en
['fr', 'no', 'en']
False
Blueprint.metadata
(self)
Return blueprint metadata.
Return blueprint metadata.
def metadata(self) -> dict: """Return blueprint metadata.""" return self.data[CONF_BLUEPRINT]
[ "def", "metadata", "(", "self", ")", "->", "dict", ":", "return", "self", ".", "data", "[", "CONF_BLUEPRINT", "]" ]
[ 83, 4 ]
[ 85, 40 ]
python
en
['fr', 'is', 'en']
False
Blueprint.update_metadata
(self, *, source_url: Optional[str] = None)
Update metadata.
Update metadata.
def update_metadata(self, *, source_url: Optional[str] = None) -> None: """Update metadata.""" if source_url is not None: self.data[CONF_BLUEPRINT][CONF_SOURCE_URL] = source_url
[ "def", "update_metadata", "(", "self", ",", "*", ",", "source_url", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "if", "source_url", "is", "not", "None", ":", "self", ".", "data", "[", "CONF_BLUEPRINT", "]", "[", "CONF_SOURCE_...
[ 87, 4 ]
[ 90, 67 ]
python
en
['en', 'la', 'it']
False
Blueprint.yaml
(self)
Dump blueprint as YAML.
Dump blueprint as YAML.
def yaml(self) -> str: """Dump blueprint as YAML.""" return yaml.dump(self.data)
[ "def", "yaml", "(", "self", ")", "->", "str", ":", "return", "yaml", ".", "dump", "(", "self", ".", "data", ")" ]
[ 92, 4 ]
[ 94, 35 ]
python
en
['en', 'ga', 'en']
True
Blueprint.validate
(self)
Test if the Home Assistant installation supports this blueprint. Return list of errors if not valid.
Test if the Home Assistant installation supports this blueprint.
def validate(self) -> Optional[List[str]]: """Test if the Home Assistant installation supports this blueprint. Return list of errors if not valid. """ errors = [] metadata = self.metadata min_version = metadata.get(CONF_HOMEASSISTANT, {}).get(CONF_MIN_VERSION) i...
[ "def", "validate", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "errors", "=", "[", "]", "metadata", "=", "self", ".", "metadata", "min_version", "=", "metadata", ".", "get", "(", "CONF_HOMEASSISTANT", ",", "{", "}", ")...
[ 97, 4 ]
[ 111, 29 ]
python
en
['en', 'en', 'en']
True
BlueprintInputs.__init__
( self, blueprint: Blueprint, config_with_inputs: Dict[str, Any] )
Instantiate a blueprint inputs object.
Instantiate a blueprint inputs object.
def __init__( self, blueprint: Blueprint, config_with_inputs: Dict[str, Any] ) -> None: """Instantiate a blueprint inputs object.""" self.blueprint = blueprint self.config_with_inputs = config_with_inputs
[ "def", "__init__", "(", "self", ",", "blueprint", ":", "Blueprint", ",", "config_with_inputs", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "self", ".", "blueprint", "=", "blueprint", "self", ".", "config_with_inputs", "=", "config_wit...
[ 117, 4 ]
[ 122, 52 ]
python
en
['en', 'lb', 'en']
True
BlueprintInputs.inputs
(self)
Return the inputs.
Return the inputs.
def inputs(self): """Return the inputs.""" return self.config_with_inputs[CONF_USE_BLUEPRINT][CONF_INPUT]
[ "def", "inputs", "(", "self", ")", ":", "return", "self", ".", "config_with_inputs", "[", "CONF_USE_BLUEPRINT", "]", "[", "CONF_INPUT", "]" ]
[ 125, 4 ]
[ 127, 70 ]
python
en
['en', 'mt', 'en']
True
BlueprintInputs.validate
(self)
Validate the inputs.
Validate the inputs.
def validate(self) -> None: """Validate the inputs.""" missing = self.blueprint.placeholders - set(self.inputs) if missing: raise MissingPlaceholder( self.blueprint.domain, self.blueprint.name, missing )
[ "def", "validate", "(", "self", ")", "->", "None", ":", "missing", "=", "self", ".", "blueprint", ".", "placeholders", "-", "set", "(", "self", ".", "inputs", ")", "if", "missing", ":", "raise", "MissingPlaceholder", "(", "self", ".", "blueprint", ".", ...
[ 129, 4 ]
[ 136, 13 ]
python
en
['en', 'en', 'en']
True
BlueprintInputs.async_substitute
(self)
Get the blueprint value with the inputs substituted.
Get the blueprint value with the inputs substituted.
def async_substitute(self) -> dict: """Get the blueprint value with the inputs substituted.""" processed = placeholder.substitute(self.blueprint.data, self.inputs) combined = {**self.config_with_inputs, **processed} # From config_with_inputs combined.pop(CONF_USE_BLUEPRINT) ...
[ "def", "async_substitute", "(", "self", ")", "->", "dict", ":", "processed", "=", "placeholder", ".", "substitute", "(", "self", ".", "blueprint", ".", "data", ",", "self", ".", "inputs", ")", "combined", "=", "{", "*", "*", "self", ".", "config_with_inp...
[ 142, 4 ]
[ 150, 23 ]
python
en
['en', 'en', 'en']
True
DomainBlueprints.__init__
( self, hass: HomeAssistant, domain: str, logger: logging.Logger, )
Initialize a domain blueprints instance.
Initialize a domain blueprints instance.
def __init__( self, hass: HomeAssistant, domain: str, logger: logging.Logger, ) -> None: """Initialize a domain blueprints instance.""" self.hass = hass self.domain = domain self.logger = logger self._blueprints = {} self._load_lock = a...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "domain", ":", "str", ",", "logger", ":", "logging", ".", "Logger", ",", ")", "->", "None", ":", "self", ".", "hass", "=", "hass", "self", ".", "domain", "=", "domain", "self", ...
[ 156, 4 ]
[ 169, 55 ]
python
en
['en', 'fr', 'en']
True
DomainBlueprints.async_reset_cache
(self)
Reset the blueprint cache.
Reset the blueprint cache.
def async_reset_cache(self) -> None: """Reset the blueprint cache.""" self._blueprints = {}
[ "def", "async_reset_cache", "(", "self", ")", "->", "None", ":", "self", ".", "_blueprints", "=", "{", "}" ]
[ 172, 4 ]
[ 174, 29 ]
python
en
['en', 'fr', 'en']
True
DomainBlueprints._load_blueprint
(self, blueprint_path)
Load a blueprint.
Load a blueprint.
def _load_blueprint(self, blueprint_path) -> Blueprint: """Load a blueprint.""" try: blueprint_data = yaml.load_yaml( self.hass.config.path(BLUEPRINT_FOLDER, self.domain, blueprint_path) ) except (HomeAssistantError, FileNotFoundError) as err: ...
[ "def", "_load_blueprint", "(", "self", ",", "blueprint_path", ")", "->", "Blueprint", ":", "try", ":", "blueprint_data", "=", "yaml", ".", "load_yaml", "(", "self", ".", "hass", ".", "config", ".", "path", "(", "BLUEPRINT_FOLDER", ",", "self", ".", "domain...
[ 176, 4 ]
[ 187, 9 ]
python
en
['en', 'ca', 'en']
True
DomainBlueprints._load_blueprints
(self)
Load all the blueprints.
Load all the blueprints.
def _load_blueprints(self) -> Dict[str, Union[Blueprint, BlueprintException]]: """Load all the blueprints.""" blueprint_folder = pathlib.Path( self.hass.config.path(BLUEPRINT_FOLDER, self.domain) ) results = {} for blueprint_path in blueprint_folder.glob("**/*.yaml")...
[ "def", "_load_blueprints", "(", "self", ")", "->", "Dict", "[", "str", ",", "Union", "[", "Blueprint", ",", "BlueprintException", "]", "]", ":", "blueprint_folder", "=", "pathlib", ".", "Path", "(", "self", ".", "hass", ".", "config", ".", "path", "(", ...
[ 189, 4 ]
[ 210, 22 ]
python
en
['en', 'en', 'en']
True
DomainBlueprints.async_get_blueprints
( self, )
Get all the blueprints.
Get all the blueprints.
async def async_get_blueprints( self, ) -> Dict[str, Union[Blueprint, BlueprintException]]: """Get all the blueprints.""" async with self._load_lock: return await self.hass.async_add_executor_job(self._load_blueprints)
[ "async", "def", "async_get_blueprints", "(", "self", ",", ")", "->", "Dict", "[", "str", ",", "Union", "[", "Blueprint", ",", "BlueprintException", "]", "]", ":", "async", "with", "self", ".", "_load_lock", ":", "return", "await", "self", ".", "hass", "....
[ 212, 4 ]
[ 217, 80 ]
python
en
['en', 'en', 'en']
True
DomainBlueprints.async_get_blueprint
(self, blueprint_path: str)
Get a blueprint.
Get a blueprint.
async def async_get_blueprint(self, blueprint_path: str) -> Blueprint: """Get a blueprint.""" if blueprint_path in self._blueprints: return self._blueprints[blueprint_path] async with self._load_lock: # Check it again if blueprint_path in self._blueprints: ...
[ "async", "def", "async_get_blueprint", "(", "self", ",", "blueprint_path", ":", "str", ")", "->", "Blueprint", ":", "if", "blueprint_path", "in", "self", ".", "_blueprints", ":", "return", "self", ".", "_blueprints", "[", "blueprint_path", "]", "async", "with"...
[ 219, 4 ]
[ 238, 28 ]
python
en
['en', 'lb', 'en']
True
DomainBlueprints.async_inputs_from_config
( self, config_with_blueprint: dict )
Process a blueprint config.
Process a blueprint config.
async def async_inputs_from_config( self, config_with_blueprint: dict ) -> BlueprintInputs: """Process a blueprint config.""" try: config_with_blueprint = BLUEPRINT_INSTANCE_FIELDS(config_with_blueprint) except vol.Invalid as err: raise InvalidBlueprintInputs(...
[ "async", "def", "async_inputs_from_config", "(", "self", ",", "config_with_blueprint", ":", "dict", ")", "->", "BlueprintInputs", ":", "try", ":", "config_with_blueprint", "=", "BLUEPRINT_INSTANCE_FIELDS", "(", "config_with_blueprint", ")", "except", "vol", ".", "Inva...
[ 240, 4 ]
[ 255, 21 ]
python
en
['en', 'ca', 'en']
True