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
is_speaking
()
Determine if Text to Speech is occurring Returns: bool: True while still speaking
Determine if Text to Speech is occurring
def is_speaking(): """Determine if Text to Speech is occurring Returns: bool: True while still speaking """ return check_for_signal("isSpeaking", -1, CONFIG)
[ "def", "is_speaking", "(", ")", ":", "return", "check_for_signal", "(", "\"isSpeaking\"", ",", "-", "1", ",", "CONFIG", ")" ]
[ 30, 0 ]
[ 36, 53 ]
python
en
['en', 'en', 'en']
True
wait_while_speaking
()
Pause as long as Text to Speech is still happening Pause while Text to Speech is still happening. This always pauses briefly to ensure that any preceeding request to speak has time to begin.
Pause as long as Text to Speech is still happening
def wait_while_speaking(): """Pause as long as Text to Speech is still happening Pause while Text to Speech is still happening. This always pauses briefly to ensure that any preceeding request to speak has time to begin. """ # TODO: Better method using messages or signals here DM time.slee...
[ "def", "wait_while_speaking", "(", ")", ":", "# TODO: Better method using messages or signals here DM", "time", ".", "sleep", "(", "0.3", ")", "# Wait briefly in for any queued speech to begin", "while", "is_speaking", "(", ")", ":", "time", ".", "sleep", "(", "0.1", ")...
[ 39, 0 ]
[ 49, 23 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Social Blade sensor.
Set up the Social Blade sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Social Blade sensor.""" social_blade = SocialBladeSensor(config[CHANNEL_ID], config[CONF_NAME]) social_blade.update() if social_blade.valid_channel_id is False: return add_entities([social_blade])
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "social_blade", "=", "SocialBladeSensor", "(", "config", "[", "CHANNEL_ID", "]", ",", "config", "[", "CONF_NAME", "]", ")", "social_blade", ...
[ 33, 0 ]
[ 41, 32 ]
python
en
['en', 'pt', 'en']
True
SocialBladeSensor.__init__
(self, case, name)
Initialize the Social Blade sensor.
Initialize the Social Blade sensor.
def __init__(self, case, name): """Initialize the Social Blade sensor.""" self._state = None self.channel_id = case self._attributes = None self.valid_channel_id = None self._name = name
[ "def", "__init__", "(", "self", ",", "case", ",", "name", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "channel_id", "=", "case", "self", ".", "_attributes", "=", "None", "self", ".", "valid_channel_id", "=", "None", "self", ".", "_name",...
[ 47, 4 ]
[ 53, 25 ]
python
en
['en', 'pt', 'en']
True
SocialBladeSensor.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 56, 4 ]
[ 58, 25 ]
python
en
['en', 'ig', 'en']
True
SocialBladeSensor.state
(self)
Return the state.
Return the state.
def state(self): """Return the state.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 61, 4 ]
[ 63, 26 ]
python
en
['en', 'en', 'en']
True
SocialBladeSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" if self._attributes: return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_attributes", ":", "return", "self", ".", "_attributes" ]
[ 66, 4 ]
[ 69, 35 ]
python
en
['en', 'en', 'en']
True
SocialBladeSensor.update
(self)
Get the latest data from Social Blade.
Get the latest data from Social Blade.
def update(self): """Get the latest data from Social Blade.""" try: data = socialbladeclient.get_data(self.channel_id) self._attributes = {TOTAL_VIEWS: data[TOTAL_VIEWS]} self._state = data[SUBSCRIBERS] self.valid_channel_id = True except (ValueE...
[ "def", "update", "(", "self", ")", ":", "try", ":", "data", "=", "socialbladeclient", ".", "get_data", "(", "self", ".", "channel_id", ")", "self", ".", "_attributes", "=", "{", "TOTAL_VIEWS", ":", "data", "[", "TOTAL_VIEWS", "]", "}", "self", ".", "_s...
[ 72, 4 ]
[ 84, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up the GeoNet NZ Volcano Feed platform.
Set up the GeoNet NZ Volcano Feed platform.
async def async_setup_entry(hass, entry, async_add_entities): """Set up the GeoNet NZ Volcano Feed platform.""" manager = hass.data[DOMAIN][FEED][entry.entry_id] @callback def async_add_sensor(feed_manager, external_id, unit_system): """Add sensor entity from feed.""" new_entity = Geone...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "manager", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "FEED", "]", "[", "entry", ".", "entry_id", "]", "@", "callback", "def", "async_add_sensor", ...
[ 33, 0 ]
[ 52, 38 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.__init__
(self, config_entry_id, feed_manager, external_id, unit_system)
Initialize entity with data from feed entry.
Initialize entity with data from feed entry.
def __init__(self, config_entry_id, feed_manager, external_id, unit_system): """Initialize entity with data from feed entry.""" self._config_entry_id = config_entry_id self._feed_manager = feed_manager self._external_id = external_id self._unit_system = unit_system self._...
[ "def", "__init__", "(", "self", ",", "config_entry_id", ",", "feed_manager", ",", "external_id", ",", "unit_system", ")", ":", "self", ".", "_config_entry_id", "=", "config_entry_id", "self", ".", "_feed_manager", "=", "feed_manager", "self", ".", "_external_id", ...
[ 58, 4 ]
[ 74, 41 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self._remove_signal_update = async_dispatcher_connect( self.hass, f"geonetnz_volcano_update_{self._external_id}", self._update_callback, )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_remove_signal_update", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "f\"geonetnz_volcano_update_{self._external_id}\"", ",", "self", ".", "_update_callback", ",", ")" ]
[ 76, 4 ]
[ 82, 9 ]
python
en
['en', 'en', 'en']
True
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", "(", ")" ]
[ 84, 4 ]
[ 87, 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", ")" ]
[ 90, 4 ]
[ 92, 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" ]
[ 95, 4 ]
[ 97, 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...
[ 99, 4 ]
[ 106, 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...
[ 108, 4 ]
[ 128, 9 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._alert_level
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_alert_level" ]
[ 131, 4 ]
[ 133, 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" ]
[ 136, 4 ]
[ 138, 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) -> Optional[str]: """Return the name of the entity.""" return f"Volcano {self._title}"
[ "def", "name", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "f\"Volcano {self._title}\"" ]
[ 141, 4 ]
[ 143, 39 ]
python
en
['en', 'en', 'en']
True
GeonetnzVolcanoSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return "alert level"
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "\"alert level\"" ]
[ 146, 4 ]
[ 148, 28 ]
python
en
['en', 'la', 'en']
True
GeonetnzVolcanoSensor.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" attributes = {} for key, value in ( (ATTR_EXTERNAL_ID, self._external_id), (ATTR_ATTRIBUTION, self._attribution), (ATTR_ACTIVITY, self._activity), (ATTR_HAZARDS, self._haz...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "for", "key", ",", "value", "in", "(", "(", "ATTR_EXTERNAL_ID", ",", "self", ".", "_external_id", ")", ",", "(", "ATTR_ATTRIBUTION", ",", "self", ".", "_attribution", ")"...
[ 151, 4 ]
[ 167, 25 ]
python
en
['en', 'en', 'en']
True
run_sensor_test
( hass: HomeAssistant, vera_component_factory: ComponentFactory, category: int, class_property: str, assert_states: Tuple[Tuple[Any, Any]], assert_unit_of_measurement: str = None, setup_callback: Callable[[pv.VeraController], None] = None, )
Test generic sensor.
Test generic sensor.
async def run_sensor_test( hass: HomeAssistant, vera_component_factory: ComponentFactory, category: int, class_property: str, assert_states: Tuple[Tuple[Any, Any]], assert_unit_of_measurement: str = None, setup_callback: Callable[[pv.VeraController], None] = None, ) -> None: """Test gene...
[ "async", "def", "run_sensor_test", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ",", "category", ":", "int", ",", "class_property", ":", "str", ",", "assert_states", ":", "Tuple", "[", "Tuple", "[", "Any", ",", "An...
[ 13, 0 ]
[ 48, 13 ]
python
en
['nl', 'id', 'en']
False
test_temperature_sensor_f
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_temperature_sensor_f( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" def setup_callback(controller: pv.VeraController) -> None: controller.temperature_units = "F" await run_sensor_test( hass=hass, vera_component_fact...
[ "async", "def", "test_temperature_sensor_f", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "def", "setup_callback", "(", "controller", ":", "pv", ".", "VeraController", ")", "->", "None", ":", ...
[ 51, 0 ]
[ 66, 5 ]
python
en
['en', 'en', 'en']
False
test_temperature_sensor_c
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_temperature_sensor_c( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" await run_sensor_test( hass=hass, vera_component_factory=vera_component_factory, category=pv.CATEGORY_TEMPERATURE_SENSOR, class_property="tempera...
[ "async", "def", "test_temperature_sensor_c", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "await", "run_sensor_test", "(", "hass", "=", "hass", ",", "vera_component_factory", "=", "vera_component_fa...
[ 69, 0 ]
[ 79, 5 ]
python
en
['en', 'en', 'en']
False
test_light_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_light_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" await run_sensor_test( hass=hass, vera_component_factory=vera_component_factory, category=pv.CATEGORY_LIGHT_SENSOR, class_property="light", asser...
[ "async", "def", "test_light_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "await", "run_sensor_test", "(", "hass", "=", "hass", ",", "vera_component_factory", "=", "vera_component_factory", ...
[ 82, 0 ]
[ 93, 5 ]
python
en
['en', 'en', 'en']
False
test_uv_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_uv_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" await run_sensor_test( hass=hass, vera_component_factory=vera_component_factory, category=pv.CATEGORY_UV_SENSOR, class_property="light", assert_stat...
[ "async", "def", "test_uv_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "await", "run_sensor_test", "(", "hass", "=", "hass", ",", "vera_component_factory", "=", "vera_component_factory", "...
[ 96, 0 ]
[ 107, 5 ]
python
en
['en', 'en', 'en']
False
test_humidity_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_humidity_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" await run_sensor_test( hass=hass, vera_component_factory=vera_component_factory, category=pv.CATEGORY_HUMIDITY_SENSOR, class_property="humidity", ...
[ "async", "def", "test_humidity_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "await", "run_sensor_test", "(", "hass", "=", "hass", ",", "vera_component_factory", "=", "vera_component_factory...
[ 110, 0 ]
[ 121, 5 ]
python
en
['en', 'en', 'en']
False
test_power_meter_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_power_meter_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" await run_sensor_test( hass=hass, vera_component_factory=vera_component_factory, category=pv.CATEGORY_POWER_METER, class_property="power", ...
[ "async", "def", "test_power_meter_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "await", "run_sensor_test", "(", "hass", "=", "hass", ",", "vera_component_factory", "=", "vera_component_fact...
[ 124, 0 ]
[ 135, 5 ]
python
en
['en', 'en', 'en']
False
test_trippable_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_trippable_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" def setup_callback(controller: pv.VeraController) -> None: controller.get_devices()[0].is_trippable = True await run_sensor_test( hass=hass, vera_compo...
[ "async", "def", "test_trippable_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "def", "setup_callback", "(", "controller", ":", "pv", ".", "VeraController", ")", "->", "None", ":", "con...
[ 138, 0 ]
[ 153, 5 ]
python
en
['en', 'en', 'en']
False
test_unknown_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_unknown_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" def setup_callback(controller: pv.VeraController) -> None: controller.get_devices()[0].is_trippable = False await run_sensor_test( hass=hass, vera_compon...
[ "async", "def", "test_unknown_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "def", "setup_callback", "(", "controller", ":", "pv", ".", "VeraController", ")", "->", "None", ":", "contr...
[ 156, 0 ]
[ 171, 5 ]
python
en
['en', 'en', 'en']
False
test_scene_controller_sensor
( hass: HomeAssistant, vera_component_factory: ComponentFactory )
Test function.
Test function.
async def test_scene_controller_sensor( hass: HomeAssistant, vera_component_factory: ComponentFactory ) -> None: """Test function.""" vera_device = MagicMock(spec=pv.VeraSensor) # type: pv.VeraSensor vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id vera_device.name =...
[ "async", "def", "test_scene_controller_sensor", "(", "hass", ":", "HomeAssistant", ",", "vera_component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "vera_device", "=", "MagicMock", "(", "spec", "=", "pv", ".", "VeraSensor", ")", "# type: pv.VeraSensor...
[ 174, 0 ]
[ 196, 52 ]
python
en
['en', 'en', 'en']
False
find_code_in_transformers
(object_name)
Find and return the code source code of `object_name`.
Find and return the code source code of `object_name`.
def find_code_in_transformers(object_name): """ Find and return the code source code of `object_name`.""" parts = object_name.split(".") i = 0 # First let's find the module where our object lives. module = parts[i] while i < len(parts) and not os.path.isfile(os.path.join(TRANSFORMERS_PATH, f"{m...
[ "def", "find_code_in_transformers", "(", "object_name", ")", ":", "parts", "=", "object_name", ".", "split", "(", "\".\"", ")", "i", "=", "0", "# First let's find the module where our object lives.", "module", "=", "parts", "[", "i", "]", "while", "i", "<", "len...
[ 34, 0 ]
[ 76, 30 ]
python
en
['en', 'en', 'en']
True
blackify
(code)
Applies the black part of our `make style` command to `code`.
Applies the black part of our `make style` command to `code`.
def blackify(code): """ Applies the black part of our `make style` command to `code`. """ has_indent = len(get_indent(code)) > 0 if has_indent: code = f"class Bla:\n{code}" result = black.format_str(code, mode=black.FileMode([black.TargetVersion.PY35], line_length=119)) return result...
[ "def", "blackify", "(", "code", ")", ":", "has_indent", "=", "len", "(", "get_indent", "(", "code", ")", ")", ">", "0", "if", "has_indent", ":", "code", "=", "f\"class Bla:\\n{code}\"", "result", "=", "black", ".", "format_str", "(", "code", ",", "mode",...
[ 93, 0 ]
[ 101, 66 ]
python
en
['en', 'error', 'th']
False
is_copy_consistent
(filename, overwrite=False)
Check if the code commented as a copy in `filename` matches the original. Return the differences or overwrites the content depending on `overwrite`.
Check if the code commented as a copy in `filename` matches the original.
def is_copy_consistent(filename, overwrite=False): """ Check if the code commented as a copy in `filename` matches the original. Return the differences or overwrites the content depending on `overwrite`. """ with open(filename, "r", encoding="utf-8", newline="\n") as f: lines = f.readlines(...
[ "def", "is_copy_consistent", "(", "filename", ",", "overwrite", "=", "False", ")", ":", "with", "open", "(", "filename", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ",", "newline", "=", "\"\\n\"", ")", "as", "f", ":", "lines", "=", "f", ".", "read...
[ 104, 0 ]
[ 175, 16 ]
python
en
['en', 'error', 'th']
False
get_model_list
()
Extracts the model list from the README.
Extracts the model list from the README.
def get_model_list(): """ Extracts the model list from the README. """ # If the introduction or the conclusion of the list change, the prompts may need to be updated. _start_prompt = "🤗 Transformers currently provides the following architectures" _end_prompt = "1. Want to contribute a new model?" w...
[ "def", "get_model_list", "(", ")", ":", "# If the introduction or the conclusion of the list change, the prompts may need to be updated.", "_start_prompt", "=", "\"🤗 Transformers currently provides the following architectures\"", "_end_prompt", "=", "\"1. Want to contribute a new model?\"", ...
[ 194, 0 ]
[ 222, 26 ]
python
en
['en', 'en', 'en']
True
split_long_line_with_indent
(line, max_per_line, indent)
Split the `line` so that it doesn't go over `max_per_line` and adds `indent` to new lines.
Split the `line` so that it doesn't go over `max_per_line` and adds `indent` to new lines.
def split_long_line_with_indent(line, max_per_line, indent): """ Split the `line` so that it doesn't go over `max_per_line` and adds `indent` to new lines. """ words = line.split(" ") lines = [] current_line = words[0] for word in words[1:]: if len(f"{current_line} {word}") > max_per_line: ...
[ "def", "split_long_line_with_indent", "(", "line", ",", "max_per_line", ",", "indent", ")", ":", "words", "=", "line", ".", "split", "(", "\" \"", ")", "lines", "=", "[", "]", "current_line", "=", "words", "[", "0", "]", "for", "word", "in", "words", "...
[ 225, 0 ]
[ 237, 27 ]
python
en
['en', 'en', 'en']
True
convert_to_rst
(model_list, max_per_line=None)
Convert `model_list` to rst format.
Convert `model_list` to rst format.
def convert_to_rst(model_list, max_per_line=None): """ Convert `model_list` to rst format. """ # Convert **[description](link)** to `description <link>`__ def _rep_link(match): title, link = match.groups() # Keep hard links for the models not released yet if "master" in link or not l...
[ "def", "convert_to_rst", "(", "model_list", ",", "max_per_line", "=", "None", ")", ":", "# Convert **[description](link)** to `description <link>`__", "def", "_rep_link", "(", "match", ")", ":", "title", ",", "link", "=", "match", ".", "groups", "(", ")", "# Keep ...
[ 240, 0 ]
[ 270, 28 ]
python
en
['en', 'en', 'en']
True
_find_text_in_file
(filename, start_prompt, end_prompt)
Find the text in `filename` between a line beginning with `start_prompt` and before `end_prompt`, removing empty lines.
Find the text in `filename` between a line beginning with `start_prompt` and before `end_prompt`, removing empty lines.
def _find_text_in_file(filename, start_prompt, end_prompt): """ Find the text in `filename` between a line beginning with `start_prompt` and before `end_prompt`, removing empty lines. """ with open(filename, "r", encoding="utf-8", newline="\n") as f: lines = f.readlines() # Find the star...
[ "def", "_find_text_in_file", "(", "filename", ",", "start_prompt", ",", "end_prompt", ")", ":", "with", "open", "(", "filename", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ",", "newline", "=", "\"\\n\"", ")", "as", "f", ":", "lines", "=", "f", ".",...
[ 273, 0 ]
[ 296, 79 ]
python
en
['en', 'error', 'th']
False
check_model_list_copy
(overwrite=False, max_per_line=119)
Check the model lists in the README and index.rst are consistent and maybe `overwrite`.
Check the model lists in the README and index.rst are consistent and maybe `overwrite`.
def check_model_list_copy(overwrite=False, max_per_line=119): """ Check the model lists in the README and index.rst are consistent and maybe `overwrite`. """ rst_list, start_index, end_index, lines = _find_text_in_file( filename=os.path.join(PATH_TO_DOCS, "index.rst"), start_prompt=" This lis...
[ "def", "check_model_list_copy", "(", "overwrite", "=", "False", ",", "max_per_line", "=", "119", ")", ":", "rst_list", ",", "start_index", ",", "end_index", ",", "lines", "=", "_find_text_in_file", "(", "filename", "=", "os", ".", "path", ".", "join", "(", ...
[ 299, 0 ]
[ 317, 13 ]
python
en
['en', 'en', 'en']
True
test_login_new_user_and_trying_refresh_token
(hass, aiohttp_client)
Test logging in with new user and refreshing tokens.
Test logging in with new user and refreshing tokens.
async def test_login_new_user_and_trying_refresh_token(hass, aiohttp_client): """Test logging in with new user and refreshing tokens.""" client = await async_setup_auth(hass, aiohttp_client, setup_api=True) resp = await client.post( "/auth/login_flow", json={ "client_id": CLIENT_...
[ "async", "def", "test_login_new_user_and_trying_refresh_token", "(", "hass", ",", "aiohttp_client", ")", ":", "client", "=", "await", "async_setup_auth", "(", "hass", ",", "aiohttp_client", ",", "setup_api", "=", "True", ")", "resp", "=", "await", "client", ".", ...
[ 15, 0 ]
[ 75, 29 ]
python
en
['en', 'en', 'en']
True
test_auth_code_store_expiration
()
Test that the auth code store will not return expired tokens.
Test that the auth code store will not return expired tokens.
def test_auth_code_store_expiration(): """Test that the auth code store will not return expired tokens.""" store, retrieve = auth._create_auth_code_store() client_id = "bla" user = MockUser(id="mock_user") now = utcnow() with patch("homeassistant.util.dt.utcnow", return_value=now): code...
[ "def", "test_auth_code_store_expiration", "(", ")", ":", "store", ",", "retrieve", "=", "auth", ".", "_create_auth_code_store", "(", ")", "client_id", "=", "\"bla\"", "user", "=", "MockUser", "(", "id", "=", "\"mock_user\"", ")", "now", "=", "utcnow", "(", "...
[ 78, 0 ]
[ 100, 66 ]
python
en
['en', 'en', 'en']
True
test_ws_current_user
(hass, hass_ws_client, hass_access_token)
Test the current user command with Home Assistant creds.
Test the current user command with Home Assistant creds.
async def test_ws_current_user(hass, hass_ws_client, hass_access_token): """Test the current user command with Home Assistant creds.""" assert await async_setup_component(hass, "auth", {}) refresh_token = await hass.auth.async_validate_access_token(hass_access_token) user = refresh_token.user crede...
[ "async", "def", "test_ws_current_user", "(", "hass", ",", "hass_ws_client", ",", "hass_access_token", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"auth\"", ",", "{", "}", ")", "refresh_token", "=", "await", "hass", ".", "auth", "....
[ 103, 0 ]
[ 132, 34 ]
python
en
['en', 'en', 'en']
True
test_cors_on_token
(hass, aiohttp_client)
Test logging in with new user and refreshing tokens.
Test logging in with new user and refreshing tokens.
async def test_cors_on_token(hass, aiohttp_client): """Test logging in with new user and refreshing tokens.""" client = await async_setup_auth(hass, aiohttp_client) resp = await client.options( "/auth/token", headers={ "origin": "http://example.com", "Access-Control-...
[ "async", "def", "test_cors_on_token", "(", "hass", ",", "aiohttp_client", ")", ":", "client", "=", "await", "async_setup_auth", "(", "hass", ",", "aiohttp_client", ")", "resp", "=", "await", "client", ".", "options", "(", "\"/auth/token\"", ",", "headers", "="...
[ 135, 0 ]
[ 150, 78 ]
python
en
['en', 'en', 'en']
True
test_refresh_token_system_generated
(hass, aiohttp_client)
Test that we can get access tokens for system generated user.
Test that we can get access tokens for system generated user.
async def test_refresh_token_system_generated(hass, aiohttp_client): """Test that we can get access tokens for system generated user.""" client = await async_setup_auth(hass, aiohttp_client) user = await hass.auth.async_create_system_user("Test System") refresh_token = await hass.auth.async_create_refre...
[ "async", "def", "test_refresh_token_system_generated", "(", "hass", ",", "aiohttp_client", ")", ":", "client", "=", "await", "async_setup_auth", "(", "hass", ",", "aiohttp_client", ")", "user", "=", "await", "hass", ".", "auth", ".", "async_create_system_user", "(...
[ 153, 0 ]
[ 181, 5 ]
python
en
['en', 'en', 'en']
True
test_refresh_token_different_client_id
(hass, aiohttp_client)
Test that we verify client ID.
Test that we verify client ID.
async def test_refresh_token_different_client_id(hass, aiohttp_client): """Test that we verify client ID.""" client = await async_setup_auth(hass, aiohttp_client) user = await hass.auth.async_create_user("Test User") refresh_token = await hass.auth.async_create_refresh_token(user, CLIENT_ID) # No c...
[ "async", "def", "test_refresh_token_different_client_id", "(", "hass", ",", "aiohttp_client", ")", ":", "client", "=", "await", "async_setup_auth", "(", "hass", ",", "aiohttp_client", ")", "user", "=", "await", "hass", ".", "auth", ".", "async_create_user", "(", ...
[ 184, 0 ]
[ 228, 5 ]
python
en
['en', 'fr', 'en']
True
test_revoking_refresh_token
(hass, aiohttp_client)
Test that we can revoke refresh tokens.
Test that we can revoke refresh tokens.
async def test_revoking_refresh_token(hass, aiohttp_client): """Test that we can revoke refresh tokens.""" client = await async_setup_auth(hass, aiohttp_client) user = await hass.auth.async_create_user("Test User") refresh_token = await hass.auth.async_create_refresh_token(user, CLIENT_ID) # Test t...
[ "async", "def", "test_revoking_refresh_token", "(", "hass", ",", "aiohttp_client", ")", ":", "client", "=", "await", "async_setup_auth", "(", "hass", ",", "aiohttp_client", ")", "user", "=", "await", "hass", ".", "auth", ".", "async_create_user", "(", "\"Test Us...
[ 231, 0 ]
[ 272, 29 ]
python
en
['en', 'en', 'en']
True
test_ws_long_lived_access_token
(hass, hass_ws_client, hass_access_token)
Test generate long-lived access token.
Test generate long-lived access token.
async def test_ws_long_lived_access_token(hass, hass_ws_client, hass_access_token): """Test generate long-lived access token.""" assert await async_setup_component(hass, "auth", {"http": {}}) ws_client = await hass_ws_client(hass, hass_access_token) # verify create long-lived access token await ws...
[ "async", "def", "test_ws_long_lived_access_token", "(", "hass", ",", "hass_ws_client", ",", "hass_access_token", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"auth\"", ",", "{", "\"http\"", ":", "{", "}", "}", ")", "ws_client", "=", ...
[ 275, 0 ]
[ 300, 44 ]
python
en
['en', 'en', 'en']
True
test_ws_refresh_tokens
(hass, hass_ws_client, hass_access_token)
Test fetching refresh token metadata.
Test fetching refresh token metadata.
async def test_ws_refresh_tokens(hass, hass_ws_client, hass_access_token): """Test fetching refresh token metadata.""" assert await async_setup_component(hass, "auth", {"http": {}}) ws_client = await hass_ws_client(hass, hass_access_token) await ws_client.send_json({"id": 5, "type": auth.WS_TYPE_REFRE...
[ "async", "def", "test_ws_refresh_tokens", "(", "hass", ",", "hass_ws_client", ",", "hass_access_token", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"auth\"", ",", "{", "\"http\"", ":", "{", "}", "}", ")", "ws_client", "=", "await"...
[ 303, 0 ]
[ 324, 62 ]
python
en
['en', 'jv', 'pt']
False
test_ws_delete_refresh_token
(hass, hass_ws_client, hass_access_token)
Test deleting a refresh token.
Test deleting a refresh token.
async def test_ws_delete_refresh_token(hass, hass_ws_client, hass_access_token): """Test deleting a refresh token.""" assert await async_setup_component(hass, "auth", {"http": {}}) refresh_token = await hass.auth.async_validate_access_token(hass_access_token) ws_client = await hass_ws_client(hass, has...
[ "async", "def", "test_ws_delete_refresh_token", "(", "hass", ",", "hass_ws_client", ",", "hass_access_token", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"auth\"", ",", "{", "\"http\"", ":", "{", "}", "}", ")", "refresh_token", "=",...
[ 327, 0 ]
[ 347, 32 ]
python
en
['en', 'en', 'pt']
True
test_ws_sign_path
(hass, hass_ws_client, hass_access_token)
Test signing a path.
Test signing a path.
async def test_ws_sign_path(hass, hass_ws_client, hass_access_token): """Test signing a path.""" assert await async_setup_component(hass, "auth", {"http": {}}) ws_client = await hass_ws_client(hass, hass_access_token) refresh_token = await hass.auth.async_validate_access_token(hass_access_token) w...
[ "async", "def", "test_ws_sign_path", "(", "hass", ",", "hass_ws_client", ",", "hass_access_token", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"auth\"", ",", "{", "\"http\"", ":", "{", "}", "}", ")", "ws_client", "=", "await", "...
[ 350, 0 ]
[ 376, 40 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the updater component.
Set up the updater component.
async def async_setup(hass, config): """Set up the updater component.""" if "dev" in current_version: # This component only makes sense in release versions _LOGGER.info("Running on 'dev', only analytics will be submitted") conf = config.get(DOMAIN, {}) if conf.get(CONF_REPORTING): ...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "\"dev\"", "in", "current_version", ":", "# This component only makes sense in release versions", "_LOGGER", ".", "info", "(", "\"Running on 'dev', only analytics will be submitted\"", ")", "conf", ...
[ 52, 0 ]
[ 116, 15 ]
python
en
['en', 'en', 'en']
True
get_newest_version
(hass, huuid, include_components)
Get the newest Home Assistant version.
Get the newest Home Assistant version.
async def get_newest_version(hass, huuid, include_components): """Get the newest Home Assistant version.""" if huuid: info_object = await hass.helpers.system_info.async_get_system_info() if include_components: info_object["components"] = list(hass.config.components) linux_d...
[ "async", "def", "get_newest_version", "(", "hass", ",", "huuid", ",", "include_components", ")", ":", "if", "huuid", ":", "info_object", "=", "await", "hass", ".", "helpers", ".", "system_info", ".", "async_get_system_info", "(", ")", "if", "include_components",...
[ 119, 0 ]
[ 161, 18 ]
python
en
['en', 'en', 'en']
True
Updater.__init__
(self, update_available: bool, newest_version: str, release_notes: str)
Initialize attributes.
Initialize attributes.
def __init__(self, update_available: bool, newest_version: str, release_notes: str): """Initialize attributes.""" self.update_available = update_available self.release_notes = release_notes self.newest_version = newest_version
[ "def", "__init__", "(", "self", ",", "update_available", ":", "bool", ",", "newest_version", ":", "str", ",", "release_notes", ":", "str", ")", ":", "self", ".", "update_available", "=", "update_available", "self", ".", "release_notes", "=", "release_notes", "...
[ 45, 4 ]
[ 49, 44 ]
python
en
['en', 'en', 'it']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Transmission switch.
Set up the Transmission switch.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Transmission switch.""" tm_client = hass.data[DOMAIN][config_entry.entry_id] name = config_entry.data[CONF_NAME] dev = [] for switch_type, switch_name in SWITCH_TYPES.items(): dev.append(TransmissionSwitch(s...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "tm_client", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "name", "=", "config_entry", ".", "data", "[", ...
[ 13, 0 ]
[ 23, 33 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.__init__
(self, switch_type, switch_name, tm_client, name)
Initialize the Transmission switch.
Initialize the Transmission switch.
def __init__(self, switch_type, switch_name, tm_client, name): """Initialize the Transmission switch.""" self._name = switch_name self.client_name = name self.type = switch_type self._tm_client = tm_client self._state = STATE_OFF self._data = None self.uns...
[ "def", "__init__", "(", "self", ",", "switch_type", ",", "switch_name", ",", "tm_client", ",", "name", ")", ":", "self", ".", "_name", "=", "switch_name", "self", ".", "client_name", "=", "name", "self", ".", "type", "=", "switch_type", "self", ".", "_tm...
[ 29, 4 ]
[ 37, 32 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return f"{self.client_name} {self._name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.client_name} {self._name}\"" ]
[ 40, 4 ]
[ 42, 49 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.unique_id
(self)
Return the unique id of the entity.
Return the unique id of the entity.
def unique_id(self): """Return the unique id of the entity.""" return f"{self._tm_client.api.host}-{self.name}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._tm_client.api.host}-{self.name}\"" ]
[ 45, 4 ]
[ 47, 56 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 50, 4 ]
[ 52, 26 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.should_poll
(self)
Poll for status regularly.
Poll for status regularly.
def should_poll(self): """Poll for status regularly.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 55, 4 ]
[ 57, 20 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state == STATE_ON
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_ON" ]
[ 60, 4 ]
[ 62, 38 ]
python
en
['en', 'fy', 'en']
True
TransmissionSwitch.available
(self)
Could the device be accessed during the last update call.
Could the device be accessed during the last update call.
def available(self): """Could the device be accessed during the last update call.""" return self._tm_client.api.available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_tm_client", ".", "api", ".", "available" ]
[ 65, 4 ]
[ 67, 44 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" if self.type == "on_off": _LOGGING.debug("Starting all torrents") self._tm_client.api.start_torrents() elif self.type == "turtle_mode": _LOGGING.debug("Turning Turtle Mode of Transmission on") ...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "type", "==", "\"on_off\"", ":", "_LOGGING", ".", "debug", "(", "\"Starting all torrents\"", ")", "self", ".", "_tm_client", ".", "api", ".", "start_torrents", "(", ")",...
[ 69, 4 ]
[ 77, 36 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" if self.type == "on_off": _LOGGING.debug("Stopping all torrents") self._tm_client.api.stop_torrents() if self.type == "turtle_mode": _LOGGING.debug("Turning Turtle Mode of Transmission off") ...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "type", "==", "\"on_off\"", ":", "_LOGGING", ".", "debug", "(", "\"Stopping all torrents\"", ")", "self", ".", "_tm_client", ".", "api", ".", "stop_torrents", "(", ")",...
[ 79, 4 ]
[ 87, 36 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" self.unsub_update = async_dispatcher_connect( self.hass, self._tm_client.api.signal_update, self._schedule_immediate_update, )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "unsub_update", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "self", ".", "_tm_client", ".", "api", ".", "signal_update", ",", "self", ".", "_schedule_immediate_update"...
[ 89, 4 ]
[ 95, 9 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.will_remove_from_hass
(self)
Unsubscribe from update dispatcher.
Unsubscribe from update dispatcher.
async def will_remove_from_hass(self): """Unsubscribe from update dispatcher.""" if self.unsub_update: self.unsub_update() self.unsub_update = None
[ "async", "def", "will_remove_from_hass", "(", "self", ")", ":", "if", "self", ".", "unsub_update", ":", "self", ".", "unsub_update", "(", ")", "self", ".", "unsub_update", "=", "None" ]
[ 101, 4 ]
[ 105, 36 ]
python
en
['en', 'en', 'en']
True
TransmissionSwitch.update
(self)
Get the latest data from Transmission and updates the state.
Get the latest data from Transmission and updates the state.
def update(self): """Get the latest data from Transmission and updates the state.""" active = None if self.type == "on_off": self._data = self._tm_client.api.data if self._data: active = self._data.activeTorrentCount > 0 elif self.type == "turtle_...
[ "def", "update", "(", "self", ")", ":", "active", "=", "None", "if", "self", ".", "type", "==", "\"on_off\"", ":", "self", ".", "_data", "=", "self", ".", "_tm_client", ".", "api", ".", "data", "if", "self", ".", "_data", ":", "active", "=", "self"...
[ 107, 4 ]
[ 121, 55 ]
python
en
['en', 'en', 'en']
True
PathConvertor.build_path_without_trailing_slash
(path: str)
Build source path without trailing '/'. Args: path (str): Original path. Returns: str: Reformatted path.
Build source path without trailing '/'.
def build_path_without_trailing_slash(path: str) -> str: """Build source path without trailing '/'. Args: path (str): Original path. Returns: str: Reformatted path. """ if path.endswith("/"): path = path[:-1] return path
[ "def", "build_path_without_trailing_slash", "(", "path", ":", "str", ")", "->", "str", ":", "if", "path", ".", "endswith", "(", "\"/\"", ")", ":", "path", "=", "path", "[", ":", "-", "1", "]", "return", "path" ]
[ 6, 4 ]
[ 17, 19 ]
python
en
['en', 'en', 'en']
True
PathConvertor.build_path_with_trailing_slash
(path: str)
Build reformatted target dir with trailing '/'. Args: path: (str): Original path. Returns: str: Reformatted path.
Build reformatted target dir with trailing '/'.
def build_path_with_trailing_slash(path: str) -> str: """Build reformatted target dir with trailing '/'. Args: path: (str): Original path. Returns: str: Reformatted path. """ if not path.endswith("/"): path = path + "/" return path
[ "def", "build_path_with_trailing_slash", "(", "path", ":", "str", ")", "->", "str", ":", "if", "not", "path", ".", "endswith", "(", "\"/\"", ")", ":", "path", "=", "path", "+", "\"/\"", "return", "path" ]
[ 20, 4 ]
[ 31, 19 ]
python
en
['en', 'en', 'en']
True
extract_placeholders
(obj: Any)
Extract placeholders from a structure.
Extract placeholders from a structure.
def extract_placeholders(obj: Any) -> Set[str]: """Extract placeholders from a structure.""" found: Set[str] = set() _extract_placeholders(obj, found) return found
[ "def", "extract_placeholders", "(", "obj", ":", "Any", ")", "->", "Set", "[", "str", "]", ":", "found", ":", "Set", "[", "str", "]", "=", "set", "(", ")", "_extract_placeholders", "(", "obj", ",", "found", ")", "return", "found" ]
[ 15, 0 ]
[ 19, 16 ]
python
en
['en', 'en', 'en']
True
_extract_placeholders
(obj: Any, found: Set[str])
Extract placeholders from a structure.
Extract placeholders from a structure.
def _extract_placeholders(obj: Any, found: Set[str]) -> None: """Extract placeholders from a structure.""" if isinstance(obj, Placeholder): found.add(obj.name) return if isinstance(obj, list): for val in obj: _extract_placeholders(val, found) return if isins...
[ "def", "_extract_placeholders", "(", "obj", ":", "Any", ",", "found", ":", "Set", "[", "str", "]", ")", "->", "None", ":", "if", "isinstance", "(", "obj", ",", "Placeholder", ")", ":", "found", ".", "add", "(", "obj", ".", "name", ")", "return", "i...
[ 22, 0 ]
[ 36, 14 ]
python
en
['en', 'en', 'en']
True
substitute
(obj: Any, substitutions: Dict[str, Any])
Substitute values.
Substitute values.
def substitute(obj: Any, substitutions: Dict[str, Any]) -> Any: """Substitute values.""" if isinstance(obj, Placeholder): if obj.name not in substitutions: raise UndefinedSubstitution(obj.name) return substitutions[obj.name] if isinstance(obj, list): return [substitute(v...
[ "def", "substitute", "(", "obj", ":", "Any", ",", "substitutions", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Any", ":", "if", "isinstance", "(", "obj", ",", "Placeholder", ")", ":", "if", "obj", ".", "name", "not", "in", "substitutions", ...
[ 39, 0 ]
[ 52, 14 ]
python
en
['en', 'la', 'en']
False
UndefinedSubstitution.__init__
(self, placeholder: str)
Initialize the undefined substitution exception.
Initialize the undefined substitution exception.
def __init__(self, placeholder: str) -> None: """Initialize the undefined substitution exception.""" super().__init__(f"No substitution found for placeholder {placeholder}") self.placeholder = placeholder
[ "def", "__init__", "(", "self", ",", "placeholder", ":", "str", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "f\"No substitution found for placeholder {placeholder}\"", ")", "self", ".", "placeholder", "=", "placeholder" ]
[ 9, 4 ]
[ 12, 38 ]
python
en
['en', 'en', 'en']
True
test_async_setup_no_domain_config
(hass: HomeAssistant)
Test setup without configuration is noop.
Test setup without configuration is noop.
async def test_async_setup_no_domain_config(hass: HomeAssistant): """Test setup without configuration is noop.""" result = await async_setup_component(hass, DOMAIN, {}) assert result is True
[ "async", "def", "test_async_setup_no_domain_config", "(", "hass", ":", "HomeAssistant", ")", ":", "result", "=", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "}", ")", "assert", "result", "is", "True" ]
[ 19, 0 ]
[ 23, 25 ]
python
en
['en', 'en', 'en']
True
test_async_setup_raises_entry_not_ready
(hass: HomeAssistant)
Test that it throws ConfigEntryNotReady when exception occurs during setup.
Test that it throws ConfigEntryNotReady when exception occurs during setup.
async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant): """Test that it throws ConfigEntryNotReady when exception occurs during setup.""" config_entry = MockConfigEntry( domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) config_entry.add_to_h...
[ "async", "def", "test_async_setup_raises_entry_not_ready", "(", "hass", ":", "HomeAssistant", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"some host\"", ",", "CONF_ACCESS_TOKEN", ":", "...
[ 26, 0 ]
[ 36, 56 ]
python
en
['en', 'en', 'en']
True
test_async_setup_entry_sets_up_hub_and_supported_domains
(hass: HomeAssistant)
Test that configuring entry sets up cover domain.
Test that configuring entry sets up cover domain.
async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAssistant): """Test that configuring entry sets up cover domain.""" config_entry = MockConfigEntry( domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) with patch_bond_version( ...
[ "async", "def", "test_async_setup_entry_sets_up_hub_and_supported_domains", "(", "hass", ":", "HomeAssistant", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"some host\"", ",", "CONF_ACCESS_T...
[ 39, 0 ]
[ 84, 61 ]
python
en
['en', 'en', 'en']
True
test_unload_config_entry
(hass: HomeAssistant)
Test that configuration entry supports unloading.
Test that configuration entry supports unloading.
async def test_unload_config_entry(hass: HomeAssistant): """Test that configuration entry supports unloading.""" config_entry = MockConfigEntry( domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, ) result = await setup_bond_entity( hass, confi...
[ "async", "def", "test_unload_config_entry", "(", "hass", ":", "HomeAssistant", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_HOST", ":", "\"some host\"", ",", "CONF_ACCESS_TOKEN", ":", "\"test-token\""...
[ 87, 0 ]
[ 108, 55 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the KNX component.
Set up the KNX component.
async def async_setup(hass, config): """Set up the KNX component.""" try: hass.data[DOMAIN] = KNXModule(hass, config) hass.data[DOMAIN].async_create_exposures() await hass.data[DOMAIN].start() except XKNXException as ex: _LOGGER.warning("Could not connect to KNX interface: %s...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "try", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "KNXModule", "(", "hass", ",", "config", ")", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_create_exposures", "(", ...
[ 144, 0 ]
[ 202, 15 ]
python
en
['en', 'en', 'en']
True
KNXModule.__init__
(self, hass, config)
Initialize of KNX module.
Initialize of KNX module.
def __init__(self, hass, config): """Initialize of KNX module.""" self.hass = hass self.config = config self.connected = False self.init_xknx() self.register_callbacks() self.exposures = []
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "config", "=", "config", "self", ".", "connected", "=", "False", "self", ".", "init_xknx", "(", ")", "self", ".", "register_callbacks",...
[ 208, 4 ]
[ 215, 27 ]
python
en
['en', 'en', 'en']
True
KNXModule.init_xknx
(self)
Initialize of KNX object.
Initialize of KNX object.
def init_xknx(self): """Initialize of KNX object.""" self.xknx = XKNX( config=self.config_file(), own_address=self.config[DOMAIN][CONF_KNX_INDIVIDUAL_ADDRESS], rate_limit=self.config[DOMAIN][CONF_KNX_RATE_LIMIT], multicast_group=self.config[DOMAIN][CONF_KN...
[ "def", "init_xknx", "(", "self", ")", ":", "self", ".", "xknx", "=", "XKNX", "(", "config", "=", "self", ".", "config_file", "(", ")", ",", "own_address", "=", "self", ".", "config", "[", "DOMAIN", "]", "[", "CONF_KNX_INDIVIDUAL_ADDRESS", "]", ",", "ra...
[ 217, 4 ]
[ 227, 9 ]
python
en
['en', 'en', 'en']
True
KNXModule.start
(self)
Start KNX object. Connect to tunneling or Routing device.
Start KNX object. Connect to tunneling or Routing device.
async def start(self): """Start KNX object. Connect to tunneling or Routing device.""" await self.xknx.start() self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop) self.connected = True
[ "async", "def", "start", "(", "self", ")", ":", "await", "self", ".", "xknx", ".", "start", "(", ")", "self", ".", "hass", ".", "bus", ".", "async_listen_once", "(", "EVENT_HOMEASSISTANT_STOP", ",", "self", ".", "stop", ")", "self", ".", "connected", "...
[ 229, 4 ]
[ 233, 29 ]
python
en
['en', 'en', 'en']
True
KNXModule.stop
(self, event)
Stop KNX object. Disconnect from tunneling or Routing device.
Stop KNX object. Disconnect from tunneling or Routing device.
async def stop(self, event): """Stop KNX object. Disconnect from tunneling or Routing device.""" await self.xknx.stop()
[ "async", "def", "stop", "(", "self", ",", "event", ")", ":", "await", "self", ".", "xknx", ".", "stop", "(", ")" ]
[ 235, 4 ]
[ 237, 30 ]
python
en
['en', 'en', 'en']
True
KNXModule.config_file
(self)
Resolve and return the full path of xknx.yaml if configured.
Resolve and return the full path of xknx.yaml if configured.
def config_file(self): """Resolve and return the full path of xknx.yaml if configured.""" config_file = self.config[DOMAIN].get(CONF_KNX_CONFIG) if not config_file: return None if not config_file.startswith("/"): return self.hass.config.path(config_file) r...
[ "def", "config_file", "(", "self", ")", ":", "config_file", "=", "self", ".", "config", "[", "DOMAIN", "]", ".", "get", "(", "CONF_KNX_CONFIG", ")", "if", "not", "config_file", ":", "return", "None", "if", "not", "config_file", ".", "startswith", "(", "\...
[ 239, 4 ]
[ 246, 26 ]
python
en
['en', 'en', 'en']
True
KNXModule.connection_config
(self)
Return the connection_config.
Return the connection_config.
def connection_config(self): """Return the connection_config.""" if CONF_KNX_TUNNELING in self.config[DOMAIN]: return self.connection_config_tunneling() if CONF_KNX_ROUTING in self.config[DOMAIN]: return self.connection_config_routing() # config from xknx.yaml alw...
[ "def", "connection_config", "(", "self", ")", ":", "if", "CONF_KNX_TUNNELING", "in", "self", ".", "config", "[", "DOMAIN", "]", ":", "return", "self", ".", "connection_config_tunneling", "(", ")", "if", "CONF_KNX_ROUTING", "in", "self", ".", "config", "[", "...
[ 248, 4 ]
[ 255, 33 ]
python
en
['en', 'en', 'en']
True
KNXModule.connection_config_routing
(self)
Return the connection_config if routing is configured.
Return the connection_config if routing is configured.
def connection_config_routing(self): """Return the connection_config if routing is configured.""" local_ip = self.config[DOMAIN][CONF_KNX_ROUTING].get( ConnectionSchema.CONF_KNX_LOCAL_IP ) return ConnectionConfig( connection_type=ConnectionType.ROUTING, local_ip=l...
[ "def", "connection_config_routing", "(", "self", ")", ":", "local_ip", "=", "self", ".", "config", "[", "DOMAIN", "]", "[", "CONF_KNX_ROUTING", "]", ".", "get", "(", "ConnectionSchema", ".", "CONF_KNX_LOCAL_IP", ")", "return", "ConnectionConfig", "(", "connectio...
[ 257, 4 ]
[ 264, 9 ]
python
en
['en', 'en', 'en']
True
KNXModule.connection_config_tunneling
(self)
Return the connection_config if tunneling is configured.
Return the connection_config if tunneling is configured.
def connection_config_tunneling(self): """Return the connection_config if tunneling is configured.""" gateway_ip = self.config[DOMAIN][CONF_KNX_TUNNELING][CONF_HOST] gateway_port = self.config[DOMAIN][CONF_KNX_TUNNELING][CONF_PORT] local_ip = self.config[DOMAIN][CONF_KNX_TUNNELING].get( ...
[ "def", "connection_config_tunneling", "(", "self", ")", ":", "gateway_ip", "=", "self", ".", "config", "[", "DOMAIN", "]", "[", "CONF_KNX_TUNNELING", "]", "[", "CONF_HOST", "]", "gateway_port", "=", "self", ".", "config", "[", "DOMAIN", "]", "[", "CONF_KNX_T...
[ 266, 4 ]
[ 279, 9 ]
python
en
['en', 'en', 'en']
True
KNXModule.register_callbacks
(self)
Register callbacks within XKNX object.
Register callbacks within XKNX object.
def register_callbacks(self): """Register callbacks within XKNX object.""" if ( CONF_KNX_FIRE_EVENT in self.config[DOMAIN] and self.config[DOMAIN][CONF_KNX_FIRE_EVENT] ): address_filters = list( map(AddressFilter, self.config[DOMAIN][CONF_KNX_F...
[ "def", "register_callbacks", "(", "self", ")", ":", "if", "(", "CONF_KNX_FIRE_EVENT", "in", "self", ".", "config", "[", "DOMAIN", "]", "and", "self", ".", "config", "[", "DOMAIN", "]", "[", "CONF_KNX_FIRE_EVENT", "]", ")", ":", "address_filters", "=", "lis...
[ 281, 4 ]
[ 292, 13 ]
python
en
['en', 'en', 'en']
True
KNXModule.async_create_exposures
(self)
Create exposures.
Create exposures.
def async_create_exposures(self): """Create exposures.""" if CONF_KNX_EXPOSE not in self.config[DOMAIN]: return for to_expose in self.config[DOMAIN][CONF_KNX_EXPOSE]: expose_type = to_expose.get(ExposeSchema.CONF_KNX_EXPOSE_TYPE) entity_id = to_expose.get(CONF...
[ "def", "async_create_exposures", "(", "self", ")", ":", "if", "CONF_KNX_EXPOSE", "not", "in", "self", ".", "config", "[", "DOMAIN", "]", ":", "return", "for", "to_expose", "in", "self", ".", "config", "[", "DOMAIN", "]", "[", "CONF_KNX_EXPOSE", "]", ":", ...
[ 295, 4 ]
[ 320, 47 ]
python
en
['es', 'la', 'en']
False
KNXModule.telegram_received_cb
(self, telegram)
Call invoked after a KNX telegram was received.
Call invoked after a KNX telegram was received.
async def telegram_received_cb(self, telegram): """Call invoked after a KNX telegram was received.""" self.hass.bus.async_fire( "knx_event", {"address": str(telegram.group_address), "data": telegram.payload.value}, ) # False signals XKNX to proceed with processing...
[ "async", "def", "telegram_received_cb", "(", "self", ",", "telegram", ")", ":", "self", ".", "hass", ".", "bus", ".", "async_fire", "(", "\"knx_event\"", ",", "{", "\"address\"", ":", "str", "(", "telegram", ".", "group_address", ")", ",", "\"data\"", ":",...
[ 322, 4 ]
[ 329, 20 ]
python
en
['en', 'en', 'en']
True
KNXModule.service_send_to_knx_bus
(self, call)
Service for sending an arbitrary KNX message to the KNX bus.
Service for sending an arbitrary KNX message to the KNX bus.
async def service_send_to_knx_bus(self, call): """Service for sending an arbitrary KNX message to the KNX bus.""" attr_payload = call.data.get(SERVICE_KNX_ATTR_PAYLOAD) attr_address = call.data.get(SERVICE_KNX_ATTR_ADDRESS) attr_type = call.data.get(SERVICE_KNX_ATTR_TYPE) def ca...
[ "async", "def", "service_send_to_knx_bus", "(", "self", ",", "call", ")", ":", "attr_payload", "=", "call", ".", "data", ".", "get", "(", "SERVICE_KNX_ATTR_PAYLOAD", ")", "attr_address", "=", "call", ".", "data", ".", "get", "(", "SERVICE_KNX_ATTR_ADDRESS", ")...
[ 331, 4 ]
[ 352, 47 ]
python
en
['en', 'en', 'en']
True
KNXExposeTime.__init__
(self, xknx: XKNX, expose_type: str, address: str)
Initialize of Expose class.
Initialize of Expose class.
def __init__(self, xknx: XKNX, expose_type: str, address: str): """Initialize of Expose class.""" self.xknx = xknx self.expose_type = expose_type self.address = address self.device = None
[ "def", "__init__", "(", "self", ",", "xknx", ":", "XKNX", ",", "expose_type", ":", "str", ",", "address", ":", "str", ")", ":", "self", ".", "xknx", "=", "xknx", "self", ".", "expose_type", "=", "expose_type", "self", ".", "address", "=", "address", ...
[ 358, 4 ]
[ 363, 26 ]
python
en
['en', 'en', 'en']
True
KNXExposeTime.async_register
(self)
Register listener.
Register listener.
def async_register(self): """Register listener.""" self.device = DateTime( self.xknx, name=self.expose_type.capitalize(), broadcast_type=self.expose_type.upper(), localtime=True, group_address=self.address, )
[ "def", "async_register", "(", "self", ")", ":", "self", ".", "device", "=", "DateTime", "(", "self", ".", "xknx", ",", "name", "=", "self", ".", "expose_type", ".", "capitalize", "(", ")", ",", "broadcast_type", "=", "self", ".", "expose_type", ".", "u...
[ 366, 4 ]
[ 374, 9 ]
python
en
['fr', 'no', 'en']
False
KNXExposeSensor.__init__
(self, hass, xknx, expose_type, entity_id, attribute, default, address)
Initialize of Expose class.
Initialize of Expose class.
def __init__(self, hass, xknx, expose_type, entity_id, attribute, default, address): """Initialize of Expose class.""" self.hass = hass self.xknx = xknx self.type = expose_type self.entity_id = entity_id self.expose_attribute = attribute self.expose_default = defa...
[ "def", "__init__", "(", "self", ",", "hass", ",", "xknx", ",", "expose_type", ",", "entity_id", ",", "attribute", ",", "default", ",", "address", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "xknx", "=", "xknx", "self", ".", "type", "=", ...
[ 380, 4 ]
[ 389, 26 ]
python
en
['en', 'en', 'en']
True
KNXExposeSensor.async_register
(self)
Register listener.
Register listener.
def async_register(self): """Register listener.""" if self.expose_attribute is not None: _name = self.entity_id + "__" + self.expose_attribute else: _name = self.entity_id self.device = ExposeSensor( self.xknx, name=_name, group...
[ "def", "async_register", "(", "self", ")", ":", "if", "self", ".", "expose_attribute", "is", "not", "None", ":", "_name", "=", "self", ".", "entity_id", "+", "\"__\"", "+", "self", ".", "expose_attribute", "else", ":", "_name", "=", "self", ".", "entity_...
[ 392, 4 ]
[ 406, 9 ]
python
en
['fr', 'no', 'en']
False
KNXExposeSensor._async_entity_changed
(self, event)
Handle entity change.
Handle entity change.
async def _async_entity_changed(self, event): """Handle entity change.""" new_state = event.data.get("new_state") if new_state is None: return if new_state.state in (STATE_UNKNOWN, STATE_UNAVAILABLE): return if self.expose_attribute is not None: ...
[ "async", "def", "_async_entity_changed", "(", "self", ",", "event", ")", ":", "new_state", "=", "event", ".", "data", ".", "get", "(", "\"new_state\"", ")", "if", "new_state", "is", "None", ":", "return", "if", "new_state", ".", "state", "in", "(", "STAT...
[ 408, 4 ]
[ 427, 60 ]
python
en
['en', 'xh', 'en']
True
KNXExposeSensor._async_set_knx_value
(self, value)
Set new value on xknx ExposeSensor.
Set new value on xknx ExposeSensor.
async def _async_set_knx_value(self, value): """Set new value on xknx ExposeSensor.""" if value is None: if self.expose_default is None: return value = self.expose_default if self.type == "binary": if value == STATE_ON: value =...
[ "async", "def", "_async_set_knx_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "if", "self", ".", "expose_default", "is", "None", ":", "return", "value", "=", "self", ".", "expose_default", "if", "self", ".", "type", "==",...
[ 429, 4 ]
[ 442, 36 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Perform the setup for Switchbot devices.
Perform the setup for Switchbot devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Perform the setup for Switchbot devices.""" name = config.get(CONF_NAME) mac_addr = config[CONF_MAC] password = config.get(CONF_PASSWORD) add_entities([SwitchBot(mac_addr, name, password)])
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "mac_addr", "=", "config", "[", "CONF_MAC", "]", "password", "=", "config", ...
[ 23, 0 ]
[ 28, 55 ]
python
en
['en', 'en', 'en']
True
SwitchBot.__init__
(self, mac, name, password)
Initialize the Switchbot.
Initialize the Switchbot.
def __init__(self, mac, name, password) -> None: """Initialize the Switchbot.""" self._state = None self._last_run_success = None self._name = name self._mac = mac self._device = switchbot.Switchbot(mac=mac, password=password)
[ "def", "__init__", "(", "self", ",", "mac", ",", "name", ",", "password", ")", "->", "None", ":", "self", ".", "_state", "=", "None", "self", ".", "_last_run_success", "=", "None", "self", ".", "_name", "=", "name", "self", ".", "_mac", "=", "mac", ...
[ 34, 4 ]
[ 41, 70 ]
python
en
['en', 'en', 'en']
True
SwitchBot.async_added_to_hass
(self)
Run when entity about to be added.
Run when entity about to be added.
async def async_added_to_hass(self): """Run when entity about to be added.""" await super().async_added_to_hass() state = await self.async_get_last_state() if not state: return self._state = state.state == "on"
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", "not", "state", ":", "return", "self", ".", "_state"...
[ 43, 4 ]
[ 49, 41 ]
python
en
['en', 'en', 'en']
True
SwitchBot.turn_on
(self, **kwargs)
Turn device on.
Turn device on.
def turn_on(self, **kwargs) -> None: """Turn device on.""" if self._device.turn_on(): self._state = True self._last_run_success = True else: self._last_run_success = False
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "self", ".", "_device", ".", "turn_on", "(", ")", ":", "self", ".", "_state", "=", "True", "self", ".", "_last_run_success", "=", "True", "else", ":", "self", "."...
[ 51, 4 ]
[ 57, 42 ]
python
en
['es', 'en', 'en']
True
SwitchBot.turn_off
(self, **kwargs)
Turn device off.
Turn device off.
def turn_off(self, **kwargs) -> None: """Turn device off.""" if self._device.turn_off(): self._state = False self._last_run_success = True else: self._last_run_success = False
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "self", ".", "_device", ".", "turn_off", "(", ")", ":", "self", ".", "_state", "=", "False", "self", ".", "_last_run_success", "=", "True", "else", ":", "self", ...
[ 59, 4 ]
[ 65, 42 ]
python
en
['en', 'en', 'en']
True