Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_if_action_after_sunset_no_offset_kotzebue
(hass, calls)
Test if action was after sunrise. Local timezone: Alaska time Location: Kotzebue, which has a very skewed local timezone with sunrise at 7 AM and sunset at 3AM during summer After sunset is true from sunset until midnight, local time.
Test if action was after sunrise.
async def test_if_action_after_sunset_no_offset_kotzebue(hass, calls): """ Test if action was after sunrise. Local timezone: Alaska time Location: Kotzebue, which has a very skewed local timezone with sunrise at 7 AM and sunset at 3AM during summer After sunset is true from sunset until midnigh...
[ "async", "def", "test_if_action_after_sunset_no_offset_kotzebue", "(", "hass", ",", "calls", ")", ":", "tz", "=", "dt_util", ".", "get_time_zone", "(", "\"America/Anchorage\"", ")", "dt_util", ".", "set_default_time_zone", "(", "tz", ")", "hass", ".", "config", "....
[ 803, 0 ]
[ 856, 30 ]
python
en
['en', 'error', 'th']
False
test_setup_entry_account_error
(hass)
Test entry setup failed due to account error.
Test entry setup failed due to account error.
async def test_setup_entry_account_error(hass): """Test entry setup failed due to account error.""" entry = MockConfigEntry( domain=DOMAIN, title="test_username", unique_id="test_username", data=CONFIG, options=None, ) with patch( "homeassistant.components...
[ "async", "def", "test_setup_entry_account_error", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"test_username\"", ",", "unique_id", "=", "\"test_username\"", ",", "data", "=", "CONFIG", ",", "options"...
[ 11, 0 ]
[ 28, 26 ]
python
en
['en', 'en', 'en']
True
test_setup_entry_session_error
(hass)
Test entry setup failed due to session error.
Test entry setup failed due to session error.
async def test_setup_entry_session_error(hass): """Test entry setup failed due to session error.""" entry = MockConfigEntry( domain=DOMAIN, title="test_username", unique_id="test_username", data=CONFIG, options=None, ) with patch( "homeassistant.components...
[ "async", "def", "test_setup_entry_session_error", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"test_username\"", ",", "unique_id", "=", "\"test_username\"", ",", "data", "=", "CONFIG", ",", "options"...
[ 31, 0 ]
[ 48, 26 ]
python
en
['en', 'en', 'en']
True
test_unload_entry
(hass)
Test successful unload of entry.
Test successful unload of entry.
async def test_unload_entry(hass): """Test successful unload of entry.""" entry = await init_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state == ENTRY_STATE_LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_bloc...
[ "async", "def", "test_unload_entry", "(", "hass", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ")", "==", "1", "assert", "entry", ".", ...
[ 51, 0 ]
[ 62, 36 ]
python
en
['en', 'en', 'en']
True
get_layers_to_supervise
(n_student, n_teacher)
Used or the --supervise_forward kwarg
Used or the --supervise_forward kwarg
def get_layers_to_supervise(n_student, n_teacher) -> List[int]: """Used or the --supervise_forward kwarg""" if n_student > n_teacher: raise ValueError(f"Cannot perform intermediate supervision for student {n_student} > teacher {n_teacher}") elif n_teacher == n_student: return list(range(n_te...
[ "def", "get_layers_to_supervise", "(", "n_student", ",", "n_teacher", ")", "->", "List", "[", "int", "]", ":", "if", "n_student", ">", "n_teacher", ":", "raise", "ValueError", "(", "f\"Cannot perform intermediate supervision for student {n_student} > teacher {n_teacher}\"",...
[ 65, 0 ]
[ 74, 56 ]
python
en
['en', 'en', 'sw']
True
create_student_by_copying_alternating_layers
( teacher: Union[str, PreTrainedModel], save_path: Union[str, Path] = "student", e: Union[int, None] = None, d: Union[int, None] = None, copy_first_teacher_layers=False, e_layers_to_copy=None, d_layers_to_copy=None, **extra_config_kwargs )
Make a student by copying alternating layers from a teacher, save it to save_path. Args: teacher: str or PreTrainedModel if str, this will call AutoModelForSeq2SeqLM.from_pretrained(teacher) before copying layers save_path: where to save the student, defaults to student directory. e:...
Make a student by copying alternating layers from a teacher, save it to save_path. Args: teacher: str or PreTrainedModel if str, this will call AutoModelForSeq2SeqLM.from_pretrained(teacher) before copying layers save_path: where to save the student, defaults to student directory. e:...
def create_student_by_copying_alternating_layers( teacher: Union[str, PreTrainedModel], save_path: Union[str, Path] = "student", e: Union[int, None] = None, d: Union[int, None] = None, copy_first_teacher_layers=False, e_layers_to_copy=None, d_layers_to_copy=None, **extra_config_kwargs ) ...
[ "def", "create_student_by_copying_alternating_layers", "(", "teacher", ":", "Union", "[", "str", ",", "PreTrainedModel", "]", ",", "save_path", ":", "Union", "[", "str", ",", "Path", "]", "=", "\"student\"", ",", "e", ":", "Union", "[", "int", ",", "None", ...
[ 77, 0 ]
[ 168, 54 ]
python
en
['en', 'en', 'en']
True
determine_zones
(receiver)
Determine what zones are available for the receiver.
Determine what zones are available for the receiver.
def determine_zones(receiver): """Determine what zones are available for the receiver.""" out = {"zone2": False, "zone3": False} try: _LOGGER.debug("Checking for zone 2 capability") receiver.raw("ZPWQSTN") out["zone2"] = True except ValueError as error: if str(error) != T...
[ "def", "determine_zones", "(", "receiver", ")", ":", "out", "=", "{", "\"zone2\"", ":", "False", ",", "\"zone3\"", ":", "False", "}", "try", ":", "_LOGGER", ".", "debug", "(", "\"Checking for zone 2 capability\"", ")", "receiver", ".", "raw", "(", "\"ZPWQSTN...
[ 117, 0 ]
[ 139, 14 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Onkyo platform.
Set up the Onkyo platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Onkyo platform.""" host = config.get(CONF_HOST) hosts = [] def service_handle(service): """Handle for services.""" entity_ids = service.data.get(ATTR_ENTITY_ID) devices = [d for d in hosts if d.en...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "hosts", "=", "[", "]", "def", "service_handle", "(", "service", ")", ":", ...
[ 142, 0 ]
[ 212, 29 ]
python
en
['en', 'lv', 'en']
True
OnkyoDevice.__init__
( self, receiver, sources, name=None, max_volume=SUPPORTED_MAX_VOLUME, receiver_max_volume=DEFAULT_RECEIVER_MAX_VOLUME, )
Initialize the Onkyo Receiver.
Initialize the Onkyo Receiver.
def __init__( self, receiver, sources, name=None, max_volume=SUPPORTED_MAX_VOLUME, receiver_max_volume=DEFAULT_RECEIVER_MAX_VOLUME, ): """Initialize the Onkyo Receiver.""" self._receiver = receiver self._muted = False self._volume = 0 ...
[ "def", "__init__", "(", "self", ",", "receiver", ",", "sources", ",", "name", "=", "None", ",", "max_volume", "=", "SUPPORTED_MAX_VOLUME", ",", "receiver_max_volume", "=", "DEFAULT_RECEIVER_MAX_VOLUME", ",", ")", ":", "self", ".", "_receiver", "=", "receiver", ...
[ 218, 4 ]
[ 241, 39 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.command
(self, command)
Run an eiscp command and catch connection errors.
Run an eiscp command and catch connection errors.
def command(self, command): """Run an eiscp command and catch connection errors.""" try: result = self._receiver.command(command) except (ValueError, OSError, AttributeError, AssertionError): if self._receiver.command_socket: self._receiver.command_socket ...
[ "def", "command", "(", "self", ",", "command", ")", ":", "try", ":", "result", "=", "self", ".", "_receiver", ".", "command", "(", "command", ")", "except", "(", "ValueError", ",", "OSError", ",", "AttributeError", ",", "AssertionError", ")", ":", "if", ...
[ 243, 4 ]
[ 255, 21 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.update
(self)
Get the latest state from the device.
Get the latest state from the device.
def update(self): """Get the latest state from the device.""" status = self.command("system-power query") if not status: return if status[1] == "on": self._pwstate = STATE_ON else: self._pwstate = STATE_OFF return volume_r...
[ "def", "update", "(", "self", ")", ":", "status", "=", "self", ".", "command", "(", "\"system-power query\"", ")", "if", "not", "status", ":", "return", "if", "status", "[", "1", "]", "==", "\"on\"", ":", "self", ".", "_pwstate", "=", "STATE_ON", "else...
[ 257, 4 ]
[ 309, 44 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.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" ]
[ 312, 4 ]
[ 314, 25 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._pwstate
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_pwstate" ]
[ 317, 4 ]
[ 319, 28 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.volume_level
(self)
Return the volume level of the media player (0..1).
Return the volume level of the media player (0..1).
def volume_level(self): """Return the volume level of the media player (0..1).""" return self._volume
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "_volume" ]
[ 322, 4 ]
[ 324, 27 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.is_volume_muted
(self)
Return boolean indicating mute status.
Return boolean indicating mute status.
def is_volume_muted(self): """Return boolean indicating mute status.""" return self._muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_muted" ]
[ 327, 4 ]
[ 329, 26 ]
python
en
['en', 'id', 'en']
True
OnkyoDevice.supported_features
(self)
Return media player features that are supported.
Return media player features that are supported.
def supported_features(self): """Return media player features that are supported.""" return SUPPORT_ONKYO
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_ONKYO" ]
[ 332, 4 ]
[ 334, 28 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.source
(self)
Return the current input source of the device.
Return the current input source of the device.
def source(self): """Return the current input source of the device.""" return self._current_source
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "_current_source" ]
[ 337, 4 ]
[ 339, 35 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.source_list
(self)
List of available input sources.
List of available input sources.
def source_list(self): """List of available input sources.""" return self._source_list
[ "def", "source_list", "(", "self", ")", ":", "return", "self", ".", "_source_list" ]
[ 342, 4 ]
[ 344, 32 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.device_state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def device_state_attributes(self): """Return device specific state attributes.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 347, 4 ]
[ 349, 31 ]
python
en
['fr', 'en', 'en']
True
OnkyoDevice.turn_off
(self)
Turn the media player off.
Turn the media player off.
def turn_off(self): """Turn the media player off.""" self.command("system-power standby")
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "command", "(", "\"system-power standby\"", ")" ]
[ 351, 4 ]
[ 353, 44 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.set_volume_level
(self, volume)
Set volume level, input is range 0..1. However full volume on the amp is usually far too loud so allow the user to specify the upper range with CONF_MAX_VOLUME. we change as per max_volume set by user. This means that if max volume is 80 then full volume in HA will give 80% volume on ...
Set volume level, input is range 0..1.
def set_volume_level(self, volume): """ Set volume level, input is range 0..1. However full volume on the amp is usually far too loud so allow the user to specify the upper range with CONF_MAX_VOLUME. we change as per max_volume set by user. This means that if max volume is 80 then ful...
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "# HA_VOL * (MAX VOL / 100) * MAX_RECEIVER_VOL", "self", ".", "command", "(", "f\"volume {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}\"", ")" ]
[ 355, 4 ]
[ 367, 9 ]
python
en
['en', 'error', 'th']
False
OnkyoDevice.volume_up
(self)
Increase volume by 1 step.
Increase volume by 1 step.
def volume_up(self): """Increase volume by 1 step.""" self.command("volume level-up")
[ "def", "volume_up", "(", "self", ")", ":", "self", ".", "command", "(", "\"volume level-up\"", ")" ]
[ 369, 4 ]
[ 371, 39 ]
python
en
['en', 'af', 'en']
True
OnkyoDevice.volume_down
(self)
Decrease volume by 1 step.
Decrease volume by 1 step.
def volume_down(self): """Decrease volume by 1 step.""" self.command("volume level-down")
[ "def", "volume_down", "(", "self", ")", ":", "self", ".", "command", "(", "\"volume level-down\"", ")" ]
[ 373, 4 ]
[ 375, 41 ]
python
en
['en', 'af', 'en']
True
OnkyoDevice.mute_volume
(self, mute)
Mute (true) or unmute (false) media player.
Mute (true) or unmute (false) media player.
def mute_volume(self, mute): """Mute (true) or unmute (false) media player.""" if mute: self.command("audio-muting on") else: self.command("audio-muting off")
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "if", "mute", ":", "self", ".", "command", "(", "\"audio-muting on\"", ")", "else", ":", "self", ".", "command", "(", "\"audio-muting off\"", ")" ]
[ 377, 4 ]
[ 382, 44 ]
python
en
['en', 'la', 'it']
False
OnkyoDevice.turn_on
(self)
Turn the media player on.
Turn the media player on.
def turn_on(self): """Turn the media player on.""" self.command("system-power on")
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "command", "(", "\"system-power on\"", ")" ]
[ 384, 4 ]
[ 386, 39 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.select_source
(self, source)
Set the input source.
Set the input source.
def select_source(self, source): """Set the input source.""" if source in self._source_list: source = self._reverse_mapping[source] self.command(f"input-selector {source}")
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "if", "source", "in", "self", ".", "_source_list", ":", "source", "=", "self", ".", "_reverse_mapping", "[", "source", "]", "self", ".", "command", "(", "f\"input-selector {source}\"", ")" ]
[ 388, 4 ]
[ 392, 48 ]
python
en
['en', 'su', 'en']
True
OnkyoDevice.play_media
(self, media_type, media_id, **kwargs)
Play radio station by preset number.
Play radio station by preset number.
def play_media(self, media_type, media_id, **kwargs): """Play radio station by preset number.""" source = self._reverse_mapping[self._current_source] if media_type.lower() == "radio" and source in DEFAULT_PLAYABLE_SOURCES: self.command(f"preset {media_id}")
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "source", "=", "self", ".", "_reverse_mapping", "[", "self", ".", "_current_source", "]", "if", "media_type", ".", "lower", "(", ")", "==", "\"radio\...
[ 394, 4 ]
[ 398, 46 ]
python
en
['en', 'en', 'en']
True
OnkyoDevice.select_output
(self, output)
Set hdmi-out.
Set hdmi-out.
def select_output(self, output): """Set hdmi-out.""" self.command(f"hdmi-output-selector={output}")
[ "def", "select_output", "(", "self", ",", "output", ")", ":", "self", ".", "command", "(", "f\"hdmi-output-selector={output}\"", ")" ]
[ 400, 4 ]
[ 402, 54 ]
python
en
['nl', 'ht', 'en']
False
OnkyoDeviceZone.__init__
( self, zone, receiver, sources, name=None, max_volume=SUPPORTED_MAX_VOLUME, receiver_max_volume=DEFAULT_RECEIVER_MAX_VOLUME, )
Initialize the Zone with the zone identifier.
Initialize the Zone with the zone identifier.
def __init__( self, zone, receiver, sources, name=None, max_volume=SUPPORTED_MAX_VOLUME, receiver_max_volume=DEFAULT_RECEIVER_MAX_VOLUME, ): """Initialize the Zone with the zone identifier.""" self._zone = zone self._supports_volume = T...
[ "def", "__init__", "(", "self", ",", "zone", ",", "receiver", ",", "sources", ",", "name", "=", "None", ",", "max_volume", "=", "SUPPORTED_MAX_VOLUME", ",", "receiver_max_volume", "=", "DEFAULT_RECEIVER_MAX_VOLUME", ",", ")", ":", "self", ".", "_zone", "=", ...
[ 408, 4 ]
[ 420, 82 ]
python
en
['en', 'en', 'en']
True
OnkyoDeviceZone.update
(self)
Get the latest state from the device.
Get the latest state from the device.
def update(self): """Get the latest state from the device.""" status = self.command(f"zone{self._zone}.power=query") if not status: return if status[1] == "on": self._pwstate = STATE_ON else: self._pwstate = STATE_OFF return ...
[ "def", "update", "(", "self", ")", ":", "status", "=", "self", ".", "command", "(", "f\"zone{self._zone}.power=query\"", ")", "if", "not", "status", ":", "return", "if", "status", "[", "1", "]", "==", "\"on\"", ":", "self", ".", "_pwstate", "=", "STATE_O...
[ 422, 4 ]
[ 470, 13 ]
python
en
['en', 'en', 'en']
True
OnkyoDeviceZone.supported_features
(self)
Return media player features that are supported.
Return media player features that are supported.
def supported_features(self): """Return media player features that are supported.""" if self._supports_volume: return SUPPORT_ONKYO return SUPPORT_ONKYO_WO_VOLUME
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_supports_volume", ":", "return", "SUPPORT_ONKYO", "return", "SUPPORT_ONKYO_WO_VOLUME" ]
[ 473, 4 ]
[ 477, 38 ]
python
en
['en', 'en', 'en']
True
OnkyoDeviceZone.turn_off
(self)
Turn the media player off.
Turn the media player off.
def turn_off(self): """Turn the media player off.""" self.command(f"zone{self._zone}.power=standby")
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "command", "(", "f\"zone{self._zone}.power=standby\"", ")" ]
[ 479, 4 ]
[ 481, 55 ]
python
en
['en', 'en', 'en']
True
OnkyoDeviceZone.set_volume_level
(self, volume)
Set volume level, input is range 0..1. However full volume on the amp is usually far too loud so allow the user to specify the upper range with CONF_MAX_VOLUME. we change as per max_volume set by user. This means that if max volume is 80 then full volume in HA will give 80% volume on ...
Set volume level, input is range 0..1.
def set_volume_level(self, volume): """ Set volume level, input is range 0..1. However full volume on the amp is usually far too loud so allow the user to specify the upper range with CONF_MAX_VOLUME. we change as per max_volume set by user. This means that if max volume is 80 then ful...
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "# HA_VOL * (MAX VOL / 100) * MAX_RECEIVER_VOL", "self", ".", "command", "(", "f\"zone{self._zone}.volume={int(volume * (self._max_volume / 100) * self._receiver_max_volume)}\"", ")" ]
[ 483, 4 ]
[ 495, 9 ]
python
en
['en', 'error', 'th']
False
OnkyoDeviceZone.volume_up
(self)
Increase volume by 1 step.
Increase volume by 1 step.
def volume_up(self): """Increase volume by 1 step.""" self.command(f"zone{self._zone}.volume=level-up")
[ "def", "volume_up", "(", "self", ")", ":", "self", ".", "command", "(", "f\"zone{self._zone}.volume=level-up\"", ")" ]
[ 497, 4 ]
[ 499, 57 ]
python
en
['en', 'af', 'en']
True
OnkyoDeviceZone.volume_down
(self)
Decrease volume by 1 step.
Decrease volume by 1 step.
def volume_down(self): """Decrease volume by 1 step.""" self.command(f"zone{self._zone}.volume=level-down")
[ "def", "volume_down", "(", "self", ")", ":", "self", ".", "command", "(", "f\"zone{self._zone}.volume=level-down\"", ")" ]
[ 501, 4 ]
[ 503, 59 ]
python
en
['en', 'af', 'en']
True
OnkyoDeviceZone.mute_volume
(self, mute)
Mute (true) or unmute (false) media player.
Mute (true) or unmute (false) media player.
def mute_volume(self, mute): """Mute (true) or unmute (false) media player.""" if mute: self.command(f"zone{self._zone}.muting=on") else: self.command(f"zone{self._zone}.muting=off")
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "if", "mute", ":", "self", ".", "command", "(", "f\"zone{self._zone}.muting=on\"", ")", "else", ":", "self", ".", "command", "(", "f\"zone{self._zone}.muting=off\"", ")" ]
[ 505, 4 ]
[ 510, 56 ]
python
en
['en', 'la', 'it']
False
OnkyoDeviceZone.turn_on
(self)
Turn the media player on.
Turn the media player on.
def turn_on(self): """Turn the media player on.""" self.command(f"zone{self._zone}.power=on")
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "command", "(", "f\"zone{self._zone}.power=on\"", ")" ]
[ 512, 4 ]
[ 514, 50 ]
python
en
['en', 'en', 'en']
True
OnkyoDeviceZone.select_source
(self, source)
Set the input source.
Set the input source.
def select_source(self, source): """Set the input source.""" if source in self._source_list: source = self._reverse_mapping[source] self.command(f"zone{self._zone}.selector={source}")
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "if", "source", "in", "self", ".", "_source_list", ":", "source", "=", "self", ".", "_reverse_mapping", "[", "source", "]", "self", ".", "command", "(", "f\"zone{self._zone}.selector={source}\"", ")...
[ 516, 4 ]
[ 520, 59 ]
python
en
['en', 'su', 'en']
True
test_is_loopback
()
Test loopback addresses.
Test loopback addresses.
def test_is_loopback(): """Test loopback addresses.""" assert network_util.is_loopback(ip_address("127.0.0.2")) assert network_util.is_loopback(ip_address("127.0.0.1")) assert network_util.is_loopback(ip_address("::1")) assert network_util.is_loopback(ip_address("::ffff:127.0.0.0")) assert netwo...
[ "def", "test_is_loopback", "(", ")", ":", "assert", "network_util", ".", "is_loopback", "(", "ip_address", "(", "\"127.0.0.2\"", ")", ")", "assert", "network_util", ".", "is_loopback", "(", "ip_address", "(", "\"127.0.0.1\"", ")", ")", "assert", "network_util", ...
[ 7, 0 ]
[ 16, 78 ]
python
en
['en', 'et', 'en']
True
test_is_private
()
Test private addresses.
Test private addresses.
def test_is_private(): """Test private addresses.""" assert network_util.is_private(ip_address("192.168.0.1")) assert network_util.is_private(ip_address("172.16.12.0")) assert network_util.is_private(ip_address("10.5.43.3")) assert network_util.is_private(ip_address("fd12:3456:789a:1::1")) asser...
[ "def", "test_is_private", "(", ")", ":", "assert", "network_util", ".", "is_private", "(", "ip_address", "(", "\"192.168.0.1\"", ")", ")", "assert", "network_util", ".", "is_private", "(", "ip_address", "(", "\"172.16.12.0\"", ")", ")", "assert", "network_util", ...
[ 19, 0 ]
[ 26, 57 ]
python
en
['en', 'en', 'en']
True
test_is_link_local
()
Test link local addresses.
Test link local addresses.
def test_is_link_local(): """Test link local addresses.""" assert network_util.is_link_local(ip_address("169.254.12.3")) assert not network_util.is_link_local(ip_address("127.0.0.1"))
[ "def", "test_is_link_local", "(", ")", ":", "assert", "network_util", ".", "is_link_local", "(", "ip_address", "(", "\"169.254.12.3\"", ")", ")", "assert", "not", "network_util", ".", "is_link_local", "(", "ip_address", "(", "\"127.0.0.1\"", ")", ")" ]
[ 29, 0 ]
[ 32, 66 ]
python
en
['en', 'da', 'en']
True
test_is_local
()
Test local addresses.
Test local addresses.
def test_is_local(): """Test local addresses.""" assert network_util.is_local(ip_address("192.168.0.1")) assert network_util.is_local(ip_address("127.0.0.1")) assert not network_util.is_local(ip_address("208.5.4.2"))
[ "def", "test_is_local", "(", ")", ":", "assert", "network_util", ".", "is_local", "(", "ip_address", "(", "\"192.168.0.1\"", ")", ")", "assert", "network_util", ".", "is_local", "(", "ip_address", "(", "\"127.0.0.1\"", ")", ")", "assert", "not", "network_util", ...
[ 35, 0 ]
[ 39, 61 ]
python
en
['en', 'la', 'en']
True
test_is_ip_address
()
Test if strings are IP addresses.
Test if strings are IP addresses.
def test_is_ip_address(): """Test if strings are IP addresses.""" assert network_util.is_ip_address("192.168.0.1") assert network_util.is_ip_address("8.8.8.8") assert network_util.is_ip_address("::ffff:127.0.0.0") assert not network_util.is_ip_address("192.168.0.999") assert not network_util.is_...
[ "def", "test_is_ip_address", "(", ")", ":", "assert", "network_util", ".", "is_ip_address", "(", "\"192.168.0.1\"", ")", "assert", "network_util", ".", "is_ip_address", "(", "\"8.8.8.8\"", ")", "assert", "network_util", ".", "is_ip_address", "(", "\"::ffff:127.0.0.0\"...
[ 42, 0 ]
[ 49, 56 ]
python
en
['en', 'en', 'en']
True
test_normalize_url
()
Test the normalizing of URLs.
Test the normalizing of URLs.
def test_normalize_url(): """Test the normalizing of URLs.""" assert network_util.normalize_url("http://example.com") == "http://example.com" assert network_util.normalize_url("https://example.com") == "https://example.com" assert network_util.normalize_url("https://example.com/") == "https://example.co...
[ "def", "test_normalize_url", "(", ")", ":", "assert", "network_util", ".", "normalize_url", "(", "\"http://example.com\"", ")", "==", "\"http://example.com\"", "assert", "network_util", ".", "normalize_url", "(", "\"https://example.com\"", ")", "==", "\"https://example.co...
[ 52, 0 ]
[ 70, 5 ]
python
en
['en', 'en', 'en']
True
_async_create_entities
(hass, config)
Create the Template lock.
Create the Template lock.
async def _async_create_entities(hass, config): """Create the Template lock.""" device = config.get(CONF_NAME) value_template = config.get(CONF_VALUE_TEMPLATE) availability_template = config.get(CONF_AVAILABILITY_TEMPLATE) return [ TemplateLock( hass, device, ...
[ "async", "def", "_async_create_entities", "(", "hass", ",", "config", ")", ":", "device", "=", "config", ".", "get", "(", "CONF_NAME", ")", "value_template", "=", "config", ".", "get", "(", "CONF_VALUE_TEMPLATE", ")", "availability_template", "=", "config", "....
[ 40, 0 ]
[ 57, 5 ]
python
en
['en', 'ro', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the template lock.
Set up the template lock.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template lock.""" await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config))
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "await", "async_setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "async_add_entities", "(", "await...
[ 60, 0 ]
[ 64, 66 ]
python
en
['en', 'en', 'en']
True
TemplateLock.__init__
( self, hass, name, value_template, availability_template, command_lock, command_unlock, optimistic, unique_id, )
Initialize the lock.
Initialize the lock.
def __init__( self, hass, name, value_template, availability_template, command_lock, command_unlock, optimistic, unique_id, ): """Initialize the lock.""" super().__init__(availability_template=availability_template) self...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ",", "value_template", ",", "availability_template", ",", "command_lock", ",", "command_unlock", ",", "optimistic", ",", "unique_id", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "availabil...
[ 70, 4 ]
[ 90, 35 ]
python
en
['en', 'en', 'en']
True
TemplateLock.assumed_state
(self)
Return true if we do optimistic updates.
Return true if we do optimistic updates.
def assumed_state(self): """Return true if we do optimistic updates.""" return self._optimistic
[ "def", "assumed_state", "(", "self", ")", ":", "return", "self", ".", "_optimistic" ]
[ 93, 4 ]
[ 95, 31 ]
python
en
['pt', 'la', 'en']
False
TemplateLock.name
(self)
Return the name of the lock.
Return the name of the lock.
def name(self): """Return the name of the lock.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 98, 4 ]
[ 100, 25 ]
python
en
['en', 'en', 'en']
True
TemplateLock.unique_id
(self)
Return the unique id of this lock.
Return the unique id of this lock.
def unique_id(self): """Return the unique id of this lock.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 103, 4 ]
[ 105, 30 ]
python
en
['en', 'la', 'en']
True
TemplateLock.is_locked
(self)
Return true if lock is locked.
Return true if lock is locked.
def is_locked(self): """Return true if lock is locked.""" return self._state
[ "def", "is_locked", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 108, 4 ]
[ 110, 26 ]
python
en
['en', 'mt', 'en']
True
TemplateLock.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.add_template_attribute( "_state", self._state_template, None, self._update_state ) await super().async_added_to_hass()
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "add_template_attribute", "(", "\"_state\"", ",", "self", ".", "_state_template", ",", "None", ",", "self", ".", "_update_state", ")", "await", "super", "(", ")", ".", "async_added_to_h...
[ 129, 4 ]
[ 135, 43 ]
python
en
['en', 'no', 'en']
False
TemplateLock.async_lock
(self, **kwargs)
Lock the device.
Lock the device.
async def async_lock(self, **kwargs): """Lock the device.""" if self._optimistic: self._state = True self.async_write_ha_state() await self._command_lock.async_run(context=self._context)
[ "async", "def", "async_lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "True", "self", ".", "async_write_ha_state", "(", ")", "await", "self", ".", "_command_lock", ".", "async_run...
[ 137, 4 ]
[ 142, 65 ]
python
en
['en', 'en', 'en']
True
TemplateLock.async_unlock
(self, **kwargs)
Unlock the device.
Unlock the device.
async def async_unlock(self, **kwargs): """Unlock the device.""" if self._optimistic: self._state = False self.async_write_ha_state() await self._command_unlock.async_run(context=self._context)
[ "async", "def", "async_unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_optimistic", ":", "self", ".", "_state", "=", "False", "self", ".", "async_write_ha_state", "(", ")", "await", "self", ".", "_command_unlock", ".", "asyn...
[ 144, 4 ]
[ 149, 67 ]
python
en
['en', 'zh', 'en']
True
update_members_dict
()
Update members dictionary
Update members dictionary
def update_members_dict(): """Update members dictionary""" global MEMBERS_DICT MEMBERS_DICT.clear() with app.app_context(): from .admin import get_members_dict new_dict = get_members_dict() MEMBERS_DICT.update(new_dict)
[ "def", "update_members_dict", "(", ")", ":", "global", "MEMBERS_DICT", "MEMBERS_DICT", ".", "clear", "(", ")", "with", "app", ".", "app_context", "(", ")", ":", "from", ".", "admin", "import", "get_members_dict", "new_dict", "=", "get_members_dict", "(", ")", ...
[ 60, 0 ]
[ 67, 33 ]
python
en
['es', 'id', 'en']
False
_load_name_dict
()
Load email: name dictionary from local file.
Load email: name dictionary from local file.
def _load_name_dict(): """Load email: name dictionary from local file.""" email_names = pd.read_table(os.path.join(DATA_DIR, 'email_names.tsv'), sep='\t', header=None, names=['email', 'full_name']) name_dict = email_names.set_index('email')['full_name'].to_dict() return n...
[ "def", "_load_name_dict", "(", ")", ":", "email_names", "=", "pd", ".", "read_table", "(", "os", ".", "path", ".", "join", "(", "DATA_DIR", ",", "'email_names.tsv'", ")", ",", "sep", "=", "'\\t'", ",", "header", "=", "None", ",", "names", "=", "[", "...
[ 82, 0 ]
[ 87, 20 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the MVGLive sensor.
Set up the MVGLive sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the MVGLive sensor.""" sensors = [] for nextdeparture in config.get(CONF_NEXT_DEPARTURE): sensors.append( MVGLiveSensor( nextdeparture.get(CONF_STATION), nextdeparture.get(CONF_...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "sensors", "=", "[", "]", "for", "nextdeparture", "in", "config", ".", "get", "(", "CONF_NEXT_DEPARTURE", ")", ":", "sensors", ".", "app...
[ 61, 0 ]
[ 77, 31 ]
python
en
['en', 'bs', 'en']
True
MVGLiveSensor.__init__
( self, station, destinations, directions, lines, products, timeoffset, number, name, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, station, destinations, directions, lines, products, timeoffset, number, name, ): """Initialize the sensor.""" self._station = station self._name = name self.data = MVGLiveData( sta...
[ "def", "__init__", "(", "self", ",", "station", ",", "destinations", ",", "directions", ",", "lines", ",", "products", ",", "timeoffset", ",", "number", ",", "name", ",", ")", ":", "self", ".", "_station", "=", "station", "self", ".", "_name", "=", "na...
[ 83, 4 ]
[ 101, 31 ]
python
en
['en', 'en', 'en']
True
MVGLiveSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" if self._name: return self._name return self._station
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "_name", ":", "return", "self", ".", "_name", "return", "self", ".", "_station" ]
[ 104, 4 ]
[ 108, 28 ]
python
en
['en', 'mi', 'en']
True
MVGLiveSensor.state
(self)
Return the next departure time.
Return the next departure time.
def state(self): """Return the next departure time.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 111, 4 ]
[ 113, 26 ]
python
en
['en', 'en', 'en']
True
MVGLiveSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" dep = self.data.departures if not dep: return None attr = dep[0] # next depature attributes attr["departures"] = deepcopy(dep) # all departures dictionary return attr
[ "def", "device_state_attributes", "(", "self", ")", ":", "dep", "=", "self", ".", "data", ".", "departures", "if", "not", "dep", ":", "return", "None", "attr", "=", "dep", "[", "0", "]", "# next depature attributes", "attr", "[", "\"departures\"", "]", "="...
[ 116, 4 ]
[ 123, 19 ]
python
en
['en', 'en', 'en']
True
MVGLiveSensor.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 self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 126, 4 ]
[ 128, 25 ]
python
en
['en', 'en', 'en']
True
MVGLiveSensor.unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def unit_of_measurement(self): """Return the unit this state is expressed in.""" return TIME_MINUTES
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "TIME_MINUTES" ]
[ 131, 4 ]
[ 133, 27 ]
python
en
['en', 'en', 'en']
True
MVGLiveSensor.update
(self)
Get the latest data and update the state.
Get the latest data and update the state.
def update(self): """Get the latest data and update the state.""" self.data.update() if not self.data.departures: self._state = "-" self._icon = ICONS["-"] else: self._state = self.data.departures[0].get("time", "-") self._icon = ICONS[self...
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "if", "not", "self", ".", "data", ".", "departures", ":", "self", ".", "_state", "=", "\"-\"", "self", ".", "_icon", "=", "ICONS", "[", "\"-\"", "]", "else", ":...
[ 135, 4 ]
[ 143, 75 ]
python
en
['en', 'en', 'en']
True
MVGLiveData.__init__
( self, station, destinations, directions, lines, products, timeoffset, number )
Initialize the sensor.
Initialize the sensor.
def __init__( self, station, destinations, directions, lines, products, timeoffset, number ): """Initialize the sensor.""" self._station = station self._destinations = destinations self._directions = directions self._lines = lines self._products = products ...
[ "def", "__init__", "(", "self", ",", "station", ",", "destinations", ",", "directions", ",", "lines", ",", "products", ",", "timeoffset", ",", "number", ")", ":", "self", ".", "_station", "=", "station", "self", ".", "_destinations", "=", "destinations", "...
[ 149, 4 ]
[ 165, 28 ]
python
en
['en', 'en', 'en']
True
MVGLiveData.update
(self)
Update the connection data.
Update the connection data.
def update(self): """Update the connection data.""" try: _departures = self.mvg.getlivedata( station=self._station, timeoffset=self._timeoffset, ubahn=self._include_ubahn, tram=self._include_tram, bus=self._inclu...
[ "def", "update", "(", "self", ")", ":", "try", ":", "_departures", "=", "self", ".", "mvg", ".", "getlivedata", "(", "station", "=", "self", ".", "_station", ",", "timeoffset", "=", "self", ".", "_timeoffset", ",", "ubahn", "=", "self", ".", "_include_...
[ 167, 4 ]
[ 210, 21 ]
python
en
['en', 'en', 'en']
True
get_dataset
(name, split_name, dataset_dir, file_pattern=None, reader=None)
Given a dataset name and a split_name returns a Dataset. Args: name: String, the name of the dataset. split_name: A train/test split name. dataset_dir: The directory where the dataset files are stored. file_pattern: The file pattern to use for matching the dataset source files. reader: The subcla...
Given a dataset name and a split_name returns a Dataset.
def get_dataset(name, split_name, dataset_dir, file_pattern=None, reader=None): """Given a dataset name and a split_name returns a Dataset. Args: name: String, the name of the dataset. split_name: A train/test split name. dataset_dir: The directory where the dataset files are stored. file_pattern: ...
[ "def", "get_dataset", "(", "name", ",", "split_name", ",", "dataset_dir", ",", "file_pattern", "=", "None", ",", "reader", "=", "None", ")", ":", "if", "name", "not", "in", "datasets_map", ":", "raise", "ValueError", "(", "'Name of dataset unknown %s'", "%", ...
[ 35, 0 ]
[ 58, 13 ]
python
en
['en', 'en', 'en']
True
_config_info
(mode, config)
Generate info about the config.
Generate info about the config.
def _config_info(mode, config): """Generate info about the config.""" return { "mode": mode, "views": len(config.get("views", [])), }
[ "def", "_config_info", "(", "mode", ",", "config", ")", ":", "return", "{", "\"mode\"", ":", "mode", ",", "\"views\"", ":", "len", "(", "config", ".", "get", "(", "\"views\"", ",", "[", "]", ")", ")", ",", "}" ]
[ 211, 0 ]
[ 216, 5 ]
python
en
['en', 'en', 'en']
True
LovelaceConfig.__init__
(self, hass, url_path, config)
Initialize Lovelace config.
Initialize Lovelace config.
def __init__(self, hass, url_path, config): """Initialize Lovelace config.""" self.hass = hass if config: self.config = {**config, CONF_URL_PATH: url_path} else: self.config = None
[ "def", "__init__", "(", "self", ",", "hass", ",", "url_path", ",", "config", ")", ":", "self", ".", "hass", "=", "hass", "if", "config", ":", "self", ".", "config", "=", "{", "*", "*", "config", ",", "CONF_URL_PATH", ":", "url_path", "}", "else", "...
[ 40, 4 ]
[ 46, 30 ]
python
en
['en', 'en', 'en']
True
LovelaceConfig.url_path
(self)
Return url path.
Return url path.
def url_path(self) -> str: """Return url path.""" return self.config[CONF_URL_PATH] if self.config else None
[ "def", "url_path", "(", "self", ")", "->", "str", ":", "return", "self", ".", "config", "[", "CONF_URL_PATH", "]", "if", "self", ".", "config", "else", "None" ]
[ 49, 4 ]
[ 51, 66 ]
python
cy
['de', 'cy', 'en']
False
LovelaceConfig.mode
(self)
Return mode of the lovelace config.
Return mode of the lovelace config.
def mode(self) -> str: """Return mode of the lovelace config."""
[ "def", "mode", "(", "self", ")", "->", "str", ":" ]
[ 55, 4 ]
[ 56, 49 ]
python
en
['en', 'en', 'en']
True
LovelaceConfig.async_get_info
(self)
Return the config info.
Return the config info.
async def async_get_info(self): """Return the config info."""
[ "async", "def", "async_get_info", "(", "self", ")", ":" ]
[ 59, 4 ]
[ 60, 37 ]
python
en
['en', 'en', 'en']
True
LovelaceConfig.async_load
(self, force)
Load config.
Load config.
async def async_load(self, force): """Load config."""
[ "async", "def", "async_load", "(", "self", ",", "force", ")", ":" ]
[ 63, 4 ]
[ 64, 26 ]
python
en
['en', 'es', 'en']
False
LovelaceConfig.async_save
(self, config)
Save config.
Save config.
async def async_save(self, config): """Save config.""" raise HomeAssistantError("Not supported")
[ "async", "def", "async_save", "(", "self", ",", "config", ")", ":", "raise", "HomeAssistantError", "(", "\"Not supported\"", ")" ]
[ 66, 4 ]
[ 68, 49 ]
python
en
['en', 'en', 'en']
False
LovelaceConfig.async_delete
(self)
Delete config.
Delete config.
async def async_delete(self): """Delete config.""" raise HomeAssistantError("Not supported")
[ "async", "def", "async_delete", "(", "self", ")", ":", "raise", "HomeAssistantError", "(", "\"Not supported\"", ")" ]
[ 70, 4 ]
[ 72, 49 ]
python
en
['en', 'es', 'en']
False
LovelaceConfig._config_updated
(self)
Fire config updated event.
Fire config updated event.
def _config_updated(self): """Fire config updated event.""" self.hass.bus.async_fire(EVENT_LOVELACE_UPDATED, {"url_path": self.url_path})
[ "def", "_config_updated", "(", "self", ")", ":", "self", ".", "hass", ".", "bus", ".", "async_fire", "(", "EVENT_LOVELACE_UPDATED", ",", "{", "\"url_path\"", ":", "self", ".", "url_path", "}", ")" ]
[ 75, 4 ]
[ 77, 85 ]
python
en
['en', 'en', 'en']
True
LovelaceStorage.__init__
(self, hass, config)
Initialize Lovelace config based on storage helper.
Initialize Lovelace config based on storage helper.
def __init__(self, hass, config): """Initialize Lovelace config based on storage helper.""" if config is None: url_path = None storage_key = CONFIG_STORAGE_KEY_DEFAULT else: url_path = config[CONF_URL_PATH] storage_key = CONFIG_STORAGE_KEY.format(c...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ")", ":", "if", "config", "is", "None", ":", "url_path", "=", "None", "storage_key", "=", "CONFIG_STORAGE_KEY_DEFAULT", "else", ":", "url_path", "=", "config", "[", "CONF_URL_PATH", "]", "storage_ke...
[ 83, 4 ]
[ 95, 25 ]
python
en
['en', 'en', 'en']
True
LovelaceStorage.mode
(self)
Return mode of the lovelace config.
Return mode of the lovelace config.
def mode(self) -> str: """Return mode of the lovelace config.""" return MODE_STORAGE
[ "def", "mode", "(", "self", ")", "->", "str", ":", "return", "MODE_STORAGE" ]
[ 98, 4 ]
[ 100, 27 ]
python
en
['en', 'en', 'en']
True
LovelaceStorage.async_get_info
(self)
Return the Lovelace storage info.
Return the Lovelace storage info.
async def async_get_info(self): """Return the Lovelace storage info.""" if self._data is None: await self._load() if self._data["config"] is None: return {"mode": "auto-gen"} return _config_info(self.mode, self._data["config"])
[ "async", "def", "async_get_info", "(", "self", ")", ":", "if", "self", ".", "_data", "is", "None", ":", "await", "self", ".", "_load", "(", ")", "if", "self", ".", "_data", "[", "\"config\"", "]", "is", "None", ":", "return", "{", "\"mode\"", ":", ...
[ 102, 4 ]
[ 110, 60 ]
python
en
['en', 'no', 'en']
True
LovelaceStorage.async_load
(self, force)
Load config.
Load config.
async def async_load(self, force): """Load config.""" if self.hass.config.safe_mode: raise ConfigNotFound if self._data is None: await self._load() config = self._data["config"] if config is None: raise ConfigNotFound return config
[ "async", "def", "async_load", "(", "self", ",", "force", ")", ":", "if", "self", ".", "hass", ".", "config", ".", "safe_mode", ":", "raise", "ConfigNotFound", "if", "self", ".", "_data", "is", "None", ":", "await", "self", ".", "_load", "(", ")", "co...
[ 112, 4 ]
[ 125, 21 ]
python
en
['en', 'es', 'en']
False
LovelaceStorage.async_save
(self, config)
Save config.
Save config.
async def async_save(self, config): """Save config.""" if self.hass.config.safe_mode: raise HomeAssistantError("Saving not supported in safe mode") if self._data is None: await self._load() self._data["config"] = config self._config_updated() awai...
[ "async", "def", "async_save", "(", "self", ",", "config", ")", ":", "if", "self", ".", "hass", ".", "config", ".", "safe_mode", ":", "raise", "HomeAssistantError", "(", "\"Saving not supported in safe mode\"", ")", "if", "self", ".", "_data", "is", "None", "...
[ 127, 4 ]
[ 136, 48 ]
python
en
['en', 'en', 'en']
False
LovelaceStorage.async_delete
(self)
Delete config.
Delete config.
async def async_delete(self): """Delete config.""" if self.hass.config.safe_mode: raise HomeAssistantError("Deleting not supported in safe mode") await self._store.async_remove() self._data = None self._config_updated()
[ "async", "def", "async_delete", "(", "self", ")", ":", "if", "self", ".", "hass", ".", "config", ".", "safe_mode", ":", "raise", "HomeAssistantError", "(", "\"Deleting not supported in safe mode\"", ")", "await", "self", ".", "_store", ".", "async_remove", "(", ...
[ 138, 4 ]
[ 145, 30 ]
python
en
['en', 'es', 'en']
False
LovelaceStorage._load
(self)
Load the config.
Load the config.
async def _load(self): """Load the config.""" data = await self._store.async_load() self._data = data if data else {"config": None}
[ "async", "def", "_load", "(", "self", ")", ":", "data", "=", "await", "self", ".", "_store", ".", "async_load", "(", ")", "self", ".", "_data", "=", "data", "if", "data", "else", "{", "\"config\"", ":", "None", "}" ]
[ 147, 4 ]
[ 150, 55 ]
python
en
['en', 'en', 'en']
True
LovelaceYAML.__init__
(self, hass, url_path, config)
Initialize the YAML config.
Initialize the YAML config.
def __init__(self, hass, url_path, config): """Initialize the YAML config.""" super().__init__(hass, url_path, config) self.path = hass.config.path( config[CONF_FILENAME] if config else LOVELACE_CONFIG_FILE ) self._cache = None
[ "def", "__init__", "(", "self", ",", "hass", ",", "url_path", ",", "config", ")", ":", "super", "(", ")", ".", "__init__", "(", "hass", ",", "url_path", ",", "config", ")", "self", ".", "path", "=", "hass", ".", "config", ".", "path", "(", "config"...
[ 156, 4 ]
[ 163, 26 ]
python
en
['en', 'en', 'en']
True
LovelaceYAML.mode
(self)
Return mode of the lovelace config.
Return mode of the lovelace config.
def mode(self) -> str: """Return mode of the lovelace config.""" return MODE_YAML
[ "def", "mode", "(", "self", ")", "->", "str", ":", "return", "MODE_YAML" ]
[ 166, 4 ]
[ 168, 24 ]
python
en
['en', 'en', 'en']
True
LovelaceYAML.async_get_info
(self)
Return the YAML storage mode.
Return the YAML storage mode.
async def async_get_info(self): """Return the YAML storage mode.""" try: config = await self.async_load(False) except ConfigNotFound: return { "mode": self.mode, "error": f"{self.path} not found", } return _config_info(...
[ "async", "def", "async_get_info", "(", "self", ")", ":", "try", ":", "config", "=", "await", "self", ".", "async_load", "(", "False", ")", "except", "ConfigNotFound", ":", "return", "{", "\"mode\"", ":", "self", ".", "mode", ",", "\"error\"", ":", "f\"{s...
[ 170, 4 ]
[ 180, 46 ]
python
en
['en', 'sn', 'en']
True
LovelaceYAML.async_load
(self, force)
Load config.
Load config.
async def async_load(self, force): """Load config.""" is_updated, config = await self.hass.async_add_executor_job( self._load_config, force ) if is_updated: self._config_updated() return config
[ "async", "def", "async_load", "(", "self", ",", "force", ")", ":", "is_updated", ",", "config", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_load_config", ",", "force", ")", "if", "is_updated", ":", "self", ".", "...
[ 182, 4 ]
[ 189, 21 ]
python
en
['en', 'es', 'en']
False
LovelaceYAML._load_config
(self, force)
Load the actual config.
Load the actual config.
def _load_config(self, force): """Load the actual config.""" # Check for a cached version of the config if not force and self._cache is not None: config, last_update = self._cache modtime = os.path.getmtime(self.path) if config and last_update > modtime: ...
[ "def", "_load_config", "(", "self", ",", "force", ")", ":", "# Check for a cached version of the config", "if", "not", "force", "and", "self", ".", "_cache", "is", "not", "None", ":", "config", ",", "last_update", "=", "self", ".", "_cache", "modtime", "=", ...
[ 191, 4 ]
[ 208, 33 ]
python
en
['en', 'en', 'en']
True
DashboardsCollection.__init__
(self, hass)
Initialize the dashboards collection.
Initialize the dashboards collection.
def __init__(self, hass): """Initialize the dashboards collection.""" super().__init__( storage.Store(hass, DASHBOARDS_STORAGE_VERSION, DASHBOARDS_STORAGE_KEY), _LOGGER, )
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "super", "(", ")", ".", "__init__", "(", "storage", ".", "Store", "(", "hass", ",", "DASHBOARDS_STORAGE_VERSION", ",", "DASHBOARDS_STORAGE_KEY", ")", ",", "_LOGGER", ",", ")" ]
[ 225, 4 ]
[ 230, 9 ]
python
en
['en', 'en', 'en']
True
DashboardsCollection._async_load_data
(self)
Load the data.
Load the data.
async def _async_load_data(self) -> Optional[dict]: """Load the data.""" data = await self.store.async_load() if data is None: return cast(Optional[dict], data) updated = False for item in data["items"] or []: if "-" not in item[CONF_URL_PATH]: ...
[ "async", "def", "_async_load_data", "(", "self", ")", "->", "Optional", "[", "dict", "]", ":", "data", "=", "await", "self", ".", "store", ".", "async_load", "(", ")", "if", "data", "is", "None", ":", "return", "cast", "(", "Optional", "[", "dict", "...
[ 232, 4 ]
[ 249, 41 ]
python
en
['en', 'en', 'en']
True
DashboardsCollection._process_create_data
(self, data: dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: dict) -> dict: """Validate the config is valid.""" if "-" not in data[CONF_URL_PATH]: raise vol.Invalid("Url path needs to contain a hyphen (-)") if data[CONF_URL_PATH] in self.hass.data[DATA_PANELS]: raise vol.Invalid("Panel ur...
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "dict", ")", "->", "dict", ":", "if", "\"-\"", "not", "in", "data", "[", "CONF_URL_PATH", "]", ":", "raise", "vol", ".", "Invalid", "(", "\"Url path needs to contain a hyphen (-)\"", ")", ...
[ 251, 4 ]
[ 259, 39 ]
python
en
['en', 'en', 'en']
True
DashboardsCollection._get_suggested_id
(self, info: dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: dict) -> str: """Suggest an ID based on the config.""" return info[CONF_URL_PATH]
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "dict", ")", "->", "str", ":", "return", "info", "[", "CONF_URL_PATH", "]" ]
[ 262, 4 ]
[ 264, 34 ]
python
en
['en', 'en', 'en']
True
DashboardsCollection._update_data
(self, data: dict, update_data: dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: dict) -> dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) updated = {**data, **update_data} if CONF_ICON in updated and updated[CONF_ICON] is None: updated.pop(CONF_ICON) ...
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "dict", ")", "->", "dict", ":", "update_data", "=", "self", ".", "UPDATE_SCHEMA", "(", "update_data", ")", "updated", "=", "{", "*", "*", "data", ",", "*", ...
[ 266, 4 ]
[ 274, 22 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up an OpenUV sensor based on a config entry.
Set up an OpenUV sensor based on a config entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up an OpenUV sensor based on a config entry.""" openuv = hass.data[DOMAIN][DATA_OPENUV_CLIENT][entry.entry_id] binary_sensors = [] for kind, attrs in BINARY_SENSORS.items(): name, icon = attrs binary_sensors.append( ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "openuv", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_OPENUV_CLIENT", "]", "[", "entry", ".", "entry_id", "]", "binary_sensors", "=", "[", "]"...
[ 25, 0 ]
[ 36, 44 ]
python
en
['en', 'en', 'en']
True
OpenUvBinarySensor.__init__
(self, openuv, sensor_type, name, icon, entry_id)
Initialize the sensor.
Initialize the sensor.
def __init__(self, openuv, sensor_type, name, icon, entry_id): """Initialize the sensor.""" super().__init__(openuv) self._async_unsub_dispatcher_connect = None self._entry_id = entry_id self._icon = icon self._latitude = openuv.client.latitude self._longitude = ...
[ "def", "__init__", "(", "self", ",", "openuv", ",", "sensor_type", ",", "name", ",", "icon", ",", "entry_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "openuv", ")", "self", ".", "_async_unsub_dispatcher_connect", "=", "None", "self", ".", "_en...
[ 42, 4 ]
[ 53, 26 ]
python
en
['en', 'en', 'en']
True
OpenUvBinarySensor.icon
(self)
Return the icon.
Return the icon.
def icon(self): """Return the icon.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 56, 4 ]
[ 58, 25 ]
python
en
['en', 'sr', 'en']
True
OpenUvBinarySensor.is_on
(self)
Return the status of the sensor.
Return the status of the sensor.
def is_on(self): """Return the status of the sensor.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 61, 4 ]
[ 63, 26 ]
python
en
['en', 'id', 'en']
True
OpenUvBinarySensor.should_poll
(self)
Disable polling.
Disable polling.
def should_poll(self): """Disable polling.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 66, 4 ]
[ 68, 20 ]
python
en
['fr', 'en', 'en']
False
OpenUvBinarySensor.unique_id
(self)
Return a unique, Home Assistant friendly identifier for this entity.
Return a unique, Home Assistant friendly identifier for this entity.
def unique_id(self) -> str: """Return a unique, Home Assistant friendly identifier for this entity.""" return f"{self._latitude}_{self._longitude}_{self._sensor_type}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._latitude}_{self._longitude}_{self._sensor_type}\"" ]
[ 71, 4 ]
[ 73, 72 ]
python
en
['en', 'en', 'en']
True
OpenUvBinarySensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self): """Update the state.""" data = self.openuv.data[DATA_PROTECTION_WINDOW] if not data: self._available = False return self._available = True for key in ("from_time", "to_time", "from_uv", "to_uv"): if not dat...
[ "def", "update_from_latest_data", "(", "self", ")", ":", "data", "=", "self", ".", "openuv", ".", "data", "[", "DATA_PROTECTION_WINDOW", "]", "if", "not", "data", ":", "self", ".", "_available", "=", "False", "return", "self", ".", "_available", "=", "True...
[ 76, 4 ]
[ 108, 13 ]
python
en
['en', 'en', 'en']
True