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
test_flux_after_sunset_after_midnight_stop_next_day
( hass, legacy_patchable_time, enable_custom_integrations )
Test the flux switch after sunset and before stop. This test has the stop_time on the next day (after midnight).
Test the flux switch after sunset and before stop.
async def test_flux_after_sunset_after_midnight_stop_next_day( hass, legacy_patchable_time, enable_custom_integrations ): """Test the flux switch after sunset and before stop. This test has the stop_time on the next day (after midnight). """ platform = getattr(hass.components, "test.light") pla...
[ "async", "def", "test_flux_after_sunset_after_midnight_stop_next_day", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init"...
[ 747, 0 ]
[ 808, 59 ]
python
en
['en', 'en', 'en']
True
test_flux_after_stop_before_sunrise_stop_next_day
( hass, legacy_patchable_time, enable_custom_integrations )
Test the flux switch after stop and before sunrise. This test has the stop_time on the next day (after midnight).
Test the flux switch after stop and before sunrise.
async def test_flux_after_stop_before_sunrise_stop_next_day( hass, legacy_patchable_time, enable_custom_integrations ): """Test the flux switch after stop and before sunrise. This test has the stop_time on the next day (after midnight). """ platform = getattr(hass.components, "test.light") plat...
[ "async", "def", "test_flux_after_stop_before_sunrise_stop_next_day", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init", ...
[ 812, 0 ]
[ 873, 59 ]
python
en
['en', 'en', 'en']
True
test_flux_with_custom_colortemps
( hass, legacy_patchable_time, enable_custom_integrations )
Test the flux with custom start and stop colortemps.
Test the flux with custom start and stop colortemps.
async def test_flux_with_custom_colortemps( hass, legacy_patchable_time, enable_custom_integrations ): """Test the flux with custom start and stop colortemps.""" platform = getattr(hass.components, "test.light") platform.init() assert await async_setup_component( hass, light.DOMAIN, {light.D...
[ "async", "def", "test_flux_with_custom_colortemps", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init", "(", ")", "...
[ 877, 0 ]
[ 937, 59 ]
python
en
['en', 'en', 'en']
True
test_flux_with_custom_brightness
( hass, legacy_patchable_time, enable_custom_integrations )
Test the flux with custom start and stop colortemps.
Test the flux with custom start and stop colortemps.
async def test_flux_with_custom_brightness( hass, legacy_patchable_time, enable_custom_integrations ): """Test the flux with custom start and stop colortemps.""" platform = getattr(hass.components, "test.light") platform.init() assert await async_setup_component( hass, light.DOMAIN, {light.D...
[ "async", "def", "test_flux_with_custom_brightness", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init", "(", ")", "...
[ 941, 0 ]
[ 1000, 59 ]
python
en
['en', 'en', 'en']
True
test_flux_with_multiple_lights
( hass, legacy_patchable_time, enable_custom_integrations )
Test the flux switch with multiple light entities.
Test the flux switch with multiple light entities.
async def test_flux_with_multiple_lights( hass, legacy_patchable_time, enable_custom_integrations ): """Test the flux switch with multiple light entities.""" platform = getattr(hass.components, "test.light") platform.init() assert await async_setup_component( hass, light.DOMAIN, {light.DOMAI...
[ "async", "def", "test_flux_with_multiple_lights", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init", "(", ")", "as...
[ 1003, 0 ]
[ 1085, 58 ]
python
en
['en', 'en', 'en']
True
test_flux_with_mired
(hass, legacy_patchable_time, enable_custom_integrations)
Test the flux switch´s mode mired.
Test the flux switch´s mode mired.
async def test_flux_with_mired(hass, legacy_patchable_time, enable_custom_integrations): """Test the flux switch´s mode mired.""" platform = getattr(hass.components, "test.light") platform.init() assert await async_setup_component( hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}} ...
[ "async", "def", "test_flux_with_mired", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init", "(", ")", "assert", "...
[ 1088, 0 ]
[ 1142, 50 ]
python
en
['en', 'en', 'en']
True
test_flux_with_rgb
(hass, legacy_patchable_time, enable_custom_integrations)
Test the flux switch´s mode rgb.
Test the flux switch´s mode rgb.
async def test_flux_with_rgb(hass, legacy_patchable_time, enable_custom_integrations): """Test the flux switch´s mode rgb.""" platform = getattr(hass.components, "test.light") platform.init() assert await async_setup_component( hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}} ) ...
[ "async", "def", "test_flux_with_rgb", "(", "hass", ",", "legacy_patchable_time", ",", "enable_custom_integrations", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "\"test.light\"", ")", "platform", ".", "init", "(", ")", "assert", "aw...
[ 1145, 0 ]
[ 1201, 30 ]
python
en
['en', 'en', 'en']
True
test_manually_configured_platform
(hass)
Test that we do not set up an access point.
Test that we do not set up an access point.
async def test_manually_configured_platform(hass): """Test that we do not set up an access point.""" assert await async_setup_component( hass, WEATHER_DOMAIN, {WEATHER_DOMAIN: {"platform": HMIPC_DOMAIN}} ) assert not hass.data.get(HMIPC_DOMAIN)
[ "async", "def", "test_manually_configured_platform", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "WEATHER_DOMAIN", ",", "{", "WEATHER_DOMAIN", ":", "{", "\"platform\"", ":", "HMIPC_DOMAIN", "}", "}", ")", "assert", "not", ...
[ 15, 0 ]
[ 20, 42 ]
python
en
['en', 'en', 'en']
True
test_hmip_weather_sensor
(hass, default_mock_hap_factory)
Test HomematicipWeatherSensor.
Test HomematicipWeatherSensor.
async def test_hmip_weather_sensor(hass, default_mock_hap_factory): """Test HomematicipWeatherSensor.""" entity_id = "weather.weather_sensor_plus" entity_name = "Weather Sensor – plus" device_model = "HmIP-SWO-PL" mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_devices=[en...
[ "async", "def", "test_hmip_weather_sensor", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"weather.weather_sensor_plus\"", "entity_name", "=", "\"Weather Sensor – plus\"", "device_model", "=", "\"HmIP-SWO-PL\"", "mock_hap", "=", "await", "defau...
[ 23, 0 ]
[ 44, 64 ]
python
en
['en', 'ro', 'en']
False
test_hmip_weather_sensor_pro
(hass, default_mock_hap_factory)
Test HomematicipWeatherSensorPro.
Test HomematicipWeatherSensorPro.
async def test_hmip_weather_sensor_pro(hass, default_mock_hap_factory): """Test HomematicipWeatherSensorPro.""" entity_id = "weather.wettersensor_pro" entity_name = "Wettersensor - pro" device_model = "HmIP-SWO-PR" mock_hap = await default_mock_hap_factory.async_get_mock_hap( test_devices=[e...
[ "async", "def", "test_hmip_weather_sensor_pro", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"weather.wettersensor_pro\"", "entity_name", "=", "\"Wettersensor - pro\"", "device_model", "=", "\"HmIP-SWO-PR\"", "mock_hap", "=", "await", "default...
[ 47, 0 ]
[ 69, 64 ]
python
en
['en', 'ny', 'en']
False
test_hmip_home_weather
(hass, default_mock_hap_factory)
Test HomematicipHomeWeather.
Test HomematicipHomeWeather.
async def test_hmip_home_weather(hass, default_mock_hap_factory): """Test HomematicipHomeWeather.""" entity_id = "weather.weather_1010_wien_osterreich" entity_name = "Weather 1010 Wien, Österreich" device_model = None mock_hap = await default_mock_hap_factory.async_get_mock_hap() ha_state, hmi...
[ "async", "def", "test_hmip_home_weather", "(", "hass", ",", "default_mock_hap_factory", ")", ":", "entity_id", "=", "\"weather.weather_1010_wien_osterreich\"", "entity_name", "=", "\"Weather 1010 Wien, Österreich\"", "device_model", "=", "None", "mock_hap", "=", "await", "...
[ 72, 0 ]
[ 95, 64 ]
python
en
['en', 'en', 'en']
False
test_thread_with_exception_invalid
(hass)
Test throwing an invalid thread exception.
Test throwing an invalid thread exception.
async def test_thread_with_exception_invalid(hass): """Test throwing an invalid thread exception.""" finish_event = asyncio.Event() def _do_nothing(*_): run_callback_threadsafe(hass.loop, finish_event.set) test_thread = ThreadWithException(target=_do_nothing) test_thread.start() await...
[ "async", "def", "test_thread_with_exception_invalid", "(", "hass", ")", ":", "finish_event", "=", "asyncio", ".", "Event", "(", ")", "def", "_do_nothing", "(", "*", "_", ")", ":", "run_callback_threadsafe", "(", "hass", ".", "loop", ",", "finish_event", ".", ...
[ 12, 0 ]
[ 26, 22 ]
python
en
['en', 'en', 'en']
True
test_thread_not_started
(hass)
Test throwing when the thread is not started.
Test throwing when the thread is not started.
async def test_thread_not_started(hass): """Test throwing when the thread is not started.""" test_thread = ThreadWithException(target=lambda *_: None) with pytest.raises(AssertionError): test_thread.raise_exc(TimeoutError)
[ "async", "def", "test_thread_not_started", "(", "hass", ")", ":", "test_thread", "=", "ThreadWithException", "(", "target", "=", "lambda", "*", "_", ":", "None", ")", "with", "pytest", ".", "raises", "(", "AssertionError", ")", ":", "test_thread", ".", "rais...
[ 29, 0 ]
[ 35, 43 ]
python
en
['en', 'en', 'en']
True
test_thread_fails_raise
(hass)
Test throwing after already ended.
Test throwing after already ended.
async def test_thread_fails_raise(hass): """Test throwing after already ended.""" finish_event = asyncio.Event() def _do_nothing(*_): run_callback_threadsafe(hass.loop, finish_event.set) test_thread = ThreadWithException(target=_do_nothing) test_thread.start() await asyncio.wait_for(f...
[ "async", "def", "test_thread_fails_raise", "(", "hass", ")", ":", "finish_event", "=", "asyncio", ".", "Event", "(", ")", "def", "_do_nothing", "(", "*", "_", ")", ":", "run_callback_threadsafe", "(", "hass", ".", "loop", ",", "finish_event", ".", "set", "...
[ 38, 0 ]
[ 52, 41 ]
python
en
['en', 'en', 'en']
True
test_deadlock_safe_shutdown_no_threads
()
Test we can shutdown without deadlock without any threads to join.
Test we can shutdown without deadlock without any threads to join.
async def test_deadlock_safe_shutdown_no_threads(): """Test we can shutdown without deadlock without any threads to join.""" dead_thread_mock = Mock( join=Mock(), daemon=False, is_alive=Mock(return_value=False) ) daemon_thread_mock = Mock( join=Mock(), daemon=True, is_alive=Mock(return_...
[ "async", "def", "test_deadlock_safe_shutdown_no_threads", "(", ")", ":", "dead_thread_mock", "=", "Mock", "(", "join", "=", "Mock", "(", ")", ",", "daemon", "=", "False", ",", "is_alive", "=", "Mock", "(", "return_value", "=", "False", ")", ")", "daemon_thre...
[ 59, 0 ]
[ 77, 45 ]
python
en
['en', 'en', 'en']
True
test_deadlock_safe_shutdown
()
Test we can shutdown without deadlock.
Test we can shutdown without deadlock.
async def test_deadlock_safe_shutdown(): """Test we can shutdown without deadlock.""" normal_thread_mock = Mock( join=Mock(), daemon=False, is_alive=Mock(return_value=True) ) dead_thread_mock = Mock( join=Mock(), daemon=False, is_alive=Mock(return_value=False) ) daemon_thread_mo...
[ "async", "def", "test_deadlock_safe_shutdown", "(", ")", ":", "normal_thread_mock", "=", "Mock", "(", "join", "=", "Mock", "(", ")", ",", "daemon", "=", "False", ",", "is_alive", "=", "Mock", "(", "return_value", "=", "True", ")", ")", "dead_thread_mock", ...
[ 80, 0 ]
[ 110, 73 ]
python
en
['en', 'en', 'en']
True
process_timestamp
(ts)
Process a timestamp into datetime object.
Process a timestamp into datetime object.
def process_timestamp(ts): """Process a timestamp into datetime object.""" if ts is None: return None if ts.tzinfo is None: return ts.replace(tzinfo=dt_util.UTC) return dt_util.as_utc(ts)
[ "def", "process_timestamp", "(", "ts", ")", ":", "if", "ts", "is", "None", ":", "return", "None", "if", "ts", ".", "tzinfo", "is", "None", ":", "return", "ts", ".", "replace", "(", "tzinfo", "=", "dt_util", ".", "UTC", ")", "return", "dt_util", ".", ...
[ 393, 0 ]
[ 400, 29 ]
python
cs
['pt', 'cs', 'en']
False
process_timestamp_to_utc_isoformat
(ts: datetime | None)
Process a timestamp into UTC isotime.
Process a timestamp into UTC isotime.
def process_timestamp_to_utc_isoformat(ts: datetime | None) -> str | None: """Process a timestamp into UTC isotime.""" if ts is None: return None if ts.tzinfo == dt_util.UTC: return ts.isoformat() if ts.tzinfo is None: return f"{ts.isoformat()}{DB_TIMEZONE}" return ts.astimez...
[ "def", "process_timestamp_to_utc_isoformat", "(", "ts", ":", "datetime", "|", "None", ")", "->", "str", "|", "None", ":", "if", "ts", "is", "None", ":", "return", "None", "if", "ts", ".", "tzinfo", "==", "dt_util", ".", "UTC", ":", "return", "ts", ".",...
[ 403, 0 ]
[ 411, 49 ]
python
en
['en', 'mk', 'en']
True
Events.__repr__
(self)
Return string representation of instance for debugging.
Return string representation of instance for debugging.
def __repr__(self) -> str: """Return string representation of instance for debugging.""" return ( f"<recorder.Events(" f"id={self.event_id}, type='{self.event_type}', data='{self.event_data}', " f"origin='{self.origin}', time_fired='{self.time_fired}'" f")...
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "(", "f\"<recorder.Events(\"", "f\"id={self.event_id}, type='{self.event_type}', data='{self.event_data}', \"", "f\"origin='{self.origin}', time_fired='{self.time_fired}'\"", "f\")>\"", ")" ]
[ 96, 4 ]
[ 103, 9 ]
python
en
['en', 'da', 'en']
True
Events.from_event
(event, event_data=None)
Create an event database object from a native event.
Create an event database object from a native event.
def from_event(event, event_data=None): """Create an event database object from a native event.""" return Events( event_type=event.event_type, event_data=event_data or json.dumps(event.data, cls=JSONEncoder, separators=(",", ":")), origin=str(event.origin....
[ "def", "from_event", "(", "event", ",", "event_data", "=", "None", ")", ":", "return", "Events", "(", "event_type", "=", "event", ".", "event_type", ",", "event_data", "=", "event_data", "or", "json", ".", "dumps", "(", "event", ".", "data", ",", "cls", ...
[ 106, 4 ]
[ 117, 9 ]
python
en
['en', 'en', 'en']
True
Events.to_native
(self, validate_entity_id=True)
Convert to a native HA Event.
Convert to a native HA Event.
def to_native(self, validate_entity_id=True): """Convert to a native HA Event.""" context = Context( id=self.context_id, user_id=self.context_user_id, parent_id=self.context_parent_id, ) try: return Event( self.event_type, ...
[ "def", "to_native", "(", "self", ",", "validate_entity_id", "=", "True", ")", ":", "context", "=", "Context", "(", "id", "=", "self", ".", "context_id", ",", "user_id", "=", "self", ".", "context_user_id", ",", "parent_id", "=", "self", ".", "context_paren...
[ 119, 4 ]
[ 137, 23 ]
python
ca
['en', 'ca', 'pt']
False
States.__repr__
(self)
Return string representation of instance for debugging.
Return string representation of instance for debugging.
def __repr__(self) -> str: """Return string representation of instance for debugging.""" return ( f"<recorder.States(" f"id={self.state_id}, domain='{self.domain}', entity_id='{self.entity_id}', " f"state='{self.state}', event_id='{self.event_id}', " f"las...
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "(", "f\"<recorder.States(\"", "f\"id={self.state_id}, domain='{self.domain}', entity_id='{self.entity_id}', \"", "f\"state='{self.state}', event_id='{self.event_id}', \"", "f\"last_updated='{self.last_updated.isoformat(sep='...
[ 165, 4 ]
[ 174, 9 ]
python
en
['en', 'da', 'en']
True
States.from_event
(event)
Create object from a state_changed event.
Create object from a state_changed event.
def from_event(event): """Create object from a state_changed event.""" entity_id = event.data["entity_id"] state = event.data.get("new_state") dbstate = States(entity_id=entity_id) # State got deleted if state is None: dbstate.state = "" dbstate....
[ "def", "from_event", "(", "event", ")", ":", "entity_id", "=", "event", ".", "data", "[", "\"entity_id\"", "]", "state", "=", "event", ".", "data", ".", "get", "(", "\"new_state\"", ")", "dbstate", "=", "States", "(", "entity_id", "=", "entity_id", ")", ...
[ 177, 4 ]
[ 200, 22 ]
python
en
['en', 'en', 'en']
True
States.to_native
(self, validate_entity_id=True)
Convert to an HA state object.
Convert to an HA state object.
def to_native(self, validate_entity_id=True): """Convert to an HA state object.""" try: return State( self.entity_id, self.state, json.loads(self.attributes), process_timestamp(self.last_changed), process_timesta...
[ "def", "to_native", "(", "self", ",", "validate_entity_id", "=", "True", ")", ":", "try", ":", "return", "State", "(", "self", ".", "entity_id", ",", "self", ".", "state", ",", "json", ".", "loads", "(", "self", ".", "attributes", ")", ",", "process_ti...
[ 202, 4 ]
[ 219, 23 ]
python
en
['en', 'en', 'en']
True
Statistics.from_stats
(metadata_id: str, start: datetime, stats: StatisticData)
Create object from a statistics.
Create object from a statistics.
def from_stats(metadata_id: str, start: datetime, stats: StatisticData): """Create object from a statistics.""" return Statistics( metadata_id=metadata_id, start=start, **stats, )
[ "def", "from_stats", "(", "metadata_id", ":", "str", ",", "start", ":", "datetime", ",", "stats", ":", "StatisticData", ")", ":", "return", "Statistics", "(", "metadata_id", "=", "metadata_id", ",", "start", "=", "start", ",", "*", "*", "stats", ",", ")"...
[ 259, 4 ]
[ 265, 9 ]
python
en
['en', 'en', 'en']
True
StatisticsMeta.from_meta
( source: str, statistic_id: str, unit_of_measurement: str | None, has_mean: bool, has_sum: bool, )
Create object from meta data.
Create object from meta data.
def from_meta( source: str, statistic_id: str, unit_of_measurement: str | None, has_mean: bool, has_sum: bool, ) -> StatisticsMeta: """Create object from meta data.""" return StatisticsMeta( source=source, statistic_id=statistic_id, ...
[ "def", "from_meta", "(", "source", ":", "str", ",", "statistic_id", ":", "str", ",", "unit_of_measurement", ":", "str", "|", "None", ",", "has_mean", ":", "bool", ",", "has_sum", ":", "bool", ",", ")", "->", "StatisticsMeta", ":", "return", "StatisticsMeta...
[ 292, 4 ]
[ 306, 9 ]
python
en
['en', 'en', 'en']
True
RecorderRuns.__repr__
(self)
Return string representation of instance for debugging.
Return string representation of instance for debugging.
def __repr__(self) -> str: """Return string representation of instance for debugging.""" end = ( f"'{self.end.isoformat(sep=' ', timespec='seconds')}'" if self.end else None ) return ( f"<recorder.RecorderRuns(" f"id={self.run_id}, start='{self.start.i...
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "end", "=", "(", "f\"'{self.end.isoformat(sep=' ', timespec='seconds')}'\"", "if", "self", ".", "end", "else", "None", ")", "return", "(", "f\"<recorder.RecorderRuns(\"", "f\"id={self.run_id}, start='{self.start.isofo...
[ 320, 4 ]
[ 331, 9 ]
python
en
['en', 'da', 'en']
True
RecorderRuns.entity_ids
(self, point_in_time=None)
Return the entity ids that existed in this run. Specify point_in_time if you want to know which existed at that point in time inside the run.
Return the entity ids that existed in this run.
def entity_ids(self, point_in_time=None): """Return the entity ids that existed in this run. Specify point_in_time if you want to know which existed at that point in time inside the run. """ session = Session.object_session(self) assert session is not None, "RecorderRun...
[ "def", "entity_ids", "(", "self", ",", "point_in_time", "=", "None", ")", ":", "session", "=", "Session", ".", "object_session", "(", "self", ")", "assert", "session", "is", "not", "None", ",", "\"RecorderRuns need to be persisted\"", "query", "=", "session", ...
[ 333, 4 ]
[ 352, 40 ]
python
en
['en', 'en', 'en']
True
RecorderRuns.to_native
(self, validate_entity_id=True)
Return self, native format is this model.
Return self, native format is this model.
def to_native(self, validate_entity_id=True): """Return self, native format is this model.""" return self
[ "def", "to_native", "(", "self", ",", "validate_entity_id", "=", "True", ")", ":", "return", "self" ]
[ 354, 4 ]
[ 356, 19 ]
python
en
['en', 'en', 'en']
True
SchemaChanges.__repr__
(self)
Return string representation of instance for debugging.
Return string representation of instance for debugging.
def __repr__(self) -> str: """Return string representation of instance for debugging.""" return ( f"<recorder.SchemaChanges(" f"id={self.change_id}, schema_version={self.schema_version}, " f"changed='{self.changed.isoformat(sep=' ', timespec='seconds')}'" ...
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "(", "f\"<recorder.SchemaChanges(\"", "f\"id={self.change_id}, schema_version={self.schema_version}, \"", "f\"changed='{self.changed.isoformat(sep=' ', timespec='seconds')}'\"", "f\")>\"", ")" ]
[ 367, 4 ]
[ 374, 9 ]
python
en
['en', 'da', 'en']
True
StatisticsRuns.__repr__
(self)
Return string representation of instance for debugging.
Return string representation of instance for debugging.
def __repr__(self) -> str: """Return string representation of instance for debugging.""" return ( f"<recorder.StatisticsRuns(" f"id={self.run_id}, start='{self.start.isoformat(sep=' ', timespec='seconds')}', " f")>" )
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "(", "f\"<recorder.StatisticsRuns(\"", "f\"id={self.run_id}, start='{self.start.isoformat(sep=' ', timespec='seconds')}', \"", "f\")>\"", ")" ]
[ 384, 4 ]
[ 390, 9 ]
python
en
['en', 'da', 'en']
True
LazyState.__init__
(self, row)
Init the lazy state.
Init the lazy state.
def __init__(self, row): # pylint: disable=super-init-not-called """Init the lazy state.""" self._row = row self.entity_id = self._row.entity_id self.state = self._row.state or "" self._attributes = None self._last_changed = None self._last_updated = None ...
[ "def", "__init__", "(", "self", ",", "row", ")", ":", "# pylint: disable=super-init-not-called", "self", ".", "_row", "=", "row", "self", ".", "entity_id", "=", "self", ".", "_row", ".", "entity_id", "self", ".", "state", "=", "self", ".", "_row", ".", "...
[ 427, 4 ]
[ 435, 28 ]
python
en
['en', 'en', 'en']
True
LazyState.attributes
(self)
State attributes.
State attributes.
def attributes(self): """State attributes.""" if not self._attributes: try: self._attributes = json.loads(self._row.attributes) except ValueError: # When json.loads fails _LOGGER.exception("Error converting row to state: %s", self._...
[ "def", "attributes", "(", "self", ")", ":", "if", "not", "self", ".", "_attributes", ":", "try", ":", "self", ".", "_attributes", "=", "json", ".", "loads", "(", "self", ".", "_row", ".", "attributes", ")", "except", "ValueError", ":", "# When json.loads...
[ 438, 4 ]
[ 447, 31 ]
python
en
['en', 'en', 'en']
False
LazyState.attributes
(self, value)
Set attributes.
Set attributes.
def attributes(self, value): """Set attributes.""" self._attributes = value
[ "def", "attributes", "(", "self", ",", "value", ")", ":", "self", ".", "_attributes", "=", "value" ]
[ 450, 4 ]
[ 452, 32 ]
python
en
['en', 'la', 'en']
False
LazyState.context
(self)
State context.
State context.
def context(self): """State context.""" if not self._context: self._context = Context(id=None) return self._context
[ "def", "context", "(", "self", ")", ":", "if", "not", "self", ".", "_context", ":", "self", ".", "_context", "=", "Context", "(", "id", "=", "None", ")", "return", "self", ".", "_context" ]
[ 455, 4 ]
[ 459, 28 ]
python
en
['en', 'en', 'en']
False
LazyState.context
(self, value)
Set context.
Set context.
def context(self, value): """Set context.""" self._context = value
[ "def", "context", "(", "self", ",", "value", ")", ":", "self", ".", "_context", "=", "value" ]
[ 462, 4 ]
[ 464, 29 ]
python
en
['en', 'ca', 'en']
False
LazyState.last_changed
(self)
Last changed datetime.
Last changed datetime.
def last_changed(self): """Last changed datetime.""" if not self._last_changed: self._last_changed = process_timestamp(self._row.last_changed) return self._last_changed
[ "def", "last_changed", "(", "self", ")", ":", "if", "not", "self", ".", "_last_changed", ":", "self", ".", "_last_changed", "=", "process_timestamp", "(", "self", ".", "_row", ".", "last_changed", ")", "return", "self", ".", "_last_changed" ]
[ 467, 4 ]
[ 471, 33 ]
python
en
['en', 'en', 'en']
True
LazyState.last_changed
(self, value)
Set last changed datetime.
Set last changed datetime.
def last_changed(self, value): """Set last changed datetime.""" self._last_changed = value
[ "def", "last_changed", "(", "self", ",", "value", ")", ":", "self", ".", "_last_changed", "=", "value" ]
[ 474, 4 ]
[ 476, 34 ]
python
en
['en', 'fr', 'en']
True
LazyState.last_updated
(self)
Last updated datetime.
Last updated datetime.
def last_updated(self): """Last updated datetime.""" if not self._last_updated: self._last_updated = process_timestamp(self._row.last_updated) return self._last_updated
[ "def", "last_updated", "(", "self", ")", ":", "if", "not", "self", ".", "_last_updated", ":", "self", ".", "_last_updated", "=", "process_timestamp", "(", "self", ".", "_row", ".", "last_updated", ")", "return", "self", ".", "_last_updated" ]
[ 479, 4 ]
[ 483, 33 ]
python
en
['en', 'en', 'en']
True
LazyState.last_updated
(self, value)
Set last updated datetime.
Set last updated datetime.
def last_updated(self, value): """Set last updated datetime.""" self._last_updated = value
[ "def", "last_updated", "(", "self", ",", "value", ")", ":", "self", ".", "_last_updated", "=", "value" ]
[ 486, 4 ]
[ 488, 34 ]
python
en
['en', 'et', 'en']
True
LazyState.as_dict
(self)
Return a dict representation of the LazyState. Async friendly. To be used for JSON serialization.
Return a dict representation of the LazyState.
def as_dict(self): """Return a dict representation of the LazyState. Async friendly. To be used for JSON serialization. """ if self._last_changed: last_changed_isoformat = self._last_changed.isoformat() else: last_changed_isoformat = process_time...
[ "def", "as_dict", "(", "self", ")", ":", "if", "self", ".", "_last_changed", ":", "last_changed_isoformat", "=", "self", ".", "_last_changed", ".", "isoformat", "(", ")", "else", ":", "last_changed_isoformat", "=", "process_timestamp_to_utc_isoformat", "(", "self"...
[ 490, 4 ]
[ 515, 9 ]
python
en
['en', 'en', 'en']
True
LazyState.__eq__
(self, other)
Return the comparison.
Return the comparison.
def __eq__(self, other): """Return the comparison.""" return ( other.__class__ in [self.__class__, State] and self.entity_id == other.entity_id and self.state == other.state and self.attributes == other.attributes )
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "return", "(", "other", ".", "__class__", "in", "[", "self", ".", "__class__", ",", "State", "]", "and", "self", ".", "entity_id", "==", "other", ".", "entity_id", "and", "self", ".", "state", "==...
[ 517, 4 ]
[ 524, 9 ]
python
en
['en', 'it', 'en']
True
test_not_setup_views_if_onboarded
(hass, hass_storage)
Test if onboarding is done, we don't setup views.
Test if onboarding is done, we don't setup views.
async def test_not_setup_views_if_onboarded(hass, hass_storage): """Test if onboarding is done, we don't setup views.""" mock_storage(hass_storage, {"done": onboarding.STEPS}) with patch("homeassistant.components.onboarding.views.async_setup") as mock_setup: assert await async_setup_component(hass,...
[ "async", "def", "test_not_setup_views_if_onboarded", "(", "hass", ",", "hass_storage", ")", ":", "mock_storage", "(", "hass_storage", ",", "{", "\"done\"", ":", "onboarding", ".", "STEPS", "}", ")", "with", "patch", "(", "\"homeassistant.components.onboarding.views.as...
[ 13, 0 ]
[ 22, 46 ]
python
en
['en', 'en', 'en']
True
test_setup_views_if_not_onboarded
(hass)
Test if onboarding is not done, we setup views.
Test if onboarding is not done, we setup views.
async def test_setup_views_if_not_onboarded(hass): """Test if onboarding is not done, we setup views.""" with patch( "homeassistant.components.onboarding.views.async_setup", return_value=mock_coro(), ) as mock_setup: assert await async_setup_component(hass, "onboarding", {}) ass...
[ "async", "def", "test_setup_views_if_not_onboarded", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.onboarding.views.async_setup\"", ",", "return_value", "=", "mock_coro", "(", ")", ",", ")", "as", "mock_setup", ":", "assert", "await", "async...
[ 25, 0 ]
[ 36, 50 ]
python
en
['en', 'en', 'en']
True
test_is_onboarded
()
Test the is onboarded function.
Test the is onboarded function.
async def test_is_onboarded(): """Test the is onboarded function.""" hass = Mock() hass.data = {} assert onboarding.async_is_onboarded(hass) hass.data[onboarding.DOMAIN] = True assert onboarding.async_is_onboarded(hass) hass.data[onboarding.DOMAIN] = {"done": []} assert not onboarding...
[ "async", "def", "test_is_onboarded", "(", ")", ":", "hass", "=", "Mock", "(", ")", "hass", ".", "data", "=", "{", "}", "assert", "onboarding", ".", "async_is_onboarded", "(", "hass", ")", "hass", ".", "data", "[", "onboarding", ".", "DOMAIN", "]", "=",...
[ 39, 0 ]
[ 50, 50 ]
python
en
['en', 'en', 'en']
True
test_is_user_onboarded
()
Test the is onboarded function.
Test the is onboarded function.
async def test_is_user_onboarded(): """Test the is onboarded function.""" hass = Mock() hass.data = {} assert onboarding.async_is_user_onboarded(hass) hass.data[onboarding.DOMAIN] = True assert onboarding.async_is_user_onboarded(hass) hass.data[onboarding.DOMAIN] = {"done": []} assert...
[ "async", "def", "test_is_user_onboarded", "(", ")", ":", "hass", "=", "Mock", "(", ")", "hass", ".", "data", "=", "{", "}", "assert", "onboarding", ".", "async_is_user_onboarded", "(", "hass", ")", "hass", ".", "data", "[", "onboarding", ".", "DOMAIN", "...
[ 53, 0 ]
[ 64, 55 ]
python
en
['en', 'en', 'en']
True
test_having_owner_finishes_user_step
(hass, hass_storage)
If owner user already exists, mark user step as complete.
If owner user already exists, mark user step as complete.
async def test_having_owner_finishes_user_step(hass, hass_storage): """If owner user already exists, mark user step as complete.""" MockUser(is_owner=True).add_to_hass(hass) with patch( "homeassistant.components.onboarding.views.async_setup" ) as mock_setup, patch.object(onboarding, "STEPS", [o...
[ "async", "def", "test_having_owner_finishes_user_step", "(", "hass", ",", "hass_storage", ")", ":", "MockUser", "(", "is_owner", "=", "True", ")", ".", "add_to_hass", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.onboarding.views.async_setup\"", ...
[ 67, 0 ]
[ 81, 39 ]
python
en
['en', 'en', 'en']
True
test_migration
(hass, hass_storage)
Test migrating onboarding to new version.
Test migrating onboarding to new version.
async def test_migration(hass, hass_storage): """Test migrating onboarding to new version.""" hass_storage[onboarding.STORAGE_KEY] = {"version": 1, "data": {"done": ["user"]}} assert await async_setup_component(hass, "onboarding", {}) assert onboarding.async_is_onboarded(hass)
[ "async", "def", "test_migration", "(", "hass", ",", "hass_storage", ")", ":", "hass_storage", "[", "onboarding", ".", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"done\"", ":", "[", "\"user\"", "]", "}", "}", "asse...
[ 84, 0 ]
[ 88, 46 ]
python
en
['en', 'en', 'en']
True
test_form_user
(hass)
Test we can setup by the user.
Test we can setup by the user.
async def test_form_user(hass): """Test we can setup by the user.""" await setup.async_setup_component(hass, DOMAIN, {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == RESULT_TYPE_FORM assert not resul...
[ "async", "def", "test_form_user", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ...
[ 12, 0 ]
[ 37, 48 ]
python
en
['en', 'en', 'en']
True
test_form_user_only_once
(hass)
Test we can setup by the user only once.
Test we can setup by the user only once.
async def test_form_user_only_once(hass): """Test we can setup by the user only once.""" MockConfigEntry(domain=DOMAIN).add_to_hass(hass) await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_e...
[ "async", "def", "test_form_user_only_once", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ")", ".", "add_to_hass", "(", "hass", ")", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "...
[ 40, 0 ]
[ 48, 51 ]
python
en
['en', 'en', 'en']
True
test_connection_error
(hass)
Test we show an error when we have trouble connecting.
Test we show an error when we have trouble connecting.
async def test_connection_error(hass): """Test we show an error when we have trouble connecting.""" await setup.async_setup_component(hass, DOMAIN, {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassis...
[ "async", "def", "test_connection_error", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOM...
[ 51, 0 ]
[ 69, 58 ]
python
en
['en', 'en', 'en']
True
test_unknown_error
(hass)
Test we show an error when an unknown error occurs.
Test we show an error when an unknown error occurs.
async def test_unknown_error(hass): """Test we show an error when an unknown error occurs.""" await setup.async_setup_component(hass, DOMAIN, {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.c...
[ "async", "def", "test_unknown_error", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN...
[ 72, 0 ]
[ 90, 51 ]
python
en
['en', 'de', 'en']
True
IHCDevice.__init__
( self, ihc_controller, name, ihc_id: int, info: bool, product=None )
Initialize IHC attributes.
Initialize IHC attributes.
def __init__( self, ihc_controller, name, ihc_id: int, info: bool, product=None ) -> None: """Initialize IHC attributes.""" self.ihc_controller = ihc_controller self._name = name self.ihc_id = ihc_id self.info = info if product: self.ihc_name = pro...
[ "def", "__init__", "(", "self", ",", "ihc_controller", ",", "name", ",", "ihc_id", ":", "int", ",", "info", ":", "bool", ",", "product", "=", "None", ")", "->", "None", ":", "self", ".", "ihc_controller", "=", "ihc_controller", "self", ".", "_name", "=...
[ 12, 4 ]
[ 27, 34 ]
python
en
['en', 'co', 'en']
True
IHCDevice.async_added_to_hass
(self)
Add callback for IHC changes.
Add callback for IHC changes.
async def async_added_to_hass(self): """Add callback for IHC changes.""" self.ihc_controller.add_notify_event(self.ihc_id, self.on_ihc_change, True)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "ihc_controller", ".", "add_notify_event", "(", "self", ".", "ihc_id", ",", "self", ".", "on_ihc_change", ",", "True", ")" ]
[ 29, 4 ]
[ 31, 83 ]
python
en
['en', 'en', 'en']
True
IHCDevice.should_poll
(self)
No polling needed for IHC devices.
No polling needed for IHC devices.
def should_poll(self) -> bool: """No polling needed for IHC devices.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 34, 4 ]
[ 36, 20 ]
python
en
['en', 'en', 'en']
True
IHCDevice.name
(self)
Return the device name.
Return the device name.
def name(self): """Return the device name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 39, 4 ]
[ 41, 25 ]
python
en
['en', 'en', 'en']
True
IHCDevice.extra_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def extra_state_attributes(self): """Return the state attributes.""" if not self.info: return {} return { "ihc_id": self.ihc_id, "ihc_name": self.ihc_name, "ihc_note": self.ihc_note, "ihc_position": self.ihc_position, }
[ "def", "extra_state_attributes", "(", "self", ")", ":", "if", "not", "self", ".", "info", ":", "return", "{", "}", "return", "{", "\"ihc_id\"", ":", "self", ".", "ihc_id", ",", "\"ihc_name\"", ":", "self", ".", "ihc_name", ",", "\"ihc_note\"", ":", "self...
[ 44, 4 ]
[ 53, 9 ]
python
en
['en', 'en', 'en']
True
IHCDevice.on_ihc_change
(self, ihc_id, value)
Handle IHC resource change. Derived classes must overwrite this to do device specific stuff.
Handle IHC resource change.
def on_ihc_change(self, ihc_id, value): """Handle IHC resource change. Derived classes must overwrite this to do device specific stuff. """ raise NotImplementedError
[ "def", "on_ihc_change", "(", "self", ",", "ihc_id", ",", "value", ")", ":", "raise", "NotImplementedError" ]
[ 55, 4 ]
[ 60, 33 ]
python
en
['en', 'xh', 'en']
True
test_conditionerror_format
()
Test ConditionError stringifiers.
Test ConditionError stringifiers.
def test_conditionerror_format(): """Test ConditionError stringifiers.""" error1 = ConditionErrorMessage("test", "A test error") assert str(error1) == "In 'test' condition: A test error" error2 = ConditionErrorMessage("test", "Another error") assert str(error2) == "In 'test' condition: Another erro...
[ "def", "test_conditionerror_format", "(", ")", ":", "error1", "=", "ConditionErrorMessage", "(", "\"test\"", ",", "\"A test error\"", ")", "assert", "str", "(", "error1", ")", "==", "\"In 'test' condition: A test error\"", "error2", "=", "ConditionErrorMessage", "(", ...
[ 8, 0 ]
[ 44, 5 ]
python
en
['en', 'la', 'it']
False
mock_stream_settings
(hass)
Set the stream settings data in hass before each test.
Set the stream settings data in hass before each test.
def mock_stream_settings(hass): """Set the stream settings data in hass before each test.""" hass.data[DOMAIN] = { ATTR_SETTINGS: StreamSettings( ll_hls=False, min_segment_duration=TARGET_SEGMENT_DURATION_NON_LL_HLS - SEGMENT_DURATION_ADJUSTER, part_target...
[ "def", "mock_stream_settings", "(", "hass", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "ATTR_SETTINGS", ":", "StreamSettings", "(", "ll_hls", "=", "False", ",", "min_segment_duration", "=", "TARGET_SEGMENT_DURATION_NON_LL_HLS", "-", "SEGMENT_DURA...
[ 66, 0 ]
[ 77, 5 ]
python
en
['en', 'en', 'en']
True
async_decode_stream
(hass, packets, py_av=None)
Start a stream worker that decodes incoming stream packets into output segments.
Start a stream worker that decodes incoming stream packets into output segments.
async def async_decode_stream(hass, packets, py_av=None): """Start a stream worker that decodes incoming stream packets into output segments.""" stream = Stream(hass, STREAM_SOURCE, {}) stream.add_provider(HLS_PROVIDER) if not py_av: py_av = MockPyAv() py_av.container.packets = iter(packets...
[ "async", "def", "async_decode_stream", "(", "hass", ",", "packets", ",", "py_av", "=", "None", ")", ":", "stream", "=", "Stream", "(", "hass", ",", "STREAM_SOURCE", ",", "{", "}", ")", "stream", ".", "add_provider", "(", "HLS_PROVIDER", ")", "if", "not",...
[ 249, 0 ]
[ 266, 31 ]
python
en
['en', 'en', 'en']
True
test_stream_open_fails
(hass)
Test failure on stream open.
Test failure on stream open.
async def test_stream_open_fails(hass): """Test failure on stream open.""" stream = Stream(hass, STREAM_SOURCE, {}) stream.add_provider(HLS_PROVIDER) with patch("av.open") as av_open: av_open.side_effect = av.error.InvalidDataError(-2, "error") segment_buffer = SegmentBuffer(hass, stream...
[ "async", "def", "test_stream_open_fails", "(", "hass", ")", ":", "stream", "=", "Stream", "(", "hass", ",", "STREAM_SOURCE", ",", "{", "}", ")", "stream", ".", "add_provider", "(", "HLS_PROVIDER", ")", "with", "patch", "(", "\"av.open\"", ")", "as", "av_op...
[ 269, 0 ]
[ 278, 36 ]
python
en
['en', 'fi', 'en']
True
test_stream_worker_success
(hass)
Test a short stream that ends and outputs everything correctly.
Test a short stream that ends and outputs everything correctly.
async def test_stream_worker_success(hass): """Test a short stream that ends and outputs everything correctly.""" decoded_stream = await async_decode_stream( hass, PacketSequence(TEST_SEQUENCE_LENGTH) ) segments = decoded_stream.segments complete_segments = decoded_stream.complete_segments ...
[ "async", "def", "test_stream_worker_success", "(", "hass", ")", ":", "decoded_stream", "=", "await", "async_decode_stream", "(", "hass", ",", "PacketSequence", "(", "TEST_SEQUENCE_LENGTH", ")", ")", "segments", "=", "decoded_stream", ".", "segments", "complete_segment...
[ 281, 0 ]
[ 298, 49 ]
python
en
['en', 'en', 'en']
True
test_skip_out_of_order_packet
(hass)
Skip a single out of order packet.
Skip a single out of order packet.
async def test_skip_out_of_order_packet(hass): """Skip a single out of order packet.""" packets = list(PacketSequence(TEST_SEQUENCE_LENGTH)) # for this test, make sure the out of order index doesn't happen on a keyframe out_of_order_index = OUT_OF_ORDER_PACKET_INDEX if packets[out_of_order_index].is...
[ "async", "def", "test_skip_out_of_order_packet", "(", "hass", ")", ":", "packets", "=", "list", "(", "PacketSequence", "(", "TEST_SEQUENCE_LENGTH", ")", ")", "# for this test, make sure the out of order index doesn't happen on a keyframe", "out_of_order_index", "=", "OUT_OF_ORD...
[ 301, 0 ]
[ 338, 49 ]
python
en
['en', 'en', 'en']
True
test_discard_old_packets
(hass)
Skip a series of out of order packets.
Skip a series of out of order packets.
async def test_discard_old_packets(hass): """Skip a series of out of order packets.""" packets = list(PacketSequence(TEST_SEQUENCE_LENGTH)) # Packets after this one are considered out of order packets[OUT_OF_ORDER_PACKET_INDEX - 1].dts = 9090 decoded_stream = await async_decode_stream(hass, packet...
[ "async", "def", "test_discard_old_packets", "(", "hass", ")", ":", "packets", "=", "list", "(", "PacketSequence", "(", "TEST_SEQUENCE_LENGTH", ")", ")", "# Packets after this one are considered out of order", "packets", "[", "OUT_OF_ORDER_PACKET_INDEX", "-", "1", "]", "...
[ 341, 0 ]
[ 360, 49 ]
python
en
['en', 'en', 'en']
True
test_packet_overflow
(hass)
Packet is too far out of order, and looks like overflow, ending stream early.
Packet is too far out of order, and looks like overflow, ending stream early.
async def test_packet_overflow(hass): """Packet is too far out of order, and looks like overflow, ending stream early.""" packets = list(PacketSequence(TEST_SEQUENCE_LENGTH)) # Packet is so far out of order, exceeds max gap and looks like overflow packets[OUT_OF_ORDER_PACKET_INDEX].dts = -9000000 ...
[ "async", "def", "test_packet_overflow", "(", "hass", ")", ":", "packets", "=", "list", "(", "PacketSequence", "(", "TEST_SEQUENCE_LENGTH", ")", ")", "# Packet is so far out of order, exceeds max gap and looks like overflow", "packets", "[", "OUT_OF_ORDER_PACKET_INDEX", "]", ...
[ 363, 0 ]
[ 382, 49 ]
python
en
['en', 'en', 'en']
True
test_skip_initial_bad_packets
(hass)
Tests a small number of initial "bad" packets with missing dts.
Tests a small number of initial "bad" packets with missing dts.
async def test_skip_initial_bad_packets(hass): """Tests a small number of initial "bad" packets with missing dts.""" num_packets = LONGER_TEST_SEQUENCE_LENGTH packets = list(PacketSequence(num_packets)) num_bad_packets = MAX_MISSING_DTS - 1 for i in range(0, num_bad_packets): packets[i].dts...
[ "async", "def", "test_skip_initial_bad_packets", "(", "hass", ")", ":", "num_packets", "=", "LONGER_TEST_SEQUENCE_LENGTH", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")", "num_bad_packets", "=", "MAX_MISSING_DTS", "-", "1", "for", "i", ...
[ 385, 0 ]
[ 412, 49 ]
python
en
['en', 'en', 'en']
True
test_too_many_initial_bad_packets_fails
(hass)
Test initial bad packets are too high, causing it to never start.
Test initial bad packets are too high, causing it to never start.
async def test_too_many_initial_bad_packets_fails(hass): """Test initial bad packets are too high, causing it to never start.""" num_packets = LONGER_TEST_SEQUENCE_LENGTH packets = list(PacketSequence(num_packets)) num_bad_packets = MAX_MISSING_DTS + 1 for i in range(0, num_bad_packets): pa...
[ "async", "def", "test_too_many_initial_bad_packets_fails", "(", "hass", ")", ":", "num_packets", "=", "LONGER_TEST_SEQUENCE_LENGTH", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")", "num_bad_packets", "=", "MAX_MISSING_DTS", "+", "1", "for"...
[ 415, 0 ]
[ 428, 49 ]
python
en
['en', 'en', 'en']
True
test_skip_missing_dts
(hass)
Test packets in the middle of the stream missing DTS are skipped.
Test packets in the middle of the stream missing DTS are skipped.
async def test_skip_missing_dts(hass): """Test packets in the middle of the stream missing DTS are skipped.""" num_packets = LONGER_TEST_SEQUENCE_LENGTH packets = list(PacketSequence(num_packets)) bad_packet_start = int(LONGER_TEST_SEQUENCE_LENGTH / 2) num_bad_packets = MAX_MISSING_DTS - 1 for ...
[ "async", "def", "test_skip_missing_dts", "(", "hass", ")", ":", "num_packets", "=", "LONGER_TEST_SEQUENCE_LENGTH", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")", "bad_packet_start", "=", "int", "(", "LONGER_TEST_SEQUENCE_LENGTH", "/", "...
[ 431, 0 ]
[ 452, 49 ]
python
en
['en', 'en', 'en']
True
test_too_many_bad_packets
(hass)
Test bad packets are too many, causing it to end.
Test bad packets are too many, causing it to end.
async def test_too_many_bad_packets(hass): """Test bad packets are too many, causing it to end.""" num_packets = LONGER_TEST_SEQUENCE_LENGTH packets = list(PacketSequence(num_packets)) bad_packet_start = int(LONGER_TEST_SEQUENCE_LENGTH / 2) num_bad_packets = MAX_MISSING_DTS + 1 for i in range(b...
[ "async", "def", "test_too_many_bad_packets", "(", "hass", ")", ":", "num_packets", "=", "LONGER_TEST_SEQUENCE_LENGTH", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")", "bad_packet_start", "=", "int", "(", "LONGER_TEST_SEQUENCE_LENGTH", "/",...
[ 455, 0 ]
[ 469, 49 ]
python
en
['en', 'en', 'en']
True
test_no_video_stream
(hass)
Test no video stream in the container means no resulting output.
Test no video stream in the container means no resulting output.
async def test_no_video_stream(hass): """Test no video stream in the container means no resulting output.""" py_av = MockPyAv(video=False) decoded_stream = await async_decode_stream( hass, PacketSequence(TEST_SEQUENCE_LENGTH), py_av=py_av ) # Note: This failure scenario does not output an e...
[ "async", "def", "test_no_video_stream", "(", "hass", ")", ":", "py_av", "=", "MockPyAv", "(", "video", "=", "False", ")", "decoded_stream", "=", "await", "async_decode_stream", "(", "hass", ",", "PacketSequence", "(", "TEST_SEQUENCE_LENGTH", ")", ",", "py_av", ...
[ 472, 0 ]
[ 483, 49 ]
python
en
['en', 'en', 'en']
True
test_audio_packets_not_found
(hass)
Set up an audio stream, but no audio packets are found.
Set up an audio stream, but no audio packets are found.
async def test_audio_packets_not_found(hass): """Set up an audio stream, but no audio packets are found.""" py_av = MockPyAv(audio=True) num_packets = PACKETS_TO_WAIT_FOR_AUDIO + 1 packets = PacketSequence(num_packets) # Contains only video packets decoded_stream = await async_decode_stream(hass,...
[ "async", "def", "test_audio_packets_not_found", "(", "hass", ")", ":", "py_av", "=", "MockPyAv", "(", "audio", "=", "True", ")", "num_packets", "=", "PACKETS_TO_WAIT_FOR_AUDIO", "+", "1", "packets", "=", "PacketSequence", "(", "num_packets", ")", "# Contains only ...
[ 486, 0 ]
[ 497, 49 ]
python
en
['en', 'en', 'en']
True
test_adts_aac_audio
(hass)
Set up an ADTS AAC audio stream and disable audio.
Set up an ADTS AAC audio stream and disable audio.
async def test_adts_aac_audio(hass): """Set up an ADTS AAC audio stream and disable audio.""" py_av = MockPyAv(audio=True) num_packets = PACKETS_TO_WAIT_FOR_AUDIO + 1 packets = list(PacketSequence(num_packets)) packets[1].stream = AUDIO_STREAM packets[1].dts = int(packets[0].dts / VIDEO_FRAME_R...
[ "async", "def", "test_adts_aac_audio", "(", "hass", ")", ":", "py_av", "=", "MockPyAv", "(", "audio", "=", "True", ")", "num_packets", "=", "PACKETS_TO_WAIT_FOR_AUDIO", "+", "1", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")", "p...
[ 500, 0 ]
[ 516, 63 ]
python
en
['en', 'en', 'en']
True
test_audio_is_first_packet
(hass)
Set up an audio stream and audio packet is the first packet in the stream.
Set up an audio stream and audio packet is the first packet in the stream.
async def test_audio_is_first_packet(hass): """Set up an audio stream and audio packet is the first packet in the stream.""" py_av = MockPyAv(audio=True) num_packets = PACKETS_TO_WAIT_FOR_AUDIO + 1 packets = list(PacketSequence(num_packets)) # Pair up an audio packet for each video packet packe...
[ "async", "def", "test_audio_is_first_packet", "(", "hass", ")", ":", "py_av", "=", "MockPyAv", "(", "audio", "=", "True", ")", "num_packets", "=", "PACKETS_TO_WAIT_FOR_AUDIO", "+", "1", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")...
[ 519, 0 ]
[ 539, 49 ]
python
en
['en', 'en', 'en']
True
test_audio_packets_found
(hass)
Set up an audio stream and audio packets are found at the start of the stream.
Set up an audio stream and audio packets are found at the start of the stream.
async def test_audio_packets_found(hass): """Set up an audio stream and audio packets are found at the start of the stream.""" py_av = MockPyAv(audio=True) num_packets = PACKETS_TO_WAIT_FOR_AUDIO + 1 packets = list(PacketSequence(num_packets)) packets[1].stream = AUDIO_STREAM packets[1].dts = i...
[ "async", "def", "test_audio_packets_found", "(", "hass", ")", ":", "py_av", "=", "MockPyAv", "(", "audio", "=", "True", ")", "num_packets", "=", "PACKETS_TO_WAIT_FOR_AUDIO", "+", "1", "packets", "=", "list", "(", "PacketSequence", "(", "num_packets", ")", ")",...
[ 542, 0 ]
[ 557, 49 ]
python
en
['en', 'en', 'en']
True
test_pts_out_of_order
(hass)
Test pts can be out of order and still be valid.
Test pts can be out of order and still be valid.
async def test_pts_out_of_order(hass): """Test pts can be out of order and still be valid.""" # Create a sequence of packets with some out of order pts packets = list(PacketSequence(TEST_SEQUENCE_LENGTH)) for i, _ in enumerate(packets): if i % PACKETS_PER_SEGMENT == 1: packets[i].pt...
[ "async", "def", "test_pts_out_of_order", "(", "hass", ")", ":", "# Create a sequence of packets with some out of order pts", "packets", "=", "list", "(", "PacketSequence", "(", "TEST_SEQUENCE_LENGTH", ")", ")", "for", "i", ",", "_", "in", "enumerate", "(", "packets", ...
[ 560, 0 ]
[ 582, 49 ]
python
en
['en', 'en', 'en']
True
test_stream_stopped_while_decoding
(hass)
Tests that worker quits when stop() is called while decodign.
Tests that worker quits when stop() is called while decodign.
async def test_stream_stopped_while_decoding(hass): """Tests that worker quits when stop() is called while decodign.""" # Add some synchronization so that the test can pause the background # worker. When the worker is stopped, the test invokes stop() which # will cause the worker thread to exit once it ...
[ "async", "def", "test_stream_stopped_while_decoding", "(", "hass", ")", ":", "# Add some synchronization so that the test can pause the background", "# worker. When the worker is stopped, the test invokes stop() which", "# will cause the worker thread to exit once it enters the decode", "# loop"...
[ 585, 0 ]
[ 613, 21 ]
python
en
['en', 'en', 'en']
True
test_update_stream_source
(hass)
Tests that the worker is re-invoked when the stream source is updated.
Tests that the worker is re-invoked when the stream source is updated.
async def test_update_stream_source(hass): """Tests that the worker is re-invoked when the stream source is updated.""" worker_open = threading.Event() worker_wake = threading.Event() stream = Stream(hass, STREAM_SOURCE, {}) stream.add_provider(HLS_PROVIDER) # Note that keepalive is not set her...
[ "async", "def", "test_update_stream_source", "(", "hass", ")", ":", "worker_open", "=", "threading", ".", "Event", "(", ")", "worker_wake", "=", "threading", ".", "Event", "(", ")", "stream", "=", "Stream", "(", "hass", ",", "STREAM_SOURCE", ",", "{", "}",...
[ 616, 0 ]
[ 656, 21 ]
python
en
['en', 'en', 'en']
True
test_worker_log
(hass, caplog)
Test that the worker logs the url without username and password.
Test that the worker logs the url without username and password.
async def test_worker_log(hass, caplog): """Test that the worker logs the url without username and password.""" stream = Stream(hass, "https://abcd:efgh@foo.bar", {}) stream.add_provider(HLS_PROVIDER) with patch("av.open") as av_open: av_open.side_effect = av.error.InvalidDataError(-2, "error") ...
[ "async", "def", "test_worker_log", "(", "hass", ",", "caplog", ")", ":", "stream", "=", "Stream", "(", "hass", ",", "\"https://abcd:efgh@foo.bar\"", ",", "{", "}", ")", "stream", ".", "add_provider", "(", "HLS_PROVIDER", ")", "with", "patch", "(", "\"av.open...
[ 659, 0 ]
[ 671, 53 ]
python
en
['en', 'en', 'en']
True
test_durations
(hass, record_worker_sync)
Test that the duration metadata matches the media.
Test that the duration metadata matches the media.
async def test_durations(hass, record_worker_sync): """Test that the duration metadata matches the media.""" await async_setup_component( hass, "stream", { "stream": { CONF_LL_HLS: True, CONF_SEGMENT_DURATION: SEGMENT_DURATION, ...
[ "async", "def", "test_durations", "(", "hass", ",", "record_worker_sync", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "CONF_LL_HLS", ":", "True", ",", "CONF_SEGMENT_DURATION", ":", "SEGMENT_DURATION...
[ 674, 0 ]
[ 722, 17 ]
python
en
['en', 'en', 'en']
True
test_has_keyframe
(hass, record_worker_sync)
Test that the has_keyframe metadata matches the media.
Test that the has_keyframe metadata matches the media.
async def test_has_keyframe(hass, record_worker_sync): """Test that the has_keyframe metadata matches the media.""" await async_setup_component( hass, "stream", { "stream": { CONF_LL_HLS: True, CONF_SEGMENT_DURATION: SEGMENT_DURATION, ...
[ "async", "def", "test_has_keyframe", "(", "hass", ",", "record_worker_sync", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "CONF_LL_HLS", ":", "True", ",", "CONF_SEGMENT_DURATION", ":", "SEGMENT_DURAT...
[ 725, 0 ]
[ 763, 17 ]
python
en
['en', 'el-Latn', 'en']
True
FakeAvInputStream.__init__
(self, name, rate)
Initialize the stream.
Initialize the stream.
def __init__(self, name, rate): """Initialize the stream.""" self.name = name self.time_base = fractions.Fraction(1, rate) self.profile = "ignored-profile" class FakeCodec: name = "aac" self.codec = FakeCodec()
[ "def", "__init__", "(", "self", ",", "name", ",", "rate", ")", ":", "self", ".", "name", "=", "name", "self", ".", "time_base", "=", "fractions", ".", "Fraction", "(", "1", ",", "rate", ")", "self", ".", "profile", "=", "\"ignored-profile\"", "class", ...
[ 83, 4 ]
[ 92, 32 ]
python
en
['en', 'en', 'en']
True
FakeAvInputStream.__str__
(self)
Return a stream name for debugging.
Return a stream name for debugging.
def __str__(self) -> str: """Return a stream name for debugging.""" return f"FakePyAvStream<{self.name}, {self.time_base}>"
[ "def", "__str__", "(", "self", ")", "->", "str", ":", "return", "f\"FakePyAvStream<{self.name}, {self.time_base}>\"" ]
[ 94, 4 ]
[ 96, 63 ]
python
en
['es', 'en', 'en']
True
PacketSequence.__init__
(self, num_packets)
Initialize the sequence with the number of packets it provides.
Initialize the sequence with the number of packets it provides.
def __init__(self, num_packets): """Initialize the sequence with the number of packets it provides.""" self.packet = 0 self.num_packets = num_packets
[ "def", "__init__", "(", "self", ",", "num_packets", ")", ":", "self", ".", "packet", "=", "0", "self", ".", "num_packets", "=", "num_packets" ]
[ 112, 4 ]
[ 115, 38 ]
python
en
['en', 'en', 'en']
True
PacketSequence.__iter__
(self)
Reset the sequence.
Reset the sequence.
def __iter__(self): """Reset the sequence.""" self.packet = 0 return self
[ "def", "__iter__", "(", "self", ")", ":", "self", ".", "packet", "=", "0", "return", "self" ]
[ 117, 4 ]
[ 120, 19 ]
python
en
['en', 'en', 'en']
True
PacketSequence.__next__
(self)
Return the next packet.
Return the next packet.
def __next__(self): """Return the next packet.""" if self.packet >= self.num_packets: raise StopIteration self.packet += 1 class FakePacket(bytearray): # Be a bytearray so that memoryview works def __init__(self): super().__init__(3) ...
[ "def", "__next__", "(", "self", ")", ":", "if", "self", ".", "packet", ">=", "self", ".", "num_packets", ":", "raise", "StopIteration", "self", ".", "packet", "+=", "1", "class", "FakePacket", "(", "bytearray", ")", ":", "# Be a bytearray so that memoryview wo...
[ 122, 4 ]
[ 145, 27 ]
python
en
['en', 'en', 'en']
True
FakePyAvContainer.__init__
(self, video_stream, audio_stream)
Initialize the fake container.
Initialize the fake container.
def __init__(self, video_stream, audio_stream): """Initialize the fake container.""" # Tests can override this to trigger different worker behavior self.packets = PacketSequence(0) class FakePyAvStreams: video = [video_stream] if video_stream else [] audio = [aud...
[ "def", "__init__", "(", "self", ",", "video_stream", ",", "audio_stream", ")", ":", "# Tests can override this to trigger different worker behavior", "self", ".", "packets", "=", "PacketSequence", "(", "0", ")", "class", "FakePyAvStreams", ":", "video", "=", "[", "v...
[ 151, 4 ]
[ 165, 38 ]
python
en
['en', 'en', 'en']
True
FakePyAvContainer.demux
(self, streams)
Decode the streams from container, and return a packet sequence.
Decode the streams from container, and return a packet sequence.
def demux(self, streams): """Decode the streams from container, and return a packet sequence.""" return self.packets
[ "def", "demux", "(", "self", ",", "streams", ")", ":", "return", "self", ".", "packets" ]
[ 167, 4 ]
[ 169, 27 ]
python
en
['en', 'en', 'en']
True
FakePyAvContainer.close
(self)
Close the container.
Close the container.
def close(self): """Close the container.""" return
[ "def", "close", "(", "self", ")", ":", "return" ]
[ 171, 4 ]
[ 173, 14 ]
python
en
['en', 'en', 'en']
True
FakePyAvBuffer.__init__
(self)
Initialize the FakePyAvBuffer.
Initialize the FakePyAvBuffer.
def __init__(self): """Initialize the FakePyAvBuffer.""" self.segments = [] self.audio_packets = [] self.video_packets = [] self.memory_file: io.BytesIO | None = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "segments", "=", "[", "]", "self", ".", "audio_packets", "=", "[", "]", "self", ".", "video_packets", "=", "[", "]", "self", ".", "memory_file", ":", "io", ".", "BytesIO", "|", "None", "=", "No...
[ 179, 4 ]
[ 184, 50 ]
python
en
['en', 'zu', 'en']
True
FakePyAvBuffer.add_stream
(self, template=None)
Create an output buffer that captures packets for test to examine.
Create an output buffer that captures packets for test to examine.
def add_stream(self, template=None): """Create an output buffer that captures packets for test to examine.""" class FakeAvOutputStream: def __init__(self, capture_packets): self.capture_packets = capture_packets def close(self): return ...
[ "def", "add_stream", "(", "self", ",", "template", "=", "None", ")", ":", "class", "FakeAvOutputStream", ":", "def", "__init__", "(", "self", ",", "capture_packets", ")", ":", "self", ".", "capture_packets", "=", "capture_packets", "def", "close", "(", "self...
[ 186, 4 ]
[ 205, 53 ]
python
en
['en', 'en', 'en']
True
FakePyAvBuffer.mux
(self, packet)
Capture a packet for tests to examine.
Capture a packet for tests to examine.
def mux(self, packet): """Capture a packet for tests to examine.""" # Forward to appropriate FakeStream packet.stream.mux(packet) # Make new init/part data available to the worker self.memory_file.write(b"0")
[ "def", "mux", "(", "self", ",", "packet", ")", ":", "# Forward to appropriate FakeStream", "packet", ".", "stream", ".", "mux", "(", "packet", ")", "# Make new init/part data available to the worker", "self", ".", "memory_file", ".", "write", "(", "b\"0\"", ")" ]
[ 207, 4 ]
[ 212, 36 ]
python
en
['en', 'en', 'en']
True
FakePyAvBuffer.close
(self)
Close the buffer.
Close the buffer.
def close(self): """Close the buffer.""" # Make the final segment data available to the worker self.memory_file.write(b"0")
[ "def", "close", "(", "self", ")", ":", "# Make the final segment data available to the worker", "self", ".", "memory_file", ".", "write", "(", "b\"0\"", ")" ]
[ 214, 4 ]
[ 217, 36 ]
python
en
['en', 'zh', 'en']
True
FakePyAvBuffer.capture_output_segment
(self, segment)
Capture the output segment for tests to inspect.
Capture the output segment for tests to inspect.
def capture_output_segment(self, segment): """Capture the output segment for tests to inspect.""" self.segments.append(segment)
[ "def", "capture_output_segment", "(", "self", ",", "segment", ")", ":", "self", ".", "segments", ".", "append", "(", "segment", ")" ]
[ 219, 4 ]
[ 221, 37 ]
python
en
['en', 'en', 'en']
True
FakePyAvBuffer.complete_segments
(self)
Return only the complete segments.
Return only the complete segments.
def complete_segments(self): """Return only the complete segments.""" return [segment for segment in self.segments if segment.complete]
[ "def", "complete_segments", "(", "self", ")", ":", "return", "[", "segment", "for", "segment", "in", "self", ".", "segments", "if", "segment", ".", "complete", "]" ]
[ 224, 4 ]
[ 226, 73 ]
python
en
['en', 'en', 'en']
True
MockPyAv.__init__
(self, video=True, audio=False)
Initialize the MockPyAv.
Initialize the MockPyAv.
def __init__(self, video=True, audio=False): """Initialize the MockPyAv.""" video_stream = VIDEO_STREAM if video else None audio_stream = AUDIO_STREAM if audio else None self.container = FakePyAvContainer( video_stream=video_stream, audio_stream=audio_stream ) ...
[ "def", "__init__", "(", "self", ",", "video", "=", "True", ",", "audio", "=", "False", ")", ":", "video_stream", "=", "VIDEO_STREAM", "if", "video", "else", "None", "audio_stream", "=", "AUDIO_STREAM", "if", "audio", "else", "None", "self", ".", "container...
[ 232, 4 ]
[ 239, 46 ]
python
en
['en', 'zu', 'en']
True
MockPyAv.open
(self, stream_source, *args, **kwargs)
Return a stream or buffer depending on args.
Return a stream or buffer depending on args.
def open(self, stream_source, *args, **kwargs): """Return a stream or buffer depending on args.""" if isinstance(stream_source, io.BytesIO): self.capture_buffer.memory_file = stream_source return self.capture_buffer return self.container
[ "def", "open", "(", "self", ",", "stream_source", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "stream_source", ",", "io", ".", "BytesIO", ")", ":", "self", ".", "capture_buffer", ".", "memory_file", "=", "stream_source",...
[ 241, 4 ]
[ 246, 29 ]
python
en
['en', 'lb', 'en']
True
NewDateTime.now
(cls, *args, **kwargs)
Overload datetime.datetime.now.
Overload datetime.datetime.now.
def now(cls, *args, **kwargs): # pylint: disable=signature-differs """Overload datetime.datetime.now.""" return cls(2020, 4, 25, 12, tzinfo=datetime.timezone.utc)
[ "def", "now", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=signature-differs", "return", "cls", "(", "2020", ",", "4", ",", "25", ",", "12", ",", "tzinfo", "=", "datetime", ".", "timezone", ".", "utc", ")" ]
[ 9, 4 ]
[ 11, 65 ]
python
en
['en', 'en', 'en']
False
async_setup
(hass, config)
Component setup, do nothing.
Component setup, do nothing.
async def async_setup(hass, config): """Component setup, do nothing.""" if DOMAIN not in config: return True for device_id in config[DOMAIN]: conf = config[DOMAIN][device_id] hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, ...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "for", "device_id", "in", "config", "[", "DOMAIN", "]", ":", "conf", "=", "config", "[", "DOMAIN", "]", "[", "device_id",...
[ 57, 0 ]
[ 71, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up the HLK-SW16 switch.
Set up the HLK-SW16 switch.
async def async_setup_entry(hass, entry): """Set up the HLK-SW16 switch.""" hass.data.setdefault(DOMAIN, {}) host = entry.data[CONF_HOST] port = entry.data[CONF_PORT] address = f"{host}:{port}" hass.data[DOMAIN][entry.entry_id] = {} @callback def disconnected(): """Schedule rec...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "host", "=", "entry", ".", "data", "[", "CONF_HOST", "]", "port", "=", "entry", ".", "data", "[", "...
[ 74, 0 ]
[ 121, 15 ]
python
en
['en', 'en', 'en']
True