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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
next_departuredate | (departure) | Calculate the next departuredate from an array input of short days. | Calculate the next departuredate from an array input of short days. | def next_departuredate(departure):
"""Calculate the next departuredate from an array input of short days."""
today_date = date.today()
today_weekday = date.weekday(today_date)
if WEEKDAYS[today_weekday] in departure:
return today_date
for day in departure:
next_departure = WEEKDAYS.i... | [
"def",
"next_departuredate",
"(",
"departure",
")",
":",
"today_date",
"=",
"date",
".",
"today",
"(",
")",
"today_weekday",
"=",
"date",
".",
"weekday",
"(",
"today_date",
")",
"if",
"WEEKDAYS",
"[",
"today_weekday",
"]",
"in",
"departure",
":",
"return",
... | [
104,
0
] | [
114,
65
] | python | en | ['en', 'lb', 'en'] | True |
TrainSensor.__init__ | (self, train_api, name, from_station, to_station, weekday, time) | Initialize the sensor. | Initialize the sensor. | def __init__(self, train_api, name, from_station, to_station, weekday, time):
"""Initialize the sensor."""
self._train_api = train_api
self._name = name
self._from_station = from_station
self._to_station = to_station
self._weekday = weekday
self._time = time
... | [
"def",
"__init__",
"(",
"self",
",",
"train_api",
",",
"name",
",",
"from_station",
",",
"to_station",
",",
"weekday",
",",
"time",
")",
":",
"self",
".",
"_train_api",
"=",
"train_api",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_from_station",
"=... | [
122,
4
] | [
132,
37
] | python | en | ['en', 'en', 'en'] | True |
TrainSensor.async_update | (self) | Retrieve latest state. | Retrieve latest state. | async def async_update(self):
"""Retrieve latest state."""
if self._time is not None:
departure_day = next_departuredate(self._weekday)
when = datetime.combine(departure_day, self._time)
try:
self._state = await self._train_api.async_get_train_stop(
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_time",
"is",
"not",
"None",
":",
"departure_day",
"=",
"next_departuredate",
"(",
"self",
".",
"_weekday",
")",
"when",
"=",
"datetime",
".",
"combine",
"(",
"departure_day",
",",
... | [
134,
4
] | [
153,
61
] | python | en | ['es', 'sk', 'en'] | False |
TrainSensor.extra_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def extra_state_attributes(self):
"""Return the state attributes."""
if self._state is None:
return None
state = self._state
other_information = None
if state.other_information is not None:
other_information = ", ".join(state.other_information)
dev... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"return",
"None",
"state",
"=",
"self",
".",
"_state",
"other_information",
"=",
"None",
"if",
"state",
".",
"other_information",
"is",
"not",
"None",
"... | [
156,
4
] | [
178,
9
] | python | en | ['en', 'en', 'en'] | True |
TrainSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
181,
4
] | [
183,
25
] | python | en | ['en', 'mi', 'en'] | True |
TrainSensor.icon | (self) | Return the icon for the frontend. | Return the icon for the frontend. | def icon(self):
"""Return the icon for the frontend."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
186,
4
] | [
188,
19
] | python | en | ['en', 'en', 'en'] | True |
TrainSensor.native_value | (self) | Return the departure state. | Return the departure state. | def native_value(self):
"""Return the departure state."""
state = self._state
if state is not None:
if state.time_at_location is not None:
return state.time_at_location
if state.estimated_time_at_location is not None:
return state.estimated... | [
"def",
"native_value",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"_state",
"if",
"state",
"is",
"not",
"None",
":",
"if",
"state",
".",
"time_at_location",
"is",
"not",
"None",
":",
"return",
"state",
".",
"time_at_location",
"if",
"state",
".",
... | [
191,
4
] | [
200,
19
] | python | en | ['en', 'en', 'en'] | True |
test_abort_already_setup | (hass) | Test if we abort because component is already setup. | Test if we abort because component is already setup. | async def test_abort_already_setup(hass):
"""Test if we abort because component is already setup."""
flow = config_flow.VeSyncFlowHandler()
flow.hass = hass
MockConfigEntry(domain=DOMAIN, title="user", data={"user": "pass"}).add_to_hass(
hass
)
result = await flow.async_step_user()
... | [
"async",
"def",
"test_abort_already_setup",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"VeSyncFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"user\"",
",",
"data",
... | [
10,
0
] | [
20,
56
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_login_error | (hass) | Test if we return error for invalid username and password. | Test if we return error for invalid username and password. | async def test_invalid_login_error(hass):
"""Test if we return error for invalid username and password."""
test_dict = {CONF_USERNAME: "user", CONF_PASSWORD: "pass"}
flow = config_flow.VeSyncFlowHandler()
flow.hass = hass
with patch("pyvesync.vesync.VeSync.login", return_value=False):
result... | [
"async",
"def",
"test_invalid_login_error",
"(",
"hass",
")",
":",
"test_dict",
"=",
"{",
"CONF_USERNAME",
":",
"\"user\"",
",",
"CONF_PASSWORD",
":",
"\"pass\"",
"}",
"flow",
"=",
"config_flow",
".",
"VeSyncFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
... | [
23,
0
] | [
32,
55
] | python | en | ['en', 'en', 'en'] | True |
test_config_flow_user_input | (hass) | Test config flow with user input. | Test config flow with user input. | async def test_config_flow_user_input(hass):
"""Test config flow with user input."""
flow = config_flow.VeSyncFlowHandler()
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
with patch("pyvesync.vesync.VeSync.login", return_value=Tru... | [
"async",
"def",
"test_config_flow_user_input",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"VeSyncFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",... | [
35,
0
] | [
47,
54
] | python | en | ['en', 'en', 'en'] | True |
explore_module | (package) | Explore the modules. | Explore the modules. | def explore_module(package):
"""Explore the modules."""
module = importlib.import_module(package)
if not hasattr(module, "__path__"):
return []
for _, name, _ in pkgutil.iter_modules(module.__path__, f"{package}."):
yield name | [
"def",
"explore_module",
"(",
"package",
")",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"package",
")",
"if",
"not",
"hasattr",
"(",
"module",
",",
"\"__path__\"",
")",
":",
"return",
"[",
"]",
"for",
"_",
",",
"name",
",",
"_",
"in",... | [
10,
0
] | [
16,
18
] | python | en | ['en', 'la', 'en'] | True |
main | () | Run the script. | Run the script. | def main():
"""Run the script."""
if not os.path.isfile("requirements_all.txt"):
print("Run this from HA root dir")
return
msg = {}
def add_msg(key, item):
"""Add a message."""
if key not in msg:
msg[key] = []
msg[key].append(item)
for package i... | [
"def",
"main",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"\"requirements_all.txt\"",
")",
":",
"print",
"(",
"\"Run this from HA root dir\"",
")",
"return",
"msg",
"=",
"{",
"}",
"def",
"add_msg",
"(",
"key",
",",
"item",
")",
... | [
19,
0
] | [
58,
64
] | python | en | ['en', 'co', 'en'] | True |
async_register | (
hass: HomeAssistant, register: system_health.SystemHealthRegistration
) | Register system health callbacks. | Register system health callbacks. | def async_register(
hass: HomeAssistant, register: system_health.SystemHealthRegistration
) -> None:
"""Register system health callbacks."""
register.async_register_info(system_health_info) | [
"def",
"async_register",
"(",
"hass",
":",
"HomeAssistant",
",",
"register",
":",
"system_health",
".",
"SystemHealthRegistration",
")",
"->",
"None",
":",
"register",
".",
"async_register_info",
"(",
"system_health_info",
")"
] | [
8,
0
] | [
12,
52
] | python | en | ['en', 'sv', 'en'] | True |
system_health_info | (hass) | Get info for the info page. | Get info for the info page. | async def system_health_info(hass):
"""Get info for the info page."""
return {
"api_endpoint_reachable": system_health.async_check_can_reach_url(
hass, IPMA_API_URL
)
} | [
"async",
"def",
"system_health_info",
"(",
"hass",
")",
":",
"return",
"{",
"\"api_endpoint_reachable\"",
":",
"system_health",
".",
"async_check_can_reach_url",
"(",
"hass",
",",
"IPMA_API_URL",
")",
"}"
] | [
15,
0
] | [
21,
5
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_no_config | (hass) | Test DOMAIN is empty if there is no config. | Test DOMAIN is empty if there is no config. | async def test_setup_with_no_config(hass):
"""Test DOMAIN is empty if there is no config."""
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
assert DOMAIN not in hass.config_entries.async_domains() | [
"async",
"def",
"test_setup_with_no_config",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"DOMAIN",
"not",
"in",
"hass",
... | [
30,
0
] | [
34,
60
] | python | en | ['en', 'en', 'en'] | True |
test_setup_ev | (hass, ev_entry) | Test setup with an EV vehicle. | Test setup with an EV vehicle. | async def test_setup_ev(hass, ev_entry):
"""Test setup with an EV vehicle."""
check_entry = hass.config_entries.async_get_entry(ev_entry.entry_id)
assert check_entry
assert check_entry.state is ConfigEntryState.LOADED | [
"async",
"def",
"test_setup_ev",
"(",
"hass",
",",
"ev_entry",
")",
":",
"check_entry",
"=",
"hass",
".",
"config_entries",
".",
"async_get_entry",
"(",
"ev_entry",
".",
"entry_id",
")",
"assert",
"check_entry",
"assert",
"check_entry",
".",
"state",
"is",
"Co... | [
37,
0
] | [
41,
55
] | python | en | ['en', 'haw', 'en'] | True |
test_setup_g2 | (hass) | Test setup with a G2 vehcile . | Test setup with a G2 vehcile . | async def test_setup_g2(hass):
"""Test setup with a G2 vehcile ."""
entry = await setup_subaru_integration(
hass,
vehicle_list=[TEST_VIN_3_G2],
vehicle_data=VEHICLE_DATA[TEST_VIN_3_G2],
vehicle_status=VEHICLE_STATUS_G2,
)
check_entry = hass.config_entries.async_get_entry(... | [
"async",
"def",
"test_setup_g2",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"setup_subaru_integration",
"(",
"hass",
",",
"vehicle_list",
"=",
"[",
"TEST_VIN_3_G2",
"]",
",",
"vehicle_data",
"=",
"VEHICLE_DATA",
"[",
"TEST_VIN_3_G2",
"]",
",",
"vehicle_status... | [
44,
0
] | [
54,
55
] | python | en | ['en', 'en', 'en'] | True |
test_setup_g1 | (hass) | Test setup with a G1 vehicle. | Test setup with a G1 vehicle. | async def test_setup_g1(hass):
"""Test setup with a G1 vehicle."""
entry = await setup_subaru_integration(
hass, vehicle_list=[TEST_VIN_1_G1], vehicle_data=VEHICLE_DATA[TEST_VIN_1_G1]
)
check_entry = hass.config_entries.async_get_entry(entry.entry_id)
assert check_entry
assert check_entr... | [
"async",
"def",
"test_setup_g1",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"setup_subaru_integration",
"(",
"hass",
",",
"vehicle_list",
"=",
"[",
"TEST_VIN_1_G1",
"]",
",",
"vehicle_data",
"=",
"VEHICLE_DATA",
"[",
"TEST_VIN_1_G1",
"]",
")",
"check_entry",
... | [
57,
0
] | [
64,
55
] | python | en | ['en', 'haw', 'en'] | True |
test_unsuccessful_connect | (hass) | Test unsuccessful connect due to connectivity. | Test unsuccessful connect due to connectivity. | async def test_unsuccessful_connect(hass):
"""Test unsuccessful connect due to connectivity."""
entry = await setup_subaru_integration(
hass,
connect_effect=SubaruException("Service Unavailable"),
vehicle_list=[TEST_VIN_2_EV],
vehicle_data=VEHICLE_DATA[TEST_VIN_2_EV],
veh... | [
"async",
"def",
"test_unsuccessful_connect",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"setup_subaru_integration",
"(",
"hass",
",",
"connect_effect",
"=",
"SubaruException",
"(",
"\"Service Unavailable\"",
")",
",",
"vehicle_list",
"=",
"[",
"TEST_VIN_2_EV",
"]... | [
67,
0
] | [
78,
60
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_credentials | (hass) | Test invalid credentials. | Test invalid credentials. | async def test_invalid_credentials(hass):
"""Test invalid credentials."""
entry = await setup_subaru_integration(
hass,
connect_effect=InvalidCredentials("Invalid Credentials"),
vehicle_list=[TEST_VIN_2_EV],
vehicle_data=VEHICLE_DATA[TEST_VIN_2_EV],
vehicle_status=VEHICLE... | [
"async",
"def",
"test_invalid_credentials",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"setup_subaru_integration",
"(",
"hass",
",",
"connect_effect",
"=",
"InvalidCredentials",
"(",
"\"Invalid Credentials\"",
")",
",",
"vehicle_list",
"=",
"[",
"TEST_VIN_2_EV",
... | [
81,
0
] | [
92,
60
] | python | en | ['en', 'la', 'en'] | True |
test_update_skip_unsubscribed | (hass) | Test update function skips vehicles without subscription. | Test update function skips vehicles without subscription. | async def test_update_skip_unsubscribed(hass):
"""Test update function skips vehicles without subscription."""
await setup_subaru_integration(
hass, vehicle_list=[TEST_VIN_1_G1], vehicle_data=VEHICLE_DATA[TEST_VIN_1_G1]
)
with patch(MOCK_API_FETCH) as mock_fetch:
await hass.services.asy... | [
"async",
"def",
"test_update_skip_unsubscribed",
"(",
"hass",
")",
":",
"await",
"setup_subaru_integration",
"(",
"hass",
",",
"vehicle_list",
"=",
"[",
"TEST_VIN_1_G1",
"]",
",",
"vehicle_data",
"=",
"VEHICLE_DATA",
"[",
"TEST_VIN_1_G1",
"]",
")",
"with",
"patch"... | [
95,
0
] | [
110,
38
] | python | en | ['en', 'en', 'en'] | True |
test_update_disabled | (hass, ev_entry) | Test update function disable option. | Test update function disable option. | async def test_update_disabled(hass, ev_entry):
"""Test update function disable option."""
with patch(MOCK_API_FETCH, side_effect=SubaruException("403 Error"),), patch(
MOCK_API_UPDATE,
) as mock_update:
await hass.services.async_call(
HA_DOMAIN,
SERVICE_UPDATE_ENTITY... | [
"async",
"def",
"test_update_disabled",
"(",
"hass",
",",
"ev_entry",
")",
":",
"with",
"patch",
"(",
"MOCK_API_FETCH",
",",
"side_effect",
"=",
"SubaruException",
"(",
"\"403 Error\"",
")",
",",
")",
",",
"patch",
"(",
"MOCK_API_UPDATE",
",",
")",
"as",
"mo... | [
113,
0
] | [
125,
39
] | python | en | ['de', 'en', 'en'] | True |
test_fetch_failed | (hass) | Tests when fetch fails. | Tests when fetch fails. | async def test_fetch_failed(hass):
"""Tests when fetch fails."""
await setup_subaru_integration(
hass,
vehicle_list=[TEST_VIN_2_EV],
vehicle_data=VEHICLE_DATA[TEST_VIN_2_EV],
vehicle_status=VEHICLE_STATUS_EV,
fetch_effect=SubaruException("403 Error"),
)
test_enti... | [
"async",
"def",
"test_fetch_failed",
"(",
"hass",
")",
":",
"await",
"setup_subaru_integration",
"(",
"hass",
",",
"vehicle_list",
"=",
"[",
"TEST_VIN_2_EV",
"]",
",",
"vehicle_data",
"=",
"VEHICLE_DATA",
"[",
"TEST_VIN_2_EV",
"]",
",",
"vehicle_status",
"=",
"V... | [
128,
0
] | [
139,
45
] | python | en | ['en', 'fr', 'en'] | True |
test_unload_entry | (hass, ev_entry) | Test that entry is unloaded. | Test that entry is unloaded. | async def test_unload_entry(hass, ev_entry):
"""Test that entry is unloaded."""
assert ev_entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(ev_entry.entry_id)
await hass.async_block_till_done()
assert ev_entry.state is ConfigEntryState.NOT_LOADED | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
",",
"ev_entry",
")",
":",
"assert",
"ev_entry",
".",
"state",
"is",
"ConfigEntryState",
".",
"LOADED",
"assert",
"await",
"hass",
".",
"config_entries",
".",
"async_unload",
"(",
"ev_entry",
".",
"entry_id",
"... | [
142,
0
] | [
147,
56
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) | Add a AccuWeather weather entity from a config_entry. | Add a AccuWeather weather entity from a config_entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Add a AccuWeather weather entity from a config_entry."""
name: str = entry.data[CONF_NAME]
coordinator: AccuWeatherDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
a... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
")",
"->",
"None",
":",
"name",
":",
"str",
"=",
"entry",
".",
"data",
"[",
"CONF_NAME",
"]",
"co... | [
40,
0
] | [
48,
62
] | python | en | ['en', 'en', 'en'] | True |
AccuWeatherEntity.__init__ | (
self, name: str, coordinator: AccuWeatherDataUpdateCoordinator
) | Initialize. | Initialize. | def __init__(
self, name: str, coordinator: AccuWeatherDataUpdateCoordinator
) -> None:
"""Initialize."""
super().__init__(coordinator)
self._unit_system = API_METRIC if coordinator.is_metric else API_IMPERIAL
self._attr_name = name
self._attr_unique_id = coordinator.... | [
"def",
"__init__",
"(",
"self",
",",
"name",
":",
"str",
",",
"coordinator",
":",
"AccuWeatherDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_unit_system",
"=",
"API_METRIC",
"if",
... | [
56,
4
] | [
73,
9
] | python | en | ['en', 'en', 'it'] | False |
AccuWeatherEntity.condition | (self) | Return the current condition. | Return the current condition. | def condition(self) -> str | None:
"""Return the current condition."""
try:
return [
k
for k, v in CONDITION_CLASSES.items()
if self.coordinator.data["WeatherIcon"] in v
][0]
except IndexError:
return None | [
"def",
"condition",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"try",
":",
"return",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"CONDITION_CLASSES",
".",
"items",
"(",
")",
"if",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"WeatherIcon\"",
"]",
... | [
76,
4
] | [
85,
23
] | python | en | ['en', 'en', 'en'] | True |
AccuWeatherEntity.temperature | (self) | Return the temperature. | Return the temperature. | def temperature(self) -> float:
"""Return the temperature."""
return cast(
float, self.coordinator.data["Temperature"][self._unit_system]["Value"]
) | [
"def",
"temperature",
"(",
"self",
")",
"->",
"float",
":",
"return",
"cast",
"(",
"float",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"Temperature\"",
"]",
"[",
"self",
".",
"_unit_system",
"]",
"[",
"\"Value\"",
"]",
")"
] | [
88,
4
] | [
92,
9
] | python | en | ['en', 'la', 'en'] | True |
AccuWeatherEntity.pressure | (self) | Return the pressure. | Return the pressure. | def pressure(self) -> float:
"""Return the pressure."""
return cast(
float, self.coordinator.data["Pressure"][self._unit_system]["Value"]
) | [
"def",
"pressure",
"(",
"self",
")",
"->",
"float",
":",
"return",
"cast",
"(",
"float",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"Pressure\"",
"]",
"[",
"self",
".",
"_unit_system",
"]",
"[",
"\"Value\"",
"]",
")"
] | [
95,
4
] | [
99,
9
] | python | en | ['en', 'ig', 'en'] | True |
AccuWeatherEntity.humidity | (self) | Return the humidity. | Return the humidity. | def humidity(self) -> int:
"""Return the humidity."""
return cast(int, self.coordinator.data["RelativeHumidity"]) | [
"def",
"humidity",
"(",
"self",
")",
"->",
"int",
":",
"return",
"cast",
"(",
"int",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"RelativeHumidity\"",
"]",
")"
] | [
102,
4
] | [
104,
67
] | python | en | ['en', 'sw', 'en'] | True |
AccuWeatherEntity.wind_speed | (self) | Return the wind speed. | Return the wind speed. | def wind_speed(self) -> float:
"""Return the wind speed."""
return cast(
float, self.coordinator.data["Wind"]["Speed"][self._unit_system]["Value"]
) | [
"def",
"wind_speed",
"(",
"self",
")",
"->",
"float",
":",
"return",
"cast",
"(",
"float",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"Wind\"",
"]",
"[",
"\"Speed\"",
"]",
"[",
"self",
".",
"_unit_system",
"]",
"[",
"\"Value\"",
"]",
")"
] | [
107,
4
] | [
111,
9
] | python | en | ['en', 'zh', 'en'] | True |
AccuWeatherEntity.wind_bearing | (self) | Return the wind bearing. | Return the wind bearing. | def wind_bearing(self) -> int:
"""Return the wind bearing."""
return cast(int, self.coordinator.data["Wind"]["Direction"]["Degrees"]) | [
"def",
"wind_bearing",
"(",
"self",
")",
"->",
"int",
":",
"return",
"cast",
"(",
"int",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"Wind\"",
"]",
"[",
"\"Direction\"",
"]",
"[",
"\"Degrees\"",
"]",
")"
] | [
114,
4
] | [
116,
79
] | python | en | ['en', 'ig', 'en'] | True |
AccuWeatherEntity.visibility | (self) | Return the visibility. | Return the visibility. | def visibility(self) -> float:
"""Return the visibility."""
return cast(
float, self.coordinator.data["Visibility"][self._unit_system]["Value"]
) | [
"def",
"visibility",
"(",
"self",
")",
"->",
"float",
":",
"return",
"cast",
"(",
"float",
",",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"Visibility\"",
"]",
"[",
"self",
".",
"_unit_system",
"]",
"[",
"\"Value\"",
"]",
")"
] | [
119,
4
] | [
123,
9
] | python | en | ['en', 'en', 'en'] | True |
AccuWeatherEntity.ozone | (self) | Return the ozone level. | Return the ozone level. | def ozone(self) -> int | None:
"""Return the ozone level."""
# We only have ozone data for certain locations and only in the forecast data.
if self.coordinator.forecast and self.coordinator.data[ATTR_FORECAST][0].get(
"Ozone"
):
return cast(int, self.coordinator.d... | [
"def",
"ozone",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"# We only have ozone data for certain locations and only in the forecast data.",
"if",
"self",
".",
"coordinator",
".",
"forecast",
"and",
"self",
".",
"coordinator",
".",
"data",
"[",
"ATTR_FORECAST",
... | [
126,
4
] | [
133,
19
] | python | en | ['en', 'zu', 'en'] | True |
AccuWeatherEntity.forecast | (self) | Return the forecast array. | Return the forecast array. | def forecast(self) -> list[Forecast] | None:
"""Return the forecast array."""
if not self.coordinator.forecast:
return None
# remap keys from library to keys understood by the weather component
return [
{
ATTR_FORECAST_TIME: utc_from_timestamp(item... | [
"def",
"forecast",
"(",
"self",
")",
"->",
"list",
"[",
"Forecast",
"]",
"|",
"None",
":",
"if",
"not",
"self",
".",
"coordinator",
".",
"forecast",
":",
"return",
"None",
"# remap keys from library to keys understood by the weather component",
"return",
"[",
"{",... | [
136,
4
] | [
162,
9
] | python | en | ['en', 'ga', 'en'] | True |
AccuWeatherEntity._calc_precipitation | (day: dict[str, Any]) | Return sum of the precipitation. | Return sum of the precipitation. | def _calc_precipitation(day: dict[str, Any]) -> float:
"""Return sum of the precipitation."""
precip_sum = 0
precip_types = ["Rain", "Snow", "Ice"]
for precip in precip_types:
precip_sum = sum(
[
precip_sum,
day[f"{preci... | [
"def",
"_calc_precipitation",
"(",
"day",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"float",
":",
"precip_sum",
"=",
"0",
"precip_types",
"=",
"[",
"\"Rain\"",
",",
"\"Snow\"",
",",
"\"Ice\"",
"]",
"for",
"precip",
"in",
"precip_types",
":",
... | [
165,
4
] | [
177,
35
] | python | en | ['en', 'pt', 'en'] | True |
_checknames | (descr, names=None) |
Checks that field names ``descr`` are not reserved keywords.
If this is the case, a default 'f%i' is substituted. If the argument
`names` is not None, updates the field names to valid names.
|
Checks that field names ``descr`` are not reserved keywords. | def _checknames(descr, names=None):
"""
Checks that field names ``descr`` are not reserved keywords.
If this is the case, a default 'f%i' is substituted. If the argument
`names` is not None, updates the field names to valid names.
"""
ndescr = len(descr)
default_names = ['f%i' % i for i i... | [
"def",
"_checknames",
"(",
"descr",
",",
"names",
"=",
"None",
")",
":",
"ndescr",
"=",
"len",
"(",
"descr",
")",
"default_names",
"=",
"[",
"'f%i'",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"ndescr",
")",
"]",
"if",
"names",
"is",
"None",
":",
... | [
44,
0
] | [
75,
27
] | python | en | ['en', 'error', 'th'] | False |
_mrreconstruct | (subtype, baseclass, baseshape, basetype,) |
Build a new MaskedArray from the information stored in a pickle.
|
Build a new MaskedArray from the information stored in a pickle. | def _mrreconstruct(subtype, baseclass, baseshape, basetype,):
"""
Build a new MaskedArray from the information stored in a pickle.
"""
_data = ndarray.__new__(baseclass, baseshape, basetype).view(subtype)
_mask = ndarray.__new__(ndarray, baseshape, 'b1')
return subtype.__new__(subtype, _data, m... | [
"def",
"_mrreconstruct",
"(",
"subtype",
",",
"baseclass",
",",
"baseshape",
",",
"basetype",
",",
")",
":",
"_data",
"=",
"ndarray",
".",
"__new__",
"(",
"baseclass",
",",
"baseshape",
",",
"basetype",
")",
".",
"view",
"(",
"subtype",
")",
"_mask",
"="... | [
485,
0
] | [
492,
71
] | python | en | ['en', 'error', 'th'] | False |
fromarrays | (arraylist, dtype=None, shape=None, formats=None,
names=None, titles=None, aligned=False, byteorder=None,
fill_value=None) |
Creates a mrecarray from a (flat) list of masked arrays.
Parameters
----------
arraylist : sequence
A list of (masked) arrays. Each element of the sequence is first converted
to a masked array if needed. If a 2D array is passed as argument, it is
processed line by line
dtyp... |
Creates a mrecarray from a (flat) list of masked arrays. | def fromarrays(arraylist, dtype=None, shape=None, formats=None,
names=None, titles=None, aligned=False, byteorder=None,
fill_value=None):
"""
Creates a mrecarray from a (flat) list of masked arrays.
Parameters
----------
arraylist : sequence
A list of (masked) ... | [
"def",
"fromarrays",
"(",
"arraylist",
",",
"dtype",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"formats",
"=",
"None",
",",
"names",
"=",
"None",
",",
"titles",
"=",
"None",
",",
"aligned",
"=",
"False",
",",
"byteorder",
"=",
"None",
",",
"fill_v... | [
502,
0
] | [
542,
17
] | python | en | ['en', 'error', 'th'] | False |
fromrecords | (reclist, dtype=None, shape=None, formats=None, names=None,
titles=None, aligned=False, byteorder=None,
fill_value=None, mask=nomask) |
Creates a MaskedRecords from a list of records.
Parameters
----------
reclist : sequence
A list of records. Each element of the sequence is first converted
to a masked array if needed. If a 2D array is passed as argument, it is
processed line by line
dtype : {None, dtype}, ... |
Creates a MaskedRecords from a list of records. | def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None,
titles=None, aligned=False, byteorder=None,
fill_value=None, mask=nomask):
"""
Creates a MaskedRecords from a list of records.
Parameters
----------
reclist : sequence
A list of record... | [
"def",
"fromrecords",
"(",
"reclist",
",",
"dtype",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"formats",
"=",
"None",
",",
"names",
"=",
"None",
",",
"titles",
"=",
"None",
",",
"aligned",
"=",
"False",
",",
"byteorder",
"=",
"None",
",",
"fill_va... | [
545,
0
] | [
607,
15
] | python | en | ['en', 'error', 'th'] | False |
_guessvartypes | (arr) |
Tries to guess the dtypes of the str_ ndarray `arr`.
Guesses by testing element-wise conversion. Returns a list of dtypes.
The array is first converted to ndarray. If the array is 2D, the test
is performed on the first line. An exception is raised if the file is
3D or more.
|
Tries to guess the dtypes of the str_ ndarray `arr`. | def _guessvartypes(arr):
"""
Tries to guess the dtypes of the str_ ndarray `arr`.
Guesses by testing element-wise conversion. Returns a list of dtypes.
The array is first converted to ndarray. If the array is 2D, the test
is performed on the first line. An exception is raised if the file is
3D ... | [
"def",
"_guessvartypes",
"(",
"arr",
")",
":",
"vartypes",
"=",
"[",
"]",
"arr",
"=",
"np",
".",
"asarray",
"(",
"arr",
")",
"if",
"arr",
".",
"ndim",
"==",
"2",
":",
"arr",
"=",
"arr",
"[",
"0",
"]",
"elif",
"arr",
".",
"ndim",
">",
"2",
":"... | [
610,
0
] | [
644,
19
] | python | en | ['en', 'error', 'th'] | False |
openfile | (fname) |
Opens the file handle of file `fname`.
|
Opens the file handle of file `fname`. | def openfile(fname):
"""
Opens the file handle of file `fname`.
"""
# A file handle
if hasattr(fname, 'readline'):
return fname
# Try to open the file and guess its type
try:
f = open(fname)
except IOError:
raise IOError("No such file: '%s'" % fname)
if f.rea... | [
"def",
"openfile",
"(",
"fname",
")",
":",
"# A file handle",
"if",
"hasattr",
"(",
"fname",
",",
"'readline'",
")",
":",
"return",
"fname",
"# Try to open the file and guess its type",
"try",
":",
"f",
"=",
"open",
"(",
"fname",
")",
"except",
"IOError",
":",... | [
647,
0
] | [
664,
49
] | python | en | ['en', 'error', 'th'] | False |
fromtextfile | (fname, delimitor=None, commentchar='#', missingchar='',
varnames=None, vartypes=None) |
Creates a mrecarray from data stored in the file `filename`.
Parameters
----------
fname : {file name/handle}
Handle of an opened file.
delimitor : {None, string}, optional
Alphanumeric character used to separate columns in the file.
If None, any (group of) white spacestrin... |
Creates a mrecarray from data stored in the file `filename`. | def fromtextfile(fname, delimitor=None, commentchar='#', missingchar='',
varnames=None, vartypes=None):
"""
Creates a mrecarray from data stored in the file `filename`.
Parameters
----------
fname : {file name/handle}
Handle of an opened file.
delimitor : {None, string}... | [
"def",
"fromtextfile",
"(",
"fname",
",",
"delimitor",
"=",
"None",
",",
"commentchar",
"=",
"'#'",
",",
"missingchar",
"=",
"''",
",",
"varnames",
"=",
"None",
",",
"vartypes",
"=",
"None",
")",
":",
"# Try to open the file.",
"ftext",
"=",
"openfile",
"(... | [
667,
0
] | [
732,
46
] | python | en | ['en', 'error', 'th'] | False |
addfield | (mrecord, newfield, newfieldname=None) | Adds a new field to the masked record array
Uses `newfield` as data and `newfieldname` as name. If `newfieldname`
is None, the new field name is set to 'fi', where `i` is the number of
existing fields.
| Adds a new field to the masked record array | def addfield(mrecord, newfield, newfieldname=None):
"""Adds a new field to the masked record array
Uses `newfield` as data and `newfieldname` as name. If `newfieldname`
is None, the new field name is set to 'fi', where `i` is the number of
existing fields.
"""
_data = mrecord._data
_mask =... | [
"def",
"addfield",
"(",
"mrecord",
",",
"newfield",
",",
"newfieldname",
"=",
"None",
")",
":",
"_data",
"=",
"mrecord",
".",
"_data",
"_mask",
"=",
"mrecord",
".",
"_mask",
"if",
"newfieldname",
"is",
"None",
"or",
"newfieldname",
"in",
"reserved_fields",
... | [
735,
0
] | [
769,
18
] | python | en | ['en', 'en', 'en'] | True |
MaskedRecords._data | (self) |
Returns the data as a recarray.
|
Returns the data as a recarray. | def _data(self):
"""
Returns the data as a recarray.
"""
return ndarray.view(self, recarray) | [
"def",
"_data",
"(",
"self",
")",
":",
"return",
"ndarray",
".",
"view",
"(",
"self",
",",
"recarray",
")"
] | [
165,
4
] | [
170,
43
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords._fieldmask | (self) |
Alias to mask.
|
Alias to mask. | def _fieldmask(self):
"""
Alias to mask.
"""
return self._mask | [
"def",
"_fieldmask",
"(",
"self",
")",
":",
"return",
"self",
".",
"_mask"
] | [
173,
4
] | [
178,
25
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__len__ | (self) |
Returns the length
|
Returns the length | def __len__(self):
"""
Returns the length
"""
# We have more than one record
if self.ndim:
return len(self._data)
# We have only one record: return the nb of fields
return len(self.dtype) | [
"def",
"__len__",
"(",
"self",
")",
":",
"# We have more than one record",
"if",
"self",
".",
"ndim",
":",
"return",
"len",
"(",
"self",
".",
"_data",
")",
"# We have only one record: return the nb of fields",
"return",
"len",
"(",
"self",
".",
"dtype",
")"
] | [
180,
4
] | [
189,
30
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__setattr__ | (self, attr, val) |
Sets the attribute attr to the value val.
|
Sets the attribute attr to the value val. | def __setattr__(self, attr, val):
"""
Sets the attribute attr to the value val.
"""
# Should we call __setmask__ first ?
if attr in ['mask', 'fieldmask']:
self.__setmask__(val)
return
# Create a shortcut (so that we don't have to call getattr all ... | [
"def",
"__setattr__",
"(",
"self",
",",
"attr",
",",
"val",
")",
":",
"# Should we call __setmask__ first ?",
"if",
"attr",
"in",
"[",
"'mask'",
",",
"'fieldmask'",
"]",
":",
"self",
".",
"__setmask__",
"(",
"val",
")",
"return",
"# Create a shortcut (so that we... | [
237,
4
] | [
290,
18
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__getitem__ | (self, indx) |
Returns all the fields sharing the same fieldname base.
The fieldname base is either `_data` or `_mask`.
|
Returns all the fields sharing the same fieldname base. | def __getitem__(self, indx):
"""
Returns all the fields sharing the same fieldname base.
The fieldname base is either `_data` or `_mask`.
"""
_localdict = self.__dict__
_mask = ndarray.__getattribute__(self, '_mask')
_data = ndarray.view(self, _localdict['_basec... | [
"def",
"__getitem__",
"(",
"self",
",",
"indx",
")",
":",
"_localdict",
"=",
"self",
".",
"__dict__",
"_mask",
"=",
"ndarray",
".",
"__getattribute__",
"(",
"self",
",",
"'_mask'",
")",
"_data",
"=",
"ndarray",
".",
"view",
"(",
"self",
",",
"_localdict"... | [
292,
4
] | [
322,
18
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__setitem__ | (self, indx, value) |
Sets the given record to value.
|
Sets the given record to value. | def __setitem__(self, indx, value):
"""
Sets the given record to value.
"""
MaskedArray.__setitem__(self, indx, value)
if isinstance(indx, str):
self._mask[indx] = ma.getmaskarray(value) | [
"def",
"__setitem__",
"(",
"self",
",",
"indx",
",",
"value",
")",
":",
"MaskedArray",
".",
"__setitem__",
"(",
"self",
",",
"indx",
",",
"value",
")",
"if",
"isinstance",
"(",
"indx",
",",
"str",
")",
":",
"self",
".",
"_mask",
"[",
"indx",
"]",
"... | [
324,
4
] | [
331,
53
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__str__ | (self) |
Calculates the string representation.
|
Calculates the string representation. | def __str__(self):
"""
Calculates the string representation.
"""
if self.size > 1:
mstr = ["(%s)" % ",".join([str(i) for i in s])
for s in zip(*[getattr(self, f) for f in self.dtype.names])]
return "[%s]" % ", ".join(mstr)
else:
... | [
"def",
"__str__",
"(",
"self",
")",
":",
"if",
"self",
".",
"size",
">",
"1",
":",
"mstr",
"=",
"[",
"\"(%s)\"",
"%",
"\",\"",
".",
"join",
"(",
"[",
"str",
"(",
"i",
")",
"for",
"i",
"in",
"s",
"]",
")",
"for",
"s",
"in",
"zip",
"(",
"*",
... | [
333,
4
] | [
345,
43
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__repr__ | (self) |
Calculates the repr representation.
|
Calculates the repr representation. | def __repr__(self):
"""
Calculates the repr representation.
"""
_names = self.dtype.names
fmt = "%%%is : %%s" % (max([len(n) for n in _names]) + 4,)
reprstr = [fmt % (f, getattr(self, f)) for f in self.dtype.names]
reprstr.insert(0, 'masked_records(')
rep... | [
"def",
"__repr__",
"(",
"self",
")",
":",
"_names",
"=",
"self",
".",
"dtype",
".",
"names",
"fmt",
"=",
"\"%%%is : %%s\"",
"%",
"(",
"max",
"(",
"[",
"len",
"(",
"n",
")",
"for",
"n",
"in",
"_names",
"]",
")",
"+",
"4",
",",
")",
"reprstr",
"=... | [
347,
4
] | [
358,
38
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.view | (self, dtype=None, type=None) |
Returns a view of the mrecarray.
|
Returns a view of the mrecarray. | def view(self, dtype=None, type=None):
"""
Returns a view of the mrecarray.
"""
# OK, basic copy-paste from MaskedArray.view.
if dtype is None:
if type is None:
output = ndarray.view(self)
else:
output = ndarray.view(self, ... | [
"def",
"view",
"(",
"self",
",",
"dtype",
"=",
"None",
",",
"type",
"=",
"None",
")",
":",
"# OK, basic copy-paste from MaskedArray.view.",
"if",
"dtype",
"is",
"None",
":",
"if",
"type",
"is",
"None",
":",
"output",
"=",
"ndarray",
".",
"view",
"(",
"se... | [
360,
4
] | [
399,
21
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.harden_mask | (self) |
Forces the mask to hard.
|
Forces the mask to hard. | def harden_mask(self):
"""
Forces the mask to hard.
"""
self._hardmask = True | [
"def",
"harden_mask",
"(",
"self",
")",
":",
"self",
".",
"_hardmask",
"=",
"True"
] | [
401,
4
] | [
406,
29
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.soften_mask | (self) |
Forces the mask to soft
|
Forces the mask to soft | def soften_mask(self):
"""
Forces the mask to soft
"""
self._hardmask = False | [
"def",
"soften_mask",
"(",
"self",
")",
":",
"self",
".",
"_hardmask",
"=",
"False"
] | [
408,
4
] | [
413,
30
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.copy | (self) |
Returns a copy of the masked record.
|
Returns a copy of the masked record. | def copy(self):
"""
Returns a copy of the masked record.
"""
copied = self._data.copy().view(type(self))
copied._mask = self._mask.copy()
return copied | [
"def",
"copy",
"(",
"self",
")",
":",
"copied",
"=",
"self",
".",
"_data",
".",
"copy",
"(",
")",
".",
"view",
"(",
"type",
"(",
"self",
")",
")",
"copied",
".",
"_mask",
"=",
"self",
".",
"_mask",
".",
"copy",
"(",
")",
"return",
"copied"
] | [
415,
4
] | [
422,
21
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.tolist | (self, fill_value=None) |
Return the data portion of the array as a list.
Data items are converted to the nearest compatible Python type.
Masked values are converted to fill_value. If fill_value is None,
the corresponding entries in the output list will be ``None``.
|
Return the data portion of the array as a list. | def tolist(self, fill_value=None):
"""
Return the data portion of the array as a list.
Data items are converted to the nearest compatible Python type.
Masked values are converted to fill_value. If fill_value is None,
the corresponding entries in the output list will be ``None``.... | [
"def",
"tolist",
"(",
"self",
",",
"fill_value",
"=",
"None",
")",
":",
"if",
"fill_value",
"is",
"not",
"None",
":",
"return",
"self",
".",
"filled",
"(",
"fill_value",
")",
".",
"tolist",
"(",
")",
"result",
"=",
"narray",
"(",
"self",
".",
"filled... | [
424,
4
] | [
438,
30
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__getstate__ | (self) | Return the internal state of the masked array.
This is for pickling.
| Return the internal state of the masked array. | def __getstate__(self):
"""Return the internal state of the masked array.
This is for pickling.
"""
state = (1,
self.shape,
self.dtype,
self.flags.fnc,
self._data.tobytes(),
self._mask.tobytes(),
... | [
"def",
"__getstate__",
"(",
"self",
")",
":",
"state",
"=",
"(",
"1",
",",
"self",
".",
"shape",
",",
"self",
".",
"dtype",
",",
"self",
".",
"flags",
".",
"fnc",
",",
"self",
".",
"_data",
".",
"tobytes",
"(",
")",
",",
"self",
".",
"_mask",
"... | [
440,
4
] | [
454,
20
] | python | en | ['en', 'en', 'en'] | True |
MaskedRecords.__setstate__ | (self, state) |
Restore the internal state of the masked array.
This is for pickling. ``state`` is typically the output of the
``__getstate__`` output, and is a 5-tuple:
- class name
- a tuple giving the shape of the data
- a typecode for the data
- a binary string for the da... |
Restore the internal state of the masked array. | def __setstate__(self, state):
"""
Restore the internal state of the masked array.
This is for pickling. ``state`` is typically the output of the
``__getstate__`` output, and is a 5-tuple:
- class name
- a tuple giving the shape of the data
- a typecode for the... | [
"def",
"__setstate__",
"(",
"self",
",",
"state",
")",
":",
"(",
"ver",
",",
"shp",
",",
"typ",
",",
"isf",
",",
"raw",
",",
"msk",
",",
"flv",
")",
"=",
"state",
"ndarray",
".",
"__setstate__",
"(",
"self",
",",
"(",
"shp",
",",
"typ",
",",
"i... | [
456,
4
] | [
474,
29
] | python | en | ['en', 'error', 'th'] | False |
MaskedRecords.__reduce__ | (self) |
Return a 3-tuple for pickling a MaskedArray.
|
Return a 3-tuple for pickling a MaskedArray. | def __reduce__(self):
"""
Return a 3-tuple for pickling a MaskedArray.
"""
return (_mrreconstruct,
(self.__class__, self._baseclass, (0,), 'b',),
self.__getstate__()) | [
"def",
"__reduce__",
"(",
"self",
")",
":",
"return",
"(",
"_mrreconstruct",
",",
"(",
"self",
".",
"__class__",
",",
"self",
".",
"_baseclass",
",",
"(",
"0",
",",
")",
",",
"'b'",
",",
")",
",",
"self",
".",
"__getstate__",
"(",
")",
")"
] | [
476,
4
] | [
483,
36
] | python | en | ['en', 'error', 'th'] | False |
ClassModel.__init__ | (self, _class=None, local_vars_configuration=None) | ClassModel - a model defined in OpenAPI | ClassModel - a model defined in OpenAPI | def __init__(self, _class=None, local_vars_configuration=None): # noqa: E501
"""ClassModel - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
self.local_vars_configuration = local_vars_config... | [
"def",
"__init__",
"(",
"self",
",",
"_class",
"=",
"None",
",",
"local_vars_configuration",
"=",
"None",
")",
":",
"# noqa: E501",
"# noqa: E501",
"if",
"local_vars_configuration",
"is",
"None",
":",
"local_vars_configuration",
"=",
"Configuration",
".",
"get_defau... | [
42,
4
] | [
52,
32
] | python | en | ['en', 'fy', 'en'] | True |
ClassModel._class | (self) | Gets the _class of this ClassModel. # noqa: E501
:return: The _class of this ClassModel. # noqa: E501
:rtype: str
| Gets the _class of this ClassModel. # noqa: E501 | def _class(self):
"""Gets the _class of this ClassModel. # noqa: E501
:return: The _class of this ClassModel. # noqa: E501
:rtype: str
"""
return self.__class | [
"def",
"_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class"
] | [
55,
4
] | [
62,
27
] | python | en | ['en', 'en', 'en'] | True |
ClassModel._class | (self, _class) | Sets the _class of this ClassModel.
:param _class: The _class of this ClassModel. # noqa: E501
:type _class: str
| Sets the _class of this ClassModel. | def _class(self, _class):
"""Sets the _class of this ClassModel.
:param _class: The _class of this ClassModel. # noqa: E501
:type _class: str
"""
self.__class = _class | [
"def",
"_class",
"(",
"self",
",",
"_class",
")",
":",
"self",
".",
"__class",
"=",
"_class"
] | [
65,
4
] | [
73,
29
] | python | en | ['en', 'en', 'en'] | True |
ClassModel.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",
... | [
75,
4
] | [
105,
21
] | python | en | ['en', 'en', 'en'] | True |
ClassModel.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",
"(",
")",
")"
] | [
107,
4
] | [
109,
45
] | python | en | ['en', 'en', 'en'] | True |
ClassModel.__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",
"(",
")"
] | [
111,
4
] | [
113,
28
] | python | en | ['en', 'en', 'en'] | True |
ClassModel.__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, ClassModel):
return False
return self.to_dict() == other.to_dict() | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ClassModel",
")",
":",
"return",
"False",
"return",
"self",
".",
"to_dict",
"(",
")",
"==",
"other",
".",
"to_dict",
"(",
")"
] | [
115,
4
] | [
120,
48
] | python | en | ['en', 'en', 'en'] | True |
ClassModel.__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, ClassModel):
return True
return self.to_dict() != other.to_dict() | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ClassModel",
")",
":",
"return",
"True",
"return",
"self",
".",
"to_dict",
"(",
")",
"!=",
"other",
".",
"to_dict",
"(",
")"
] | [
122,
4
] | [
127,
48
] | python | en | ['en', 'en', 'en'] | True |
requests_mock_fixture | () | Fixture to provide a requests mocker. | Fixture to provide a requests mocker. | def requests_mock_fixture():
"""Fixture to provide a requests mocker."""
with requests_mock.mock() as mock:
# Note all devices have an id of 987652, but a different device_id.
# the device_id is used as our unique_id, but the id is what is sent
# to the APIs, which is why every mock uses... | [
"def",
"requests_mock_fixture",
"(",
")",
":",
"with",
"requests_mock",
".",
"mock",
"(",
")",
"as",
"mock",
":",
"# Note all devices have an id of 987652, but a different device_id.",
"# the device_id is used as our unique_id, but the id is what is sent",
"# to the APIs, which is wh... | [
11,
0
] | [
54,
18
] | python | en | ['en', 'en', 'en'] | True |
test_lennox_e30_setup | (hass) | Test that a Lennox E30 can be correctly setup in HA. | Test that a Lennox E30 can be correctly setup in HA. | async def test_lennox_e30_setup(hass):
"""Test that a Lennox E30 can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, "lennox_e30.json")
config_entry, pairing = await setup_test_accessories(hass, accessories)
entity_registry = er.async_get(hass)
climate = entity_r... | [
"async",
"def",
"test_lennox_e30_setup",
"(",
"hass",
")",
":",
"accessories",
"=",
"await",
"setup_accessories_from_file",
"(",
"hass",
",",
"\"lennox_e30.json\"",
")",
"config_entry",
",",
"pairing",
"=",
"await",
"setup_test_accessories",
"(",
"hass",
",",
"acces... | [
19,
0
] | [
48,
39
] | python | en | ['en', 'en', 'en'] | True |
roomba_no_wake_time | () | Fixture that prevents sleep. | Fixture that prevents sleep. | def roomba_no_wake_time():
"""Fixture that prevents sleep."""
with patch.object(config_flow, "ROOMBA_WAKE_TIME", 0):
yield | [
"def",
"roomba_no_wake_time",
"(",
")",
":",
"with",
"patch",
".",
"object",
"(",
"config_flow",
",",
"\"ROOMBA_WAKE_TIME\"",
",",
"0",
")",
":",
"yield"
] | [
46,
0
] | [
49,
13
] | python | en | ['en', 'sr', 'en'] | True |
test_form_user_discovery_and_password_fetch | (hass) | Test we can discovery and fetch the password. | Test we can discovery and fetch the password. | async def test_form_user_discovery_and_password_fetch(hass):
"""Test we can discovery and fetch the password."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_connected=True,
master_state={"state": {"reported": {"name": ... | [
"async",
"def",
"test_form_user_discovery_and_password_fetch",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roomba",
"(",
"roomba_connect... | [
114,
0
] | [
170,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_skips_known | (hass) | Test discovery proceeds to manual if all discovered are already known. | Test discovery proceeds to manual if all discovered are already known. | async def test_form_user_discovery_skips_known(hass):
"""Test discovery proceeds to manual if all discovered are already known."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG, unique_id="BLID")
entry.add_to_hass(hass)
... | [
"async",
"def",
"test_form_user_discovery_skips_known",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
... | [
173,
0
] | [
190,
40
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_no_devices_found_discovery_aborts_already_configured | (hass) | Test if we manually configure an existing host we abort. | Test if we manually configure an existing host we abort. | async def test_form_user_no_devices_found_discovery_aborts_already_configured(hass):
"""Test if we manually configure an existing host we abort."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG, unique_id="BLID")
entry.ad... | [
"async",
"def",
"test_form_user_no_devices_found_discovery_aborts_already_configured",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entry",
"=",
"MockConfigEntry",
"(",
"doma... | [
193,
0
] | [
219,
52
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_manual_and_auto_password_fetch | (hass) | Test discovery skipped and we can auto fetch the password. | Test discovery skipped and we can auto fetch the password. | async def test_form_user_discovery_manual_and_auto_password_fetch(hass):
"""Test discovery skipped and we can auto fetch the password."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_connected=True,
master_state={"state... | [
"async",
"def",
"test_form_user_discovery_manual_and_auto_password_fetch",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roomba",
"(",
"ro... | [
222,
0
] | [
290,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discover_fails_aborts_already_configured | (hass) | Test if we manually configure an existing host we abort after failed discovery. | Test if we manually configure an existing host we abort after failed discovery. | async def test_form_user_discover_fails_aborts_already_configured(hass):
"""Test if we manually configure an existing host we abort after failed discovery."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG, unique_id="BLID")
... | [
"async",
"def",
"test_form_user_discover_fails_aborts_already_configured",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
... | [
293,
0
] | [
319,
52
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_manual_and_auto_password_fetch_but_cannot_connect | (
hass,
) | Test discovery skipped and we can auto fetch the password then we fail to connect. | Test discovery skipped and we can auto fetch the password then we fail to connect. | async def test_form_user_discovery_manual_and_auto_password_fetch_but_cannot_connect(
hass,
):
"""Test discovery skipped and we can auto fetch the password then we fail to connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.ro... | [
"async",
"def",
"test_form_user_discovery_manual_and_auto_password_fetch_but_cannot_connect",
"(",
"hass",
",",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeas... | [
322,
0
] | [
360,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_no_devices_found_and_auto_password_fetch | (hass) | Test discovery finds no devices and we can auto fetch the password. | Test discovery finds no devices and we can auto fetch the password. | async def test_form_user_discovery_no_devices_found_and_auto_password_fetch(hass):
"""Test discovery finds no devices and we can auto fetch the password."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_connected=True,
m... | [
"async",
"def",
"test_form_user_discovery_no_devices_found_and_auto_password_fetch",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roomba",
... | [
363,
0
] | [
422,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_no_devices_found_and_password_fetch_fails | (hass) | Test discovery finds no devices and password fetch fails. | Test discovery finds no devices and password fetch fails. | async def test_form_user_discovery_no_devices_found_and_password_fetch_fails(hass):
"""Test discovery finds no devices and password fetch fails."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_connected=True,
master_sta... | [
"async",
"def",
"test_form_user_discovery_no_devices_found_and_password_fetch_fails",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roomba",
... | [
425,
0
] | [
491,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_not_devices_found_and_password_fetch_fails_and_cannot_connect | (
hass,
) | Test discovery finds no devices and password fetch fails then we cannot connect. | Test discovery finds no devices and password fetch fails then we cannot connect. | async def test_form_user_discovery_not_devices_found_and_password_fetch_fails_and_cannot_connect(
hass,
):
"""Test discovery finds no devices and password fetch fails then we cannot connect."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(... | [
"async",
"def",
"test_form_user_discovery_not_devices_found_and_password_fetch_fails_and_cannot_connect",
"(",
"hass",
",",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
... | [
494,
0
] | [
555,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_discovery_and_password_fetch_gets_connection_refused | (hass) | Test we can discovery and fetch the password manually. | Test we can discovery and fetch the password manually. | async def test_form_user_discovery_and_password_fetch_gets_connection_refused(hass):
"""Test we can discovery and fetch the password manually."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_connected=True,
master_state... | [
"async",
"def",
"test_form_user_discovery_and_password_fetch_gets_connection_refused",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roomba",
... | [
558,
0
] | [
621,
48
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_and_roomba_discovery_finds | (hass, discovery_data) | Test we can process the discovery from dhcp and roomba discovery matches the device. | Test we can process the discovery from dhcp and roomba discovery matches the device. | async def test_dhcp_discovery_and_roomba_discovery_finds(hass, discovery_data):
"""Test we can process the discovery from dhcp and roomba discovery matches the device."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_connected=T... | [
"async",
"def",
"test_dhcp_discovery_and_roomba_discovery_finds",
"(",
"hass",
",",
"discovery_data",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roo... | [
625,
0
] | [
675,
48
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_falls_back_to_manual | (hass, discovery_data) | Test we can process the discovery from dhcp but roomba discovery cannot find the specific device. | Test we can process the discovery from dhcp but roomba discovery cannot find the specific device. | async def test_dhcp_discovery_falls_back_to_manual(hass, discovery_data):
"""Test we can process the discovery from dhcp but roomba discovery cannot find the specific device."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_conn... | [
"async",
"def",
"test_dhcp_discovery_falls_back_to_manual",
"(",
"hass",
",",
"discovery_data",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocked_roomba",
... | [
679,
0
] | [
748,
48
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_no_devices_falls_back_to_manual | (hass, discovery_data) | Test we can process the discovery from dhcp but roomba discovery cannot find any devices. | Test we can process the discovery from dhcp but roomba discovery cannot find any devices. | async def test_dhcp_discovery_no_devices_falls_back_to_manual(hass, discovery_data):
"""Test we can process the discovery from dhcp but roomba discovery cannot find any devices."""
await setup.async_setup_component(hass, "persistent_notification", {})
mocked_roomba = _create_mocked_roomba(
roomba_c... | [
"async",
"def",
"test_dhcp_discovery_no_devices_falls_back_to_manual",
"(",
"hass",
",",
"discovery_data",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"mocked_roomba",
"=",
"_create_mocke... | [
752,
0
] | [
813,
48
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_with_ignored | (hass) | Test ignored entries do not break checking for existing entries. | Test ignored entries do not break checking for existing entries. | async def test_dhcp_discovery_with_ignored(hass):
"""Test ignored entries do not break checking for existing entries."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
)
confi... | [
"async",
"def",
"test_dhcp_discovery_with_ignored",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",... | [
816,
0
] | [
839,
35
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_already_configured_host | (hass) | Test we abort if the host is already configured. | Test we abort if the host is already configured. | async def test_dhcp_discovery_already_configured_host(hass):
"""Test we abort if the host is already configured."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(domain=DOMAIN, data={CONF_HOST: MOCK_IP})
config_entry.add_to_hass(hass)
with pa... | [
"async",
"def",
"test_dhcp_discovery_already_configured_host",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DO... | [
842,
0
] | [
864,
51
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_already_configured_blid | (hass) | Test we abort if the blid is already configured. | Test we abort if the blid is already configured. | async def test_dhcp_discovery_already_configured_blid(hass):
"""Test we abort if the blid is already configured."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_BLID: "BLID"}, unique_id="BLID"
)
config_entry... | [
"async",
"def",
"test_dhcp_discovery_already_configured_blid",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DO... | [
867,
0
] | [
891,
51
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_not_irobot | (hass) | Test we abort if the discovered device is not an irobot device. | Test we abort if the discovered device is not an irobot device. | async def test_dhcp_discovery_not_irobot(hass):
"""Test we abort if the discovered device is not an irobot device."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_BLID: "BLID"}, unique_id="BLID"
)
config_ent... | [
"async",
"def",
"test_dhcp_discovery_not_irobot",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",... | [
894,
0
] | [
918,
50
] | python | en | ['en', 'en', 'en'] | True |
test_dhcp_discovery_partial_hostname | (hass) | Test we abort flows when we have a partial hostname. | Test we abort flows when we have a partial hostname. | async def test_dhcp_discovery_partial_hostname(hass):
"""Test we abort flows when we have a partial hostname."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.roomba.config_flow.RoombaDiscovery", _mocked_discovery
):
result ... | [
"async",
"def",
"test_dhcp_discovery_partial_hostname",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.roomba.config_flow.RoombaD... | [
921,
0
] | [
982,
60
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Goalfeed component. | Set up the Goalfeed component. | def setup(hass, config):
"""Set up the Goalfeed component."""
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)
password = conf.get(CONF_PASSWORD)
def goal_handler(data):
"""Handle goal events."""
goal = json.loads(json.loads(data))
hass.bus.fire("goal", event_data=g... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"username",
"=",
"conf",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"conf",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"def",
"goal_handler",
"(",... | [
31,
0
] | [
62,
15
] | python | en | ['en', 'en', 'en'] | True |
test_immediate_works | (hass) | Test immediate works. | Test immediate works. | async def test_immediate_works(hass):
"""Test immediate works."""
calls = []
debouncer = debounce.Debouncer(
hass,
None,
cooldown=0.01,
immediate=True,
function=AsyncMock(side_effect=lambda: calls.append(None)),
)
# Call when nothing happening
await debou... | [
"async",
"def",
"test_immediate_works",
"(",
"hass",
")",
":",
"calls",
"=",
"[",
"]",
"debouncer",
"=",
"debounce",
".",
"Debouncer",
"(",
"hass",
",",
"None",
",",
"cooldown",
"=",
"0.01",
",",
"immediate",
"=",
"True",
",",
"function",
"=",
"AsyncMock... | [
6,
0
] | [
56,
54
] | python | en | ['en', 'ig', 'en'] | True |
test_not_immediate_works | (hass) | Test immediate works. | Test immediate works. | async def test_not_immediate_works(hass):
"""Test immediate works."""
calls = []
debouncer = debounce.Debouncer(
hass,
None,
cooldown=0.01,
immediate=False,
function=AsyncMock(side_effect=lambda: calls.append(None)),
)
# Call when nothing happening
await ... | [
"async",
"def",
"test_not_immediate_works",
"(",
"hass",
")",
":",
"calls",
"=",
"[",
"]",
"debouncer",
"=",
"debounce",
".",
"Debouncer",
"(",
"hass",
",",
"None",
",",
"cooldown",
"=",
"0.01",
",",
"immediate",
"=",
"False",
",",
"function",
"=",
"Asyn... | [
59,
0
] | [
106,
54
] | python | en | ['en', 'ig', 'en'] | True |
test_immediate_works_with_function_swapped | (hass) | Test immediate works and we can change out the function. | Test immediate works and we can change out the function. | async def test_immediate_works_with_function_swapped(hass):
"""Test immediate works and we can change out the function."""
calls = []
one_function = AsyncMock(side_effect=lambda: calls.append(1))
two_function = AsyncMock(side_effect=lambda: calls.append(2))
debouncer = debounce.Debouncer(
... | [
"async",
"def",
"test_immediate_works_with_function_swapped",
"(",
"hass",
")",
":",
"calls",
"=",
"[",
"]",
"one_function",
"=",
"AsyncMock",
"(",
"side_effect",
"=",
"lambda",
":",
"calls",
".",
"append",
"(",
"1",
")",
")",
"two_function",
"=",
"AsyncMock",... | [
109,
0
] | [
167,
54
] | python | en | ['en', 'en', 'en'] | True |
_async_reproduce_state | (
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) | Reproduce a single state. | Reproduce a single state. | async def _async_reproduce_state(
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) -> None:
"""Reproduce a single state."""
cur_state = hass.states.get(state.entity_id)
if cur_state is None:
_LOGGER.warning(... | [
"async",
"def",
"_async_reproduce_state",
"(",
"hass",
":",
"HomeAssistant",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Context",
"|",
"None",
"=",
"None",
",",
"reproduce_options",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
... | [
26,
0
] | [
59,
5
] | python | en | ['en', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) | Reproduce Lock states. | Reproduce Lock states. | async def async_reproduce_states(
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
reproduce_options: dict[str, Any] | None = None,
) -> None:
"""Reproduce Lock states."""
await asyncio.gather(
*(
_async_reproduce_state(
has... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistant",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Context",
"|",
"None",
"=",
"None",
",",
"reproduce_options",
":",
"dict",
"[",
"str",
",",
"A... | [
62,
0
] | [
77,
5
] | python | en | ['en', 'en', 'en'] | True |
HealthCheckResult.__init__ | (self, nullable_message=None, local_vars_configuration=None) | HealthCheckResult - a model defined in OpenAPI | HealthCheckResult - a model defined in OpenAPI | def __init__(self, nullable_message=None, local_vars_configuration=None): # noqa: E501
"""HealthCheckResult - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
self.local_vars_configuration = ... | [
"def",
"__init__",
"(",
"self",
",",
"nullable_message",
"=",
"None",
",",
"local_vars_configuration",
"=",
"None",
")",
":",
"# noqa: E501",
"# noqa: E501",
"if",
"local_vars_configuration",
"is",
"None",
":",
"local_vars_configuration",
"=",
"Configuration",
".",
... | [
42,
4
] | [
51,
48
] | python | en | ['en', 'da', 'en'] | True |
HealthCheckResult.nullable_message | (self) | Gets the nullable_message of this HealthCheckResult. # noqa: E501
:return: The nullable_message of this HealthCheckResult. # noqa: E501
:rtype: str
| Gets the nullable_message of this HealthCheckResult. # noqa: E501 | def nullable_message(self):
"""Gets the nullable_message of this HealthCheckResult. # noqa: E501
:return: The nullable_message of this HealthCheckResult. # noqa: E501
:rtype: str
"""
return self._nullable_message | [
"def",
"nullable_message",
"(",
"self",
")",
":",
"return",
"self",
".",
"_nullable_message"
] | [
54,
4
] | [
61,
37
] | python | en | ['en', 'en', 'en'] | True |
HealthCheckResult.nullable_message | (self, nullable_message) | Sets the nullable_message of this HealthCheckResult.
:param nullable_message: The nullable_message of this HealthCheckResult. # noqa: E501
:type nullable_message: str
| Sets the nullable_message of this HealthCheckResult. | def nullable_message(self, nullable_message):
"""Sets the nullable_message of this HealthCheckResult.
:param nullable_message: The nullable_message of this HealthCheckResult. # noqa: E501
:type nullable_message: str
"""
self._nullable_message = nullable_message | [
"def",
"nullable_message",
"(",
"self",
",",
"nullable_message",
")",
":",
"self",
".",
"_nullable_message",
"=",
"nullable_message"
] | [
64,
4
] | [
72,
49
] | python | en | ['en', 'en', 'en'] | True |
HealthCheckResult.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",
... | [
74,
4
] | [
104,
21
] | python | en | ['en', 'en', 'en'] | True |
HealthCheckResult.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",
"(",
")",
")"
] | [
106,
4
] | [
108,
45
] | 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.