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
MochadLight.is_on
(self)
Return true if the light is on.
Return true if the light is on.
def is_on(self): """Return true if the light is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 74, 4 ]
[ 76, 26 ]
python
en
['en', 'en', 'en']
True
MochadLight.supported_features
(self)
Return supported features.
Return supported features.
def supported_features(self): """Return supported features.""" return SUPPORT_BRIGHTNESS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS" ]
[ 79, 4 ]
[ 81, 33 ]
python
en
['en', 'en', 'en']
True
MochadLight.assumed_state
(self)
X10 devices are normally 1-way so we have to assume the state.
X10 devices are normally 1-way so we have to assume the state.
def assumed_state(self): """X10 devices are normally 1-way so we have to assume the state.""" return True
[ "def", "assumed_state", "(", "self", ")", ":", "return", "True" ]
[ 84, 4 ]
[ 86, 19 ]
python
en
['en', 'en', 'en']
True
MochadLight.turn_on
(self, **kwargs)
Send the command to turn the light on.
Send the command to turn the light on.
def turn_on(self, **kwargs): """Send the command to turn the light on.""" brightness = kwargs.get(ATTR_BRIGHTNESS, 255) with REQ_LOCK: if self._brightness_levels > 32: out_brightness = self._calculate_brightness_value(brightness) self.light.send_cmd(f"...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ",", "255", ")", "with", "REQ_LOCK", ":", "if", "self", ".", "_brightness_levels", ">", "32", ":", "out_brightness", "=", ...
[ 103, 4 ]
[ 120, 26 ]
python
en
['en', 'en', 'en']
True
MochadLight.turn_off
(self, **kwargs)
Send the command to turn the light on.
Send the command to turn the light on.
def turn_off(self, **kwargs): """Send the command to turn the light on.""" with REQ_LOCK: self.light.send_cmd("off") self._controller.read_data() # There is no persistence for X10 modules so we need to prepare # to track a fresh on command will full bright...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "with", "REQ_LOCK", ":", "self", ".", "light", ".", "send_cmd", "(", "\"off\"", ")", "self", ".", "_controller", ".", "read_data", "(", ")", "# There is no persistence for X10 modules so we nee...
[ 122, 4 ]
[ 131, 27 ]
python
en
['en', 'en', 'en']
True
relative_url
(url)
Convert an absolute url to a relative one.
Convert an absolute url to a relative one.
def relative_url(url): """Convert an absolute url to a relative one.""" return str(yarl.URL(url).relative())
[ "def", "relative_url", "(", "url", ")", ":", "return", "str", "(", "yarl", ".", "URL", "(", "url", ")", ".", "relative", "(", ")", ")" ]
[ 18, 0 ]
[ 20, 40 ]
python
en
['en', 'en', 'en']
True
mutagen_mock
()
Mock writing tags.
Mock writing tags.
def mutagen_mock(): """Mock writing tags.""" with patch( "homeassistant.components.tts.SpeechManager.write_tags", side_effect=lambda *args: args[1], ): yield
[ "def", "mutagen_mock", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.tts.SpeechManager.write_tags\"", ",", "side_effect", "=", "lambda", "*", "args", ":", "args", "[", "1", "]", ",", ")", ":", "yield" ]
[ 24, 0 ]
[ 30, 13 ]
python
en
['en', 'ceb', 'en']
True
internal_url_mock
(hass)
Mock internal URL of the instance.
Mock internal URL of the instance.
async def internal_url_mock(hass): """Mock internal URL of the instance.""" await async_process_ha_core_config( hass, {"internal_url": "http://example.local:8123"}, )
[ "async", "def", "internal_url_mock", "(", "hass", ")", ":", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"internal_url\"", ":", "\"http://example.local:8123\"", "}", ",", ")" ]
[ 34, 0 ]
[ 39, 5 ]
python
en
['en', 'fy', 'en']
True
test_setup_platform
(hass)
Set up the tts platform .
Set up the tts platform .
async def test_setup_platform(hass): """Set up the tts platform .""" config = { notify.DOMAIN: { "platform": "tts", "name": "tts_test", "tts_service": "tts.demo_say", "media_player": "media_player.demo", } } with assert_setup_component(1, n...
[ "async", "def", "test_setup_platform", "(", "hass", ")", ":", "config", "=", "{", "notify", ".", "DOMAIN", ":", "{", "\"platform\"", ":", "\"tts\"", ",", "\"name\"", ":", "\"tts_test\"", ",", "\"tts_service\"", ":", "\"tts.demo_say\"", ",", "\"media_player\"", ...
[ 42, 0 ]
[ 55, 63 ]
python
en
['en', 'da', 'en']
True
test_setup_component_and_test_service
(hass)
Set up the demo platform and call service.
Set up the demo platform and call service.
async def test_setup_component_and_test_service(hass): """Set up the demo platform and call service.""" calls = async_mock_service(hass, DOMAIN_MP, SERVICE_PLAY_MEDIA) config = { tts.DOMAIN: {"platform": "demo"}, media_player.DOMAIN: {"platform": "demo"}, notify.DOMAIN: { ...
[ "async", "def", "test_setup_component_and_test_service", "(", "hass", ")", ":", "calls", "=", "async_mock_service", "(", "hass", ",", "DOMAIN_MP", ",", "SERVICE_PLAY_MEDIA", ")", "config", "=", "{", "tts", ".", "DOMAIN", ":", "{", "\"platform\"", ":", "\"demo\""...
[ 58, 0 ]
[ 91, 26 ]
python
en
['en', 'pt', 'en']
True
_build_engine_onnx
(input_onnx: Union[str, bytes], force_fp16: bool = False, max_batch_size: int = 1, max_workspace: int = 1024)
Builds TensorRT engine from provided ONNX file :param input_onnx: serialized ONNX model. :param force_fp16: Force use of FP16 precision, even if device doesn't support it. Be careful. :param max_batch_size: Define maximum batch size supported by engine. If >1 creates optimization profile. :param m...
Builds TensorRT engine from provided ONNX file
def _build_engine_onnx(input_onnx: Union[str, bytes], force_fp16: bool = False, max_batch_size: int = 1, max_workspace: int = 1024): """ Builds TensorRT engine from provided ONNX file :param input_onnx: serialized ONNX model. :param force_fp16: Force use of FP16 precision, even i...
[ "def", "_build_engine_onnx", "(", "input_onnx", ":", "Union", "[", "str", ",", "bytes", "]", ",", "force_fp16", ":", "bool", "=", "False", ",", "max_batch_size", ":", "int", "=", "1", ",", "max_workspace", ":", "int", "=", "1024", ")", ":", "with", "tr...
[ 14, 0 ]
[ 58, 59 ]
python
en
['en', 'error', 'th']
False
convert_onnx
(input_onnx: Union[str, bytes], engine_file_path: str, force_fp16: bool = False, max_batch_size: int = 1,)
Creates TensorRT engine and serializes it to disk :param input_onnx: Path to ONNX file on disk or serialized ONNX model. :param engine_file_path: Path where TensorRT engine should be saved. :param force_fp16: Force use of FP16 precision, even if device doesn't support it. Be careful. :param max_bat...
Creates TensorRT engine and serializes it to disk :param input_onnx: Path to ONNX file on disk or serialized ONNX model. :param engine_file_path: Path where TensorRT engine should be saved. :param force_fp16: Force use of FP16 precision, even if device doesn't support it. Be careful. :param max_bat...
def convert_onnx(input_onnx: Union[str, bytes], engine_file_path: str, force_fp16: bool = False, max_batch_size: int = 1,): ''' Creates TensorRT engine and serializes it to disk :param input_onnx: Path to ONNX file on disk or serialized ONNX model. :param engine_file_path: Path where Te...
[ "def", "convert_onnx", "(", "input_onnx", ":", "Union", "[", "str", ",", "bytes", "]", ",", "engine_file_path", ":", "str", ",", "force_fp16", ":", "bool", "=", "False", ",", "max_batch_size", ":", "int", "=", "1", ",", ")", ":", "onnx_obj", "=", "None...
[ 62, 0 ]
[ 86, 35 ]
python
en
['en', 'error', 'th']
False
_assert_tensors_equal
(a, b, atol=1e-12, prefix="")
If tensors not close, or a and b arent both tensors, raise a nice Assertion error.
If tensors not close, or a and b arent both tensors, raise a nice Assertion error.
def _assert_tensors_equal(a, b, atol=1e-12, prefix=""): """If tensors not close, or a and b arent both tensors, raise a nice Assertion error.""" if a is None and b is None: return True try: if tf.debugging.assert_near(a, b, atol=atol): return True raise except Excepti...
[ "def", "_assert_tensors_equal", "(", "a", ",", "b", ",", "atol", "=", "1e-12", ",", "prefix", "=", "\"\"", ")", ":", "if", "a", "is", "None", "and", "b", "is", "None", ":", "return", "True", "try", ":", "if", "tf", ".", "debugging", ".", "assert_ne...
[ 578, 0 ]
[ 590, 33 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the N26 switch platform.
Set up the N26 switch platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the N26 switch platform.""" if discovery_info is None: return api_list = hass.data[DOMAIN][DATA] switch_entities = [] for api_data in api_list: for card in api_data.cards: switch_entities.app...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "api_list", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA", "]", "swit...
[ 9, 0 ]
[ 21, 33 ]
python
en
['en', 'da', 'en']
True
N26CardSwitch.__init__
(self, api_data, card: dict)
Initialize the N26 card block/unblock switch.
Initialize the N26 card block/unblock switch.
def __init__(self, api_data, card: dict): """Initialize the N26 card block/unblock switch.""" self._data = api_data self._card = card
[ "def", "__init__", "(", "self", ",", "api_data", ",", "card", ":", "dict", ")", ":", "self", ".", "_data", "=", "api_data", "self", ".", "_card", "=", "card" ]
[ 27, 4 ]
[ 30, 25 ]
python
en
['en', 'en', 'en']
True
N26CardSwitch.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 self._card["id"]
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_card", "[", "\"id\"", "]" ]
[ 33, 4 ]
[ 35, 31 ]
python
en
['en', 'en', 'en']
True
N26CardSwitch.name
(self)
Friendly name of the sensor.
Friendly name of the sensor.
def name(self) -> str: """Friendly name of the sensor.""" return f"card_{self._card['id']}"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"card_{self._card['id']}\"" ]
[ 38, 4 ]
[ 40, 41 ]
python
en
['en', 'en', 'en']
True
N26CardSwitch.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" return self._card["status"] == CARD_STATE_ACTIVE
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_card", "[", "\"status\"", "]", "==", "CARD_STATE_ACTIVE" ]
[ 43, 4 ]
[ 45, 56 ]
python
en
['en', 'fy', 'en']
True
N26CardSwitch.turn_on
(self, **kwargs)
Block the card.
Block the card.
def turn_on(self, **kwargs): """Block the card.""" self._data.api.unblock_card(self._card["id"]) self._card["status"] = CARD_STATE_ACTIVE
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_data", ".", "api", ".", "unblock_card", "(", "self", ".", "_card", "[", "\"id\"", "]", ")", "self", ".", "_card", "[", "\"status\"", "]", "=", "CARD_STATE_ACTIVE" ]
[ 47, 4 ]
[ 50, 48 ]
python
en
['en', 'ms', 'en']
True
N26CardSwitch.turn_off
(self, **kwargs)
Unblock the card.
Unblock the card.
def turn_off(self, **kwargs): """Unblock the card.""" self._data.api.block_card(self._card["id"]) self._card["status"] = CARD_STATE_BLOCKED
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_data", ".", "api", ".", "block_card", "(", "self", ".", "_card", "[", "\"id\"", "]", ")", "self", ".", "_card", "[", "\"status\"", "]", "=", "CARD_STATE_BLOCKED" ]
[ 52, 4 ]
[ 55, 49 ]
python
en
['en', 'en', 'en']
True
N26CardSwitch.update
(self)
Update the switch state.
Update the switch state.
def update(self): """Update the switch state.""" self._data.update_cards() self._card = self._data.card(self._card["id"], self._card)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_data", ".", "update_cards", "(", ")", "self", ".", "_card", "=", "self", ".", "_data", ".", "card", "(", "self", ".", "_card", "[", "\"id\"", "]", ",", "self", ".", "_card", ")" ]
[ 57, 4 ]
[ 60, 66 ]
python
en
['en', 'en', 'en']
True
generate_summaries_or_translations
( examples: List[str], out_file: str, model_name: str, batch_size: int = 8, device: str = DEFAULT_DEVICE, fp16=False, task="summarization", prefix=None, **generate_kwargs, )
Save model.generate results to <out_file>, and return how long it took.
Save model.generate results to <out_file>, and return how long it took.
def generate_summaries_or_translations( examples: List[str], out_file: str, model_name: str, batch_size: int = 8, device: str = DEFAULT_DEVICE, fp16=False, task="summarization", prefix=None, **generate_kwargs, ) -> Dict: """Save model.generate results to <out_file>, and return ho...
[ "def", "generate_summaries_or_translations", "(", "examples", ":", "List", "[", "str", "]", ",", "out_file", ":", "str", ",", "model_name", ":", "str", ",", "batch_size", ":", "int", "=", "8", ",", "device", ":", "str", "=", "DEFAULT_DEVICE", ",", "fp16", ...
[ 24, 0 ]
[ 65, 91 ]
python
en
['en', 'en', 'en']
True
run_generate
(verbose=True)
Takes input text, generates output, and then using reference calculates the BLEU scores. The results are saved to a file and returned to the caller, and printed out unless ``verbose=False`` is passed. Args: verbose (:obj:`bool`, `optional`, defaults to :obj:`True`): print results to stdout ...
def run_generate(verbose=True): """ Takes input text, generates output, and then using reference calculates the BLEU scores. The results are saved to a file and returned to the caller, and printed out unless ``verbose=False`` is passed. Args: verbose (:obj:`bool`, `optional`, defaults to :obj...
[ "def", "run_generate", "(", "verbose", "=", "True", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"model_name\"", ",", "type", "=", "str", ",", "help", "=", "\"like facebook/bart-large-cnn,t5-base, et...
[ 72, 0 ]
[ 156, 17 ]
python
en
['en', 'error', 'th']
False
update
(player, force_refresh=False)
Force a update of player and return current state data.
Force a update of player and return current state data.
async def update(player, force_refresh=False): """Force a update of player and return current state data.""" await player.async_update_ha_state(force_refresh=force_refresh) return player.hass.states.get(player.entity_id)
[ "async", "def", "update", "(", "player", ",", "force_refresh", "=", "False", ")", ":", "await", "player", ".", "async_update_ha_state", "(", "force_refresh", "=", "force_refresh", ")", "return", "player", ".", "hass", ".", "states", ".", "get", "(", "player"...
[ 23, 0 ]
[ 26, 51 ]
python
en
['en', 'en', 'en']
True
test_properties
(player, state)
Test standard properties.
Test standard properties.
async def test_properties(player, state): """Test standard properties.""" assert player.unique_id == f"{MOCK_UUID}-1" assert player.device_info == { "name": f"Arcam FMJ ({MOCK_HOST})", "identifiers": {("arcam_fmj", MOCK_UUID), ("arcam_fmj", MOCK_HOST, MOCK_PORT)}, "model": "Arcam FMJ...
[ "async", "def", "test_properties", "(", "player", ",", "state", ")", ":", "assert", "player", ".", "unique_id", "==", "f\"{MOCK_UUID}-1\"", "assert", "player", ".", "device_info", "==", "{", "\"name\"", ":", "f\"Arcam FMJ ({MOCK_HOST})\"", ",", "\"identifiers\"", ...
[ 29, 0 ]
[ 38, 33 ]
python
en
['en', 'lb', 'en']
True
test_powered_off
(hass, player, state)
Test properties in powered off state.
Test properties in powered off state.
async def test_powered_off(hass, player, state): """Test properties in powered off state.""" state.get_source.return_value = None state.get_power.return_value = None data = await update(player) assert "source" not in data.attributes assert data.state == "off"
[ "async", "def", "test_powered_off", "(", "hass", ",", "player", ",", "state", ")", ":", "state", ".", "get_source", ".", "return_value", "=", "None", "state", ".", "get_power", ".", "return_value", "=", "None", "data", "=", "await", "update", "(", "player"...
[ 41, 0 ]
[ 48, 30 ]
python
en
['en', 'en', 'en']
True
test_powered_on
(player, state)
Test properties in powered on state.
Test properties in powered on state.
async def test_powered_on(player, state): """Test properties in powered on state.""" state.get_source.return_value = SourceCodes.PVR state.get_power.return_value = True data = await update(player) assert data.attributes["source"] == "PVR" assert data.state == "on"
[ "async", "def", "test_powered_on", "(", "player", ",", "state", ")", ":", "state", ".", "get_source", ".", "return_value", "=", "SourceCodes", ".", "PVR", "state", ".", "get_power", ".", "return_value", "=", "True", "data", "=", "await", "update", "(", "pl...
[ 51, 0 ]
[ 58, 29 ]
python
en
['en', 'en', 'en']
True
test_supported_features
(player, state)
Test supported features.
Test supported features.
async def test_supported_features(player, state): """Test supported features.""" data = await update(player) assert data.attributes["supported_features"] == 200588
[ "async", "def", "test_supported_features", "(", "player", ",", "state", ")", ":", "data", "=", "await", "update", "(", "player", ")", "assert", "data", ".", "attributes", "[", "\"supported_features\"", "]", "==", "200588" ]
[ 61, 0 ]
[ 64, 58 ]
python
en
['en', 'en', 'en']
True
test_turn_on
(player, state)
Test turn on service.
Test turn on service.
async def test_turn_on(player, state): """Test turn on service.""" state.get_power.return_value = None await player.async_turn_on() state.set_power.assert_not_called() state.get_power.return_value = False await player.async_turn_on() state.set_power.assert_called_with(True)
[ "async", "def", "test_turn_on", "(", "player", ",", "state", ")", ":", "state", ".", "get_power", ".", "return_value", "=", "None", "await", "player", ".", "async_turn_on", "(", ")", "state", ".", "set_power", ".", "assert_not_called", "(", ")", "state", "...
[ 67, 0 ]
[ 75, 44 ]
python
en
['en', 'fi', 'en']
True
test_turn_off
(player, state)
Test command to turn off.
Test command to turn off.
async def test_turn_off(player, state): """Test command to turn off.""" await player.async_turn_off() state.set_power.assert_called_with(False)
[ "async", "def", "test_turn_off", "(", "player", ",", "state", ")", ":", "await", "player", ".", "async_turn_off", "(", ")", "state", ".", "set_power", ".", "assert_called_with", "(", "False", ")" ]
[ 78, 0 ]
[ 81, 45 ]
python
en
['en', 'en', 'en']
True
test_mute_volume
(player, state, mute)
Test mute functionality.
Test mute functionality.
async def test_mute_volume(player, state, mute): """Test mute functionality.""" await player.async_mute_volume(mute) state.set_mute.assert_called_with(mute) player.async_write_ha_state.assert_called_with()
[ "async", "def", "test_mute_volume", "(", "player", ",", "state", ",", "mute", ")", ":", "await", "player", ".", "async_mute_volume", "(", "mute", ")", "state", ".", "set_mute", ".", "assert_called_with", "(", "mute", ")", "player", ".", "async_write_ha_state",...
[ 85, 0 ]
[ 89, 52 ]
python
en
['en', 'en', 'en']
True
test_update
(player, state)
Test update.
Test update.
async def test_update(player, state): """Test update.""" await update(player, force_refresh=True) state.update.assert_called_with()
[ "async", "def", "test_update", "(", "player", ",", "state", ")", ":", "await", "update", "(", "player", ",", "force_refresh", "=", "True", ")", "state", ".", "update", ".", "assert_called_with", "(", ")" ]
[ 97, 0 ]
[ 100, 37 ]
python
en
['en', 'de', 'en']
False
test_2ch
(player, state, fmt, result)
Test selection of 2ch mode.
Test selection of 2ch mode.
async def test_2ch(player, state, fmt, result): """Test selection of 2ch mode.""" state.get_incoming_audio_format.return_value = (fmt, None) assert player._get_2ch() == result
[ "async", "def", "test_2ch", "(", "player", ",", "state", ",", "fmt", ",", "result", ")", ":", "state", ".", "get_incoming_audio_format", ".", "return_value", "=", "(", "fmt", ",", "None", ")", "assert", "player", ".", "_get_2ch", "(", ")", "==", "result"...
[ 112, 0 ]
[ 115, 38 ]
python
en
['en', 'en', 'en']
True
test_select_source
(hass, player_setup, state, source, value)
Test selection of source.
Test selection of source.
async def test_select_source(hass, player_setup, state, source, value): """Test selection of source.""" await hass.services.async_call( "media_player", SERVICE_SELECT_SOURCE, service_data={ATTR_ENTITY_ID: player_setup, ATTR_INPUT_SOURCE: source}, blocking=True, ) if valu...
[ "async", "def", "test_select_source", "(", "hass", ",", "player_setup", ",", "state", ",", "source", ",", "value", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "\"media_player\"", ",", "SERVICE_SELECT_SOURCE", ",", "service_data", "=", "...
[ 122, 0 ]
[ 134, 44 ]
python
en
['en', 'en', 'en']
True
test_source_list
(player, state)
Test source list.
Test source list.
async def test_source_list(player, state): """Test source list.""" state.get_source_list.return_value = [SourceCodes.BD] data = await update(player) assert data.attributes["source_list"] == ["BD"]
[ "async", "def", "test_source_list", "(", "player", ",", "state", ")", ":", "state", ".", "get_source_list", ".", "return_value", "=", "[", "SourceCodes", ".", "BD", "]", "data", "=", "await", "update", "(", "player", ")", "assert", "data", ".", "attributes...
[ 137, 0 ]
[ 141, 51 ]
python
de
['fr', 'de', 'en']
False
test_select_sound_mode
(player, state, mode, mode_sel, mode_2ch, mode_mch)
Test selection sound mode.
Test selection sound mode.
async def test_select_sound_mode(player, state, mode, mode_sel, mode_2ch, mode_mch): """Test selection sound mode.""" player._get_2ch = Mock(return_value=mode_sel) # pylint: disable=W0212 await player.async_select_sound_mode(mode) if mode_2ch: state.set_decode_mode_2ch.assert_called_with(mode_...
[ "async", "def", "test_select_sound_mode", "(", "player", ",", "state", ",", "mode", ",", "mode_sel", ",", "mode_2ch", ",", "mode_mch", ")", ":", "player", ".", "_get_2ch", "=", "Mock", "(", "return_value", "=", "mode_sel", ")", "# pylint: disable=W0212", "awai...
[ 152, 0 ]
[ 165, 53 ]
python
en
['en', 'en', 'en']
True
test_volume_up
(player, state)
Test mute functionality.
Test mute functionality.
async def test_volume_up(player, state): """Test mute functionality.""" await player.async_volume_up() state.inc_volume.assert_called_with() player.async_write_ha_state.assert_called_with()
[ "async", "def", "test_volume_up", "(", "player", ",", "state", ")", ":", "await", "player", ".", "async_volume_up", "(", ")", "state", ".", "inc_volume", ".", "assert_called_with", "(", ")", "player", ".", "async_write_ha_state", ".", "assert_called_with", "(", ...
[ 168, 0 ]
[ 172, 52 ]
python
en
['en', 'en', 'en']
True
test_volume_down
(player, state)
Test mute functionality.
Test mute functionality.
async def test_volume_down(player, state): """Test mute functionality.""" await player.async_volume_down() state.dec_volume.assert_called_with() player.async_write_ha_state.assert_called_with()
[ "async", "def", "test_volume_down", "(", "player", ",", "state", ")", ":", "await", "player", ".", "async_volume_down", "(", ")", "state", ".", "dec_volume", ".", "assert_called_with", "(", ")", "player", ".", "async_write_ha_state", ".", "assert_called_with", "...
[ 175, 0 ]
[ 179, 52 ]
python
en
['en', 'en', 'en']
True
test_sound_mode
(player, state, mode, mode_sel, mode_2ch, mode_mch)
Test selection sound mode.
Test selection sound mode.
async def test_sound_mode(player, state, mode, mode_sel, mode_2ch, mode_mch): """Test selection sound mode.""" player._get_2ch = Mock(return_value=mode_sel) # pylint: disable=W0212 state.get_decode_mode_2ch.return_value = mode_2ch state.get_decode_mode_mch.return_value = mode_mch assert player.sou...
[ "async", "def", "test_sound_mode", "(", "player", ",", "state", ",", "mode", ",", "mode_sel", ",", "mode_2ch", ",", "mode_mch", ")", ":", "player", ".", "_get_2ch", "=", "Mock", "(", "return_value", "=", "mode_sel", ")", "# pylint: disable=W0212", "state", "...
[ 190, 0 ]
[ 196, 36 ]
python
en
['en', 'en', 'en']
True
test_sound_mode_list
(player, state)
Test sound mode list.
Test sound mode list.
async def test_sound_mode_list(player, state): """Test sound mode list.""" player._get_2ch = Mock(return_value=True) # pylint: disable=W0212 assert sorted(player.sound_mode_list) == sorted([x.name for x in DecodeMode2CH]) player._get_2ch = Mock(return_value=False) # pylint: disable=W0212 assert so...
[ "async", "def", "test_sound_mode_list", "(", "player", ",", "state", ")", ":", "player", ".", "_get_2ch", "=", "Mock", "(", "return_value", "=", "True", ")", "# pylint: disable=W0212", "assert", "sorted", "(", "player", ".", "sound_mode_list", ")", "==", "sort...
[ 199, 0 ]
[ 204, 84 ]
python
en
['en', 'de', 'en']
True
test_sound_mode_zone_x
(player, state)
Test second zone sound mode.
Test second zone sound mode.
async def test_sound_mode_zone_x(player, state): """Test second zone sound mode.""" state.zn = 2 assert player.sound_mode is None assert player.sound_mode_list is None
[ "async", "def", "test_sound_mode_zone_x", "(", "player", ",", "state", ")", ":", "state", ".", "zn", "=", "2", "assert", "player", ".", "sound_mode", "is", "None", "assert", "player", ".", "sound_mode_list", "is", "None" ]
[ 207, 0 ]
[ 211, 41 ]
python
en
['en', 'de', 'en']
True
test_is_volume_muted
(player, state)
Test muted.
Test muted.
async def test_is_volume_muted(player, state): """Test muted.""" state.get_mute.return_value = True assert player.is_volume_muted is True # pylint: disable=singleton-comparison state.get_mute.return_value = False assert player.is_volume_muted is False # pylint: disable=singleton-comparison sta...
[ "async", "def", "test_is_volume_muted", "(", "player", ",", "state", ")", ":", "state", ".", "get_mute", ".", "return_value", "=", "True", "assert", "player", ".", "is_volume_muted", "is", "True", "# pylint: disable=singleton-comparison", "state", ".", "get_mute", ...
[ 214, 0 ]
[ 221, 41 ]
python
en
['en', 'en', 'it']
False
test_volume_level
(player, state)
Test volume.
Test volume.
async def test_volume_level(player, state): """Test volume.""" state.get_volume.return_value = 0 assert isclose(player.volume_level, 0.0) state.get_volume.return_value = 50 assert isclose(player.volume_level, 50.0 / 99) state.get_volume.return_value = 99 assert isclose(player.volume_level, 1...
[ "async", "def", "test_volume_level", "(", "player", ",", "state", ")", ":", "state", ".", "get_volume", ".", "return_value", "=", "0", "assert", "isclose", "(", "player", ".", "volume_level", ",", "0.0", ")", "state", ".", "get_volume", ".", "return_value", ...
[ 224, 0 ]
[ 233, 38 ]
python
de
['nl', 'de', 'en']
False
test_set_volume_level
(player, state, volume, call)
Test setting volume.
Test setting volume.
async def test_set_volume_level(player, state, volume, call): """Test setting volume.""" await player.async_set_volume_level(volume) state.set_volume.assert_called_with(call)
[ "async", "def", "test_set_volume_level", "(", "player", ",", "state", ",", "volume", ",", "call", ")", ":", "await", "player", ".", "async_set_volume_level", "(", "volume", ")", "state", ".", "set_volume", ".", "assert_called_with", "(", "call", ")" ]
[ 237, 0 ]
[ 240, 45 ]
python
en
['nl', 'ko', 'en']
False
test_media_content_type
(player, state, source, media_content_type)
Test content type deduction.
Test content type deduction.
async def test_media_content_type(player, state, source, media_content_type): """Test content type deduction.""" state.get_source.return_value = source assert player.media_content_type == media_content_type
[ "async", "def", "test_media_content_type", "(", "player", ",", "state", ",", "source", ",", "media_content_type", ")", ":", "state", ".", "get_source", ".", "return_value", "=", "source", "assert", "player", ".", "media_content_type", "==", "media_content_type" ]
[ 252, 0 ]
[ 255, 58 ]
python
fr
['fr', 'fr', 'en']
True
test_media_channel
(player, state, source, dab, rds, channel)
Test media channel.
Test media channel.
async def test_media_channel(player, state, source, dab, rds, channel): """Test media channel.""" state.get_dab_station.return_value = dab state.get_rds_information.return_value = rds state.get_source.return_value = source assert player.media_channel == channel
[ "async", "def", "test_media_channel", "(", "player", ",", "state", ",", "source", ",", "dab", ",", "rds", ",", "channel", ")", ":", "state", ".", "get_dab_station", ".", "return_value", "=", "dab", "state", ".", "get_rds_information", ".", "return_value", "=...
[ 268, 0 ]
[ 273, 42 ]
python
en
['it', 'en', 'en']
True
test_media_artist
(player, state, source, dls, artist)
Test media artist.
Test media artist.
async def test_media_artist(player, state, source, dls, artist): """Test media artist.""" state.get_dls_pdt.return_value = dls state.get_source.return_value = source assert player.media_artist == artist
[ "async", "def", "test_media_artist", "(", "player", ",", "state", ",", "source", ",", "dls", ",", "artist", ")", ":", "state", ".", "get_dls_pdt", ".", "return_value", "=", "dls", "state", ".", "get_source", ".", "return_value", "=", "source", "assert", "p...
[ 284, 0 ]
[ 288, 40 ]
python
en
['en', 'no', 'en']
True
test_media_title
(player, state, source, channel, title)
Test media title.
Test media title.
async def test_media_title(player, state, source, channel, title): """Test media title.""" from homeassistant.components.arcam_fmj.media_player import ArcamFmj state.get_source.return_value = source with patch.object( ArcamFmj, "media_channel", new_callable=PropertyMock ) as media_channel: ...
[ "async", "def", "test_media_title", "(", "player", ",", "state", ",", "source", ",", "channel", ",", "title", ")", ":", "from", "homeassistant", ".", "components", ".", "arcam_fmj", ".", "media_player", "import", "ArcamFmj", "state", ".", "get_source", ".", ...
[ 299, 0 ]
[ 312, 58 ]
python
en
['en', 'da', 'en']
True
test_added_to_hass
(player, state)
Test addition to hass.
Test addition to hass.
async def test_added_to_hass(player, state): """Test addition to hass.""" from homeassistant.components.arcam_fmj.const import ( SIGNAL_CLIENT_DATA, SIGNAL_CLIENT_STARTED, SIGNAL_CLIENT_STOPPED, ) connectors = {} def _connect(signal, fun): connectors[signal] = fun ...
[ "async", "def", "test_added_to_hass", "(", "player", ",", "state", ")", ":", "from", "homeassistant", ".", "components", ".", "arcam_fmj", ".", "const", "import", "(", "SIGNAL_CLIENT_DATA", ",", "SIGNAL_CLIENT_STARTED", ",", "SIGNAL_CLIENT_STOPPED", ",", ")", "con...
[ 315, 0 ]
[ 341, 5 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the Freebox component.
Set up the Freebox component.
async def async_setup(hass, config): """Set up the Freebox component.""" conf = config.get(DOMAIN) async def discovery_dispatch(service, discovery_info): if conf is None: host = discovery_info.get("properties", {}).get("api_domain") port = discovery_info.get("properties", {}...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "async", "def", "discovery_dispatch", "(", "service", ",", "discovery_info", ")", ":", "if", "conf", "is", "None", ":", "host", ...
[ 27, 0 ]
[ 58, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Set up Freebox component.
Set up Freebox component.
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): """Set up Freebox component.""" router = FreeboxRouter(hass, entry) await router.setup() hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][entry.unique_id] = router for platform in PLATFORMS: hass.async_create_t...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "router", "=", "FreeboxRouter", "(", "hass", ",", "entry", ")", "await", "router", ".", "setup", "(", ")", "hass", ".", "data", ".", "...
[ 61, 0 ]
[ 87, 15 ]
python
en
['en', 'bg', 'en']
True
async_unload_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in PLATFORMS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_un...
[ 90, 0 ]
[ 104, 20 ]
python
en
['en', 'es', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Supla switches.
Set up the Supla switches.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Supla switches.""" if discovery_info is None: return _LOGGER.debug("Discovery: %s", pformat(discovery_info)) entities = [] for device in discovery_info: server_name = device["server...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "_LOGGER", ".", "debug", "(", "\"Discovery: %s\"", ",", "pformat", ...
[ 15, 0 ]
[ 34, 32 ]
python
en
['en', 'en', 'en']
True
SuplaSwitch.async_turn_on
(self, **kwargs)
Turn on the switch.
Turn on the switch.
async def async_turn_on(self, **kwargs): """Turn on the switch.""" await self.async_action("TURN_ON")
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_action", "(", "\"TURN_ON\"", ")" ]
[ 40, 4 ]
[ 42, 42 ]
python
en
['en', 'en', 'en']
True
SuplaSwitch.async_turn_off
(self, **kwargs)
Turn off the switch.
Turn off the switch.
async def async_turn_off(self, **kwargs): """Turn off the switch.""" await self.async_action("TURN_OFF")
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_action", "(", "\"TURN_OFF\"", ")" ]
[ 44, 4 ]
[ 46, 43 ]
python
en
['en', 'en', 'en']
True
SuplaSwitch.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" state = self.channel_data.get("state") if state: return state["on"] return False
[ "def", "is_on", "(", "self", ")", ":", "state", "=", "self", ".", "channel_data", ".", "get", "(", "\"state\"", ")", "if", "state", ":", "return", "state", "[", "\"on\"", "]", "return", "False" ]
[ 49, 4 ]
[ 54, 20 ]
python
en
['en', 'fy', 'en']
True
_has_all_unique_bilds
(value)
Validate that each vacuum configured has a unique bild. Uniqueness is determined case-independently.
Validate that each vacuum configured has a unique bild.
def _has_all_unique_bilds(value): """Validate that each vacuum configured has a unique bild. Uniqueness is determined case-independently. """ bilds = [device[CONF_BLID] for device in value] schema = vol.Schema(vol.Unique()) schema(bilds) return value
[ "def", "_has_all_unique_bilds", "(", "value", ")", ":", "bilds", "=", "[", "device", "[", "CONF_BLID", "]", "for", "device", "in", "value", "]", "schema", "=", "vol", ".", "Schema", "(", "vol", ".", "Unique", "(", ")", ")", "schema", "(", "bilds", ")...
[ 31, 0 ]
[ 39, 16 ]
python
en
['en', 'la', 'en']
True
async_setup
(hass, config)
Set up the roomba environment.
Set up the roomba environment.
async def async_setup(hass, config): """Set up the roomba environment.""" hass.data.setdefault(DOMAIN, {}) if DOMAIN not in config: return True for index, conf in enumerate(config[DOMAIN]): _LOGGER.debug("Importing Roomba #%d - %s", index, conf[CONF_HOST]) hass.async_create_task...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "for", "index", ",", "conf", "in", "enumerat...
[ 63, 0 ]
[ 79, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set the config entry up.
Set the config entry up.
async def async_setup_entry(hass, config_entry): """Set the config entry up.""" # Set up roomba platforms with config entry if not config_entry.options: hass.config_entries.async_update_entry( config_entry, options={ "continuous": config_entry.data[CONF_CONTI...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "# Set up roomba platforms with config entry", "if", "not", "config_entry", ".", "options", ":", "hass", ".", "config_entries", ".", "async_update_entry", "(", "config_entry", ",", "optio...
[ 82, 0 ]
[ 122, 15 ]
python
en
['en', 'en', 'en']
True
async_connect_or_timeout
(hass, roomba)
Connect to vacuum.
Connect to vacuum.
async def async_connect_or_timeout(hass, roomba): """Connect to vacuum.""" try: name = None with async_timeout.timeout(10): _LOGGER.debug("Initialize connection to vacuum") await hass.async_add_executor_job(roomba.connect) while not roomba.roomba_connected or ...
[ "async", "def", "async_connect_or_timeout", "(", "hass", ",", "roomba", ")", ":", "try", ":", "name", "=", "None", "with", "async_timeout", ".", "timeout", "(", "10", ")", ":", "_LOGGER", ".", "debug", "(", "\"Initialize connection to vacuum\"", ")", "await", ...
[ 125, 0 ]
[ 147, 52 ]
python
en
['en', 'en', 'en']
True
async_disconnect_or_timeout
(hass, roomba)
Disconnect to vacuum.
Disconnect to vacuum.
async def async_disconnect_or_timeout(hass, roomba): """Disconnect to vacuum.""" _LOGGER.debug("Disconnect vacuum") with async_timeout.timeout(3): await hass.async_add_executor_job(roomba.disconnect) return True
[ "async", "def", "async_disconnect_or_timeout", "(", "hass", ",", "roomba", ")", ":", "_LOGGER", ".", "debug", "(", "\"Disconnect vacuum\"", ")", "with", "async_timeout", ".", "timeout", "(", "3", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "...
[ 150, 0 ]
[ 155, 15 ]
python
en
['en', 'en', 'en']
True
async_update_options
(hass, config_entry)
Update options.
Update options.
async def async_update_options(hass, config_entry): """Update options.""" await hass.config_entries.async_reload(config_entry.entry_id)
[ "async", "def", "async_update_options", "(", "hass", ",", "config_entry", ")", ":", "await", "hass", ".", "config_entries", ".", "async_reload", "(", "config_entry", ".", "entry_id", ")" ]
[ 158, 0 ]
[ 160, 65 ]
python
en
['en', 'en', 'en']
False
async_unload_entry
(hass, config_entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, config_entry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(config_entry, component) for component in COMPONENTS ] ) ) if un...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "config_entry", ",", "compo...
[ 163, 0 ]
[ 178, 20 ]
python
en
['en', 'es', 'en']
True
roomba_reported_state
(roomba)
Roomba report.
Roomba report.
def roomba_reported_state(roomba): """Roomba report.""" return roomba.master_state.get("state", {}).get("reported", {})
[ "def", "roomba_reported_state", "(", "roomba", ")", ":", "return", "roomba", ".", "master_state", ".", "get", "(", "\"state\"", ",", "{", "}", ")", ".", "get", "(", "\"reported\"", ",", "{", "}", ")" ]
[ 181, 0 ]
[ 183, 67 ]
python
en
['en', 'sr', 'en']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Taps Aff binary sensor.
Set up the Taps Aff binary sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Taps Aff binary sensor.""" name = config.get(CONF_NAME) location = config.get(CONF_LOCATION) taps_aff_data = TapsAffData(location) add_entities([TapsAffSensor(taps_aff_data, name)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "location", "=", "config", ".", "get", "(", "CONF_LOCATION", ")", "taps_aff_da...
[ 27, 0 ]
[ 34, 60 ]
python
en
['en', 'pt', 'en']
True
TapsAffSensor.__init__
(self, taps_aff_data, name)
Initialize the Taps Aff sensor.
Initialize the Taps Aff sensor.
def __init__(self, taps_aff_data, name): """Initialize the Taps Aff sensor.""" self.data = taps_aff_data self._name = name
[ "def", "__init__", "(", "self", ",", "taps_aff_data", ",", "name", ")", ":", "self", ".", "data", "=", "taps_aff_data", "self", ".", "_name", "=", "name" ]
[ 40, 4 ]
[ 43, 25 ]
python
en
['en', 'en', 'en']
True
TapsAffSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"{self._name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._name}\"" ]
[ 46, 4 ]
[ 48, 30 ]
python
en
['en', 'mi', 'en']
True
TapsAffSensor.is_on
(self)
Return true if taps aff.
Return true if taps aff.
def is_on(self): """Return true if taps aff.""" return self.data.is_taps_aff
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "data", ".", "is_taps_aff" ]
[ 51, 4 ]
[ 53, 36 ]
python
en
['en', 'mt', 'en']
True
TapsAffSensor.update
(self)
Get the latest data.
Get the latest data.
def update(self): """Get the latest data.""" self.data.update()
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")" ]
[ 55, 4 ]
[ 57, 26 ]
python
en
['en', 'en', 'en']
True
TapsAffData.__init__
(self, location)
Initialize the data object.
Initialize the data object.
def __init__(self, location): """Initialize the data object.""" self._is_taps_aff = None self.taps_aff = TapsAff(location)
[ "def", "__init__", "(", "self", ",", "location", ")", ":", "self", ".", "_is_taps_aff", "=", "None", "self", ".", "taps_aff", "=", "TapsAff", "(", "location", ")" ]
[ 63, 4 ]
[ 67, 41 ]
python
en
['en', 'en', 'en']
True
TapsAffData.is_taps_aff
(self)
Return true if taps aff.
Return true if taps aff.
def is_taps_aff(self): """Return true if taps aff.""" return self._is_taps_aff
[ "def", "is_taps_aff", "(", "self", ")", ":", "return", "self", ".", "_is_taps_aff" ]
[ 70, 4 ]
[ 72, 32 ]
python
en
['en', 'mt', 'en']
True
TapsAffData.update
(self)
Get the latest data from the Taps Aff API and updates the states.
Get the latest data from the Taps Aff API and updates the states.
def update(self): """Get the latest data from the Taps Aff API and updates the states.""" try: self._is_taps_aff = self.taps_aff.is_taps_aff except RuntimeError: _LOGGER.error("Update failed. Check configured location")
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_is_taps_aff", "=", "self", ".", "taps_aff", ".", "is_taps_aff", "except", "RuntimeError", ":", "_LOGGER", ".", "error", "(", "\"Update failed. Check configured location\"", ")" ]
[ 74, 4 ]
[ 79, 69 ]
python
en
['en', 'en', 'en']
True
_validate_dsmr_connection
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect.
Validate the user input allows us to connect.
async def _validate_dsmr_connection(hass: core.HomeAssistant, data): """Validate the user input allows us to connect.""" conn = DSMRConnection(data.get(CONF_HOST), data[CONF_PORT], data[CONF_DSMR_VERSION]) if not await conn.validate_connect(hass): raise CannotConnect equipment_identifier = con...
[ "async", "def", "_validate_dsmr_connection", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "conn", "=", "DSMRConnection", "(", "data", ".", "get", "(", "CONF_HOST", ")", ",", "data", "[", "CONF_PORT", "]", ",", "data", "[", "CONF...
[ 93, 0 ]
[ 112, 15 ]
python
en
['en', 'en', 'en']
True
DSMRConnection.__init__
(self, host, port, dsmr_version)
Initialize.
Initialize.
def __init__(self, host, port, dsmr_version): """Initialize.""" self._host = host self._port = port self._dsmr_version = dsmr_version self._telegram = {}
[ "def", "__init__", "(", "self", ",", "host", ",", "port", ",", "dsmr_version", ")", ":", "self", ".", "_host", "=", "host", "self", ".", "_port", "=", "port", "self", ".", "_dsmr_version", "=", "dsmr_version", "self", ".", "_telegram", "=", "{", "}" ]
[ 31, 4 ]
[ 36, 27 ]
python
en
['en', 'en', 'it']
False
DSMRConnection.equipment_identifier
(self)
Equipment identifier.
Equipment identifier.
def equipment_identifier(self): """Equipment identifier.""" if obis_ref.EQUIPMENT_IDENTIFIER in self._telegram: dsmr_object = self._telegram[obis_ref.EQUIPMENT_IDENTIFIER] return getattr(dsmr_object, "value", None)
[ "def", "equipment_identifier", "(", "self", ")", ":", "if", "obis_ref", ".", "EQUIPMENT_IDENTIFIER", "in", "self", ".", "_telegram", ":", "dsmr_object", "=", "self", ".", "_telegram", "[", "obis_ref", ".", "EQUIPMENT_IDENTIFIER", "]", "return", "getattr", "(", ...
[ 38, 4 ]
[ 42, 54 ]
python
en
['en', 'nl', 'en']
False
DSMRConnection.equipment_identifier_gas
(self)
Equipment identifier gas.
Equipment identifier gas.
def equipment_identifier_gas(self): """Equipment identifier gas.""" if obis_ref.EQUIPMENT_IDENTIFIER_GAS in self._telegram: dsmr_object = self._telegram[obis_ref.EQUIPMENT_IDENTIFIER_GAS] return getattr(dsmr_object, "value", None)
[ "def", "equipment_identifier_gas", "(", "self", ")", ":", "if", "obis_ref", ".", "EQUIPMENT_IDENTIFIER_GAS", "in", "self", ".", "_telegram", ":", "dsmr_object", "=", "self", ".", "_telegram", "[", "obis_ref", ".", "EQUIPMENT_IDENTIFIER_GAS", "]", "return", "getatt...
[ 44, 4 ]
[ 48, 54 ]
python
de
['de', 'de', 'en']
True
DSMRConnection.validate_connect
(self, hass: core.HomeAssistant)
Test if we can validate connection with the device.
Test if we can validate connection with the device.
async def validate_connect(self, hass: core.HomeAssistant) -> bool: """Test if we can validate connection with the device.""" def update_telegram(telegram): if obis_ref.EQUIPMENT_IDENTIFIER in telegram: self._telegram = telegram transport.close() if ...
[ "async", "def", "validate_connect", "(", "self", ",", "hass", ":", "core", ".", "HomeAssistant", ")", "->", "bool", ":", "def", "update_telegram", "(", "telegram", ")", ":", "if", "obis_ref", ".", "EQUIPMENT_IDENTIFIER", "in", "telegram", ":", "self", ".", ...
[ 50, 4 ]
[ 90, 19 ]
python
en
['en', 'en', 'en']
True
DSMRFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return DSMROptionFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "DSMROptionFlowHandler", "(", "config_entry", ")" ]
[ 123, 4 ]
[ 125, 50 ]
python
en
['en', 'en', 'en']
True
DSMRFlowHandler._abort_if_host_port_configured
( self, port: str, host: str = None, updates: Optional[Dict[Any, Any]] = None, reload_on_update: bool = True, )
Test if host and port are already configured.
Test if host and port are already configured.
def _abort_if_host_port_configured( self, port: str, host: str = None, updates: Optional[Dict[Any, Any]] = None, reload_on_update: bool = True, ): """Test if host and port are already configured.""" for entry in self._async_current_entries(): if en...
[ "def", "_abort_if_host_port_configured", "(", "self", ",", "port", ":", "str", ",", "host", ":", "str", "=", "None", ",", "updates", ":", "Optional", "[", "Dict", "[", "Any", ",", "Any", "]", "]", "=", "None", ",", "reload_on_update", ":", "bool", "=",...
[ 127, 4 ]
[ 155, 19 ]
python
en
['en', 'en', 'en']
True
DSMRFlowHandler.async_step_import
(self, import_config=None)
Handle the initial step.
Handle the initial step.
async def async_step_import(self, import_config=None): """Handle the initial step.""" host = import_config.get(CONF_HOST) port = import_config[CONF_PORT] status = self._abort_if_host_port_configured(port, host, import_config) if status is not None: return status ...
[ "async", "def", "async_step_import", "(", "self", ",", "import_config", "=", "None", ")", ":", "host", "=", "import_config", ".", "get", "(", "CONF_HOST", ")", "port", "=", "import_config", "[", "CONF_PORT", "]", "status", "=", "self", ".", "_abort_if_host_p...
[ 157, 4 ]
[ 183, 61 ]
python
en
['en', 'en', 'en']
True
DSMROptionFlowHandler.__init__
(self, config_entry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry): """Initialize options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 189, 4 ]
[ 191, 40 ]
python
en
['en', 'en', 'en']
True
DSMROptionFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) return self.async_show_form( step_id="init", data_schema=vol.Schema( { ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "return", ...
[ 193, 4 ]
[ 210, 9 ]
python
en
['en', 'en', 'en']
True
test_coil_true
(hass, mock_hub, cfg, regs, expected)
Run test for given config.
Run test for given config.
async def test_coil_true(hass, mock_hub, cfg, regs, expected): """Run test for given config.""" sensor_name = "modbus_test_binary_sensor" scan_interval = 5 entity_id, now, device = await setup_base_test( sensor_name, hass, mock_hub, {CONF_INPUTS: [dict(**{CONF_NAME: senso...
[ "async", "def", "test_coil_true", "(", "hass", ",", "mock_hub", ",", "cfg", ",", "regs", ",", "expected", ")", ":", "sensor_name", "=", "\"modbus_test_binary_sensor\"", "scan_interval", "=", "5", "entity_id", ",", "now", ",", "device", "=", "await", "setup_bas...
[ 72, 0 ]
[ 92, 5 ]
python
en
['en', 'en', 'en']
True
conversion
(source, dest)
:param source: the unit of measure you have :param dest: the unit of measure need to convert to :return:
:param source: the unit of measure you have :param dest: the unit of measure need to convert to :return:
def conversion(source, dest): """ :param source: the unit of measure you have :param dest: the unit of measure need to convert to :return: """ stemmer = SnowballStemmer('english') source = stemmer.stem(source) dest = stemmer.stem(dest) try: units = conv_dict.get(source).get('...
[ "def", "conversion", "(", "source", ",", "dest", ")", ":", "stemmer", "=", "SnowballStemmer", "(", "'english'", ")", "source", "=", "stemmer", ".", "stem", "(", "source", ")", "dest", "=", "stemmer", ".", "stem", "(", "dest", ")", "try", ":", "units", ...
[ 8, 0 ]
[ 25, 30 ]
python
en
['en', 'error', 'th']
False
GenericHueDevice.__init__
(self, sensor, name, bridge, primary_sensor=None)
Initialize the sensor.
Initialize the sensor.
def __init__(self, sensor, name, bridge, primary_sensor=None): """Initialize the sensor.""" self.sensor = sensor self._name = name self._primary_sensor = primary_sensor self.bridge = bridge
[ "def", "__init__", "(", "self", ",", "sensor", ",", "name", ",", "bridge", ",", "primary_sensor", "=", "None", ")", ":", "self", ".", "sensor", "=", "sensor", "self", ".", "_name", "=", "name", "self", ".", "_primary_sensor", "=", "primary_sensor", "self...
[ 7, 4 ]
[ 12, 28 ]
python
en
['en', 'en', 'en']
True
GenericHueDevice.primary_sensor
(self)
Return the primary sensor entity of the physical device.
Return the primary sensor entity of the physical device.
def primary_sensor(self): """Return the primary sensor entity of the physical device.""" return self._primary_sensor or self.sensor
[ "def", "primary_sensor", "(", "self", ")", ":", "return", "self", ".", "_primary_sensor", "or", "self", ".", "sensor" ]
[ 15, 4 ]
[ 17, 50 ]
python
en
['en', 'en', 'en']
True
GenericHueDevice.device_id
(self)
Return the ID of the physical device this sensor is part of.
Return the ID of the physical device this sensor is part of.
def device_id(self): """Return the ID of the physical device this sensor is part of.""" return self.unique_id[:23]
[ "def", "device_id", "(", "self", ")", ":", "return", "self", ".", "unique_id", "[", ":", "23", "]" ]
[ 20, 4 ]
[ 22, 34 ]
python
en
['en', 'en', 'en']
True
GenericHueDevice.unique_id
(self)
Return the ID of this Hue sensor.
Return the ID of this Hue sensor.
def unique_id(self): """Return the ID of this Hue sensor.""" return self.sensor.uniqueid
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "sensor", ".", "uniqueid" ]
[ 25, 4 ]
[ 27, 35 ]
python
en
['en', 'mi', 'en']
True
GenericHueDevice.name
(self)
Return a friendly name for the sensor.
Return a friendly name for the sensor.
def name(self): """Return a friendly name for the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 30, 4 ]
[ 32, 25 ]
python
en
['en', 'pt', 'en']
True
GenericHueDevice.swupdatestate
(self)
Return detail of available software updates for this device.
Return detail of available software updates for this device.
def swupdatestate(self): """Return detail of available software updates for this device.""" return self.primary_sensor.raw.get("swupdate", {}).get("state")
[ "def", "swupdatestate", "(", "self", ")", ":", "return", "self", ".", "primary_sensor", ".", "raw", ".", "get", "(", "\"swupdate\"", ",", "{", "}", ")", ".", "get", "(", "\"state\"", ")" ]
[ 35, 4 ]
[ 37, 71 ]
python
en
['en', 'en', 'en']
True
GenericHueDevice.device_info
(self)
Return the device info. Links individual entities together in the hass device registry.
Return the device info.
def device_info(self): """Return the device info. Links individual entities together in the hass device registry. """ return { "identifiers": {(HUE_DOMAIN, self.device_id)}, "name": self.primary_sensor.name, "manufacturer": self.primary_sensor.manufac...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "HUE_DOMAIN", ",", "self", ".", "device_id", ")", "}", ",", "\"name\"", ":", "self", ".", "primary_sensor", ".", "name", ",", "\"manufacturer\"", ":", "self", "...
[ 40, 4 ]
[ 52, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up Velbus switch based on config_entry.
Set up Velbus switch based on config_entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up Velbus switch based on config_entry.""" cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"] modules_data = hass.data[DOMAIN][entry.entry_id]["switch"] entities = [] for address, channel in modules_data: module = cntrl.get...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "cntrl", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "\"cntrl\"", "]", "modules_data", "=", "hass", ".", "data...
[ 13, 0 ]
[ 21, 32 ]
python
en
['en', 'zu', 'en']
True
VelbusSwitch.is_on
(self)
Return true if the switch is on.
Return true if the switch is on.
def is_on(self): """Return true if the switch is on.""" return self._module.is_on(self._channel)
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_module", ".", "is_on", "(", "self", ".", "_channel", ")" ]
[ 28, 4 ]
[ 30, 48 ]
python
en
['en', 'en', 'en']
True
VelbusSwitch.turn_on
(self, **kwargs)
Instruct the switch to turn on.
Instruct the switch to turn on.
def turn_on(self, **kwargs): """Instruct the switch to turn on.""" try: self._module.turn_on(self._channel) except VelbusException as err: _LOGGER.error("A Velbus error occurred: %s", err)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_module", ".", "turn_on", "(", "self", ".", "_channel", ")", "except", "VelbusException", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"A Velbus error occurr...
[ 32, 4 ]
[ 37, 61 ]
python
en
['en', 'en', 'en']
True
VelbusSwitch.turn_off
(self, **kwargs)
Instruct the switch to turn off.
Instruct the switch to turn off.
def turn_off(self, **kwargs): """Instruct the switch to turn off.""" try: self._module.turn_off(self._channel) except VelbusException as err: _LOGGER.error("A Velbus error occurred: %s", err)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_module", ".", "turn_off", "(", "self", ".", "_channel", ")", "except", "VelbusException", "as", "err", ":", "_LOGGER", ".", "error", "(", "\"A Velbus error occu...
[ 39, 4 ]
[ 44, 61 ]
python
en
['en', 'en', 'en']
True
Preprocessor.__call__
(self, recording, **kwargs)
Preprocess a particular recording. This is allowed to modify aspects of the recording in-place, but is not strictly advised. Parameters ---------- recording : kwargs : dict New :any:`_Recording` subclasses may need to provide additional arguments. This ...
Preprocess a particular recording. This is allowed to modify aspects of the recording in-place, but is not strictly advised.
def __call__(self, recording, **kwargs): """ Preprocess a particular recording. This is allowed to modify aspects of the recording in-place, but is not strictly advised. Parameters ---------- recording : kwargs : dict New :any:`_Recording` subcla...
[ "def", "__call__", "(", "self", ",", "recording", ",", "*", "*", "kwargs", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 11, 4 ]
[ 23, 35 ]
python
en
['en', 'error', 'th']
False
Preprocessor.get_transform
(self)
Generate and return any transform associated with this preprocessor. Should be used after applying this to a dataset, i.e. through :meth:`DN3ataset.preprocess` Returns ------- transform : BaseTransform
Generate and return any transform associated with this preprocessor. Should be used after applying this to a dataset, i.e. through :meth:`DN3ataset.preprocess`
def get_transform(self): """ Generate and return any transform associated with this preprocessor. Should be used after applying this to a dataset, i.e. through :meth:`DN3ataset.preprocess` Returns ------- transform : BaseTransform """ raise NotImplemented...
[ "def", "get_transform", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 25, 4 ]
[ 34, 35 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the demo image processing platform.
Set up the demo image processing platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the demo image processing platform.""" add_entities( [ DemoImageProcessingAlpr("camera.demo_camera", "Demo Alpr"), DemoImageProcessingFace("camera.demo_camera", "Demo Face"), ] )
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "add_entities", "(", "[", "DemoImageProcessingAlpr", "(", "\"camera.demo_camera\"", ",", "\"Demo Alpr\"", ")", ",", "DemoImageProcessingFace", "("...
[ 13, 0 ]
[ 20, 5 ]
python
en
['en', 'da', 'en']
True
DemoImageProcessingAlpr.__init__
(self, camera_entity, name)
Initialize demo ALPR image processing entity.
Initialize demo ALPR image processing entity.
def __init__(self, camera_entity, name): """Initialize demo ALPR image processing entity.""" super().__init__() self._name = name self._camera = camera_entity
[ "def", "__init__", "(", "self", ",", "camera_entity", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "name", "self", ".", "_camera", "=", "camera_entity" ]
[ 26, 4 ]
[ 31, 36 ]
python
en
['es', 'en', 'en']
True
DemoImageProcessingAlpr.camera_entity
(self)
Return camera entity id from process pictures.
Return camera entity id from process pictures.
def camera_entity(self): """Return camera entity id from process pictures.""" return self._camera
[ "def", "camera_entity", "(", "self", ")", ":", "return", "self", ".", "_camera" ]
[ 34, 4 ]
[ 36, 27 ]
python
en
['en', 'en', 'en']
True