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
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect.""" if data[CONF_VERSION] not in SUPPORTED_VERSIONS: raise WrongVersion try: api = get_api(hass, data) await api.get_data() except glances_api.exceptions.GlancesApiConnection...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "if", "data", "[", "CONF_VERSION", "]", "not", "in", "SUPPORTED_VERSIONS", ":", "raise", "WrongVersion", "try", ":", "api", "=", "get_api", "(", "hass"...
[ 43, 0 ]
[ 51, 36 ]
python
en
['en', 'en', 'en']
True
GlancesFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return GlancesOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "GlancesOptionsFlowHandler", "(", "config_entry", ")" ]
[ 61, 4 ]
[ 63, 54 ]
python
en
['en', 'en', 'en']
True
GlancesFlowHandler.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]}) try: await validate_input(self.hass, user_input) ret...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "self", ".", "_async_abort_entries_match", "(", "{", "CONF_HOST", ":", "user_input", "[", "CONF...
[ 65, 4 ]
[ 82, 9 ]
python
en
['en', 'en', 'en']
True
GlancesFlowHandler.async_step_import
(self, import_config)
Import from Glances sensor config.
Import from Glances sensor config.
async def async_step_import(self, import_config): """Import from Glances sensor config.""" return await self.async_step_user(user_input=import_config)
[ "async", "def", "async_step_import", "(", "self", ",", "import_config", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", "=", "import_config", ")" ]
[ 84, 4 ]
[ 87, 67 ]
python
en
['en', 'pt', 'en']
True
GlancesOptionsFlowHandler.__init__
(self, config_entry)
Initialize Glances options flow.
Initialize Glances options flow.
def __init__(self, config_entry): """Initialize Glances options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 93, 4 ]
[ 95, 40 ]
python
en
['en', 'fr', 'en']
True
GlancesOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the Glances options.
Manage the Glances options.
async def async_step_init(self, user_input=None): """Manage the Glances options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) options = { vol.Optional( CONF_SCAN_INTERVAL, default=self.config_entr...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "options", ...
[ 97, 4 ]
[ 111, 84 ]
python
en
['en', 'en', 'en']
True
uptime
(ut, facter)
Check uptime and facts to get the uptime information. Prefer uptime to facts. Returns: insights.combiners.uptime.Uptime: A named tuple with `currtime`, `updays`, `uphhmm`, `users`, `loadavg` and `uptime` components. Raises: Exception: If no data is available from both of the parse...
Check uptime and facts to get the uptime information.
def uptime(ut, facter): """Check uptime and facts to get the uptime information. Prefer uptime to facts. Returns: insights.combiners.uptime.Uptime: A named tuple with `currtime`, `updays`, `uphhmm`, `users`, `loadavg` and `uptime` components. Raises: Exception: If no data is a...
[ "def", "uptime", "(", "ut", ",", "facter", ")", ":", "ut", "=", "ut", "if", "ut", "and", "ut", ".", "loadavg", ":", "return", "Uptime", "(", "ut", ".", "currtime", ",", "ut", ".", "updays", ",", "ut", ".", "uphhmm", ",", "ut", ".", "users", ","...
[ 30, 0 ]
[ 59, 56 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the RESTful sensor.
Set up the RESTful sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the RESTful sensor.""" # Must update the sensor now (including fetching the rest resource) to # ensure it's updating its state. if discovery_info is not None: conf, coordinator, rest = await async_ge...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "# Must update the sensor now (including fetching the rest resource) to", "# ensure it's updating its state.", "if", "discovery_info", "i...
[ 40, 0 ]
[ 86, 5 ]
python
en
['en', 'da', 'en']
True
RestSensor.__init__
( self, coordinator, rest, name, unit_of_measurement, device_class, value_template, json_attrs, force_update, resource_template, json_attrs_path, )
Initialize the REST sensor.
Initialize the REST sensor.
def __init__( self, coordinator, rest, name, unit_of_measurement, device_class, value_template, json_attrs, force_update, resource_template, json_attrs_path, ): """Initialize the REST sensor.""" super().__init__(...
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "rest", ",", "name", ",", "unit_of_measurement", ",", "device_class", ",", "value_template", ",", "json_attrs", ",", "force_update", ",", "resource_template", ",", "json_attrs_path", ",", ")", ":", "super"...
[ 92, 4 ]
[ 114, 47 ]
python
en
['en', 'en', 'en']
True
RestSensor.native_unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit_of_measurement
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 117, 4 ]
[ 119, 40 ]
python
en
['en', 'en', 'en']
True
RestSensor.native_value
(self)
Return the state of the device.
Return the state of the device.
def native_value(self): """Return the state of the device.""" return self._state
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 122, 4 ]
[ 124, 26 ]
python
en
['en', 'en', 'en']
True
RestSensor.extra_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def extra_state_attributes(self): """Return the state attributes.""" return self._attributes
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 127, 4 ]
[ 129, 31 ]
python
en
['en', 'en', 'en']
True
RestSensor._update_from_rest_data
(self)
Update state from the rest data.
Update state from the rest data.
def _update_from_rest_data(self): """Update state from the rest data.""" value = self.rest.data _LOGGER.debug("Data fetched from resource: %s", value) if self.rest.headers is not None: # If the http request failed, headers will be None content_type = self.rest.hea...
[ "def", "_update_from_rest_data", "(", "self", ")", ":", "value", "=", "self", ".", "rest", ".", "data", "_LOGGER", ".", "debug", "(", "\"Data fetched from resource: %s\"", ",", "value", ")", "if", "self", ".", "rest", ".", "headers", "is", "not", "None", "...
[ 131, 4 ]
[ 187, 27 ]
python
en
['en', 'en', 'en']
True
tostring
(element)
Serialize an element and its child nodes to a string
Serialize an element and its child nodes to a string
def tostring(element): """Serialize an element and its child nodes to a string""" rv = [] def serializeElement(element): if not hasattr(element, "tag"): if element.docinfo.internalDTD: if element.docinfo.doctype: dtd_str = element.docinfo.doctype ...
[ "def", "tostring", "(", "element", ")", ":", "rv", "=", "[", "]", "def", "serializeElement", "(", "element", ")", ":", "if", "not", "hasattr", "(", "element", ",", "\"tag\"", ")", ":", "if", "element", ".", "docinfo", ".", "internalDTD", ":", "if", "...
[ 143, 0 ]
[ 181, 22 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up the sensor platform.
Set up the sensor platform.
async def async_setup_entry(hass, entry, async_add_entities): """Set up the sensor platform.""" coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR] entities = [] for item_id, item in coordinator.data.items(): id_len = len(item_id) item_kind = item_id[-2] entity_setting...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "COORDINATOR", "]", "entities", "=", "[", "]", "for...
[ 16, 0 ]
[ 48, 32 ]
python
en
['en', 'da', 'en']
True
OmnilogicSensor.__init__
( self, coordinator: OmniLogicUpdateCoordinator, kind: str, name: str, device_class: str, icon: str, unit: str, item_id: tuple, state_key: str, )
Initialize Entities.
Initialize Entities.
def __init__( self, coordinator: OmniLogicUpdateCoordinator, kind: str, name: str, device_class: str, icon: str, unit: str, item_id: tuple, state_key: str, ) -> None: """Initialize Entities.""" super().__init__( coor...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "OmniLogicUpdateCoordinator", ",", "kind", ":", "str", ",", "name", ":", "str", ",", "device_class", ":", "str", ",", "icon", ":", "str", ",", "unit", ":", "str", ",", "item_id", ":", "tuple", ",...
[ 54, 4 ]
[ 80, 35 ]
python
en
['en', 'en', 'en']
False
OmnilogicSensor.device_class
(self)
Return the device class of the entity.
Return the device class of the entity.
def device_class(self): """Return the device class of the entity.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 83, 4 ]
[ 85, 33 ]
python
en
['en', 'en', 'en']
True
OmnilogicSensor.native_unit_of_measurement
(self)
Return the right unit of measure.
Return the right unit of measure.
def native_unit_of_measurement(self): """Return the right unit of measure.""" return self._unit
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 88, 4 ]
[ 90, 25 ]
python
en
['en', 'en', 'en']
True
OmniLogicTemperatureSensor.native_value
(self)
Return the state for the temperature sensor.
Return the state for the temperature sensor.
def native_value(self): """Return the state for the temperature sensor.""" sensor_data = self.coordinator.data[self._item_id][self._state_key] hayward_state = sensor_data hayward_unit_of_measure = TEMP_FAHRENHEIT state = sensor_data if self._unit_type == "Metric": ...
[ "def", "native_value", "(", "self", ")", ":", "sensor_data", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_item_id", "]", "[", "self", ".", "_state_key", "]", "hayward_state", "=", "sensor_data", "hayward_unit_of_measure", "=", "TEMP_FAHREN...
[ 97, 4 ]
[ 118, 20 ]
python
en
['en', 'en', 'en']
True
OmniLogicPumpSpeedSensor.native_value
(self)
Return the state for the pump speed sensor.
Return the state for the pump speed sensor.
def native_value(self): """Return the state for the pump speed sensor.""" pump_type = PUMP_TYPES[ self.coordinator.data[self._item_id].get( "Filter-Type", self.coordinator.data[self._item_id].get("Type", {}) ) ] pump_speed = self.coordinator.data[...
[ "def", "native_value", "(", "self", ")", ":", "pump_type", "=", "PUMP_TYPES", "[", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_item_id", "]", ".", "get", "(", "\"Filter-Type\"", ",", "self", ".", "coordinator", ".", "data", "[", "self", ...
[ 125, 4 ]
[ 153, 20 ]
python
en
['en', 'en', 'en']
True
OmniLogicSaltLevelSensor.native_value
(self)
Return the state for the salt level sensor.
Return the state for the salt level sensor.
def native_value(self): """Return the state for the salt level sensor.""" salt_return = self.coordinator.data[self._item_id][self._state_key] unit_of_measurement = self._unit if self._unit_type == "Metric": salt_return = round(int(salt_return) / 1000, 2) unit_of...
[ "def", "native_value", "(", "self", ")", ":", "salt_return", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_item_id", "]", "[", "self", ".", "_state_key", "]", "unit_of_measurement", "=", "self", ".", "_unit", "if", "self", ".", "_unit...
[ 160, 4 ]
[ 172, 26 ]
python
en
['en', 'no', 'en']
True
OmniLogicChlorinatorSensor.native_value
(self)
Return the state for the chlorinator sensor.
Return the state for the chlorinator sensor.
def native_value(self): """Return the state for the chlorinator sensor.""" state = self.coordinator.data[self._item_id][self._state_key] return state
[ "def", "native_value", "(", "self", ")", ":", "state", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_item_id", "]", "[", "self", ".", "_state_key", "]", "return", "state" ]
[ 179, 4 ]
[ 183, 20 ]
python
en
['en', 'no', 'en']
True
OmniLogicPHSensor.native_value
(self)
Return the state for the pH sensor.
Return the state for the pH sensor.
def native_value(self): """Return the state for the pH sensor.""" ph_state = self.coordinator.data[self._item_id][self._state_key] if ph_state == 0: ph_state = None else: ph_state = float(ph_state) + float( self.coordinator.config_entry.options.g...
[ "def", "native_value", "(", "self", ")", ":", "ph_state", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_item_id", "]", "[", "self", ".", "_state_key", "]", "if", "ph_state", "==", "0", ":", "ph_state", "=", "None", "else", ":", "p...
[ 190, 4 ]
[ 204, 23 ]
python
en
['en', 'en', 'en']
True
OmniLogicORPSensor.__init__
( self, coordinator: OmniLogicUpdateCoordinator, state_key: str, name: str, kind: str, item_id: tuple, device_class: str, icon: str, unit: str, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, coordinator: OmniLogicUpdateCoordinator, state_key: str, name: str, kind: str, item_id: tuple, device_class: str, icon: str, unit: str, ) -> None: """Initialize the sensor.""" super().__init__( co...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "OmniLogicUpdateCoordinator", ",", "state_key", ":", "str", ",", "name", ":", "str", ",", "kind", ":", "str", ",", "item_id", ":", "tuple", ",", "device_class", ":", "str", ",", "icon", ":", "str",...
[ 210, 4 ]
[ 231, 9 ]
python
en
['en', 'en', 'en']
True
OmniLogicORPSensor.native_value
(self)
Return the state for the ORP sensor.
Return the state for the ORP sensor.
def native_value(self): """Return the state for the ORP sensor.""" orp_state = int(self.coordinator.data[self._item_id][self._state_key]) if orp_state == -1: orp_state = None return orp_state
[ "def", "native_value", "(", "self", ")", ":", "orp_state", "=", "int", "(", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_item_id", "]", "[", "self", ".", "_state_key", "]", ")", "if", "orp_state", "==", "-", "1", ":", "orp_state", "="...
[ 234, 4 ]
[ 242, 24 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the Sure Petcare integration.
Set up the Sure Petcare integration.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Sure Petcare integration.""" conf = config[DOMAIN] hass.data.setdefault(DOMAIN, {}) try: surepy = Surepy( conf[CONF_USERNAME], conf[CONF_PASSWORD], auth_token=None, ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "conf", "=", "config", "[", "DOMAIN", "]", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "try", "...
[ 61, 0 ]
[ 139, 15 ]
python
en
['en', 'fr', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the Toon components.
Set up the Toon components.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Toon components.""" if DOMAIN not in config: return True register_oauth2_implementations( hass, config[DOMAIN][CONF_CLIENT_ID], config[DOMAIN][CONF_CLIENT_SECRET] ) hass.async_create_task( ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "register_oauth2_implementations", "(", "hass", ",", "config", "[", "DOM...
[ 54, 0 ]
[ 67, 15 ]
python
en
['en', 'en', 'en']
True
async_migrate_entry
(hass: HomeAssistant, entry: ConfigEntry)
Handle migration of a previous version config entry.
Handle migration of a previous version config entry.
async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Handle migration of a previous version config entry.""" if entry.version == 1: # There is no usable data in version 1 anymore. # The integration switched to OAuth and because of this, uses # different uniq...
[ "async", "def", "async_migrate_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "if", "entry", ".", "version", "==", "1", ":", "# There is no usable data in version 1 anymore.", "# The integration switched to OAuth and...
[ 70, 0 ]
[ 86, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Toon from a config entry.
Set up Toon from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Toon from a config entry.""" implementation = await async_get_config_entry_implementation(hass, entry) session = OAuth2Session(hass, entry, implementation) coordinator = ToonDataUpdateCoordinator(hass, entry=entry, ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "implementation", "=", "await", "async_get_config_entry_implementation", "(", "hass", ",", "entry", ")", "session", "=", "OAuth2Sessio...
[ 89, 0 ]
[ 127, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload Toon config entry.
Unload Toon config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload Toon config entry.""" # Remove webhooks registration await hass.data[DOMAIN][entry.entry_id].unregister_webhook() # Unload entities for this entry/device. unload_ok = await hass.config_entries.async_unload_pla...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "# Remove webhooks registration", "await", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", ".", "u...
[ 130, 0 ]
[ 143, 20 ]
python
en
['nl', 'en', 'en']
True
async_request_config
( hass, name, callback=None, description=None, description_image=None, submit_caption=None, fields=None, link_name=None, link_url=None, entity_picture=None, )
Create a new request for configuration. Will return an ID to be used for sequent calls.
Create a new request for configuration.
def async_request_config( hass, name, callback=None, description=None, description_image=None, submit_caption=None, fields=None, link_name=None, link_url=None, entity_picture=None, ): """Create a new request for configuration. Will return an ID to be used for sequent cal...
[ "def", "async_request_config", "(", "hass", ",", "name", ",", "callback", "=", "None", ",", "description", "=", "None", ",", "description_image", "=", "None", ",", "submit_caption", "=", "None", ",", "fields", "=", "None", ",", "link_name", "=", "None", ",...
[ 45, 0 ]
[ 81, 21 ]
python
en
['en', 'en', 'en']
True
request_config
(hass, *args, **kwargs)
Create a new request for configuration. Will return an ID to be used for sequent calls.
Create a new request for configuration.
def request_config(hass, *args, **kwargs): """Create a new request for configuration. Will return an ID to be used for sequent calls. """ return run_callback_threadsafe( hass.loop, ft.partial(async_request_config, hass, *args, **kwargs) ).result()
[ "def", "request_config", "(", "hass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "run_callback_threadsafe", "(", "hass", ".", "loop", ",", "ft", ".", "partial", "(", "async_request_config", ",", "hass", ",", "*", "args", ",", "*", "...
[ 85, 0 ]
[ 92, 14 ]
python
en
['en', 'en', 'en']
True
async_notify_errors
(hass, request_id, error)
Add errors to a config request.
Add errors to a config request.
def async_notify_errors(hass, request_id, error): """Add errors to a config request.""" with suppress(KeyError): # If request_id does not exist hass.data[DATA_REQUESTS][request_id].async_notify_errors(request_id, error)
[ "def", "async_notify_errors", "(", "hass", ",", "request_id", ",", "error", ")", ":", "with", "suppress", "(", "KeyError", ")", ":", "# If request_id does not exist", "hass", ".", "data", "[", "DATA_REQUESTS", "]", "[", "request_id", "]", ".", "async_notify_erro...
[ 97, 0 ]
[ 100, 83 ]
python
en
['en', 'en', 'en']
True
notify_errors
(hass, request_id, error)
Add errors to a config request.
Add errors to a config request.
def notify_errors(hass, request_id, error): """Add errors to a config request.""" return run_callback_threadsafe( hass.loop, async_notify_errors, hass, request_id, error ).result()
[ "def", "notify_errors", "(", "hass", ",", "request_id", ",", "error", ")", ":", "return", "run_callback_threadsafe", "(", "hass", ".", "loop", ",", "async_notify_errors", ",", "hass", ",", "request_id", ",", "error", ")", ".", "result", "(", ")" ]
[ 104, 0 ]
[ 108, 14 ]
python
en
['en', 'en', 'en']
True
async_request_done
(hass, request_id)
Mark a configuration request as done.
Mark a configuration request as done.
def async_request_done(hass, request_id): """Mark a configuration request as done.""" with suppress(KeyError): # If request_id does not exist hass.data[DATA_REQUESTS].pop(request_id).async_request_done(request_id)
[ "def", "async_request_done", "(", "hass", ",", "request_id", ")", ":", "with", "suppress", "(", "KeyError", ")", ":", "# If request_id does not exist", "hass", ".", "data", "[", "DATA_REQUESTS", "]", ".", "pop", "(", "request_id", ")", ".", "async_request_done",...
[ 113, 0 ]
[ 116, 79 ]
python
en
['pt', 'en', 'en']
True
request_done
(hass, request_id)
Mark a configuration request as done.
Mark a configuration request as done.
def request_done(hass, request_id): """Mark a configuration request as done.""" return run_callback_threadsafe( hass.loop, async_request_done, hass, request_id ).result()
[ "def", "request_done", "(", "hass", ",", "request_id", ")", ":", "return", "run_callback_threadsafe", "(", "hass", ".", "loop", ",", "async_request_done", ",", "hass", ",", "request_id", ")", ".", "result", "(", ")" ]
[ 120, 0 ]
[ 124, 14 ]
python
en
['pt', 'en', 'en']
True
async_setup
(hass, config)
Set up the configurator component.
Set up the configurator component.
async def async_setup(hass, config): """Set up the configurator component.""" return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "return", "True" ]
[ 127, 0 ]
[ 129, 15 ]
python
en
['en', 'en', 'en']
True
Configurator.__init__
(self, hass)
Initialize the configurator.
Initialize the configurator.
def __init__(self, hass): """Initialize the configurator.""" self.hass = hass self._cur_id = 0 self._requests = {} hass.services.async_register( DOMAIN, SERVICE_CONFIGURE, self.async_handle_service_call )
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_cur_id", "=", "0", "self", ".", "_requests", "=", "{", "}", "hass", ".", "services", ".", "async_register", "(", "DOMAIN", ",", "SERVICE_CONFIGURE",...
[ 135, 4 ]
[ 142, 9 ]
python
en
['en', 'en', 'en']
True
Configurator.async_request_config
( self, name, callback, description, submit_caption, fields, entity_picture )
Set up a request for configuration.
Set up a request for configuration.
def async_request_config( self, name, callback, description, submit_caption, fields, entity_picture ): """Set up a request for configuration.""" entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, name, hass=self.hass) if fields is None: fields = [] request_i...
[ "def", "async_request_config", "(", "self", ",", "name", ",", "callback", ",", "description", ",", "submit_caption", ",", "fields", ",", "entity_picture", ")", ":", "entity_id", "=", "async_generate_entity_id", "(", "ENTITY_ID_FORMAT", ",", "name", ",", "hass", ...
[ 145, 4 ]
[ 178, 25 ]
python
en
['en', 'en', 'en']
True
Configurator.async_notify_errors
(self, request_id, error)
Update the state with errors.
Update the state with errors.
def async_notify_errors(self, request_id, error): """Update the state with errors.""" if not self._validate_request_id(request_id): return entity_id = self._requests[request_id][0] state = self.hass.states.get(entity_id) new_data = dict(state.attributes) ne...
[ "def", "async_notify_errors", "(", "self", ",", "request_id", ",", "error", ")", ":", "if", "not", "self", ".", "_validate_request_id", "(", "request_id", ")", ":", "return", "entity_id", "=", "self", ".", "_requests", "[", "request_id", "]", "[", "0", "]"...
[ 181, 4 ]
[ 193, 72 ]
python
en
['en', 'en', 'en']
True
Configurator.async_request_done
(self, request_id)
Remove the configuration request.
Remove the configuration request.
def async_request_done(self, request_id): """Remove the configuration request.""" if not self._validate_request_id(request_id): return entity_id = self._requests.pop(request_id)[0] # If we remove the state right away, it will not be included with # the result of the...
[ "def", "async_request_done", "(", "self", ",", "request_id", ")", ":", "if", "not", "self", ".", "_validate_request_id", "(", "request_id", ")", ":", "return", "entity_id", "=", "self", ".", "_requests", ".", "pop", "(", "request_id", ")", "[", "0", "]", ...
[ 196, 4 ]
[ 213, 76 ]
python
en
['en', 'it', 'en']
True
Configurator.async_handle_service_call
(self, call)
Handle a configure service call.
Handle a configure service call.
async def async_handle_service_call(self, call): """Handle a configure service call.""" request_id = call.data.get(ATTR_CONFIGURE_ID) if not self._validate_request_id(request_id): return # pylint: disable=unused-variable entity_id, fields, callback = self._requests[...
[ "async", "def", "async_handle_service_call", "(", "self", ",", "call", ")", ":", "request_id", "=", "call", ".", "data", ".", "get", "(", "ATTR_CONFIGURE_ID", ")", "if", "not", "self", ".", "_validate_request_id", "(", "request_id", ")", ":", "return", "# py...
[ 215, 4 ]
[ 227, 83 ]
python
en
['es', 'gl', 'en']
False
Configurator._generate_unique_id
(self)
Generate a unique configurator ID.
Generate a unique configurator ID.
def _generate_unique_id(self): """Generate a unique configurator ID.""" self._cur_id += 1 return f"{id(self)}-{self._cur_id}"
[ "def", "_generate_unique_id", "(", "self", ")", ":", "self", ".", "_cur_id", "+=", "1", "return", "f\"{id(self)}-{self._cur_id}\"" ]
[ 229, 4 ]
[ 232, 43 ]
python
it
['fr', 'it', 'it']
True
Configurator._validate_request_id
(self, request_id)
Validate that the request belongs to this instance.
Validate that the request belongs to this instance.
def _validate_request_id(self, request_id): """Validate that the request belongs to this instance.""" return request_id in self._requests
[ "def", "_validate_request_id", "(", "self", ",", "request_id", ")", ":", "return", "request_id", "in", "self", ".", "_requests" ]
[ 234, 4 ]
[ 236, 43 ]
python
en
['en', 'en', 'en']
True
cli
(ctx, feature_id)
Get cvterms associated with a feature Output: Feature cvterms
Get cvterms associated with a feature
def cli(ctx, feature_id): """Get cvterms associated with a feature Output: Feature cvterms """ return ctx.gi.feature.get_feature_cvterms(feature_id)
[ "def", "cli", "(", "ctx", ",", "feature_id", ")", ":", "return", "ctx", ".", "gi", ".", "feature", ".", "get_feature_cvterms", "(", "feature_id", ")" ]
[ 10, 0 ]
[ 17, 57 ]
python
en
['en', 'en', 'en']
True
mock_scan_fixture
()
Mock pyatv.scan.
Mock pyatv.scan.
def mock_scan_fixture(): """Mock pyatv.scan.""" with patch("homeassistant.components.apple_tv.config_flow.scan") as mock_scan: async def _scan(loop, timeout=5, identifier=None, protocol=None, hosts=None): if not mock_scan.hosts: mock_scan.hosts = hosts return moc...
[ "def", "mock_scan_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.apple_tv.config_flow.scan\"", ")", "as", "mock_scan", ":", "async", "def", "_scan", "(", "loop", ",", "timeout", "=", "5", ",", "identifier", "=", "None", ",", "protocol...
[ 12, 0 ]
[ 24, 23 ]
python
en
['lt', 'tr', 'en']
False
dmap_pin_fixture
()
Mock pyatv.scan.
Mock pyatv.scan.
def dmap_pin_fixture(): """Mock pyatv.scan.""" with patch("homeassistant.components.apple_tv.config_flow.randrange") as mock_pin: mock_pin.side_effect = lambda start, stop: 1111 yield mock_pin
[ "def", "dmap_pin_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.apple_tv.config_flow.randrange\"", ")", "as", "mock_pin", ":", "mock_pin", ".", "side_effect", "=", "lambda", "start", ",", "stop", ":", "1111", "yield", "mock_pin" ]
[ 28, 0 ]
[ 32, 22 ]
python
en
['lt', 'tr', 'en']
False
pairing
()
Mock pyatv.scan.
Mock pyatv.scan.
def pairing(): """Mock pyatv.scan.""" with patch("homeassistant.components.apple_tv.config_flow.pair") as mock_pair: async def _pair(config, protocol, loop, session=None, **kwargs): handler = MockPairingHandler( await create_session(session), config.get_service(protocol) ...
[ "def", "pairing", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.apple_tv.config_flow.pair\"", ")", "as", "mock_pair", ":", "async", "def", "_pair", "(", "config", ",", "protocol", ",", "loop", ",", "session", "=", "None", ",", "*", "*", "k...
[ 36, 0 ]
[ 49, 23 ]
python
en
['lt', 'tr', 'en']
False
pairing_mock
()
Mock pyatv.scan.
Mock pyatv.scan.
def pairing_mock(): """Mock pyatv.scan.""" with patch("homeassistant.components.apple_tv.config_flow.pair") as mock_pair: async def _pair(config, protocol, loop, session=None, **kwargs): return mock_pair async def _begin(): pass async def _close(): ...
[ "def", "pairing_mock", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.apple_tv.config_flow.pair\"", ")", "as", "mock_pair", ":", "async", "def", "_pair", "(", "config", ",", "protocol", ",", "loop", ",", "session", "=", "None", ",", "*", "*",...
[ 53, 0 ]
[ 70, 23 ]
python
en
['lt', 'tr', 'en']
False
full_device
(mock_scan, dmap_pin)
Mock pyatv.scan.
Mock pyatv.scan.
def full_device(mock_scan, dmap_pin): """Mock pyatv.scan.""" mock_scan.result.append( create_conf( "127.0.0.1", "MRP Device", conf.MrpService("mrpid", 5555), conf.DmapService("dmapid", None, port=6666), conf.AirPlayService("airplayid", port=777...
[ "def", "full_device", "(", "mock_scan", ",", "dmap_pin", ")", ":", "mock_scan", ".", "result", ".", "append", "(", "create_conf", "(", "\"127.0.0.1\"", ",", "\"MRP Device\"", ",", "conf", ".", "MrpService", "(", "\"mrpid\"", ",", "5555", ")", ",", "conf", ...
[ 74, 0 ]
[ 85, 19 ]
python
en
['lt', 'tr', 'en']
False
mrp_device
(mock_scan)
Mock pyatv.scan.
Mock pyatv.scan.
def mrp_device(mock_scan): """Mock pyatv.scan.""" mock_scan.result.append( create_conf("127.0.0.1", "MRP Device", conf.MrpService("mrpid", 5555)) ) yield mock_scan
[ "def", "mrp_device", "(", "mock_scan", ")", ":", "mock_scan", ".", "result", ".", "append", "(", "create_conf", "(", "\"127.0.0.1\"", ",", "\"MRP Device\"", ",", "conf", ".", "MrpService", "(", "\"mrpid\"", ",", "5555", ")", ")", ")", "yield", "mock_scan" ]
[ 89, 0 ]
[ 94, 19 ]
python
en
['lt', 'tr', 'en']
False
dmap_device
(mock_scan)
Mock pyatv.scan.
Mock pyatv.scan.
def dmap_device(mock_scan): """Mock pyatv.scan.""" mock_scan.result.append( create_conf( "127.0.0.1", "DMAP Device", conf.DmapService("dmapid", None, port=6666), ) ) yield mock_scan
[ "def", "dmap_device", "(", "mock_scan", ")", ":", "mock_scan", ".", "result", ".", "append", "(", "create_conf", "(", "\"127.0.0.1\"", ",", "\"DMAP Device\"", ",", "conf", ".", "DmapService", "(", "\"dmapid\"", ",", "None", ",", "port", "=", "6666", ")", "...
[ 98, 0 ]
[ 107, 19 ]
python
en
['lt', 'tr', 'en']
False
dmap_device_with_credentials
(mock_scan)
Mock pyatv.scan.
Mock pyatv.scan.
def dmap_device_with_credentials(mock_scan): """Mock pyatv.scan.""" mock_scan.result.append( create_conf( "127.0.0.1", "DMAP Device", conf.DmapService("dmapid", "dummy_creds", port=6666), ) ) yield mock_scan
[ "def", "dmap_device_with_credentials", "(", "mock_scan", ")", ":", "mock_scan", ".", "result", ".", "append", "(", "create_conf", "(", "\"127.0.0.1\"", ",", "\"DMAP Device\"", ",", "conf", ".", "DmapService", "(", "\"dmapid\"", ",", "\"dummy_creds\"", ",", "port",...
[ 111, 0 ]
[ 120, 19 ]
python
en
['lt', 'tr', 'en']
False
device_with_no_services
(mock_scan)
Mock pyatv.scan.
Mock pyatv.scan.
def device_with_no_services(mock_scan): """Mock pyatv.scan.""" mock_scan.result.append(create_conf("127.0.0.1", "Invalid Device")) yield mock_scan
[ "def", "device_with_no_services", "(", "mock_scan", ")", ":", "mock_scan", ".", "result", ".", "append", "(", "create_conf", "(", "\"127.0.0.1\"", ",", "\"Invalid Device\"", ")", ")", "yield", "mock_scan" ]
[ 124, 0 ]
[ 127, 19 ]
python
en
['lt', 'tr', 'en']
False
test_valid_device_config
(hass, monkeypatch)
Test valid device config.
Test valid device config.
async def test_valid_device_config(hass, monkeypatch): """Test valid device config.""" config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}} with patch( "homeassistant.components.spc.SpcWebGateway.async_load_parameters", return_value=mock_coro(True), ): ...
[ "async", "def", "test_valid_device_config", "(", "hass", ",", "monkeypatch", ")", ":", "config", "=", "{", "\"spc\"", ":", "{", "\"api_url\"", ":", "\"http://localhost/\"", ",", "\"ws_url\"", ":", "\"ws://localhost/\"", "}", "}", "with", "patch", "(", "\"homeass...
[ 10, 0 ]
[ 18, 71 ]
python
en
['nl', 'en', 'en']
True
test_invalid_device_config
(hass, monkeypatch)
Test valid device config.
Test valid device config.
async def test_invalid_device_config(hass, monkeypatch): """Test valid device config.""" config = {"spc": {"api_url": "http://localhost/"}} with patch( "homeassistant.components.spc.SpcWebGateway.async_load_parameters", return_value=mock_coro(True), ): assert await async_setup_c...
[ "async", "def", "test_invalid_device_config", "(", "hass", ",", "monkeypatch", ")", ":", "config", "=", "{", "\"spc\"", ":", "{", "\"api_url\"", ":", "\"http://localhost/\"", "}", "}", "with", "patch", "(", "\"homeassistant.components.spc.SpcWebGateway.async_load_parame...
[ 21, 0 ]
[ 29, 72 ]
python
en
['nl', 'en', 'en']
True
test_update_alarm_device
(hass)
Test that alarm panel state changes on incoming websocket data.
Test that alarm panel state changes on incoming websocket data.
async def test_update_alarm_device(hass): """Test that alarm panel state changes on incoming websocket data.""" import pyspcwebgw from pyspcwebgw.const import AreaMode config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}} area_mock = Mock( spec=pyspcwebgw.area.Are...
[ "async", "def", "test_update_alarm_device", "(", "hass", ")", ":", "import", "pyspcwebgw", "from", "pyspcwebgw", ".", "const", "import", "AreaMode", "config", "=", "{", "\"spc\"", ":", "{", "\"api_url\"", ":", "\"http://localhost/\"", ",", "\"ws_url\"", ":", "\"...
[ 32, 0 ]
[ 71, 72 ]
python
en
['en', 'en', 'en']
True
test_reference_data
()
Check that SeedSequence generates data the same as the C++ reference. https://gist.github.com/imneme/540829265469e673d045
Check that SeedSequence generates data the same as the C++ reference.
def test_reference_data(): """ Check that SeedSequence generates data the same as the C++ reference. https://gist.github.com/imneme/540829265469e673d045 """ inputs = [ [3735928559, 195939070, 229505742, 305419896], [3668361503, 4165561550, 1661411377, 3634257570], [164546577, 41...
[ "def", "test_reference_data", "(", ")", ":", "inputs", "=", "[", "[", "3735928559", ",", "195939070", ",", "229505742", ",", "305419896", "]", ",", "[", "3668361503", ",", "4165561550", ",", "1661411377", ",", "3634257570", "]", ",", "[", "164546577", ",",...
[ 6, 0 ]
[ 53, 47 ]
python
en
['en', 'en', 'en']
True
test_zero_padding
()
Ensure that the implicit zero-padding does not cause problems.
Ensure that the implicit zero-padding does not cause problems.
def test_zero_padding(): """ Ensure that the implicit zero-padding does not cause problems. """ # Ensure that large integers are inserted in little-endian fashion to avoid # trailing 0s. ss0 = SeedSequence(42) ss1 = SeedSequence(42 << 32) assert_array_compare( np.not_equal, s...
[ "def", "test_zero_padding", "(", ")", ":", "# Ensure that large integers are inserted in little-endian fashion to avoid", "# trailing 0s.", "ss0", "=", "SeedSequence", "(", "42", ")", "ss1", "=", "SeedSequence", "(", "42", "<<", "32", ")", "assert_array_compare", "(", "...
[ 56, 0 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
TestEnumClass.make_instance
(self, include_optional)
Test EnumClass include_option is a boolean, when False only required params are included, when True both required and optional params are included
Test EnumClass include_option is a boolean, when False only required params are included, when True both required and optional params are included
def make_instance(self, include_optional): """Test EnumClass include_option is a boolean, when False only required params are included, when True both required and optional params are included """ # model = petstore_api.models.enum_class.EnumClass() # noqa: E501 ...
[ "def", "make_instance", "(", "self", ",", "include_optional", ")", ":", "# model = petstore_api.models.enum_class.EnumClass() # noqa: E501", "if", "include_optional", ":", "return", "EnumClass", "(", ")", "else", ":", "return", "EnumClass", "(", ")" ]
[ 30, 4 ]
[ 41, 9 ]
python
en
['en', 'fy', 'ur']
False
TestEnumClass.testEnumClass
(self)
Test EnumClass
Test EnumClass
def testEnumClass(self): """Test EnumClass""" inst_req_only = self.make_instance(include_optional=False) inst_req_and_optional = self.make_instance(include_optional=True)
[ "def", "testEnumClass", "(", "self", ")", ":", "inst_req_only", "=", "self", ".", "make_instance", "(", "include_optional", "=", "False", ")", "inst_req_and_optional", "=", "self", ".", "make_instance", "(", "include_optional", "=", "True", ")" ]
[ 43, 4 ]
[ 46, 73 ]
python
en
['en', 'fy', 'ur']
False
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Sonarr from a config entry.
Set up Sonarr from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Sonarr from a config entry.""" if not entry.options: options = { CONF_UPCOMING_DAYS: entry.data.get( CONF_UPCOMING_DAYS, DEFAULT_UPCOMING_DAYS ), CONF_WANTED_MAX_IT...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "if", "not", "entry", ".", "options", ":", "options", "=", "{", "CONF_UPCOMING_DAYS", ":", "entry", ".", "data", ".", "get", ...
[ 35, 0 ]
[ 76, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unload_ok", "=", "await", "hass", ".", "config_entries", ".", "async_unload_platforms", "(", "entry", ",", "PLATFORMS", ")", "if...
[ 79, 0 ]
[ 86, 20 ]
python
en
['en', 'es', 'en']
True
_async_update_listener
(hass: HomeAssistant, entry: ConfigEntry)
Handle options update.
Handle options update.
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None: """Handle options update.""" await hass.config_entries.async_reload(entry.entry_id)
[ "async", "def", "_async_update_listener", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "None", ":", "await", "hass", ".", "config_entries", ".", "async_reload", "(", "entry", ".", "entry_id", ")" ]
[ 89, 0 ]
[ 91, 58 ]
python
en
['en', 'nl', 'en']
True
test_async_setup_entry
(hass)
Test a successful setup entry.
Test a successful setup entry.
async def test_async_setup_entry(hass): """Test a successful setup entry.""" await init_integration(hass) state = hass.states.get("sensor.home_pm2_5") assert state is not None assert state.state != STATE_UNAVAILABLE assert state.state == "4"
[ "async", "def", "test_async_setup_entry", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.home_pm2_5\"", ")", "assert", "state", "is", "not", "None", "assert", "state", "."...
[ 16, 0 ]
[ 23, 29 ]
python
en
['en', 'en', 'en']
True
test_config_not_ready
(hass)
Test for setup failure if connection to GIOS is missing.
Test for setup failure if connection to GIOS is missing.
async def test_config_not_ready(hass): """Test for setup failure if connection to GIOS is missing.""" entry = MockConfigEntry( domain=DOMAIN, title="Home", unique_id=123, data={"station_id": 123, "name": "Home"}, ) with patch( "homeassistant.components.gios.Gios....
[ "async", "def", "test_config_not_ready", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"Home\"", ",", "unique_id", "=", "123", ",", "data", "=", "{", "\"station_id\"", ":", "123", ",", "\"name\""...
[ 26, 0 ]
[ 41, 58 ]
python
en
['en', 'en', 'en']
True
test_unload_entry
(hass)
Test successful unload of entry.
Test successful unload of entry.
async def test_unload_entry(hass): """Test successful unload of entry.""" entry = await init_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async...
[ "async", "def", "test_unload_entry", "(", "hass", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ")", "==", "1", "assert", "entry", ".", ...
[ 44, 0 ]
[ 55, 36 ]
python
en
['en', 'en', 'en']
True
test_migrate_device_and_config_entry
(hass)
Test device_info identifiers and config entry migration.
Test device_info identifiers and config entry migration.
async def test_migrate_device_and_config_entry(hass): """Test device_info identifiers and config entry migration.""" config_entry = MockConfigEntry( domain=DOMAIN, title="Home", unique_id=123, data={ "station_id": 123, "name": "Home", }, ) ...
[ "async", "def", "test_migrate_device_and_config_entry", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "title", "=", "\"Home\"", ",", "unique_id", "=", "123", ",", "data", "=", "{", "\"station_id\"", ":", "123...
[ 58, 0 ]
[ 98, 58 ]
python
en
['en', 'en', 'en']
True
test_remove_air_quality_entities
(hass)
Test remove air_quality entities from registry.
Test remove air_quality entities from registry.
async def test_remove_air_quality_entities(hass): """Test remove air_quality entities from registry.""" registry = er.async_get(hass) registry.async_get_or_create( AIR_QUALITY_PLATFORM, DOMAIN, "123", suggested_object_id="home", disabled_by=None, ) await ini...
[ "async", "def", "test_remove_air_quality_entities", "(", "hass", ")", ":", "registry", "=", "er", ".", "async_get", "(", "hass", ")", "registry", ".", "async_get_or_create", "(", "AIR_QUALITY_PLATFORM", ",", "DOMAIN", ",", "\"123\"", ",", "suggested_object_id", "=...
[ 101, 0 ]
[ 116, 24 ]
python
en
['en', 'en', 'en']
True
reduce_score
(puzzles, moves, pushes, steps, box_on_goal)
Convert tuple into 1-dimension score.
Convert tuple into 1-dimension score.
def reduce_score(puzzles, moves, pushes, steps, box_on_goal): """Convert tuple into 1-dimension score.""" return 50000 * puzzles + 5000 * box_on_goal - 100 * pushes - steps
[ "def", "reduce_score", "(", "puzzles", ",", "moves", ",", "pushes", ",", "steps", ",", "box_on_goal", ")", ":", "return", "50000", "*", "puzzles", "+", "5000", "*", "box_on_goal", "-", "100", "*", "pushes", "-", "steps" ]
[ 16, 0 ]
[ 18, 70 ]
python
en
['en', 'it', 'en']
True
Game.info
(self)
Initial Static information about the game.
Initial Static information about the game.
def info(self): """Initial Static information about the game.""" return { "fps": GAME_SPEED, "timeout": self._timeout, "map": f"levels/{self.level}.xsb", }
[ "def", "info", "(", "self", ")", ":", "return", "{", "\"fps\"", ":", "GAME_SPEED", ",", "\"timeout\"", ":", "self", ".", "_timeout", ",", "\"map\"", ":", "f\"levels/{self.level}.xsb\"", ",", "}" ]
[ 45, 4 ]
[ 51, 9 ]
python
en
['en', 'en', 'en']
True
Game.papertrail
(self)
String containing all pressed keys by agent.
String containing all pressed keys by agent.
def papertrail(self): """String containing all pressed keys by agent.""" return self._papertrail
[ "def", "papertrail", "(", "self", ")", ":", "return", "self", ".", "_papertrail" ]
[ 54, 4 ]
[ 56, 31 ]
python
en
['en', 'en', 'en']
True
Game.running
(self)
Status on game.
Status on game.
def running(self): """Status on game.""" return self._running
[ "def", "running", "(", "self", ")", ":", "return", "self", ".", "_running" ]
[ 59, 4 ]
[ 61, 28 ]
python
en
['en', 'jv', 'en']
True
Game.score
(self)
Calculus of the current score.
Calculus of the current score.
def score(self): """Calculus of the current score.""" return self.puzzles, self._moves, self._pushes, self._total_steps + self._step, self.map.on_goal
[ "def", "score", "(", "self", ")", ":", "return", "self", ".", "puzzles", ",", "self", ".", "_moves", ",", "self", ".", "_pushes", ",", "self", ".", "_total_steps", "+", "self", ".", "_step", ",", "self", ".", "map", ".", "on_goal" ]
[ 64, 4 ]
[ 66, 104 ]
python
en
['en', 'en', 'en']
True
Game.stop
(self)
Stop the game.
Stop the game.
def stop(self): """Stop the game.""" if self._step: logger.info("GAME OVER at %s", self._step) self._running = False
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_step", ":", "logger", ".", "info", "(", "\"GAME OVER at %s\"", ",", "self", ".", "_step", ")", "self", ".", "_running", "=", "False" ]
[ 68, 4 ]
[ 72, 29 ]
python
en
['en', 'en', 'en']
True
Game.next_level
(self, level)
Update all state variables to a new level.
Update all state variables to a new level.
def next_level(self, level): """Update all state variables to a new level.""" self.puzzles += 1 self._total_steps += self._step self._step = 0 self._lastkeypress = "" self._papertrail += "," self.level = level try: self.map = Map(f"levels/{lev...
[ "def", "next_level", "(", "self", ",", "level", ")", ":", "self", ".", "puzzles", "+=", "1", "self", ".", "_total_steps", "+=", "self", ".", "_step", "self", ".", "_step", "=", "0", "self", ".", "_lastkeypress", "=", "\"\"", "self", ".", "_papertrail",...
[ 74, 4 ]
[ 88, 18 ]
python
en
['en', 'en', 'en']
True
Game.keypress
(self, key)
Update locally last key pressed.
Update locally last key pressed.
def keypress(self, key): """Update locally last key pressed.""" self._lastkeypress = key
[ "def", "keypress", "(", "self", ",", "key", ")", ":", "self", ".", "_lastkeypress", "=", "key" ]
[ 90, 4 ]
[ 92, 32 ]
python
en
['en', 'en', 'en']
True
Game.move
(self, cur, direction)
Move an entity in the game.
Move an entity in the game.
def move(self, cur, direction): """Move an entity in the game.""" assert direction in "wasd", f"Can't move in {direction} direction" cx, cy = cur ctile = self.map.get_tile(cur) npos = cur if direction == "w": npos = cx, cy - 1 if direction == "a": ...
[ "def", "move", "(", "self", ",", "cur", ",", "direction", ")", ":", "assert", "direction", "in", "\"wasd\"", ",", "f\"Can't move in {direction} direction\"", "cx", ",", "cy", "=", "cur", "ctile", "=", "self", ".", "map", ".", "get_tile", "(", "cur", ")", ...
[ 94, 4 ]
[ 131, 19 ]
python
en
['en', 'en', 'en']
True
Game.update_keeper
(self)
Update the location of the Keeper.
Update the location of the Keeper.
def update_keeper(self): """Update the location of the Keeper.""" if self._lastkeypress == "": return GameStatus.NO_OPERATION try: # Update position self.move(self.map.keeper, self._lastkeypress) self._papertrail += self._lastkeypress excep...
[ "def", "update_keeper", "(", "self", ")", ":", "if", "self", ".", "_lastkeypress", "==", "\"\"", ":", "return", "GameStatus", ".", "NO_OPERATION", "try", ":", "# Update position", "self", ".", "move", "(", "self", ".", "map", ".", "keeper", ",", "self", ...
[ 133, 4 ]
[ 153, 33 ]
python
en
['en', 'en', 'en']
True
Game.next_frame
(self)
Calculate next frame.
Calculate next frame.
async def next_frame(self): """Calculate next frame.""" await asyncio.sleep(1.0 / GAME_SPEED) if not self._running: logger.info("Waiting for player 1") return self._step += 1 if self._step >= self._timeout: self.stop() if self._step ...
[ "async", "def", "next_frame", "(", "self", ")", ":", "await", "asyncio", ".", "sleep", "(", "1.0", "/", "GAME_SPEED", ")", "if", "not", "self", ".", "_running", ":", "logger", ".", "info", "(", "\"Waiting for player 1\"", ")", "return", "self", ".", "_st...
[ 155, 4 ]
[ 181, 26 ]
python
en
['en', 'pt', 'en']
True
Game.state
(self)
Contains the state of the Game.
Contains the state of the Game.
def state(self): """Contains the state of the Game.""" # logger.debug(self._state) return json.dumps(self._state)
[ "def", "state", "(", "self", ")", ":", "# logger.debug(self._state)", "return", "json", ".", "dumps", "(", "self", ".", "_state", ")" ]
[ 184, 4 ]
[ 187, 38 ]
python
en
['en', 'en', 'en']
True
test_select_schedule_thermostats
(hass, config_entry, caplog, netatmo_auth)
Test service for selecting Netatmo schedule with thermostats.
Test service for selecting Netatmo schedule with thermostats.
async def test_select_schedule_thermostats(hass, config_entry, caplog, netatmo_auth): """Test service for selecting Netatmo schedule with thermostats.""" with selected_platforms(["climate", "select"]): await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done...
[ "async", "def", "test_select_schedule_thermostats", "(", "hass", ",", "config_entry", ",", "caplog", ",", "netatmo_auth", ")", ":", "with", "selected_platforms", "(", "[", "\"climate\"", ",", "\"select\"", "]", ")", ":", "await", "hass", ".", "config_entries", "...
[ 10, 0 ]
[ 65, 60 ]
python
en
['en', 'en', 'en']
True
GrubConfig.parse_content
(self, content)
Parse grub configuration file to create a dict with this structure:: { "configs": { name1: [val1, val2, ...] name2: [val], ... }, "title": [ {title: name1, kernel: [val],...
Parse grub configuration file to create a dict with this structure::
def parse_content(self, content): """ Parse grub configuration file to create a dict with this structure:: { "configs": { name1: [val1, val2, ...] name2: [val], ... }, "title": [ ...
[ "def", "parse_content", "(", "self", ",", "content", ")", ":", "def", "_skip_script", "(", "line", ")", ":", "# Skip the script in Grub2", "if", "line", ".", "startswith", "(", "'if'", ")", ":", "_skip_script", ".", "if_idx", "+=", "1", "elif", "line", "."...
[ 78, 4 ]
[ 169, 63 ]
python
en
['en', 'error', 'th']
False
GrubConfig.boot_entries
(self)
Get all boot entries in GRUB configuration. Returns: (list): A list of :class:`insights.parsers.grub_conf.BootEntry` objects for each boot entry in below format: - 'name': "Red Hat Enterprise Linux Server" - 'cmdline': "kernel /vm...
Get all boot entries in GRUB configuration.
def boot_entries(self): """ Get all boot entries in GRUB configuration. Returns: (list): A list of :class:`insights.parsers.grub_conf.BootEntry` objects for each boot entry in below format: - 'name': "Red Hat Enterprise Linux Server" ...
[ "def", "boot_entries", "(", "self", ")", ":", "return", "self", ".", "_boot_entries" ]
[ 178, 4 ]
[ 189, 33 ]
python
en
['en', 'error', 'th']
False
GrubConfig.is_kdump_iommu_enabled
(self)
Does any kernel have 'intel_iommu=on' set? Returns: (bool): ``True`` when 'intel_iommu=on' is set, otherwise returns ``False``
Does any kernel have 'intel_iommu=on' set?
def is_kdump_iommu_enabled(self): """ Does any kernel have 'intel_iommu=on' set? Returns: (bool): ``True`` when 'intel_iommu=on' is set, otherwise returns ``False`` """ return self._is_kdump_iommu_enabled_
[ "def", "is_kdump_iommu_enabled", "(", "self", ")", ":", "return", "self", ".", "_is_kdump_iommu_enabled_" ]
[ 192, 4 ]
[ 199, 44 ]
python
en
['en', 'error', 'th']
False
GrubConfig.kernel_initrds
(self)
Get the `kernel` and `initrd` files referenced in GRUB configuration files Returns: (dict): Returns a dict of the `kernel` and `initrd` files referenced in GRUB configuration files
Get the `kernel` and `initrd` files referenced in GRUB configuration files
def kernel_initrds(self): """ Get the `kernel` and `initrd` files referenced in GRUB configuration files Returns: (dict): Returns a dict of the `kernel` and `initrd` files referenced in GRUB configuration files """ return self._kernel_initrds
[ "def", "kernel_initrds", "(", "self", ")", ":", "return", "self", ".", "_kernel_initrds" ]
[ 202, 4 ]
[ 210, 35 ]
python
en
['en', 'error', 'th']
False
ChildCatAllOf.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", "}" ]
[ 64, 4 ]
[ 75, 9 ]
python
en
['en', 'error', 'th']
False
ChildCatAllOf.__init__
(self, *args, **kwargs)
ChildCatAllOf - a model defined in OpenAPI Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. ...
ChildCatAllOf - a model defined in OpenAPI
def __init__(self, *args, **kwargs): # noqa: E501 """ChildCatAllOf - a model defined in OpenAPI Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be rai...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ".", "pop", "(", "'_spec_property...
[ 98, 4 ]
[ 165, 46 ]
python
en
['en', 'en', 'en']
True
register
(linter: PyLinter)
Register the checker.
Register the checker.
def register(linter: PyLinter) -> None: """Register the checker.""" linter.register_checker(HassConstructorFormatChecker(linter))
[ "def", "register", "(", "linter", ":", "PyLinter", ")", "->", "None", ":", "linter", ".", "register_checker", "(", "HassConstructorFormatChecker", "(", "linter", ")", ")" ]
[ 49, 0 ]
[ 51, 65 ]
python
en
['en', 'no', 'en']
True
HassConstructorFormatChecker.visit_functiondef
(self, node: FunctionDef)
Called when a FunctionDef node is visited.
Called when a FunctionDef node is visited.
def visit_functiondef(self, node: FunctionDef) -> None: """Called when a FunctionDef node is visited.""" if not node.is_method() or node.name != "__init__": return # Check that all arguments are annotated. # The first argument is "self". args = node.args anno...
[ "def", "visit_functiondef", "(", "self", ",", "node", ":", "FunctionDef", ")", "->", "None", ":", "if", "not", "node", ".", "is_method", "(", ")", "or", "node", ".", "name", "!=", "\"__init__\"", ":", "return", "# Check that all arguments are annotated.", "# T...
[ 24, 4 ]
[ 46, 66 ]
python
en
['en', 'en', 'en']
True
test_minimum_fields
(hass, validate_config_entry, bypass_setup)
Test we get the form.
Test we get the form.
async def test_minimum_fields(hass, validate_config_entry, bypass_setup): """Test we get the form.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["errors"]...
[ "async", "def", "test_minimum_fields", "(", "hass", ",", "validate_config_entry", ",", "bypass_setup", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", ...
[ 21, 0 ]
[ 46, 5 ]
python
en
['en', 'en', 'en']
True
test_options
(hass, validate_config_entry, mock_update)
Test options flow.
Test options flow.
async def test_options(hass, validate_config_entry, mock_update): """Test options flow.""" entry = MockConfigEntry( domain=DOMAIN, data={ CONF_ORIGIN: "location1", CONF_DESTINATION: "location2", CONF_REGION: "US", }, ) entry.add_to_hass(hass) ...
[ "async", "def", "test_options", "(", "hass", ",", "validate_config_entry", ",", "mock_update", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_ORIGIN", ":", "\"location1\"", ",", "CONF_DESTINATION", ":", "\...
[ 49, 0 ]
[ 104, 5 ]
python
en
['en', 'fr', 'en']
True
test_import
(hass, validate_config_entry, mock_update)
Test import for config flow.
Test import for config flow.
async def test_import(hass, validate_config_entry, mock_update): """Test import for config flow.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={ CONF_ORIGIN: "location1", CONF_DESTINATION: "lo...
[ "async", "def", "test_import", "(", "hass", ",", "validate_config_entry", ",", "mock_update", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config...
[ 107, 0 ]
[ 144, 5 ]
python
da
['da', 'da', 'en']
True
_setup_dupe_import
(hass, mock_update)
Set up dupe import.
Set up dupe import.
async def _setup_dupe_import(hass, mock_update): """Set up dupe import.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={ CONF_ORIGIN: "location1", CONF_DESTINATION: "location2", CON...
[ "async", "def", "_setup_dupe_import", "(", "hass", ",", "mock_update", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE...
[ 147, 0 ]
[ 167, 38 ]
python
en
['en', 'da', 'en']
True
test_dupe_import
(hass, mock_update)
Test duplicate import.
Test duplicate import.
async def test_dupe_import(hass, mock_update): """Test duplicate import.""" await _setup_dupe_import(hass, mock_update) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={ CONF_ORIGIN: "location1", ...
[ "async", "def", "test_dupe_import", "(", "hass", ",", "mock_update", ")", ":", "await", "_setup_dupe_import", "(", "hass", ",", "mock_update", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "co...
[ 170, 0 ]
[ 192, 51 ]
python
fr
['fr', 'la', 'it']
False
test_dupe_import_false_check_different_options_value
(hass, mock_update)
Test false duplicate import check when options value differs.
Test false duplicate import check when options value differs.
async def test_dupe_import_false_check_different_options_value(hass, mock_update): """Test false duplicate import check when options value differs.""" await _setup_dupe_import(hass, mock_update) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SO...
[ "async", "def", "test_dupe_import_false_check_different_options_value", "(", "hass", ",", "mock_update", ")", ":", "await", "_setup_dupe_import", "(", "hass", ",", "mock_update", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_in...
[ 195, 0 ]
[ 216, 69 ]
python
en
['en', 'en', 'en']
True
test_dupe_import_false_check_default_option
(hass, mock_update)
Test false duplicate import check when option with a default is missing.
Test false duplicate import check when option with a default is missing.
async def test_dupe_import_false_check_default_option(hass, mock_update): """Test false duplicate import check when option with a default is missing.""" await _setup_dupe_import(hass, mock_update) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries....
[ "async", "def", "test_dupe_import_false_check_default_option", "(", "hass", ",", "mock_update", ")", ":", "await", "_setup_dupe_import", "(", "hass", ",", "mock_update", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 219, 0 ]
[ 239, 69 ]
python
en
['en', 'en', 'en']
True
test_dupe_import_false_check_no_default_option
(hass, mock_update)
Test false duplicate import check option when option with no default is miissing.
Test false duplicate import check option when option with no default is miissing.
async def test_dupe_import_false_check_no_default_option(hass, mock_update): """Test false duplicate import check option when option with no default is miissing.""" await _setup_dupe_import(hass, mock_update) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": con...
[ "async", "def", "test_dupe_import_false_check_no_default_option", "(", "hass", ",", "mock_update", ")", ":", "await", "_setup_dupe_import", "(", "hass", ",", "mock_update", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", ...
[ 242, 0 ]
[ 261, 69 ]
python
en
['en', 'en', 'en']
True
test_dupe
(hass, validate_config_entry, bypass_setup)
Test setting up the same entry data twice is OK.
Test setting up the same entry data twice is OK.
async def test_dupe(hass, validate_config_entry, bypass_setup): """Test setting up the same entry data twice is OK.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert...
[ "async", "def", "test_dupe", "(", "hass", ",", "validate_config_entry", ",", "bypass_setup", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_...
[ 264, 0 ]
[ 301, 70 ]
python
en
['en', 'en', 'en']
True
test_invalid_config_entry
(hass, invalidate_config_entry)
Test we get the form.
Test we get the form.
async def test_invalid_config_entry(hass, invalidate_config_entry): """Test we get the form.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["errors"] == {}...
[ "async", "def", "test_invalid_config_entry", "(", "hass", ",", "invalidate_config_entry", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries...
[ 304, 0 ]
[ 321, 58 ]
python
en
['en', 'en', 'en']
True