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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DeconzFlowHandler.async_step_ssdp | (self, discovery_info) | Handle a discovered deCONZ bridge. | Handle a discovered deCONZ bridge. | async def async_step_ssdp(self, discovery_info):
"""Handle a discovered deCONZ bridge."""
if (
discovery_info.get(ssdp.ATTR_UPNP_MANUFACTURER_URL)
!= DECONZ_MANUFACTURERURL
):
return self.async_abort(reason="not_deconz_bridge")
LOGGER.debug("deCONZ SS... | [
"async",
"def",
"async_step_ssdp",
"(",
"self",
",",
"discovery_info",
")",
":",
"if",
"(",
"discovery_info",
".",
"get",
"(",
"ssdp",
".",
"ATTR_UPNP_MANUFACTURER_URL",
")",
"!=",
"DECONZ_MANUFACTURERURL",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
... | [
179,
4
] | [
208,
43
] | python | en | ['en', 'fr', 'en'] | True |
DeconzFlowHandler.async_step_hassio | (self, discovery_info) | Prepare configuration for a Hass.io deCONZ bridge.
This flow is triggered by the discovery component.
| Prepare configuration for a Hass.io deCONZ bridge. | async def async_step_hassio(self, discovery_info):
"""Prepare configuration for a Hass.io deCONZ bridge.
This flow is triggered by the discovery component.
"""
LOGGER.debug("deCONZ HASSIO discovery %s", pformat(discovery_info))
self.bridge_id = normalize_bridge_id(discovery_inf... | [
"async",
"def",
"async_step_hassio",
"(",
"self",
",",
"discovery_info",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"deCONZ HASSIO discovery %s\"",
",",
"pformat",
"(",
"discovery_info",
")",
")",
"self",
".",
"bridge_id",
"=",
"normalize_bridge_id",
"(",
"discovery... | [
210,
4
] | [
230,
53
] | python | it | ['it', 'it', 'en'] | True |
DeconzFlowHandler.async_step_hassio_confirm | (self, user_input=None) | Confirm a Hass.io discovery. | Confirm a Hass.io discovery. | async def async_step_hassio_confirm(self, user_input=None):
"""Confirm a Hass.io discovery."""
if user_input is not None:
self.deconz_config = {
CONF_HOST: self._hassio_discovery[CONF_HOST],
CONF_PORT: self._hassio_discovery[CONF_PORT],
CONF_AP... | [
"async",
"def",
"async_step_hassio_confirm",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"deconz_config",
"=",
"{",
"CONF_HOST",
":",
"self",
".",
"_hassio_discovery",
"[",
"CONF_HOST",
"]... | [
232,
4
] | [
246,
9
] | python | en | ['pt', 'en', 'en'] | True |
DeconzOptionsFlowHandler.__init__ | (self, config_entry) | Initialize deCONZ options flow. | Initialize deCONZ options flow. | def __init__(self, config_entry):
"""Initialize deCONZ options flow."""
self.config_entry = config_entry
self.options = dict(config_entry.options)
self.gateway = None | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"options",
"=",
"dict",
"(",
"config_entry",
".",
"options",
")",
"self",
".",
"gateway",
"=",
"None"
] | [
252,
4
] | [
256,
27
] | python | fr | ['fr', 'fr', 'nl'] | True |
DeconzOptionsFlowHandler.async_step_init | (self, user_input=None) | Manage the deCONZ options. | Manage the deCONZ options. | async def async_step_init(self, user_input=None):
"""Manage the deCONZ options."""
self.gateway = get_gateway_from_config_entry(self.hass, self.config_entry)
return await self.async_step_deconz_devices() | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"self",
".",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"self",
".",
"hass",
",",
"self",
".",
"config_entry",
")",
"return",
"await",
"self",
".",
"async_st... | [
258,
4
] | [
261,
53
] | python | en | ['en', 'en', 'en'] | True |
DeconzOptionsFlowHandler.async_step_deconz_devices | (self, user_input=None) | Manage the deconz devices options. | Manage the deconz devices options. | async def async_step_deconz_devices(self, user_input=None):
"""Manage the deconz devices options."""
if user_input is not None:
self.options.update(user_input)
return self.async_create_entry(title="", data=self.options)
return self.async_show_form(
step_id="d... | [
"async",
"def",
"async_step_deconz_devices",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"options",
".",
"update",
"(",
"user_input",
")",
"return",
"self",
".",
"async_create_entry",
"(",... | [
263,
4
] | [
287,
9
] | python | en | ['en', 'en', 'en'] | True |
_convert_name | (name: str) |
Convert the names using separator '.' to valid variable name in code
|
Convert the names using separator '.' to valid variable name in code
| def _convert_name(name: str) -> str:
"""
Convert the names using separator '.' to valid variable name in code
"""
return name.replace('.', '__') | [
"def",
"_convert_name",
"(",
"name",
":",
"str",
")",
"->",
"str",
":",
"return",
"name",
".",
"replace",
"(",
"'.'",
",",
"'__'",
")"
] | [
12,
0
] | [
16,
34
] | python | en | ['en', 'error', 'th'] | False |
RobertaTokenizerFast.mask_token | (self) |
:obj:`str`: Mask token, to use when training a model with masked-language modeling. Log an error if used while
not having been set.
Roberta tokenizer has a special mask token to be usble in the fill-mask pipeline. The mask token will greedily
comprise the space before the `<mask>`.
... |
:obj:`str`: Mask token, to use when training a model with masked-language modeling. Log an error if used while
not having been set. | def mask_token(self) -> str:
"""
:obj:`str`: Mask token, to use when training a model with masked-language modeling. Log an error if used while
not having been set.
Roberta tokenizer has a special mask token to be usble in the fill-mask pipeline. The mask token will greedily
com... | [
"def",
"mask_token",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_mask_token",
"is",
"None",
"and",
"self",
".",
"verbose",
":",
"logger",
".",
"error",
"(",
"\"Using mask_token, but it is not set yet.\"",
")",
"return",
"None",
"return",
"str",
... | [
176,
4
] | [
187,
36
] | python | en | ['en', 'error', 'th'] | False |
RobertaTokenizerFast.mask_token | (self, value) |
Overriding the default behavior of the mask token to have it eat the space before it.
This is needed to preserve backward compatibility with all the previously used models based on Roberta.
|
Overriding the default behavior of the mask token to have it eat the space before it. | def mask_token(self, value):
"""
Overriding the default behavior of the mask token to have it eat the space before it.
This is needed to preserve backward compatibility with all the previously used models based on Roberta.
"""
# Mask token behave like a normal word, i.e. include... | [
"def",
"mask_token",
"(",
"self",
",",
"value",
")",
":",
"# Mask token behave like a normal word, i.e. include the space before it",
"# So we set lstrip to True",
"value",
"=",
"AddedToken",
"(",
"value",
",",
"lstrip",
"=",
"True",
",",
"rstrip",
"=",
"False",
")",
... | [
190,
4
] | [
199,
32
] | python | en | ['en', 'error', 'th'] | False |
RobertaTokenizerFast.create_token_type_ids_from_sequences | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. RoBERTa does not
make use of token type ids, therefore a list of zeros is returned.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:obj:`List[... |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. RoBERTa does not
make use of token type ids, therefore a list of zeros is returned. | def create_token_type_ids_from_sequences(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Create a mask from the two sequences passed to be used in a sequence-pair classification task. RoBERTa does not
make use of token type ids, therefore a ... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
208,
4
] | [
229,
75
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, entry, async_add_entities) | Set up the GDACS Feed platform. | Set up the GDACS Feed platform. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the GDACS Feed platform."""
manager = hass.data[DOMAIN][FEED][entry.entry_id]
@callback
def async_add_geolocation(feed_manager, integration_id, external_id):
"""Add gelocation entity from feed."""
new_entity = Gdacs... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"manager",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"FEED",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"@",
"callback",
"def",
"async_add_geolocati... | [
47,
0
] | [
66,
43
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.__init__ | (self, feed_manager, integration_id, external_id) | Initialize entity with data from feed entry. | Initialize entity with data from feed entry. | def __init__(self, feed_manager, integration_id, external_id):
"""Initialize entity with data from feed entry."""
self._feed_manager = feed_manager
self._integration_id = integration_id
self._external_id = external_id
self._title = None
self._distance = None
self.... | [
"def",
"__init__",
"(",
"self",
",",
"feed_manager",
",",
"integration_id",
",",
"external_id",
")",
":",
"self",
".",
"_feed_manager",
"=",
"feed_manager",
"self",
".",
"_integration_id",
"=",
"integration_id",
"self",
".",
"_external_id",
"=",
"external_id",
"... | [
72,
4
] | [
95,
41
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
self._remove_signal_delete = async_dispatcher_connect(
self.hass, f"gdacs_delete_{self._external_id}", self._delete_callback
)
self._remove_signal_update = async_dispatcher_connect(
self... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_remove_signal_delete",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"f\"gdacs_delete_{self._external_id}\"",
",",
"self",
".",
"_delete_callback",
")",
"self",
".",
"_rem... | [
97,
4
] | [
104,
9
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.async_will_remove_from_hass | (self) | Call when entity will be removed from hass. | Call when entity will be removed from hass. | async def async_will_remove_from_hass(self) -> None:
"""Call when entity will be removed from hass."""
self._remove_signal_delete()
self._remove_signal_update()
# Remove from entity registry.
entity_registry = await async_get_registry(self.hass)
if self.entity_id in entit... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_remove_signal_delete",
"(",
")",
"self",
".",
"_remove_signal_update",
"(",
")",
"# Remove from entity registry.",
"entity_registry",
"=",
"await",
"async_get_registry",
... | [
106,
4
] | [
113,
56
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent._delete_callback | (self) | Remove this entity. | Remove this entity. | def _delete_callback(self):
"""Remove this entity."""
self.hass.async_create_task(self.async_remove()) | [
"def",
"_delete_callback",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"self",
".",
"async_remove",
"(",
")",
")"
] | [
116,
4
] | [
118,
56
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
121,
4
] | [
123,
49
] | python | en | ['en', 'sn', 'en'] | True |
GdacsEvent.should_poll | (self) | No polling needed for GDACS feed location events. | No polling needed for GDACS feed location events. | def should_poll(self):
"""No polling needed for GDACS feed location events."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
126,
4
] | [
128,
20
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.async_update | (self) | Update this entity from the data held in the feed manager. | Update this entity from the data held in the feed manager. | async def async_update(self):
"""Update this entity from the data held in the feed manager."""
_LOGGER.debug("Updating %s", self._external_id)
feed_entry = self._feed_manager.get_entry(self._external_id)
if feed_entry:
self._update_from_feed(feed_entry) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating %s\"",
",",
"self",
".",
"_external_id",
")",
"feed_entry",
"=",
"self",
".",
"_feed_manager",
".",
"get_entry",
"(",
"self",
".",
"_external_id",
")",
"if",
"... | [
130,
4
] | [
135,
46
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent._update_from_feed | (self, feed_entry) | Update the internal state from the provided feed entry. | Update the internal state from the provided feed entry. | def _update_from_feed(self, feed_entry):
"""Update the internal state from the provided feed entry."""
event_name = feed_entry.event_name
if not event_name:
# Earthquakes usually don't have an event name.
event_name = f"{feed_entry.country} ({feed_entry.event_id})"
... | [
"def",
"_update_from_feed",
"(",
"self",
",",
"feed_entry",
")",
":",
"event_name",
"=",
"feed_entry",
".",
"event_name",
"if",
"not",
"event_name",
":",
"# Earthquakes usually don't have an event name.",
"event_name",
"=",
"f\"{feed_entry.country} ({feed_entry.event_id})\"",... | [
137,
4
] | [
168,
42
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.unique_id | (self) | Return a unique ID containing latitude/longitude and external id. | Return a unique ID containing latitude/longitude and external id. | def unique_id(self) -> Optional[str]:
"""Return a unique ID containing latitude/longitude and external id."""
return f"{self._integration_id}_{self._external_id}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"f\"{self._integration_id}_{self._external_id}\""
] | [
171,
4
] | [
173,
60
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
if self._event_type_short and self._event_type_short in ICONS:
return ICONS[self._event_type_short]
return DEFAULT_ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_event_type_short",
"and",
"self",
".",
"_event_type_short",
"in",
"ICONS",
":",
"return",
"ICONS",
"[",
"self",
".",
"_event_type_short",
"]",
"return",
"DEFAULT_ICON"
] | [
176,
4
] | [
180,
27
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.source | (self) | Return source value of this external event. | Return source value of this external event. | def source(self) -> str:
"""Return source value of this external event."""
return SOURCE | [
"def",
"source",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SOURCE"
] | [
183,
4
] | [
185,
21
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> Optional[str]:
"""Return the name of the entity."""
return self._title | [
"def",
"name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_title"
] | [
188,
4
] | [
190,
26
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.distance | (self) | Return distance value of this external event. | Return distance value of this external event. | def distance(self) -> Optional[float]:
"""Return distance value of this external event."""
return self._distance | [
"def",
"distance",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_distance"
] | [
193,
4
] | [
195,
29
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.latitude | (self) | Return latitude value of this external event. | Return latitude value of this external event. | def latitude(self) -> Optional[float]:
"""Return latitude value of this external event."""
return self._latitude | [
"def",
"latitude",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_latitude"
] | [
198,
4
] | [
200,
29
] | python | en | ['en', 'la', 'en'] | True |
GdacsEvent.longitude | (self) | Return longitude value of this external event. | Return longitude value of this external event. | def longitude(self) -> Optional[float]:
"""Return longitude value of this external event."""
return self._longitude | [
"def",
"longitude",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"_longitude"
] | [
203,
4
] | [
205,
30
] | python | en | ['en', 'en', 'en'] | True |
GdacsEvent.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
if self.hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL:
return LENGTH_MILES
return LENGTH_KILOMETERS | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"if",
"self",
".",
"hass",
".",
"config",
".",
"units",
".",
"name",
"==",
"CONF_UNIT_SYSTEM_IMPERIAL",
":",
"return",
"LENGTH_MILES",
"return",
"LENGTH_KILOMETERS"
] | [
208,
4
] | [
212,
32
] | python | en | ['en', 'la', 'en'] | True |
GdacsEvent.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
attributes = {}
for key, value in (
(ATTR_EXTERNAL_ID, self._external_id),
(ATTR_DESCRIPTION, self._description),
(ATTR_ATTRIBUTION, self._attribution),
(ATTR_EVENT_TYPE, ... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"(",
"(",
"ATTR_EXTERNAL_ID",
",",
"self",
".",
"_external_id",
")",
",",
"(",
"ATTR_DESCRIPTION",
",",
"self",
".",
"_description",
")"... | [
215,
4
] | [
234,
25
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.__init__ | (self, roller: aiopulse.Roller) | Initialize the roller. | Initialize the roller. | def __init__(self, roller: aiopulse.Roller):
"""Initialize the roller."""
self.roller = roller | [
"def",
"__init__",
"(",
"self",
",",
"roller",
":",
"aiopulse",
".",
"Roller",
")",
":",
"self",
".",
"roller",
"=",
"roller"
] | [
15,
4
] | [
17,
28
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.async_remove_and_unregister | (self) | Unregister from entity and device registry and call entity remove function. | Unregister from entity and device registry and call entity remove function. | async def async_remove_and_unregister(self):
"""Unregister from entity and device registry and call entity remove function."""
LOGGER.error("Removing %s %s", self.__class__.__name__, self.unique_id)
ent_registry = await get_ent_reg(self.hass)
if self.entity_id in ent_registry.entities:
... | [
"async",
"def",
"async_remove_and_unregister",
"(",
"self",
")",
":",
"LOGGER",
".",
"error",
"(",
"\"Removing %s %s\"",
",",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"unique_id",
")",
"ent_registry",
"=",
"await",
"get_ent_reg",
"(",
"self... | [
19,
4
] | [
36,
33
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.async_added_to_hass | (self) | Entity has been added to hass. | Entity has been added to hass. | async def async_added_to_hass(self):
"""Entity has been added to hass."""
self.roller.callback_subscribe(self.notify_update)
self.async_on_remove(
async_dispatcher_connect(
self.hass,
ACMEDA_ENTITY_REMOVE.format(self.roller.id),
self.a... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"roller",
".",
"callback_subscribe",
"(",
"self",
".",
"notify_update",
")",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"ACMEDA_ENTITY... | [
38,
4
] | [
48,
9
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.async_will_remove_from_hass | (self) | Entity being removed from hass. | Entity being removed from hass. | async def async_will_remove_from_hass(self):
"""Entity being removed from hass."""
self.roller.callback_unsubscribe(self.notify_update) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"roller",
".",
"callback_unsubscribe",
"(",
"self",
".",
"notify_update",
")"
] | [
50,
4
] | [
52,
60
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.notify_update | (self) | Write updated device state information. | Write updated device state information. | def notify_update(self):
"""Write updated device state information."""
LOGGER.debug("Device update notification received: %s", self.name)
self.async_write_ha_state() | [
"def",
"notify_update",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Device update notification received: %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
55,
4
] | [
58,
35
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.should_poll | (self) | Report that Acmeda entities do not need polling. | Report that Acmeda entities do not need polling. | def should_poll(self):
"""Report that Acmeda entities do not need polling."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
61,
4
] | [
63,
20
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.unique_id | (self) | Return the unique ID of this roller. | Return the unique ID of this roller. | def unique_id(self):
"""Return the unique ID of this roller."""
return self.roller.id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"roller",
".",
"id"
] | [
66,
4
] | [
68,
29
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.device_id | (self) | Return the ID of this roller. | Return the ID of this roller. | def device_id(self):
"""Return the ID of this roller."""
return self.roller.id | [
"def",
"device_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"roller",
".",
"id"
] | [
71,
4
] | [
73,
29
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.name | (self) | Return the name of roller. | Return the name of roller. | def name(self):
"""Return the name of roller."""
return self.roller.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"roller",
".",
"name"
] | [
76,
4
] | [
78,
31
] | python | en | ['en', 'en', 'en'] | True |
AcmedaBase.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self.unique_id)},
"name": self.roller.name,
"manufacturer": "Rollease Acmeda",
"via_device": (DOMAIN, self.roller.hub.id),
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"roller",
".",
"name",
",",
"\"manufacturer\"",
":",
"\"Rollease Acmeda\"",
... | [
81,
4
] | [
88,
9
] | python | en | ['en', 'en', 'en'] | True |
do_http_discovery | (config, hass, hass_client) | Submit a request to the Smart Home HTTP API. | Submit a request to the Smart Home HTTP API. | async def do_http_discovery(config, hass, hass_client):
"""Submit a request to the Smart Home HTTP API."""
await async_setup_component(hass, DOMAIN, config)
http_client = await hass_client()
request = get_new_request("Alexa.Discovery", "Discover")
response = await http_client.post(
smart_ho... | [
"async",
"def",
"do_http_discovery",
"(",
"config",
",",
"hass",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"config",
")",
"http_client",
"=",
"await",
"hass_client",
"(",
")",
"request",
"=",
"get_new_requ... | [
10,
0
] | [
21,
19
] | python | en | ['en', 'en', 'en'] | True |
test_http_api | (hass, hass_client) | With `smart_home:` HTTP API is exposed. | With `smart_home:` HTTP API is exposed. | async def test_http_api(hass, hass_client):
"""With `smart_home:` HTTP API is exposed."""
config = {"alexa": {"smart_home": None}}
response = await do_http_discovery(config, hass, hass_client)
response_data = await response.json()
# Here we're testing just the HTTP view glue -- details of discover... | [
"async",
"def",
"test_http_api",
"(",
"hass",
",",
"hass_client",
")",
":",
"config",
"=",
"{",
"\"alexa\"",
":",
"{",
"\"smart_home\"",
":",
"None",
"}",
"}",
"response",
"=",
"await",
"do_http_discovery",
"(",
"config",
",",
"hass",
",",
"hass_client",
"... | [
24,
0
] | [
33,
74
] | python | en | ['en', 'en', 'en'] | True |
test_http_api_disabled | (hass, hass_client) | Without `smart_home:`, the HTTP API is disabled. | Without `smart_home:`, the HTTP API is disabled. | async def test_http_api_disabled(hass, hass_client):
"""Without `smart_home:`, the HTTP API is disabled."""
config = {"alexa": {}}
response = await do_http_discovery(config, hass, hass_client)
assert response.status == HTTP_NOT_FOUND | [
"async",
"def",
"test_http_api_disabled",
"(",
"hass",
",",
"hass_client",
")",
":",
"config",
"=",
"{",
"\"alexa\"",
":",
"{",
"}",
"}",
"response",
"=",
"await",
"do_http_discovery",
"(",
"config",
",",
"hass",
",",
"hass_client",
")",
"assert",
"response"... | [
36,
0
] | [
41,
44
] | python | en | ['en', '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",
")"
] | [
20,
0
] | [
22,
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",
")"
] | [
26,
0
] | [
28,
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\"",
")"
] | [
32,
0
] | [
34,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_triggers | (hass, device_reg, entity_reg) | Test we get the expected triggers from a fan. | Test we get the expected triggers from a fan. | async def test_get_triggers(hass, device_reg, entity_reg):
"""Test we get the expected triggers from a fan."""
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_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
37,
0
] | [
63,
50
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change | (hass, calls) | Test for turn_on and turn_off triggers firing. | Test for turn_on and turn_off triggers firing. | async def test_if_fires_on_state_change(hass, calls):
"""Test for turn_on and turn_off triggers firing."""
hass.states.async_set("fan.entity", STATE_OFF)
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
... | [
"async",
"def",
"test_if_fires_on_state_change",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"fan.entity\"",
",",
"STATE_OFF",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN"... | [
66,
0
] | [
127,
86
] | python | en | ['en', 'en', 'en'] | True |
to_lutron_level | (level) | Convert the given Home Assistant light level (0-255) to Lutron (0-100). | Convert the given Home Assistant light level (0-255) to Lutron (0-100). | def to_lutron_level(level):
"""Convert the given Home Assistant light level (0-255) to Lutron (0-100)."""
return int(round((level * 100) / 255)) | [
"def",
"to_lutron_level",
"(",
"level",
")",
":",
"return",
"int",
"(",
"round",
"(",
"(",
"level",
"*",
"100",
")",
"/",
"255",
")",
")"
] | [
18,
0
] | [
20,
42
] | python | en | ['en', 'en', 'en'] | True |
to_hass_level | (level) | Convert the given Lutron (0-100) light level to Home Assistant (0-255). | Convert the given Lutron (0-100) light level to Home Assistant (0-255). | def to_hass_level(level):
"""Convert the given Lutron (0-100) light level to Home Assistant (0-255)."""
return int((level * 255) // 100) | [
"def",
"to_hass_level",
"(",
"level",
")",
":",
"return",
"int",
"(",
"(",
"level",
"*",
"255",
")",
"//",
"100",
")"
] | [
23,
0
] | [
25,
36
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Lutron Caseta light platform.
Adds dimmers from the Caseta bridge associated with the config_entry as
light entities.
| Set up the Lutron Caseta light platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Lutron Caseta light platform.
Adds dimmers from the Caseta bridge associated with the config_entry as
light entities.
"""
entities = []
bridge = hass.data[CASETA_DOMAIN][config_entry.entry_id]
light_devices ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"bridge",
"=",
"hass",
".",
"data",
"[",
"CASETA_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"light_devices",
... | [
28,
0
] | [
43,
38
] | python | en | ['en', 'ru', 'en'] | True |
LutronCasetaLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BRIGHTNESS",
"|",
"SUPPORT_TRANSITION"
] | [
50,
4
] | [
52,
54
] | python | en | ['da', 'en', 'en'] | True |
LutronCasetaLight.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["current_state"]) | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"to_hass_level",
"(",
"self",
".",
"_device",
"[",
"\"current_state\"",
"]",
")"
] | [
55,
4
] | [
57,
59
] | python | en | ['en', 'no', 'en'] | True |
LutronCasetaLight.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs):
"""Turn the light on."""
brightness = kwargs.pop(ATTR_BRIGHTNESS, 255)
await self._set_brightness(brightness, **kwargs) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"brightness",
"=",
"kwargs",
".",
"pop",
"(",
"ATTR_BRIGHTNESS",
",",
"255",
")",
"await",
"self",
".",
"_set_brightness",
"(",
"brightness",
",",
"*",
"*",
"kwargs",
")"
] | [
68,
4
] | [
72,
56
] | python | en | ['en', 'et', 'en'] | True |
LutronCasetaLight.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs):
"""Turn the light off."""
await self._set_brightness(0, **kwargs) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_set_brightness",
"(",
"0",
",",
"*",
"*",
"kwargs",
")"
] | [
74,
4
] | [
76,
47
] | python | en | ['en', 'zh', 'en'] | True |
LutronCasetaLight.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["current_state"] > 0 | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
"[",
"\"current_state\"",
"]",
">",
"0"
] | [
79,
4
] | [
81,
48
] | python | en | ['en', 'fy', 'en'] | True |
LutronCasetaLight.async_update | (self) | Call when forcing a refresh of the device. | Call when forcing a refresh of the device. | async def async_update(self):
"""Call when forcing a refresh of the device."""
self._device = self._smartbridge.get_device_by_id(self.device_id)
_LOGGER.debug(self._device) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"self",
".",
"_device",
"=",
"self",
".",
"_smartbridge",
".",
"get_device_by_id",
"(",
"self",
".",
"device_id",
")",
"_LOGGER",
".",
"debug",
"(",
"self",
".",
"_device",
")"
] | [
83,
4
] | [
86,
35
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the Lannouncer notification service. | Get the Lannouncer notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Lannouncer notification service."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
return LannouncerNotificationService(hass, host, port) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
")",
"return",
"LannouncerNotificationService",
"... | [
31,
0
] | [
36,
58
] | python | en | ['en', 'en', 'en'] | True |
LannouncerNotificationService.__init__ | (self, hass, host, port) | Initialize the service. | Initialize the service. | def __init__(self, hass, host, port):
"""Initialize the service."""
self._hass = hass
self._host = host
self._port = port | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"host",
",",
"port",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_port",
"=",
"port"
] | [
42,
4
] | [
46,
25
] | python | en | ['en', 'en', 'en'] | True |
LannouncerNotificationService.send_message | (self, message="", **kwargs) | Send a message to Lannouncer. | Send a message to Lannouncer. | def send_message(self, message="", **kwargs):
"""Send a message to Lannouncer."""
data = kwargs.get(ATTR_DATA)
if data is not None and ATTR_METHOD in data:
method = data.get(ATTR_METHOD)
else:
method = ATTR_METHOD_DEFAULT
if method not in ATTR_METHOD_ALLO... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"if",
"data",
"is",
"not",
"None",
"and",
"ATTR_METHOD",
"in",
"data",
":",
"method",
"=",
... | [
48,
4
] | [
83,
67
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_valid_config | (hass) | Test the platform setup with Reddit configuration. | Test the platform setup with Reddit configuration. | async def test_setup_with_valid_config(hass):
"""Test the platform setup with Reddit configuration."""
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
await hass.async_block_till_done()
state = hass.states.get("sensor.reddit_worldnews")
assert int(state.state) == MOCK_RESULTS_LENGT... | [
"async",
"def",
"test_setup_with_valid_config",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"VALID_CONFIG",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"state",
"=",
"hass",
".",
"stat... | [
152,
0
] | [
175,
50
] | python | en | ['en', 'da', 'en'] | True |
test_setup_with_invalid_config | (hass) | Test the platform setup with invalid Reddit configuration. | Test the platform setup with invalid Reddit configuration. | async def test_setup_with_invalid_config(hass):
"""Test the platform setup with invalid Reddit configuration."""
assert await async_setup_component(hass, "sensor", INVALID_SORT_BY_CONFIG)
await hass.async_block_till_done()
assert not hass.states.get("sensor.reddit_worldnews") | [
"async",
"def",
"test_setup_with_invalid_config",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"INVALID_SORT_BY_CONFIG",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"assert",
"not",
"hass",... | [
179,
0
] | [
183,
57
] | python | en | ['en', 'da', 'en'] | True |
ObjectView.__init__ | (self, d) | Set dict as internal dict. | Set dict as internal dict. | def __init__(self, d):
"""Set dict as internal dict."""
self.__dict__ = d | [
"def",
"__init__",
"(",
"self",
",",
"d",
")",
":",
"self",
".",
"__dict__",
"=",
"d"
] | [
67,
4
] | [
69,
25
] | python | en | ['id', 'su', 'en'] | False |
MockPraw.__init__ | (
self,
client_id: str,
client_secret: str,
username: str,
password: str,
user_agent: str,
) | Add mock data for API return. | Add mock data for API return. | def __init__(
self,
client_id: str,
client_secret: str,
username: str,
password: str,
user_agent: str,
):
"""Add mock data for API return."""
self._data = MOCK_RESULTS | [
"def",
"__init__",
"(",
"self",
",",
"client_id",
":",
"str",
",",
"client_secret",
":",
"str",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"user_agent",
":",
"str",
",",
")",
":",
"self",
".",
"_data",
"=",
"MOCK_RESULTS"
] | [
105,
4
] | [
114,
33
] | python | en | ['en', 'no', 'en'] | True |
MockPraw.subreddit | (self, subreddit: str) | Return an instance of a subreddit. | Return an instance of a subreddit. | def subreddit(self, subreddit: str):
"""Return an instance of a subreddit."""
return MockSubreddit(subreddit, self._data) | [
"def",
"subreddit",
"(",
"self",
",",
"subreddit",
":",
"str",
")",
":",
"return",
"MockSubreddit",
"(",
"subreddit",
",",
"self",
".",
"_data",
")"
] | [
116,
4
] | [
118,
51
] | python | en | ['en', 'da', 'en'] | True |
MockSubreddit.__init__ | (self, subreddit: str, data) | Add mock data for API return. | Add mock data for API return. | def __init__(self, subreddit: str, data):
"""Add mock data for API return."""
self._subreddit = subreddit
self._data = data | [
"def",
"__init__",
"(",
"self",
",",
"subreddit",
":",
"str",
",",
"data",
")",
":",
"self",
".",
"_subreddit",
"=",
"subreddit",
"self",
".",
"_data",
"=",
"data"
] | [
124,
4
] | [
127,
25
] | python | en | ['en', 'no', 'en'] | True |
MockSubreddit.top | (self, limit) | Return top posts for a subreddit. | Return top posts for a subreddit. | def top(self, limit):
"""Return top posts for a subreddit."""
return self._return_data(limit) | [
"def",
"top",
"(",
"self",
",",
"limit",
")",
":",
"return",
"self",
".",
"_return_data",
"(",
"limit",
")"
] | [
129,
4
] | [
131,
39
] | python | en | ['en', 'da', 'en'] | True |
MockSubreddit.controversial | (self, limit) | Return controversial posts for a subreddit. | Return controversial posts for a subreddit. | def controversial(self, limit):
"""Return controversial posts for a subreddit."""
return self._return_data(limit) | [
"def",
"controversial",
"(",
"self",
",",
"limit",
")",
":",
"return",
"self",
".",
"_return_data",
"(",
"limit",
")"
] | [
133,
4
] | [
135,
39
] | python | en | ['en', 'en', 'en'] | True |
MockSubreddit.hot | (self, limit) | Return hot posts for a subreddit. | Return hot posts for a subreddit. | def hot(self, limit):
"""Return hot posts for a subreddit."""
return self._return_data(limit) | [
"def",
"hot",
"(",
"self",
",",
"limit",
")",
":",
"return",
"self",
".",
"_return_data",
"(",
"limit",
")"
] | [
137,
4
] | [
139,
39
] | python | en | ['en', 'da', 'en'] | True |
MockSubreddit.new | (self, limit) | Return new posts for a subreddit. | Return new posts for a subreddit. | def new(self, limit):
"""Return new posts for a subreddit."""
return self._return_data(limit) | [
"def",
"new",
"(",
"self",
",",
"limit",
")",
":",
"return",
"self",
".",
"_return_data",
"(",
"limit",
")"
] | [
141,
4
] | [
143,
39
] | python | en | ['en', 'da', 'en'] | True |
MockSubreddit._return_data | (self, limit) | Test method to return modified data. | Test method to return modified data. | def _return_data(self, limit):
"""Test method to return modified data."""
data = copy.deepcopy(self._data)
return data["results"][:limit] | [
"def",
"_return_data",
"(",
"self",
",",
"limit",
")",
":",
"data",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_data",
")",
"return",
"data",
"[",
"\"results\"",
"]",
"[",
":",
"limit",
"]"
] | [
145,
4
] | [
148,
38
] | python | en | ['en', 'en', 'en'] | True |
test_platform_manually_configured | (hass) | Test that we do not discover anything or try to set up a gateway. | Test that we do not discover anything or try to set up a gateway. | async def test_platform_manually_configured(hass):
"""Test that we do not discover anything or try to set up a gateway."""
assert (
await async_setup_component(
hass, SCENE_DOMAIN, {"scene": {"platform": DECONZ_DOMAIN}}
)
is True
)
assert DECONZ_DOMAIN not in hass.dat... | [
"async",
"def",
"test_platform_manually_configured",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"SCENE_DOMAIN",
",",
"{",
"\"scene\"",
":",
"{",
"\"platform\"",
":",
"DECONZ_DOMAIN",
"}",
"}",
")",
"is",
"True",
"... | [
27,
0
] | [
35,
41
] | python | en | ['en', 'en', 'en'] | True |
test_no_scenes | (hass) | Test that scenes can be loaded without scenes being available. | Test that scenes can be loaded without scenes being available. | async def test_no_scenes(hass):
"""Test that scenes can be loaded without scenes being available."""
await setup_deconz_integration(hass)
assert len(hass.states.async_all()) == 0 | [
"async",
"def",
"test_no_scenes",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"0"
] | [
38,
0
] | [
41,
44
] | python | en | ['en', 'en', 'en'] | True |
test_scenes | (hass) | Test that scenes works. | Test that scenes works. | async def test_scenes(hass):
"""Test that scenes works."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["groups"] = deepcopy(GROUPS)
config_entry = await setup_deconz_integration(hass, get_state_response=data)
gateway = get_gateway_from_config_entry(hass, config_entry)
assert len(hass.states.async_... | [
"async",
"def",
"test_scenes",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"groups\"",
"]",
"=",
"deepcopy",
"(",
"GROUPS",
")",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
",",
"g... | [
44,
0
] | [
72,
44
] | python | en | ['en', 'en', 'en'] | True |
create_lookup | (results) | Create a lookup table by key name. | Create a lookup table by key name. | def create_lookup(results):
"""Create a lookup table by key name."""
return {key["key_name"]["web"]: key for key in results} | [
"def",
"create_lookup",
"(",
"results",
")",
":",
"return",
"{",
"key",
"[",
"\"key_name\"",
"]",
"[",
"\"web\"",
"]",
":",
"key",
"for",
"key",
"in",
"results",
"}"
] | [
12,
0
] | [
14,
59
] | python | en | ['en', 'en', 'en'] | True |
rename_keys | (project_id, to_migrate) | Rename keys.
to_migrate is Dict[from_key] = to_key.
| Rename keys. | def rename_keys(project_id, to_migrate):
"""Rename keys.
to_migrate is Dict[from_key] = to_key.
"""
updates = []
lokalise = get_api(project_id)
from_key_data = lokalise.keys_list({"filter_keys": ",".join(to_migrate)})
if len(from_key_data) != len(to_migrate):
print(
f"... | [
"def",
"rename_keys",
"(",
"project_id",
",",
"to_migrate",
")",
":",
"updates",
"=",
"[",
"]",
"lokalise",
"=",
"get_api",
"(",
"project_id",
")",
"from_key_data",
"=",
"lokalise",
".",
"keys_list",
"(",
"{",
"\"filter_keys\"",
":",
"\",\"",
".",
"join",
... | [
17,
0
] | [
50,
46
] | python | en | ['en', 'ht', 'en'] | False |
list_keys_helper | (lokalise, keys, params={}, *, validate=True) | List keys in chunks so it doesn't exceed max URL length. | List keys in chunks so it doesn't exceed max URL length. | def list_keys_helper(lokalise, keys, params={}, *, validate=True):
"""List keys in chunks so it doesn't exceed max URL length."""
results = []
for i in range(0, len(keys), 100):
filter_keys = keys[i : i + 100]
from_key_data = lokalise.keys_list(
{
**params,
... | [
"def",
"list_keys_helper",
"(",
"lokalise",
",",
"keys",
",",
"params",
"=",
"{",
"}",
",",
"*",
",",
"validate",
"=",
"True",
")",
":",
"results",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"keys",
")",
",",
"100",
")... | [
53,
0
] | [
79,
18
] | python | en | ['en', 'en', 'en'] | True |
migrate_project_keys_translations | (from_project_id, to_project_id, to_migrate) | Migrate keys and translations from one project to another.
to_migrate is Dict[from_key] = to_key.
| Migrate keys and translations from one project to another. | def migrate_project_keys_translations(from_project_id, to_project_id, to_migrate):
"""Migrate keys and translations from one project to another.
to_migrate is Dict[from_key] = to_key.
"""
from_lokalise = get_api(from_project_id)
to_lokalise = get_api(to_project_id)
# Fetch keys in target
#... | [
"def",
"migrate_project_keys_translations",
"(",
"from_project_id",
",",
"to_project_id",
",",
"to_migrate",
")",
":",
"from_lokalise",
"=",
"get_api",
"(",
"from_project_id",
")",
"to_lokalise",
"=",
"get_api",
"(",
"to_project_id",
")",
"# Fetch keys in target",
"# We... | [
82,
0
] | [
154,
49
] | python | en | ['en', 'en', 'en'] | True |
find_and_rename_keys | () | Find and rename keys in core. | Find and rename keys in core. | def find_and_rename_keys():
"""Find and rename keys in core."""
to_migrate = {}
for integration in INTEGRATIONS_DIR.iterdir():
strings_file = integration / "strings.json"
if not strings_file.is_file():
continue
strings = json.loads(strings_file.read_text())
if ... | [
"def",
"find_and_rename_keys",
"(",
")",
":",
"to_migrate",
"=",
"{",
"}",
"for",
"integration",
"in",
"INTEGRATIONS_DIR",
".",
"iterdir",
"(",
")",
":",
"strings_file",
"=",
"integration",
"/",
"\"strings.json\"",
"if",
"not",
"strings_file",
".",
"is_file",
... | [
157,
0
] | [
173,
44
] | python | en | ['en', 'en', 'en'] | True |
find_different_languages | () | Find different supported languages. | Find different supported languages. | def find_different_languages():
"""Find different supported languages."""
core_api = get_api(CORE_PROJECT_ID)
frontend_api = get_api(FRONTEND_PROJECT_ID)
core_languages = {lang["lang_iso"] for lang in core_api.languages_list()}
frontend_languages = {lang["lang_iso"] for lang in frontend_api.languag... | [
"def",
"find_different_languages",
"(",
")",
":",
"core_api",
"=",
"get_api",
"(",
"CORE_PROJECT_ID",
")",
"frontend_api",
"=",
"get_api",
"(",
"FRONTEND_PROJECT_ID",
")",
"core_languages",
"=",
"{",
"lang",
"[",
"\"lang_iso\"",
"]",
"for",
"lang",
"in",
"core_a... | [
176,
0
] | [
185,
69
] | python | en | ['en', 'en', 'en'] | True |
interactive_update | () | Interactive update integration strings. | Interactive update integration strings. | def interactive_update():
"""Interactive update integration strings."""
for integration in INTEGRATIONS_DIR.iterdir():
strings_file = integration / "strings.json"
if not strings_file.is_file():
continue
strings = json.loads(strings_file.read_text())
if "title" not ... | [
"def",
"interactive_update",
"(",
")",
":",
"for",
"integration",
"in",
"INTEGRATIONS_DIR",
".",
"iterdir",
"(",
")",
":",
"strings_file",
"=",
"integration",
"/",
"\"strings.json\"",
"if",
"not",
"strings_file",
".",
"is_file",
"(",
")",
":",
"continue",
"str... | [
188,
0
] | [
208,
15
] | python | en | ['en', 'en', 'en'] | True |
find_frontend_states | () | Find frontend states.
Source key -> target key
Add key to integrations strings.json
| Find frontend states. | def find_frontend_states():
"""Find frontend states.
Source key -> target key
Add key to integrations strings.json
"""
frontend_states = json.loads(
(FRONTEND_REPO / "src/translations/en.json").read_text()
)["state"]
# domain => state object
to_write = {}
to_migrate = {}
... | [
"def",
"find_frontend_states",
"(",
")",
":",
"frontend_states",
"=",
"json",
".",
"loads",
"(",
"(",
"FRONTEND_REPO",
"/",
"\"src/translations/en.json\"",
")",
".",
"read_text",
"(",
")",
")",
"[",
"\"state\"",
"]",
"# domain => state object",
"to_write",
"=",
... | [
243,
0
] | [
323,
87
] | python | en | ['en', 'en', 'en'] | True |
apply_data_references | (to_migrate) | Apply references. | Apply references. | def apply_data_references(to_migrate):
"""Apply references."""
for strings_file in INTEGRATIONS_DIR.glob("*/strings.json"):
strings = json.loads(strings_file.read_text())
steps = strings.get("config", {}).get("step")
if not steps:
continue
changed = False
f... | [
"def",
"apply_data_references",
"(",
"to_migrate",
")",
":",
"for",
"strings_file",
"in",
"INTEGRATIONS_DIR",
".",
"glob",
"(",
"\"*/strings.json\"",
")",
":",
"strings",
"=",
"json",
".",
"loads",
"(",
"strings_file",
".",
"read_text",
"(",
")",
")",
"steps",... | [
326,
0
] | [
355,
62
] | python | en | ['en', 'en', 'en'] | False |
run | () | Migrate translations. | Migrate translations. | def run():
"""Migrate translations."""
apply_data_references(
{
"host": "[%key:common::config_flow::data::host%]",
"username": "[%key:common::config_flow::data::username%]",
"password": "[%key:common::config_flow::data::password%]",
"port": "[%key:common::... | [
"def",
"run",
"(",
")",
":",
"apply_data_references",
"(",
"{",
"\"host\"",
":",
"\"[%key:common::config_flow::data::host%]\"",
",",
"\"username\"",
":",
"\"[%key:common::config_flow::data::username%]\"",
",",
"\"password\"",
":",
"\"[%key:common::config_flow::data::password%]\""... | [
358,
0
] | [
385,
12
] | python | en | ['en', 'en', 'en'] | False |
async_setup_entry | (
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up NZBGet sensor based on a config entry. | Set up NZBGet sensor based on a config entry. | async def async_setup_entry(
hass: HomeAssistantType,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up NZBGet sensor based on a config entry."""
coordinator: NZBGetDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][
DATA_COORDINATOR
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":... | [
14,
0
] | [
32,
32
] | python | en | ['en', 'da', 'en'] | True |
NZBGetDownloadSwitch.__init__ | (
self,
coordinator: NZBGetDataUpdateCoordinator,
entry_id: str,
entry_name: str,
) | Initialize a new NZBGet switch. | Initialize a new NZBGet switch. | def __init__(
self,
coordinator: NZBGetDataUpdateCoordinator,
entry_id: str,
entry_name: str,
):
"""Initialize a new NZBGet switch."""
self._unique_id = f"{entry_id}_download"
super().__init__(
coordinator=coordinator,
entry_id=entry_i... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"NZBGetDataUpdateCoordinator",
",",
"entry_id",
":",
"str",
",",
"entry_name",
":",
"str",
",",
")",
":",
"self",
".",
"_unique_id",
"=",
"f\"{entry_id}_download\"",
"super",
"(",
")",
".",
"__init__",
... | [
38,
4
] | [
51,
9
] | python | en | ['en', 'pl', 'en'] | True |
NZBGetDownloadSwitch.unique_id | (self) | Return the unique ID of the switch. | Return the unique ID of the switch. | def unique_id(self) -> str:
"""Return the unique ID of the switch."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
54,
4
] | [
56,
30
] | python | en | ['en', 'en', 'en'] | True |
NZBGetDownloadSwitch.is_on | (self) | Return the state of the switch. | Return the state of the switch. | def is_on(self):
"""Return the state of the switch."""
return not self.coordinator.data["status"].get("DownloadPaused", False) | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"status\"",
"]",
".",
"get",
"(",
"\"DownloadPaused\"",
",",
"False",
")"
] | [
59,
4
] | [
61,
79
] | python | en | ['en', 'en', 'en'] | True |
NZBGetDownloadSwitch.async_turn_on | (self, **kwargs) | Set downloads to enabled. | Set downloads to enabled. | async def async_turn_on(self, **kwargs) -> None:
"""Set downloads to enabled."""
await self.hass.async_add_executor_job(self.coordinator.nzbget.resumedownload)
await self.coordinator.async_request_refresh() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"coordinator",
".",
"nzbget",
".",
"resumedownload",
")",
"await",
"self",
".",
... | [
63,
4
] | [
66,
54
] | python | en | ['en', 'en', 'en'] | True |
NZBGetDownloadSwitch.async_turn_off | (self, **kwargs) | Set downloads to paused. | Set downloads to paused. | async def async_turn_off(self, **kwargs) -> None:
"""Set downloads to paused."""
await self.hass.async_add_executor_job(self.coordinator.nzbget.pausedownload)
await self.coordinator.async_request_refresh() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"coordinator",
".",
"nzbget",
".",
"pausedownload",
")",
"await",
"self",
".",
... | [
68,
4
] | [
71,
54
] | python | en | ['en', 'en', 'en'] | True |
test_reproducing_states | (hass, caplog) | Test reproducing Input select states. | Test reproducing Input select states. | async def test_reproducing_states(hass, caplog):
"""Test reproducing Input select states."""
# Setup entity
assert await async_setup_component(
hass,
"input_select",
{
"input_select": {
"test_select": {"options": VALID_OPTION_SET1, "initial": VALID_OPTION... | [
"async",
"def",
"test_reproducing_states",
"(",
"hass",
",",
"caplog",
")",
":",
"# Setup entity",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"input_select\"",
",",
"{",
"\"input_select\"",
":",
"{",
"\"test_select\"",
":",
"{",
"\"options\"",
... | [
16,
0
] | [
67,
57
] | python | en | ['en', 'en', 'en'] | True |
get_packages | () |
All of the package data: What's parsed from download.lst,
plus our additions.
|
All of the package data: What's parsed from download.lst,
plus our additions.
| def get_packages():
"""
All of the package data: What's parsed from download.lst,
plus our additions.
"""
return apply_additions(get_packages_from_download_list(),
get_additions()) | [
"def",
"get_packages",
"(",
")",
":",
"return",
"apply_additions",
"(",
"get_packages_from_download_list",
"(",
")",
",",
"get_additions",
"(",
")",
")"
] | [
77,
0
] | [
83,
43
] | python | en | ['en', 'error', 'th'] | False |
get_additions | () |
A mapping from package name (the all-caps identifiers used in
`download.lst`) to a dict of additional attributes to set on the package.
|
A mapping from package name (the all-caps identifiers used in
`download.lst`) to a dict of additional attributes to set on the package.
| def get_additions():
"""
A mapping from package name (the all-caps identifiers used in
`download.lst`) to a dict of additional attributes to set on the package.
"""
with open('./libreoffice-srcs-additions.json') as f:
return json.load(f) | [
"def",
"get_additions",
"(",
")",
":",
"with",
"open",
"(",
"'./libreoffice-srcs-additions.json'",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
")"
] | [
86,
0
] | [
92,
27
] | python | en | ['en', 'error', 'th'] | False |
get_packages_from_download_list | () |
The result of parsing `download.lst`: A list of dicts containing keys
'name', 'tarball', 'md5', 'brief'.
|
The result of parsing `download.lst`: A list of dicts containing keys
'name', 'tarball', 'md5', 'brief'.
| def get_packages_from_download_list():
"""
The result of parsing `download.lst`: A list of dicts containing keys
'name', 'tarball', 'md5', 'brief'.
"""
def lines():
for x in sub_symbols(parse_lines(get_lines())):
interpretation = interpret(x)
if interpretation == '... | [
"def",
"get_packages_from_download_list",
"(",
")",
":",
"def",
"lines",
"(",
")",
":",
"for",
"x",
"in",
"sub_symbols",
"(",
"parse_lines",
"(",
"get_lines",
"(",
")",
")",
")",
":",
"interpretation",
"=",
"interpret",
"(",
"x",
")",
"if",
"interpretation... | [
101,
0
] | [
136,
38
] | python | en | ['en', 'error', 'th'] | False |
dict_merge | (xs) |
>>> dict_merge([{1: 2}, {3: 4}, {3: 5}])
{1: 2, 3: 4}
|
>>> dict_merge([{1: 2}, {3: 4}, {3: 5}])
{1: 2, 3: 4}
| def dict_merge(xs):
"""
>>> dict_merge([{1: 2}, {3: 4}, {3: 5}])
{1: 2, 3: 4}
"""
return dict(collections.ChainMap(*xs)) | [
"def",
"dict_merge",
"(",
"xs",
")",
":",
"return",
"dict",
"(",
"collections",
".",
"ChainMap",
"(",
"*",
"xs",
")",
")"
] | [
139,
0
] | [
144,
42
] | python | en | ['en', 'error', 'th'] | False |
groupby | (xs, f) |
>>> groupby([1, 2, 3, 4], lambda x: x % 2)
[(0, [2, 4]), (1, [1, 3])]
|
>>> groupby([1, 2, 3, 4], lambda x: x % 2)
[(0, [2, 4]), (1, [1, 3])]
| def groupby(xs, f):
"""
>>> groupby([1, 2, 3, 4], lambda x: x % 2)
[(0, [2, 4]), (1, [1, 3])]
"""
for (k, iter) in itertools.groupby(sorted(xs, key=f), f):
group = list(iter)
yield (f(group[0]), group) | [
"def",
"groupby",
"(",
"xs",
",",
"f",
")",
":",
"for",
"(",
"k",
",",
"iter",
")",
"in",
"itertools",
".",
"groupby",
"(",
"sorted",
"(",
"xs",
",",
"key",
"=",
"f",
")",
",",
"f",
")",
":",
"group",
"=",
"list",
"(",
"iter",
")",
"yield",
... | [
147,
0
] | [
154,
34
] | python | en | ['en', 'error', 'th'] | False |
parse_lines | (lines) |
Input: List of strings (the lines from `download.lst`
Output: Iterator of dicts with keys 'key', 'value', and 'index'
|
Input: List of strings (the lines from `download.lst`
Output: Iterator of dicts with keys 'key', 'value', and 'index'
| def parse_lines(lines):
"""
Input: List of strings (the lines from `download.lst`
Output: Iterator of dicts with keys 'key', 'value', and 'index'
"""
for (index, line) in enumerate(lines):
x = { 'index': index, 'original': line }
result = parse_line(line)
if result == 'not... | [
"def",
"parse_lines",
"(",
"lines",
")",
":",
"for",
"(",
"index",
",",
"line",
")",
"in",
"enumerate",
"(",
"lines",
")",
":",
"x",
"=",
"{",
"'index'",
":",
"index",
",",
"'original'",
":",
"line",
"}",
"result",
"=",
"parse_line",
"(",
"line",
"... | [
172,
0
] | [
189,
37
] | python | en | ['en', 'error', 'th'] | False |
parse_line | (line) |
Input: A string
Output: One of 1. A dict with keys 'key', 'value'
2. 'nothing' (if the line contains no information)
2. 'unrecognized' (if parsing failed)
|
Input: A string
Output: One of 1. A dict with keys 'key', 'value'
2. 'nothing' (if the line contains no information)
2. 'unrecognized' (if parsing failed)
| def parse_line(line):
"""
Input: A string
Output: One of 1. A dict with keys 'key', 'value'
2. 'nothing' (if the line contains no information)
2. 'unrecognized' (if parsing failed)
"""
if re.match('\s*(#.*)?$', line):
return 'nothing'
match = re.ma... | [
"def",
"parse_line",
"(",
"line",
")",
":",
"if",
"re",
".",
"match",
"(",
"'\\s*(#.*)?$'",
",",
"line",
")",
":",
"return",
"'nothing'",
"match",
"=",
"re",
".",
"match",
"(",
"'\\s*export\\s+([^:\\s]+)\\s*:=\\s*(.*)$'",
",",
"line",
")",
"if",
"match",
"... | [
192,
0
] | [
211,
29
] | python | en | ['en', 'error', 'th'] | False |
sub_symbols | (xs) |
Do substitution of variables across all lines.
>>> sub_symbols([{'key': 'a', 'value': 'x'},
... {'key': 'c': 'value': '$(a)yz'}])
[{'key': 'a', 'value': 'x'}, {'key': 'c': 'value': 'xyz'}]
|
Do substitution of variables across all lines. | def sub_symbols(xs):
"""
Do substitution of variables across all lines.
>>> sub_symbols([{'key': 'a', 'value': 'x'},
... {'key': 'c': 'value': '$(a)yz'}])
[{'key': 'a', 'value': 'x'}, {'key': 'c': 'value': 'xyz'}]
"""
xs = list(xs)
symbols = {x['key']: x for x in xs}
... | [
"def",
"sub_symbols",
"(",
"xs",
")",
":",
"xs",
"=",
"list",
"(",
"xs",
")",
"symbols",
"=",
"{",
"x",
"[",
"'key'",
"]",
":",
"x",
"for",
"x",
"in",
"xs",
"}",
"def",
"get_value",
"(",
"k",
")",
":",
"x",
"=",
"symbols",
".",
"get",
"(",
... | [
214,
0
] | [
233,
29
] | python | en | ['en', 'error', 'th'] | False |
sub_str | (string, func) |
Do substitution of variables in a single line.
>>> sub_str("x = $(x)", lambda k: {'x': 'a'}[k])
"x = a"
|
Do substitution of variables in a single line. | def sub_str(string, func):
"""
Do substitution of variables in a single line.
>>> sub_str("x = $(x)", lambda k: {'x': 'a'}[k])
"x = a"
"""
def func2(m):
x = m.group(1)
result = func(x)
return result if result is not None else x
return re.sub(r'\$\(([^\$\(\)]+)\)', ... | [
"def",
"sub_str",
"(",
"string",
",",
"func",
")",
":",
"def",
"func2",
"(",
"m",
")",
":",
"x",
"=",
"m",
".",
"group",
"(",
"1",
")",
"result",
"=",
"func",
"(",
"x",
")",
"return",
"result",
"if",
"result",
"is",
"not",
"None",
"else",
"x",
... | [
236,
0
] | [
249,
55
] | python | en | ['en', 'error', 'th'] | False |
interpret | (x) |
Input: Dict with keys 'key' and 'value'
Output: One of 1. Dict with keys 'name' and 'attrs'
2. 'unrecognized' (if interpretation failed)
|
Input: Dict with keys 'key' and 'value'
Output: One of 1. Dict with keys 'name' and 'attrs'
2. 'unrecognized' (if interpretation failed)
| def interpret(x):
"""
Input: Dict with keys 'key' and 'value'
Output: One of 1. Dict with keys 'name' and 'attrs'
2. 'unrecognized' (if interpretation failed)
"""
for f in [interpret_md5, interpret_sha256, interpret_tarball_with_md5, interpret_tarball, interpret_jar]:
resu... | [
"def",
"interpret",
"(",
"x",
")",
":",
"for",
"f",
"in",
"[",
"interpret_md5",
",",
"interpret_sha256",
",",
"interpret_tarball_with_md5",
",",
"interpret_tarball",
",",
"interpret_jar",
"]",
":",
"result",
"=",
"f",
"(",
"x",
")",
"if",
"result",
"is",
"... | [
252,
0
] | [
263,
25
] | python | en | ['en', 'error', 'th'] | False |
interpret_md5 | (x) |
>>> interpret_md5("ODFGEN_MD5SUM", "32572ea48d9021bbd6fa317ddb697abc")
{'name': 'ODFGEN', 'attrs': {'md5': '32572ea48d9021bbd6fa317ddb697abc'}}
|
>>> interpret_md5("ODFGEN_MD5SUM", "32572ea48d9021bbd6fa317ddb697abc")
{'name': 'ODFGEN', 'attrs': {'md5': '32572ea48d9021bbd6fa317ddb697abc'}}
| def interpret_md5(x):
"""
>>> interpret_md5("ODFGEN_MD5SUM", "32572ea48d9021bbd6fa317ddb697abc")
{'name': 'ODFGEN', 'attrs': {'md5': '32572ea48d9021bbd6fa317ddb697abc'}}
"""
match = re.match('^(.*)_MD5SUM$', x['key'])
if match:
return {'name': match.group(1),
'attrs': {... | [
"def",
"interpret_md5",
"(",
"x",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"'^(.*)_MD5SUM$'",
",",
"x",
"[",
"'key'",
"]",
")",
"if",
"match",
":",
"return",
"{",
"'name'",
":",
"match",
".",
"group",
"(",
"1",
")",
",",
"'attrs'",
":",
"... | [
266,
0
] | [
276,
59
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.