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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_to_hass_level | (level) | Convert the given Skybell (0-100) light level to Home Assistant (0-255). | Convert the given Skybell (0-100) light level to Home Assistant (0-255). | def _to_hass_level(level):
"""Convert the given Skybell (0-100) light level to Home Assistant (0-255)."""
return int((level * 255) / 100) | [
"def",
"_to_hass_level",
"(",
"level",
")",
":",
"return",
"int",
"(",
"(",
"level",
"*",
"255",
")",
"/",
"100",
")"
] | [
29,
0
] | [
31,
35
] | python | en | ['en', 'en', 'en'] | True |
SkybellLight.__init__ | (self, device) | Initialize a light for a Skybell device. | Initialize a light for a Skybell device. | def __init__(self, device):
"""Initialize a light for a Skybell device."""
super().__init__(device)
self._name = self._device.name | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"_name",
"=",
"self",
".",
"_device",
".",
"name"
] | [
37,
4
] | [
40,
38
] | python | en | ['en', 'en', 'en'] | True |
SkybellLight.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"
] | [
43,
4
] | [
45,
25
] | python | en | ['en', 'mi', 'en'] | True |
SkybellLight.turn_on | (self, **kwargs) | Turn on the light. | Turn on the light. | def turn_on(self, **kwargs):
"""Turn on the light."""
if ATTR_HS_COLOR in kwargs:
rgb = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
self._device.led_rgb = rgb
elif ATTR_BRIGHTNESS in kwargs:
self._device.led_intensity = _to_skybell_level(kwargs[ATTR_BRI... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_HS_COLOR",
"in",
"kwargs",
":",
"rgb",
"=",
"color_util",
".",
"color_hs_to_RGB",
"(",
"*",
"kwargs",
"[",
"ATTR_HS_COLOR",
"]",
")",
"self",
".",
"_device",
".",
"led_rgb",
... | [
47,
4
] | [
55,
63
] | python | en | ['en', 'et', 'en'] | True |
SkybellLight.turn_off | (self, **kwargs) | Turn off the light. | Turn off the light. | def turn_off(self, **kwargs):
"""Turn off the light."""
self._device.led_intensity = 0 | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_device",
".",
"led_intensity",
"=",
"0"
] | [
57,
4
] | [
59,
38
] | python | en | ['en', 'zh', 'en'] | True |
SkybellLight.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._device.led_intensity > 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"led_intensity",
">",
"0"
] | [
62,
4
] | [
64,
45
] | python | en | ['en', 'fy', 'en'] | True |
SkybellLight.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self):
"""Return the brightness of the light."""
return _to_hass_level(self._device.led_intensity) | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"_to_hass_level",
"(",
"self",
".",
"_device",
".",
"led_intensity",
")"
] | [
67,
4
] | [
69,
57
] | python | en | ['en', 'no', 'en'] | True |
SkybellLight.hs_color | (self) | Return the color of the light. | Return the color of the light. | def hs_color(self):
"""Return the color of the light."""
return color_util.color_RGB_to_hs(*self._device.led_rgb) | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"color_util",
".",
"color_RGB_to_hs",
"(",
"*",
"self",
".",
"_device",
".",
"led_rgb",
")"
] | [
72,
4
] | [
74,
64
] | python | en | ['en', 'en', 'en'] | True |
SkybellLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | SUPPORT_COLOR | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BRIGHTNESS",
"|",
"SUPPORT_COLOR"
] | [
77,
4
] | [
79,
49
] | python | en | ['da', 'en', 'en'] | True |
test_show_user_form | (hass: HomeAssistant) | Test that the user set up form is served. | Test that the user set up form is served. | async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"
assert result["type"] == data_ent... | [
"async",
"def",
"test_show_user_form",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"config_flow",
".",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\""... | [
17,
0
] | [
25,
61
] | python | en | ['en', 'en', 'en'] | True |
test_show_zeroconf_confirm_form | (hass: HomeAssistant) | Test that the zeroconf confirmation form is served. | Test that the zeroconf confirmation form is served. | async def test_show_zeroconf_confirm_form(hass: HomeAssistant) -> None:
"""Test that the zeroconf confirmation form is served."""
flow = config_flow.WLEDFlowHandler()
flow.hass = hass
flow.context = {"source": SOURCE_ZEROCONF, CONF_NAME: "test"}
result = await flow.async_step_zeroconf_confirm()
... | [
"async",
"def",
"test_show_zeroconf_confirm_form",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"flow",
"=",
"config_flow",
".",
"WLEDFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"flow",
".",
"context",
"=",
"{",
"\"source\"",
":",... | [
28,
0
] | [
37,
61
] | python | en | ['en', 'en', 'en'] | True |
test_show_zerconf_form | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test that the zeroconf confirmation form is served. | Test that the zeroconf confirmation form is served. | async def test_show_zerconf_form(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test that the zeroconf confirmation form is served."""
aioclient_mock.get(
"http://192.168.1.123:80/json/",
text=load_fixture("wled/rgb.json"),
headers={"Content-Type": CONTENT_TY... | [
"async",
"def",
"test_show_zerconf_form",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://192.168.1.123:80/json/\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"... | [
40,
0
] | [
61,
61
] | python | en | ['en', 'en', 'en'] | True |
test_connection_error | (
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we show user form on WLED connection error. | Test we show user form on WLED connection error. | async def test_connection_error(
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we show user form on WLED connection error."""
aioclient_mock.get("http://example.com/json/", exc=aiohttp.ClientError)
result = await hass.config_entries.flow.async_init(... | [
"async",
"def",
"test_connection_error",
"(",
"update_mock",
":",
"MagicMock",
",",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.com/json/\"",
",",
"exc"... | [
65,
0
] | [
79,
61
] | python | en | ['en', 'en', 'en'] | True |
test_zeroconf_connection_error | (
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort zeroconf flow on WLED connection error. | Test we abort zeroconf flow on WLED connection error. | async def test_zeroconf_connection_error(
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow on WLED connection error."""
aioclient_mock.get("http://192.168.1.123/json/", exc=aiohttp.ClientError)
result = await hass.config_entries.... | [
"async",
"def",
"test_zeroconf_connection_error",
"(",
"update_mock",
":",
"MagicMock",
",",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://192.168.1.123/json/\"",
"... | [
83,
0
] | [
96,
62
] | python | en | ['en', 'de', 'en'] | True |
test_zeroconf_confirm_connection_error | (
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort zeroconf flow on WLED connection error. | Test we abort zeroconf flow on WLED connection error. | async def test_zeroconf_confirm_connection_error(
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow on WLED connection error."""
aioclient_mock.get("http://192.168.1.123:80/json/", exc=aiohttp.ClientError)
result = await hass.conf... | [
"async",
"def",
"test_zeroconf_confirm_connection_error",
"(",
"update_mock",
":",
"MagicMock",
",",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://192.168.1.123:80/js... | [
100,
0
] | [
117,
62
] | python | en | ['en', 'de', 'en'] | True |
test_zeroconf_no_data | (
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort if zeroconf provides no data. | Test we abort if zeroconf provides no data. | async def test_zeroconf_no_data(
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort if zeroconf provides no data."""
flow = config_flow.WLEDFlowHandler()
flow.hass = hass
result = await flow.async_step_zeroconf()
assert result["reason"] ... | [
"async",
"def",
"test_zeroconf_no_data",
"(",
"update_mock",
":",
"MagicMock",
",",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"flow",
"=",
"config_flow",
".",
"WLEDFlowHandler",
"(",
")",
"flow",
"."... | [
121,
0
] | [
130,
62
] | python | de | ['pt', 'de', 'en'] | False |
test_user_device_exists_abort | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort zeroconf flow if WLED device already configured. | Test we abort zeroconf flow if WLED device already configured. | async def test_user_device_exists_abort(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow if WLED device already configured."""
await init_integration(hass, aioclient_mock)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
... | [
"async",
"def",
"test_user_device_exists_abort",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"result",
"=",
"await",
"hass",
"."... | [
133,
0
] | [
146,
51
] | python | de | ['de', 'de', 'en'] | True |
test_zeroconf_device_exists_abort | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort zeroconf flow if WLED device already configured. | Test we abort zeroconf flow if WLED device already configured. | async def test_zeroconf_device_exists_abort(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow if WLED device already configured."""
await init_integration(hass, aioclient_mock)
result = await hass.config_entries.flow.async_init(
config_flow.DOMA... | [
"async",
"def",
"test_zeroconf_device_exists_abort",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"result",
"=",
"await",
"hass",
... | [
149,
0
] | [
162,
51
] | python | de | ['de', 'de', 'en'] | True |
test_zeroconf_with_mac_device_exists_abort | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test we abort zeroconf flow if WLED device already configured. | Test we abort zeroconf flow if WLED device already configured. | async def test_zeroconf_with_mac_device_exists_abort(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow if WLED device already configured."""
await init_integration(hass, aioclient_mock)
result = await hass.config_entries.flow.async_init(
config_... | [
"async",
"def",
"test_zeroconf_with_mac_device_exists_abort",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"result",
"=",
"await",
... | [
165,
0
] | [
182,
51
] | python | de | ['de', 'de', 'en'] | True |
test_full_user_flow_implementation | (
hass: HomeAssistant, aioclient_mock
) | Test the full manual user flow from start to finish. | Test the full manual user flow from start to finish. | async def test_full_user_flow_implementation(
hass: HomeAssistant, aioclient_mock
) -> None:
"""Test the full manual user flow from start to finish."""
aioclient_mock.get(
"http://192.168.1.123:80/json/",
text=load_fixture("wled/rgb.json"),
headers={"Content-Type": CONTENT_TYPE_JSON}... | [
"async",
"def",
"test_full_user_flow_implementation",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://192.168.1.123:80/json/\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"wled/rgb.json\"",
... | [
185,
0
] | [
210,
69
] | python | en | ['en', 'en', 'en'] | True |
test_full_zeroconf_flow_implementation | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the full manual user flow from start to finish. | Test the full manual user flow from start to finish. | async def test_full_zeroconf_flow_implementation(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the full manual user flow from start to finish."""
aioclient_mock.get(
"http://192.168.1.123:80/json/",
text=load_fixture("wled/rgb.json"),
headers={"Content-... | [
"async",
"def",
"test_full_zeroconf_flow_implementation",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://192.168.1.123:80/json/\"",
",",
"text",
"=",
"load_fixtur... | [
213,
0
] | [
240,
69
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Smappee component. | Set up the Smappee component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Smappee component."""
hass.data[DOMAIN] = {}
if DOMAIN not in config:
return True
client_id = config[DOMAIN][CONF_CLIENT_ID]
hass.data[DOMAIN][client_id] = {}
# decide platform
platform = "PRODUCTION"
if c... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"client_id",
"=",
"config",
... | [
40,
0
] | [
71,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Smappee from a zeroconf or config entry. | Set up Smappee from a zeroconf or config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Smappee from a zeroconf or config entry."""
if CONF_IP_ADDRESS in entry.data:
smappee_api = api.api.SmappeeLocalApi(ip=entry.data[CONF_IP_ADDRESS])
smappee = Smappee(api=smappee_api, serialnumber=entry.data[CONF_SERI... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"if",
"CONF_IP_ADDRESS",
"in",
"entry",
".",
"data",
":",
"smappee_api",
"=",
"api",
".",
"api",
".",
"SmappeeLocalApi",
"(",
"ip",
"=",
"en... | [
74,
0
] | [
99,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in SMAPPEE_PLATFORMS
]
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
102,
0
] | [
116,
20
] | python | en | ['en', 'es', 'en'] | True |
SmappeeBase.__init__ | (self, hass, smappee) | Initialize the Smappee API wrapper class. | Initialize the Smappee API wrapper class. | def __init__(self, hass, smappee):
"""Initialize the Smappee API wrapper class."""
self.hass = hass
self.smappee = smappee | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"smappee",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"smappee",
"=",
"smappee"
] | [
122,
4
] | [
125,
30
] | python | en | ['en', 'en', 'en'] | True |
SmappeeBase.async_update | (self) | Update all Smappee trends and appliance states. | Update all Smappee trends and appliance states. | async def async_update(self):
"""Update all Smappee trends and appliance states."""
await self.hass.async_add_executor_job(
self.smappee.update_trends_and_appliance_states
) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"smappee",
".",
"update_trends_and_appliance_states",
")"
] | [
128,
4
] | [
132,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigType, async_add_entities
) | Set up the Met Office weather sensor platform. | Set up the Met Office weather sensor platform. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigType, async_add_entities
) -> None:
"""Set up the Met Office weather sensor platform."""
hass_data = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
[
MetOfficeCurrentSensor(entry.data, hass_data, sensor_type)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigType",
",",
"async_add_entities",
")",
"->",
"None",
":",
"hass_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"... | [
79,
0
] | [
91,
5
] | python | en | ['en', 'da', 'en'] | True |
MetOfficeCurrentSensor.__init__ | (self, entry_data, hass_data, sensor_type) | Initialize the sensor. | Initialize the sensor. | def __init__(self, entry_data, hass_data, sensor_type):
"""Initialize the sensor."""
self._data = hass_data[METOFFICE_DATA]
self._coordinator = hass_data[METOFFICE_COORDINATOR]
self._type = sensor_type
self._name = f"{hass_data[METOFFICE_NAME]} {SENSOR_TYPES[self._type][0]}"
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_data",
",",
"hass_data",
",",
"sensor_type",
")",
":",
"self",
".",
"_data",
"=",
"hass_data",
"[",
"METOFFICE_DATA",
"]",
"self",
".",
"_coordinator",
"=",
"hass_data",
"[",
"METOFFICE_COORDINATOR",
"]",
"self",
"... | [
97,
4
] | [
108,
33
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.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"
] | [
111,
4
] | [
113,
25
] | python | en | ['en', 'mi', 'en'] | True |
MetOfficeCurrentSensor.unique_id | (self) | Return the unique of the sensor. | Return the unique of the sensor. | def unique_id(self):
"""Return the unique of the sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
116,
4
] | [
118,
30
] | python | en | ['en', 'la', 'en'] | True |
MetOfficeCurrentSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
value = None
if self._type == "visibility_distance" and hasattr(
self.metoffice_now, "visibility"
):
value = VISIBILITY_DISTANCE_CLASSES.get(self.metoffice_now.visibility.value)
if self._type == "vis... | [
"def",
"state",
"(",
"self",
")",
":",
"value",
"=",
"None",
"if",
"self",
".",
"_type",
"==",
"\"visibility_distance\"",
"and",
"hasattr",
"(",
"self",
".",
"metoffice_now",
",",
"\"visibility\"",
")",
":",
"value",
"=",
"VISIBILITY_DISTANCE_CLASSES",
".",
... | [
121,
4
] | [
146,
20
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return SENSOR_TYPES[self._type][2] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_type",
"]",
"[",
"2",
"]"
] | [
149,
4
] | [
151,
42
] | python | en | ['en', 'la', 'en'] | True |
MetOfficeCurrentSensor.icon | (self) | Return the icon for the entity card. | Return the icon for the entity card. | def icon(self):
"""Return the icon for the entity card."""
value = SENSOR_TYPES[self._type][3]
if self._type == "weather":
value = self.state
if value is None:
value = "sunny"
elif value == "partlycloudy":
value = "partly-cloudy... | [
"def",
"icon",
"(",
"self",
")",
":",
"value",
"=",
"SENSOR_TYPES",
"[",
"self",
".",
"_type",
"]",
"[",
"3",
"]",
"if",
"self",
".",
"_type",
"==",
"\"weather\"",
":",
"value",
"=",
"self",
".",
"state",
"if",
"value",
"is",
"None",
":",
"value",
... | [
154,
4
] | [
165,
20
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self):
"""Return the device class of the sensor."""
return SENSOR_TYPES[self._type][1] | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_type",
"]",
"[",
"1",
"]"
] | [
168,
4
] | [
170,
42
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_LAST_UPDATE: self.metoffice_now.date if self.metoffice_now else None,
ATTR_SENSOR_ID: self._type,
ATTR_SITE_ID: self.metoffice_... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"ATTR_LAST_UPDATE",
":",
"self",
".",
"metoffice_now",
".",
"date",
"if",
"self",
".",
"metoffice_now",
"else",
"None",
",",
"ATTR_SENSOR_ID",
":... | [
173,
4
] | [
183,
9
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.async_added_to_hass | (self) | Set up a listener and load data. | Set up a listener and load data. | async def async_added_to_hass(self) -> None:
"""Set up a listener and load data."""
self.async_on_remove(
self._coordinator.async_add_listener(self._update_callback)
)
self._update_callback() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"_coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"_update_callback",
")",
")",
"self",
".",
"_update_callback",
"(",
")"
] | [
185,
4
] | [
190,
31
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.async_update | (self) | Schedule a custom update via the common entity update service. | Schedule a custom update via the common entity update service. | async def async_update(self):
"""Schedule a custom update via the common entity update service."""
await self._coordinator.async_request_refresh() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_coordinator",
".",
"async_request_refresh",
"(",
")"
] | [
192,
4
] | [
194,
55
] | python | en | ['en', 'co', 'en'] | True |
MetOfficeCurrentSensor._update_callback | (self) | Load data from integration. | Load data from integration. | def _update_callback(self) -> None:
"""Load data from integration."""
self.metoffice_site_id = self._data.site_id
self.metoffice_site_name = self._data.site_name
self.metoffice_now = self._data.now
self.async_write_ha_state() | [
"def",
"_update_callback",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"metoffice_site_id",
"=",
"self",
".",
"_data",
".",
"site_id",
"self",
".",
"metoffice_site_name",
"=",
"self",
".",
"_data",
".",
"site_name",
"self",
".",
"metoffice_now",
"=",
... | [
197,
4
] | [
202,
35
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.should_poll | (self) | Entities do not individually poll. | Entities do not individually poll. | def should_poll(self) -> bool:
"""Entities do not individually poll."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
205,
4
] | [
207,
20
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return SENSOR_TYPES[self._type][4] | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"SENSOR_TYPES",
"[",
"self",
".",
"_type",
"]",
"[",
"4",
"]"
] | [
210,
4
] | [
212,
42
] | python | en | ['en', 'en', 'en'] | True |
MetOfficeCurrentSensor.available | (self) | Return if state is available. | Return if state is available. | def available(self):
"""Return if state is available."""
return self.metoffice_site_id is not None and self.metoffice_now is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"metoffice_site_id",
"is",
"not",
"None",
"and",
"self",
".",
"metoffice_now",
"is",
"not",
"None"
] | [
215,
4
] | [
217,
84
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up the sensors. | Set up the sensors. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up the sensors."""
router = hass.data[DOMAIN][entry.unique_id]
entities = []
for sensor_name in router.sensors_temperature:
entities.append(
FreeboxSensor(
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"router",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"unique_id",
"]",
"e... | [
24,
0
] | [
48,
38
] | python | en | ['en', 'bg', 'en'] | True |
FreeboxSensor.__init__ | (
self, router: FreeboxRouter, sensor_type: str, sensor: Dict[str, any]
) | Initialize a Freebox sensor. | Initialize a Freebox sensor. | def __init__(
self, router: FreeboxRouter, sensor_type: str, sensor: Dict[str, any]
) -> None:
"""Initialize a Freebox sensor."""
self._state = None
self._router = router
self._sensor_type = sensor_type
self._name = sensor[SENSOR_NAME]
self._unit = sensor[SENS... | [
"def",
"__init__",
"(",
"self",
",",
"router",
":",
"FreeboxRouter",
",",
"sensor_type",
":",
"str",
",",
"sensor",
":",
"Dict",
"[",
"str",
",",
"any",
"]",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_router",
"=",
"... | [
54,
4
] | [
65,
60
] | python | en | ['en', 'haw', 'en'] | True |
FreeboxSensor.async_update_state | (self) | Update the Freebox sensor. | Update the Freebox sensor. | def async_update_state(self) -> None:
"""Update the Freebox sensor."""
state = self._router.sensors[self._sensor_type]
if self._unit == DATA_RATE_KILOBYTES_PER_SECOND:
self._state = round(state / 1000, 2)
else:
self._state = state | [
"def",
"async_update_state",
"(",
"self",
")",
"->",
"None",
":",
"state",
"=",
"self",
".",
"_router",
".",
"sensors",
"[",
"self",
".",
"_sensor_type",
"]",
"if",
"self",
".",
"_unit",
"==",
"DATA_RATE_KILOBYTES_PER_SECOND",
":",
"self",
".",
"_state",
"... | [
68,
4
] | [
74,
31
] | python | en | ['en', 'ig', 'en'] | True |
FreeboxSensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
77,
4
] | [
79,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
FreeboxSensor.name | (self) | Return the name. | Return the name. | def name(self) -> str:
"""Return the name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
82,
4
] | [
84,
25
] | python | en | ['en', 'ig', 'en'] | True |
FreeboxSensor.state | (self) | Return the state. | Return the state. | def state(self) -> str:
"""Return the state."""
return self._state | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_state"
] | [
87,
4
] | [
89,
26
] | python | en | ['en', 'en', 'en'] | True |
FreeboxSensor.unit_of_measurement | (self) | Return the unit. | Return the unit. | def unit_of_measurement(self) -> str:
"""Return the unit."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unit"
] | [
92,
4
] | [
94,
25
] | python | en | ['en', 'sq', 'en'] | True |
FreeboxSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self) -> str:
"""Return the icon."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_icon"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'sr', 'en'] | True |
FreeboxSensor.device_class | (self) | Return the device_class. | Return the device_class. | def device_class(self) -> str:
"""Return the device_class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device_class"
] | [
102,
4
] | [
104,
33
] | python | en | ['en', 'en', 'en'] | True |
FreeboxSensor.device_info | (self) | Return the device information. | Return the device information. | def device_info(self) -> Dict[str, any]:
"""Return the device information."""
return self._router.device_info | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"any",
"]",
":",
"return",
"self",
".",
"_router",
".",
"device_info"
] | [
107,
4
] | [
109,
39
] | python | en | ['en', 'en', 'en'] | True |
FreeboxSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self) -> bool:
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
112,
4
] | [
114,
20
] | python | en | ['en', 'en', 'en'] | True |
FreeboxSensor.async_on_demand_update | (self) | Update state. | Update state. | def async_on_demand_update(self):
"""Update state."""
self.async_update_state()
self.async_write_ha_state() | [
"def",
"async_on_demand_update",
"(",
"self",
")",
":",
"self",
".",
"async_update_state",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
117,
4
] | [
120,
35
] | python | en | ['en', 'co', 'en'] | False |
FreeboxSensor.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self):
"""Register state update callback."""
self.async_update_state()
self.async_on_remove(
async_dispatcher_connect(
self.hass,
self._router.signal_sensor_update,
self.async_on_demand_update,
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_update_state",
"(",
")",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_router",
".",
"signal_sensor_update",
",",
... | [
122,
4
] | [
131,
9
] | python | en | ['en', 'co', 'en'] | True |
FreeboxCallSensor.__init__ | (
self, router: FreeboxRouter, sensor_type: str, sensor: Dict[str, any]
) | Initialize a Freebox call sensor. | Initialize a Freebox call sensor. | def __init__(
self, router: FreeboxRouter, sensor_type: str, sensor: Dict[str, any]
) -> None:
"""Initialize a Freebox call sensor."""
self._call_list_for_type = []
super().__init__(router, sensor_type, sensor) | [
"def",
"__init__",
"(",
"self",
",",
"router",
":",
"FreeboxRouter",
",",
"sensor_type",
":",
"str",
",",
"sensor",
":",
"Dict",
"[",
"str",
",",
"any",
"]",
")",
"->",
"None",
":",
"self",
".",
"_call_list_for_type",
"=",
"[",
"]",
"super",
"(",
")"... | [
137,
4
] | [
142,
53
] | python | en | ['en', 'pt', 'en'] | True |
FreeboxCallSensor.async_update_state | (self) | Update the Freebox call sensor. | Update the Freebox call sensor. | def async_update_state(self) -> None:
"""Update the Freebox call sensor."""
self._call_list_for_type = []
if self._router.call_list:
for call in self._router.call_list:
if not call["new"]:
continue
if call["type"] == self._sensor_ty... | [
"def",
"async_update_state",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_call_list_for_type",
"=",
"[",
"]",
"if",
"self",
".",
"_router",
".",
"call_list",
":",
"for",
"call",
"in",
"self",
".",
"_router",
".",
"call_list",
":",
"if",
"not",
"... | [
145,
4
] | [
155,
51
] | python | en | ['en', 'ig', 'en'] | True |
FreeboxCallSensor.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self) -> Dict[str, any]:
"""Return device specific state attributes."""
return {
dt_util.utc_from_timestamp(call["datetime"]).isoformat(): call["name"]
for call in self._call_list_for_type
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"any",
"]",
":",
"return",
"{",
"dt_util",
".",
"utc_from_timestamp",
"(",
"call",
"[",
"\"datetime\"",
"]",
")",
".",
"isoformat",
"(",
")",
":",
"call",
"[",
"\"name\"",... | [
158,
4
] | [
163,
9
] | python | en | ['fr', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
26,
0
] | [
28,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
32,
0
] | [
34,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
38,
0
] | [
40,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_actions | (hass, device_reg, entity_reg) | Test we get the expected actions from a light. | Test we get the expected actions from a light. | async def test_get_actions(hass, device_reg, entity_reg):
"""Test we get the expected actions from a light."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
conne... | [
"async",
"def",
"test_get_actions",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
43,
0
] | [
97,
38
] | python | en | ['en', 'en', 'en'] | True |
test_get_action_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a light action. | Test we get the expected capabilities from a light action. | async def test_get_action_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a light action."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry... | [
"async",
"def",
"test_get_action_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass... | [
100,
0
] | [
121,
51
] | python | en | ['en', 'en', 'en'] | True |
test_get_action_capabilities_brightness | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a light action. | Test we get the expected capabilities from a light action. | async def test_get_action_capabilities_brightness(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a light action."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=c... | [
"async",
"def",
"test_get_action_capabilities_brightness",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"... | [
124,
0
] | [
160,
55
] | python | en | ['en', 'en', 'en'] | True |
test_get_action_capabilities_flash | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a light action. | Test we get the expected capabilities from a light action. | async def test_get_action_capabilities_flash(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a light action."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config... | [
"async",
"def",
"test_get_action_capabilities_flash",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
... | [
163,
0
] | [
199,
55
] | python | en | ['en', 'en', 'en'] | True |
test_action | (hass, calls) | Test for turn_on and turn_off actions. | Test for turn_on and turn_off actions. | async def test_action(hass, calls):
"""Test for turn_on and turn_off actions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass.async_block_till_done()
ent1, ent2, ent3 = platf... | [
"async",
"def",
"test_action",
"(",
"hass",
",",
"calls",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
... | [
202,
0
] | [
386,
55
] | python | en | ['en', 'en', 'en'] | True |
load_data | (
hass,
url=None,
filepath=None,
username=None,
password=None,
authentication=None,
num_retries=5,
verify_ssl=None,
) | Load data into ByteIO/File container from a source. | Load data into ByteIO/File container from a source. | def load_data(
hass,
url=None,
filepath=None,
username=None,
password=None,
authentication=None,
num_retries=5,
verify_ssl=None,
):
"""Load data into ByteIO/File container from a source."""
try:
if url is not None:
# Load data from URL
params = {"t... | [
"def",
"load_data",
"(",
"hass",
",",
"url",
"=",
"None",
",",
"filepath",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"authentication",
"=",
"None",
",",
"num_retries",
"=",
"5",
",",
"verify_ssl",
"=",
"None",
",",
... | [
237,
0
] | [
289,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Telegram bot component. | Set up the Telegram bot component. | async def async_setup(hass, config):
"""Set up the Telegram bot component."""
if not config[DOMAIN]:
return False
for p_config in config[DOMAIN]:
p_type = p_config.get(CONF_PLATFORM)
platform = importlib.import_module(
".{}".format(p_config[CONF_PLATFORM]), __name__
... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"not",
"config",
"[",
"DOMAIN",
"]",
":",
"return",
"False",
"for",
"p_config",
"in",
"config",
"[",
"DOMAIN",
"]",
":",
"p_type",
"=",
"p_config",
".",
"get",
"(",
"CONF_PLATFO... | [
292,
0
] | [
396,
15
] | python | en | ['en', 'da', 'en'] | True |
initialize_bot | (p_config) | Initialize telegram bot with proxy support. | Initialize telegram bot with proxy support. | def initialize_bot(p_config):
"""Initialize telegram bot with proxy support."""
api_key = p_config.get(CONF_API_KEY)
proxy_url = p_config.get(CONF_PROXY_URL)
proxy_params = p_config.get(CONF_PROXY_PARAMS)
if proxy_url is not None:
request = Request(
con_pool_size=8, proxy_url=p... | [
"def",
"initialize_bot",
"(",
"p_config",
")",
":",
"api_key",
"=",
"p_config",
".",
"get",
"(",
"CONF_API_KEY",
")",
"proxy_url",
"=",
"p_config",
".",
"get",
"(",
"CONF_PROXY_URL",
")",
"proxy_params",
"=",
"p_config",
".",
"get",
"(",
"CONF_PROXY_PARAMS",
... | [
399,
0
] | [
412,
46
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.__init__ | (self, hass, bot, allowed_chat_ids, parser) | Initialize the service. | Initialize the service. | def __init__(self, hass, bot, allowed_chat_ids, parser):
"""Initialize the service."""
self.allowed_chat_ids = allowed_chat_ids
self._default_user = self.allowed_chat_ids[0]
self._last_message_id = {user: None for user in self.allowed_chat_ids}
self._parsers = {PARSER_HTML: Pars... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"bot",
",",
"allowed_chat_ids",
",",
"parser",
")",
":",
"self",
".",
"allowed_chat_ids",
"=",
"allowed_chat_ids",
"self",
".",
"_default_user",
"=",
"self",
".",
"allowed_chat_ids",
"[",
"0",
"]",
"self",
... | [
418,
4
] | [
427,
24
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService._get_msg_ids | (self, msg_data, chat_id) | Get the message id to edit.
This can be one of (message_id, inline_message_id) from a msg dict,
returning a tuple.
**You can use 'last' as message_id** to edit
the message last sent in the chat_id.
| Get the message id to edit. | def _get_msg_ids(self, msg_data, chat_id):
"""Get the message id to edit.
This can be one of (message_id, inline_message_id) from a msg dict,
returning a tuple.
**You can use 'last' as message_id** to edit
the message last sent in the chat_id.
"""
message_id = in... | [
"def",
"_get_msg_ids",
"(",
"self",
",",
"msg_data",
",",
"chat_id",
")",
":",
"message_id",
"=",
"inline_message_id",
"=",
"None",
"if",
"ATTR_MESSAGEID",
"in",
"msg_data",
":",
"message_id",
"=",
"msg_data",
"[",
"ATTR_MESSAGEID",
"]",
"if",
"(",
"isinstance... | [
429,
4
] | [
448,
44
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService._get_target_chat_ids | (self, target) | Validate chat_id targets or return default target (first).
:param target: optional list of integers ([12234, -12345])
:return list of chat_id targets (integers)
| Validate chat_id targets or return default target (first). | def _get_target_chat_ids(self, target):
"""Validate chat_id targets or return default target (first).
:param target: optional list of integers ([12234, -12345])
:return list of chat_id targets (integers)
"""
if target is not None:
if isinstance(target, int):
... | [
"def",
"_get_target_chat_ids",
"(",
"self",
",",
"target",
")",
":",
"if",
"target",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"target",
",",
"int",
")",
":",
"target",
"=",
"[",
"target",
"]",
"chat_ids",
"=",
"[",
"t",
"for",
"t",
"in",
... | [
450,
4
] | [
465,
35
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService._get_msg_kwargs | (self, data) | Get parameters in message data kwargs. | Get parameters in message data kwargs. | def _get_msg_kwargs(self, data):
"""Get parameters in message data kwargs."""
def _make_row_inline_keyboard(row_keyboard):
"""Make a list of InlineKeyboardButtons.
It can accept:
- a list of tuples like:
`[(text_b1, data_callback_b1),
... | [
"def",
"_get_msg_kwargs",
"(",
"self",
",",
"data",
")",
":",
"def",
"_make_row_inline_keyboard",
"(",
"row_keyboard",
")",
":",
"\"\"\"Make a list of InlineKeyboardButtons.\n\n It can accept:\n - a list of tuples like:\n `[(text_b1, data_callback_b... | [
467,
4
] | [
547,
21
] | python | en | ['en', 'en', 'sw'] | True |
TelegramNotificationService._send_msg | (self, func_send, msg_error, *args_msg, **kwargs_msg) | Send one message. | Send one message. | def _send_msg(self, func_send, msg_error, *args_msg, **kwargs_msg):
"""Send one message."""
try:
out = func_send(*args_msg, **kwargs_msg)
if not isinstance(out, bool) and hasattr(out, ATTR_MESSAGEID):
chat_id = out.chat_id
message_id = out[ATTR_ME... | [
"def",
"_send_msg",
"(",
"self",
",",
"func_send",
",",
"msg_error",
",",
"*",
"args_msg",
",",
"*",
"*",
"kwargs_msg",
")",
":",
"try",
":",
"out",
"=",
"func_send",
"(",
"*",
"args_msg",
",",
"*",
"*",
"kwargs_msg",
")",
"if",
"not",
"isinstance",
... | [
549,
4
] | [
580,
13
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.send_message | (self, message="", target=None, **kwargs) | Send a message to one or multiple pre-allowed chat IDs. | Send a message to one or multiple pre-allowed chat IDs. | def send_message(self, message="", target=None, **kwargs):
"""Send a message to one or multiple pre-allowed chat IDs."""
title = kwargs.get(ATTR_TITLE)
text = f"{title}\n{message}" if title else message
params = self._get_msg_kwargs(kwargs)
for chat_id in self._get_target_chat_id... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"target",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"title",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
")",
"text",
"=",
"f\"{title}\\n{message}\"",
"if",
"title",
"else",
... | [
582,
4
] | [
591,
13
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.delete_message | (self, chat_id=None, **kwargs) | Delete a previously sent message. | Delete a previously sent message. | def delete_message(self, chat_id=None, **kwargs):
"""Delete a previously sent message."""
chat_id = self._get_target_chat_ids(chat_id)[0]
message_id, _ = self._get_msg_ids(kwargs, chat_id)
_LOGGER.debug("Delete message %s in chat ID %s", message_id, chat_id)
deleted = self._send_... | [
"def",
"delete_message",
"(",
"self",
",",
"chat_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"chat_id",
"=",
"self",
".",
"_get_target_chat_ids",
"(",
"chat_id",
")",
"[",
"0",
"]",
"message_id",
",",
"_",
"=",
"self",
".",
"_get_msg_ids",
"("... | [
593,
4
] | [
605,
22
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.edit_message | (self, type_edit, chat_id=None, **kwargs) | Edit a previously sent message. | Edit a previously sent message. | def edit_message(self, type_edit, chat_id=None, **kwargs):
"""Edit a previously sent message."""
chat_id = self._get_target_chat_ids(chat_id)[0]
message_id, inline_message_id = self._get_msg_ids(kwargs, chat_id)
params = self._get_msg_kwargs(kwargs)
_LOGGER.debug(
"Ed... | [
"def",
"edit_message",
"(",
"self",
",",
"type_edit",
",",
"chat_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"chat_id",
"=",
"self",
".",
"_get_target_chat_ids",
"(",
"chat_id",
")",
"[",
"0",
"]",
"message_id",
",",
"inline_message_id",
"=",
"s... | [
607,
4
] | [
644,
9
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.answer_callback_query | (
self, message, callback_query_id, show_alert=False, **kwargs
) | Answer a callback originated with a press in an inline keyboard. | Answer a callback originated with a press in an inline keyboard. | def answer_callback_query(
self, message, callback_query_id, show_alert=False, **kwargs
):
"""Answer a callback originated with a press in an inline keyboard."""
params = self._get_msg_kwargs(kwargs)
_LOGGER.debug(
"Answer callback query with callback ID %s: %s, alert: %s... | [
"def",
"answer_callback_query",
"(",
"self",
",",
"message",
",",
"callback_query_id",
",",
"show_alert",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"self",
".",
"_get_msg_kwargs",
"(",
"kwargs",
")",
"_LOGGER",
".",
"debug",
"(",
"\"A... | [
646,
4
] | [
664,
9
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.send_file | (self, file_type=SERVICE_SEND_PHOTO, target=None, **kwargs) | Send a photo, sticker, video, or document. | Send a photo, sticker, video, or document. | def send_file(self, file_type=SERVICE_SEND_PHOTO, target=None, **kwargs):
"""Send a photo, sticker, video, or document."""
params = self._get_msg_kwargs(kwargs)
caption = kwargs.get(ATTR_CAPTION)
func_send = {
SERVICE_SEND_PHOTO: self.bot.sendPhoto,
SERVICE_SEND_S... | [
"def",
"send_file",
"(",
"self",
",",
"file_type",
"=",
"SERVICE_SEND_PHOTO",
",",
"target",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"self",
".",
"_get_msg_kwargs",
"(",
"kwargs",
")",
"caption",
"=",
"kwargs",
".",
"get",
"(",
"... | [
666,
4
] | [
698,
68
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.send_location | (self, latitude, longitude, target=None, **kwargs) | Send a location. | Send a location. | def send_location(self, latitude, longitude, target=None, **kwargs):
"""Send a location."""
latitude = float(latitude)
longitude = float(longitude)
params = self._get_msg_kwargs(kwargs)
for chat_id in self._get_target_chat_ids(target):
_LOGGER.debug(
"... | [
"def",
"send_location",
"(",
"self",
",",
"latitude",
",",
"longitude",
",",
"target",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"latitude",
"=",
"float",
"(",
"latitude",
")",
"longitude",
"=",
"float",
"(",
"longitude",
")",
"params",
"=",
"sel... | [
700,
4
] | [
716,
13
] | python | en | ['en', 'zh', 'en'] | True |
TelegramNotificationService.leave_chat | (self, chat_id=None) | Remove bot from chat. | Remove bot from chat. | def leave_chat(self, chat_id=None):
"""Remove bot from chat."""
chat_id = self._get_target_chat_ids(chat_id)[0]
_LOGGER.debug("Leave from chat ID %s", chat_id)
leaved = self._send_msg(self.bot.leaveChat, "Error leaving chat", chat_id)
return leaved | [
"def",
"leave_chat",
"(",
"self",
",",
"chat_id",
"=",
"None",
")",
":",
"chat_id",
"=",
"self",
".",
"_get_target_chat_ids",
"(",
"chat_id",
")",
"[",
"0",
"]",
"_LOGGER",
".",
"debug",
"(",
"\"Leave from chat ID %s\"",
",",
"chat_id",
")",
"leaved",
"=",... | [
718,
4
] | [
723,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseTelegramBotEntity.__init__ | (self, hass, allowed_chat_ids) | Initialize the bot base class. | Initialize the bot base class. | def __init__(self, hass, allowed_chat_ids):
"""Initialize the bot base class."""
self.allowed_chat_ids = allowed_chat_ids
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"allowed_chat_ids",
")",
":",
"self",
".",
"allowed_chat_ids",
"=",
"allowed_chat_ids",
"self",
".",
"hass",
"=",
"hass"
] | [
729,
4
] | [
732,
24
] | python | en | ['en', 'en', 'en'] | True |
BaseTelegramBotEntity._get_message_data | (self, msg_data) | Return boolean msg_data_is_ok and dict msg_data. | Return boolean msg_data_is_ok and dict msg_data. | def _get_message_data(self, msg_data):
"""Return boolean msg_data_is_ok and dict msg_data."""
if not msg_data:
return False, None
bad_fields = (
"text" not in msg_data and "data" not in msg_data and "chat" not in msg_data
)
if bad_fields or "from" not in m... | [
"def",
"_get_message_data",
"(",
"self",
",",
"msg_data",
")",
":",
"if",
"not",
"msg_data",
":",
"return",
"False",
",",
"None",
"bad_fields",
"=",
"(",
"\"text\"",
"not",
"in",
"msg_data",
"and",
"\"data\"",
"not",
"in",
"msg_data",
"and",
"\"chat\"",
"n... | [
734,
4
] | [
767,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseTelegramBotEntity.process_message | (self, data) | Check for basic message rules and fire an event if message is ok. | Check for basic message rules and fire an event if message is ok. | def process_message(self, data):
"""Check for basic message rules and fire an event if message is ok."""
if ATTR_MSG in data or ATTR_EDITED_MSG in data:
event = EVENT_TELEGRAM_COMMAND
if ATTR_MSG in data:
data = data.get(ATTR_MSG)
else:
... | [
"def",
"process_message",
"(",
"self",
",",
"data",
")",
":",
"if",
"ATTR_MSG",
"in",
"data",
"or",
"ATTR_EDITED_MSG",
"in",
"data",
":",
"event",
"=",
"EVENT_TELEGRAM_COMMAND",
"if",
"ATTR_MSG",
"in",
"data",
":",
"data",
"=",
"data",
".",
"get",
"(",
"... | [
769,
4
] | [
821,
19
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up Tahoma controller devices. | Set up Tahoma controller devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Tahoma controller devices."""
if discovery_info is None:
return
_LOGGER.debug("Setup Tahoma Binary sensor platform")
controller = hass.data[TAHOMA_DOMAIN]["controller"]
devices = []
for device in hass.data[TAH... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"_LOGGER",
".",
"debug",
"(",
"\"Setup Tahoma Binary sensor platform\"",
")",
"controller",... | [
17,
0
] | [
26,
31
] | python | en | ['oc', 'en', 'en'] | True |
TahomaBinarySensor.__init__ | (self, tahoma_device, controller) | Initialize the sensor. | Initialize the sensor. | def __init__(self, tahoma_device, controller):
"""Initialize the sensor."""
super().__init__(tahoma_device, controller)
self._state = None
self._icon = None
self._battery = None
self._available = False | [
"def",
"__init__",
"(",
"self",
",",
"tahoma_device",
",",
"controller",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"tahoma_device",
",",
"controller",
")",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_icon",
"=",
"None",
"self",
".",
"_b... | [
32,
4
] | [
39,
31
] | python | en | ['en', 'en', 'en'] | True |
TahomaBinarySensor.is_on | (self) | Return the state of the sensor. | Return the state of the sensor. | def is_on(self):
"""Return the state of the sensor."""
return bool(self._state == STATE_ON) | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_state",
"==",
"STATE_ON",
")"
] | [
42,
4
] | [
44,
44
] | python | en | ['en', 'en', 'en'] | True |
TahomaBinarySensor.device_class | (self) | Return the class of the device. | Return the class of the device. | def device_class(self):
"""Return the class of the device."""
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
return DEVICE_CLASS_SMOKE
return None | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"tahoma_device",
".",
"type",
"==",
"\"rtds:RTDSSmokeSensor\"",
":",
"return",
"DEVICE_CLASS_SMOKE",
"return",
"None"
] | [
47,
4
] | [
51,
19
] | python | en | ['en', 'en', 'en'] | True |
TahomaBinarySensor.icon | (self) | Icon for device by its type. | Icon for device by its type. | def icon(self):
"""Icon for device by its type."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
54,
4
] | [
56,
25
] | python | en | ['en', 'en', 'en'] | True |
TahomaBinarySensor.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
attr = {}
super_attr = super().device_state_attributes
if super_attr is not None:
attr.update(super_attr)
if self._battery is not None:
attr[ATTR_BATTERY_LEVEL] = self._battery
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"super_attr",
"=",
"super",
"(",
")",
".",
"device_state_attributes",
"if",
"super_attr",
"is",
"not",
"None",
":",
"attr",
".",
"update",
"(",
"super_attr",
")",
"if",
"self",... | [
59,
4
] | [
68,
19
] | python | en | ['en', 'en', 'en'] | True |
TahomaBinarySensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
71,
4
] | [
73,
30
] | python | en | ['en', 'en', 'en'] | True |
TahomaBinarySensor.update | (self) | Update the state. | Update the state. | def update(self):
"""Update the state."""
self.controller.get_states([self.tahoma_device])
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
if self.tahoma_device.active_states["core:SmokeState"] == "notDetected":
self._state = STATE_OFF
else:
... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"controller",
".",
"get_states",
"(",
"[",
"self",
".",
"tahoma_device",
"]",
")",
"if",
"self",
".",
"tahoma_device",
".",
"type",
"==",
"\"rtds:RTDSSmokeSensor\"",
":",
"if",
"self",
".",
"tahoma_devic... | [
75,
4
] | [
99,
70
] | python | en | ['en', 'en', 'en'] | True |
get_order_data | (experiment_name: str, episode: str, tick: str) | Get the order data within one tick.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
tick (str): Number of tick of expected data.
Returns:
Dataframe: Formatted order value of current tick.
... | Get the order data within one tick. | def get_order_data(experiment_name: str, episode: str, tick: str) -> pd.DataFrame:
"""Get the order data within one tick.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
tick (str): Number of tick of e... | [
"def",
"get_order_data",
"(",
"experiment_name",
":",
"str",
",",
"episode",
":",
"str",
",",
"tick",
":",
"str",
")",
"->",
"pd",
".",
"DataFrame",
":",
"params",
"=",
"{",
"\"query\"",
":",
"f\"select {request_column.order_header.value} from {experiment_name}.full... | [
12,
0
] | [
35,
21
] | python | en | ['en', 'en', 'en'] | True |
get_acc_order_data | (experiment_name: str, episode: str, start_tick: str, end_tick: str) | Get the order data within a range.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
start_tick (str): Number of tick to the start point of order data.
end_tick(str): Number of tick to the end point ... | Get the order data within a range. | def get_acc_order_data(experiment_name: str, episode: str, start_tick: str, end_tick: str) -> json:
"""Get the order data within a range.
Args:
experiment_name (str): Name of the experiment expected to be displayed.
episode (str) : Number of the episode of expected data.
start_tick (str... | [
"def",
"get_acc_order_data",
"(",
"experiment_name",
":",
"str",
",",
"episode",
":",
"str",
",",
"start_tick",
":",
"str",
",",
"end_tick",
":",
"str",
")",
"->",
"json",
":",
"input_range",
"=",
"get_input_range",
"(",
"start_tick",
",",
"end_tick",
")",
... | [
38,
0
] | [
73,
23
] | python | en | ['en', 'en', 'en'] | True |
AbstractCommon.define_variable_properties | (self, ndim, output_lists, variable_list) | Bounds are defined in this class, where all the Planet-related
variables are stored
Bounds and parameter index CANNOT be defined in the Common class:
we don't know a priori which parameters
will be actually used in the complete model.
| Bounds are defined in this class, where all the Planet-related
variables are stored
Bounds and parameter index CANNOT be defined in the Common class:
we don't know a priori which parameters
will be actually used in the complete model.
| def define_variable_properties(self, ndim, output_lists, variable_list):
""" Bounds are defined in this class, where all the Planet-related
variables are stored
Bounds and parameter index CANNOT be defined in the Common class:
we don't know a priori which parameters
... | [
"def",
"define_variable_properties",
"(",
"self",
",",
"ndim",
",",
"output_lists",
",",
"variable_list",
")",
":",
"for",
"var",
"in",
"list",
"(",
"set",
"(",
"variable_list",
")",
"&",
"set",
"(",
"self",
".",
"list_pams",
")",
")",
":",
"\"\"\"We check... | [
38,
4
] | [
116,
33
] | python | en | ['en', 'en', 'en'] | True |
AbstractCommon.return_priors | (self, theta) | Compute the prior probability for a given set of input parameters
return_priors is defined in the common models because, differently
from other functions that can be executed more than once on the same
variable, the prior for a given parameter should be computed and added
to the log_chi... | Compute the prior probability for a given set of input parameters | def return_priors(self, theta):
"""Compute the prior probability for a given set of input parameters
return_priors is defined in the common models because, differently
from other functions that can be executed more than once on the same
variable, the prior for a given parameter should b... | [
"def",
"return_priors",
"(",
"self",
",",
"theta",
")",
":",
"prior_out",
"=",
"0.00",
"variable_value",
"=",
"self",
".",
"convert",
"(",
"theta",
")",
"\"\"\" The first time this subroutine is called, the KDE is computed\n for those variables where a \n \"\"... | [
143,
4
] | [
170,
24
] | python | en | ['en', 'en', 'en'] | True |
load_from_folder | (source_folder: str) | Load data from dump folder.
NOTE:
Dumps folder should contains following files:
ports.csv, vessels.csv, routes.csv, order_proportion.csv,
global_order_proportion.txt, misc.yml, stops.bin.
Args:
source_folder(str): Source folder container dumped files.
Returns:
CimDataColle... | Load data from dump folder. | def load_from_folder(source_folder: str) -> CimDataCollection:
"""Load data from dump folder.
NOTE:
Dumps folder should contains following files:
ports.csv, vessels.csv, routes.csv, order_proportion.csv,
global_order_proportion.txt, misc.yml, stops.bin.
Args:
source_folder(str): So... | [
"def",
"load_from_folder",
"(",
"source_folder",
":",
"str",
")",
"->",
"CimDataCollection",
":",
"loader",
"=",
"CimDumpDataLoader",
"(",
")",
"return",
"loader",
".",
"load",
"(",
"source_folder",
")"
] | [
233,
0
] | [
249,
37
] | python | en | ['en', 'no', 'en'] | True |
CimDumpDataLoader.load | (self, dumps_folder: str) | Load data from dump folder
NOTE:
dumps folder should contains following files.
ports.csv, vessels.csv, routes.csv, order_proportion.csv,
global_order_proportion.txt, misc.yml, stops.bin
Args:
dumps_folders(str): folder that contains dumped files
Returns:
... | Load data from dump folder | def load(self, dumps_folder: str) -> CimDataCollection:
"""Load data from dump folder
NOTE:
dumps folder should contains following files.
ports.csv, vessels.csv, routes.csv, order_proportion.csv,
global_order_proportion.txt, misc.yml, stops.bin
Args:
dumps_f... | [
"def",
"load",
"(",
"self",
",",
"dumps_folder",
":",
"str",
")",
"->",
"CimDataCollection",
":",
"# load from files",
"misc_items",
"=",
"self",
".",
"_load_misc",
"(",
"dumps_folder",
")",
"order_target_proportion",
"=",
"self",
".",
"_load_order_proportions",
"... | [
20,
4
] | [
65,
30
] | python | en | ['en', 'no', 'en'] | True |
CimDumpDataLoader._load_misc | (self, dumps_folder: str) | Load misc items from yaml | Load misc items from yaml | def _load_misc(self, dumps_folder: str) -> dict:
"""Load misc items from yaml"""
misc_file_path = os.path.join(dumps_folder, "misc.yml")
for _ in range(3):
if not os.path.exists(misc_file_path):
time.sleep(10)
with open(misc_file_path, "rt") as fp:
... | [
"def",
"_load_misc",
"(",
"self",
",",
"dumps_folder",
":",
"str",
")",
"->",
"dict",
":",
"misc_file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dumps_folder",
",",
"\"misc.yml\"",
")",
"for",
"_",
"in",
"range",
"(",
"3",
")",
":",
"if",
"not... | [
67,
4
] | [
74,
32
] | python | en | ['en', 'en', 'en'] | True |
CimDumpDataLoader._load_global_order_proportions | (self, dumps_folder: str) | load global order proportions from txt file | load global order proportions from txt file | def _load_global_order_proportions(self, dumps_folder: str) -> np.ndarray:
"""load global order proportions from txt file"""
global_order_prop_file = os.path.join(
dumps_folder, "global_order_proportion.txt")
return np.loadtxt(global_order_prop_file) | [
"def",
"_load_global_order_proportions",
"(",
"self",
",",
"dumps_folder",
":",
"str",
")",
"->",
"np",
".",
"ndarray",
":",
"global_order_prop_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dumps_folder",
",",
"\"global_order_proportion.txt\"",
")",
"return",
... | [
76,
4
] | [
81,
49
] | python | en | ['en', 'en', 'en'] | True |
CimDumpDataLoader._read_csv_lines | (self, file_path: str) | Helper to read and yield line from csv file | Helper to read and yield line from csv file | def _read_csv_lines(self, file_path: str):
"""Helper to read and yield line from csv file"""
for _ in range(3):
if not os.path.exists(file_path):
time.sleep(10)
with open(file_path, "rt") as fp:
reader = csv.DictReader(fp)
for line in reader:
... | [
"def",
"_read_csv_lines",
"(",
"self",
",",
"file_path",
":",
"str",
")",
":",
"for",
"_",
"in",
"range",
"(",
"3",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"file_path",
")",
":",
"time",
".",
"sleep",
"(",
"10",
")",
"with",... | [
83,
4
] | [
92,
26
] | 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.