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
NX584Alarm.alarm_unbypass
(self, zone)
Send bypass command.
Send bypass command.
def alarm_unbypass(self, zone): """Send bypass command.""" self._alarm.set_bypass(zone, False)
[ "def", "alarm_unbypass", "(", "self", ",", "zone", ")", ":", "self", ".", "_alarm", ".", "set_bypass", "(", "zone", ",", "False", ")" ]
[ 166, 4 ]
[ 168, 43 ]
python
en
['en', 'lb', 'en']
True
async_setup
(hass, config)
Set up for Envisalink devices.
Set up for Envisalink devices.
async def async_setup(hass, config): """Set up for Envisalink devices.""" conf = config.get(DOMAIN) host = conf.get(CONF_HOST) port = conf.get(CONF_EVL_PORT) code = conf.get(CONF_CODE) panel_type = conf.get(CONF_PANEL_TYPE) panic_type = conf.get(CONF_PANIC) version = conf.get(CONF_EVL_...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "host", "=", "conf", ".", "get", "(", "CONF_HOST", ")", "port", "=", "conf", ".", "get", "(", "CONF_EVL_PORT", ")", "code", ...
[ 99, 0 ]
[ 234, 15 ]
python
en
['en', 'en', 'en']
True
EnvisalinkDevice.__init__
(self, name, info, controller)
Initialize the device.
Initialize the device.
def __init__(self, name, info, controller): """Initialize the device.""" self._controller = controller self._info = info self._name = name
[ "def", "__init__", "(", "self", ",", "name", ",", "info", ",", "controller", ")", ":", "self", ".", "_controller", "=", "controller", "self", ".", "_info", "=", "info", "self", ".", "_name", "=", "name" ]
[ 240, 4 ]
[ 244, 25 ]
python
en
['en', 'en', 'en']
True
EnvisalinkDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 247, 4 ]
[ 249, 25 ]
python
en
['en', 'en', 'en']
True
EnvisalinkDevice.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 252, 4 ]
[ 254, 20 ]
python
en
['en', 'en', 'en']
True
async_get_media_source
(hass: HomeAssistant)
Set up Netatmo media source.
Set up Netatmo media source.
async def async_get_media_source(hass: HomeAssistant): """Set up Netatmo media source.""" return NetatmoSource(hass)
[ "async", "def", "async_get_media_source", "(", "hass", ":", "HomeAssistant", ")", ":", "return", "NetatmoSource", "(", "hass", ")" ]
[ 32, 0 ]
[ 34, 30 ]
python
en
['en', 'bg', 'en']
True
remove_html_tags
(text)
Remove html tags from string.
Remove html tags from string.
def remove_html_tags(text): """Remove html tags from string.""" clean = re.compile("<.*?>") return re.sub(clean, "", text)
[ "def", "remove_html_tags", "(", "text", ")", ":", "clean", "=", "re", ".", "compile", "(", "\"<.*?>\"", ")", "return", "re", ".", "sub", "(", "clean", ",", "\"\"", ",", "text", ")" ]
[ 149, 0 ]
[ 152, 34 ]
python
en
['en', 'en', 'en']
True
async_parse_identifier
( item: MediaSourceItem, )
Parse identifier.
Parse identifier.
def async_parse_identifier( item: MediaSourceItem, ) -> Tuple[str, str, Optional[int]]: """Parse identifier.""" if not item.identifier: return "events", "", None source, path = item.identifier.lstrip("/").split("/", 1) if source != "events": raise Unresolvable("Unknown source direc...
[ "def", "async_parse_identifier", "(", "item", ":", "MediaSourceItem", ",", ")", "->", "Tuple", "[", "str", ",", "str", ",", "Optional", "[", "int", "]", "]", ":", "if", "not", "item", ".", "identifier", ":", "return", "\"events\"", ",", "\"\"", ",", "N...
[ 156, 0 ]
[ 172, 29 ]
python
de
['en', 'de', 'hi']
False
NetatmoSource.__init__
(self, hass: HomeAssistant)
Initialize Netatmo source.
Initialize Netatmo source.
def __init__(self, hass: HomeAssistant): """Initialize Netatmo source.""" super().__init__(DOMAIN) self.hass = hass self.events = self.hass.data[DOMAIN][DATA_EVENTS]
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ")", ":", "super", "(", ")", ".", "__init__", "(", "DOMAIN", ")", "self", ".", "hass", "=", "hass", "self", ".", "events", "=", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]",...
[ 42, 4 ]
[ 46, 57 ]
python
it
['lt', 'pl', 'it']
False
NetatmoSource.async_resolve_media
(self, item: MediaSourceItem)
Resolve media to a url.
Resolve media to a url.
async def async_resolve_media(self, item: MediaSourceItem) -> PlayMedia: """Resolve media to a url.""" _, camera_id, event_id = async_parse_identifier(item) url = self.events[camera_id][event_id]["media_url"] return PlayMedia(url, MIME_TYPE)
[ "async", "def", "async_resolve_media", "(", "self", ",", "item", ":", "MediaSourceItem", ")", "->", "PlayMedia", ":", "_", ",", "camera_id", ",", "event_id", "=", "async_parse_identifier", "(", "item", ")", "url", "=", "self", ".", "events", "[", "camera_id"...
[ 48, 4 ]
[ 52, 40 ]
python
en
['en', 'en', 'en']
True
NetatmoSource.async_browse_media
( self, item: MediaSourceItem, media_types: Tuple[str] = MEDIA_MIME_TYPES )
Return media.
Return media.
async def async_browse_media( self, item: MediaSourceItem, media_types: Tuple[str] = MEDIA_MIME_TYPES ) -> BrowseMediaSource: """Return media.""" try: source, camera_id, event_id = async_parse_identifier(item) except Unresolvable as err: raise BrowseError(str(...
[ "async", "def", "async_browse_media", "(", "self", ",", "item", ":", "MediaSourceItem", ",", "media_types", ":", "Tuple", "[", "str", "]", "=", "MEDIA_MIME_TYPES", ")", "->", "BrowseMediaSource", ":", "try", ":", "source", ",", "camera_id", ",", "event_id", ...
[ 54, 4 ]
[ 63, 62 ]
python
en
['en', 'no', 'en']
False
NetatmoSource._browse_media
( self, source: str, camera_id: str, event_id: int )
Browse media.
Browse media.
def _browse_media( self, source: str, camera_id: str, event_id: int ) -> BrowseMediaSource: """Browse media.""" if camera_id and camera_id not in self.events: raise BrowseError("Camera does not exist.") if event_id and event_id not in self.events[camera_id]: ...
[ "def", "_browse_media", "(", "self", ",", "source", ":", "str", ",", "camera_id", ":", "str", ",", "event_id", ":", "int", ")", "->", "BrowseMediaSource", ":", "if", "camera_id", "and", "camera_id", "not", "in", "self", ".", "events", ":", "raise", "Brow...
[ 65, 4 ]
[ 75, 69 ]
python
en
['en', 'en', 'en']
False
_async_start_streaming
(hass, acc)
Start streaming a camera.
Start streaming a camera.
async def _async_start_streaming(hass, acc): """Start streaming a camera.""" acc.set_selected_stream_configuration(MOCK_START_STREAM_TLV) await acc.run_handler() await hass.async_block_till_done()
[ "async", "def", "_async_start_streaming", "(", "hass", ",", "acc", ")", ":", "acc", ".", "set_selected_stream_configuration", "(", "MOCK_START_STREAM_TLV", ")", "await", "acc", ".", "run_handler", "(", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 45, 0 ]
[ 49, 38 ]
python
en
['en', 'en', 'en']
True
_async_setup_endpoints
(hass, acc)
Set camera endpoints.
Set camera endpoints.
async def _async_setup_endpoints(hass, acc): """Set camera endpoints.""" acc.set_endpoints(MOCK_END_POINTS_TLV) await acc.run_handler() await hass.async_block_till_done()
[ "async", "def", "_async_setup_endpoints", "(", "hass", ",", "acc", ")", ":", "acc", ".", "set_endpoints", "(", "MOCK_END_POINTS_TLV", ")", "await", "acc", ".", "run_handler", "(", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 52, 0 ]
[ 56, 38 ]
python
da
['es', 'da', 'en']
False
_async_reconfigure_stream
(hass, acc, session_info, stream_config)
Reconfigure the stream.
Reconfigure the stream.
async def _async_reconfigure_stream(hass, acc, session_info, stream_config): """Reconfigure the stream.""" await acc.reconfigure_stream(session_info, stream_config) await acc.run_handler() await hass.async_block_till_done()
[ "async", "def", "_async_reconfigure_stream", "(", "hass", ",", "acc", ",", "session_info", ",", "stream_config", ")", ":", "await", "acc", ".", "reconfigure_stream", "(", "session_info", ",", "stream_config", ")", "await", "acc", ".", "run_handler", "(", ")", ...
[ 59, 0 ]
[ 63, 38 ]
python
en
['en', 'sr', 'en']
True
_async_stop_all_streams
(hass, acc)
Stop all camera streams.
Stop all camera streams.
async def _async_stop_all_streams(hass, acc): """Stop all camera streams.""" await acc.stop() await acc.run_handler() await hass.async_block_till_done()
[ "async", "def", "_async_stop_all_streams", "(", "hass", ",", "acc", ")", ":", "await", "acc", ".", "stop", "(", ")", "await", "acc", ".", "run_handler", "(", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 66, 0 ]
[ 70, 38 ]
python
en
['en', 'es', 'en']
True
_async_stop_stream
(hass, acc, session_info)
Stop a camera stream.
Stop a camera stream.
async def _async_stop_stream(hass, acc, session_info): """Stop a camera stream.""" await acc.stop_stream(session_info) await acc.run_handler() await hass.async_block_till_done()
[ "async", "def", "_async_stop_stream", "(", "hass", ",", "acc", ",", "session_info", ")", ":", "await", "acc", ".", "stop_stream", "(", "session_info", ")", "await", "acc", ".", "run_handler", "(", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ...
[ 73, 0 ]
[ 77, 38 ]
python
en
['es', 'pt', 'en']
False
run_driver
(hass)
Return a custom AccessoryDriver instance for HomeKit accessory init.
Return a custom AccessoryDriver instance for HomeKit accessory init.
def run_driver(hass): """Return a custom AccessoryDriver instance for HomeKit accessory init.""" with patch("pyhap.accessory_driver.Zeroconf"), patch( "pyhap.accessory_driver.AccessoryEncoder" ), patch("pyhap.accessory_driver.HAPServer"), patch( "pyhap.accessory_driver.AccessoryDriver.publis...
[ "def", "run_driver", "(", "hass", ")", ":", "with", "patch", "(", "\"pyhap.accessory_driver.Zeroconf\"", ")", ",", "patch", "(", "\"pyhap.accessory_driver.AccessoryEncoder\"", ")", ",", "patch", "(", "\"pyhap.accessory_driver.HAPServer\"", ")", ",", "patch", "(", "\"p...
[ 81, 0 ]
[ 92, 9 ]
python
en
['en', 'en', 'en']
True
_get_exits_after_startup_mock_ffmpeg
()
Return a ffmpeg that will have an invalid pid.
Return a ffmpeg that will have an invalid pid.
def _get_exits_after_startup_mock_ffmpeg(): """Return a ffmpeg that will have an invalid pid.""" ffmpeg = MagicMock() type(ffmpeg.process).pid = PropertyMock(return_value=PID_THAT_WILL_NEVER_BE_ALIVE) ffmpeg.open = AsyncMock(return_value=True) ffmpeg.close = AsyncMock(return_value=True) ffmpeg.k...
[ "def", "_get_exits_after_startup_mock_ffmpeg", "(", ")", ":", "ffmpeg", "=", "MagicMock", "(", ")", "type", "(", "ffmpeg", ".", "process", ")", ".", "pid", "=", "PropertyMock", "(", "return_value", "=", "PID_THAT_WILL_NEVER_BE_ALIVE", ")", "ffmpeg", ".", "open",...
[ 95, 0 ]
[ 102, 17 ]
python
en
['en', 'en', 'en']
True
_get_working_mock_ffmpeg
()
Return a working ffmpeg.
Return a working ffmpeg.
def _get_working_mock_ffmpeg(): """Return a working ffmpeg.""" ffmpeg = MagicMock() ffmpeg.open = AsyncMock(return_value=True) ffmpeg.close = AsyncMock(return_value=True) ffmpeg.kill = AsyncMock(return_value=True) return ffmpeg
[ "def", "_get_working_mock_ffmpeg", "(", ")", ":", "ffmpeg", "=", "MagicMock", "(", ")", "ffmpeg", ".", "open", "=", "AsyncMock", "(", "return_value", "=", "True", ")", "ffmpeg", ".", "close", "=", "AsyncMock", "(", "return_value", "=", "True", ")", "ffmpeg...
[ 105, 0 ]
[ 111, 17 ]
python
en
['en', 'cy', 'en']
True
_get_failing_mock_ffmpeg
()
Return an ffmpeg that fails to shutdown.
Return an ffmpeg that fails to shutdown.
def _get_failing_mock_ffmpeg(): """Return an ffmpeg that fails to shutdown.""" ffmpeg = MagicMock() type(ffmpeg.process).pid = PropertyMock(return_value=PID_THAT_WILL_NEVER_BE_ALIVE) ffmpeg.open = AsyncMock(return_value=False) ffmpeg.close = AsyncMock(side_effect=OSError) ffmpeg.kill = AsyncMock...
[ "def", "_get_failing_mock_ffmpeg", "(", ")", ":", "ffmpeg", "=", "MagicMock", "(", ")", "type", "(", "ffmpeg", ".", "process", ")", ".", "pid", "=", "PropertyMock", "(", "return_value", "=", "PID_THAT_WILL_NEVER_BE_ALIVE", ")", "ffmpeg", ".", "open", "=", "A...
[ 114, 0 ]
[ 121, 17 ]
python
en
['en', 'gd', 'en']
True
test_camera_stream_source_configured
(hass, run_driver, events)
Test a camera that can stream with a configured source.
Test a camera that can stream with a configured source.
async def test_camera_stream_source_configured(hass, run_driver, events): """Test a camera that can stream with a configured source.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}} ) ...
[ "async", "def", "test_camera_stream_source_configured", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")", "await",...
[ 124, 0 ]
[ 231, 9 ]
python
en
['en', 'en', 'en']
True
test_camera_stream_source_configured_with_failing_ffmpeg
( hass, run_driver, events )
Test a camera that can stream with a configured source with ffmpeg failing.
Test a camera that can stream with a configured source with ffmpeg failing.
async def test_camera_stream_source_configured_with_failing_ffmpeg( hass, run_driver, events ): """Test a camera that can stream with a configured source with ffmpeg failing.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN...
[ "async", "def", "test_camera_stream_source_configured_with_failing_ffmpeg", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}...
[ 234, 0 ]
[ 285, 48 ]
python
en
['en', 'en', 'en']
True
test_camera_stream_source_found
(hass, run_driver, events)
Test a camera that can stream and we get the source from the entity.
Test a camera that can stream and we get the source from the entity.
async def test_camera_stream_source_found(hass, run_driver, events): """Test a camera that can stream and we get the source from the entity.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}...
[ "async", "def", "test_camera_stream_source_found", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")", "await", "a...
[ 288, 0 ]
[ 335, 48 ]
python
en
['en', 'en', 'en']
True
test_camera_stream_source_fails
(hass, run_driver, events)
Test a camera that can stream and we cannot get the source from the entity.
Test a camera that can stream and we cannot get the source from the entity.
async def test_camera_stream_source_fails(hass, run_driver, events): """Test a camera that can stream and we cannot get the source from the entity.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": ...
[ "async", "def", "test_camera_stream_source_fails", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")", "await", "a...
[ 338, 0 ]
[ 373, 48 ]
python
en
['en', 'en', 'en']
True
test_camera_with_no_stream
(hass, run_driver, events)
Test a camera that cannot stream.
Test a camera that cannot stream.
async def test_camera_with_no_stream(hass, run_driver, events): """Test a camera that cannot stream.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component(hass, camera.DOMAIN, {camera.DOMAIN: {}}) entity_id = "camera.demo_camera" hass.states.async_set...
[ "async", "def", "test_camera_with_no_stream", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")", "await", "async_...
[ 376, 0 ]
[ 405, 9 ]
python
en
['en', 'en', 'en']
True
test_camera_stream_source_configured_and_copy_codec
(hass, run_driver, events)
Test a camera that can stream with a configured source.
Test a camera that can stream with a configured source.
async def test_camera_stream_source_configured_and_copy_codec(hass, run_driver, events): """Test a camera that can stream with a configured source.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": ...
[ "async", "def", "test_camera_stream_source_configured_and_copy_codec", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ...
[ 408, 0 ]
[ 474, 5 ]
python
en
['en', 'en', 'en']
True
test_camera_streaming_fails_after_starting_ffmpeg
(hass, run_driver, events)
Test a camera that can stream with a configured source.
Test a camera that can stream with a configured source.
async def test_camera_streaming_fails_after_starting_ffmpeg(hass, run_driver, events): """Test a camera that can stream with a configured source.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "d...
[ "async", "def", "test_camera_streaming_fails_after_starting_ffmpeg", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")...
[ 477, 0 ]
[ 544, 5 ]
python
en
['en', 'en', 'en']
True
test_camera_with_linked_motion_sensor
(hass, run_driver, events)
Test a camera with a linked motion sensor can update.
Test a camera with a linked motion sensor can update.
async def test_camera_with_linked_motion_sensor(hass, run_driver, events): """Test a camera with a linked motion sensor can update.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}} ) ...
[ "async", "def", "test_camera_with_linked_motion_sensor", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")", "await"...
[ 547, 0 ]
[ 612, 29 ]
python
en
['en', 'en', 'en']
True
test_camera_with_a_missing_linked_motion_sensor
(hass, run_driver, events)
Test a camera with a configured linked motion sensor that is missing.
Test a camera with a configured linked motion sensor that is missing.
async def test_camera_with_a_missing_linked_motion_sensor(hass, run_driver, events): """Test a camera with a configured linked motion sensor that is missing.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"p...
[ "async", "def", "test_camera_with_a_missing_linked_motion_sensor", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")",...
[ 615, 0 ]
[ 642, 50 ]
python
en
['en', 'en', 'en']
True
test_camera_with_linked_doorbell_sensor
(hass, run_driver, events)
Test a camera with a linked doorbell sensor can update.
Test a camera with a linked doorbell sensor can update.
async def test_camera_with_linked_doorbell_sensor(hass, run_driver, events): """Test a camera with a linked doorbell sensor can update.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}} ...
[ "async", "def", "test_camera_with_linked_doorbell_sensor", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")", "awai...
[ 645, 0 ]
[ 721, 27 ]
python
en
['en', 'en', 'en']
True
test_camera_with_a_missing_linked_doorbell_sensor
(hass, run_driver, events)
Test a camera with a configured linked doorbell sensor that is missing.
Test a camera with a configured linked doorbell sensor that is missing.
async def test_camera_with_a_missing_linked_doorbell_sensor(hass, run_driver, events): """Test a camera with a configured linked doorbell sensor that is missing.""" await async_setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}}) await async_setup_component( hass, camera.DOMAIN, {camera.DOMAIN:...
[ "async", "def", "test_camera_with_a_missing_linked_doorbell_sensor", "(", "hass", ",", "run_driver", ",", "events", ")", ":", "await", "async_setup_component", "(", "hass", ",", "ffmpeg", ".", "DOMAIN", ",", "{", "ffmpeg", ".", "DOMAIN", ":", "{", "}", "}", ")...
[ 724, 0 ]
[ 752, 66 ]
python
en
['en', 'en', 'en']
True
test_light
(hass, light_data, light_msg, light_rgb_msg, sent_messages)
Test setting up config entry.
Test setting up config entry.
async def test_light(hass, light_data, light_msg, light_rgb_msg, sent_messages): """Test setting up config entry.""" receive_message = await setup_ozw(hass, fixture=light_data) # Test loaded state = hass.states.get("light.led_bulb_6_multi_colour_level") assert state is not None assert state.sta...
[ "async", "def", "test_light", "(", "hass", ",", "light_data", ",", "light_msg", ",", "light_rgb_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_data", ")", "# Test loaded", "state", "...
[ 6, 0 ]
[ 349, 48 ]
python
en
['en', 'en', 'en']
True
test_pure_rgb_dimmer_light
( hass, light_data, light_pure_rgb_msg, sent_messages )
Test light with no color channels command class.
Test light with no color channels command class.
async def test_pure_rgb_dimmer_light( hass, light_data, light_pure_rgb_msg, sent_messages ): """Test light with no color channels command class.""" receive_message = await setup_ozw(hass, fixture=light_data) # Test loaded state = hass.states.get("light.kitchen_rgb_strip_level") assert state is ...
[ "async", "def", "test_pure_rgb_dimmer_light", "(", "hass", ",", "light_data", ",", "light_pure_rgb_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_data", ")", "# Test loaded", "state", "=...
[ 352, 0 ]
[ 391, 58 ]
python
en
['en', 'en', 'en']
True
test_no_rgb_light
(hass, light_data, light_no_rgb_msg, sent_messages)
Test setting up config entry.
Test setting up config entry.
async def test_no_rgb_light(hass, light_data, light_no_rgb_msg, sent_messages): """Test setting up config entry.""" receive_message = await setup_ozw(hass, fixture=light_data) # Test loaded no RGBW support (dimmer only) state = hass.states.get("light.master_bedroom_l_level") assert state is not Non...
[ "async", "def", "test_no_rgb_light", "(", "hass", ",", "light_data", ",", "light_no_rgb_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_data", ")", "# Test loaded no RGBW support (dimmer only...
[ 394, 0 ]
[ 430, 59 ]
python
en
['en', 'en', 'en']
True
test_no_ww_light
( hass, light_no_ww_data, light_msg, light_rgb_msg, sent_messages )
Test setting up config entry.
Test setting up config entry.
async def test_no_ww_light( hass, light_no_ww_data, light_msg, light_rgb_msg, sent_messages ): """Test setting up config entry.""" receive_message = await setup_ozw(hass, fixture=light_no_ww_data) # Test loaded no ww support state = hass.states.get("light.led_bulb_6_multi_colour_level") assert ...
[ "async", "def", "test_no_ww_light", "(", "hass", ",", "light_no_ww_data", ",", "light_msg", ",", "light_rgb_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_no_ww_data", ")", "# Test loade...
[ 433, 0 ]
[ 474, 49 ]
python
en
['en', 'en', 'en']
True
test_no_cw_light
( hass, light_no_cw_data, light_msg, light_rgb_msg, sent_messages )
Test setting up config entry.
Test setting up config entry.
async def test_no_cw_light( hass, light_no_cw_data, light_msg, light_rgb_msg, sent_messages ): """Test setting up config entry.""" receive_message = await setup_ozw(hass, fixture=light_no_cw_data) # Test loaded no cw support state = hass.states.get("light.led_bulb_6_multi_colour_level") assert ...
[ "async", "def", "test_no_cw_light", "(", "hass", ",", "light_no_cw_data", ",", "light_msg", ",", "light_rgb_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_no_cw_data", ")", "# Test loade...
[ 477, 0 ]
[ 518, 49 ]
python
en
['en', 'en', 'en']
True
test_wc_light
(hass, light_wc_data, light_msg, light_rgb_msg, sent_messages)
Test setting up config entry.
Test setting up config entry.
async def test_wc_light(hass, light_wc_data, light_msg, light_rgb_msg, sent_messages): """Test setting up config entry.""" receive_message = await setup_ozw(hass, fixture=light_wc_data) # Test loaded only white LED support state = hass.states.get("light.led_bulb_6_multi_colour_level") assert state ...
[ "async", "def", "test_wc_light", "(", "hass", ",", "light_wc_data", ",", "light_msg", ",", "light_rgb_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_wc_data", ")", "# Test loaded only wh...
[ 521, 0 ]
[ 560, 48 ]
python
en
['en', 'en', 'en']
True
test_new_ozw_light
(hass, light_new_ozw_data, light_msg, sent_messages)
Test setting up config entry.
Test setting up config entry.
async def test_new_ozw_light(hass, light_new_ozw_data, light_msg, sent_messages): """Test setting up config entry.""" receive_message = await setup_ozw(hass, fixture=light_new_ozw_data) # Test loaded only white LED support state = hass.states.get("light.led_bulb_6_multi_colour_level") assert state ...
[ "async", "def", "test_new_ozw_light", "(", "hass", ",", "light_new_ozw_data", ",", "light_msg", ",", "sent_messages", ")", ":", "receive_message", "=", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_new_ozw_data", ")", "# Test loaded only white LED sup...
[ 563, 0 ]
[ 650, 38 ]
python
en
['en', 'en', 'en']
True
load_from_file
(path, fmt=None, is_training=True)
load data from file
load data from file
def load_from_file(path, fmt=None, is_training=True): ''' load data from file ''' if fmt is None: fmt = 'squad' assert fmt in ['squad', 'csv'], 'input format must be squad or csv' qp_pairs = [] if fmt == 'squad': with open(path) as data_file: data = json.load(data...
[ "def", "load_from_file", "(", "path", ",", "fmt", "=", "None", ",", "is_training", "=", "True", ")", ":", "if", "fmt", "is", "None", ":", "fmt", "=", "'squad'", "assert", "fmt", "in", "[", "'squad'", ",", "'csv'", "]", ",", "'input format must be squad o...
[ 65, 0 ]
[ 102, 19 ]
python
en
['en', 'error', 'th']
False
tokenize
(qp_pair, tokenizer=None, is_training=False)
tokenize function.
tokenize function.
def tokenize(qp_pair, tokenizer=None, is_training=False): ''' tokenize function. ''' question_tokens = tokenizer.tokenize(qp_pair['question']) passage_tokens = tokenizer.tokenize(qp_pair['passage']) if is_training: question_tokens = question_tokens[:300] passage_tokens = passage_...
[ "def", "tokenize", "(", "qp_pair", ",", "tokenizer", "=", "None", ",", "is_training", "=", "False", ")", ":", "question_tokens", "=", "tokenizer", ".", "tokenize", "(", "qp_pair", "[", "'question'", "]", ")", "passage_tokens", "=", "tokenizer", ".", "tokeniz...
[ 105, 0 ]
[ 119, 46 ]
python
en
['en', 'error', 'th']
False
collect_vocab
(qp_pairs)
Build the vocab from corpus.
Build the vocab from corpus.
def collect_vocab(qp_pairs): ''' Build the vocab from corpus. ''' vocab = set() for qp_pair in qp_pairs: for word in qp_pair['question_tokens']: vocab.add(word['word']) for word in qp_pair['passage_tokens']: vocab.add(word['word']) return vocab
[ "def", "collect_vocab", "(", "qp_pairs", ")", ":", "vocab", "=", "set", "(", ")", "for", "qp_pair", "in", "qp_pairs", ":", "for", "word", "in", "qp_pair", "[", "'question_tokens'", "]", ":", "vocab", ".", "add", "(", "word", "[", "'word'", "]", ")", ...
[ 122, 0 ]
[ 132, 16 ]
python
en
['en', 'error', 'th']
False
shuffle_step
(entries, step)
Shuffle the step
Shuffle the step
def shuffle_step(entries, step): ''' Shuffle the step ''' answer = [] for i in range(0, len(entries), step): sub = entries[i:i+step] shuffle(sub) answer += sub return answer
[ "def", "shuffle_step", "(", "entries", ",", "step", ")", ":", "answer", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "entries", ")", ",", "step", ")", ":", "sub", "=", "entries", "[", "i", ":", "i", "+", "step", "]", "...
[ 135, 0 ]
[ 144, 17 ]
python
en
['en', 'error', 'th']
False
get_batches
(qp_pairs, batch_size, need_sort=True)
Get batches data and shuffle.
Get batches data and shuffle.
def get_batches(qp_pairs, batch_size, need_sort=True): ''' Get batches data and shuffle. ''' if need_sort: qp_pairs = sorted(qp_pairs, key=lambda qp: ( len(qp['passage_tokens']), qp['id']), reverse=True) batches = [{'qp_pairs': qp_pairs[i:(i + batch_size)]} for i i...
[ "def", "get_batches", "(", "qp_pairs", ",", "batch_size", ",", "need_sort", "=", "True", ")", ":", "if", "need_sort", ":", "qp_pairs", "=", "sorted", "(", "qp_pairs", ",", "key", "=", "lambda", "qp", ":", "(", "len", "(", "qp", "[", "'passage_tokens'", ...
[ 147, 0 ]
[ 157, 18 ]
python
en
['en', 'error', 'th']
False
get_char_input
(data, char_dict, max_char_length)
Get char input.
Get char input.
def get_char_input(data, char_dict, max_char_length): ''' Get char input. ''' batch_size = len(data) sequence_length = max(len(d) for d in data) char_id = np.zeros((max_char_length, sequence_length, batch_size), dtype=np.int32) char_lengths = np.zeros((sequence_length...
[ "def", "get_char_input", "(", "data", ",", "char_dict", ",", "max_char_length", ")", ":", "batch_size", "=", "len", "(", "data", ")", "sequence_length", "=", "max", "(", "len", "(", "d", ")", "for", "d", "in", "data", ")", "char_id", "=", "np", ".", ...
[ 160, 0 ]
[ 176, 32 ]
python
en
['en', 'error', 'th']
False
get_word_input
(data, word_dict, embed, embed_dim)
Get word input.
Get word input.
def get_word_input(data, word_dict, embed, embed_dim): ''' Get word input. ''' batch_size = len(data) max_sequence_length = max(len(d) for d in data) sequence_length = max_sequence_length word_input = np.zeros((max_sequence_length, batch_size, embed_dim), dtype=np....
[ "def", "get_word_input", "(", "data", ",", "word_dict", ",", "embed", ",", "embed_dim", ")", ":", "batch_size", "=", "len", "(", "data", ")", "max_sequence_length", "=", "max", "(", "len", "(", "d", ")", "for", "d", "in", "data", ")", "sequence_length", ...
[ 179, 0 ]
[ 205, 42 ]
python
en
['en', 'error', 'th']
False
get_word_index
(tokens, char_index)
Given word return word index.
Given word return word index.
def get_word_index(tokens, char_index): ''' Given word return word index. ''' for (i, token) in enumerate(tokens): if token['char_end'] == 0: continue if token['char_begin'] <= char_index and char_index <= token['char_end']: return i return 0
[ "def", "get_word_index", "(", "tokens", ",", "char_index", ")", ":", "for", "(", "i", ",", "token", ")", "in", "enumerate", "(", "tokens", ")", ":", "if", "token", "[", "'char_end'", "]", "==", "0", ":", "continue", "if", "token", "[", "'char_begin'", ...
[ 208, 0 ]
[ 217, 12 ]
python
en
['en', 'error', 'th']
False
get_answer_begin_end
(data)
Get answer's index of begin and end.
Get answer's index of begin and end.
def get_answer_begin_end(data): ''' Get answer's index of begin and end. ''' begin = [] end = [] for qa_pair in data: tokens = qa_pair['passage_tokens'] char_begin = qa_pair['answer_begin'] char_end = qa_pair['answer_end'] word_begin = get_word_index(tokens, char_...
[ "def", "get_answer_begin_end", "(", "data", ")", ":", "begin", "=", "[", "]", "end", "=", "[", "]", "for", "qa_pair", "in", "data", ":", "tokens", "=", "qa_pair", "[", "'passage_tokens'", "]", "char_begin", "=", "qa_pair", "[", "'answer_begin'", "]", "ch...
[ 220, 0 ]
[ 234, 45 ]
python
en
['en', 'error', 'th']
False
get_id
(word_dict, word)
Given word, return word id.
Given word, return word id.
def get_id(word_dict, word): ''' Given word, return word id. ''' if word in word_dict.keys(): return word_dict[word] return word_dict['<unk>']
[ "def", "get_id", "(", "word_dict", ",", "word", ")", ":", "if", "word", "in", "word_dict", ".", "keys", "(", ")", ":", "return", "word_dict", "[", "word", "]", "return", "word_dict", "[", "'<unk>'", "]" ]
[ 237, 0 ]
[ 243, 29 ]
python
en
['en', 'error', 'th']
False
get_buckets
(min_length, max_length, bucket_count)
Get bucket by length.
Get bucket by length.
def get_buckets(min_length, max_length, bucket_count): ''' Get bucket by length. ''' if bucket_count <= 0: return [max_length] unit_length = int((max_length - min_length) // (bucket_count)) buckets = [min_length + unit_length * (i + 1) for i in range(0, bucket_count)] ...
[ "def", "get_buckets", "(", "min_length", ",", "max_length", ",", "bucket_count", ")", ":", "if", "bucket_count", "<=", "0", ":", "return", "[", "max_length", "]", "unit_length", "=", "int", "(", "(", "max_length", "-", "min_length", ")", "//", "(", "bucket...
[ 246, 0 ]
[ 256, 18 ]
python
en
['en', 'error', 'th']
False
find_bucket
(length, buckets)
Find bucket.
Find bucket.
def find_bucket(length, buckets): ''' Find bucket. ''' for bucket in buckets: if length <= bucket: return bucket return buckets[-1]
[ "def", "find_bucket", "(", "length", ",", "buckets", ")", ":", "for", "bucket", "in", "buckets", ":", "if", "length", "<=", "bucket", ":", "return", "bucket", "return", "buckets", "[", "-", "1", "]" ]
[ 259, 0 ]
[ 266, 22 ]
python
en
['en', 'error', 'th']
False
WhitespaceTokenizer.tokenize
(self, text)
tokenize function in Tokenizer.
tokenize function in Tokenizer.
def tokenize(self, text): ''' tokenize function in Tokenizer. ''' start = -1 tokens = [] for i, character in enumerate(text): if character == ' ' or character == '\t': if start >= 0: word = text[start:i] ...
[ "def", "tokenize", "(", "self", ",", "text", ")", ":", "start", "=", "-", "1", "tokens", "=", "[", "]", "for", "i", ",", "character", "in", "enumerate", "(", "text", ")", ":", "if", "character", "==", "' '", "or", "character", "==", "'\\t'", ":", ...
[ 36, 4 ]
[ 62, 21 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the SyncThru component.
Set up the SyncThru component.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the SyncThru component.""" _LOGGER.warning( "Loading syncthru via platform config is deprecated and no longer " "necessary as of 0.113. Please remove it from your configuration YAML." ) hass....
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "_LOGGER", ".", "warning", "(", "\"Loading syncthru via platform config is deprecated and no longer \"", "\"necessary as of 0.113. Plea...
[ 39, 0 ]
[ 55, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up from config entry.
Set up from config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up from config entry.""" printer = hass.data[DOMAIN][config_entry.entry_id] supp_toner = printer.toner_status(filter_supported=True) supp_drum = printer.drum_status(filter_supported=True) supp_tray = printer.input_tray_sta...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "printer", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "supp_toner", "=", "printer", ".", "toner_status", ...
[ 58, 0 ]
[ 80, 37 ]
python
en
['en', 'en', 'en']
True
SyncThruSensor.__init__
(self, syncthru, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, syncthru, name): """Initialize the sensor.""" self.syncthru: SyncThru = syncthru self._attributes = {} self._state = None self._name = name self._icon = "mdi:printer" self._unit_of_measurement = None self._id_suffix = ""
[ "def", "__init__", "(", "self", ",", "syncthru", ",", "name", ")", ":", "self", ".", "syncthru", ":", "SyncThru", "=", "syncthru", "self", ".", "_attributes", "=", "{", "}", "self", ".", "_state", "=", "None", "self", ".", "_name", "=", "name", "self...
[ 86, 4 ]
[ 94, 28 ]
python
en
['en', 'en', 'en']
True
SyncThruSensor.unique_id
(self)
Return unique ID for the sensor.
Return unique ID for the sensor.
def unique_id(self): """Return unique ID for the sensor.""" serial = self.syncthru.serial_number() return serial + self._id_suffix if serial else super().unique_id
[ "def", "unique_id", "(", "self", ")", ":", "serial", "=", "self", ".", "syncthru", ".", "serial_number", "(", ")", "return", "serial", "+", "self", ".", "_id_suffix", "if", "serial", "else", "super", "(", ")", ".", "unique_id" ]
[ 97, 4 ]
[ 100, 72 ]
python
en
['en', 'it', 'en']
True
SyncThruSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 103, 4 ]
[ 105, 25 ]
python
en
['en', 'mi', 'en']
True
SyncThruSensor.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" ]
[ 108, 4 ]
[ 110, 26 ]
python
en
['en', 'en', 'en']
True
SyncThruSensor.icon
(self)
Return the icon of the device.
Return the icon of the device.
def icon(self): """Return the icon of the device.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 113, 4 ]
[ 115, 25 ]
python
en
['en', 'en', 'en']
True
SyncThruSensor.unit_of_measurement
(self)
Return the unit of measuremnt.
Return the unit of measuremnt.
def unit_of_measurement(self): """Return the unit of measuremnt.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 118, 4 ]
[ 120, 40 ]
python
en
['en', 'da', 'en']
True
SyncThruSensor.device_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def device_state_attributes(self): """Return the state attributes of the device.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 123, 4 ]
[ 125, 31 ]
python
en
['en', 'en', 'en']
True
SyncThruSensor.device_info
(self)
Return device information.
Return device information.
def device_info(self): """Return device information.""" return {"identifiers": device_identifiers(self.syncthru)}
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "device_identifiers", "(", "self", ".", "syncthru", ")", "}" ]
[ 128, 4 ]
[ 130, 65 ]
python
da
['es', 'da', 'en']
False
SyncThruMainSensor.__init__
(self, syncthru, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, syncthru, name): """Initialize the sensor.""" super().__init__(syncthru, name) self._id_suffix = "_main" self._active = True
[ "def", "__init__", "(", "self", ",", "syncthru", ",", "name", ")", ":", "super", "(", ")", ".", "__init__", "(", "syncthru", ",", "name", ")", "self", ".", "_id_suffix", "=", "\"_main\"", "self", ".", "_active", "=", "True" ]
[ 136, 4 ]
[ 140, 27 ]
python
en
['en', 'en', 'en']
True
SyncThruMainSensor.async_update
(self)
Get the latest data from SyncThru and update the state.
Get the latest data from SyncThru and update the state.
async def async_update(self): """Get the latest data from SyncThru and update the state.""" if not self._active: return try: await self.syncthru.update() except ValueError: # if an exception is thrown, printer does not support syncthru _LOG...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "not", "self", ".", "_active", ":", "return", "try", ":", "await", "self", ".", "syncthru", ".", "update", "(", ")", "except", "ValueError", ":", "# if an exception is thrown, printer does not support ...
[ 142, 4 ]
[ 157, 82 ]
python
en
['en', 'en', 'en']
True
SyncThruTonerSensor.__init__
(self, syncthru, name, color)
Initialize the sensor.
Initialize the sensor.
def __init__(self, syncthru, name, color): """Initialize the sensor.""" super().__init__(syncthru, name) self._name = f"{name} Toner {color}" self._color = color self._unit_of_measurement = PERCENTAGE self._id_suffix = f"_toner_{color}"
[ "def", "__init__", "(", "self", ",", "syncthru", ",", "name", ",", "color", ")", ":", "super", "(", ")", ".", "__init__", "(", "syncthru", ",", "name", ")", "self", ".", "_name", "=", "f\"{name} Toner {color}\"", "self", ".", "_color", "=", "color", "s...
[ 163, 4 ]
[ 169, 43 ]
python
en
['en', 'en', 'en']
True
SyncThruTonerSensor.update
(self)
Get the latest data from SyncThru and update the state.
Get the latest data from SyncThru and update the state.
def update(self): """Get the latest data from SyncThru and update the state.""" # Data fetching is taken care of through the Main sensor if self.syncthru.is_online(): self._attributes = self.syncthru.toner_status().get(self._color, {}) self._state = self._attributes.get(...
[ "def", "update", "(", "self", ")", ":", "# Data fetching is taken care of through the Main sensor", "if", "self", ".", "syncthru", ".", "is_online", "(", ")", ":", "self", ".", "_attributes", "=", "self", ".", "syncthru", ".", "toner_status", "(", ")", ".", "g...
[ 171, 4 ]
[ 177, 59 ]
python
en
['en', 'en', 'en']
True
SyncThruDrumSensor.__init__
(self, syncthru, name, color)
Initialize the sensor.
Initialize the sensor.
def __init__(self, syncthru, name, color): """Initialize the sensor.""" super().__init__(syncthru, name) self._name = f"{name} Drum {color}" self._color = color self._unit_of_measurement = PERCENTAGE self._id_suffix = f"_drum_{color}"
[ "def", "__init__", "(", "self", ",", "syncthru", ",", "name", ",", "color", ")", ":", "super", "(", ")", ".", "__init__", "(", "syncthru", ",", "name", ")", "self", ".", "_name", "=", "f\"{name} Drum {color}\"", "self", ".", "_color", "=", "color", "se...
[ 183, 4 ]
[ 189, 42 ]
python
en
['en', 'en', 'en']
True
SyncThruDrumSensor.update
(self)
Get the latest data from SyncThru and update the state.
Get the latest data from SyncThru and update the state.
def update(self): """Get the latest data from SyncThru and update the state.""" # Data fetching is taken care of through the Main sensor if self.syncthru.is_online(): self._attributes = self.syncthru.drum_status().get(self._color, {}) self._state = self._attributes.get("...
[ "def", "update", "(", "self", ")", ":", "# Data fetching is taken care of through the Main sensor", "if", "self", ".", "syncthru", ".", "is_online", "(", ")", ":", "self", ".", "_attributes", "=", "self", ".", "syncthru", ".", "drum_status", "(", ")", ".", "ge...
[ 191, 4 ]
[ 197, 59 ]
python
en
['en', 'en', 'en']
True
SyncThruInputTraySensor.__init__
(self, syncthru, name, number)
Initialize the sensor.
Initialize the sensor.
def __init__(self, syncthru, name, number): """Initialize the sensor.""" super().__init__(syncthru, name) self._name = f"{name} Tray {number}" self._number = number self._id_suffix = f"_tray_{number}"
[ "def", "__init__", "(", "self", ",", "syncthru", ",", "name", ",", "number", ")", ":", "super", "(", ")", ".", "__init__", "(", "syncthru", ",", "name", ")", "self", ".", "_name", "=", "f\"{name} Tray {number}\"", "self", ".", "_number", "=", "number", ...
[ 203, 4 ]
[ 208, 43 ]
python
en
['en', 'en', 'en']
True
SyncThruInputTraySensor.update
(self)
Get the latest data from SyncThru and update the state.
Get the latest data from SyncThru and update the state.
def update(self): """Get the latest data from SyncThru and update the state.""" # Data fetching is taken care of through the Main sensor if self.syncthru.is_online(): self._attributes = self.syncthru.input_tray_status().get(self._number, {}) self._state = self._attribute...
[ "def", "update", "(", "self", ")", ":", "# Data fetching is taken care of through the Main sensor", "if", "self", ".", "syncthru", ".", "is_online", "(", ")", ":", "self", ".", "_attributes", "=", "self", ".", "syncthru", ".", "input_tray_status", "(", ")", ".",...
[ 210, 4 ]
[ 218, 37 ]
python
en
['en', 'en', 'en']
True
SyncThruOutputTraySensor.__init__
(self, syncthru, name, number)
Initialize the sensor.
Initialize the sensor.
def __init__(self, syncthru, name, number): """Initialize the sensor.""" super().__init__(syncthru, name) self._name = f"{name} Output Tray {number}" self._number = number self._id_suffix = f"_output_tray_{number}"
[ "def", "__init__", "(", "self", ",", "syncthru", ",", "name", ",", "number", ")", ":", "super", "(", ")", ".", "__init__", "(", "syncthru", ",", "name", ")", "self", ".", "_name", "=", "f\"{name} Output Tray {number}\"", "self", ".", "_number", "=", "num...
[ 224, 4 ]
[ 229, 50 ]
python
en
['en', 'en', 'en']
True
SyncThruOutputTraySensor.update
(self)
Get the latest data from SyncThru and update the state.
Get the latest data from SyncThru and update the state.
def update(self): """Get the latest data from SyncThru and update the state.""" # Data fetching is taken care of through the Main sensor if self.syncthru.is_online(): self._attributes = self.syncthru.output_tray_status().get(self._number, {}) self._state = self._attribut...
[ "def", "update", "(", "self", ")", ":", "# Data fetching is taken care of through the Main sensor", "if", "self", ".", "syncthru", ".", "is_online", "(", ")", ":", "self", ".", "_attributes", "=", "self", ".", "syncthru", ".", "output_tray_status", "(", ")", "."...
[ 231, 4 ]
[ 239, 37 ]
python
en
['en', 'en', 'en']
True
detect
()
Return a list of candidate paths for USB ENOcean dongles. This method is currently a bit simplistic, it may need to be improved to support more configurations and OS.
Return a list of candidate paths for USB ENOcean dongles.
def detect(): """Return a list of candidate paths for USB ENOcean dongles. This method is currently a bit simplistic, it may need to be improved to support more configurations and OS. """ globs_to_test = ["/dev/tty*FTOA2PV*", "/dev/serial/by-id/*EnOcean*"] found_paths = [] for current_glob ...
[ "def", "detect", "(", ")", ":", "globs_to_test", "=", "[", "\"/dev/tty*FTOA2PV*\"", ",", "\"/dev/serial/by-id/*EnOcean*\"", "]", "found_paths", "=", "[", "]", "for", "current_glob", "in", "globs_to_test", ":", "found_paths", ".", "extend", "(", "glob", ".", "glo...
[ 63, 0 ]
[ 74, 22 ]
python
en
['en', 'en', 'en']
True
validate_path
(path: str)
Return True if the provided path points to a valid serial port, False otherwise.
Return True if the provided path points to a valid serial port, False otherwise.
def validate_path(path: str): """Return True if the provided path points to a valid serial port, False otherwise.""" try: # Creating the serial communicator will raise an exception # if it cannot connect SerialCommunicator(port=path) return True except serial.SerialException ...
[ "def", "validate_path", "(", "path", ":", "str", ")", ":", "try", ":", "# Creating the serial communicator will raise an exception", "# if it cannot connect", "SerialCommunicator", "(", "port", "=", "path", ")", "return", "True", "except", "serial", ".", "SerialExceptio...
[ 77, 0 ]
[ 86, 20 ]
python
en
['en', 'en', 'en']
True
EnOceanDongle.__init__
(self, hass, serial_path)
Initialize the EnOcean dongle.
Initialize the EnOcean dongle.
def __init__(self, hass, serial_path): """Initialize the EnOcean dongle.""" self._communicator = SerialCommunicator( port=serial_path, callback=self.callback ) self.serial_path = serial_path self.identifier = basename(normpath(serial_path)) self.hass = hass ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "serial_path", ")", ":", "self", ".", "_communicator", "=", "SerialCommunicator", "(", "port", "=", "serial_path", ",", "callback", "=", "self", ".", "callback", ")", "self", ".", "serial_path", "=", "seria...
[ 23, 4 ]
[ 32, 48 ]
python
en
['en', 'en', 'en']
True
EnOceanDongle.async_setup
(self)
Finish the setup of the bridge and supported platforms.
Finish the setup of the bridge and supported platforms.
async def async_setup(self): """Finish the setup of the bridge and supported platforms.""" self._communicator.start() self.dispatcher_disconnect_handle = async_dispatcher_connect( self.hass, SIGNAL_SEND_MESSAGE, self._send_message_callback )
[ "async", "def", "async_setup", "(", "self", ")", ":", "self", ".", "_communicator", ".", "start", "(", ")", "self", ".", "dispatcher_disconnect_handle", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_SEND_MESSAGE", ",", "self", ".", "_...
[ 34, 4 ]
[ 39, 9 ]
python
en
['en', 'en', 'en']
True
EnOceanDongle.unload
(self)
Disconnect callbacks established at init time.
Disconnect callbacks established at init time.
def unload(self): """Disconnect callbacks established at init time.""" if self.dispatcher_disconnect_handle: self.dispatcher_disconnect_handle() self.dispatcher_disconnect_handle = None
[ "def", "unload", "(", "self", ")", ":", "if", "self", ".", "dispatcher_disconnect_handle", ":", "self", ".", "dispatcher_disconnect_handle", "(", ")", "self", ".", "dispatcher_disconnect_handle", "=", "None" ]
[ 41, 4 ]
[ 45, 52 ]
python
en
['en', 'en', 'en']
True
EnOceanDongle._send_message_callback
(self, command)
Send a command through the EnOcean dongle.
Send a command through the EnOcean dongle.
def _send_message_callback(self, command): """Send a command through the EnOcean dongle.""" self._communicator.send(command)
[ "def", "_send_message_callback", "(", "self", ",", "command", ")", ":", "self", ".", "_communicator", ".", "send", "(", "command", ")" ]
[ 47, 4 ]
[ 49, 40 ]
python
en
['en', 'gl', 'en']
True
EnOceanDongle.callback
(self, packet)
Handle EnOcean device's callback. This is the callback function called by python-enocan whenever there is an incoming packet.
Handle EnOcean device's callback.
def callback(self, packet): """Handle EnOcean device's callback. This is the callback function called by python-enocan whenever there is an incoming packet. """ if isinstance(packet, RadioPacket): _LOGGER.debug("Received radio packet: %s", packet) self.h...
[ "def", "callback", "(", "self", ",", "packet", ")", ":", "if", "isinstance", "(", "packet", ",", "RadioPacket", ")", ":", "_LOGGER", ".", "debug", "(", "\"Received radio packet: %s\"", ",", "packet", ")", "self", ".", "hass", ".", "helpers", ".", "dispatch...
[ 51, 4 ]
[ 60, 88 ]
python
en
['nl', 'es', 'en']
False
test_device
(hass, config_entry, aioclient_mock_fixture, aioclient_mock)
Test Flo by Moen device.
Test Flo by Moen device.
async def test_device(hass, config_entry, aioclient_mock_fixture, aioclient_mock): """Test Flo by Moen device.""" config_entry.add_to_hass(hass) assert await async_setup_component( hass, FLO_DOMAIN, {CONF_USERNAME: TEST_USER_ID, CONF_PASSWORD: TEST_PASSWORD} ) await hass.async_block_till_don...
[ "async", "def", "test_device", "(", "hass", ",", "config_entry", ",", "aioclient_mock_fixture", ",", "aioclient_mock", ")", ":", "config_entry", ".", "add_to_hass", "(", "hass", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "FLO_DOMAIN", ",", ...
[ 14, 0 ]
[ 57, 54 ]
python
en
['en', 'fy', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Demo lock platform.
Set up the Demo lock platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Demo lock platform.""" async_add_entities( [ DemoLock("Front Door", STATE_LOCKED), DemoLock("Kitchen Door", STATE_UNLOCKED), DemoLock("Openable Lock", STATE_LOCKED, Tr...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities", "(", "[", "DemoLock", "(", "\"Front Door\"", ",", "STATE_LOCKED", ")", ",", "DemoLock", "(", "\"Kit...
[ 5, 0 ]
[ 13, 5 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Demo config entry.
Set up the Demo config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Demo config entry.""" await async_setup_platform(hass, {}, async_add_entities)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "await", "async_setup_platform", "(", "hass", ",", "{", "}", ",", "async_add_entities", ")" ]
[ 16, 0 ]
[ 18, 60 ]
python
en
['en', 'en', 'en']
True
DemoLock.__init__
(self, name, state, openable=False)
Initialize the lock.
Initialize the lock.
def __init__(self, name, state, openable=False): """Initialize the lock.""" self._name = name self._state = state self._openable = openable
[ "def", "__init__", "(", "self", ",", "name", ",", "state", ",", "openable", "=", "False", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "state", "self", ".", "_openable", "=", "openable" ]
[ 24, 4 ]
[ 28, 33 ]
python
en
['en', 'en', 'en']
True
DemoLock.should_poll
(self)
No polling needed for a demo lock.
No polling needed for a demo lock.
def should_poll(self): """No polling needed for a demo lock.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 31, 4 ]
[ 33, 20 ]
python
en
['en', 'en', 'en']
True
DemoLock.name
(self)
Return the name of the lock if any.
Return the name of the lock if any.
def name(self): """Return the name of the lock if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 36, 4 ]
[ 38, 25 ]
python
en
['en', 'en', 'en']
True
DemoLock.is_locked
(self)
Return true if lock is locked.
Return true if lock is locked.
def is_locked(self): """Return true if lock is locked.""" return self._state == STATE_LOCKED
[ "def", "is_locked", "(", "self", ")", ":", "return", "self", ".", "_state", "==", "STATE_LOCKED" ]
[ 41, 4 ]
[ 43, 42 ]
python
en
['en', 'mt', 'en']
True
DemoLock.lock
(self, **kwargs)
Lock the device.
Lock the device.
def lock(self, **kwargs): """Lock the device.""" self._state = STATE_LOCKED self.schedule_update_ha_state()
[ "def", "lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "STATE_LOCKED", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 45, 4 ]
[ 48, 39 ]
python
en
['en', 'en', 'en']
True
DemoLock.unlock
(self, **kwargs)
Unlock the device.
Unlock the device.
def unlock(self, **kwargs): """Unlock the device.""" self._state = STATE_UNLOCKED self.schedule_update_ha_state()
[ "def", "unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "STATE_UNLOCKED", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 50, 4 ]
[ 53, 39 ]
python
en
['en', 'zh', 'en']
True
DemoLock.open
(self, **kwargs)
Open the door latch.
Open the door latch.
def open(self, **kwargs): """Open the door latch.""" self._state = STATE_UNLOCKED self.schedule_update_ha_state()
[ "def", "open", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_state", "=", "STATE_UNLOCKED", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 55, 4 ]
[ 58, 39 ]
python
en
['en', 'nl', 'en']
True
DemoLock.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" if self._openable: return SUPPORT_OPEN
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_openable", ":", "return", "SUPPORT_OPEN" ]
[ 61, 4 ]
[ 64, 31 ]
python
en
['da', 'en', 'en']
True
ConfigFlow.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 OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 24, 4 ]
[ 26, 47 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} config_entry = self.hass.config_entries.async_entries(DOMAIN) if config_entry: return self.async_abort(reason="single_instance_allowed") errors = {} if user_input i...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "config_entry", "=", "self", ".", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", "if", "config_entry", ":", "return...
[ 28, 4 ]
[ 68, 9 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.__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" ]
[ 74, 4 ]
[ 76, 40 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_init
(self, user_input=None)
Manage options.
Manage options.
async def async_step_init(self, user_input=None): """Manage 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", ...
[ 78, 4 ]
[ 94, 9 ]
python
en
['en', 'en', 'en']
False
setup_platform
(hass, config, add_entities, disc_info=None)
Set up the calendar platform for event devices.
Set up the calendar platform for event devices.
def setup_platform(hass, config, add_entities, disc_info=None): """Set up the calendar platform for event devices.""" if disc_info is None: return if not any(data[CONF_TRACK] for data in disc_info[CONF_ENTITIES]): return calendar_service = GoogleCalendarService(hass.config.path(TOKEN_F...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "disc_info", "=", "None", ")", ":", "if", "disc_info", "is", "None", ":", "return", "if", "not", "any", "(", "data", "[", "CONF_TRACK", "]", "for", "data", "in", "disc_info", ...
[ 42, 0 ]
[ 63, 32 ]
python
en
['en', 'pt', 'en']
True
GoogleCalendarEventDevice.__init__
(self, calendar_service, calendar, data, entity_id)
Create the Calendar event device.
Create the Calendar event device.
def __init__(self, calendar_service, calendar, data, entity_id): """Create the Calendar event device.""" self.data = GoogleCalendarData( calendar_service, calendar, data.get(CONF_SEARCH), data.get(CONF_IGNORE_AVAILABILITY), data.get(CONF_MAX_RE...
[ "def", "__init__", "(", "self", ",", "calendar_service", ",", "calendar", ",", "data", ",", "entity_id", ")", ":", "self", ".", "data", "=", "GoogleCalendarData", "(", "calendar_service", ",", "calendar", ",", "data", ".", "get", "(", "CONF_SEARCH", ")", "...
[ 69, 4 ]
[ 82, 34 ]
python
en
['en', 'ro', 'en']
True
GoogleCalendarEventDevice.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" return {"offset_reached": self._offset_reached}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"offset_reached\"", ":", "self", ".", "_offset_reached", "}" ]
[ 85, 4 ]
[ 87, 55 ]
python
en
['en', 'en', 'en']
True
GoogleCalendarEventDevice.event
(self)
Return the next upcoming event.
Return the next upcoming event.
def event(self): """Return the next upcoming event.""" return self._event
[ "def", "event", "(", "self", ")", ":", "return", "self", ".", "_event" ]
[ 90, 4 ]
[ 92, 26 ]
python
en
['en', 'en', 'en']
True
GoogleCalendarEventDevice.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 95, 4 ]
[ 97, 25 ]
python
en
['en', 'en', 'en']
True
GoogleCalendarEventDevice.async_get_events
(self, hass, start_date, end_date)
Get all events in a specific time frame.
Get all events in a specific time frame.
async def async_get_events(self, hass, start_date, end_date): """Get all events in a specific time frame.""" return await self.data.async_get_events(hass, start_date, end_date)
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "return", "await", "self", ".", "data", ".", "async_get_events", "(", "hass", ",", "start_date", ",", "end_date", ")" ]
[ 99, 4 ]
[ 101, 75 ]
python
en
['en', 'en', 'en']
True