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_onewiredirect_setup_valid_device | (hass, device_id) | Test that sysbus config entry works correctly. | Test that sysbus config entry works correctly. | async def test_onewiredirect_setup_valid_device(hass, device_id):
"""Test that sysbus config entry works correctly."""
await async_setup_component(hass, "persistent_notification", {})
entity_registry = mock_registry(hass)
device_registry = mock_device_registry(hass)
glob_result, read_side_effect = ... | [
"async",
"def",
"test_onewiredirect_setup_valid_device",
"(",
"hass",
",",
"device_id",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entity_registry",
"=",
"mock_registry",
"(",
"hass",
")",
"devic... | [
184,
0
] | [
224,
70
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Kaiterra integration. | Set up the Kaiterra integration. | async def async_setup(hass, config):
"""Set up the Kaiterra integration."""
conf = config[DOMAIN]
scan_interval = conf[CONF_SCAN_INTERVAL]
devices = conf[CONF_DEVICES]
session = async_get_clientsession(hass)
api = hass.data[DOMAIN] = KaiterraApiData(hass, conf, session)
await api.async_upd... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"scan_interval",
"=",
"conf",
"[",
"CONF_SCAN_INTERVAL",
"]",
"devices",
"=",
"conf",
"[",
"CONF_DEVICES",
"]",
"session",
"=",
"async_get_clients... | [
55,
0
] | [
89,
15
] | python | en | ['en', 'no', 'en'] | True |
async_validate_trigger_config | (
hass: HomeAssistant, config: dict[str, Any]
) | Validate config. | Validate config. | async def async_validate_trigger_config(
hass: HomeAssistant, config: dict[str, Any]
) -> dict[str, Any]:
"""Validate config."""
config = TRIGGER_SCHEMA(config)
# if device is available verify parameters against device capabilities
wrapper = get_device_wrapper(hass, config[CONF_DEVICE_ID])
if n... | [
"async",
"def",
"async_validate_trigger_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"dict",
"[",
"str",
",",
"Any",
"]",
":",
"config",
"=",
"TRIGGER_SCHEMA",
"(",
"config",
")",
"# if d... | [
49,
0
] | [
69,
5
] | python | en | ['en', 'la', 'it'] | False |
async_get_triggers | (
hass: HomeAssistant, device_id: str
) | List device triggers for Shelly devices. | List device triggers for Shelly devices. | async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
"""List device triggers for Shelly devices."""
triggers = []
wrapper = get_device_wrapper(hass, device_id)
if not wrapper:
raise InvalidDeviceAutomationConfig(f"Device not found: {device_id}")
... | [
"async",
"def",
"async_get_triggers",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"list",
"[",
"dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"triggers",
"=",
"[",
"]",
"wrapper",
"=",
"get_device_wrapper",
"(",
"hass",
... | [
72,
0
] | [
109,
19
] | python | en | ['en', 'en', 'en'] | True |
async_attach_trigger | (
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: AutomationTriggerInfo,
) | Attach a trigger. | Attach a trigger. | async def async_attach_trigger(
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: AutomationTriggerInfo,
) -> CALLBACK_TYPE:
"""Attach a trigger."""
event_config = {
event_trigger.CONF_PLATFORM: CONF_EVENT,
event_trigger.CONF_EVENT_TYPE: EVEN... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"action",
":",
"AutomationActionType",
",",
"automation_info",
":",
"AutomationTriggerInfo",
",",
")",
"->",
"CALLBACK_TYPE",
":",
"event_config",
"=",
... | [
112,
0
] | [
131,
5
] | python | en | ['en', 'lb', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Microsoft Teams notification service. | Get the Microsoft Teams notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Microsoft Teams notification service."""
webhook_url = config.get(CONF_URL)
try:
return MSTeamsNotificationService(webhook_url)
except RuntimeError as err:
_LOGGER.exception("Error in creating a new Microsoft Teams message:... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"webhook_url",
"=",
"config",
".",
"get",
"(",
"CONF_URL",
")",
"try",
":",
"return",
"MSTeamsNotificationService",
"(",
"webhook_url",
")",
"except",
"RuntimeError... | [
23,
0
] | [
32,
19
] | python | en | ['en', 'en', 'en'] | True |
MSTeamsNotificationService.__init__ | (self, webhook_url) | Initialize the service. | Initialize the service. | def __init__(self, webhook_url):
"""Initialize the service."""
self._webhook_url = webhook_url | [
"def",
"__init__",
"(",
"self",
",",
"webhook_url",
")",
":",
"self",
".",
"_webhook_url",
"=",
"webhook_url"
] | [
38,
4
] | [
40,
39
] | python | en | ['en', 'en', 'en'] | True |
MSTeamsNotificationService.send_message | (self, message=None, **kwargs) | Send a message to the webhook. | Send a message to the webhook. | def send_message(self, message=None, **kwargs):
"""Send a message to the webhook."""
teams_message = pymsteams.connectorcard(self._webhook_url)
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
data = kwargs.get(ATTR_DATA)
teams_message.title(title)
teams_message.tex... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"teams_message",
"=",
"pymsteams",
".",
"connectorcard",
"(",
"self",
".",
"_webhook_url",
")",
"title",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
","... | [
42,
4
] | [
68,
72
] | python | en | ['en', 'en', 'en'] | True |
DevoloMultiLevelSwitchDeviceEntity.__init__ | (
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
) | Initialize a multi level switch within devolo Home Control. | Initialize a multi level switch within devolo Home Control. | def __init__(
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
) -> None:
"""Initialize a multi level switch within devolo Home Control."""
super().__init__(
homecontrol=homecontrol,
device_instance=device_instance,
element_uid=elem... | [
"def",
"__init__",
"(",
"self",
",",
"homecontrol",
":",
"HomeControl",
",",
"device_instance",
":",
"Zwave",
",",
"element_uid",
":",
"str",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"homecontrol",
"=",
"homecontrol",
",",
"device_i... | [
10,
4
] | [
23,
61
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) | Test setup with basic config. | Test setup with basic config. | async def test_setup(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None:
"""Test setup with basic config."""
await setup_integration(hass, aioclient_mock)
entity_registry = er.async_get(hass)
main = entity_registry.async_get(MAIN_ENTITY_ID)
assert hass.states.get(MAIN_ENTITY_ID)
... | [
"async",
"def",
"test_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"entity_registry",
"=",
"er",
".",
"async_get",
"("... | [
82,
0
] | [
92,
40
] | python | en | ['en', 'zu', 'en'] | True |
test_idle_setup | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test setup with idle device. | Test setup with idle device. | async def test_idle_setup(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test setup with idle device."""
await setup_integration(hass, aioclient_mock, power=False)
state = hass.states.get(MAIN_ENTITY_ID)
assert state.state == STATE_STANDBY | [
"async",
"def",
"test_idle_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"power",
"=",
"False",
")",
"state",
"=",
"h... | [
95,
0
] | [
102,
39
] | python | en | ['en', 'haw', 'en'] | True |
test_tv_setup | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test Roku TV setup. | Test Roku TV setup. | async def test_tv_setup(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test Roku TV setup."""
await setup_integration(
hass,
aioclient_mock,
device="rokutv",
app="tvinput-dtv",
host=TV_HOST,
unique_id=TV_SERIAL,
)
entity_regis... | [
"async",
"def",
"test_tv_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"device",
"=",
"\"rokutv\"",
",",
"app",
"=",
... | [
105,
0
] | [
124,
36
] | python | en | ['en', 'haw', 'en'] | True |
test_availability | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test entity availability. | Test entity availability. | async def test_availability(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test entity availability."""
now = dt_util.utcnow()
future = now + timedelta(minutes=1)
with patch("homeassistant.util.dt.utcnow", return_value=now):
await setup_integration(hass, aioclient_m... | [
"async",
"def",
"test_availability",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"future",
"=",
"now",
"+",
"timedelta",
"(",
"minutes",
"=",
... | [
127,
0
] | [
149,
66
] | python | en | ['en', 'ga', 'en'] | True |
test_supported_features | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test supported features. | Test supported features. | async def test_supported_features(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test supported features."""
await setup_integration(hass, aioclient_mock)
# Features supported for Rokus
state = hass.states.get(MAIN_ENTITY_ID)
assert (
SUPPORT_PREVIOUS_TRACK
... | [
"async",
"def",
"test_supported_features",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"# Features supported for Rokus",
"state",
"... | [
152,
0
] | [
173,
5
] | python | en | ['en', 'en', 'en'] | True |
test_tv_supported_features | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test supported features for Roku TV. | Test supported features for Roku TV. | async def test_tv_supported_features(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test supported features for Roku TV."""
await setup_integration(
hass,
aioclient_mock,
device="rokutv",
app="tvinput-dtv",
host=TV_HOST,
unique_id=TV_S... | [
"async",
"def",
"test_tv_supported_features",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"device",
"=",
"\"rokutv\"",
",",
"ap... | [
176,
0
] | [
203,
5
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test attributes. | Test attributes. | async def test_attributes(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test attributes."""
await setup_integration(hass, aioclient_mock)
state = hass.states.get(MAIN_ENTITY_ID)
assert state.state == STATE_HOME
assert state.attributes.get(ATTR_MEDIA_CONTENT_TYPE) is N... | [
"async",
"def",
"test_attributes",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"state",
"=",
"hass",
".",
"states",
".",
"g... | [
206,
0
] | [
218,
60
] | python | en | ['en', 'la', 'en'] | False |
test_attributes_app | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test attributes for app. | Test attributes for app. | async def test_attributes_app(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test attributes for app."""
await setup_integration(hass, aioclient_mock, app="netflix")
state = hass.states.get(MAIN_ENTITY_ID)
assert state.state == STATE_ON
assert state.attributes.get(ATTR... | [
"async",
"def",
"test_attributes_app",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"app",
"=",
"\"netflix\"",
")",
"state",
"... | [
221,
0
] | [
233,
63
] | python | en | ['en', 'en', 'en'] | True |
test_attributes_app_media_playing | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test attributes for app with playing media. | Test attributes for app with playing media. | async def test_attributes_app_media_playing(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test attributes for app with playing media."""
await setup_integration(hass, aioclient_mock, app="pluto", media_state="play")
state = hass.states.get(MAIN_ENTITY_ID)
assert state.stat... | [
"async",
"def",
"test_attributes_app_media_playing",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"app",
"=",
"\"pluto\"",
",",
... | [
236,
0
] | [
250,
79
] | python | en | ['en', 'en', 'en'] | True |
test_attributes_app_media_paused | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test attributes for app with paused media. | Test attributes for app with paused media. | async def test_attributes_app_media_paused(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test attributes for app with paused media."""
await setup_integration(hass, aioclient_mock, app="pluto", media_state="pause")
state = hass.states.get(MAIN_ENTITY_ID)
assert state.state... | [
"async",
"def",
"test_attributes_app_media_paused",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"app",
"=",
"\"pluto\"",
",",
"... | [
253,
0
] | [
267,
79
] | python | en | ['en', 'en', 'en'] | True |
test_attributes_screensaver | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test attributes for app with screensaver. | Test attributes for app with screensaver. | async def test_attributes_screensaver(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test attributes for app with screensaver."""
await setup_integration(hass, aioclient_mock, app="screensaver")
state = hass.states.get(MAIN_ENTITY_ID)
assert state.state == STATE_IDLE
a... | [
"async",
"def",
"test_attributes_screensaver",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"app",
"=",
"\"screensaver\"",
")",
... | [
270,
0
] | [
282,
60
] | python | en | ['en', 'en', 'en'] | True |
test_tv_attributes | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test attributes for Roku TV. | Test attributes for Roku TV. | async def test_tv_attributes(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test attributes for Roku TV."""
await setup_integration(
hass,
aioclient_mock,
device="rokutv",
app="tvinput-dtv",
host=TV_HOST,
unique_id=TV_SERIAL,
)
... | [
"async",
"def",
"test_tv_attributes",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"device",
"=",
"\"rokutv\"",
",",
"app",
"=... | [
285,
0
] | [
306,
62
] | python | en | ['en', 'en', 'en'] | True |
test_tv_device_registry | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test device registered for Roku TV in the device registry. | Test device registered for Roku TV in the device registry. | async def test_tv_device_registry(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test device registered for Roku TV in the device registry."""
await setup_integration(
hass,
aioclient_mock,
device="rokutv",
app="tvinput-dtv",
host=TV_HOST,
... | [
"async",
"def",
"test_tv_device_registry",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"device",
"=",
"\"rokutv\"",
",",
"app",... | [
309,
0
] | [
329,
41
] | python | en | ['en', 'en', 'en'] | True |
test_services | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the different media player services. | Test the different media player services. | async def test_services(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the different media player services."""
await setup_integration(hass, aioclient_mock)
with patch("homeassistant.components.roku.coordinator.Roku.remote") as remote_mock:
await hass.services.asyn... | [
"async",
"def",
"test_services",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"with",
"patch",
"(",
"\"homeassistant.components.ro... | [
332,
0
] | [
444,
49
] | python | en | ['en', 'en', 'en'] | True |
test_tv_services | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the media player services related to Roku TV. | Test the media player services related to Roku TV. | async def test_tv_services(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the media player services related to Roku TV."""
await setup_integration(
hass,
aioclient_mock,
device="rokutv",
app="tvinput-dtv",
host=TV_HOST,
unique_id=... | [
"async",
"def",
"test_tv_services",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"device",
"=",
"\"rokutv\"",
",",
"app",
"=",... | [
447,
0
] | [
499,
47
] | python | en | ['en', 'en', 'en'] | True |
test_media_browse | (hass, aioclient_mock, hass_ws_client) | Test browsing media. | Test browsing media. | async def test_media_browse(hass, aioclient_mock, hass_ws_client):
"""Test browsing media."""
await setup_integration(
hass,
aioclient_mock,
device="rokutv",
app="tvinput-dtv",
host=TV_HOST,
unique_id=TV_SERIAL,
)
client = await hass_ws_client(hass)
... | [
"async",
"def",
"test_media_browse",
"(",
"hass",
",",
"aioclient_mock",
",",
"hass_ws_client",
")",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"device",
"=",
"\"rokutv\"",
",",
"app",
"=",
"\"tvinput-dtv\"",
",",
"host",
"=",
... | [
502,
0
] | [
625,
29
] | python | en | ['en', 'jv', 'en'] | True |
test_media_browse_internal | (hass, aioclient_mock, hass_ws_client) | Test browsing media with internal url. | Test browsing media with internal url. | async def test_media_browse_internal(hass, aioclient_mock, hass_ws_client):
"""Test browsing media with internal url."""
await async_process_ha_core_config(
hass,
{"internal_url": "http://example.local:8123"},
)
assert hass.config.internal_url == "http://example.local:8123"
await s... | [
"async",
"def",
"test_media_browse_internal",
"(",
"hass",
",",
"aioclient_mock",
",",
"hass_ws_client",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://example.local:8123\"",
"}",
",",
")",
"assert",
"hass"... | [
628,
0
] | [
687,
51
] | python | en | ['en', 'en', 'en'] | True |
test_integration_services | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test integration services. | Test integration services. | async def test_integration_services(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test integration services."""
await setup_integration(hass, aioclient_mock)
with patch("homeassistant.components.roku.coordinator.Roku.search") as search_mock:
await hass.services.async_c... | [
"async",
"def",
"test_integration_services",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"setup_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"with",
"patch",
"(",
"\"homeassistant.c... | [
690,
0
] | [
703,
56
] | python | en | ['en', 'da', 'en'] | True |
test_ok_requests | (request_path, request_params, aiohttp_client) | Test request paths that should not be filtered. | Test request paths that should not be filtered. | async def test_ok_requests(request_path, request_params, aiohttp_client):
"""Test request paths that should not be filtered."""
app = web.Application()
app.router.add_get("/{all:.*}", mock_handler)
setup_security_filter(app)
mock_api_client = await aiohttp_client(app)
resp = await mock_api_cli... | [
"async",
"def",
"test_ok_requests",
"(",
"request_path",
",",
"request_params",
",",
"aiohttp_client",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
".",
"router",
".",
"add_get",
"(",
"\"/{all:.*}\"",
",",
"mock_handler",
")",
"setup_secur... | [
23,
0
] | [
34,
36
] | python | en | ['en', 'en', 'en'] | True |
test_bad_requests | (
request_path, request_params, fail_on_query_string, aiohttp_client, caplog, loop
) | Test request paths that should be filtered. | Test request paths that should be filtered. | async def test_bad_requests(
request_path, request_params, fail_on_query_string, aiohttp_client, caplog, loop
):
"""Test request paths that should be filtered."""
app = web.Application()
app.router.add_get("/{all:.*}", mock_handler)
setup_security_filter(app)
mock_api_client = await aiohttp_cl... | [
"async",
"def",
"test_bad_requests",
"(",
"request_path",
",",
"request_params",
",",
"fail_on_query_string",
",",
"aiohttp_client",
",",
"caplog",
",",
"loop",
")",
":",
"app",
"=",
"web",
".",
"Application",
"(",
")",
"app",
".",
"router",
".",
"add_get",
... | [
55,
0
] | [
87,
33
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the MyChevy sensors. | Set up the MyChevy sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the MyChevy sensors."""
if discovery_info is None:
return
sensors = []
hub = hass.data[MYCHEVY_DOMAIN]
for sconfig in SENSORS:
for car in hub.cars:
sensors.append(EVBinarySen... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"sensors",
"=",
"[",
"]",
"hub",
"=",
"hass",
".",
"data",
"["... | [
13,
0
] | [
24,
31
] | python | en | ['en', 'fr', 'en'] | True |
EVBinarySensor.__init__ | (self, connection, config, car_vid) | Initialize sensor with car connection. | Initialize sensor with car connection. | def __init__(self, connection, config, car_vid):
"""Initialize sensor with car connection."""
self._conn = connection
self._name = config.name
self._attr = config.attr
self._type = config.device_class
self._is_on = None
self._car_vid = car_vid
self.entity_... | [
"def",
"__init__",
"(",
"self",
",",
"connection",
",",
"config",
",",
"car_vid",
")",
":",
"self",
".",
"_conn",
"=",
"connection",
"self",
".",
"_name",
"=",
"config",
".",
"name",
"self",
".",
"_attr",
"=",
"config",
".",
"attr",
"self",
".",
"_ty... | [
35,
4
] | [
43,
115
] | python | en | ['en', 'en', 'en'] | True |
EVBinarySensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
46,
4
] | [
48,
25
] | python | en | ['en', 'ig', 'en'] | True |
EVBinarySensor.is_on | (self) | Return if on. | Return if on. | def is_on(self):
"""Return if on."""
return self._is_on | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_on"
] | [
51,
4
] | [
53,
26
] | python | en | ['en', 'et', 'en'] | True |
EVBinarySensor._car | (self) | Return the car. | Return the car. | def _car(self):
"""Return the car."""
return self._conn.get_car(self._car_vid) | [
"def",
"_car",
"(",
"self",
")",
":",
"return",
"self",
".",
"_conn",
".",
"get_car",
"(",
"self",
".",
"_car_vid",
")"
] | [
56,
4
] | [
58,
48
] | python | en | ['en', 'hi-Latn', 'en'] | True |
EVBinarySensor.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatcher_connect(
UPDATE_TOPIC, self.async_update_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
"UPDATE_TOPIC",
",",
"self",
".",
"async_update_callback",
")",
")"
] | [
60,
4
] | [
66,
9
] | python | en | ['en', 'no', 'en'] | False |
EVBinarySensor.async_update_callback | (self) | Update state. | Update state. | def async_update_callback(self):
"""Update state."""
if self._car is not None:
self._is_on = getattr(self._car, self._attr, None)
self.async_write_ha_state() | [
"def",
"async_update_callback",
"(",
"self",
")",
":",
"if",
"self",
".",
"_car",
"is",
"not",
"None",
":",
"self",
".",
"_is_on",
"=",
"getattr",
"(",
"self",
".",
"_car",
",",
"self",
".",
"_attr",
",",
"None",
")",
"self",
".",
"async_write_ha_state... | [
69,
4
] | [
73,
39
] | python | en | ['en', 'co', 'en'] | False |
EVBinarySensor.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
76,
4
] | [
78,
20
] | python | en | ['en', 'en', 'en'] | True |
pywemo_model | () | Pywemo LightSwitch models use the switch platform. | Pywemo LightSwitch models use the switch platform. | def pywemo_model():
"""Pywemo LightSwitch models use the switch platform."""
return "Insight" | [
"def",
"pywemo_model",
"(",
")",
":",
"return",
"\"Insight\""
] | [
15,
0
] | [
17,
20
] | python | en | ['en', 'en', 'en'] | True |
pywemo_device_fixture | (pywemo_device) | Fixture for WeMoDevice instances. | Fixture for WeMoDevice instances. | def pywemo_device_fixture(pywemo_device):
"""Fixture for WeMoDevice instances."""
pywemo_device.insight_params = {
"currentpower": 1.0,
"todaymw": 200000000.0,
"state": 0,
"onfor": 0,
"ontoday": 0,
"ontotal": 0,
"powerthreshold": 0,
}
yield pywemo_... | [
"def",
"pywemo_device_fixture",
"(",
"pywemo_device",
")",
":",
"pywemo_device",
".",
"insight_params",
"=",
"{",
"\"currentpower\"",
":",
"1.0",
",",
"\"todaymw\"",
":",
"200000000.0",
",",
"\"state\"",
":",
"0",
",",
"\"onfor\"",
":",
"0",
",",
"\"ontoday\"",
... | [
21,
0
] | [
32,
23
] | python | en | ['en', 'en', 'en'] | True |
InsightTestTemplate.wemo_entity_suffix_fixture | (cls) | Select the appropriate entity for the test. | Select the appropriate entity for the test. | def wemo_entity_suffix_fixture(cls):
"""Select the appropriate entity for the test."""
return cls.ENTITY_ID_SUFFIX | [
"def",
"wemo_entity_suffix_fixture",
"(",
"cls",
")",
":",
"return",
"cls",
".",
"ENTITY_ID_SUFFIX"
] | [
44,
4
] | [
46,
35
] | python | en | ['en', 'en', 'en'] | True |
InsightTestTemplate.test_async_update_locked_multiple_updates | (
self, hass, pywemo_device, wemo_entity
) | Test that two hass async_update state updates do not proceed at the same time. | Test that two hass async_update state updates do not proceed at the same time. | async def test_async_update_locked_multiple_updates(
self, hass, pywemo_device, wemo_entity
):
"""Test that two hass async_update state updates do not proceed at the same time."""
await entity_test_helpers.test_async_update_locked_multiple_updates(
hass,
pywemo_device... | [
"async",
"def",
"test_async_update_locked_multiple_updates",
"(",
"self",
",",
"hass",
",",
"pywemo_device",
",",
"wemo_entity",
")",
":",
"await",
"entity_test_helpers",
".",
"test_async_update_locked_multiple_updates",
"(",
"hass",
",",
"pywemo_device",
",",
"wemo_entit... | [
51,
4
] | [
59,
9
] | python | en | ['en', 'en', 'en'] | True |
InsightTestTemplate.test_async_update_locked_multiple_callbacks | (
self, hass, pywemo_device, wemo_entity
) | Test that two device callback state updates do not proceed at the same time. | Test that two device callback state updates do not proceed at the same time. | async def test_async_update_locked_multiple_callbacks(
self, hass, pywemo_device, wemo_entity
):
"""Test that two device callback state updates do not proceed at the same time."""
await entity_test_helpers.test_async_update_locked_multiple_callbacks(
hass,
pywemo_devi... | [
"async",
"def",
"test_async_update_locked_multiple_callbacks",
"(",
"self",
",",
"hass",
",",
"pywemo_device",
",",
"wemo_entity",
")",
":",
"await",
"entity_test_helpers",
".",
"test_async_update_locked_multiple_callbacks",
"(",
"hass",
",",
"pywemo_device",
",",
"wemo_e... | [
61,
4
] | [
69,
9
] | python | en | ['en', 'en', 'en'] | True |
InsightTestTemplate.test_async_update_locked_callback_and_update | (
self, hass, pywemo_device, wemo_entity
) | Test that a callback and a state update request can't both happen at the same time. | Test that a callback and a state update request can't both happen at the same time. | async def test_async_update_locked_callback_and_update(
self, hass, pywemo_device, wemo_entity
):
"""Test that a callback and a state update request can't both happen at the same time."""
await entity_test_helpers.test_async_update_locked_callback_and_update(
hass,
py... | [
"async",
"def",
"test_async_update_locked_callback_and_update",
"(",
"self",
",",
"hass",
",",
"pywemo_device",
",",
"wemo_entity",
")",
":",
"await",
"entity_test_helpers",
".",
"test_async_update_locked_callback_and_update",
"(",
"hass",
",",
"pywemo_device",
",",
"wemo... | [
71,
4
] | [
79,
9
] | python | en | ['en', 'en', 'en'] | True |
InsightTestTemplate.test_state_unavailable | (self, hass, wemo_entity, pywemo_device) | Test that there is no failure if the insight_params is not populated. | Test that there is no failure if the insight_params is not populated. | async def test_state_unavailable(self, hass, wemo_entity, pywemo_device):
"""Test that there is no failure if the insight_params is not populated."""
del pywemo_device.insight_params[self.INSIGHT_PARAM_NAME]
await async_setup_component(hass, HA_DOMAIN, {})
await hass.services.async_call(... | [
"async",
"def",
"test_state_unavailable",
"(",
"self",
",",
"hass",
",",
"wemo_entity",
",",
"pywemo_device",
")",
":",
"del",
"pywemo_device",
".",
"insight_params",
"[",
"self",
".",
"INSIGHT_PARAM_NAME",
"]",
"await",
"async_setup_component",
"(",
"hass",
",",
... | [
81,
4
] | [
91,
80
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Broadlink integration. | Set up the Broadlink integration. | async def async_setup(hass, config):
"""Set up the Broadlink integration."""
hass.data[DOMAIN] = BroadlinkData()
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"BroadlinkData",
"(",
")",
"return",
"True"
] | [
19,
0
] | [
22,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a Broadlink device from a config entry. | Set up a Broadlink device from a config entry. | async def async_setup_entry(hass, entry):
"""Set up a Broadlink device from a config entry."""
data = hass.data[DOMAIN]
if data.heartbeat is None:
data.heartbeat = BroadlinkHeartbeat(hass)
hass.async_create_task(data.heartbeat.async_setup())
device = BroadlinkDevice(hass, entry)
re... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"if",
"data",
".",
"heartbeat",
"is",
"None",
":",
"data",
".",
"heartbeat",
"=",
"BroadlinkHeartbeat",
"(",
"hass",
")",
"h... | [
25,
0
] | [
34,
37
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
data = hass.data[DOMAIN]
device = data.devices.pop(entry.entry_id)
result = await device.async_unload()
if not data.devices:
await data.heartbeat.async_unload()
data.heartbeat = None
return result | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"device",
"=",
"data",
".",
"devices",
".",
"pop",
"(",
"entry",
".",
"entry_id",
")",
"result",
"=",
"await",
"device",
... | [
37,
0
] | [
48,
17
] | python | en | ['en', 'es', 'en'] | True |
update_rules_args | () |
Mocks InsightsConfig with some values that allow instantiating InsightsUploadConf without errors.
|
Mocks InsightsConfig with some values that allow instantiating InsightsUploadConf without errors.
| def update_rules_args():
"""
Mocks InsightsConfig with some values that allow instantiating InsightsUploadConf without errors.
"""
return Mock(base_url=""), Mock | [
"def",
"update_rules_args",
"(",
")",
":",
"return",
"Mock",
"(",
"base_url",
"=",
"\"\"",
")",
",",
"Mock"
] | [
9,
0
] | [
13,
34
] | python | en | ['en', 'error', 'th'] | False |
coerce_result | (result) |
Coerces return value to a tuple if it returned only a single value.
|
Coerces return value to a tuple if it returned only a single value.
| def coerce_result(result):
"""
Coerces return value to a tuple if it returned only a single value.
"""
if isinstance(result, tuple):
return result
else:
return (result,) | [
"def",
"coerce_result",
"(",
"result",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"tuple",
")",
":",
"return",
"result",
"else",
":",
"return",
"(",
"result",
",",
")"
] | [
16,
0
] | [
23,
24
] | python | en | ['en', 'error', 'th'] | False |
try_disk_call_file | (mock) |
Finds a filename what the try_disk method was called with.
|
Finds a filename what the try_disk method was called with.
| def try_disk_call_file(mock):
"""
Finds a filename what the try_disk method was called with.
"""
name, args, kwargs = mock.mock_calls[0]
return args[0] | [
"def",
"try_disk_call_file",
"(",
"mock",
")",
":",
"name",
",",
"args",
",",
"kwargs",
"=",
"mock",
".",
"mock_calls",
"[",
"0",
"]",
"return",
"args",
"[",
"0",
"]"
] | [
26,
0
] | [
31,
18
] | python | en | ['en', 'error', 'th'] | False |
patch_insights_upload_conf | () |
Mocks InsightsUploadConf class.
|
Mocks InsightsUploadConf class.
| def patch_insights_upload_conf():
"""
Mocks InsightsUploadConf class.
"""
def decorator(old_function):
patcher = patch("insights.client.client.InsightsUploadConf")
return patcher(old_function)
return decorator | [
"def",
"patch_insights_upload_conf",
"(",
")",
":",
"def",
"decorator",
"(",
"old_function",
")",
":",
"patcher",
"=",
"patch",
"(",
"\"insights.client.client.InsightsUploadConf\"",
")",
"return",
"patcher",
"(",
"old_function",
")",
"return",
"decorator"
] | [
34,
0
] | [
41,
20
] | python | en | ['en', 'error', 'th'] | False |
patch_get_collection_rules | (return_value) |
Mocks InsightsUploadConf.get_collection_rules method so it returns a given value.
|
Mocks InsightsUploadConf.get_collection_rules method so it returns a given value.
| def patch_get_collection_rules(return_value):
"""
Mocks InsightsUploadConf.get_collection_rules method so it returns a given value.
"""
def decorator(old_function):
patcher = patch("insights.client.client.InsightsUploadConf.get_collection_rules", return_value=return_value)
return patcher... | [
"def",
"patch_get_collection_rules",
"(",
"return_value",
")",
":",
"def",
"decorator",
"(",
"old_function",
")",
":",
"patcher",
"=",
"patch",
"(",
"\"insights.client.client.InsightsUploadConf.get_collection_rules\"",
",",
"return_value",
"=",
"return_value",
")",
"retur... | [
44,
0
] | [
51,
20
] | python | en | ['en', 'error', 'th'] | False |
patch_try_disk | (return_value) |
Mocks InsightsUploadConf.try_disk method so it returns a given value.
|
Mocks InsightsUploadConf.try_disk method so it returns a given value.
| def patch_try_disk(return_value):
"""
Mocks InsightsUploadConf.try_disk method so it returns a given value.
"""
def decorator(old_function):
patcher = patch("insights.client.client.InsightsUploadConf.try_disk", return_value=return_value)
return patcher(old_function)
return decorator | [
"def",
"patch_try_disk",
"(",
"return_value",
")",
":",
"def",
"decorator",
"(",
"old_function",
")",
":",
"patcher",
"=",
"patch",
"(",
"\"insights.client.client.InsightsUploadConf.try_disk\"",
",",
"return_value",
"=",
"return_value",
")",
"return",
"patcher",
"(",
... | [
54,
0
] | [
61,
20
] | python | en | ['en', 'error', 'th'] | False |
patch_collection_rules_file | () |
Mocks the collection_rules_file contant so it contains a fixed value.
|
Mocks the collection_rules_file contant so it contains a fixed value.
| def patch_collection_rules_file():
"""
Mocks the collection_rules_file contant so it contains a fixed value.
"""
def decorator(old_function):
patcher = patch("insights.client.collection_rules.constants.collection_rules_file", collection_rules_file)
return patcher(old_function)
return... | [
"def",
"patch_collection_rules_file",
"(",
")",
":",
"def",
"decorator",
"(",
"old_function",
")",
":",
"patcher",
"=",
"patch",
"(",
"\"insights.client.collection_rules.constants.collection_rules_file\"",
",",
"collection_rules_file",
")",
"return",
"patcher",
"(",
"old_... | [
64,
0
] | [
71,
20
] | python | en | ['en', 'error', 'th'] | False |
test_no_connection_error | () |
Error is raised when connection couldn't be established.
|
Error is raised when connection couldn't be established.
| def test_no_connection_error():
"""
Error is raised when connection couldn't be established.
"""
config, pconn = update_rules_args()
with raises(ValueError):
update_rules(config, None) | [
"def",
"test_no_connection_error",
"(",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"with",
"raises",
"(",
"ValueError",
")",
":",
"update_rules",
"(",
"config",
",",
"None",
")"
] | [
75,
0
] | [
81,
34
] | python | en | ['en', 'error', 'th'] | False |
test_no_connection_no_configuration | (insights_upload_conf) |
Configuration is not loaded when connection couldn't be established.
|
Configuration is not loaded when connection couldn't be established.
| def test_no_connection_no_configuration(insights_upload_conf):
"""
Configuration is not loaded when connection couldn't be established.
"""
config, pconn = update_rules_args()
try:
update_rules(config, None)
except ValueError:
pass
insights_upload_conf.assert_not_called() | [
"def",
"test_no_connection_no_configuration",
"(",
"insights_upload_conf",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"try",
":",
"update_rules",
"(",
"config",
",",
"None",
")",
"except",
"ValueError",
":",
"pass",
"insights_upload_conf",... | [
85,
0
] | [
95,
44
] | python | en | ['en', 'error', 'th'] | False |
test_configuration | (insights_upload_conf) |
Configuration is created with given options and retrieved connection.
|
Configuration is created with given options and retrieved connection.
| def test_configuration(insights_upload_conf):
"""
Configuration is created with given options and retrieved connection.
"""
config, pconn = update_rules_args()
update_rules(config, pconn)
insights_upload_conf.assert_called_once_with(config, conn=pconn) | [
"def",
"test_configuration",
"(",
"insights_upload_conf",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"update_rules",
"(",
"config",
",",
"pconn",
")",
"insights_upload_conf",
".",
"assert_called_once_with",
"(",
"config",
",",
"conn",
"=... | [
99,
0
] | [
106,
68
] | python | en | ['en', 'error', 'th'] | False |
test_return_get_conf_update | (insights_upload_conf) |
Updated configuration is loaded and returned.
|
Updated configuration is loaded and returned.
| def test_return_get_conf_update(insights_upload_conf):
"""
Updated configuration is loaded and returned.
"""
config, pconn = update_rules_args()
result = update_rules(config, pconn)
get_conf_update = insights_upload_conf.return_value.get_conf_update
get_conf_update.assert_called_once_with()... | [
"def",
"test_return_get_conf_update",
"(",
"insights_upload_conf",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"result",
"=",
"update_rules",
"(",
"config",
",",
"pconn",
")",
"get_conf_update",
"=",
"insights_upload_conf",
".",
"return_val... | [
110,
0
] | [
119,
49
] | python | en | ['en', 'error', 'th'] | False |
test_get_collection_rules_calls | (get_collection_rules, try_disk) |
Collection rules are retrieved from online source, skipping loading from file.
|
Collection rules are retrieved from online source, skipping loading from file.
| def test_get_collection_rules_calls(get_collection_rules, try_disk):
"""
Collection rules are retrieved from online source, skipping loading from file.
"""
config, pconn = update_rules_args()
update_rules(config, pconn)
get_collection_rules.assert_called_once_with()
try_disk.assert_not_call... | [
"def",
"test_get_collection_rules_calls",
"(",
"get_collection_rules",
",",
"try_disk",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"update_rules",
"(",
"config",
",",
"pconn",
")",
"get_collection_rules",
".",
"assert_called_once_with",
"(",... | [
125,
0
] | [
133,
32
] | python | en | ['en', 'error', 'th'] | False |
test_get_collection_rules_no_version_error | (get_collection_rules) |
An error is raised if collection rules retrieved from online source don’t contain a version.
|
An error is raised if collection rules retrieved from online source don’t contain a version.
| def test_get_collection_rules_no_version_error(get_collection_rules):
"""
An error is raised if collection rules retrieved from online source don’t contain a version.
"""
config, pconn = update_rules_args()
with raises(ValueError):
update_rules(config, pconn) | [
"def",
"test_get_collection_rules_no_version_error",
"(",
"get_collection_rules",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"with",
"raises",
"(",
"ValueError",
")",
":",
"update_rules",
"(",
"config",
",",
"pconn",
")"
] | [
138,
0
] | [
144,
35
] | python | en | ['en', 'error', 'th'] | False |
test_get_collection_rules_result | (get_collection_rules) |
Collection rules file name is added to the retrieved result.
|
Collection rules file name is added to the retrieved result.
| def test_get_collection_rules_result(get_collection_rules):
"""
Collection rules file name is added to the retrieved result.
"""
config, pconn = update_rules_args()
raw_result = update_rules(config, pconn)
coerced_result = coerce_result(raw_result)
expected = get_collection_rules.return_val... | [
"def",
"test_get_collection_rules_result",
"(",
"get_collection_rules",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"raw_result",
"=",
"update_rules",
"(",
"config",
",",
"pconn",
")",
"coerced_result",
"=",
"coerce_result",
"(",
"raw_resul... | [
150,
0
] | [
160,
40
] | python | en | ['en', 'error', 'th'] | False |
test_try_disk_calls | (get_collection_rules, try_disk) |
Collection rules are not retrieved from online source, loading from file.
|
Collection rules are not retrieved from online source, loading from file.
| def test_try_disk_calls(get_collection_rules, try_disk):
"""
Collection rules are not retrieved from online source, loading from file.
"""
config, pconn = update_rules_args()
update_rules(config, pconn)
get_collection_rules.assert_called_once_with()
try_disk.assert_called() | [
"def",
"test_try_disk_calls",
"(",
"get_collection_rules",
",",
"try_disk",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"update_rules",
"(",
"config",
",",
"pconn",
")",
"get_collection_rules",
".",
"assert_called_once_with",
"(",
")",
"t... | [
166,
0
] | [
174,
28
] | python | en | ['en', 'error', 'th'] | False |
test_try_disk_no_version_error | (get_collection_rules, try_disk) |
An error is raised if collection rules retrieved from file don’t contain a version.
|
An error is raised if collection rules retrieved from file don’t contain a version.
| def test_try_disk_no_version_error(get_collection_rules, try_disk):
"""
An error is raised if collection rules retrieved from file don’t contain a version.
"""
config, pconn = update_rules_args()
with raises(ValueError):
update_rules(config, pconn) | [
"def",
"test_try_disk_no_version_error",
"(",
"get_collection_rules",
",",
"try_disk",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"with",
"raises",
"(",
"ValueError",
")",
":",
"update_rules",
"(",
"config",
",",
"pconn",
")"
] | [
180,
0
] | [
186,
35
] | python | en | ['en', 'error', 'th'] | False |
test_try_disk_result | (get_collection_rules, try_disk) |
Local file name is added to the stored result.
|
Local file name is added to the stored result.
| def test_try_disk_result(get_collection_rules, try_disk):
"""
Local file name is added to the stored result.
"""
config, pconn = update_rules_args()
raw_result = update_rules(config, pconn)
coerced_result = coerce_result(raw_result)
name, args, kwargs = try_disk.mock_calls[0]
expected =... | [
"def",
"test_try_disk_result",
"(",
"get_collection_rules",
",",
"try_disk",
")",
":",
"config",
",",
"pconn",
"=",
"update_rules_args",
"(",
")",
"raw_result",
"=",
"update_rules",
"(",
"config",
",",
"pconn",
")",
"coerced_result",
"=",
"coerce_result",
"(",
"... | [
192,
0
] | [
203,
40
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the habitica sensors. | Set up the habitica sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the habitica sensors."""
entities = []
name = config_entry.data[CONF_NAME]
sensor_data = HabitipyData(hass.data[DOMAIN][config_entry.entry_id])
await sensor_data.update()
for sensor_type in SENSORS_TYPES:
ent... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"name",
"=",
"config_entry",
".",
"data",
"[",
"CONF_NAME",
"]",
"sensor_data",
"=",
"HabitipyData",
"(",
"hass",
".",
"dat... | [
67,
0
] | [
78,
38
] | python | en | ['en', 'ca', 'en'] | True |
HabitipyData.__init__ | (self, api) | Habitica API user data cache. | Habitica API user data cache. | def __init__(self, api):
"""Habitica API user data cache."""
self.api = api
self.data = None
self.tasks = {} | [
"def",
"__init__",
"(",
"self",
",",
"api",
")",
":",
"self",
".",
"api",
"=",
"api",
"self",
".",
"data",
"=",
"None",
"self",
".",
"tasks",
"=",
"{",
"}"
] | [
84,
4
] | [
88,
23
] | python | it | ['ca', 'it', 'it'] | True |
HabitipyData.update | (self) | Get a new fix from Habitica servers. | Get a new fix from Habitica servers. | async def update(self):
"""Get a new fix from Habitica servers."""
try:
self.data = await self.api.user.get()
except ClientResponseError as error:
if error.status == HTTP_TOO_MANY_REQUESTS:
_LOGGER.warning(
"Sensor data update for %s ha... | [
"async",
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"data",
"=",
"await",
"self",
".",
"api",
".",
"user",
".",
"get",
"(",
")",
"except",
"ClientResponseError",
"as",
"error",
":",
"if",
"error",
".",
"status",
"==",
"HTTP_TOO_... | [
91,
4
] | [
124,
21
] | python | en | ['en', 'en', 'en'] | True |
HabitipySensor.__init__ | (self, name, sensor_name, updater) | Initialize a generic Habitica sensor. | Initialize a generic Habitica sensor. | def __init__(self, name, sensor_name, updater):
"""Initialize a generic Habitica sensor."""
self._name = name
self._sensor_name = sensor_name
self._sensor_type = SENSORS_TYPES[sensor_name]
self._state = None
self._updater = updater | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"sensor_name",
",",
"updater",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_sensor_name",
"=",
"sensor_name",
"self",
".",
"_sensor_type",
"=",
"SENSORS_TYPES",
"[",
"sensor_name",
"]",
"self... | [
130,
4
] | [
136,
31
] | python | it | ['it', 'ro', 'it'] | True |
HabitipySensor.async_update | (self) | Update Condition and Forecast. | Update Condition and Forecast. | async def async_update(self):
"""Update Condition and Forecast."""
await self._updater.update()
data = self._updater.data
for element in self._sensor_type.path:
data = data[element]
self._state = data | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_updater",
".",
"update",
"(",
")",
"data",
"=",
"self",
".",
"_updater",
".",
"data",
"for",
"element",
"in",
"self",
".",
"_sensor_type",
".",
"path",
":",
"data",
"=",
"... | [
138,
4
] | [
144,
26
] | python | en | ['en', 'en', 'en'] | True |
HabitipySensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return self._sensor_type.icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor_type",
".",
"icon"
] | [
147,
4
] | [
149,
37
] | python | en | ['en', 'en', 'en'] | True |
HabitipySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{DOMAIN}_{self._name}_{self._sensor_name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{DOMAIN}_{self._name}_{self._sensor_name}\""
] | [
152,
4
] | [
154,
59
] | python | en | ['en', 'mi', 'en'] | True |
HabitipySensor.native_value | (self) | Return the state of the device. | Return the state of the device. | def native_value(self):
"""Return the state of the device."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
157,
4
] | [
159,
26
] | python | en | ['en', 'en', 'en'] | True |
HabitipySensor.native_unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._sensor_type.unit | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor_type",
".",
"unit"
] | [
162,
4
] | [
164,
37
] | python | en | ['en', 'en', 'en'] | True |
HabitipyTaskSensor.__init__ | (self, name, task_name, updater) | Initialize a generic Habitica task. | Initialize a generic Habitica task. | def __init__(self, name, task_name, updater):
"""Initialize a generic Habitica task."""
self._name = name
self._task_name = task_name
self._task_type = TASKS_TYPES[task_name]
self._state = None
self._updater = updater | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"task_name",
",",
"updater",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_task_name",
"=",
"task_name",
"self",
".",
"_task_type",
"=",
"TASKS_TYPES",
"[",
"task_name",
"]",
"self",
".",
... | [
170,
4
] | [
176,
31
] | python | it | ['it', 'co', 'it'] | True |
HabitipyTaskSensor.async_update | (self) | Update Condition and Forecast. | Update Condition and Forecast. | async def async_update(self):
"""Update Condition and Forecast."""
await self._updater.update()
all_tasks = self._updater.tasks
for element in self._task_type.path:
tasks_length = len(all_tasks[element])
self._state = tasks_length | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_updater",
".",
"update",
"(",
")",
"all_tasks",
"=",
"self",
".",
"_updater",
".",
"tasks",
"for",
"element",
"in",
"self",
".",
"_task_type",
".",
"path",
":",
"tasks_length"... | [
178,
4
] | [
184,
34
] | python | en | ['en', 'en', 'en'] | True |
HabitipyTaskSensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return self._task_type.icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_task_type",
".",
"icon"
] | [
187,
4
] | [
189,
35
] | python | en | ['en', 'en', 'en'] | True |
HabitipyTaskSensor.name | (self) | Return the name of the task. | Return the name of the task. | def name(self):
"""Return the name of the task."""
return f"{DOMAIN}_{self._name}_{self._task_name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{DOMAIN}_{self._name}_{self._task_name}\""
] | [
192,
4
] | [
194,
57
] | python | en | ['en', 'en', 'en'] | True |
HabitipyTaskSensor.native_value | (self) | Return the state of the device. | Return the state of the device. | def native_value(self):
"""Return the state of the device."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
197,
4
] | [
199,
26
] | python | en | ['en', 'en', 'en'] | True |
HabitipyTaskSensor.extra_state_attributes | (self) | Return the state attributes of all user tasks. | Return the state attributes of all user tasks. | def extra_state_attributes(self):
"""Return the state attributes of all user tasks."""
if self._updater.tasks is not None:
all_received_tasks = self._updater.tasks
for element in self._task_type.path:
received_tasks = all_received_tasks[element]
attrs ... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_updater",
".",
"tasks",
"is",
"not",
"None",
":",
"all_received_tasks",
"=",
"self",
".",
"_updater",
".",
"tasks",
"for",
"element",
"in",
"self",
".",
"_task_type",
".",
"path",... | [
202,
4
] | [
219,
24
] | python | en | ['en', 'en', 'en'] | True |
HabitipyTaskSensor.native_unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._task_type.unit | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_task_type",
".",
"unit"
] | [
222,
4
] | [
224,
35
] | python | en | ['en', 'en', 'en'] | True |
TestSpecialModelName.make_instance | (self, include_optional) | Test SpecialModelName
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test SpecialModelName
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | def make_instance(self, include_optional):
"""Test SpecialModelName
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.special_model_name.SpecialModelNam... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"# model = petstore_api.models.special_model_name.SpecialModelName() # noqa: E501",
"if",
"include_optional",
":",
"return",
"SpecialModelName",
"(",
"special_property_name",
"=",
"56",
")",
"else",
":",... | [
30,
4
] | [
42,
9
] | python | en | ['en', 'en', 'en'] | False |
TestSpecialModelName.testSpecialModelName | (self) | Test SpecialModelName | Test SpecialModelName | def testSpecialModelName(self):
"""Test SpecialModelName"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True) | [
"def",
"testSpecialModelName",
"(",
"self",
")",
":",
"inst_req_only",
"=",
"self",
".",
"make_instance",
"(",
"include_optional",
"=",
"False",
")",
"inst_req_and_optional",
"=",
"self",
".",
"make_instance",
"(",
"include_optional",
"=",
"True",
")"
] | [
44,
4
] | [
47,
73
] | python | en | ['en', 'en', 'en'] | False |
async_setup_platform | (
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) | Set up number entities for KNX platform. | Set up number entities for KNX platform. | async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up number entities for KNX platform."""
if not discovery_info or not discovery_info["platform_config"]:
ret... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
"discovery_info",
":",
"DiscoveryInfoType",
"|",
"None",
"=",
"None",
",",
")",
"->",
"None",
... | [
20,
0
] | [
34,
5
] | python | en | ['en', 'da', 'en'] | True |
_create_numeric_value | (xknx: XKNX, config: ConfigType) | Return a KNX NumericValue to be used within XKNX. | Return a KNX NumericValue to be used within XKNX. | def _create_numeric_value(xknx: XKNX, config: ConfigType) -> NumericValue:
"""Return a KNX NumericValue to be used within XKNX."""
return NumericValue(
xknx,
name=config[CONF_NAME],
group_address=config[KNX_ADDRESS],
group_address_state=config.get(CONF_STATE_ADDRESS),
res... | [
"def",
"_create_numeric_value",
"(",
"xknx",
":",
"XKNX",
",",
"config",
":",
"ConfigType",
")",
"->",
"NumericValue",
":",
"return",
"NumericValue",
"(",
"xknx",
",",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
",",
"group_address",
"=",
"config",
"[",
... | [
37,
0
] | [
46,
5
] | python | en | ['en', 'en', 'en'] | True |
KNXNumber.__init__ | (self, xknx: XKNX, config: ConfigType) | Initialize a KNX number. | Initialize a KNX number. | def __init__(self, xknx: XKNX, config: ConfigType) -> None:
"""Initialize a KNX number."""
super().__init__(_create_numeric_value(xknx, config))
self._attr_max_value = config.get(
NumberSchema.CONF_MAX,
self._device.sensor_value.dpt_class.value_max,
)
self... | [
"def",
"__init__",
"(",
"self",
",",
"xknx",
":",
"XKNX",
",",
"config",
":",
"ConfigType",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"_create_numeric_value",
"(",
"xknx",
",",
"config",
")",
")",
"self",
".",
"_attr_max_value",
... | [
54,
4
] | [
70,
70
] | python | en | ['en', 'en', 'en'] | True |
KNXNumber.async_added_to_hass | (self) | Restore last state. | Restore last state. | async def async_added_to_hass(self) -> None:
"""Restore last state."""
await super().async_added_to_hass()
if not self._device.sensor_value.readable and (
last_state := await self.async_get_last_state()
):
if last_state.state not in (STATE_UNKNOWN, STATE_UNAVAILAB... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"if",
"not",
"self",
".",
"_device",
".",
"sensor_value",
".",
"readable",
"and",
"(",
"last_state",
":=",
"await"... | [
72,
4
] | [
79,
73
] | python | it | ['it', 'it', 'en'] | True |
KNXNumber.value | (self) | Return the entity value to represent the entity state. | Return the entity value to represent the entity state. | def value(self) -> float:
"""Return the entity value to represent the entity state."""
# self._device.sensor_value.value is set in __init__ so it is never None
return cast(float, self._device.resolve_state()) | [
"def",
"value",
"(",
"self",
")",
"->",
"float",
":",
"# self._device.sensor_value.value is set in __init__ so it is never None",
"return",
"cast",
"(",
"float",
",",
"self",
".",
"_device",
".",
"resolve_state",
"(",
")",
")"
] | [
82,
4
] | [
85,
56
] | python | en | ['en', 'en', 'en'] | True |
KNXNumber.async_set_value | (self, value: float) | Set new value. | Set new value. | async def async_set_value(self, value: float) -> None:
"""Set new value."""
if value < self.min_value or value > self.max_value:
raise ValueError(
f"Invalid value for {self.entity_id}: {value} "
f"(range {self.min_value} - {self.max_value})"
)
... | [
"async",
"def",
"async_set_value",
"(",
"self",
",",
"value",
":",
"float",
")",
"->",
"None",
":",
"if",
"value",
"<",
"self",
".",
"min_value",
"or",
"value",
">",
"self",
".",
"max_value",
":",
"raise",
"ValueError",
"(",
"f\"Invalid value for {self.entit... | [
87,
4
] | [
94,
37
] | python | en | ['en', 'yi', 'en'] | True |
Plenticore.__init__ | (self, hass, config_entry) | Create a new plenticore manager instance. | Create a new plenticore manager instance. | def __init__(self, hass, config_entry):
"""Create a new plenticore manager instance."""
self.hass = hass
self.config_entry = config_entry
self._client = None
self._shutdown_remove_listener = None
self.device_info = {} | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"_client",
"=",
"None",
"self",
".",
"_shutdown_remove_listener",
"=",
"None",
"sel... | [
26,
4
] | [
34,
29
] | python | en | ['en', 'en', 'en'] | True |
Plenticore.host | (self) | Return the host of the Plenticore inverter. | Return the host of the Plenticore inverter. | def host(self) -> str:
"""Return the host of the Plenticore inverter."""
return self.config_entry.data[CONF_HOST] | [
"def",
"host",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]"
] | [
37,
4
] | [
39,
48
] | python | en | ['en', 'no', 'en'] | True |
Plenticore.client | (self) | Return the Plenticore API client. | Return the Plenticore API client. | def client(self) -> PlenticoreApiClient:
"""Return the Plenticore API client."""
return self._client | [
"def",
"client",
"(",
"self",
")",
"->",
"PlenticoreApiClient",
":",
"return",
"self",
".",
"_client"
] | [
42,
4
] | [
44,
27
] | python | en | ['en', 'la', 'en'] | True |
Plenticore.async_setup | (self) | Set up Plenticore API client. | Set up Plenticore API client. | async def async_setup(self) -> bool:
"""Set up Plenticore API client."""
self._client = PlenticoreApiClient(
async_get_clientsession(self.hass), host=self.host
)
try:
await self._client.login(self.config_entry.data[CONF_PASSWORD])
except PlenticoreAuthenti... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
"->",
"bool",
":",
"self",
".",
"_client",
"=",
"PlenticoreApiClient",
"(",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
",",
"host",
"=",
"self",
".",
"host",
")",
"try",
":",
"await",
"self"... | [
46,
4
] | [
95,
19
] | python | en | ['en', 'fr', 'en'] | True |
Plenticore._async_shutdown | (self, event) | Call from Homeassistant shutdown event. | Call from Homeassistant shutdown event. | async def _async_shutdown(self, event):
"""Call from Homeassistant shutdown event."""
# unset remove listener otherwise calling it would raise an exception
self._shutdown_remove_listener = None
await self.async_unload() | [
"async",
"def",
"_async_shutdown",
"(",
"self",
",",
"event",
")",
":",
"# unset remove listener otherwise calling it would raise an exception",
"self",
".",
"_shutdown_remove_listener",
"=",
"None",
"await",
"self",
".",
"async_unload",
"(",
")"
] | [
97,
4
] | [
101,
33
] | python | en | ['en', 'en', 'en'] | True |
Plenticore.async_unload | (self) | Unload the Plenticore API client. | Unload the Plenticore API client. | async def async_unload(self) -> None:
"""Unload the Plenticore API client."""
if self._shutdown_remove_listener:
self._shutdown_remove_listener()
await self._client.logout()
self._client = None
_LOGGER.debug("Logged out from %s", self.host) | [
"async",
"def",
"async_unload",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_shutdown_remove_listener",
":",
"self",
".",
"_shutdown_remove_listener",
"(",
")",
"await",
"self",
".",
"_client",
".",
"logout",
"(",
")",
"self",
".",
"_client",
... | [
103,
4
] | [
110,
54
] | python | en | ['en', 'la', 'en'] | True |
PlenticoreUpdateCoordinator.__init__ | (
self,
hass: HomeAssistant,
logger: logging.Logger,
name: str,
update_inverval: timedelta,
plenticore: Plenticore,
) | Create a new update coordinator for plenticore data. | Create a new update coordinator for plenticore data. | def __init__(
self,
hass: HomeAssistant,
logger: logging.Logger,
name: str,
update_inverval: timedelta,
plenticore: Plenticore,
) -> None:
"""Create a new update coordinator for plenticore data."""
super().__init__(
hass=hass,
l... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"logger",
":",
"logging",
".",
"Logger",
",",
"name",
":",
"str",
",",
"update_inverval",
":",
"timedelta",
",",
"plenticore",
":",
"Plenticore",
",",
")",
"->",
"None",
":",
"super"... | [
116,
4
] | [
133,
37
] | python | it | ['it', 'it', 'en'] | True |
PlenticoreUpdateCoordinator.start_fetch_data | (self, module_id: str, data_id: str) | Start fetching the given data (module-id and data-id). | Start fetching the given data (module-id and data-id). | def start_fetch_data(self, module_id: str, data_id: str) -> None:
"""Start fetching the given data (module-id and data-id)."""
self._fetch[module_id].append(data_id)
# Force an update of all data. Multiple refresh calls
# are ignored by the debouncer.
async def force_refresh(eve... | [
"def",
"start_fetch_data",
"(",
"self",
",",
"module_id",
":",
"str",
",",
"data_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_fetch",
"[",
"module_id",
"]",
".",
"append",
"(",
"data_id",
")",
"# Force an update of all data. Multiple refresh calls",
... | [
135,
4
] | [
144,
53
] | python | en | ['en', 'en', 'en'] | True |
PlenticoreUpdateCoordinator.stop_fetch_data | (self, module_id: str, data_id: str) | Stop fetching the given data (module-id and data-id). | Stop fetching the given data (module-id and data-id). | def stop_fetch_data(self, module_id: str, data_id: str) -> None:
"""Stop fetching the given data (module-id and data-id)."""
self._fetch[module_id].remove(data_id) | [
"def",
"stop_fetch_data",
"(",
"self",
",",
"module_id",
":",
"str",
",",
"data_id",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_fetch",
"[",
"module_id",
"]",
".",
"remove",
"(",
"data_id",
")"
] | [
146,
4
] | [
148,
46
] | python | en | ['en', 'en', 'en'] | True |
PlenticoreDataFormatter.get_method | (cls, name: str) | Return a callable formatter of the given name. | Return a callable formatter of the given name. | def get_method(cls, name: str) -> callable:
"""Return a callable formatter of the given name."""
return getattr(cls, name) | [
"def",
"get_method",
"(",
"cls",
",",
"name",
":",
"str",
")",
"->",
"callable",
":",
"return",
"getattr",
"(",
"cls",
",",
"name",
")"
] | [
221,
4
] | [
223,
33
] | python | en | ['en', 'en', 'en'] | True |
PlenticoreDataFormatter.format_round | (state: str) | Return the given state value as rounded integer. | Return the given state value as rounded integer. | def format_round(state: str) -> int | str:
"""Return the given state value as rounded integer."""
try:
return round(float(state))
except (TypeError, ValueError):
return state | [
"def",
"format_round",
"(",
"state",
":",
"str",
")",
"->",
"int",
"|",
"str",
":",
"try",
":",
"return",
"round",
"(",
"float",
"(",
"state",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"state"
] | [
226,
4
] | [
231,
24
] | python | en | ['en', 'en', 'en'] | True |
PlenticoreDataFormatter.format_energy | (state: str) | Return the given state value as energy value, scaled to kWh. | Return the given state value as energy value, scaled to kWh. | def format_energy(state: str) -> float | str:
"""Return the given state value as energy value, scaled to kWh."""
try:
return round(float(state) / 1000, 1)
except (TypeError, ValueError):
return state | [
"def",
"format_energy",
"(",
"state",
":",
"str",
")",
"->",
"float",
"|",
"str",
":",
"try",
":",
"return",
"round",
"(",
"float",
"(",
"state",
")",
"/",
"1000",
",",
"1",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"s... | [
234,
4
] | [
239,
24
] | 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.