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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_extract_referenced_entity_ids | (
hass: HomeAssistant, service_call: ServiceCall, expand_group: bool = True
) | Extract referenced entity IDs from a service call. | Extract referenced entity IDs from a service call. | async def async_extract_referenced_entity_ids(
hass: HomeAssistant, service_call: ServiceCall, expand_group: bool = True
) -> SelectedEntities:
"""Extract referenced entity IDs from a service call."""
selector = ServiceTargetSelector(service_call)
selected = SelectedEntities()
if not selector.has_a... | [
"async",
"def",
"async_extract_referenced_entity_ids",
"(",
"hass",
":",
"HomeAssistant",
",",
"service_call",
":",
"ServiceCall",
",",
"expand_group",
":",
"bool",
"=",
"True",
")",
"->",
"SelectedEntities",
":",
"selector",
"=",
"ServiceTargetSelector",
"(",
"serv... | [
324,
0
] | [
378,
19
] | python | en | ['en', 'en', 'en'] | True |
async_extract_config_entry_ids | (
hass: HomeAssistant, service_call: ServiceCall, expand_group: bool = True
) | Extract referenced config entry ids from a service call. | Extract referenced config entry ids from a service call. | async def async_extract_config_entry_ids(
hass: HomeAssistant, service_call: ServiceCall, expand_group: bool = True
) -> set:
"""Extract referenced config entry ids from a service call."""
referenced = await async_extract_referenced_entity_ids(
hass, service_call, expand_group
)
ent_reg = en... | [
"async",
"def",
"async_extract_config_entry_ids",
"(",
"hass",
":",
"HomeAssistant",
",",
"service_call",
":",
"ServiceCall",
",",
"expand_group",
":",
"bool",
"=",
"True",
")",
"->",
"set",
":",
"referenced",
"=",
"await",
"async_extract_referenced_entity_ids",
"("... | [
382,
0
] | [
405,
27
] | python | en | ['en', 'en', 'en'] | True |
_load_services_file | (hass: HomeAssistant, integration: Integration) | Load services file for an integration. | Load services file for an integration. | def _load_services_file(hass: HomeAssistant, integration: Integration) -> JSON_TYPE:
"""Load services file for an integration."""
try:
return load_yaml(str(integration.file_path / "services.yaml"))
except FileNotFoundError:
_LOGGER.warning(
"Unable to find services.yaml for the %... | [
"def",
"_load_services_file",
"(",
"hass",
":",
"HomeAssistant",
",",
"integration",
":",
"Integration",
")",
"->",
"JSON_TYPE",
":",
"try",
":",
"return",
"load_yaml",
"(",
"str",
"(",
"integration",
".",
"file_path",
"/",
"\"services.yaml\"",
")",
")",
"exce... | [
408,
0
] | [
421,
17
] | python | en | ['en', 'en', 'en'] | True |
_load_services_files | (
hass: HomeAssistant, integrations: Iterable[Integration]
) | Load service files for multiple intergrations. | Load service files for multiple intergrations. | def _load_services_files(
hass: HomeAssistant, integrations: Iterable[Integration]
) -> list[JSON_TYPE]:
"""Load service files for multiple intergrations."""
return [_load_services_file(hass, integration) for integration in integrations] | [
"def",
"_load_services_files",
"(",
"hass",
":",
"HomeAssistant",
",",
"integrations",
":",
"Iterable",
"[",
"Integration",
"]",
")",
"->",
"list",
"[",
"JSON_TYPE",
"]",
":",
"return",
"[",
"_load_services_file",
"(",
"hass",
",",
"integration",
")",
"for",
... | [
424,
0
] | [
428,
83
] | python | en | ['en', 'en', 'en'] | True |
async_get_all_descriptions | (
hass: HomeAssistant,
) | Return descriptions (i.e. user documentation) for all service calls. | Return descriptions (i.e. user documentation) for all service calls. | async def async_get_all_descriptions(
hass: HomeAssistant,
) -> dict[str, dict[str, Any]]:
"""Return descriptions (i.e. user documentation) for all service calls."""
descriptions_cache = hass.data.setdefault(SERVICE_DESCRIPTION_CACHE, {})
format_cache_key = "{}.{}".format
services = hass.services.as... | [
"async",
"def",
"async_get_all_descriptions",
"(",
"hass",
":",
"HomeAssistant",
",",
")",
"->",
"dict",
"[",
"str",
",",
"dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"descriptions_cache",
"=",
"hass",
".",
"data",
".",
"setdefault",
"(",
"SERVICE_DESCRI... | [
432,
0
] | [
495,
23
] | python | en | ['en', 'pt', 'en'] | True |
async_set_service_schema | (
hass: HomeAssistant, domain: str, service: str, schema: dict[str, Any]
) | Register a description for a service. | Register a description for a service. | def async_set_service_schema(
hass: HomeAssistant, domain: str, service: str, schema: dict[str, Any]
) -> None:
"""Register a description for a service."""
hass.data.setdefault(SERVICE_DESCRIPTION_CACHE, {})
description = {
"name": schema.get("name", ""),
"description": schema.get("desc... | [
"def",
"async_set_service_schema",
"(",
"hass",
":",
"HomeAssistant",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"schema",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
... | [
500,
0
] | [
515,
77
] | python | en | ['es', 'fr', 'en'] | False |
entity_service_call | (
hass: HomeAssistant,
platforms: Iterable[EntityPlatform],
func: str | Callable[..., Any],
call: ServiceCall,
required_features: Iterable[int] | None = None,
) | Handle an entity service call.
Calls all platforms simultaneously.
| Handle an entity service call. | async def entity_service_call(
hass: HomeAssistant,
platforms: Iterable[EntityPlatform],
func: str | Callable[..., Any],
call: ServiceCall,
required_features: Iterable[int] | None = None,
) -> None:
"""Handle an entity service call.
Calls all platforms simultaneously.
"""
if call.co... | [
"async",
"def",
"entity_service_call",
"(",
"hass",
":",
"HomeAssistant",
",",
"platforms",
":",
"Iterable",
"[",
"EntityPlatform",
"]",
",",
"func",
":",
"str",
"|",
"Callable",
"[",
"...",
",",
"Any",
"]",
",",
"call",
":",
"ServiceCall",
",",
"required_... | [
519,
0
] | [
674,
27
] | python | en | ['en', 'en', 'en'] | True |
_handle_entity_call | (
hass: HomeAssistant,
entity: Entity,
func: str | Callable[..., Any],
data: dict | ServiceCall,
context: Context,
) | Handle calling service method. | Handle calling service method. | async def _handle_entity_call(
hass: HomeAssistant,
entity: Entity,
func: str | Callable[..., Any],
data: dict | ServiceCall,
context: Context,
) -> None:
"""Handle calling service method."""
entity.async_set_context(context)
if isinstance(func, str):
result = hass.async_run_job... | [
"async",
"def",
"_handle_entity_call",
"(",
"hass",
":",
"HomeAssistant",
",",
"entity",
":",
"Entity",
",",
"func",
":",
"str",
"|",
"Callable",
"[",
"...",
",",
"Any",
"]",
",",
"data",
":",
"dict",
"|",
"ServiceCall",
",",
"context",
":",
"Context",
... | [
677,
0
] | [
702,
20
] | python | en | ['en', 'xh', 'en'] | True |
async_register_admin_service | (
hass: HomeAssistant,
domain: str,
service: str,
service_func: Callable[[ServiceCall], Awaitable | None],
schema: vol.Schema = vol.Schema({}, extra=vol.PREVENT_EXTRA),
) | Register a service that requires admin access. | Register a service that requires admin access. | def async_register_admin_service(
hass: HomeAssistant,
domain: str,
service: str,
service_func: Callable[[ServiceCall], Awaitable | None],
schema: vol.Schema = vol.Schema({}, extra=vol.PREVENT_EXTRA),
) -> None:
"""Register a service that requires admin access."""
@wraps(service_func)
a... | [
"def",
"async_register_admin_service",
"(",
"hass",
":",
"HomeAssistant",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"service_func",
":",
"Callable",
"[",
"[",
"ServiceCall",
"]",
",",
"Awaitable",
"|",
"None",
"]",
",",
"schema",
":",
"vo... | [
707,
0
] | [
729,
72
] | python | en | ['en', 'en', 'en'] | True |
verify_domain_control | (
hass: HomeAssistant, domain: str
) | Ensure permission to access any entity under domain in service call. | Ensure permission to access any entity under domain in service call. | def verify_domain_control(
hass: HomeAssistant, domain: str
) -> Callable[[Callable[[ServiceCall], Any]], Callable[[ServiceCall], Any]]:
"""Ensure permission to access any entity under domain in service call."""
def decorator(
service_handler: Callable[[ServiceCall], Any]
) -> Callable[[Service... | [
"def",
"verify_domain_control",
"(",
"hass",
":",
"HomeAssistant",
",",
"domain",
":",
"str",
")",
"->",
"Callable",
"[",
"[",
"Callable",
"[",
"[",
"ServiceCall",
"]",
",",
"Any",
"]",
"]",
",",
"Callable",
"[",
"[",
"ServiceCall",
"]",
",",
"Any",
"]... | [
734,
0
] | [
784,
20
] | python | en | ['en', 'en', 'en'] | True |
ServiceTargetSelector.__init__ | (self, service_call: ServiceCall) | Extract ids from service call data. | Extract ids from service call data. | def __init__(self, service_call: ServiceCall) -> None:
"""Extract ids from service call data."""
entity_ids: str | list | None = service_call.data.get(ATTR_ENTITY_ID)
device_ids: str | list | None = service_call.data.get(ATTR_DEVICE_ID)
area_ids: str | list | None = service_call.data.get... | [
"def",
"__init__",
"(",
"self",
",",
"service_call",
":",
"ServiceCall",
")",
"->",
"None",
":",
"entity_ids",
":",
"str",
"|",
"list",
"|",
"None",
"=",
"service_call",
".",
"data",
".",
"get",
"(",
"ATTR_ENTITY_ID",
")",
"device_ids",
":",
"str",
"|",
... | [
75,
4
] | [
87,
88
] | python | en | ['en', 'en', 'en'] | True |
ServiceTargetSelector.has_any_selector | (self) | Determine if any selectors are present. | Determine if any selectors are present. | def has_any_selector(self) -> bool:
"""Determine if any selectors are present."""
return bool(self.entity_ids or self.device_ids or self.area_ids) | [
"def",
"has_any_selector",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"self",
".",
"entity_ids",
"or",
"self",
".",
"device_ids",
"or",
"self",
".",
"area_ids",
")"
] | [
90,
4
] | [
92,
72
] | python | en | ['en', 'en', 'en'] | True |
ReloadServiceHelper.__init__ | (self, service_func: Callable[[ServiceCall], Awaitable]) | Initialize ReloadServiceHelper. | Initialize ReloadServiceHelper. | def __init__(self, service_func: Callable[[ServiceCall], Awaitable]) -> None:
"""Initialize ReloadServiceHelper."""
self._service_func = service_func
self._service_running = False
self._service_condition = asyncio.Condition() | [
"def",
"__init__",
"(",
"self",
",",
"service_func",
":",
"Callable",
"[",
"[",
"ServiceCall",
"]",
",",
"Awaitable",
"]",
")",
"->",
"None",
":",
"self",
".",
"_service_func",
"=",
"service_func",
"self",
".",
"_service_running",
"=",
"False",
"self",
"."... | [
790,
4
] | [
794,
53
] | python | en | ['en', 'co', 'en'] | False |
ReloadServiceHelper.execute_service | (self, service_call: ServiceCall) | Execute the service.
If a previous reload task if currently in progress, wait for it to finish first.
Once the previous reload task has finished, one of the waiting tasks will be
assigned to execute the reload, the others will wait for the reload to finish.
| Execute the service. | async def execute_service(self, service_call: ServiceCall) -> None:
"""Execute the service.
If a previous reload task if currently in progress, wait for it to finish first.
Once the previous reload task has finished, one of the waiting tasks will be
assigned to execute the reload, the o... | [
"async",
"def",
"execute_service",
"(",
"self",
",",
"service_call",
":",
"ServiceCall",
")",
"->",
"None",
":",
"do_reload",
"=",
"False",
"async",
"with",
"self",
".",
"_service_condition",
":",
"if",
"self",
".",
"_service_running",
":",
"# A previous reload ... | [
796,
4
] | [
824,
52
] | python | en | ['en', 'en', 'en'] | True |
process_turn_on_params | (
siren: SirenEntity, params: SirenTurnOnServiceParameters
) |
Process turn_on service params.
Filters out unsupported params and validates the rest.
|
Process turn_on service params. | def process_turn_on_params(
siren: SirenEntity, params: SirenTurnOnServiceParameters
) -> SirenTurnOnServiceParameters:
"""
Process turn_on service params.
Filters out unsupported params and validates the rest.
"""
supported_features = siren.supported_features or 0
if not supported_feature... | [
"def",
"process_turn_on_params",
"(",
"siren",
":",
"SirenEntity",
",",
"params",
":",
"SirenTurnOnServiceParameters",
")",
"->",
"SirenTurnOnServiceParameters",
":",
"supported_features",
"=",
"siren",
".",
"supported_features",
"or",
"0",
"if",
"not",
"supported_featu... | [
54,
0
] | [
95,
17
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up siren devices. | Set up siren devices. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up siren devices."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
async def async_handle_turn_on_service(
siren: SirenEntity,... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"component",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
","... | [
98,
0
] | [
128,
15
] | python | en | ['eu', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up a config entry. | Set up a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
component: EntityComponent = hass.data[DOMAIN]
return await component.async_setup_entry(entry) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"component",
":",
"EntityComponent",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"return",
"await",
"component",
".",
"async_s... | [
131,
0
] | [
134,
51
] | 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) -> bool:
"""Unload a config entry."""
component: EntityComponent = hass.data[DOMAIN]
return await component.async_unload_entry(entry) | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"component",
":",
"EntityComponent",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"return",
"await",
"component",
".",
"async_... | [
137,
0
] | [
140,
52
] | python | en | ['en', 'es', 'en'] | True |
SirenEntity.capability_attributes | (self) | Return capability attributes. | Return capability attributes. | def capability_attributes(self) -> dict[str, Any] | None:
"""Return capability attributes."""
supported_features = self.supported_features or 0
if supported_features & SUPPORT_TONES and self.available_tones is not None:
return {ATTR_AVAILABLE_TONES: self.available_tones}
re... | [
"def",
"capability_attributes",
"(",
"self",
")",
"->",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
":",
"supported_features",
"=",
"self",
".",
"supported_features",
"or",
"0",
"if",
"supported_features",
"&",
"SUPPORT_TONES",
"and",
"self",
".",
"ava... | [
156,
4
] | [
163,
19
] | python | en | ['en', 'la', 'en'] | True |
SirenEntity.available_tones | (self) |
Return a list of available tones.
Requires SUPPORT_TONES.
|
Return a list of available tones. | def available_tones(self) -> list[int | str] | dict[int, str] | None:
"""
Return a list of available tones.
Requires SUPPORT_TONES.
"""
return self._attr_available_tones | [
"def",
"available_tones",
"(",
"self",
")",
"->",
"list",
"[",
"int",
"|",
"str",
"]",
"|",
"dict",
"[",
"int",
",",
"str",
"]",
"|",
"None",
":",
"return",
"self",
".",
"_attr_available_tones"
] | [
166,
4
] | [
172,
41
] | python | en | ['en', 'error', 'th'] | False |
setup | (hass, config) | Set up the QVR Pro component. | Set up the QVR Pro component. | def setup(hass, config):
"""Set up the QVR Pro component."""
conf = config[DOMAIN]
user = conf[CONF_USERNAME]
password = conf[CONF_PASSWORD]
host = conf[CONF_HOST]
port = conf[CONF_PORT]
excluded_channels = conf[CONF_EXCLUDE_CHANNELS]
try:
qvrpro = Client(user, password, host, p... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"user",
"=",
"conf",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"conf",
"[",
"CONF_PASSWORD",
"]",
"host",
"=",
"conf",
"[",
"CONF_HOST",
"]",
"port",
"... | [
49,
0
] | [
107,
15
] | python | en | ['en', 'fr', 'en'] | True |
Category.openapi_types | () |
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
|
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded | def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
retu... | [
"def",
"openapi_types",
"(",
")",
":",
"return",
"{",
"'name'",
":",
"(",
"str",
",",
")",
",",
"# noqa: E501",
"'id'",
":",
"(",
"int",
",",
")",
",",
"# noqa: E501",
"}"
] | [
64,
4
] | [
76,
9
] | python | en | ['en', 'error', 'th'] | False |
Category.__init__ | (self, *args, **kwargs) | Category - a model defined in OpenAPI
Args:
Keyword Args:
name (str): defaults to "default-name" # noqa: E501
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
... | Category - a model defined in OpenAPI | def __init__(self, *args, **kwargs): # noqa: E501
"""Category - a model defined in OpenAPI
Args:
Keyword Args:
name (str): defaults to "default-name" # noqa: E501
_check_type (bool): if True, values for parameters in openapi_types
will ... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
",",
"\"default-name\"",
")",
"_check_type",
"=",
"kwargs",
".",
"pop",
"(",
"'_check_type'",
",",
"T... | [
100,
4
] | [
172,
46
] | python | en | ['en', 'en', 'en'] | True |
TestEnumClass.testEnumClass | (self) | Test EnumClass | Test EnumClass | def testEnumClass(self):
"""Test EnumClass"""
# FIXME: construct object with mandatory attributes with example values
# model = EnumClass() # noqa: E501
pass | [
"def",
"testEnumClass",
"(",
"self",
")",
":",
"# FIXME: construct object with mandatory attributes with example values",
"# model = EnumClass() # noqa: E501",
"pass"
] | [
28,
4
] | [
32,
12
] | python | en | ['en', 'fy', 'ur'] | False |
async_setup_entry | (hass, entry, async_add_entities) | Set up EcoNet water heater based on a config entry. | Set up EcoNet water heater based on a config entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up EcoNet water heater based on a config entry."""
equipment = hass.data[DOMAIN][EQUIPMENT][entry.entry_id]
async_add_entities(
[
EcoNetWaterHeater(water_heater)
for water_heater in equipment[EquipmentType.W... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"equipment",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"EQUIPMENT",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"async_add_entities",
"(",
"[",
"EcoN... | [
41,
0
] | [
49,
5
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.__init__ | (self, water_heater) | Initialize. | Initialize. | def __init__(self, water_heater):
"""Initialize."""
super().__init__(water_heater)
self._running = water_heater.running
self._poll = True
self.water_heater = water_heater
self.econet_state_to_ha = {}
self.ha_state_to_econet = {} | [
"def",
"__init__",
"(",
"self",
",",
"water_heater",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"water_heater",
")",
"self",
".",
"_running",
"=",
"water_heater",
".",
"running",
"self",
".",
"_poll",
"=",
"True",
"self",
".",
"water_heater",
"="... | [
55,
4
] | [
62,
36
] | python | en | ['en', 'en', 'it'] | False |
EcoNetWaterHeater.on_update_received | (self) | Update was pushed from the ecoent API. | Update was pushed from the ecoent API. | def on_update_received(self):
"""Update was pushed from the ecoent API."""
if self._running != self.water_heater.running:
# Water heater running state has changed so check usage on next update
self._poll = True
self._running = self.water_heater.running
self.as... | [
"def",
"on_update_received",
"(",
"self",
")",
":",
"if",
"self",
".",
"_running",
"!=",
"self",
".",
"water_heater",
".",
"running",
":",
"# Water heater running state has changed so check usage on next update",
"self",
".",
"_poll",
"=",
"True",
"self",
".",
"_run... | [
65,
4
] | [
71,
35
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.is_away_mode_on | (self) | Return true if away mode is on. | Return true if away mode is on. | def is_away_mode_on(self):
"""Return true if away mode is on."""
return self._econet.away | [
"def",
"is_away_mode_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_econet",
".",
"away"
] | [
74,
4
] | [
76,
32
] | python | en | ['en', 'fy', 'en'] | True |
EcoNetWaterHeater.current_operation | (self) | Return current operation. | Return current operation. | def current_operation(self):
"""Return current operation."""
econet_mode = self.water_heater.mode
_current_op = STATE_OFF
if econet_mode is not None:
_current_op = ECONET_STATE_TO_HA[econet_mode]
return _current_op | [
"def",
"current_operation",
"(",
"self",
")",
":",
"econet_mode",
"=",
"self",
".",
"water_heater",
".",
"mode",
"_current_op",
"=",
"STATE_OFF",
"if",
"econet_mode",
"is",
"not",
"None",
":",
"_current_op",
"=",
"ECONET_STATE_TO_HA",
"[",
"econet_mode",
"]",
... | [
79,
4
] | [
86,
26
] | python | bg | ['nl', 'bg', 'en'] | False |
EcoNetWaterHeater.operation_list | (self) | List of available operation modes. | List of available operation modes. | def operation_list(self):
"""List of available operation modes."""
econet_modes = self.water_heater.modes
op_list = []
for mode in econet_modes:
if (
mode is not WaterHeaterOperationMode.UNKNOWN
and mode is not WaterHeaterOperationMode.VACATION... | [
"def",
"operation_list",
"(",
"self",
")",
":",
"econet_modes",
"=",
"self",
".",
"water_heater",
".",
"modes",
"op_list",
"=",
"[",
"]",
"for",
"mode",
"in",
"econet_modes",
":",
"if",
"(",
"mode",
"is",
"not",
"WaterHeaterOperationMode",
".",
"UNKNOWN",
... | [
89,
4
] | [
100,
22
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
if self.water_heater.modes:
if self.water_heater.supports_away:
return SUPPORT_FLAGS_HEATER | SUPPORT_AWAY_MODE
return SUPPORT_FLAGS_HEATER
if self.water_heater.supports_away:
... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"water_heater",
".",
"modes",
":",
"if",
"self",
".",
"water_heater",
".",
"supports_away",
":",
"return",
"SUPPORT_FLAGS_HEATER",
"|",
"SUPPORT_AWAY_MODE",
"return",
"SUPPORT_FLAGS_HEATER",
"i... | [
103,
4
] | [
111,
41
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | def set_temperature(self, **kwargs):
"""Set new target temperature."""
target_temp = kwargs.get(ATTR_TEMPERATURE)
if target_temp is not None:
self.water_heater.set_set_point(target_temp)
else:
_LOGGER.error("A target temperature must be provided") | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"target_temp",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"target_temp",
"is",
"not",
"None",
":",
"self",
".",
"water_heater",
".",
"set_set_point",
"(",
"target... | [
113,
4
] | [
119,
66
] | python | en | ['en', 'ca', 'en'] | True |
EcoNetWaterHeater.set_operation_mode | (self, operation_mode) | Set operation mode. | Set operation mode. | def set_operation_mode(self, operation_mode):
"""Set operation mode."""
op_mode_to_set = HA_STATE_TO_ECONET.get(operation_mode)
if op_mode_to_set is not None:
self.water_heater.set_mode(op_mode_to_set)
else:
_LOGGER.error("Invalid operation mode: %s", operation_mo... | [
"def",
"set_operation_mode",
"(",
"self",
",",
"operation_mode",
")",
":",
"op_mode_to_set",
"=",
"HA_STATE_TO_ECONET",
".",
"get",
"(",
"operation_mode",
")",
"if",
"op_mode_to_set",
"is",
"not",
"None",
":",
"self",
".",
"water_heater",
".",
"set_mode",
"(",
... | [
121,
4
] | [
127,
71
] | python | en | ['nl', 'ny', 'en'] | False |
EcoNetWaterHeater.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
return self.water_heater.set_point | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"water_heater",
".",
"set_point"
] | [
130,
4
] | [
132,
42
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self):
"""Return the minimum temperature."""
return self.water_heater.set_point_limits[0] | [
"def",
"min_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"water_heater",
".",
"set_point_limits",
"[",
"0",
"]"
] | [
135,
4
] | [
137,
52
] | python | en | ['en', 'la', 'en'] | True |
EcoNetWaterHeater.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self):
"""Return the maximum temperature."""
return self.water_heater.set_point_limits[1] | [
"def",
"max_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"water_heater",
".",
"set_point_limits",
"[",
"1",
"]"
] | [
140,
4
] | [
142,
52
] | python | en | ['en', 'la', 'en'] | True |
EcoNetWaterHeater.should_poll | (self) | Return True if entity has to be polled for state.
False if entity pushes its state to HA.
| Return True if entity has to be polled for state. | def should_poll(self) -> bool:
"""Return True if entity has to be polled for state.
False if entity pushes its state to HA.
"""
return self._poll | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_poll"
] | [
145,
4
] | [
150,
25
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.async_update | (self) | Get the latest energy usage. | Get the latest energy usage. | async def async_update(self):
"""Get the latest energy usage."""
await self.water_heater.get_energy_usage()
await self.water_heater.get_water_usage()
self.async_write_ha_state()
self._poll = False | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"water_heater",
".",
"get_energy_usage",
"(",
")",
"await",
"self",
".",
"water_heater",
".",
"get_water_usage",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")",
"self",
"."... | [
152,
4
] | [
157,
26
] | python | en | ['en', 'en', 'en'] | True |
EcoNetWaterHeater.turn_away_mode_on | (self) | Turn away mode on. | Turn away mode on. | def turn_away_mode_on(self):
"""Turn away mode on."""
self.water_heater.set_away_mode(True) | [
"def",
"turn_away_mode_on",
"(",
"self",
")",
":",
"self",
".",
"water_heater",
".",
"set_away_mode",
"(",
"True",
")"
] | [
159,
4
] | [
161,
45
] | python | en | ['en', 'yo', 'en'] | True |
EcoNetWaterHeater.turn_away_mode_off | (self) | Turn away mode off. | Turn away mode off. | def turn_away_mode_off(self):
"""Turn away mode off."""
self.water_heater.set_away_mode(False) | [
"def",
"turn_away_mode_off",
"(",
"self",
")",
":",
"self",
".",
"water_heater",
".",
"set_away_mode",
"(",
"False",
")"
] | [
163,
4
] | [
165,
46
] | python | en | ['en', 'yo', 'en'] | True |
raise_option_error | (parser, option, msg) |
Raise an option parsing error using parser.error().
Args:
parser: an OptionParser instance.
option: an Option instance.
msg: the error text.
|
Raise an option parsing error using parser.error(). | def raise_option_error(parser, option, msg):
# type: (OptionParser, Option, str) -> None
"""
Raise an option parsing error using parser.error().
Args:
parser: an OptionParser instance.
option: an Option instance.
msg: the error text.
"""
msg = '{} error: {}'.format(option, msg... | [
"def",
"raise_option_error",
"(",
"parser",
",",
"option",
",",
"msg",
")",
":",
"# type: (OptionParser, Option, str) -> None",
"msg",
"=",
"'{} error: {}'",
".",
"format",
"(",
"option",
",",
"msg",
")",
"msg",
"=",
"textwrap",
".",
"fill",
"(",
"' '",
".",
... | [
37,
0
] | [
49,
21
] | python | en | ['en', 'error', 'th'] | False |
make_option_group | (group, parser) |
Return an OptionGroup object
group -- assumed to be dict with 'name' and 'options' keys
parser -- an optparse Parser
|
Return an OptionGroup object
group -- assumed to be dict with 'name' and 'options' keys
parser -- an optparse Parser
| def make_option_group(group, parser):
# type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup
"""
Return an OptionGroup object
group -- assumed to be dict with 'name' and 'options' keys
parser -- an optparse Parser
"""
option_group = OptionGroup(parser, group['name'])
for option in ... | [
"def",
"make_option_group",
"(",
"group",
",",
"parser",
")",
":",
"# type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup",
"option_group",
"=",
"OptionGroup",
"(",
"parser",
",",
"group",
"[",
"'name'",
"]",
")",
"for",
"option",
"in",
"group",
"[",
"'options... | [
52,
0
] | [
62,
23
] | python | en | ['en', 'error', 'th'] | False |
check_install_build_global | (options, check_options=None) | Disable wheels if per-setup.py call options are set.
:param options: The OptionParser options to update.
:param check_options: The options to check, if not supplied defaults to
options.
| Disable wheels if per-setup.py call options are set. | def check_install_build_global(options, check_options=None):
# type: (Values, Optional[Values]) -> None
"""Disable wheels if per-setup.py call options are set.
:param options: The OptionParser options to update.
:param check_options: The options to check, if not supplied defaults to
options.
... | [
"def",
"check_install_build_global",
"(",
"options",
",",
"check_options",
"=",
"None",
")",
":",
"# type: (Values, Optional[Values]) -> None",
"if",
"check_options",
"is",
"None",
":",
"check_options",
"=",
"options",
"def",
"getname",
"(",
"n",
")",
":",
"# type: ... | [
65,
0
] | [
86,
9
] | python | en | ['en', 'en', 'en'] | True |
check_dist_restriction | (options, check_target=False) | Function for determining if custom platform options are allowed.
:param options: The OptionParser options.
:param check_target: Whether or not to check if --target is being used.
| Function for determining if custom platform options are allowed. | def check_dist_restriction(options, check_target=False):
# type: (Values, bool) -> None
"""Function for determining if custom platform options are allowed.
:param options: The OptionParser options.
:param check_target: Whether or not to check if --target is being used.
"""
dist_restriction_set ... | [
"def",
"check_dist_restriction",
"(",
"options",
",",
"check_target",
"=",
"False",
")",
":",
"# type: (Values, bool) -> None",
"dist_restriction_set",
"=",
"any",
"(",
"[",
"options",
".",
"python_version",
",",
"options",
".",
"platform",
",",
"options",
".",
"a... | [
89,
0
] | [
126,
13
] | python | en | ['en', 'en', 'en'] | True |
_get_format_control | (values, option) | Get a format_control object. | Get a format_control object. | def _get_format_control(values, option):
# type: (Values, Option) -> Any
"""Get a format_control object."""
return getattr(values, option.dest) | [
"def",
"_get_format_control",
"(",
"values",
",",
"option",
")",
":",
"# type: (Values, Option) -> Any",
"return",
"getattr",
"(",
"values",
",",
"option",
".",
"dest",
")"
] | [
437,
0
] | [
440,
39
] | python | en | ['en', 'en', 'en'] | True |
_convert_python_version | (value) |
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.
:return: A 2-tuple (version_info, error_msg), where `error_msg` is
non-None if and only if there was a parsing error.
|
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints. | def _convert_python_version(value):
# type: (str) -> Tuple[Tuple[int, ...], Optional[str]]
"""
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.
:return: A 2-tuple (version_info, error_msg), where `error_msg` is
non-None if and only if there was a parsing error.
"""
... | [
"def",
"_convert_python_version",
"(",
"value",
")",
":",
"# type: (str) -> Tuple[Tuple[int, ...], Optional[str]]",
"if",
"not",
"value",
":",
"# The empty string is the same as not providing a value.",
"return",
"(",
"None",
",",
"None",
")",
"parts",
"=",
"value",
".",
... | [
503,
0
] | [
530,
31
] | python | en | ['en', 'error', 'th'] | False |
_handle_python_version | (option, opt_str, value, parser) |
Handle a provided --python-version value.
|
Handle a provided --python-version value.
| def _handle_python_version(option, opt_str, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""
Handle a provided --python-version value.
"""
version_info, error_msg = _convert_python_version(value)
if error_msg is not None:
msg = (
'invalid --python-version ... | [
"def",
"_handle_python_version",
"(",
"option",
",",
"opt_str",
",",
"value",
",",
"parser",
")",
":",
"# type: (Option, str, str, OptionParser) -> None",
"version_info",
",",
"error_msg",
"=",
"_convert_python_version",
"(",
"value",
")",
"if",
"error_msg",
"is",
"no... | [
533,
0
] | [
547,
47
] | python | en | ['en', 'error', 'th'] | False |
_handle_no_cache_dir | (option, opt, value, parser) |
Process a value provided for the --no-cache-dir option.
This is an optparse.Option callback for the --no-cache-dir option.
|
Process a value provided for the --no-cache-dir option. | def _handle_no_cache_dir(option, opt, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""
Process a value provided for the --no-cache-dir option.
This is an optparse.Option callback for the --no-cache-dir option.
"""
# The value argument will be None if --no-cache-dir is passed... | [
"def",
"_handle_no_cache_dir",
"(",
"option",
",",
"opt",
",",
"value",
",",
"parser",
")",
":",
"# type: (Option, str, str, OptionParser) -> None",
"# The value argument will be None if --no-cache-dir is passed via the",
"# command-line, since the option doesn't accept arguments. Howev... | [
639,
0
] | [
664,
35
] | python | en | ['en', 'error', 'th'] | False |
_handle_no_use_pep517 | (option, opt, value, parser) |
Process a value provided for the --no-use-pep517 option.
This is an optparse.Option callback for the no_use_pep517 option.
|
Process a value provided for the --no-use-pep517 option. | def _handle_no_use_pep517(option, opt, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""
Process a value provided for the --no-use-pep517 option.
This is an optparse.Option callback for the no_use_pep517 option.
"""
# Since --no-use-pep517 doesn't accept arguments, the value ... | [
"def",
"_handle_no_use_pep517",
"(",
"option",
",",
"opt",
",",
"value",
",",
"parser",
")",
":",
"# type: (Option, str, str, OptionParser) -> None",
"# Since --no-use-pep517 doesn't accept arguments, the value argument",
"# will be None if --no-use-pep517 is passed via the command-line.... | [
729,
0
] | [
750,
36
] | python | en | ['en', 'error', 'th'] | False |
_handle_merge_hash | (option, opt_str, value, parser) | Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name. | Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name. | def _handle_merge_hash(option, opt_str, value, parser):
# type: (Option, str, str, OptionParser) -> None
"""Given a value spelled "algo:digest", append the digest to a list
pointed to in a dict by the algo name."""
if not parser.values.hashes:
parser.values.hashes = {}
try:
algo, dig... | [
"def",
"_handle_merge_hash",
"(",
"option",
",",
"opt_str",
",",
"value",
",",
"parser",
")",
":",
"# type: (Option, str, str, OptionParser) -> None",
"if",
"not",
"parser",
".",
"values",
".",
"hashes",
":",
"parser",
".",
"values",
".",
"hashes",
"=",
"{",
"... | [
824,
0
] | [
839,
60
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up Netgear LTE component. | Set up Netgear LTE component. | async def async_setup(hass, config):
"""Set up Netgear LTE component."""
if DATA_KEY not in hass.data:
websession = async_create_clientsession(
hass, cookie_jar=aiohttp.CookieJar(unsafe=True)
)
hass.data[DATA_KEY] = LTEData(websession)
async def service_handler(servi... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DATA_KEY",
"not",
"in",
"hass",
".",
"data",
":",
"websession",
"=",
"async_create_clientsession",
"(",
"hass",
",",
"cookie_jar",
"=",
"aiohttp",
".",
"CookieJar",
"(",
"unsafe",
... | [
173,
0
] | [
261,
15
] | python | en | ['en', 'lb', 'en'] | True |
_setup_lte | (hass, lte_config) | Set up a Netgear LTE modem. | Set up a Netgear LTE modem. | async def _setup_lte(hass, lte_config):
"""Set up a Netgear LTE modem."""
host = lte_config[CONF_HOST]
password = lte_config[CONF_PASSWORD]
websession = hass.data[DATA_KEY].websession
modem = eternalegypt.Modem(hostname=host, websession=websession)
modem_data = ModemData(hass, host, modem)
... | [
"async",
"def",
"_setup_lte",
"(",
"hass",
",",
"lte_config",
")",
":",
"host",
"=",
"lte_config",
"[",
"CONF_HOST",
"]",
"password",
"=",
"lte_config",
"[",
"CONF_PASSWORD",
"]",
"websession",
"=",
"hass",
".",
"data",
"[",
"DATA_KEY",
"]",
".",
"websessi... | [
264,
0
] | [
286,
75
] | python | en | ['en', 'lb', 'en'] | True |
_login | (hass, modem_data, password) | Log in and complete setup. | Log in and complete setup. | async def _login(hass, modem_data, password):
"""Log in and complete setup."""
await modem_data.modem.login(password=password)
def fire_sms_event(sms):
"""Send an SMS event."""
data = {
ATTR_HOST: modem_data.host,
ATTR_SMS_ID: sms.id,
ATTR_FROM: sms.sende... | [
"async",
"def",
"_login",
"(",
"hass",
",",
"modem_data",
",",
"password",
")",
":",
"await",
"modem_data",
".",
"modem",
".",
"login",
"(",
"password",
"=",
"password",
")",
"def",
"fire_sms_event",
"(",
"sms",
")",
":",
"\"\"\"Send an SMS event.\"\"\"",
"d... | [
289,
0
] | [
320,
65
] | python | en | ['en', 'en', 'en'] | True |
_retry_login | (hass, modem_data, password) | Sleep and retry setup. | Sleep and retry setup. | async def _retry_login(hass, modem_data, password):
"""Sleep and retry setup."""
_LOGGER.warning("Could not connect to %s. Will keep trying", modem_data.host)
modem_data.connected = False
delay = 15
while not modem_data.connected:
await asyncio.sleep(delay)
try:
await... | [
"async",
"def",
"_retry_login",
"(",
"hass",
",",
"modem_data",
",",
"password",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Could not connect to %s. Will keep trying\"",
",",
"modem_data",
".",
"host",
")",
"modem_data",
".",
"connected",
"=",
"False",
"delay",
... | [
323,
0
] | [
337,
39
] | python | en | ['en', 'ceb', 'en'] | True |
test_abort_if_no_implementation_registered | (hass) | Test we abort if no implementation is registered. | Test we abort if no implementation is registered. | async def test_abort_if_no_implementation_registered(hass):
"""Test we abort if no implementation is registered."""
flow = config_flow.NestFlowHandler()
flow.hass = hass
result = await flow.async_step_init()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "... | [
"async",
"def",
"test_abort_if_no_implementation_registered",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"NestFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".",
"async_step_init",
"(",
")",
"assert",
"re... | [
11,
0
] | [
18,
54
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_single_instance_allowed | (hass) | Test we abort if Nest is already setup. | Test we abort if Nest is already setup. | async def test_abort_if_single_instance_allowed(hass):
"""Test we abort if Nest is already setup."""
flow = config_flow.NestFlowHandler()
flow.hass = hass
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
result = await flow.async_step_init()
assert result["type"]... | [
"async",
"def",
"test_abort_if_single_instance_allowed",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"NestFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"config_entries",
",",
"\"async_en... | [
21,
0
] | [
30,
56
] | python | en | ['en', 'zu', 'en'] | True |
test_full_flow_implementation | (hass) | Test registering an implementation and finishing flow works. | Test registering an implementation and finishing flow works. | async def test_full_flow_implementation(hass):
"""Test registering an implementation and finishing flow works."""
gen_authorize_url = AsyncMock(return_value="https://example.com")
convert_code = AsyncMock(return_value={"access_token": "yoo"})
config_flow.register_flow_implementation(
hass, "test... | [
"async",
"def",
"test_full_flow_implementation",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"\"https://example.com\"",
")",
"convert_code",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"{",
"\"access_token\"",
":",
"\"yoo\""... | [
33,
0
] | [
59,
47
] | python | en | ['en', 'en', 'en'] | True |
test_not_pick_implementation_if_only_one | (hass) | Test we allow picking implementation if we have two. | Test we allow picking implementation if we have two. | async def test_not_pick_implementation_if_only_one(hass):
"""Test we allow picking implementation if we have two."""
gen_authorize_url = AsyncMock(return_value="https://example.com")
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, None
)
flow = config_flow... | [
"async",
"def",
"test_not_pick_implementation_if_only_one",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"\"https://example.com\"",
")",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"\"test\"",
",",
"\"... | [
62,
0
] | [
73,
38
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_timeout_generating_auth_url | (hass) | Test we abort if generating authorize url fails. | Test we abort if generating authorize url fails. | async def test_abort_if_timeout_generating_auth_url(hass):
"""Test we abort if generating authorize url fails."""
gen_authorize_url = Mock(side_effect=asyncio.TimeoutError)
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, None
)
flow = config_flow.NestFlowH... | [
"async",
"def",
"test_abort_if_timeout_generating_auth_url",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"Mock",
"(",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
")",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"\"test\"",
",",
... | [
76,
0
] | [
87,
54
] | python | en | ['en', 'zu', 'en'] | True |
test_abort_if_exception_generating_auth_url | (hass) | Test we abort if generating authorize url blows up. | Test we abort if generating authorize url blows up. | async def test_abort_if_exception_generating_auth_url(hass):
"""Test we abort if generating authorize url blows up."""
gen_authorize_url = Mock(side_effect=ValueError)
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, None
)
flow = config_flow.NestFlowHandle... | [
"async",
"def",
"test_abort_if_exception_generating_auth_url",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"Mock",
"(",
"side_effect",
"=",
"ValueError",
")",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"\"test\"",
",",
"\"Test\"",
",",
... | [
90,
0
] | [
101,
65
] | python | en | ['de', 'en', 'en'] | True |
test_verify_code_timeout | (hass) | Test verify code timing out. | Test verify code timing out. | async def test_verify_code_timeout(hass):
"""Test verify code timing out."""
gen_authorize_url = AsyncMock(return_value="https://example.com")
convert_code = Mock(side_effect=asyncio.TimeoutError)
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, convert_code
... | [
"async",
"def",
"test_verify_code_timeout",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"\"https://example.com\"",
")",
"convert_code",
"=",
"Mock",
"(",
"side_effect",
"=",
"asyncio",
".",
"TimeoutError",
")",
"config_flo... | [
104,
0
] | [
121,
50
] | python | en | ['en', 'en', 'en'] | True |
test_verify_code_invalid | (hass) | Test verify code invalid. | Test verify code invalid. | async def test_verify_code_invalid(hass):
"""Test verify code invalid."""
gen_authorize_url = AsyncMock(return_value="https://example.com")
convert_code = Mock(side_effect=config_flow.CodeInvalid)
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, convert_code
... | [
"async",
"def",
"test_verify_code_invalid",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"\"https://example.com\"",
")",
"convert_code",
"=",
"Mock",
"(",
"side_effect",
"=",
"config_flow",
".",
"CodeInvalid",
")",
"config_... | [
124,
0
] | [
141,
54
] | python | en | ['en', 'sk', 'en'] | True |
test_verify_code_unknown_error | (hass) | Test verify code unknown error. | Test verify code unknown error. | async def test_verify_code_unknown_error(hass):
"""Test verify code unknown error."""
gen_authorize_url = AsyncMock(return_value="https://example.com")
convert_code = Mock(side_effect=config_flow.NestAuthError)
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, co... | [
"async",
"def",
"test_verify_code_unknown_error",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"\"https://example.com\"",
")",
"convert_code",
"=",
"Mock",
"(",
"side_effect",
"=",
"config_flow",
".",
"NestAuthError",
")",
... | [
144,
0
] | [
161,
50
] | python | en | ['en', 'de', 'en'] | True |
test_verify_code_exception | (hass) | Test verify code blows up. | Test verify code blows up. | async def test_verify_code_exception(hass):
"""Test verify code blows up."""
gen_authorize_url = AsyncMock(return_value="https://example.com")
convert_code = Mock(side_effect=ValueError)
config_flow.register_flow_implementation(
hass, "test", "Test", gen_authorize_url, convert_code
)
fl... | [
"async",
"def",
"test_verify_code_exception",
"(",
"hass",
")",
":",
"gen_authorize_url",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"\"https://example.com\"",
")",
"convert_code",
"=",
"Mock",
"(",
"side_effect",
"=",
"ValueError",
")",
"config_flow",
".",
"regist... | [
164,
0
] | [
181,
57
] | python | en | ['fr', 'lb', 'en'] | False |
test_step_import | (hass) | Test that we trigger import when configuring with client. | Test that we trigger import when configuring with client. | async def test_step_import(hass):
"""Test that we trigger import when configuring with client."""
with patch("os.path.isfile", return_value=False):
assert await async_setup_component(
hass, DOMAIN, {DOMAIN: {"client_id": "bla", "client_secret": "bla"}}
)
await hass.async_bloc... | [
"async",
"def",
"test_step_import",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"return_value",
"=",
"False",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"\"clien... | [
184,
0
] | [
196,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import_with_token_cache | (hass) | Test that we import existing token cache. | Test that we import existing token cache. | async def test_step_import_with_token_cache(hass):
"""Test that we import existing token cache."""
with patch("os.path.isfile", return_value=True), patch(
"homeassistant.components.nest.config_flow.load_json",
return_value={"access_token": "yo"},
), patch(
"homeassistant.components.n... | [
"async",
"def",
"test_step_import_with_token_cache",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch",
"(",
"\"homeassistant.components.nest.config_flow.load_json\"",
",",
"return_value",
"=",
"{",
... | [
199,
0
] | [
214,
82
] | python | en | ['en', 'en', 'en'] | True |
pad_numbers | (string) | Modify a string to make its numbers suitable for natural sorting. | Modify a string to make its numbers suitable for natural sorting. | def pad_numbers(string):
"""Modify a string to make its numbers suitable for natural sorting."""
return re.sub(r'\d+', lambda m: m.group(0).rjust(16, '0'), string) | [
"def",
"pad_numbers",
"(",
"string",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'\\d+'",
",",
"lambda",
"m",
":",
"m",
".",
"group",
"(",
"0",
")",
".",
"rjust",
"(",
"16",
",",
"'0'",
")",
",",
"string",
")"
] | [
37,
0
] | [
39,
70
] | python | en | ['en', 'en', 'en'] | True |
mp_init_worker | (jobs_dir, metadata, client_class, use_signal=True) |
Initialize the environment for multiprocessing-based multithreading.
|
Initialize the environment for multiprocessing-based multithreading.
| def mp_init_worker(jobs_dir, metadata, client_class, use_signal=True):
"""
Initialize the environment for multiprocessing-based multithreading.
"""
if use_signal:
signal.signal(signal.SIGINT, signal.SIG_IGN)
# Multiprocessing doesn't allow local variables for each worker, so we need
# t... | [
"def",
"mp_init_worker",
"(",
"jobs_dir",
",",
"metadata",
",",
"client_class",
",",
"use_signal",
"=",
"True",
")",
":",
"if",
"use_signal",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal",
".",
"SIG_IGN",
")",
"# Multiprocessing d... | [
200,
0
] | [
210,
52
] | python | en | ['en', 'error', 'th'] | False |
get_all_builds | (db, jobs_dir, metadata, threads, client_class, build_limit) |
Adds information about tests to a dictionary.
Args:
jobs_dir: the GCS path containing jobs.
metadata: a dict of metadata about the jobs_dir.
threads: how many threads to use to download build information.
client_class: a constructor for a GCSClient (or a subclass).
|
Adds information about tests to a dictionary. | def get_all_builds(db, jobs_dir, metadata, threads, client_class, build_limit):
"""
Adds information about tests to a dictionary.
Args:
jobs_dir: the GCS path containing jobs.
metadata: a dict of metadata about the jobs_dir.
threads: how many threads to use to download build informa... | [
"def",
"get_all_builds",
"(",
"db",
",",
"jobs_dir",
",",
"metadata",
",",
"threads",
",",
"client_class",
",",
"build_limit",
")",
":",
"gcs",
"=",
"client_class",
"(",
"jobs_dir",
",",
"metadata",
")",
"print",
"(",
"f'Loading builds from {jobs_dir}'",
")",
... | [
230,
0
] | [
279,
15
] | python | en | ['en', 'error', 'th'] | False |
remove_system_out | (data) | Strip bloated system-out annotations. | Strip bloated system-out annotations. | def remove_system_out(data):
"""Strip bloated system-out annotations."""
if 'system-out' in data:
try:
root = ET.fromstring(data)
for parent in root.findall('*//system-out/..'):
for child in parent.findall('system-out'):
parent.remove(child)
... | [
"def",
"remove_system_out",
"(",
"data",
")",
":",
"if",
"'system-out'",
"in",
"data",
":",
"try",
":",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"data",
")",
"for",
"parent",
"in",
"root",
".",
"findall",
"(",
"'*//system-out/..'",
")",
":",
"for",
"... | [
282,
0
] | [
293,
15
] | python | en | ['en', 'en', 'en'] | True |
download_junit | (db, threads, client_class) | Download junit results for builds without them. | Download junit results for builds without them. | def download_junit(db, threads, client_class):
"""Download junit results for builds without them."""
logging.info('Downloading JUnit artifacts.')
sys.stdout.flush()
builds_to_grab = db.get_builds_missing_junit()
pool = None
if threads > 1:
pool = multiprocessing.pool.ThreadPool(
... | [
"def",
"download_junit",
"(",
"db",
",",
"threads",
",",
"client_class",
")",
":",
"logging",
".",
"info",
"(",
"'Downloading JUnit artifacts.'",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")",
"builds_to_grab",
"=",
"db",
".",
"get_builds_missing_junit",
"... | [
296,
0
] | [
323,
19
] | python | en | ['en', 'en', 'en'] | True |
main | (db, jobs_dirs, threads, get_junit, build_limit, client_class=GCSClient) | Collect test info in matching jobs. | Collect test info in matching jobs. | def main(db, jobs_dirs, threads, get_junit, build_limit, client_class=GCSClient):
"""Collect test info in matching jobs."""
get_all_builds(db, 'gs://kubernetes-jenkins/pr-logs', {'pr': True},
threads, client_class, build_limit)
for bucket, metadata in jobs_dirs.items():
if not buc... | [
"def",
"main",
"(",
"db",
",",
"jobs_dirs",
",",
"threads",
",",
"get_junit",
",",
"build_limit",
",",
"client_class",
"=",
"GCSClient",
")",
":",
"get_all_builds",
"(",
"db",
",",
"'gs://kubernetes-jenkins/pr-logs'",
",",
"{",
"'pr'",
":",
"True",
"}",
",",... | [
326,
0
] | [
335,
49
] | python | en | ['en', 'en', 'en'] | True |
get_options | (argv) | Process command line arguments. | Process command line arguments. | def get_options(argv):
"""Process command line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument(
'--buckets',
help='YAML file with GCS bucket locations',
required=True,
)
parser.add_argument(
'--threads',
help='number of concurrent threads ... | [
"def",
"get_options",
"(",
"argv",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'--buckets'",
",",
"help",
"=",
"'YAML file with GCS bucket locations'",
",",
"required",
"=",
"True",
",",
")",
"pars... | [
338,
0
] | [
364,
34
] | python | en | ['en', 'fr', 'en'] | True |
GCSClient._request | (self, path, params, as_json=True) | GETs a JSON resource from GCS, with retries on failure.
Retries are based on guidance from
cloud.google.com/storage/docs/gsutil/addlhelp/RetryHandlingStrategy
| GETs a JSON resource from GCS, with retries on failure. | def _request(self, path, params, as_json=True):
"""GETs a JSON resource from GCS, with retries on failure.
Retries are based on guidance from
cloud.google.com/storage/docs/gsutil/addlhelp/RetryHandlingStrategy
"""
url = f'https://www.googleapis.com/storage/v1/b/{path}'
... | [
"def",
"_request",
"(",
"self",
",",
"path",
",",
"params",
",",
"as_json",
"=",
"True",
")",
":",
"url",
"=",
"f'https://www.googleapis.com/storage/v1/b/{path}'",
"for",
"retry",
"in",
"range",
"(",
"23",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
... | [
50,
4
] | [
74,
61
] | python | en | ['en', 'en', 'en'] | True |
GCSClient.get | (self, path, as_json=False) | Get an object from GCS. | Get an object from GCS. | def get(self, path, as_json=False):
"""Get an object from GCS."""
bucket, prefix = self._parse_uri(path)
return self._request(f'{bucket}/o/{urllib.parse.quote(prefix, "")}',
{'alt': 'media'}, as_json=as_json) | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"as_json",
"=",
"False",
")",
":",
"bucket",
",",
"prefix",
"=",
"self",
".",
"_parse_uri",
"(",
"path",
")",
"return",
"self",
".",
"_request",
"(",
"f'{bucket}/o/{urllib.parse.quote(prefix, \"\")}'",
",",
"{",
... | [
83,
4
] | [
87,
63
] | python | en | ['en', 'en', 'en'] | True |
GCSClient.ls | (self,
path,
dirs=True,
files=True,
delim=True,
item_field='name',
build_limit=sys.maxsize,) | Lists objects under a path on gcs. | Lists objects under a path on gcs. | def ls(self,
path,
dirs=True,
files=True,
delim=True,
item_field='name',
build_limit=sys.maxsize,):
"""Lists objects under a path on gcs."""
# pylint: disable=invalid-name
bucket, prefix = self._parse_uri(path)
params = {... | [
"def",
"ls",
"(",
"self",
",",
"path",
",",
"dirs",
"=",
"True",
",",
"files",
"=",
"True",
",",
"delim",
"=",
"True",
",",
"item_field",
"=",
"'name'",
",",
"build_limit",
"=",
"sys",
".",
"maxsize",
",",
")",
":",
"# pylint: disable=invalid-name",
"b... | [
89,
4
] | [
123,
55
] | python | en | ['en', 'en', 'en'] | True |
GCSClient._ls_junit_paths | (self, build_dir) | Lists the paths of JUnit XML files for a build. | Lists the paths of JUnit XML files for a build. | def _ls_junit_paths(self, build_dir):
"""Lists the paths of JUnit XML files for a build."""
url = f'{build_dir}artifacts/'
for path in self.ls(url):
if re.match(r'.*/junit.*\.xml$', path):
yield path | [
"def",
"_ls_junit_paths",
"(",
"self",
",",
"build_dir",
")",
":",
"url",
"=",
"f'{build_dir}artifacts/'",
"for",
"path",
"in",
"self",
".",
"ls",
"(",
"url",
")",
":",
"if",
"re",
".",
"match",
"(",
"r'.*/junit.*\\.xml$'",
",",
"path",
")",
":",
"yield"... | [
128,
4
] | [
133,
26
] | python | en | ['en', 'en', 'en'] | True |
GCSClient.get_junits_from_build | (self, build_dir) | Generates all tests for a build. | Generates all tests for a build. | def get_junits_from_build(self, build_dir):
"""Generates all tests for a build."""
files = {}
assert not build_dir.endswith('/')
for junit_path in self._ls_junit_paths(build_dir + '/'):
junit = self.get(junit_path)
if junit is None:
continue
... | [
"def",
"get_junits_from_build",
"(",
"self",
",",
"build_dir",
")",
":",
"files",
"=",
"{",
"}",
"assert",
"not",
"build_dir",
".",
"endswith",
"(",
"'/'",
")",
"for",
"junit_path",
"in",
"self",
".",
"_ls_junit_paths",
"(",
"build_dir",
"+",
"'/'",
")",
... | [
135,
4
] | [
144,
20
] | python | en | ['en', 'en', 'en'] | True |
GCSClient._get_jobs | (self) | Generates all jobs in the bucket. | Generates all jobs in the bucket. | def _get_jobs(self):
"""Generates all jobs in the bucket."""
for job_path in self.ls_dirs(self.jobs_dir):
yield os.path.basename(os.path.dirname(job_path)) | [
"def",
"_get_jobs",
"(",
"self",
")",
":",
"for",
"job_path",
"in",
"self",
".",
"ls_dirs",
"(",
"self",
".",
"jobs_dir",
")",
":",
"yield",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"job_path",
")",
")"
] | [
146,
4
] | [
149,
61
] | python | en | ['en', 'en', 'en'] | True |
GCSClient._get_builds | (self, job, build_limit=sys.maxsize) | Returns whether builds are precise (guarantees existence) | Returns whether builds are precise (guarantees existence) | def _get_builds(self, job, build_limit=sys.maxsize):
'''Returns whether builds are precise (guarantees existence)'''
if self.metadata.get('sequential', True):
try:
latest_build = int(self.get(f'{self.jobs_dir}{job}/latest-build.txt'))
except (ValueError, TypeError... | [
"def",
"_get_builds",
"(",
"self",
",",
"job",
",",
"build_limit",
"=",
"sys",
".",
"maxsize",
")",
":",
"if",
"self",
".",
"metadata",
".",
"get",
"(",
"'sequential'",
",",
"True",
")",
":",
"try",
":",
"latest_build",
"=",
"int",
"(",
"self",
".",
... | [
151,
4
] | [
164,
56
] | python | en | ['en', 'en', 'en'] | True |
GCSClient.get_builds | (self, builds_have, build_limit=sys.maxsize) | Generates all (job, build) pairs ever. | Generates all (job, build) pairs ever. | def get_builds(self, builds_have, build_limit=sys.maxsize):
"""Generates all (job, build) pairs ever."""
if self.metadata.get('pr'):
files = self.ls(self.jobs_dir + '/directory/', delim=False, build_limit=build_limit)
for fname in files:
if fname.endswith('.txt') ... | [
"def",
"get_builds",
"(",
"self",
",",
"builds_have",
",",
"build_limit",
"=",
"sys",
".",
"maxsize",
")",
":",
"if",
"self",
".",
"metadata",
".",
"get",
"(",
"'pr'",
")",
":",
"files",
"=",
"self",
".",
"ls",
"(",
"self",
".",
"jobs_dir",
"+",
"'... | [
175,
4
] | [
197,
32
] | python | en | ['en', 'la', 'en'] | True |
async_connect_or_timeout | (ayla_api: AylaApi) | Connect to vacuum. | Connect to vacuum. | async def async_connect_or_timeout(ayla_api: AylaApi) -> bool:
"""Connect to vacuum."""
try:
with async_timeout.timeout(API_TIMEOUT):
_LOGGER.debug("Initialize connection to Ayla networks API")
await ayla_api.async_sign_in()
except SharkIqAuthError:
_LOGGER.error("Aut... | [
"async",
"def",
"async_connect_or_timeout",
"(",
"ayla_api",
":",
"AylaApi",
")",
"->",
"bool",
":",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"API_TIMEOUT",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Initialize connection to Ayla networks API\"",
... | [
25,
0
] | [
38,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Initialize the sharkiq platform via config entry. | Initialize the sharkiq platform via config entry. | async def async_setup_entry(hass, config_entry):
"""Initialize the sharkiq platform via config entry."""
ayla_api = get_ayla_api(
username=config_entry.data[CONF_USERNAME],
password=config_entry.data[CONF_PASSWORD],
websession=hass.helpers.aiohttp_client.async_get_clientsession(),
)
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"ayla_api",
"=",
"get_ayla_api",
"(",
"username",
"=",
"config_entry",
".",
"data",
"[",
"CONF_USERNAME",
"]",
",",
"password",
"=",
"config_entry",
".",
"data",
"[",
"CONF_PASSWO... | [
41,
0
] | [
67,
15
] | python | en | ['en', 'pt', 'en'] | True |
async_disconnect_or_timeout | (coordinator: SharkIqUpdateCoordinator) | Disconnect to vacuum. | Disconnect to vacuum. | async def async_disconnect_or_timeout(coordinator: SharkIqUpdateCoordinator):
"""Disconnect to vacuum."""
_LOGGER.debug("Disconnecting from Ayla Api")
with async_timeout.timeout(5), suppress(
SharkIqAuthError, SharkIqAuthExpiringError, SharkIqNotAuthedError
):
await coordinator.ayla_api.... | [
"async",
"def",
"async_disconnect_or_timeout",
"(",
"coordinator",
":",
"SharkIqUpdateCoordinator",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Disconnecting from Ayla Api\"",
")",
"with",
"async_timeout",
".",
"timeout",
"(",
"5",
")",
",",
"suppress",
"(",
"SharkIq... | [
70,
0
] | [
76,
51
] | python | en | ['en', 'en', 'en'] | True |
async_update_options | (hass, config_entry) | Update options. | Update options. | async def async_update_options(hass, config_entry):
"""Update options."""
await hass.config_entries.async_reload(config_entry.entry_id) | [
"async",
"def",
"async_update_options",
"(",
"hass",
",",
"config_entry",
")",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"config_entry",
".",
"entry_id",
")"
] | [
79,
0
] | [
81,
65
] | python | en | ['en', 'en', 'en'] | False |
async_unload_entry | (hass, config_entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(
config_entry, PLATFORMS
)
if unload_ok:
domain_data = hass.data[DOMAIN][config_entry.entry_id]
with suppress(SharkIqAuthError):
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"unload_ok",
"=",
"await",
"hass",
".",
"config_entries",
".",
"async_unload_platforms",
"(",
"config_entry",
",",
"PLATFORMS",
")",
"if",
"unload_ok",
":",
"domain_data",
"=",
"ha... | [
84,
0
] | [
95,
20
] | python | en | ['en', 'es', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Smart Meter Texas sensors. | Set up the Smart Meter Texas sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Smart Meter Texas sensors."""
coordinator = hass.data[DOMAIN][config_entry.entry_id][DATA_COORDINATOR]
meters = hass.data[DOMAIN][config_entry.entry_id][DATA_SMART_METER].meters
async_add_entities(
[SmartMeterTex... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"DATA_COORDINATOR",
"]",
"meters",
"=",
"... | [
22,
0
] | [
29,
5
] | python | en | ['en', 'nl', 'en'] | True |
SmartMeterTexasSensor.__init__ | (self, meter: Meter, coordinator: DataUpdateCoordinator) | Initialize the sensor. | Initialize the sensor. | def __init__(self, meter: Meter, coordinator: DataUpdateCoordinator) -> None:
"""Initialize the sensor."""
super().__init__(coordinator)
self.meter = meter
self._state = None
self._available = False | [
"def",
"__init__",
"(",
"self",
",",
"meter",
":",
"Meter",
",",
"coordinator",
":",
"DataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"meter",
"=",
"meter",
"self",
".",
"_state",
... | [
39,
4
] | [
44,
31
] | python | en | ['en', 'en', 'en'] | True |
SmartMeterTexasSensor.name | (self) | Device Name. | Device Name. | def name(self):
"""Device Name."""
return f"{ELECTRIC_METER} {self.meter.meter}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{ELECTRIC_METER} {self.meter.meter}\""
] | [
47,
4
] | [
49,
53
] | python | en | ['en', 'en', 'en'] | False |
SmartMeterTexasSensor.unique_id | (self) | Device Uniqueid. | Device Uniqueid. | def unique_id(self):
"""Device Uniqueid."""
return f"{self.meter.esiid}_{self.meter.meter}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.meter.esiid}_{self.meter.meter}\""
] | [
52,
4
] | [
54,
55
] | python | fr | ['fr', 'fr', 'en'] | False |
SmartMeterTexasSensor.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"
] | [
57,
4
] | [
59,
30
] | python | en | ['en', 'en', 'en'] | True |
SmartMeterTexasSensor.native_value | (self) | Get the latest reading. | Get the latest reading. | def native_value(self):
"""Get the latest reading."""
return self._state | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
62,
4
] | [
64,
26
] | python | en | ['en', 'en', 'en'] | True |
SmartMeterTexasSensor.extra_state_attributes | (self) | Return the device specific state attributes. | Return the device specific state attributes. | def extra_state_attributes(self):
"""Return the device specific state attributes."""
attributes = {
METER_NUMBER: self.meter.meter,
ESIID: self.meter.esiid,
CONF_ADDRESS: self.meter.address,
}
return attributes | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"METER_NUMBER",
":",
"self",
".",
"meter",
".",
"meter",
",",
"ESIID",
":",
"self",
".",
"meter",
".",
"esiid",
",",
"CONF_ADDRESS",
":",
"self",
".",
"meter",
".",
"address"... | [
67,
4
] | [
74,
25
] | python | en | ['en', 'en', 'en'] | True |
SmartMeterTexasSensor._state_update | (self) | Call when the coordinator has an update. | Call when the coordinator has an update. | def _state_update(self):
"""Call when the coordinator has an update."""
self._available = self.coordinator.last_update_success
if self._available:
self._state = self.meter.reading
self.async_write_ha_state() | [
"def",
"_state_update",
"(",
"self",
")",
":",
"self",
".",
"_available",
"=",
"self",
".",
"coordinator",
".",
"last_update_success",
"if",
"self",
".",
"_available",
":",
"self",
".",
"_state",
"=",
"self",
".",
"meter",
".",
"reading",
"self",
".",
"a... | [
77,
4
] | [
82,
35
] | python | en | ['en', 'lb', 'en'] | True |
SmartMeterTexasSensor.async_added_to_hass | (self) | Subscribe to updates. | Subscribe to updates. | async def async_added_to_hass(self):
"""Subscribe to updates."""
self.async_on_remove(self.coordinator.async_add_listener(self._state_update))
# If the background update finished before
# we added the entity, there is no need to restore
# state.
if self.coordinator.last_... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"_state_update",
")",
")",
"# If the background update finished before",
"# we added the entity, t... | [
84,
4
] | [
97,
34
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the requested World Air Quality Index locations. | Set up the requested World Air Quality Index locations. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the requested World Air Quality Index locations."""
token = config.get(CONF_TOKEN)
station_filter = config.get(CONF_STATIONS)
locations = config.get(CONF_LOCATIONS)
client = WaqiClient(token, async_get... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"token",
"=",
"config",
".",
"get",
"(",
"CONF_TOKEN",
")",
"station_filter",
"=",
"config",
".",
"get",
"(",
"CONF_S... | [
61,
0
] | [
92,
33
] | python | en | ['en', 'en', 'en'] | True |
WaqiSensor.__init__ | (self, client, station) | Initialize the sensor. | Initialize the sensor. | def __init__(self, client, station):
"""Initialize the sensor."""
self._client = client
try:
self.uid = station["uid"]
except (KeyError, TypeError):
self.uid = None
try:
self.url = station["station"]["url"]
except (KeyError, TypeError)... | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"station",
")",
":",
"self",
".",
"_client",
"=",
"client",
"try",
":",
"self",
".",
"uid",
"=",
"station",
"[",
"\"uid\"",
"]",
"except",
"(",
"KeyError",
",",
"TypeError",
")",
":",
"self",
".",
... | [
98,
4
] | [
116,
25
] | python | en | ['en', 'en', 'en'] | True |
WaqiSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
if self.station_name:
return f"WAQI {self.station_name}"
return f"WAQI {self.url if self.url else self.uid}" | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"station_name",
":",
"return",
"f\"WAQI {self.station_name}\"",
"return",
"f\"WAQI {self.url if self.url else self.uid}\""
] | [
119,
4
] | [
123,
59
] | python | en | ['en', 'mi', 'en'] | True |
WaqiSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return "mdi:cloud" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:cloud\""
] | [
126,
4
] | [
128,
26
] | python | en | ['en', 'en', 'en'] | True |
WaqiSensor.native_value | (self) | Return the state of the device. | Return the state of the device. | def native_value(self):
"""Return the state of the device."""
if self._data is not None:
return self._data.get("aqi")
return None | [
"def",
"native_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"aqi\"",
")",
"return",
"None"
] | [
131,
4
] | [
135,
19
] | 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.