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
GeonetnzVolcanoSensor.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.""" if self._remove_signal_update: self._remove_signal_update()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_remove_signal_update", ":", "self", ".", "_remove_signal_update", "(", ")" ]
[ 85, 4 ]
[ 88, 40 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor._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", ")" ]
[ 91, 4 ]
[ 93, 49 ]
python
en
['en', 'sn', 'en']
True
GeonetnzVolcanoSensor.should_poll
(self)
No polling needed for GeoNet NZ Volcano feed location events.
No polling needed for GeoNet NZ Volcano feed location events.
def should_poll(self): """No polling needed for GeoNet NZ Volcano feed location events.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 96, 4 ]
[ 98, 20 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.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) last_update = self._feed_manager.last_update() last_update_successful = self...
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating %s\"", ",", "self", ".", "_external_id", ")", "feed_entry", "=", "self", ".", "_feed_manager", ".", "get_entry", "(", "self", ".", "_external_id", ")", "last_upd...
[ 100, 4 ]
[ 107, 83 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor._update_from_feed
(self, feed_entry, last_update, last_update_successful)
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, last_update, last_update_successful): """Update the internal state from the provided feed entry.""" self._title = feed_entry.title # Convert distance if not metric system. if self._unit_system == CONF_UNIT_SYSTEM_IMPERIAL: self._distanc...
[ "def", "_update_from_feed", "(", "self", ",", "feed_entry", ",", "last_update", ",", "last_update_successful", ")", ":", "self", ".", "_title", "=", "feed_entry", ".", "title", "# Convert distance if not metric system.", "if", "self", ".", "_unit_system", "==", "CON...
[ 109, 4 ]
[ 129, 9 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self._alert_level
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_alert_level" ]
[ 132, 4 ]
[ 134, 32 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.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.""" return DEFAULT_ICON
[ "def", "icon", "(", "self", ")", ":", "return", "DEFAULT_ICON" ]
[ 137, 4 ]
[ 139, 27 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str | None: """Return the name of the entity.""" return f"Volcano {self._title}"
[ "def", "name", "(", "self", ")", "->", "str", "|", "None", ":", "return", "f\"Volcano {self._title}\"" ]
[ 142, 4 ]
[ 144, 39 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.native_unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def native_unit_of_measurement(self): """Return the unit of measurement.""" return "alert level"
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "\"alert level\"" ]
[ 147, 4 ]
[ 149, 28 ]
python
en
['en', 'la', 'en']
True
GeonetnzVolcanoSensor.extra_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def extra_state_attributes(self): """Return the device state attributes.""" attributes = {} for key, value in ( (ATTR_EXTERNAL_ID, self._external_id), (ATTR_ATTRIBUTION, self._attribution), (ATTR_ACTIVITY, self._activity), (ATTR_HAZARDS, self._haza...
[ "def", "extra_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "for", "key", ",", "value", "in", "(", "(", "ATTR_EXTERNAL_ID", ",", "self", ".", "_external_id", ")", ",", "(", "ATTR_ATTRIBUTION", ",", "self", ".", "_attribution", ")",...
[ 152, 4 ]
[ 168, 25 ]
python
en
['en', 'en', 'en']
True
_deserialize
(data, klass)
Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. :return: object.
Deserializes dict, list, str into an object.
def _deserialize(data, klass): """Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. :return: object. """ if data is None: return None if klass in six.integer_types or klass in (float, str, bool): ...
[ "def", "_deserialize", "(", "data", ",", "klass", ")", ":", "if", "data", "is", "None", ":", "return", "None", "if", "klass", "in", "six", ".", "integer_types", "or", "klass", "in", "(", "float", ",", "str", ",", "bool", ")", ":", "return", "_deseria...
[ 7, 0 ]
[ 32, 45 ]
python
en
['en', 'en', 'en']
True
_deserialize_primitive
(data, klass)
Deserializes to primitive type. :param data: data to deserialize. :param klass: class literal. :return: int, long, float, str, bool. :rtype: int | long | float | str | bool
Deserializes to primitive type.
def _deserialize_primitive(data, klass): """Deserializes to primitive type. :param data: data to deserialize. :param klass: class literal. :return: int, long, float, str, bool. :rtype: int | long | float | str | bool """ try: value = klass(data) except UnicodeEncodeError: ...
[ "def", "_deserialize_primitive", "(", "data", ",", "klass", ")", ":", "try", ":", "value", "=", "klass", "(", "data", ")", "except", "UnicodeEncodeError", ":", "value", "=", "six", ".", "u", "(", "data", ")", "except", "TypeError", ":", "value", "=", "...
[ 35, 0 ]
[ 50, 16 ]
python
en
['en', 'en', 'en']
True
_deserialize_object
(value)
Return a original value. :return: object.
Return a original value.
def _deserialize_object(value): """Return a original value. :return: object. """ return value
[ "def", "_deserialize_object", "(", "value", ")", ":", "return", "value" ]
[ 53, 0 ]
[ 58, 16 ]
python
en
['en', 'pt', 'en']
True
deserialize_date
(string)
Deserializes string to date. :param string: str. :type string: str :return: date. :rtype: date
Deserializes string to date.
def deserialize_date(string): """Deserializes string to date. :param string: str. :type string: str :return: date. :rtype: date """ try: from dateutil.parser import parse return parse(string).date() except ImportError: return string
[ "def", "deserialize_date", "(", "string", ")", ":", "try", ":", "from", "dateutil", ".", "parser", "import", "parse", "return", "parse", "(", "string", ")", ".", "date", "(", ")", "except", "ImportError", ":", "return", "string" ]
[ 61, 0 ]
[ 73, 21 ]
python
en
['en', 'en', 'en']
True
deserialize_datetime
(string)
Deserializes string to datetime. The string should be in iso8601 datetime format. :param string: str. :type string: str :return: datetime. :rtype: datetime
Deserializes string to datetime.
def deserialize_datetime(string): """Deserializes string to datetime. The string should be in iso8601 datetime format. :param string: str. :type string: str :return: datetime. :rtype: datetime """ try: from dateutil.parser import parse return parse(string) except Im...
[ "def", "deserialize_datetime", "(", "string", ")", ":", "try", ":", "from", "dateutil", ".", "parser", "import", "parse", "return", "parse", "(", "string", ")", "except", "ImportError", ":", "return", "string" ]
[ 76, 0 ]
[ 90, 21 ]
python
en
['en', 'en', 'en']
True
deserialize_model
(data, klass)
Deserializes list or dict to model. :param data: dict, list. :type data: dict | list :param klass: class literal. :return: model object.
Deserializes list or dict to model.
def deserialize_model(data, klass): """Deserializes list or dict to model. :param data: dict, list. :type data: dict | list :param klass: class literal. :return: model object. """ instance = klass() if not instance.swagger_types: return data for attr, attr_type in six.iter...
[ "def", "deserialize_model", "(", "data", ",", "klass", ")", ":", "instance", "=", "klass", "(", ")", "if", "not", "instance", ".", "swagger_types", ":", "return", "data", "for", "attr", ",", "attr_type", "in", "six", ".", "iteritems", "(", "instance", "....
[ 93, 0 ]
[ 113, 19 ]
python
en
['en', 'en', 'en']
True
_deserialize_list
(data, boxed_type)
Deserializes a list and its elements. :param data: list to deserialize. :type data: list :param boxed_type: class literal. :return: deserialized list. :rtype: list
Deserializes a list and its elements.
def _deserialize_list(data, boxed_type): """Deserializes a list and its elements. :param data: list to deserialize. :type data: list :param boxed_type: class literal. :return: deserialized list. :rtype: list """ return [_deserialize(sub_data, boxed_type) for sub_data in dat...
[ "def", "_deserialize_list", "(", "data", ",", "boxed_type", ")", ":", "return", "[", "_deserialize", "(", "sub_data", ",", "boxed_type", ")", "for", "sub_data", "in", "data", "]" ]
[ 116, 0 ]
[ 127, 33 ]
python
en
['en', 'en', 'en']
True
_deserialize_dict
(data, boxed_type)
Deserializes a dict and its elements. :param data: dict to deserialize. :type data: dict :param boxed_type: class literal. :return: deserialized dict. :rtype: dict
Deserializes a dict and its elements.
def _deserialize_dict(data, boxed_type): """Deserializes a dict and its elements. :param data: dict to deserialize. :type data: dict :param boxed_type: class literal. :return: deserialized dict. :rtype: dict """ return {k: _deserialize(v, boxed_type) for k, v in six.iterite...
[ "def", "_deserialize_dict", "(", "data", ",", "boxed_type", ")", ":", "return", "{", "k", ":", "_deserialize", "(", "v", ",", "boxed_type", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "data", ")", "}" ]
[ 130, 0 ]
[ 141, 44 ]
python
en
['en', 'en', 'en']
True
test_successful_config_entry
(hass: HomeAssistant)
Test that SpeedTestDotNet is configured successfully.
Test that SpeedTestDotNet is configured successfully.
async def test_successful_config_entry(hass: HomeAssistant) -> None: """Test that SpeedTestDotNet is configured successfully.""" entry = MockConfigEntry( domain=DOMAIN, data={}, options={ CONF_SERVER_NAME: "Country1 - Sponsor1 - Server1", CONF_SERVER_ID: "1", ...
[ "async", "def", "test_successful_config_entry", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "}", ",", "options", "=", "{", "CONF_SERVER_NAME", ":", "\"Countr...
[ 19, 0 ]
[ 38, 64 ]
python
en
['en', 'de', 'en']
True
test_setup_failed
(hass: HomeAssistant, mock_api: MagicMock)
Test SpeedTestDotNet failed due to an error.
Test SpeedTestDotNet failed due to an error.
async def test_setup_failed(hass: HomeAssistant, mock_api: MagicMock) -> None: """Test SpeedTestDotNet failed due to an error.""" entry = MockConfigEntry( domain=DOMAIN, ) entry.add_to_hass(hass) mock_api.side_effect = speedtest.ConfigRetrievalError await hass.config_entries.async_setu...
[ "async", "def", "test_setup_failed", "(", "hass", ":", "HomeAssistant", ",", "mock_api", ":", "MagicMock", ")", "->", "None", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "mock...
[ 41, 0 ]
[ 51, 54 ]
python
en
['en', 'lb', 'en']
True
test_unload_entry
(hass: HomeAssistant)
Test removing SpeedTestDotNet.
Test removing SpeedTestDotNet.
async def test_unload_entry(hass: HomeAssistant) -> None: """Test removing SpeedTestDotNet.""" entry = MockConfigEntry( domain=DOMAIN, ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() assert await hass.config_entries...
[ "async", "def", "test_unload_entry", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "await", "hass", ".", "config_entries", ...
[ 54, 0 ]
[ 68, 34 ]
python
en
['en', 'ru-Latn', 'en']
True
test_server_not_found
(hass: HomeAssistant, mock_api: MagicMock)
Test configured server id is not found.
Test configured server id is not found.
async def test_server_not_found(hass: HomeAssistant, mock_api: MagicMock) -> None: """Test configured server id is not found.""" entry = MockConfigEntry( domain=DOMAIN, ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() ...
[ "async", "def", "test_server_not_found", "(", "hass", ":", "HomeAssistant", ",", "mock_api", ":", "MagicMock", ")", "->", "None", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "...
[ 71, 0 ]
[ 88, 43 ]
python
en
['en', 'en', 'en']
True
test_get_best_server_error
(hass: HomeAssistant, mock_api: MagicMock)
Test configured server id is not found.
Test configured server id is not found.
async def test_get_best_server_error(hass: HomeAssistant, mock_api: MagicMock) -> None: """Test configured server id is not found.""" entry = MockConfigEntry( domain=DOMAIN, ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done...
[ "async", "def", "test_get_best_server_error", "(", "hass", ":", "HomeAssistant", ",", "mock_api", ":", "MagicMock", ")", "->", "None", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", ")", "entry", ".", "add_to_hass", "(", "hass", ")"...
[ 91, 0 ]
[ 112, 43 ]
python
en
['en', 'en', 'en']
True
test_missing_client
(hass: HomeAssistant)
Validate that if client has not been setup, it fails immediately in setup.
Validate that if client has not been setup, it fails immediately in setup.
async def test_missing_client(hass: HomeAssistant): """Validate that if client has not been setup, it fails immediately in setup.""" try: config_entry = MockConfigEntry( data={ CONF_ENTRY_HOST: TEST_HOST, CONF_ENTRY_ID: TEST_ID, CONF_ENTRY_NAME...
[ "async", "def", "test_missing_client", "(", "hass", ":", "HomeAssistant", ")", ":", "try", ":", "config_entry", "=", "MockConfigEntry", "(", "data", "=", "{", "CONF_ENTRY_HOST", ":", "TEST_HOST", ",", "CONF_ENTRY_ID", ":", "TEST_ID", ",", "CONF_ENTRY_NAME", ":",...
[ 28, 0 ]
[ 43, 16 ]
python
en
['en', 'en', 'en']
True
test_initial_state
(hass: HomeAssistant)
Validate that entity and device states are updated on startup.
Validate that entity and device states are updated on startup.
async def test_initial_state(hass: HomeAssistant): """Validate that entity and device states are updated on startup.""" entity, device, _ = await _create_entries(hass) state = hass.states.get(entity.entity_id) # Basic state properties assert state.name == entity.unique_id assert state.state ==...
[ "async", "def", "test_initial_state", "(", "hass", ":", "HomeAssistant", ")", ":", "entity", ",", "device", ",", "_", "=", "await", "_create_entries", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "entity", ".", "entity_id", ")"...
[ 46, 0 ]
[ 68, 44 ]
python
en
['en', 'en', 'en']
True
test_initial_state_offline
(hass: HomeAssistant)
Validate that entity and device are restored from config is offline on startup.
Validate that entity and device are restored from config is offline on startup.
async def test_initial_state_offline(hass: HomeAssistant): """Validate that entity and device are restored from config is offline on startup.""" client = ClientMock() client.is_offline = True entity, device, _ = await _create_entries(hass, client) state = hass.states.get(entity.entity_id) asse...
[ "async", "def", "test_initial_state_offline", "(", "hass", ":", "HomeAssistant", ")", ":", "client", "=", "ClientMock", "(", ")", "client", ".", "is_offline", "=", "True", "entity", ",", "device", ",", "_", "=", "await", "_create_entries", "(", "hass", ",", ...
[ 71, 0 ]
[ 89, 44 ]
python
en
['en', 'en', 'en']
True
test_turn_on
(hass: HomeAssistant)
Test support of the light.turn_on service.
Test support of the light.turn_on service.
async def test_turn_on(hass: HomeAssistant): """Test support of the light.turn_on service.""" client = ClientMock() client.is_on = False client.brightness = 20 entity, _, _ = await _create_entries(hass, client) assert hass.states.get(entity.entity_id).state == "off" await hass.services.asy...
[ "async", "def", "test_turn_on", "(", "hass", ":", "HomeAssistant", ")", ":", "client", "=", "ClientMock", "(", ")", "client", ".", "is_on", "=", "False", "client", ".", "brightness", "=", "20", "entity", ",", "_", ",", "_", "=", "await", "_create_entries...
[ 92, 0 ]
[ 109, 47 ]
python
en
['en', 'en', 'en']
True
test_turn_on_with_brightness
(hass: HomeAssistant)
Test support of the light.turn_on service with a brightness parameter.
Test support of the light.turn_on service with a brightness parameter.
async def test_turn_on_with_brightness(hass: HomeAssistant): """Test support of the light.turn_on service with a brightness parameter.""" client = ClientMock() client.is_on = False client.brightness = 20 entity, _, _ = await _create_entries(hass, client) assert hass.states.get(entity.entity_id)...
[ "async", "def", "test_turn_on_with_brightness", "(", "hass", ":", "HomeAssistant", ")", ":", "client", "=", "ClientMock", "(", ")", "client", ".", "is_on", "=", "False", "client", ".", "brightness", "=", "20", "entity", ",", "_", ",", "_", "=", "await", ...
[ 112, 0 ]
[ 131, 48 ]
python
en
['en', 'en', 'en']
True
test_turn_off
(hass: HomeAssistant)
Test support of the light.turn_off service.
Test support of the light.turn_off service.
async def test_turn_off(hass: HomeAssistant): """Test support of the light.turn_off service.""" entity, _, _ = await _create_entries(hass) assert hass.states.get(entity.entity_id).state == "on" await hass.services.async_call( "light", "turn_off", service_data={"entity_id": entity.entity_id} ...
[ "async", "def", "test_turn_off", "(", "hass", ":", "HomeAssistant", ")", ":", "entity", ",", "_", ",", "_", "=", "await", "_create_entries", "(", "hass", ")", "assert", "hass", ".", "states", ".", "get", "(", "entity", ".", "entity_id", ")", ".", "stat...
[ 134, 0 ]
[ 148, 46 ]
python
en
['en', 'en', 'en']
True
test_update_name
(hass: HomeAssistant)
Validate device's name update behavior. Validate that if device name is changed from the Twinkly app, then the name of the entity is updated and it's also persisted, so it can be restored when starting HA while Twinkly is offline.
Validate device's name update behavior.
async def test_update_name(hass: HomeAssistant): """ Validate device's name update behavior. Validate that if device name is changed from the Twinkly app, then the name of the entity is updated and it's also persisted, so it can be restored when starting HA while Twinkly is offline. """ ent...
[ "async", "def", "test_update_name", "(", "hass", ":", "HomeAssistant", ")", ":", "entity", ",", "_", ",", "client", "=", "await", "_create_entries", "(", "hass", ")", "updated_config_entry", "=", "None", "async", "def", "on_update", "(", "ha", ",", "co", "...
[ 151, 0 ]
[ 179, 65 ]
python
en
['en', 'error', 'th']
False
test_unload
(hass: HomeAssistant)
Validate that entities can be unloaded from the UI.
Validate that entities can be unloaded from the UI.
async def test_unload(hass: HomeAssistant): """Validate that entities can be unloaded from the UI.""" _, _, client = await _create_entries(hass) entry_id = client.id assert await hass.config_entries.async_unload(entry_id)
[ "async", "def", "test_unload", "(", "hass", ":", "HomeAssistant", ")", ":", "_", ",", "_", ",", "client", "=", "await", "_create_entries", "(", "hass", ")", "entry_id", "=", "client", ".", "id", "assert", "await", "hass", ".", "config_entries", ".", "asy...
[ 182, 0 ]
[ 188, 59 ]
python
en
['en', 'en', 'en']
True
Filter.__init__
(self, source, require_matching_tags=True)
Creates a Filter :arg source: the source token stream :arg require_matching_tags: whether or not to require matching tags
Creates a Filter
def __init__(self, source, require_matching_tags=True): """Creates a Filter :arg source: the source token stream :arg require_matching_tags: whether or not to require matching tags """ super(Filter, self).__init__(source) self.require_matching_tags = require_matching_t...
[ "def", "__init__", "(", "self", ",", "source", ",", "require_matching_tags", "=", "True", ")", ":", "super", "(", "Filter", ",", "self", ")", ".", "__init__", "(", "source", ")", "self", ".", "require_matching_tags", "=", "require_matching_tags" ]
[ 17, 4 ]
[ 26, 58 ]
python
en
['en', 'gl', 'en']
True
pythonlib_dir
()
return path where libpython* is.
return path where libpython* is.
def pythonlib_dir(): """return path where libpython* is.""" if sys.platform == 'win32': return os.path.join(sys.prefix, "libs") else: return get_config_var('LIBDIR')
[ "def", "pythonlib_dir", "(", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "return", "os", ".", "path", ".", "join", "(", "sys", ".", "prefix", ",", "\"libs\"", ")", "else", ":", "return", "get_config_var", "(", "'LIBDIR'", ")" ]
[ 68, 0 ]
[ 73, 39 ]
python
en
['en', 'gd', 'en']
True
is_npy_no_signal
()
Return True if the NPY_NO_SIGNAL symbol must be defined in configuration header.
Return True if the NPY_NO_SIGNAL symbol must be defined in configuration header.
def is_npy_no_signal(): """Return True if the NPY_NO_SIGNAL symbol must be defined in configuration header.""" return sys.platform == 'win32'
[ "def", "is_npy_no_signal", "(", ")", ":", "return", "sys", ".", "platform", "==", "'win32'" ]
[ 75, 0 ]
[ 78, 34 ]
python
en
['en', 'en', 'en']
True
is_npy_no_smp
()
Return True if the NPY_NO_SMP symbol must be defined in public header (when SMP support cannot be reliably enabled).
Return True if the NPY_NO_SMP symbol must be defined in public header (when SMP support cannot be reliably enabled).
def is_npy_no_smp(): """Return True if the NPY_NO_SMP symbol must be defined in public header (when SMP support cannot be reliably enabled).""" # Perhaps a fancier check is in order here. # so that threads are only enabled if there # are actually multiple CPUS? -- but # threaded code can be n...
[ "def", "is_npy_no_smp", "(", ")", ":", "# Perhaps a fancier check is in order here.", "# so that threads are only enabled if there", "# are actually multiple CPUS? -- but", "# threaded code can be nice even on a single", "# CPU so that long-calculating code doesn't", "# block.", "return",...
[ 80, 0 ]
[ 89, 36 ]
python
en
['en', 'en', 'en']
True
visibility_define
(config)
Return the define value to use for NPY_VISIBILITY_HIDDEN (may be empty string).
Return the define value to use for NPY_VISIBILITY_HIDDEN (may be empty string).
def visibility_define(config): """Return the define value to use for NPY_VISIBILITY_HIDDEN (may be empty string).""" hide = '__attribute__((visibility("hidden")))' if config.check_gcc_function_attribute(hide, 'hideme'): return hide else: return ''
[ "def", "visibility_define", "(", "config", ")", ":", "hide", "=", "'__attribute__((visibility(\"hidden\")))'", "if", "config", ".", "check_gcc_function_attribute", "(", "hide", ",", "'hideme'", ")", ":", "return", "hide", "else", ":", "return", "''" ]
[ 383, 0 ]
[ 390, 17 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up an Avion switch.
Set up an Avion switch.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up an Avion switch.""" avion = importlib.import_module("avion") lights = [] if CONF_USERNAME in config and CONF_PASSWORD in config: devices = avion.get_devices(config[CONF_USERNAME], config[CONF_PASSWORD]) for d...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "avion", "=", "importlib", ".", "import_module", "(", "\"avion\"", ")", "lights", "=", "[", "]", "if", "CONF_USERNAME", "in", "config", ...
[ 41, 0 ]
[ 61, 24 ]
python
en
['en', 'lb', 'en']
True
AvionLight.__init__
(self, device)
Initialize the light.
Initialize the light.
def __init__(self, device): """Initialize the light.""" self._attr_name = device.name self._attr_unique_id = device.mac self._attr_brightness = 255 self._switch = device
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "_attr_name", "=", "device", ".", "name", "self", ".", "_attr_unique_id", "=", "device", ".", "mac", "self", ".", "_attr_brightness", "=", "255", "self", ".", "_switch", "=", "device" ...
[ 71, 4 ]
[ 76, 29 ]
python
en
['en', 'en', 'en']
True
AvionLight.set_state
(self, brightness)
Set the state of this lamp to the provided brightness.
Set the state of this lamp to the provided brightness.
def set_state(self, brightness): """Set the state of this lamp to the provided brightness.""" avion = importlib.import_module("avion") # Bluetooth LE is unreliable, and the connection may drop at any # time. Make an effort to re-establish the link. initial = time.monotonic() ...
[ "def", "set_state", "(", "self", ",", "brightness", ")", ":", "avion", "=", "importlib", ".", "import_module", "(", "\"avion\"", ")", "# Bluetooth LE is unreliable, and the connection may drop at any", "# time. Make an effort to re-establish the link.", "initial", "=", "time"...
[ 78, 4 ]
[ 93, 19 ]
python
en
['en', 'en', 'en']
True
AvionLight.turn_on
(self, **kwargs)
Turn the specified or all lights on.
Turn the specified or all lights on.
def turn_on(self, **kwargs): """Turn the specified or all lights on.""" brightness = kwargs.get(ATTR_BRIGHTNESS) if brightness is not None: self._attr_brightness = brightness self.set_state(self.brightness) self._attr_is_on = True
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ")", "if", "brightness", "is", "not", "None", ":", "self", ".", "_attr_brightness", "=", "brightness", "self", ".", "set_st...
[ 95, 4 ]
[ 103, 31 ]
python
en
['en', 'en', 'en']
True
AvionLight.turn_off
(self, **kwargs)
Turn the specified or all lights off.
Turn the specified or all lights off.
def turn_off(self, **kwargs): """Turn the specified or all lights off.""" self.set_state(0) self._attr_is_on = False
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "set_state", "(", "0", ")", "self", ".", "_attr_is_on", "=", "False" ]
[ 105, 4 ]
[ 108, 32 ]
python
en
['en', 'en', 'en']
True
NullableShape.additional_properties_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
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 additional_properties_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 """ lazy_import() return (bool, date, datetime, dict, float, int, list, str, none_type,)
[ "def", "additional_properties_type", "(", ")", ":", "lazy_import", "(", ")", "return", "(", "bool", ",", "date", ",", "datetime", ",", "dict", ",", "float", ",", "int", ",", "list", ",", "str", ",", "none_type", ",", ")" ]
[ 66, 4 ]
[ 72, 78 ]
python
en
['en', 'error', 'th']
False
NullableShape.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. """ lazy...
[ "def", "openapi_types", "(", ")", ":", "lazy_import", "(", ")", "return", "{", "'shape_type'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "'quadrilateral_type'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "'triangle_type'", ":", "(", "str", ",", ...
[ 77, 4 ]
[ 91, 9 ]
python
en
['en', 'error', 'th']
False
NullableShape.__init__
(self, shape_type, *args, **kwargs)
NullableShape - a model defined in OpenAPI Args: shape_type (str): 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 ...
NullableShape - a model defined in OpenAPI
def __init__(self, shape_type, *args, **kwargs): # noqa: E501 """NullableShape - a model defined in OpenAPI Args: shape_type (str): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked an...
[ "def", "__init__", "(", "self", ",", "shape_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ".", "pop", ...
[ 123, 4 ]
[ 216, 46 ]
python
en
['en', 'en', 'it']
True
mock_command
(self, cmd, params=None)
Mock the Mikrotik command method.
Mock the Mikrotik command method.
def mock_command(self, cmd, params=None): """Mock the Mikrotik command method.""" if cmd == mikrotik.const.MIKROTIK_SERVICES[mikrotik.const.IS_WIRELESS]: return True if cmd == mikrotik.const.MIKROTIK_SERVICES[mikrotik.const.DHCP]: return DHCP_DATA if cmd == mikrotik.const.MIKROTIK_SERVIC...
[ "def", "mock_command", "(", "self", ",", "cmd", ",", "params", "=", "None", ")", ":", "if", "cmd", "==", "mikrotik", ".", "const", ".", "MIKROTIK_SERVICES", "[", "mikrotik", ".", "const", ".", "IS_WIRELESS", "]", ":", "return", "True", "if", "cmd", "==...
[ 17, 0 ]
[ 25, 13 ]
python
en
['en', 'et', 'en']
True
test_platform_manually_configured
(hass)
Test that nothing happens when configuring mikrotik through device tracker platform.
Test that nothing happens when configuring mikrotik through device tracker platform.
async def test_platform_manually_configured(hass): """Test that nothing happens when configuring mikrotik through device tracker platform.""" assert ( await async_setup_component( hass, device_tracker.DOMAIN, {device_tracker.DOMAIN: {"platform": "mikrotik"}}, ...
[ "async", "def", "test_platform_manually_configured", "(", "hass", ")", ":", "assert", "(", "await", "async_setup_component", "(", "hass", ",", "device_tracker", ".", "DOMAIN", ",", "{", "device_tracker", ".", "DOMAIN", ":", "{", "\"platform\"", ":", "\"mikrotik\""...
[ 28, 0 ]
[ 38, 43 ]
python
en
['en', 'en', 'en']
True
test_device_trackers
(hass, legacy_patchable_time)
Test device_trackers created by mikrotik.
Test device_trackers created by mikrotik.
async def test_device_trackers(hass, legacy_patchable_time): """Test device_trackers created by mikrotik.""" # test devices are added from wireless list only hub = await setup_mikrotik_entry(hass) device_1 = hass.states.get("device_tracker.device_1") assert device_1 is not None assert device_1...
[ "async", "def", "test_device_trackers", "(", "hass", ",", "legacy_patchable_time", ")", ":", "# test devices are added from wireless list only", "hub", "=", "await", "setup_mikrotik_entry", "(", "hass", ")", "device_1", "=", "hass", ".", "states", ".", "get", "(", "...
[ 41, 0 ]
[ 93, 43 ]
python
en
['en', 'en', 'en']
True
test_restoring_devices
(hass)
Test restoring existing device_tracker entities if not detected on startup.
Test restoring existing device_tracker entities if not detected on startup.
async def test_restoring_devices(hass): """Test restoring existing device_tracker entities if not detected on startup.""" config_entry = MockConfigEntry( domain=mikrotik.DOMAIN, data=MOCK_DATA, options=MOCK_OPTIONS ) config_entry.add_to_hass(hass) registry = er.async_get(hass) registry....
[ "async", "def", "test_restoring_devices", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "mikrotik", ".", "DOMAIN", ",", "data", "=", "MOCK_DATA", ",", "options", "=", "MOCK_OPTIONS", ")", "config_entry", ".", "add_to_hass", ...
[ 96, 0 ]
[ 127, 39 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback )
Set up SimpliSafe freeze sensors based on a config entry.
Set up SimpliSafe freeze sensors based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Set up SimpliSafe freeze sensors based on a config entry.""" simplisafe = hass.data[DOMAIN][DATA_CLIENT][entry.entry_id] sensors = [] for system in simplisafe.systems.values()...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ")", "->", "None", ":", "simplisafe", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CLIE...
[ 13, 0 ]
[ 29, 31 ]
python
en
['en', 'da', 'en']
True
SimplisafeFreezeSensor.async_update_from_rest_api
(self)
Update the entity with the provided REST API data.
Update the entity with the provided REST API data.
def async_update_from_rest_api(self) -> None: """Update the entity with the provided REST API data.""" self._attr_native_value = self._sensor.temperature
[ "def", "async_update_from_rest_api", "(", "self", ")", "->", "None", ":", "self", ".", "_attr_native_value", "=", "self", ".", "_sensor", ".", "temperature" ]
[ 40, 4 ]
[ 42, 58 ]
python
en
['en', 'en', 'en']
True
fix_font
(source_filename)
Create a Windows-specific version of the font.
Create a Windows-specific version of the font.
def fix_font(source_filename): """Create a Windows-specific version of the font.""" assert source_filename.endswith(".otf") font = ttLib.TTFont(source_filename) name_table = font["name"] for record in name_table.names: if record.platformID == 1: # Mac assert record.platEncID ==...
[ "def", "fix_font", "(", "source_filename", ")", ":", "assert", "source_filename", ".", "endswith", "(", "\".otf\"", ")", "font", "=", "ttLib", ".", "TTFont", "(", "source_filename", ")", "name_table", "=", "font", "[", "\"name\"", "]", "for", "record", "in",...
[ 29, 0 ]
[ 77, 30 ]
python
en
['en', 'en', 'en']
True
main
(argv)
Fix all fonts provided in the command line.
Fix all fonts provided in the command line.
def main(argv): """Fix all fonts provided in the command line.""" for font_filename in argv[1:]: fix_font(font_filename)
[ "def", "main", "(", "argv", ")", ":", "for", "font_filename", "in", "argv", "[", "1", ":", "]", ":", "fix_font", "(", "font_filename", ")" ]
[ 80, 0 ]
[ 83, 31 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the configured Numato USB GPIO ADC sensor ports.
Set up the configured Numato USB GPIO ADC sensor ports.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the configured Numato USB GPIO ADC sensor ports.""" if discovery_info is None: return api = hass.data[DOMAIN][DATA_API] sensors = [] devices = hass.data[DOMAIN][CONF_DEVICES] for device in [d for d in devices...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "api", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_API", "]", "senso...
[ 23, 0 ]
[ 57, 31 ]
python
en
['en', 'sm', 'en']
True
NumatoGpioAdc.__init__
(self, name, device_id, port, src_range, dst_range, dst_unit, api)
Initialize the sensor.
Initialize the sensor.
def __init__(self, name, device_id, port, src_range, dst_range, dst_unit, api): """Initialize the sensor.""" self._name = name self._device_id = device_id self._port = port self._src_range = src_range self._dst_range = dst_range self._state = None self._un...
[ "def", "__init__", "(", "self", ",", "name", ",", "device_id", ",", "port", ",", "src_range", ",", "dst_range", ",", "dst_unit", ",", "api", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_device_id", "=", "device_id", "self", ".", "_port",...
[ 63, 4 ]
[ 72, 23 ]
python
en
['en', 'en', 'en']
True
NumatoGpioAdc.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 75, 4 ]
[ 77, 25 ]
python
en
['en', 'mi', 'en']
True
NumatoGpioAdc.native_value
(self)
Return the state of the sensor.
Return the state of the sensor.
def native_value(self): """Return the state of the sensor.""" return self._state
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 80, 4 ]
[ 82, 26 ]
python
en
['en', 'en', 'en']
True
NumatoGpioAdc.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" ]
[ 85, 4 ]
[ 87, 40 ]
python
en
['en', 'en', 'en']
True
NumatoGpioAdc.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.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 90, 4 ]
[ 92, 19 ]
python
en
['en', 'en', 'en']
True
NumatoGpioAdc.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" try: adc_val = self._api.read_adc_input(self._device_id, self._port) adc_val = self._clamp_to_source_range(adc_val) self._state = self._linear_scale_to_dest_range(adc_val) except NumatoGpioErro...
[ "def", "update", "(", "self", ")", ":", "try", ":", "adc_val", "=", "self", ".", "_api", ".", "read_adc_input", "(", "self", ".", "_device_id", ",", "self", ".", "_port", ")", "adc_val", "=", "self", ".", "_clamp_to_source_range", "(", "adc_val", ")", ...
[ 94, 4 ]
[ 107, 13 ]
python
en
['en', 'en', 'en']
True
StringEnumWithDefaultValue.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", "{", "'value'", ":", "(", "str", ",", ")", ",", "}" ]
[ 65, 4 ]
[ 76, 9 ]
python
en
['en', 'error', 'th']
False
StringEnumWithDefaultValue.__init__
(self, *args, **kwargs)
StringEnumWithDefaultValue - a model defined in OpenAPI Note that value can be passed either in args or in kwargs, but not in both. Args: args[0] (str): if omitted defaults to "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 Keyword Args: va...
StringEnumWithDefaultValue - a model defined in OpenAPI
def __init__(self, *args, **kwargs): """StringEnumWithDefaultValue - a model defined in OpenAPI Note that value can be passed either in args or in kwargs, but not in both. Args: args[0] (str): if omitted defaults to "placed", must be one of ["placed", "approved", "delivered", ] # ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'value'", "in", "kwargs", ":", "value", "=", "kwargs", ".", "pop", "(", "'value'", ")", "elif", "args", ":", "args", "=", "list", "(", "args", ")", "value...
[ 97, 4 ]
[ 178, 13 ]
python
en
['en', 'en', 'en']
True
async_citybikes_request
(hass, uri, schema)
Perform a request to CityBikes API endpoint, and parse the response.
Perform a request to CityBikes API endpoint, and parse the response.
async def async_citybikes_request(hass, uri, schema): """Perform a request to CityBikes API endpoint, and parse the response.""" try: session = async_get_clientsession(hass) with async_timeout.timeout(REQUEST_TIMEOUT): req = await session.get(DEFAULT_ENDPOINT.format(uri=uri)) ...
[ "async", "def", "async_citybikes_request", "(", "hass", ",", "uri", ",", "schema", ")", ":", "try", ":", "session", "=", "async_get_clientsession", "(", "hass", ")", "with", "async_timeout", ".", "timeout", "(", "REQUEST_TIMEOUT", ")", ":", "req", "=", "awai...
[ 132, 0 ]
[ 148, 31 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the CityBikes platform.
Set up the CityBikes platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the CityBikes platform.""" if PLATFORM not in hass.data: hass.data[PLATFORM] = {MONITORED_NETWORKS: {}} latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITU...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "PLATFORM", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "PLATFORM", "]", "=", "{", "MO...
[ 151, 0 ]
[ 197, 37 ]
python
en
['en', 'sr', 'en']
True
CityBikesNetworks.__init__
(self, hass)
Initialize the networks instance.
Initialize the networks instance.
def __init__(self, hass): """Initialize the networks instance.""" self.hass = hass self.networks = None self.networks_loading = asyncio.Condition()
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "networks", "=", "None", "self", ".", "networks_loading", "=", "asyncio", ".", "Condition", "(", ")" ]
[ 203, 4 ]
[ 207, 51 ]
python
en
['en', 'en', 'en']
True
CityBikesNetworks.get_closest_network_id
(self, latitude, longitude)
Return the id of the network closest to provided location.
Return the id of the network closest to provided location.
async def get_closest_network_id(self, latitude, longitude): """Return the id of the network closest to provided location.""" try: await self.networks_loading.acquire() if self.networks is None: networks = await async_citybikes_request( self.ha...
[ "async", "def", "get_closest_network_id", "(", "self", ",", "latitude", ",", "longitude", ")", ":", "try", ":", "await", "self", ".", "networks_loading", ".", "acquire", "(", ")", "if", "self", ".", "networks", "is", "None", ":", "networks", "=", "await", ...
[ 209, 4 ]
[ 234, 43 ]
python
en
['en', 'en', 'en']
True
CityBikesNetwork.__init__
(self, hass, network_id)
Initialize the network object.
Initialize the network object.
def __init__(self, hass, network_id): """Initialize the network object.""" self.hass = hass self.network_id = network_id self.stations = [] self.ready = asyncio.Event()
[ "def", "__init__", "(", "self", ",", "hass", ",", "network_id", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "network_id", "=", "network_id", "self", ".", "stations", "=", "[", "]", "self", ".", "ready", "=", "asyncio", ".", "Event", "(",...
[ 240, 4 ]
[ 245, 36 ]
python
en
['en', 'en', 'en']
True
CityBikesNetwork.async_refresh
(self, now=None)
Refresh the state of the network.
Refresh the state of the network.
async def async_refresh(self, now=None): """Refresh the state of the network.""" try: network = await async_citybikes_request( self.hass, STATIONS_URI.format(uid=self.network_id), STATIONS_RESPONSE_SCHEMA, ) self.station...
[ "async", "def", "async_refresh", "(", "self", ",", "now", "=", "None", ")", ":", "try", ":", "network", "=", "await", "async_citybikes_request", "(", "self", ".", "hass", ",", "STATIONS_URI", ".", "format", "(", "uid", "=", "self", ".", "network_id", ")"...
[ 247, 4 ]
[ 261, 47 ]
python
en
['en', 'en', 'en']
True
CityBikesStation.__init__
(self, network, station_id, entity_id)
Initialize the sensor.
Initialize the sensor.
def __init__(self, network, station_id, entity_id): """Initialize the sensor.""" self._network = network self._station_id = station_id self.entity_id = entity_id
[ "def", "__init__", "(", "self", ",", "network", ",", "station_id", ",", "entity_id", ")", ":", "self", ".", "_network", "=", "network", "self", ".", "_station_id", "=", "station_id", "self", ".", "entity_id", "=", "entity_id" ]
[ 270, 4 ]
[ 274, 34 ]
python
en
['en', 'en', 'en']
True
CityBikesStation.async_update
(self)
Update station state.
Update station state.
async def async_update(self): """Update station state.""" for station in self._network.stations: if station[ATTR_ID] == self._station_id: station_data = station break self._attr_name = station_data.get(ATTR_NAME) self._attr_native_value = stati...
[ "async", "def", "async_update", "(", "self", ")", ":", "for", "station", "in", "self", ".", "_network", ".", "stations", ":", "if", "station", "[", "ATTR_ID", "]", "==", "self", ".", "_station_id", ":", "station_data", "=", "station", "break", "self", "....
[ 276, 4 ]
[ 295, 9 ]
python
en
['en', 'en', 'en']
True
Marker.evaluate
(self, environment=None)
Evaluate a marker. Return the boolean from evaluating the given marker against the environment. environment is an optional argument to override all or part of the determined environment. The environment is determined from the current Python process.
Evaluate a marker.
def evaluate(self, environment=None): # type: (Optional[Dict[str, str]]) -> bool """Evaluate a marker. Return the boolean from evaluating the given marker against the environment. environment is an optional argument to override all or part of the determined environment. ...
[ "def", "evaluate", "(", "self", ",", "environment", "=", "None", ")", ":", "# type: (Optional[Dict[str, str]]) -> bool", "current_environment", "=", "default_environment", "(", ")", "if", "environment", "is", "not", "None", ":", "current_environment", ".", "update", ...
[ 313, 4 ]
[ 327, 68 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Insteon covers from a config entry.
Set up the Insteon covers from a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Insteon covers from a config entry.""" @callback def async_add_insteon_cover_entities(discovery_info=None): """Add the Insteon entities for the platform.""" async_add_insteon_entities( hass, COVER...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "@", "callback", "def", "async_add_insteon_cover_entities", "(", "discovery_info", "=", "None", ")", ":", "\"\"\"Add the Insteon entities for the platform.\"\"\"", ...
[ 21, 0 ]
[ 33, 38 ]
python
en
['en', 'en', 'en']
True
InsteonCoverEntity.current_cover_position
(self)
Return the current cover position.
Return the current cover position.
def current_cover_position(self): """Return the current cover position.""" if self._insteon_device_group.value is not None: pos = self._insteon_device_group.value else: pos = 0 return int(math.ceil(pos * 100 / 255))
[ "def", "current_cover_position", "(", "self", ")", ":", "if", "self", ".", "_insteon_device_group", ".", "value", "is", "not", "None", ":", "pos", "=", "self", ".", "_insteon_device_group", ".", "value", "else", ":", "pos", "=", "0", "return", "int", "(", ...
[ 40, 4 ]
[ 46, 46 ]
python
en
['en', 'en', 'en']
True
InsteonCoverEntity.supported_features
(self)
Return the supported features for this entity.
Return the supported features for this entity.
def supported_features(self): """Return the supported features for this entity.""" return SUPPORTED_FEATURES
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORTED_FEATURES" ]
[ 49, 4 ]
[ 51, 33 ]
python
en
['en', 'en', 'en']
True
InsteonCoverEntity.is_closed
(self)
Return the boolean response if the node is on.
Return the boolean response if the node is on.
def is_closed(self): """Return the boolean response if the node is on.""" return bool(self.current_cover_position)
[ "def", "is_closed", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "current_cover_position", ")" ]
[ 54, 4 ]
[ 56, 48 ]
python
en
['en', 'en', 'en']
True
InsteonCoverEntity.async_open_cover
(self, **kwargs)
Open cover.
Open cover.
async def async_open_cover(self, **kwargs): """Open cover.""" await self._insteon_device.async_open()
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_insteon_device", ".", "async_open", "(", ")" ]
[ 58, 4 ]
[ 60, 47 ]
python
en
['es', 'en', 'en']
False
InsteonCoverEntity.async_close_cover
(self, **kwargs)
Close cover.
Close cover.
async def async_close_cover(self, **kwargs): """Close cover.""" await self._insteon_device.async_close()
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_insteon_device", ".", "async_close", "(", ")" ]
[ 62, 4 ]
[ 64, 48 ]
python
en
['en', 'la', 'en']
False
InsteonCoverEntity.async_set_cover_position
(self, **kwargs)
Set the cover position.
Set the cover position.
async def async_set_cover_position(self, **kwargs): """Set the cover position.""" position = int(kwargs[ATTR_POSITION] * 255 / 100) if position == 0: await self._insteon_device.async_close() else: await self._insteon_device.async_open( open_level=p...
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "position", "=", "int", "(", "kwargs", "[", "ATTR_POSITION", "]", "*", "255", "/", "100", ")", "if", "position", "==", "0", ":", "await", "self", ".", "_insteon...
[ 66, 4 ]
[ 74, 13 ]
python
en
['en', 'en', 'en']
True
fake_zones
()
Fixture for fake zones. Returns: list: List of fake zones
Fixture for fake zones.
def fake_zones(): """Fixture for fake zones. Returns: list: List of fake zones """ return [ {"name": "front", "number": 1}, {"name": "back", "number": 2}, {"name": "inside", "number": 3}, ]
[ "def", "fake_zones", "(", ")", ":", "return", "[", "{", "\"name\"", ":", "\"front\"", ",", "\"number\"", ":", "1", "}", ",", "{", "\"name\"", ":", "\"back\"", ",", "\"number\"", ":", "2", "}", ",", "{", "\"name\"", ":", "\"inside\"", ",", "\"number\"",...
[ 16, 0 ]
[ 26, 5 ]
python
en
['en', 'en', 'en']
True
client
(fake_zones)
Fixture for client. Args: fake_zones (list): Fixture of fake zones Yields: MagicMock: Client Mock
Fixture for client.
def client(fake_zones): """Fixture for client. Args: fake_zones (list): Fixture of fake zones Yields: MagicMock: Client Mock """ with mock.patch.object(nx584_client, "Client") as _mock_client: client = nx584_client.Client.return_value client.list_zones.return_value ...
[ "def", "client", "(", "fake_zones", ")", ":", "with", "mock", ".", "patch", ".", "object", "(", "nx584_client", ",", "\"Client\"", ")", "as", "_mock_client", ":", "client", "=", "nx584_client", ".", "Client", ".", "return_value", "client", ".", "list_zones",...
[ 30, 0 ]
[ 44, 26 ]
python
en
['en', 'fr', 'en']
True
test_nx584_sensor_setup_defaults
(mock_nx, mock_watcher, hass, fake_zones)
Test the setup with no configuration.
Test the setup with no configuration.
def test_nx584_sensor_setup_defaults(mock_nx, mock_watcher, hass, fake_zones): """Test the setup with no configuration.""" add_entities = mock.MagicMock() config = { "host": nx584.DEFAULT_HOST, "port": nx584.DEFAULT_PORT, "exclude_zones": [], "zone_types": {}, } asser...
[ "def", "test_nx584_sensor_setup_defaults", "(", "mock_nx", ",", "mock_watcher", ",", "hass", ",", "fake_zones", ")", ":", "add_entities", "=", "mock", ".", "MagicMock", "(", ")", "config", "=", "{", "\"host\"", ":", "nx584", ".", "DEFAULT_HOST", ",", "\"port\"...
[ 50, 0 ]
[ 63, 78 ]
python
en
['en', 'en', 'en']
True
test_nx584_sensor_setup_full_config
(mock_nx, mock_watcher, hass, fake_zones)
Test the setup with full configuration.
Test the setup with full configuration.
def test_nx584_sensor_setup_full_config(mock_nx, mock_watcher, hass, fake_zones): """Test the setup with full configuration.""" config = { "host": "foo", "port": 123, "exclude_zones": [2], "zone_types": {3: "motion"}, } add_entities = mock.MagicMock() assert nx584.set...
[ "def", "test_nx584_sensor_setup_full_config", "(", "mock_nx", ",", "mock_watcher", ",", "hass", ",", "fake_zones", ")", ":", "config", "=", "{", "\"host\"", ":", "\"foo\"", ",", "\"port\"", ":", "123", ",", "\"exclude_zones\"", ":", "[", "2", "]", ",", "\"zo...
[ 69, 0 ]
[ 88, 30 ]
python
en
['en', 'en', 'en']
True
_test_assert_graceful_fail
(hass, config)
Test the failing.
Test the failing.
async def _test_assert_graceful_fail(hass, config): """Test the failing.""" assert not await async_setup_component(hass, "nx584", config)
[ "async", "def", "_test_assert_graceful_fail", "(", "hass", ",", "config", ")", ":", "assert", "not", "await", "async_setup_component", "(", "hass", ",", "\"nx584\"", ",", "config", ")" ]
[ 91, 0 ]
[ 93, 65 ]
python
en
['en', 'sm', 'en']
True
test_nx584_sensor_setup_bad_config
(hass, config)
Test the setup with bad configuration.
Test the setup with bad configuration.
async def test_nx584_sensor_setup_bad_config(hass, config): """Test the setup with bad configuration.""" await _test_assert_graceful_fail(hass, config)
[ "async", "def", "test_nx584_sensor_setup_bad_config", "(", "hass", ",", "config", ")", ":", "await", "_test_assert_graceful_fail", "(", "hass", ",", "config", ")" ]
[ 106, 0 ]
[ 108, 50 ]
python
en
['en', 'en', 'en']
True
test_nx584_sensor_setup_with_exceptions
(hass, exception_type)
Test the setup handles exceptions.
Test the setup handles exceptions.
async def test_nx584_sensor_setup_with_exceptions(hass, exception_type): """Test the setup handles exceptions.""" nx584_client.Client.return_value.list_zones.side_effect = exception_type await _test_assert_graceful_fail(hass, {})
[ "async", "def", "test_nx584_sensor_setup_with_exceptions", "(", "hass", ",", "exception_type", ")", ":", "nx584_client", ".", "Client", ".", "return_value", ".", "list_zones", ".", "side_effect", "=", "exception_type", "await", "_test_assert_graceful_fail", "(", "hass",...
[ 119, 0 ]
[ 122, 46 ]
python
en
['en', 'en', 'en']
True
test_nx584_sensor_setup_version_too_old
(hass)
Test if version is too old.
Test if version is too old.
async def test_nx584_sensor_setup_version_too_old(hass): """Test if version is too old.""" nx584_client.Client.return_value.get_version.return_value = "1.0" await _test_assert_graceful_fail(hass, {})
[ "async", "def", "test_nx584_sensor_setup_version_too_old", "(", "hass", ")", ":", "nx584_client", ".", "Client", ".", "return_value", ".", "get_version", ".", "return_value", "=", "\"1.0\"", "await", "_test_assert_graceful_fail", "(", "hass", ",", "{", "}", ")" ]
[ 126, 0 ]
[ 129, 46 ]
python
en
['en', 'en', 'en']
True
test_nx584_sensor_setup_no_zones
(hass)
Test the setup with no zones.
Test the setup with no zones.
def test_nx584_sensor_setup_no_zones(hass): """Test the setup with no zones.""" nx584_client.Client.return_value.list_zones.return_value = [] add_entities = mock.MagicMock() assert nx584.setup_platform(hass, {}, add_entities) assert not add_entities.called
[ "def", "test_nx584_sensor_setup_no_zones", "(", "hass", ")", ":", "nx584_client", ".", "Client", ".", "return_value", ".", "list_zones", ".", "return_value", "=", "[", "]", "add_entities", "=", "mock", ".", "MagicMock", "(", ")", "assert", "nx584", ".", "setup...
[ 133, 0 ]
[ 138, 34 ]
python
en
['en', 'en', 'en']
True
test_nx584_zone_sensor_normal
()
Test for the NX584 zone sensor.
Test for the NX584 zone sensor.
def test_nx584_zone_sensor_normal(): """Test for the NX584 zone sensor.""" zone = {"number": 1, "name": "foo", "state": True} sensor = nx584.NX584ZoneSensor(zone, "motion") assert sensor.name == "foo" assert not sensor.should_poll assert sensor.is_on assert sensor.extra_state_attributes["zon...
[ "def", "test_nx584_zone_sensor_normal", "(", ")", ":", "zone", "=", "{", "\"number\"", ":", "1", ",", "\"name\"", ":", "\"foo\"", ",", "\"state\"", ":", "True", "}", "sensor", "=", "nx584", ".", "NX584ZoneSensor", "(", "zone", ",", "\"motion\"", ")", "asse...
[ 141, 0 ]
[ 151, 27 ]
python
en
['en', 'en', 'en']
True
test_nx584_watcher_process_zone_event
(mock_update)
Test the processing of zone events.
Test the processing of zone events.
def test_nx584_watcher_process_zone_event(mock_update): """Test the processing of zone events.""" zone1 = {"number": 1, "name": "foo", "state": True} zone2 = {"number": 2, "name": "bar", "state": True} zones = { 1: nx584.NX584ZoneSensor(zone1, "motion"), 2: nx584.NX584ZoneSensor(zone2, "...
[ "def", "test_nx584_watcher_process_zone_event", "(", "mock_update", ")", ":", "zone1", "=", "{", "\"number\"", ":", "1", ",", "\"name\"", ":", "\"foo\"", ",", "\"state\"", ":", "True", "}", "zone2", "=", "{", "\"number\"", ":", "2", ",", "\"name\"", ":", "...
[ 155, 0 ]
[ 166, 38 ]
python
en
['en', 'en', 'en']
True
test_nx584_watcher_process_zone_event_missing_zone
(mock_update)
Test the processing of zone events with missing zones.
Test the processing of zone events with missing zones.
def test_nx584_watcher_process_zone_event_missing_zone(mock_update): """Test the processing of zone events with missing zones.""" watcher = nx584.NX584Watcher(None, {}) watcher._process_zone_event({"zone": 1, "zone_state": False}) assert not mock_update.called
[ "def", "test_nx584_watcher_process_zone_event_missing_zone", "(", "mock_update", ")", ":", "watcher", "=", "nx584", ".", "NX584Watcher", "(", "None", ",", "{", "}", ")", "watcher", ".", "_process_zone_event", "(", "{", "\"zone\"", ":", "1", ",", "\"zone_state\"", ...
[ 170, 0 ]
[ 174, 33 ]
python
en
['en', 'en', 'en']
True
test_nx584_watcher_run_with_zone_events
()
Test the zone events.
Test the zone events.
def test_nx584_watcher_run_with_zone_events(): """Test the zone events.""" empty_me = [1, 2] def fake_get_events(): """Return nothing twice, then some events.""" if empty_me: empty_me.pop() else: return fake_events client = mock.MagicMock() fake_even...
[ "def", "test_nx584_watcher_run_with_zone_events", "(", ")", ":", "empty_me", "=", "[", "1", ",", "2", "]", "def", "fake_get_events", "(", ")", ":", "\"\"\"Return nothing twice, then some events.\"\"\"", "if", "empty_me", ":", "empty_me", ".", "pop", "(", ")", "els...
[ 177, 0 ]
[ 206, 44 ]
python
en
['en', 'en', 'en']
True
test_nx584_watcher_run_retries_failures
(mock_sleep)
Test the retries with failures.
Test the retries with failures.
def test_nx584_watcher_run_retries_failures(mock_sleep): """Test the retries with failures.""" empty_me = [1, 2] def fake_run(): """Fake runner.""" if empty_me: empty_me.pop() raise requests.exceptions.ConnectionError() raise StopMe() watcher = nx584.NX5...
[ "def", "test_nx584_watcher_run_retries_failures", "(", "mock_sleep", ")", ":", "empty_me", "=", "[", "1", ",", "2", "]", "def", "fake_run", "(", ")", ":", "\"\"\"Fake runner.\"\"\"", "if", "empty_me", ":", "empty_me", ".", "pop", "(", ")", "raise", "requests",...
[ 210, 0 ]
[ 227, 63 ]
python
en
['en', 'en', 'en']
True
init
(empty=False)
Initialize the platform with entities.
Initialize the platform with entities.
def init(empty=False): """Initialize the platform with entities.""" global ENTITIES ENTITIES = ( {} if empty else { device_class: MockSensor( name=f"{device_class} sensor", unique_id=f"unique_{device_class}", device_class=d...
[ "def", "init", "(", "empty", "=", "False", ")", ":", "global", "ENTITIES", "ENTITIES", "=", "(", "{", "}", "if", "empty", "else", "{", "device_class", ":", "MockSensor", "(", "name", "=", "f\"{device_class} sensor\"", ",", "unique_id", "=", "f\"unique_{devic...
[ 49, 0 ]
[ 65, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, config, async_add_entities_callback, discovery_info=None )
Return mock entities.
Return mock entities.
async def async_setup_platform( hass, config, async_add_entities_callback, discovery_info=None ): """Return mock entities.""" async_add_entities_callback(list(ENTITIES.values()))
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities_callback", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities_callback", "(", "list", "(", "ENTITIES", ".", "values", "(", ")", ")", ")" ]
[ 68, 0 ]
[ 72, 56 ]
python
af
['nl', 'af', 'en']
False
MockSensor.device_class
(self)
Return the class of this sensor.
Return the class of this sensor.
def device_class(self): """Return the class of this sensor.""" return self._handle("device_class")
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"device_class\"", ")" ]
[ 79, 4 ]
[ 81, 43 ]
python
en
['en', 'en', 'en']
True
MockSensor.last_reset
(self)
Return the last_reset of this sensor.
Return the last_reset of this sensor.
def last_reset(self): """Return the last_reset of this sensor.""" return self._handle("last_reset")
[ "def", "last_reset", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"last_reset\"", ")" ]
[ 84, 4 ]
[ 86, 41 ]
python
en
['en', 'id', 'en']
True
MockSensor.native_unit_of_measurement
(self)
Return the native unit_of_measurement of this sensor.
Return the native unit_of_measurement of this sensor.
def native_unit_of_measurement(self): """Return the native unit_of_measurement of this sensor.""" return self._handle("native_unit_of_measurement")
[ "def", "native_unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"native_unit_of_measurement\"", ")" ]
[ 89, 4 ]
[ 91, 57 ]
python
en
['en', 'id', 'en']
True
MockSensor.native_value
(self)
Return the native value of this sensor.
Return the native value of this sensor.
def native_value(self): """Return the native value of this sensor.""" return self._handle("native_value")
[ "def", "native_value", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"native_value\"", ")" ]
[ 94, 4 ]
[ 96, 43 ]
python
en
['en', 'en', 'en']
True
MockSensor.state_class
(self)
Return the state class of this sensor.
Return the state class of this sensor.
def state_class(self): """Return the state class of this sensor.""" return self._handle("state_class")
[ "def", "state_class", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"state_class\"", ")" ]
[ 99, 4 ]
[ 101, 42 ]
python
en
['en', 'en', 'en']
True
_battery_convert
(value)
Battery is given as a value between 0 and 9.
Battery is given as a value between 0 and 9.
def _battery_convert(value): """Battery is given as a value between 0 and 9.""" if value is None: return None return (value + 1) * 10
[ "def", "_battery_convert", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "return", "(", "value", "+", "1", ")", "*", "10" ]
[ 54, 0 ]
[ 58, 27 ]
python
en
['en', 'en', 'en']
True
_rssi_convert
(value)
Rssi is given as dBm value.
Rssi is given as dBm value.
def _rssi_convert(value): """Rssi is given as dBm value.""" if value is None: return None return f"{value*8-120}"
[ "def", "_rssi_convert", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "return", "f\"{value*8-120}\"" ]
[ 61, 0 ]
[ 65, 27 ]
python
en
['en', 'en', 'en']
True