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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
uninstall_osx | () | Unload from launchd on OS X. | Unload from launchd on OS X. | def uninstall_osx():
"""Unload from launchd on OS X."""
path = os.path.expanduser("~/Library/LaunchAgents/org.homeassistant.plist")
os.popen(f"launchctl unload {path}")
print("Home Assistant has been uninstalled.") | [
"def",
"uninstall_osx",
"(",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/Library/LaunchAgents/org.homeassistant.plist\"",
")",
"os",
".",
"popen",
"(",
"f\"launchctl unload {path}\"",
")",
"print",
"(",
"\"Home Assistant has been uninstalled.\... | [
40,
0
] | [
45,
49
] | python | en | ['en', 'en', 'en'] | True |
run | (args) | Handle OSX commandline script. | Handle OSX commandline script. | def run(args):
"""Handle OSX commandline script."""
commands = "install", "uninstall", "restart"
if not args or args[0] not in commands:
print("Invalid command. Available commands:", ", ".join(commands))
return 1
if args[0] == "install":
install_osx()
return 0
if arg... | [
"def",
"run",
"(",
"args",
")",
":",
"commands",
"=",
"\"install\"",
",",
"\"uninstall\"",
",",
"\"restart\"",
"if",
"not",
"args",
"or",
"args",
"[",
"0",
"]",
"not",
"in",
"commands",
":",
"print",
"(",
"\"Invalid command. Available commands:\"",
",",
"\",... | [
48,
0
] | [
66,
16
] | python | de | ['de', 'nl', 'en'] | False |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up the dhcp component. | Set up the dhcp component. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the dhcp component."""
async def _initialize(_):
address_data = {}
integration_matchers = await async_get_dhcp(hass)
watchers = []
for cls in (DHCPWatcher, DeviceTrackerWatcher, NetworkWatcher):
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"async",
"def",
"_initialize",
"(",
"_",
")",
":",
"address_data",
"=",
"{",
"}",
"integration_matchers",
"=",
"await",
"async_get_dhc... | [
56,
0
] | [
76,
15
] | python | en | ['en', 'en', 'en'] | True |
_decode_dhcp_option | (dhcp_options, key) | Extract and decode data from a packet option. | Extract and decode data from a packet option. | def _decode_dhcp_option(dhcp_options, key):
"""Extract and decode data from a packet option."""
for option in dhcp_options:
if len(option) < 2 or option[0] != key:
continue
value = option[1]
if value is None or key != HOSTNAME:
return value
# hostname is... | [
"def",
"_decode_dhcp_option",
"(",
"dhcp_options",
",",
"key",
")",
":",
"for",
"option",
"in",
"dhcp_options",
":",
"if",
"len",
"(",
"option",
")",
"<",
"2",
"or",
"option",
"[",
"0",
"]",
"!=",
"key",
":",
"continue",
"value",
"=",
"option",
"[",
... | [
362,
0
] | [
376,
23
] | python | en | ['en', 'en', 'en'] | True |
_format_mac | (mac_address) | Format a mac address for matching. | Format a mac address for matching. | def _format_mac(mac_address):
"""Format a mac address for matching."""
return format_mac(mac_address).replace(":", "") | [
"def",
"_format_mac",
"(",
"mac_address",
")",
":",
"return",
"format_mac",
"(",
"mac_address",
")",
".",
"replace",
"(",
"\":\"",
",",
"\"\"",
")"
] | [
379,
0
] | [
381,
51
] | python | en | ['en', 'en', 'en'] | True |
_verify_l2socket_setup | (cap_filter) | Create a socket using the scapy configured l2socket.
Try to create the socket
to see if we have permissions
since AsyncSniffer will do it another
thread so we will not be able to capture
any permission or bind errors.
| Create a socket using the scapy configured l2socket. | def _verify_l2socket_setup(cap_filter):
"""Create a socket using the scapy configured l2socket.
Try to create the socket
to see if we have permissions
since AsyncSniffer will do it another
thread so we will not be able to capture
any permission or bind errors.
"""
conf.L2socket(filter=c... | [
"def",
"_verify_l2socket_setup",
"(",
"cap_filter",
")",
":",
"conf",
".",
"L2socket",
"(",
"filter",
"=",
"cap_filter",
")"
] | [
384,
0
] | [
393,
36
] | python | en | ['en', 'en', 'en'] | True |
_verify_working_pcap | (cap_filter) | Verify we can create a packet filter.
If we cannot create a filter we will be listening for
all traffic which is too intensive.
| Verify we can create a packet filter. | def _verify_working_pcap(cap_filter):
"""Verify we can create a packet filter.
If we cannot create a filter we will be listening for
all traffic which is too intensive.
"""
# Local import because importing from scapy has side effects such as opening
# sockets
from scapy.arch.common import (... | [
"def",
"_verify_working_pcap",
"(",
"cap_filter",
")",
":",
"# Local import because importing from scapy has side effects such as opening",
"# sockets",
"from",
"scapy",
".",
"arch",
".",
"common",
"import",
"(",
"# pylint: disable=import-outside-toplevel",
"compile_filter",
",",... | [
396,
0
] | [
408,
30
] | python | en | ['en', 'en', 'en'] | True |
WatcherBase.__init__ | (self, hass, address_data, integration_matchers) | Initialize class. | Initialize class. | def __init__(self, hass, address_data, integration_matchers):
"""Initialize class."""
super().__init__()
self.hass = hass
self._integration_matchers = integration_matchers
self._address_data = address_data | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_integration_matchers",
"=",
"integration_matchers",
"self"... | [
82,
4
] | [
88,
41
] | python | en | ['en', 'co', 'en'] | False |
WatcherBase.process_client | (self, ip_address, hostname, mac_address) | Process a client. | Process a client. | def process_client(self, ip_address, hostname, mac_address):
"""Process a client."""
made_ip_address = make_ip_address(ip_address)
if (
is_link_local(made_ip_address)
or is_loopback(made_ip_address)
or is_invalid(made_ip_address)
):
# Igno... | [
"def",
"process_client",
"(",
"self",
",",
"ip_address",
",",
"hostname",
",",
"mac_address",
")",
":",
"made_ip_address",
"=",
"make_ip_address",
"(",
"ip_address",
")",
"if",
"(",
"is_link_local",
"(",
"made_ip_address",
")",
"or",
"is_loopback",
"(",
"made_ip... | [
90,
4
] | [
115,
85
] | python | en | ['en', 'fr', 'en'] | True |
WatcherBase.process_updated_address_data | (self, ip_address, data) | Process the address data update. | Process the address data update. | def process_updated_address_data(self, ip_address, data):
"""Process the address data update."""
lowercase_hostname = data[HOSTNAME].lower()
uppercase_mac = data[MAC_ADDRESS].upper()
_LOGGER.debug(
"Processing updated address data for %s: mac=%s hostname=%s",
ip_... | [
"def",
"process_updated_address_data",
"(",
"self",
",",
"ip_address",
",",
"data",
")",
":",
"lowercase_hostname",
"=",
"data",
"[",
"HOSTNAME",
"]",
".",
"lower",
"(",
")",
"uppercase_mac",
"=",
"data",
"[",
"MAC_ADDRESS",
"]",
".",
"upper",
"(",
")",
"_... | [
117,
4
] | [
152,
13
] | python | en | ['en', 'ny', 'en'] | True |
WatcherBase.create_task | (self, task) | Pass a task to async_add_task based on which context we are in. | Pass a task to async_add_task based on which context we are in. | def create_task(self, task):
"""Pass a task to async_add_task based on which context we are in.""" | [
"def",
"create_task",
"(",
"self",
",",
"task",
")",
":"
] | [
155,
4
] | [
156,
77
] | python | en | ['en', 'en', 'en'] | True |
NetworkWatcher.__init__ | (self, hass, address_data, integration_matchers) | Initialize class. | Initialize class. | def __init__(self, hass, address_data, integration_matchers):
"""Initialize class."""
super().__init__(hass, address_data, integration_matchers)
self._unsub = None
self._discover_hosts = None
self._discover_task = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
"self",
".",
"_unsub",
"=",
"None",
"self",
"."... | [
162,
4
] | [
167,
34
] | python | en | ['en', 'co', 'en'] | False |
NetworkWatcher.async_stop | (self) | Stop scanning for new devices on the network. | Stop scanning for new devices on the network. | async def async_stop(self):
"""Stop scanning for new devices on the network."""
if self._unsub:
self._unsub()
self._unsub = None
if self._discover_task:
self._discover_task.cancel()
self._discover_task = None | [
"async",
"def",
"async_stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unsub",
":",
"self",
".",
"_unsub",
"(",
")",
"self",
".",
"_unsub",
"=",
"None",
"if",
"self",
".",
"_discover_task",
":",
"self",
".",
"_discover_task",
".",
"cancel",
"(",
"... | [
169,
4
] | [
176,
38
] | python | en | ['en', 'en', 'en'] | True |
NetworkWatcher.async_start | (self) | Start scanning for new devices on the network. | Start scanning for new devices on the network. | async def async_start(self):
"""Start scanning for new devices on the network."""
self._discover_hosts = DiscoverHosts()
self._unsub = async_track_time_interval(
self.hass, self.async_start_discover, SCAN_INTERVAL
)
self.async_start_discover() | [
"async",
"def",
"async_start",
"(",
"self",
")",
":",
"self",
".",
"_discover_hosts",
"=",
"DiscoverHosts",
"(",
")",
"self",
".",
"_unsub",
"=",
"async_track_time_interval",
"(",
"self",
".",
"hass",
",",
"self",
".",
"async_start_discover",
",",
"SCAN_INTERV... | [
178,
4
] | [
184,
35
] | python | en | ['en', 'en', 'en'] | True |
NetworkWatcher.async_start_discover | (self, *_) | Start a new discovery task if one is not running. | Start a new discovery task if one is not running. | def async_start_discover(self, *_):
"""Start a new discovery task if one is not running."""
if self._discover_task and not self._discover_task.done():
return
self._discover_task = self.create_task(self.async_discover()) | [
"def",
"async_start_discover",
"(",
"self",
",",
"*",
"_",
")",
":",
"if",
"self",
".",
"_discover_task",
"and",
"not",
"self",
".",
"_discover_task",
".",
"done",
"(",
")",
":",
"return",
"self",
".",
"_discover_task",
"=",
"self",
".",
"create_task",
"... | [
187,
4
] | [
191,
69
] | python | en | ['en', 'en', 'en'] | True |
NetworkWatcher.async_discover | (self) | Process discovery. | Process discovery. | async def async_discover(self):
"""Process discovery."""
for host in await self._discover_hosts.async_discover():
self.process_client(
host[DISCOVERY_IP_ADDRESS],
host[DISCOVERY_HOSTNAME],
_format_mac(host[DISCOVERY_MAC_ADDRESS]),
) | [
"async",
"def",
"async_discover",
"(",
"self",
")",
":",
"for",
"host",
"in",
"await",
"self",
".",
"_discover_hosts",
".",
"async_discover",
"(",
")",
":",
"self",
".",
"process_client",
"(",
"host",
"[",
"DISCOVERY_IP_ADDRESS",
"]",
",",
"host",
"[",
"DI... | [
193,
4
] | [
200,
13
] | python | en | ['en', 'en', 'en'] | False |
NetworkWatcher.create_task | (self, task) | Pass a task to async_create_task since we are in async context. | Pass a task to async_create_task since we are in async context. | def create_task(self, task):
"""Pass a task to async_create_task since we are in async context."""
return self.hass.async_create_task(task) | [
"def",
"create_task",
"(",
"self",
",",
"task",
")",
":",
"return",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"task",
")"
] | [
202,
4
] | [
204,
48
] | python | en | ['en', 'en', 'en'] | True |
DeviceTrackerWatcher.__init__ | (self, hass, address_data, integration_matchers) | Initialize class. | Initialize class. | def __init__(self, hass, address_data, integration_matchers):
"""Initialize class."""
super().__init__(hass, address_data, integration_matchers)
self._unsub = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
"self",
".",
"_unsub",
"=",
"None"
] | [
210,
4
] | [
213,
26
] | python | en | ['en', 'co', 'en'] | False |
DeviceTrackerWatcher.async_stop | (self) | Stop watching for new device trackers. | Stop watching for new device trackers. | async def async_stop(self):
"""Stop watching for new device trackers."""
if self._unsub:
self._unsub()
self._unsub = None | [
"async",
"def",
"async_stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unsub",
":",
"self",
".",
"_unsub",
"(",
")",
"self",
".",
"_unsub",
"=",
"None"
] | [
215,
4
] | [
219,
30
] | python | en | ['en', 'en', 'en'] | True |
DeviceTrackerWatcher.async_start | (self) | Stop watching for new device trackers. | Stop watching for new device trackers. | async def async_start(self):
"""Stop watching for new device trackers."""
self._unsub = async_track_state_added_domain(
self.hass, [DEVICE_TRACKER_DOMAIN], self._async_process_device_event
)
for state in self.hass.states.async_all(DEVICE_TRACKER_DOMAIN):
self._asy... | [
"async",
"def",
"async_start",
"(",
"self",
")",
":",
"self",
".",
"_unsub",
"=",
"async_track_state_added_domain",
"(",
"self",
".",
"hass",
",",
"[",
"DEVICE_TRACKER_DOMAIN",
"]",
",",
"self",
".",
"_async_process_device_event",
")",
"for",
"state",
"in",
"s... | [
221,
4
] | [
227,
51
] | python | en | ['en', 'en', 'en'] | True |
DeviceTrackerWatcher._async_process_device_event | (self, event: Event) | Process a device tracker state change event. | Process a device tracker state change event. | def _async_process_device_event(self, event: Event):
"""Process a device tracker state change event."""
self._async_process_device_state(event.data.get("new_state")) | [
"def",
"_async_process_device_event",
"(",
"self",
",",
"event",
":",
"Event",
")",
":",
"self",
".",
"_async_process_device_state",
"(",
"event",
".",
"data",
".",
"get",
"(",
"\"new_state\"",
")",
")"
] | [
230,
4
] | [
232,
69
] | python | en | ['en', 'en', 'en'] | True |
DeviceTrackerWatcher._async_process_device_state | (self, state: State) | Process a device tracker state. | Process a device tracker state. | def _async_process_device_state(self, state: State):
"""Process a device tracker state."""
if state.state != STATE_HOME:
return
attributes = state.attributes
if attributes.get(ATTR_SOURCE_TYPE) != SOURCE_TYPE_ROUTER:
return
ip_address = attributes.get(A... | [
"def",
"_async_process_device_state",
"(",
"self",
",",
"state",
":",
"State",
")",
":",
"if",
"state",
".",
"state",
"!=",
"STATE_HOME",
":",
"return",
"attributes",
"=",
"state",
".",
"attributes",
"if",
"attributes",
".",
"get",
"(",
"ATTR_SOURCE_TYPE",
"... | [
235,
4
] | [
252,
75
] | python | en | ['en', 'en', 'en'] | True |
DeviceTrackerWatcher.create_task | (self, task) | Pass a task to async_create_task since we are in async context. | Pass a task to async_create_task since we are in async context. | def create_task(self, task):
"""Pass a task to async_create_task since we are in async context."""
return self.hass.async_create_task(task) | [
"def",
"create_task",
"(",
"self",
",",
"task",
")",
":",
"return",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"task",
")"
] | [
254,
4
] | [
256,
48
] | python | en | ['en', 'en', 'en'] | True |
DHCPWatcher.__init__ | (self, hass, address_data, integration_matchers) | Initialize class. | Initialize class. | def __init__(self, hass, address_data, integration_matchers):
"""Initialize class."""
super().__init__(hass, address_data, integration_matchers)
self._sniffer = None
self._started = threading.Event() | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"address_data",
",",
"integration_matchers",
")",
"self",
".",
"_sniffer",
"=",
"None",
"self",
"... | [
262,
4
] | [
266,
41
] | python | en | ['en', 'co', 'en'] | False |
DHCPWatcher.async_stop | (self) | Stop watching for new device trackers. | Stop watching for new device trackers. | async def async_stop(self):
"""Stop watching for new device trackers."""
await self.hass.async_add_executor_job(self._stop) | [
"async",
"def",
"async_stop",
"(",
"self",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_stop",
")"
] | [
268,
4
] | [
270,
58
] | python | en | ['en', 'en', 'en'] | True |
DHCPWatcher._stop | (self) | Stop the thread. | Stop the thread. | def _stop(self):
"""Stop the thread."""
if self._started.is_set():
self._sniffer.stop() | [
"def",
"_stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_started",
".",
"is_set",
"(",
")",
":",
"self",
".",
"_sniffer",
".",
"stop",
"(",
")"
] | [
272,
4
] | [
275,
32
] | python | en | ['en', 'en', 'en'] | True |
DHCPWatcher.async_start | (self) | Start watching for dhcp packets. | Start watching for dhcp packets. | async def async_start(self):
"""Start watching for dhcp packets."""
# Local import because importing from scapy has side effects such as opening
# sockets
from scapy import ( # pylint: disable=import-outside-toplevel,unused-import # noqa: F401
arch,
)
#
... | [
"async",
"def",
"async_start",
"(",
"self",
")",
":",
"# Local import because importing from scapy has side effects such as opening",
"# sockets",
"from",
"scapy",
"import",
"(",
"# pylint: disable=import-outside-toplevel,unused-import # noqa: F401",
"arch",
",",
")",
"#",
"# Im... | [
277,
4
] | [
328,
63
] | python | en | ['en', 'en', 'en'] | True |
DHCPWatcher.handle_dhcp_packet | (self, packet) | Process a dhcp packet. | Process a dhcp packet. | def handle_dhcp_packet(self, packet):
"""Process a dhcp packet."""
# Local import because importing from scapy has side effects such as opening
# sockets
from scapy.layers.dhcp import DHCP # pylint: disable=import-outside-toplevel
from scapy.layers.inet import IP # pylint: disa... | [
"def",
"handle_dhcp_packet",
"(",
"self",
",",
"packet",
")",
":",
"# Local import because importing from scapy has side effects such as opening",
"# sockets",
"from",
"scapy",
".",
"layers",
".",
"dhcp",
"import",
"DHCP",
"# pylint: disable=import-outside-toplevel",
"from",
... | [
330,
4
] | [
355,
62
] | python | en | ['en', 'en', 'en'] | True |
DHCPWatcher.create_task | (self, task) | Pass a task to hass.add_job since we are in a thread. | Pass a task to hass.add_job since we are in a thread. | def create_task(self, task):
"""Pass a task to hass.add_job since we are in a thread."""
return self.hass.add_job(task) | [
"def",
"create_task",
"(",
"self",
",",
"task",
")",
":",
"return",
"self",
".",
"hass",
".",
"add_job",
"(",
"task",
")"
] | [
357,
4
] | [
359,
38
] | python | en | ['en', 'en', 'en'] | True |
test_sensors | (
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_wled: MagicMock,
) | Test the creation and values of the WLED sensors. | Test the creation and values of the WLED sensors. | async def test_sensors(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_wled: MagicMock,
) -> None:
"""Test the creation and values of the WLED sensors."""
registry = er.async_get(hass)
# Pre-create registry entries for disabled by default sensors
registry.async_get_or_create(... | [
"async",
"def",
"test_sensors",
"(",
"hass",
":",
"HomeAssistant",
",",
"mock_config_entry",
":",
"MockConfigEntry",
",",
"mock_wled",
":",
"MagicMock",
",",
")",
"->",
"None",
":",
"registry",
"=",
"er",
".",
"async_get",
"(",
"hass",
")",
"# Pre-create regis... | [
30,
0
] | [
170,
55
] | python | en | ['en', 'en', 'en'] | True |
test_disabled_by_default_sensors | (
hass: HomeAssistant, init_integration: MockConfigEntry, entity_id: str
) | Test the disabled by default WLED sensors. | Test the disabled by default WLED sensors. | async def test_disabled_by_default_sensors(
hass: HomeAssistant, init_integration: MockConfigEntry, entity_id: str
) -> None:
"""Test the disabled by default WLED sensors."""
registry = er.async_get(hass)
state = hass.states.get(entity_id)
assert state is None
entry = registry.async_get(entity... | [
"async",
"def",
"test_disabled_by_default_sensors",
"(",
"hass",
":",
"HomeAssistant",
",",
"init_integration",
":",
"MockConfigEntry",
",",
"entity_id",
":",
"str",
")",
"->",
"None",
":",
"registry",
"=",
"er",
".",
"async_get",
"(",
"hass",
")",
"state",
"=... | [
184,
0
] | [
196,
55
] | python | en | ['en', 'en', 'en'] | True |
test_no_wifi_support | (
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_wled: MagicMock,
key: str,
) | Test missing Wi-Fi information from WLED device. | Test missing Wi-Fi information from WLED device. | async def test_no_wifi_support(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_wled: MagicMock,
key: str,
) -> None:
"""Test missing Wi-Fi information from WLED device."""
registry = er.async_get(hass)
# Pre-create registry entries for disabled by default sensors
registry... | [
"async",
"def",
"test_no_wifi_support",
"(",
"hass",
":",
"HomeAssistant",
",",
"mock_config_entry",
":",
"MockConfigEntry",
",",
"mock_wled",
":",
"MagicMock",
",",
"key",
":",
"str",
",",
")",
"->",
"None",
":",
"registry",
"=",
"er",
".",
"async_get",
"("... | [
208,
0
] | [
237,
39
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_auth_providers | (hass, aiohttp_client) | Test fetching auth providers. | Test fetching auth providers. | async def test_fetch_auth_providers(hass, aiohttp_client):
"""Test fetching auth providers."""
client = await async_setup_auth(hass, aiohttp_client)
resp = await client.get("/auth/providers")
assert resp.status == 200
assert await resp.json() == [
{"name": "Example", "type": "insecure_exampl... | [
"async",
"def",
"test_fetch_auth_providers",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"client",
"=",
"await",
"async_setup_auth",
"(",
"hass",
",",
"aiohttp_client",
")",
"resp",
"=",
"await",
"client",
".",
"get",
"(",
"\"/auth/providers\"",
")",
"assert",... | [
8,
0
] | [
15,
5
] | python | en | ['en', 'en', 'en'] | True |
test_fetch_auth_providers_onboarding | (hass, aiohttp_client) | Test fetching auth providers. | Test fetching auth providers. | async def test_fetch_auth_providers_onboarding(hass, aiohttp_client):
"""Test fetching auth providers."""
client = await async_setup_auth(hass, aiohttp_client)
with patch(
"homeassistant.components.onboarding.async_is_user_onboarded",
return_value=False,
):
resp = await client.ge... | [
"async",
"def",
"test_fetch_auth_providers_onboarding",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"client",
"=",
"await",
"async_setup_auth",
"(",
"hass",
",",
"aiohttp_client",
")",
"with",
"patch",
"(",
"\"homeassistant.components.onboarding.async_is_user_onboarded\""... | [
18,
0
] | [
30,
5
] | python | en | ['en', 'en', 'en'] | True |
test_cannot_get_flows_in_progress | (hass, aiohttp_client) | Test we cannot get flows in progress. | Test we cannot get flows in progress. | async def test_cannot_get_flows_in_progress(hass, aiohttp_client):
"""Test we cannot get flows in progress."""
client = await async_setup_auth(hass, aiohttp_client, [])
resp = await client.get("/auth/login_flow")
assert resp.status == 405 | [
"async",
"def",
"test_cannot_get_flows_in_progress",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"client",
"=",
"await",
"async_setup_auth",
"(",
"hass",
",",
"aiohttp_client",
",",
"[",
"]",
")",
"resp",
"=",
"await",
"client",
".",
"get",
"(",
"\"/auth/log... | [
33,
0
] | [
37,
29
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_username_password | (hass, aiohttp_client) | Test we cannot get flows in progress. | Test we cannot get flows in progress. | async def test_invalid_username_password(hass, aiohttp_client):
"""Test we cannot get flows in progress."""
client = await async_setup_auth(hass, aiohttp_client)
resp = await client.post(
"/auth/login_flow",
json={
"client_id": CLIENT_ID,
"handler": ["insecure_example... | [
"async",
"def",
"test_invalid_username_password",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"client",
"=",
"await",
"async_setup_auth",
"(",
"hass",
",",
"aiohttp_client",
")",
"resp",
"=",
"await",
"client",
".",
"post",
"(",
"\"/auth/login_flow\"",
",",
"j... | [
40,
0
] | [
84,
51
] | python | en | ['en', 'en', 'en'] | True |
test_login_exist_user | (hass, aiohttp_client) | Test logging in with exist user. | Test logging in with exist user. | async def test_login_exist_user(hass, aiohttp_client):
"""Test logging in with exist user."""
client = await async_setup_auth(hass, aiohttp_client, setup_api=True)
cred = await hass.auth.auth_providers[0].async_get_or_create_credentials(
{"username": "test-user"}
)
await hass.auth.async_get_... | [
"async",
"def",
"test_login_exist_user",
"(",
"hass",
",",
"aiohttp_client",
")",
":",
"client",
"=",
"await",
"async_setup_auth",
"(",
"hass",
",",
"aiohttp_client",
",",
"setup_api",
"=",
"True",
")",
"cred",
"=",
"await",
"hass",
".",
"auth",
".",
"auth_p... | [
87,
0
] | [
114,
34
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Horizon platform. | Set up the Horizon platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Horizon platform."""
host = config[CONF_HOST]
name = config[CONF_NAME]
port = config[CONF_PORT]
try:
client = Client(host, port=port)
except AuthenticationError as msg:
_LOGGER.error("Authenticat... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"port",
"=",
"config",
"[",
"CONF_PORT",
"... | [
58,
0
] | [
77,
59
] | python | en | ['en', 'su', 'en'] | True |
HorizonDevice.__init__ | (self, client, name, remote_keys) | Initialize the remote. | Initialize the remote. | def __init__(self, client, name, remote_keys):
"""Initialize the remote."""
self._client = client
self._name = name
self._state = None
self._keys = remote_keys | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"name",
",",
"remote_keys",
")",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_keys",
"=",
"remote_keys"
] | [
83,
4
] | [
88,
32
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.name | (self) | Return the name of the remote. | Return the name of the remote. | def name(self):
"""Return the name of the remote."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
91,
4
] | [
93,
25
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
96,
4
] | [
98,
26
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_HORIZON | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_HORIZON"
] | [
101,
4
] | [
103,
30
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.update | (self) | Update State using the media server running on the Horizon. | Update State using the media server running on the Horizon. | def update(self):
"""Update State using the media server running on the Horizon."""
try:
if self._client.is_powered_on():
self._state = STATE_PLAYING
else:
self._state = STATE_OFF
except OSError:
self._state = STATE_OFF | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_client",
".",
"is_powered_on",
"(",
")",
":",
"self",
".",
"_state",
"=",
"STATE_PLAYING",
"else",
":",
"self",
".",
"_state",
"=",
"STATE_OFF",
"except",
"OSError",
":",
"self",
... | [
106,
4
] | [
114,
35
] | python | en | ['en', 'sn', 'en'] | True |
HorizonDevice.turn_on | (self) | Turn the device on. | Turn the device on. | def turn_on(self):
"""Turn the device on."""
if self._state == STATE_OFF:
self._send_key(self._keys.POWER) | [
"def",
"turn_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"==",
"STATE_OFF",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"POWER",
")"
] | [
116,
4
] | [
119,
44
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.turn_off | (self) | Turn the device off. | Turn the device off. | def turn_off(self):
"""Turn the device off."""
if self._state != STATE_OFF:
self._send_key(self._keys.POWER) | [
"def",
"turn_off",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"!=",
"STATE_OFF",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"POWER",
")"
] | [
121,
4
] | [
124,
44
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.media_previous_track | (self) | Channel down. | Channel down. | def media_previous_track(self):
"""Channel down."""
self._send_key(self._keys.CHAN_DOWN)
self._state = STATE_PLAYING | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"CHAN_DOWN",
")",
"self",
".",
"_state",
"=",
"STATE_PLAYING"
] | [
126,
4
] | [
129,
35
] | python | en | ['it', 'en', 'en'] | False |
HorizonDevice.media_next_track | (self) | Channel up. | Channel up. | def media_next_track(self):
"""Channel up."""
self._send_key(self._keys.CHAN_UP)
self._state = STATE_PLAYING | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"CHAN_UP",
")",
"self",
".",
"_state",
"=",
"STATE_PLAYING"
] | [
131,
4
] | [
134,
35
] | python | en | ['it', 'en', 'en'] | False |
HorizonDevice.media_play | (self) | Send play command. | Send play command. | def media_play(self):
"""Send play command."""
self._send_key(self._keys.PAUSE)
self._state = STATE_PLAYING | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"PAUSE",
")",
"self",
".",
"_state",
"=",
"STATE_PLAYING"
] | [
136,
4
] | [
139,
35
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.media_pause | (self) | Send pause command. | Send pause command. | def media_pause(self):
"""Send pause command."""
self._send_key(self._keys.PAUSE)
self._state = STATE_PAUSED | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"PAUSE",
")",
"self",
".",
"_state",
"=",
"STATE_PAUSED"
] | [
141,
4
] | [
144,
34
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.media_play_pause | (self) | Send play/pause command. | Send play/pause command. | def media_play_pause(self):
"""Send play/pause command."""
self._send_key(self._keys.PAUSE)
if self._state == STATE_PAUSED:
self._state = STATE_PLAYING
else:
self._state = STATE_PAUSED | [
"def",
"media_play_pause",
"(",
"self",
")",
":",
"self",
".",
"_send_key",
"(",
"self",
".",
"_keys",
".",
"PAUSE",
")",
"if",
"self",
".",
"_state",
"==",
"STATE_PAUSED",
":",
"self",
".",
"_state",
"=",
"STATE_PLAYING",
"else",
":",
"self",
".",
"_s... | [
146,
4
] | [
152,
38
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice.play_media | (self, media_type, media_id, **kwargs) | Play media / switch to channel. | Play media / switch to channel. | def play_media(self, media_type, media_id, **kwargs):
"""Play media / switch to channel."""
if MEDIA_TYPE_CHANNEL == media_type:
try:
self._select_channel(int(media_id))
self._state = STATE_PLAYING
except ValueError:
_LOGGER.error("... | [
"def",
"play_media",
"(",
"self",
",",
"media_type",
",",
"media_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"MEDIA_TYPE_CHANNEL",
"==",
"media_type",
":",
"try",
":",
"self",
".",
"_select_channel",
"(",
"int",
"(",
"media_id",
")",
")",
"self",
".",
... | [
154,
4
] | [
167,
13
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice._select_channel | (self, channel) | Select a channel (taken from einder library, thx). | Select a channel (taken from einder library, thx). | def _select_channel(self, channel):
"""Select a channel (taken from einder library, thx)."""
self._send(channel=channel) | [
"def",
"_select_channel",
"(",
"self",
",",
"channel",
")",
":",
"self",
".",
"_send",
"(",
"channel",
"=",
"channel",
")"
] | [
169,
4
] | [
171,
35
] | python | en | ['en', 'en', 'en'] | True |
HorizonDevice._send_key | (self, key) | Send a key to the Horizon device. | Send a key to the Horizon device. | def _send_key(self, key):
"""Send a key to the Horizon device."""
self._send(key=key) | [
"def",
"_send_key",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_send",
"(",
"key",
"=",
"key",
")"
] | [
173,
4
] | [
175,
27
] | python | en | ['en', 'mk', 'en'] | True |
HorizonDevice._send | (self, key=None, channel=None) | Send a key to the Horizon device. | Send a key to the Horizon device. | def _send(self, key=None, channel=None):
"""Send a key to the Horizon device."""
try:
if key:
self._client.send_key(key)
elif channel:
self._client.select_channel(channel)
except OSError as msg:
_LOGGER.error("%s disconnected: ... | [
"def",
"_send",
"(",
"self",
",",
"key",
"=",
"None",
",",
"channel",
"=",
"None",
")",
":",
"try",
":",
"if",
"key",
":",
"self",
".",
"_client",
".",
"send_key",
"(",
"key",
")",
"elif",
"channel",
":",
"self",
".",
"_client",
".",
"select_channe... | [
177,
4
] | [
202,
48
] | python | en | ['en', 'mk', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Zigbee Home Automation binary sensor from config entry. | Set up the Zigbee Home Automation binary sensor from config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Zigbee Home Automation binary sensor from config entry."""
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
unsub = async_dispatcher_connect(
hass,
SIGNAL_ADD_ENTITIES,
functools.partial(
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities_to_create",
"=",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]",
"[",
"DOMAIN",
"]",
"unsub",
"=",
"async_dispatcher_connect",
"(",
"hass",
",",
"S... | [
47,
0
] | [
58,
59
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.__init__ | (self, unique_id, zha_device, channels, **kwargs) | Initialize the ZHA binary sensor. | Initialize the ZHA binary sensor. | def __init__(self, unique_id, zha_device, channels, **kwargs):
"""Initialize the ZHA binary sensor."""
super().__init__(unique_id, zha_device, channels, **kwargs)
self._channel = channels[0]
self._device_class = self.DEVICE_CLASS | [
"def",
"__init__",
"(",
"self",
",",
"unique_id",
",",
"zha_device",
",",
"channels",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"unique_id",
",",
"zha_device",
",",
"channels",
",",
"*",
"*",
"kwargs",
")",
"self",
"... | [
67,
4
] | [
71,
46
] | python | en | ['en', 'zh-Latn', 'en'] | True |
BinarySensor.async_added_to_hass | (self) | Run when about to be added to hass. | Run when about to be added to hass. | async def async_added_to_hass(self):
"""Run when about to be added to hass."""
await super().async_added_to_hass()
self.async_accept_signal(
self._channel, SIGNAL_ATTR_UPDATED, self.async_set_state
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"async_accept_signal",
"(",
"self",
".",
"_channel",
",",
"SIGNAL_ATTR_UPDATED",
",",
"self",
".",
"async_set_state",
"... | [
73,
4
] | [
78,
9
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_restore_last_state | (self, last_state) | Restore previous state. | Restore previous state. | def async_restore_last_state(self, last_state):
"""Restore previous state."""
super().async_restore_last_state(last_state)
self._state = last_state.state == STATE_ON | [
"def",
"async_restore_last_state",
"(",
"self",
",",
"last_state",
")",
":",
"super",
"(",
")",
".",
"async_restore_last_state",
"(",
"last_state",
")",
"self",
".",
"_state",
"=",
"last_state",
".",
"state",
"==",
"STATE_ON"
] | [
81,
4
] | [
84,
50
] | python | it | ['it', 'it', 'en'] | True |
BinarySensor.is_on | (self) | Return True if the switch is on based on the state machine. | Return True if the switch is on based on the state machine. | def is_on(self) -> bool:
"""Return True if the switch is on based on the state machine."""
if self._state is None:
return False
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_state"
] | [
87,
4
] | [
91,
26
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.device_class | (self) | Return device class from component DEVICE_CLASSES. | Return device class from component DEVICE_CLASSES. | def device_class(self) -> str:
"""Return device class from component DEVICE_CLASSES."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device_class"
] | [
94,
4
] | [
96,
33
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_set_state | (self, attr_id, attr_name, value) | Set the state. | Set the state. | def async_set_state(self, attr_id, attr_name, value):
"""Set the state."""
if self.SENSOR_ATTR is None or self.SENSOR_ATTR != attr_name:
return
self._state = bool(value)
self.async_write_ha_state() | [
"def",
"async_set_state",
"(",
"self",
",",
"attr_id",
",",
"attr_name",
",",
"value",
")",
":",
"if",
"self",
".",
"SENSOR_ATTR",
"is",
"None",
"or",
"self",
".",
"SENSOR_ATTR",
"!=",
"attr_name",
":",
"return",
"self",
".",
"_state",
"=",
"bool",
"(",
... | [
99,
4
] | [
104,
35
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_update | (self) | Attempt to retrieve on off state from the binary sensor. | Attempt to retrieve on off state from the binary sensor. | async def async_update(self):
"""Attempt to retrieve on off state from the binary sensor."""
await super().async_update()
attribute = getattr(self._channel, "value_attribute", "on_off")
attr_value = await self._channel.get_attribute_value(attribute)
if attr_value is not None:
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_update",
"(",
")",
"attribute",
"=",
"getattr",
"(",
"self",
".",
"_channel",
",",
"\"value_attribute\"",
",",
"\"on_off\"",
")",
"attr_value",
"=",
"await",
"se... | [
106,
4
] | [
112,
36
] | python | en | ['en', 'en', 'en'] | True |
is_loopback | (address: IPv4Address | IPv6Address) | Check if an address is a loopback address. | Check if an address is a loopback address. | def is_loopback(address: IPv4Address | IPv6Address) -> bool:
"""Check if an address is a loopback address."""
return any(address in network for network in LOOPBACK_NETWORKS) | [
"def",
"is_loopback",
"(",
"address",
":",
"IPv4Address",
"|",
"IPv6Address",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"address",
"in",
"network",
"for",
"network",
"in",
"LOOPBACK_NETWORKS",
")"
] | [
26,
0
] | [
28,
67
] | python | en | ['en', 'en', 'en'] | True |
is_private | (address: IPv4Address | IPv6Address) | Check if an address is a private address. | Check if an address is a private address. | def is_private(address: IPv4Address | IPv6Address) -> bool:
"""Check if an address is a private address."""
return any(address in network for network in PRIVATE_NETWORKS) | [
"def",
"is_private",
"(",
"address",
":",
"IPv4Address",
"|",
"IPv6Address",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"address",
"in",
"network",
"for",
"network",
"in",
"PRIVATE_NETWORKS",
")"
] | [
31,
0
] | [
33,
66
] | python | en | ['en', 'en', 'en'] | True |
is_link_local | (address: IPv4Address | IPv6Address) | Check if an address is link local. | Check if an address is link local. | def is_link_local(address: IPv4Address | IPv6Address) -> bool:
"""Check if an address is link local."""
return address in LINK_LOCAL_NETWORK | [
"def",
"is_link_local",
"(",
"address",
":",
"IPv4Address",
"|",
"IPv6Address",
")",
"->",
"bool",
":",
"return",
"address",
"in",
"LINK_LOCAL_NETWORK"
] | [
36,
0
] | [
38,
40
] | python | en | ['en', 'en', 'en'] | True |
is_local | (address: IPv4Address | IPv6Address) | Check if an address is loopback or private. | Check if an address is loopback or private. | def is_local(address: IPv4Address | IPv6Address) -> bool:
"""Check if an address is loopback or private."""
return is_loopback(address) or is_private(address) | [
"def",
"is_local",
"(",
"address",
":",
"IPv4Address",
"|",
"IPv6Address",
")",
"->",
"bool",
":",
"return",
"is_loopback",
"(",
"address",
")",
"or",
"is_private",
"(",
"address",
")"
] | [
41,
0
] | [
43,
54
] | python | en | ['en', 'en', 'en'] | True |
is_invalid | (address: IPv4Address | IPv6Address) | Check if an address is invalid. | Check if an address is invalid. | def is_invalid(address: IPv4Address | IPv6Address) -> bool:
"""Check if an address is invalid."""
return bool(address == ip_address("0.0.0.0")) | [
"def",
"is_invalid",
"(",
"address",
":",
"IPv4Address",
"|",
"IPv6Address",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"address",
"==",
"ip_address",
"(",
"\"0.0.0.0\"",
")",
")"
] | [
46,
0
] | [
48,
49
] | python | en | ['en', 'en', 'en'] | True |
is_ip_address | (address: str) | Check if a given string is an IP address. | Check if a given string is an IP address. | def is_ip_address(address: str) -> bool:
"""Check if a given string is an IP address."""
try:
ip_address(address)
except ValueError:
return False
return True | [
"def",
"is_ip_address",
"(",
"address",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"ip_address",
"(",
"address",
")",
"except",
"ValueError",
":",
"return",
"False",
"return",
"True"
] | [
51,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
normalize_url | (address: str) | Normalize a given URL. | Normalize a given URL. | def normalize_url(address: str) -> str:
"""Normalize a given URL."""
url = yarl.URL(address.rstrip("/"))
if url.is_default_port():
return str(url.with_port(None))
return str(url) | [
"def",
"normalize_url",
"(",
"address",
":",
"str",
")",
"->",
"str",
":",
"url",
"=",
"yarl",
".",
"URL",
"(",
"address",
".",
"rstrip",
"(",
"\"/\"",
")",
")",
"if",
"url",
".",
"is_default_port",
"(",
")",
":",
"return",
"str",
"(",
"url",
".",
... | [
61,
0
] | [
66,
19
] | python | en | ['en', 'en', 'en'] | True |
Pet.__init__ | (self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None, local_vars_configuration=None) | Pet - a model defined in OpenAPI | Pet - a model defined in OpenAPI | def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None, local_vars_configuration=None): # noqa: E501
"""Pet - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
... | [
"def",
"__init__",
"(",
"self",
",",
"id",
"=",
"None",
",",
"category",
"=",
"None",
",",
"name",
"=",
"None",
",",
"photo_urls",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"status",
"=",
"None",
",",
"local_vars_configuration",
"=",
"None",
")",
"... | [
52,
4
] | [
75,
32
] | python | en | ['en', 'en', 'en'] | True |
Pet.id | (self) | Gets the id of this Pet. # noqa: E501
:return: The id of this Pet. # noqa: E501
:rtype: int
| Gets the id of this Pet. # noqa: E501 | def id(self):
"""Gets the id of this Pet. # noqa: E501
:return: The id of this Pet. # noqa: E501
:rtype: int
"""
return self._id | [
"def",
"id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_id"
] | [
78,
4
] | [
85,
23
] | python | en | ['en', 'en', 'en'] | True |
Pet.id | (self, id) | Sets the id of this Pet.
:param id: The id of this Pet. # noqa: E501
:type id: int
| Sets the id of this Pet. | def id(self, id):
"""Sets the id of this Pet.
:param id: The id of this Pet. # noqa: E501
:type id: int
"""
self._id = id | [
"def",
"id",
"(",
"self",
",",
"id",
")",
":",
"self",
".",
"_id",
"=",
"id"
] | [
88,
4
] | [
96,
21
] | python | en | ['en', 'en', 'en'] | True |
Pet.category | (self) | Gets the category of this Pet. # noqa: E501
:return: The category of this Pet. # noqa: E501
:rtype: Category
| Gets the category of this Pet. # noqa: E501 | def category(self):
"""Gets the category of this Pet. # noqa: E501
:return: The category of this Pet. # noqa: E501
:rtype: Category
"""
return self._category | [
"def",
"category",
"(",
"self",
")",
":",
"return",
"self",
".",
"_category"
] | [
99,
4
] | [
106,
29
] | python | en | ['en', 'en', 'en'] | True |
Pet.category | (self, category) | Sets the category of this Pet.
:param category: The category of this Pet. # noqa: E501
:type category: Category
| Sets the category of this Pet. | def category(self, category):
"""Sets the category of this Pet.
:param category: The category of this Pet. # noqa: E501
:type category: Category
"""
self._category = category | [
"def",
"category",
"(",
"self",
",",
"category",
")",
":",
"self",
".",
"_category",
"=",
"category"
] | [
109,
4
] | [
117,
33
] | python | en | ['en', 'en', 'en'] | True |
Pet.name | (self) | Gets the name of this Pet. # noqa: E501
:return: The name of this Pet. # noqa: E501
:rtype: str
| Gets the name of this Pet. # noqa: E501 | def name(self):
"""Gets the name of this Pet. # noqa: E501
:return: The name of this Pet. # noqa: E501
:rtype: str
"""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
120,
4
] | [
127,
25
] | python | en | ['en', 'en', 'en'] | True |
Pet.name | (self, name) | Sets the name of this Pet.
:param name: The name of this Pet. # noqa: E501
:type name: str
| Sets the name of this Pet. | def name(self, name):
"""Sets the name of this Pet.
:param name: The name of this Pet. # noqa: E501
:type name: str
"""
if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501
raise ValueError("Invalid value for `name`, must not be `... | [
"def",
"name",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"local_vars_configuration",
".",
"client_side_validation",
"and",
"name",
"is",
"None",
":",
"# noqa: E501",
"raise",
"ValueError",
"(",
"\"Invalid value for `name`, must not be `None`\"",
")",
"#... | [
130,
4
] | [
140,
25
] | python | en | ['en', 'en', 'en'] | True |
Pet.photo_urls | (self) | Gets the photo_urls of this Pet. # noqa: E501
:return: The photo_urls of this Pet. # noqa: E501
:rtype: list[str]
| Gets the photo_urls of this Pet. # noqa: E501 | def photo_urls(self):
"""Gets the photo_urls of this Pet. # noqa: E501
:return: The photo_urls of this Pet. # noqa: E501
:rtype: list[str]
"""
return self._photo_urls | [
"def",
"photo_urls",
"(",
"self",
")",
":",
"return",
"self",
".",
"_photo_urls"
] | [
143,
4
] | [
150,
31
] | python | en | ['en', 'en', 'en'] | True |
Pet.photo_urls | (self, photo_urls) | Sets the photo_urls of this Pet.
:param photo_urls: The photo_urls of this Pet. # noqa: E501
:type photo_urls: list[str]
| Sets the photo_urls of this Pet. | def photo_urls(self, photo_urls):
"""Sets the photo_urls of this Pet.
:param photo_urls: The photo_urls of this Pet. # noqa: E501
:type photo_urls: list[str]
"""
if self.local_vars_configuration.client_side_validation and photo_urls is None: # noqa: E501
raise Val... | [
"def",
"photo_urls",
"(",
"self",
",",
"photo_urls",
")",
":",
"if",
"self",
".",
"local_vars_configuration",
".",
"client_side_validation",
"and",
"photo_urls",
"is",
"None",
":",
"# noqa: E501",
"raise",
"ValueError",
"(",
"\"Invalid value for `photo_urls`, must not b... | [
153,
4
] | [
163,
37
] | python | en | ['en', 'en', 'en'] | True |
Pet.tags | (self) | Gets the tags of this Pet. # noqa: E501
:return: The tags of this Pet. # noqa: E501
:rtype: list[Tag]
| Gets the tags of this Pet. # noqa: E501 | def tags(self):
"""Gets the tags of this Pet. # noqa: E501
:return: The tags of this Pet. # noqa: E501
:rtype: list[Tag]
"""
return self._tags | [
"def",
"tags",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tags"
] | [
166,
4
] | [
173,
25
] | python | en | ['en', 'en', 'en'] | True |
Pet.tags | (self, tags) | Sets the tags of this Pet.
:param tags: The tags of this Pet. # noqa: E501
:type tags: list[Tag]
| Sets the tags of this Pet. | def tags(self, tags):
"""Sets the tags of this Pet.
:param tags: The tags of this Pet. # noqa: E501
:type tags: list[Tag]
"""
self._tags = tags | [
"def",
"tags",
"(",
"self",
",",
"tags",
")",
":",
"self",
".",
"_tags",
"=",
"tags"
] | [
176,
4
] | [
184,
25
] | python | en | ['en', 'en', 'en'] | True |
Pet.status | (self) | Gets the status of this Pet. # noqa: E501
pet status in the store # noqa: E501
:return: The status of this Pet. # noqa: E501
:rtype: str
| Gets the status of this Pet. # noqa: E501 | def status(self):
"""Gets the status of this Pet. # noqa: E501
pet status in the store # noqa: E501
:return: The status of this Pet. # noqa: E501
:rtype: str
"""
return self._status | [
"def",
"status",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status"
] | [
187,
4
] | [
195,
27
] | python | en | ['en', 'en', 'en'] | True |
Pet.status | (self, status) | Sets the status of this Pet.
pet status in the store # noqa: E501
:param status: The status of this Pet. # noqa: E501
:type status: str
| Sets the status of this Pet. | def status(self, status):
"""Sets the status of this Pet.
pet status in the store # noqa: E501
:param status: The status of this Pet. # noqa: E501
:type status: str
"""
allowed_values = ["available", "pending", "sold"] # noqa: E501
if self.local_vars_configur... | [
"def",
"status",
"(",
"self",
",",
"status",
")",
":",
"allowed_values",
"=",
"[",
"\"available\"",
",",
"\"pending\"",
",",
"\"sold\"",
"]",
"# noqa: E501",
"if",
"self",
".",
"local_vars_configuration",
".",
"client_side_validation",
"and",
"status",
"not",
"i... | [
198,
4
] | [
213,
29
] | python | en | ['en', 'en', 'en'] | True |
Pet.to_dict | (self, serialize=False) | Returns the model properties as a dict | Returns the model properties as a dict | def to_dict(self, serialize=False):
"""Returns the model properties as a dict"""
result = {}
def convert(x):
if hasattr(x, "to_dict"):
args = inspect.getargspec(x.to_dict).args
if len(args) == 1:
return x.to_dict()
... | [
"def",
"to_dict",
"(",
"self",
",",
"serialize",
"=",
"False",
")",
":",
"result",
"=",
"{",
"}",
"def",
"convert",
"(",
"x",
")",
":",
"if",
"hasattr",
"(",
"x",
",",
"\"to_dict\"",
")",
":",
"args",
"=",
"inspect",
".",
"getargspec",
"(",
"x",
... | [
215,
4
] | [
245,
21
] | python | en | ['en', 'en', 'en'] | True |
Pet.to_str | (self) | Returns the string representation of the model | Returns the string representation of the model | def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict()) | [
"def",
"to_str",
"(",
"self",
")",
":",
"return",
"pprint",
".",
"pformat",
"(",
"self",
".",
"to_dict",
"(",
")",
")"
] | [
247,
4
] | [
249,
45
] | python | en | ['en', 'en', 'en'] | True |
Pet.__repr__ | (self) | For `print` and `pprint` | For `print` and `pprint` | def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str() | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"self",
".",
"to_str",
"(",
")"
] | [
251,
4
] | [
253,
28
] | python | en | ['en', 'en', 'en'] | True |
Pet.__eq__ | (self, other) | Returns true if both objects are equal | Returns true if both objects are equal | def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, Pet):
return False
return self.to_dict() == other.to_dict() | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Pet",
")",
":",
"return",
"False",
"return",
"self",
".",
"to_dict",
"(",
")",
"==",
"other",
".",
"to_dict",
"(",
")"
] | [
255,
4
] | [
260,
48
] | python | en | ['en', 'en', 'en'] | True |
Pet.__ne__ | (self, other) | Returns true if both objects are not equal | Returns true if both objects are not equal | def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, Pet):
return True
return self.to_dict() != other.to_dict() | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Pet",
")",
":",
"return",
"True",
"return",
"self",
".",
"to_dict",
"(",
")",
"!=",
"other",
".",
"to_dict",
"(",
")"
] | [
262,
4
] | [
267,
48
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) | Set up the Netatmo energy platform. | Set up the Netatmo energy platform. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the Netatmo energy platform."""
data_handler = hass.data[DOMAIN][entry.entry_id][DATA_HANDLER]
await data_handler.register_data_class(
HOMEDATA_DATA_CLASS_NAME, HOM... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
")",
"->",
"None",
":",
"data_handler",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",... | [
120,
0
] | [
169,
9
] | python | en | ['en', 'zu', 'en'] | True |
NetatmoThermostat.__init__ | (
self, data_handler: NetatmoDataHandler, home_id: str, room_id: str
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self, data_handler: NetatmoDataHandler, home_id: str, room_id: str
) -> None:
"""Initialize the sensor."""
ClimateEntity.__init__(self)
super().__init__(data_handler)
self._id = room_id
self._home_id = home_id
self._home_status_class = f"{HOMES... | [
"def",
"__init__",
"(",
"self",
",",
"data_handler",
":",
"NetatmoDataHandler",
",",
"home_id",
":",
"str",
",",
"room_id",
":",
"str",
")",
"->",
"None",
":",
"ClimateEntity",
".",
"__init__",
"(",
"self",
")",
"super",
"(",
")",
".",
"__init__",
"(",
... | [
175,
4
] | [
232,
58
] | python | en | ['en', 'en', 'en'] | True |
NetatmoThermostat.async_added_to_hass | (self) | Entity created. | Entity created. | async def async_added_to_hass(self) -> None:
"""Entity created."""
await super().async_added_to_hass()
for event_type in (
EVENT_TYPE_SET_POINT,
EVENT_TYPE_THERM_MODE,
EVENT_TYPE_CANCEL_SET_POINT,
EVENT_TYPE_SCHEDULE,
):
self._... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"for",
"event_type",
"in",
"(",
"EVENT_TYPE_SET_POINT",
",",
"EVENT_TYPE_THERM_MODE",
",",
"EVENT_TYPE_CANCEL_SET_POINT",
... | [
234,
4
] | [
255,
74
] | python | en | ['en', 'sm', 'en'] | False |
NetatmoThermostat.handle_event | (self, event: dict) | Handle webhook events. | Handle webhook events. | def handle_event(self, event: dict) -> None:
"""Handle webhook events."""
data = event["data"]
if self._home_id != data["home_id"]:
return
if data["event_type"] == EVENT_TYPE_SCHEDULE and "schedule_id" in data:
self._selected_schedule = self.hass.data[DOMAIN][DA... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
":",
"dict",
")",
"->",
"None",
":",
"data",
"=",
"event",
"[",
"\"data\"",
"]",
"if",
"self",
".",
"_home_id",
"!=",
"data",
"[",
"\"home_id\"",
"]",
":",
"return",
"if",
"data",
"[",
"\"event_type\"",... | [
258,
4
] | [
320,
22
] | python | en | ['eu', 'xh', 'en'] | False |
NetatmoThermostat._data | (self) | Return data for this entity. | Return data for this entity. | def _data(self) -> pyatmo.AsyncHomeData:
"""Return data for this entity."""
return cast(
pyatmo.AsyncHomeData, self.data_handler.data[self._data_classes[0]["name"]]
) | [
"def",
"_data",
"(",
"self",
")",
"->",
"pyatmo",
".",
"AsyncHomeData",
":",
"return",
"cast",
"(",
"pyatmo",
".",
"AsyncHomeData",
",",
"self",
".",
"data_handler",
".",
"data",
"[",
"self",
".",
"_data_classes",
"[",
"0",
"]",
"[",
"\"name\"",
"]",
"... | [
323,
4
] | [
327,
9
] | python | en | ['en', 'en', 'en'] | True |
NetatmoThermostat.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return self._support_flags | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_support_flags"
] | [
330,
4
] | [
332,
34
] | python | en | ['en', 'en', 'en'] | True |
NetatmoThermostat.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self) -> str:
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"return",
"TEMP_CELSIUS"
] | [
335,
4
] | [
337,
27
] | python | en | ['en', 'la', 'en'] | True |
NetatmoThermostat.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self) -> float | None:
"""Return the current temperature."""
return self._current_temperature | [
"def",
"current_temperature",
"(",
"self",
")",
"->",
"float",
"|",
"None",
":",
"return",
"self",
".",
"_current_temperature"
] | [
340,
4
] | [
342,
40
] | python | en | ['en', 'la', 'en'] | True |
NetatmoThermostat.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self) -> float | None:
"""Return the temperature we try to reach."""
return self._target_temperature | [
"def",
"target_temperature",
"(",
"self",
")",
"->",
"float",
"|",
"None",
":",
"return",
"self",
".",
"_target_temperature"
] | [
345,
4
] | [
347,
39
] | python | en | ['en', 'en', 'en'] | True |
NetatmoThermostat.target_temperature_step | (self) | Return the supported step of target temperature. | Return the supported step of target temperature. | def target_temperature_step(self) -> float | None:
"""Return the supported step of target temperature."""
return PRECISION_HALVES | [
"def",
"target_temperature_step",
"(",
"self",
")",
"->",
"float",
"|",
"None",
":",
"return",
"PRECISION_HALVES"
] | [
350,
4
] | [
352,
31
] | python | en | ['en', 'en', 'en'] | True |
NetatmoThermostat.hvac_mode | (self) | Return hvac operation ie. heat, cool mode. | Return hvac operation ie. heat, cool mode. | def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode."""
return self._hvac_mode | [
"def",
"hvac_mode",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_hvac_mode"
] | [
355,
4
] | [
357,
30
] | python | bg | ['en', 'bg', 'bg'] | True |
NetatmoThermostat.hvac_modes | (self) | Return the list of available hvac operation modes. | Return the list of available hvac operation modes. | def hvac_modes(self) -> list[str]:
"""Return the list of available hvac operation modes."""
return self._operation_list | [
"def",
"hvac_modes",
"(",
"self",
")",
"->",
"list",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_operation_list"
] | [
360,
4
] | [
362,
35
] | python | en | ['en', 'en', 'en'] | True |
NetatmoThermostat.hvac_action | (self) | Return the current running hvac operation if supported. | Return the current running hvac operation if supported. | def hvac_action(self) -> str | None:
"""Return the current running hvac operation if supported."""
if self._model == NA_THERM and self._boilerstatus is not None:
return CURRENT_HVAC_MAP_NETATMO[self._boilerstatus]
# Maybe it is a valve
if self._room_status and self._room_stat... | [
"def",
"hvac_action",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"if",
"self",
".",
"_model",
"==",
"NA_THERM",
"and",
"self",
".",
"_boilerstatus",
"is",
"not",
"None",
":",
"return",
"CURRENT_HVAC_MAP_NETATMO",
"[",
"self",
".",
"_boilerstatus",
"]... | [
365,
4
] | [
372,
32
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.