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
_GlobalTaskContext._start_timer
(self)
Start timeout handler.
Start timeout handler.
def _start_timer(self) -> None: """Start timeout handler.""" if self._timeout_handler: return self._expiration_time = self._loop.time() + self._time_left self._timeout_handler = self._loop.call_at( self._expiration_time, self._on_timeout )
[ "def", "_start_timer", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_timeout_handler", ":", "return", "self", ".", "_expiration_time", "=", "self", ".", "_loop", ".", "time", "(", ")", "+", "self", ".", "_time_left", "self", ".", "_timeout_ha...
[ 195, 4 ]
[ 203, 9 ]
python
en
['en', 'jv', 'en']
True
_GlobalTaskContext._stop_timer
(self)
Stop zone timer.
Stop zone timer.
def _stop_timer(self) -> None: """Stop zone timer.""" if self._timeout_handler is None: return self._timeout_handler.cancel() self._timeout_handler = None # Calculate new timeout assert self._expiration_time self._time_left = self._expiration_time - s...
[ "def", "_stop_timer", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_timeout_handler", "is", "None", ":", "return", "self", ".", "_timeout_handler", ".", "cancel", "(", ")", "self", ".", "_timeout_handler", "=", "None", "# Calculate new timeout", ...
[ 205, 4 ]
[ 214, 67 ]
python
en
['pl', 'en', 'en']
True
_GlobalTaskContext._on_timeout
(self)
Process timeout.
Process timeout.
def _on_timeout(self) -> None: """Process timeout.""" self._state = _State.TIMEOUT self._timeout_handler = None # Reset timer if zones are running if not self._manager.zones_done: asyncio.create_task(self._on_wait()) else: self._cancel_task()
[ "def", "_on_timeout", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "_State", ".", "TIMEOUT", "self", ".", "_timeout_handler", "=", "None", "# Reset timer if zones are running", "if", "not", "self", ".", "_manager", ".", "zones_done", ":", ...
[ 216, 4 ]
[ 225, 31 ]
python
en
['en', 'ny', 'en']
False
_GlobalTaskContext._cancel_task
(self)
Cancel own task.
Cancel own task.
def _cancel_task(self) -> None: """Cancel own task.""" if self._task.done(): return self._task.cancel()
[ "def", "_cancel_task", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_task", ".", "done", "(", ")", ":", "return", "self", ".", "_task", ".", "cancel", "(", ")" ]
[ 227, 4 ]
[ 231, 27 ]
python
en
['en', 'cy', 'en']
True
_GlobalTaskContext.pause
(self)
Pause timers while it freeze.
Pause timers while it freeze.
def pause(self) -> None: """Pause timers while it freeze.""" self._stop_timer()
[ "def", "pause", "(", "self", ")", "->", "None", ":", "self", ".", "_stop_timer", "(", ")" ]
[ 233, 4 ]
[ 235, 26 ]
python
en
['en', 'en', 'en']
True
_GlobalTaskContext.reset
(self)
Reset timer after freeze.
Reset timer after freeze.
def reset(self) -> None: """Reset timer after freeze.""" self._start_timer()
[ "def", "reset", "(", "self", ")", "->", "None", ":", "self", ".", "_start_timer", "(", ")" ]
[ 237, 4 ]
[ 239, 27 ]
python
da
['da', 'su', 'en']
False
_GlobalTaskContext._on_wait
(self)
Wait until zones are done.
Wait until zones are done.
async def _on_wait(self) -> None: """Wait until zones are done.""" await self._wait_zone.wait() await asyncio.sleep(self._cool_down) # Allow context switch if not self.state == _State.TIMEOUT: return self._cancel_task()
[ "async", "def", "_on_wait", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_wait_zone", ".", "wait", "(", ")", "await", "asyncio", ".", "sleep", "(", "self", ".", "_cool_down", ")", "# Allow context switch", "if", "not", "self", ".", "state"...
[ 241, 4 ]
[ 247, 27 ]
python
en
['en', 'en', 'en']
True
_ZoneTaskContext.__init__
( self, zone: _ZoneTimeoutManager, task: asyncio.Task[Any], timeout: float, )
Initialize internal timeout context manager.
Initialize internal timeout context manager.
def __init__( self, zone: _ZoneTimeoutManager, task: asyncio.Task[Any], timeout: float, ) -> None: """Initialize internal timeout context manager.""" self._loop: asyncio.AbstractEventLoop = asyncio.get_running_loop() self._zone: _ZoneTimeoutManager = zone ...
[ "def", "__init__", "(", "self", ",", "zone", ":", "_ZoneTimeoutManager", ",", "task", ":", "asyncio", ".", "Task", "[", "Any", "]", ",", "timeout", ":", "float", ",", ")", "->", "None", ":", "self", ".", "_loop", ":", "asyncio", ".", "AbstractEventLoop...
[ 253, 4 ]
[ 266, 62 ]
python
en
['en', 'en', 'en']
True
_ZoneTaskContext.state
(self)
Return state of the Zone task.
Return state of the Zone task.
def state(self) -> _State: """Return state of the Zone task.""" return self._state
[ "def", "state", "(", "self", ")", "->", "_State", ":", "return", "self", ".", "_state" ]
[ 269, 4 ]
[ 271, 26 ]
python
en
['en', 'en', 'en']
True
_ZoneTaskContext._start_timer
(self)
Start timeout handler.
Start timeout handler.
def _start_timer(self) -> None: """Start timeout handler.""" if self._timeout_handler: return self._expiration_time = self._loop.time() + self._time_left self._timeout_handler = self._loop.call_at( self._expiration_time, self._on_timeout )
[ "def", "_start_timer", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_timeout_handler", ":", "return", "self", ".", "_expiration_time", "=", "self", ".", "_loop", ".", "time", "(", ")", "+", "self", ".", "_time_left", "self", ".", "_timeout_ha...
[ 299, 4 ]
[ 307, 9 ]
python
en
['en', 'jv', 'en']
True
_ZoneTaskContext._stop_timer
(self)
Stop zone timer.
Stop zone timer.
def _stop_timer(self) -> None: """Stop zone timer.""" if self._timeout_handler is None: return self._timeout_handler.cancel() self._timeout_handler = None # Calculate new timeout assert self._expiration_time self._time_left = self._expiration_time - s...
[ "def", "_stop_timer", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_timeout_handler", "is", "None", ":", "return", "self", ".", "_timeout_handler", ".", "cancel", "(", ")", "self", ".", "_timeout_handler", "=", "None", "# Calculate new timeout", ...
[ 309, 4 ]
[ 318, 67 ]
python
en
['pl', 'en', 'en']
True
_ZoneTaskContext._on_timeout
(self)
Process timeout.
Process timeout.
def _on_timeout(self) -> None: """Process timeout.""" self._state = _State.TIMEOUT self._timeout_handler = None # Timeout if self._task.done(): return self._task.cancel()
[ "def", "_on_timeout", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "_State", ".", "TIMEOUT", "self", ".", "_timeout_handler", "=", "None", "# Timeout", "if", "self", ".", "_task", ".", "done", "(", ")", ":", "return", "self", ".", ...
[ 320, 4 ]
[ 328, 27 ]
python
en
['en', 'ny', 'en']
False
_ZoneTaskContext.pause
(self)
Pause timers while it freeze.
Pause timers while it freeze.
def pause(self) -> None: """Pause timers while it freeze.""" self._stop_timer()
[ "def", "pause", "(", "self", ")", "->", "None", ":", "self", ".", "_stop_timer", "(", ")" ]
[ 330, 4 ]
[ 332, 26 ]
python
en
['en', 'en', 'en']
True
_ZoneTaskContext.reset
(self)
Reset timer after freeze.
Reset timer after freeze.
def reset(self) -> None: """Reset timer after freeze.""" self._start_timer()
[ "def", "reset", "(", "self", ")", "->", "None", ":", "self", ".", "_start_timer", "(", ")" ]
[ 334, 4 ]
[ 336, 27 ]
python
da
['da', 'su', 'en']
False
_ZoneTimeoutManager.__init__
(self, manager: TimeoutManager, zone: str)
Initialize internal timeout context manager.
Initialize internal timeout context manager.
def __init__(self, manager: TimeoutManager, zone: str) -> None: """Initialize internal timeout context manager.""" self._manager: TimeoutManager = manager self._zone: str = zone self._tasks: List[_ZoneTaskContext] = [] self._freezes: List[_ZoneFreezeContext] = []
[ "def", "__init__", "(", "self", ",", "manager", ":", "TimeoutManager", ",", "zone", ":", "str", ")", "->", "None", ":", "self", ".", "_manager", ":", "TimeoutManager", "=", "manager", "self", ".", "_zone", ":", "str", "=", "zone", "self", ".", "_tasks"...
[ 342, 4 ]
[ 347, 52 ]
python
en
['en', 'en', 'en']
True
_ZoneTimeoutManager.name
(self)
Return Zone name.
Return Zone name.
def name(self) -> str: """Return Zone name.""" return self._zone
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_zone" ]
[ 350, 4 ]
[ 352, 25 ]
python
en
['en', 'sl', 'en']
True
_ZoneTimeoutManager.active
(self)
Return True if zone is active.
Return True if zone is active.
def active(self) -> bool: """Return True if zone is active.""" return len(self._tasks) > 0 or len(self._freezes) > 0
[ "def", "active", "(", "self", ")", "->", "bool", ":", "return", "len", "(", "self", ".", "_tasks", ")", ">", "0", "or", "len", "(", "self", ".", "_freezes", ")", ">", "0" ]
[ 355, 4 ]
[ 357, 61 ]
python
en
['en', 'nl', 'en']
True
_ZoneTimeoutManager.freezes_done
(self)
Return True if all freeze are done.
Return True if all freeze are done.
def freezes_done(self) -> bool: """Return True if all freeze are done.""" return len(self._freezes) == 0 and self._manager.freezes_done
[ "def", "freezes_done", "(", "self", ")", "->", "bool", ":", "return", "len", "(", "self", ".", "_freezes", ")", "==", "0", "and", "self", ".", "_manager", ".", "freezes_done" ]
[ 360, 4 ]
[ 362, 69 ]
python
en
['en', 'en', 'en']
True
_ZoneTimeoutManager.enter_task
(self, task: _ZoneTaskContext)
Start into new Task.
Start into new Task.
def enter_task(self, task: _ZoneTaskContext) -> None: """Start into new Task.""" self._tasks.append(task)
[ "def", "enter_task", "(", "self", ",", "task", ":", "_ZoneTaskContext", ")", "->", "None", ":", "self", ".", "_tasks", ".", "append", "(", "task", ")" ]
[ 364, 4 ]
[ 366, 32 ]
python
en
['it', 'no', 'en']
False
_ZoneTimeoutManager.exit_task
(self, task: _ZoneTaskContext)
Exit a running Task.
Exit a running Task.
def exit_task(self, task: _ZoneTaskContext) -> None: """Exit a running Task.""" self._tasks.remove(task) # On latest listener if not self.active: self._manager.drop_zone(self.name)
[ "def", "exit_task", "(", "self", ",", "task", ":", "_ZoneTaskContext", ")", "->", "None", ":", "self", ".", "_tasks", ".", "remove", "(", "task", ")", "# On latest listener", "if", "not", "self", ".", "active", ":", "self", ".", "_manager", ".", "drop_zo...
[ 368, 4 ]
[ 374, 46 ]
python
en
['en', 'en', 'en']
True
_ZoneTimeoutManager.enter_freeze
(self, freeze: _ZoneFreezeContext)
Start into new freeze.
Start into new freeze.
def enter_freeze(self, freeze: _ZoneFreezeContext) -> None: """Start into new freeze.""" self._freezes.append(freeze)
[ "def", "enter_freeze", "(", "self", ",", "freeze", ":", "_ZoneFreezeContext", ")", "->", "None", ":", "self", ".", "_freezes", ".", "append", "(", "freeze", ")" ]
[ 376, 4 ]
[ 378, 36 ]
python
en
['it', 'en', 'en']
True
_ZoneTimeoutManager.exit_freeze
(self, freeze: _ZoneFreezeContext)
Exit a running Freeze.
Exit a running Freeze.
def exit_freeze(self, freeze: _ZoneFreezeContext) -> None: """Exit a running Freeze.""" self._freezes.remove(freeze) # On latest listener if not self.active: self._manager.drop_zone(self.name)
[ "def", "exit_freeze", "(", "self", ",", "freeze", ":", "_ZoneFreezeContext", ")", "->", "None", ":", "self", ".", "_freezes", ".", "remove", "(", "freeze", ")", "# On latest listener", "if", "not", "self", ".", "active", ":", "self", ".", "_manager", ".", ...
[ 380, 4 ]
[ 386, 46 ]
python
en
['en', 'en', 'en']
True
_ZoneTimeoutManager.pause
(self)
Stop timers while it freeze.
Stop timers while it freeze.
def pause(self) -> None: """Stop timers while it freeze.""" if not self.active: return # Forward pause for task in self._tasks: task.pause()
[ "def", "pause", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "active", ":", "return", "# Forward pause", "for", "task", "in", "self", ".", "_tasks", ":", "task", ".", "pause", "(", ")" ]
[ 388, 4 ]
[ 395, 24 ]
python
en
['en', 'en', 'en']
True
_ZoneTimeoutManager.reset
(self)
Reset timer after freeze.
Reset timer after freeze.
def reset(self) -> None: """Reset timer after freeze.""" if not self.active: return # Forward reset for task in self._tasks: task.reset()
[ "def", "reset", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "active", ":", "return", "# Forward reset", "for", "task", "in", "self", ".", "_tasks", ":", "task", ".", "reset", "(", ")" ]
[ 397, 4 ]
[ 404, 24 ]
python
da
['da', 'su', 'en']
False
TimeoutManager.__init__
(self)
Initialize TimeoutManager.
Initialize TimeoutManager.
def __init__(self) -> None: """Initialize TimeoutManager.""" self._loop: asyncio.AbstractEventLoop = asyncio.get_running_loop() self._zones: Dict[str, _ZoneTimeoutManager] = {} self._globals: List[_GlobalTaskContext] = [] self._freezes: List[_GlobalFreezeContext] = []
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "self", ".", "_loop", ":", "asyncio", ".", "AbstractEventLoop", "=", "asyncio", ".", "get_running_loop", "(", ")", "self", ".", "_zones", ":", "Dict", "[", "str", ",", "_ZoneTimeoutManager", "]", "=...
[ 413, 4 ]
[ 418, 54 ]
python
en
['en', 'en', 'en']
False
TimeoutManager.zones_done
(self)
Return True if all zones are finished.
Return True if all zones are finished.
def zones_done(self) -> bool: """Return True if all zones are finished.""" return not bool(self._zones)
[ "def", "zones_done", "(", "self", ")", "->", "bool", ":", "return", "not", "bool", "(", "self", ".", "_zones", ")" ]
[ 421, 4 ]
[ 423, 36 ]
python
en
['en', 'en', 'en']
True
TimeoutManager.freezes_done
(self)
Return True if all freezes are finished.
Return True if all freezes are finished.
def freezes_done(self) -> bool: """Return True if all freezes are finished.""" return not self._freezes
[ "def", "freezes_done", "(", "self", ")", "->", "bool", ":", "return", "not", "self", ".", "_freezes" ]
[ 426, 4 ]
[ 428, 32 ]
python
en
['en', 'en', 'en']
True
TimeoutManager.zones
(self)
Return all Zones.
Return all Zones.
def zones(self) -> Dict[str, _ZoneTimeoutManager]: """Return all Zones.""" return self._zones
[ "def", "zones", "(", "self", ")", "->", "Dict", "[", "str", ",", "_ZoneTimeoutManager", "]", ":", "return", "self", ".", "_zones" ]
[ 431, 4 ]
[ 433, 26 ]
python
en
['en', 'no', 'en']
True
TimeoutManager.global_tasks
(self)
Return all global Tasks.
Return all global Tasks.
def global_tasks(self) -> List[_GlobalTaskContext]: """Return all global Tasks.""" return self._globals
[ "def", "global_tasks", "(", "self", ")", "->", "List", "[", "_GlobalTaskContext", "]", ":", "return", "self", ".", "_globals" ]
[ 436, 4 ]
[ 438, 28 ]
python
en
['en', 'no', 'en']
True
TimeoutManager.global_freezes
(self)
Return all global Freezes.
Return all global Freezes.
def global_freezes(self) -> List[_GlobalFreezeContext]: """Return all global Freezes.""" return self._freezes
[ "def", "global_freezes", "(", "self", ")", "->", "List", "[", "_GlobalFreezeContext", "]", ":", "return", "self", ".", "_freezes" ]
[ 441, 4 ]
[ 443, 28 ]
python
en
['en', 'ig', 'en']
True
TimeoutManager.drop_zone
(self, zone_name: str)
Drop a zone out of scope.
Drop a zone out of scope.
def drop_zone(self, zone_name: str) -> None: """Drop a zone out of scope.""" self._zones.pop(zone_name, None) if self._zones: return # Signal Global task, all zones are done for task in self._globals: task.zones_done_signal()
[ "def", "drop_zone", "(", "self", ",", "zone_name", ":", "str", ")", "->", "None", ":", "self", ".", "_zones", ".", "pop", "(", "zone_name", ",", "None", ")", "if", "self", ".", "_zones", ":", "return", "# Signal Global task, all zones are done", "for", "ta...
[ 445, 4 ]
[ 453, 36 ]
python
en
['en', 'en', 'en']
True
TimeoutManager.async_timeout
( self, timeout: float, zone_name: str = ZONE_GLOBAL, cool_down: float = 0 )
Timeout based on a zone. For using as Async Context Manager.
Timeout based on a zone.
def async_timeout( self, timeout: float, zone_name: str = ZONE_GLOBAL, cool_down: float = 0 ) -> Union[_ZoneTaskContext, _GlobalTaskContext]: """Timeout based on a zone. For using as Async Context Manager. """ current_task: Optional[asyncio.Task[Any]] = asyncio.current_task(...
[ "def", "async_timeout", "(", "self", ",", "timeout", ":", "float", ",", "zone_name", ":", "str", "=", "ZONE_GLOBAL", ",", "cool_down", ":", "float", "=", "0", ")", "->", "Union", "[", "_ZoneTaskContext", ",", "_GlobalTaskContext", "]", ":", "current_task", ...
[ 455, 4 ]
[ 477, 60 ]
python
en
['en', 'en', 'en']
True
TimeoutManager.async_freeze
( self, zone_name: str = ZONE_GLOBAL )
Freeze all timer until job is done. For using as Async Context Manager.
Freeze all timer until job is done.
def async_freeze( self, zone_name: str = ZONE_GLOBAL ) -> Union[_ZoneFreezeContext, _GlobalFreezeContext]: """Freeze all timer until job is done. For using as Async Context Manager. """ # Global Freeze if zone_name == ZONE_GLOBAL: return _GlobalFreezeCont...
[ "def", "async_freeze", "(", "self", ",", "zone_name", ":", "str", "=", "ZONE_GLOBAL", ")", "->", "Union", "[", "_ZoneFreezeContext", ",", "_GlobalFreezeContext", "]", ":", "# Global Freeze", "if", "zone_name", "==", "ZONE_GLOBAL", ":", "return", "_GlobalFreezeCont...
[ 479, 4 ]
[ 496, 39 ]
python
en
['en', 'en', 'en']
True
TimeoutManager.freeze
( self, zone_name: str = ZONE_GLOBAL )
Freeze all timer until job is done. For using as Context Manager.
Freeze all timer until job is done.
def freeze( self, zone_name: str = ZONE_GLOBAL ) -> Union[_ZoneFreezeContext, _GlobalFreezeContext]: """Freeze all timer until job is done. For using as Context Manager. """ return run_callback_threadsafe( self._loop, self.async_freeze, zone_name ).result...
[ "def", "freeze", "(", "self", ",", "zone_name", ":", "str", "=", "ZONE_GLOBAL", ")", "->", "Union", "[", "_ZoneFreezeContext", ",", "_GlobalFreezeContext", "]", ":", "return", "run_callback_threadsafe", "(", "self", ".", "_loop", ",", "self", ".", "async_freez...
[ 498, 4 ]
[ 507, 18 ]
python
en
['en', 'en', 'en']
True
_is_chinese_char
(cp)
Checks whether CP is the codepoint of a CJK character.
Checks whether CP is the codepoint of a CJK character.
def _is_chinese_char(cp): """Checks whether CP is the codepoint of a CJK character.""" # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block) # # Note that the CJK Unicode block is NOT all Japanese and Korea...
[ "def", "_is_chinese_char", "(", "cp", ")", ":", "# This defines a \"chinese character\" as anything in the CJK Unicode block:", "# https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)", "#", "# Note that the CJK Unicode block is NOT all Japanese and Korean characters,", "# desp...
[ 8, 0 ]
[ 30, 16 ]
python
en
['en', 'en', 'en']
True
mock_feed
()
Pytest fixture for homeassistant.components.geo_rss_events.sensor.GenericFeed.
Pytest fixture for homeassistant.components.geo_rss_events.sensor.GenericFeed.
def mock_feed(): """Pytest fixture for homeassistant.components.geo_rss_events.sensor.GenericFeed.""" with patch( "homeassistant.components.geo_rss_events.sensor.GenericFeed" ) as mock_feed: yield mock_feed
[ "def", "mock_feed", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.geo_rss_events.sensor.GenericFeed\"", ")", "as", "mock_feed", ":", "yield", "mock_feed" ]
[ 35, 0 ]
[ 40, 23 ]
python
en
['en', 'en', 'en']
True
_generate_mock_feed_entry
( external_id, title, distance_to_home, coordinates, category )
Construct a mock feed entry for testing purposes.
Construct a mock feed entry for testing purposes.
def _generate_mock_feed_entry( external_id, title, distance_to_home, coordinates, category ): """Construct a mock feed entry for testing purposes.""" feed_entry = MagicMock() feed_entry.external_id = external_id feed_entry.title = title feed_entry.distance_to_home = distance_to_home feed_ent...
[ "def", "_generate_mock_feed_entry", "(", "external_id", ",", "title", ",", "distance_to_home", ",", "coordinates", ",", "category", ")", ":", "feed_entry", "=", "MagicMock", "(", ")", "feed_entry", ".", "external_id", "=", "external_id", "feed_entry", ".", "title"...
[ 43, 0 ]
[ 53, 21 ]
python
en
['en', 'en', 'en']
True
test_setup
(hass, mock_feed)
Test the general setup of the platform.
Test the general setup of the platform.
async def test_setup(hass, mock_feed): """Test the general setup of the platform.""" # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry( "1234", "Title 1", 15.5, (-31.0, 150.0), "Category 1" ) mock_entry_2 = _generate_mock_feed_entry( "2345", "Tit...
[ "async", "def", "test_setup", "(", "hass", ",", "mock_feed", ")", ":", "# Set up some mock feed entries for this test.", "mock_entry_1", "=", "_generate_mock_feed_entry", "(", "\"1234\"", ",", "\"Title 1\"", ",", "15.5", ",", "(", "-", "31.0", ",", "150.0", ")", "...
[ 56, 0 ]
[ 116, 13 ]
python
en
['en', 'da', 'en']
True
test_setup_with_categories
(hass, mock_feed)
Test the general setup of the platform.
Test the general setup of the platform.
async def test_setup_with_categories(hass, mock_feed): """Test the general setup of the platform.""" # Set up some mock feed entries for this test. mock_entry_1 = _generate_mock_feed_entry( "1234", "Title 1", 15.5, (-31.0, 150.0), "Category 1" ) mock_entry_2 = _generate_mock_feed_entry( ...
[ "async", "def", "test_setup_with_categories", "(", "hass", ",", "mock_feed", ")", ":", "# Set up some mock feed entries for this test.", "mock_entry_1", "=", "_generate_mock_feed_entry", "(", "\"1234\"", ",", "\"Title 1\"", ",", "15.5", ",", "(", "-", "31.0", ",", "15...
[ 119, 0 ]
[ 152, 9 ]
python
en
['en', 'da', 'en']
True
async_setup
(hass: HomeAssistant, config: Config)
Set up the Brother component.
Set up the Brother component.
async def async_setup(hass: HomeAssistant, config: Config): """Set up the Brother component.""" return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "Config", ")", ":", "return", "True" ]
[ 22, 0 ]
[ 24, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Brother from a config entry.
Set up Brother from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Brother from a config entry.""" host = entry.data[CONF_HOST] kind = entry.data[CONF_TYPE] coordinator = BrotherDataUpdateCoordinator(hass, host=host, kind=kind) await coordinator.async_refresh() if not coordinator....
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "host", "=", "entry", ".", "data", "[", "CONF_HOST", "]", "kind", "=", "entry", ".", "data", "[", "CONF_TYPE", "]", "coordinator", "=", "B...
[ 27, 0 ]
[ 47, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload...
[ 50, 0 ]
[ 63, 20 ]
python
en
['en', 'es', 'en']
True
BrotherDataUpdateCoordinator.__init__
(self, hass, host, kind)
Initialize.
Initialize.
def __init__(self, hass, host, kind): """Initialize.""" self.brother = Brother(host, kind=kind) self._unsub_stop = hass.bus.async_listen( EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop ) super().__init__( hass, _LOGGER, name=DOMAIN...
[ "def", "__init__", "(", "self", ",", "hass", ",", "host", ",", "kind", ")", ":", "self", ".", "brother", "=", "Brother", "(", "host", ",", "kind", "=", "kind", ")", "self", ".", "_unsub_stop", "=", "hass", ".", "bus", ".", "async_listen", "(", "EVE...
[ 69, 4 ]
[ 81, 9 ]
python
en
['en', 'en', 'it']
False
BrotherDataUpdateCoordinator._async_update_data
(self)
Update data via library.
Update data via library.
async def _async_update_data(self): """Update data via library.""" # Race condition on shutdown. Stop all the fetches. if self._unsub_stop is None: return None try: await self.brother.async_update() except (ConnectionError, SnmpError, UnsupportedModel) as...
[ "async", "def", "_async_update_data", "(", "self", ")", ":", "# Race condition on shutdown. Stop all the fetches.", "if", "self", ".", "_unsub_stop", "is", "None", ":", "return", "None", "try", ":", "await", "self", ".", "brother", ".", "async_update", "(", ")", ...
[ 83, 4 ]
[ 93, 32 ]
python
en
['fr', 'en', 'en']
True
BrotherDataUpdateCoordinator.shutdown
(self)
Shutdown the Brother coordinator.
Shutdown the Brother coordinator.
def shutdown(self): """Shutdown the Brother coordinator.""" self._unsub_stop() self._unsub_stop = None self.brother.shutdown()
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "_unsub_stop", "(", ")", "self", ".", "_unsub_stop", "=", "None", "self", ".", "brother", ".", "shutdown", "(", ")" ]
[ 95, 4 ]
[ 99, 31 ]
python
en
['en', 'en', 'en']
True
BrotherDataUpdateCoordinator._handle_ha_stop
(self, _)
Handle Home Assistant stopping.
Handle Home Assistant stopping.
def _handle_ha_stop(self, _): """Handle Home Assistant stopping.""" self.shutdown()
[ "def", "_handle_ha_stop", "(", "self", ",", "_", ")", ":", "self", ".", "shutdown", "(", ")" ]
[ 101, 4 ]
[ 103, 23 ]
python
en
['fr', 'en', 'en']
True
bar
()
I'm doc string
I'm doc string
def bar(): """I'm doc string""" return nni.report_final_result(0)
[ "def", "bar", "(", ")", ":", "return", "nni", ".", "report_final_result", "(", "0", ")" ]
[ 2, 0 ]
[ 4, 37 ]
python
en
['en', 'ru-Latn', 'en']
True
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["errors...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 46, 0 ]
[ 88, 48 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_auth
(hass)
Test we handle invalid auth.
Test we handle invalid auth.
async def test_form_invalid_auth(hass): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.control4.config_flow.C4Account", side_effect=Unauthorized...
[ "async", "def", "test_form_invalid_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")"...
[ 91, 0 ]
[ 111, 56 ]
python
en
['en', 'en', 'en']
True
test_form_unexpected_exception
(hass)
Test we handle an unexpected exception.
Test we handle an unexpected exception.
async def test_form_unexpected_exception(hass): """Test we handle an unexpected exception.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.control4.config_flow.C4Account", side_...
[ "async", "def", "test_form_unexpected_exception", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}...
[ 114, 0 ]
[ 134, 51 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.control4.config_flow.Control4Validator.authenticate", ...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 137, 0 ]
[ 160, 58 ]
python
en
['en', 'en', 'en']
True
test_option_flow
(hass)
Test config flow options.
Test config flow options.
async def test_option_flow(hass): """Test config flow options.""" entry = MockConfigEntry(domain=DOMAIN, data={}, options=None) entry.add_to_hass(hass) result = await hass.config_entries.options.async_init(entry.entry_id) assert result["type"] == "form" assert result["step_id"] == "init" ...
[ "async", "def", "test_option_flow", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "}", ",", "options", "=", "None", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "result", "=", "await...
[ 163, 0 ]
[ 180, 5 ]
python
en
['en', 'fr', 'en']
True
test_option_flow_defaults
(hass)
Test config flow options.
Test config flow options.
async def test_option_flow_defaults(hass): """Test config flow options.""" entry = MockConfigEntry(domain=DOMAIN, data={}, options=None) entry.add_to_hass(hass) result = await hass.config_entries.options.async_init(entry.entry_id) assert result["type"] == "form" assert result["step_id"] == "in...
[ "async", "def", "test_option_flow_defaults", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "}", ",", "options", "=", "None", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "result", "=",...
[ 183, 0 ]
[ 199, 5 ]
python
en
['en', 'fr', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Create the sensor.
Create the sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Create the sensor.""" api_key = config[CONF_API_KEY] session = async_get_clientsession(hass) sensors = [] for nextpassage in config[CONF_NEXT_DEPARTURE]: sensors.append( DeLijnPublicTransp...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "api_key", "=", "config", "[", "CONF_API_KEY", "]", "session", "=", "async_get_clientsession", "(", "hass", ")", "sensors...
[ 37, 0 ]
[ 58, 37 ]
python
en
['en', 'mi', 'en']
True
DeLijnPublicTransportSensor.__init__
(self, line)
Initialize the sensor.
Initialize the sensor.
def __init__(self, line): """Initialize the sensor.""" self.line = line self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} self._name = None self._state = None self._available = True
[ "def", "__init__", "(", "self", ",", "line", ")", ":", "self", ".", "line", "=", "line", "self", ".", "_attributes", "=", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}", "self", ".", "_name", "=", "None", "self", ".", "_state", "=", "None", "self", ...
[ 64, 4 ]
[ 70, 30 ]
python
en
['en', 'en', 'en']
True
DeLijnPublicTransportSensor.async_update
(self)
Get the latest data from the De Lijn API.
Get the latest data from the De Lijn API.
async def async_update(self): """Get the latest data from the De Lijn API.""" try: await self.line.get_passages() self._name = await self.line.get_stopname() except HttpException: self._available = False _LOGGER.error("De Lijn http error") ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "await", "self", ".", "line", ".", "get_passages", "(", ")", "self", ".", "_name", "=", "await", "self", ".", "line", ".", "get_stopname", "(", ")", "except", "HttpException", ":", "sel...
[ 72, 4 ]
[ 101, 35 ]
python
en
['en', 'en', 'nl']
True
DeLijnPublicTransportSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 104, 4 ]
[ 106, 30 ]
python
en
['en', 'en', 'en']
True
DeLijnPublicTransportSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return DEVICE_CLASS_TIMESTAMP
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TIMESTAMP" ]
[ 109, 4 ]
[ 111, 37 ]
python
en
['en', 'en', 'en']
True
DeLijnPublicTransportSensor.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" ]
[ 114, 4 ]
[ 116, 25 ]
python
en
['en', 'mi', 'en']
True
DeLijnPublicTransportSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 119, 4 ]
[ 121, 26 ]
python
en
['en', 'en', 'en']
True
DeLijnPublicTransportSensor.icon
(self)
Return the icon of the sensor.
Return the icon of the sensor.
def icon(self): """Return the icon of the sensor.""" return "mdi:bus"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:bus\"" ]
[ 124, 4 ]
[ 126, 24 ]
python
en
['en', 'en', 'en']
True
DeLijnPublicTransportSensor.device_state_attributes
(self)
Return attributes for the sensor.
Return attributes for the sensor.
def device_state_attributes(self): """Return attributes for the sensor.""" return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attributes" ]
[ 129, 4 ]
[ 131, 31 ]
python
en
['en', 'no', 'en']
True
start
(update: Update, _: CallbackContext)
Send a message when the command /start is issued.
Send a message when the command /start is issued.
def start(update: Update, _: CallbackContext) -> None: """Send a message when the command /start is issued.""" user = update.effective_user update.message.reply_markdown_v2( fr'Hi {user.mention_markdown_v2()}\!' '\n\nType /help to see what can i do' )
[ "def", "start", "(", "update", ":", "Update", ",", "_", ":", "CallbackContext", ")", "->", "None", ":", "user", "=", "update", ".", "effective_user", "update", ".", "message", ".", "reply_markdown_v2", "(", "fr'Hi {user.mention_markdown_v2()}\\!'", "'\\n\\nType /h...
[ 57, 0 ]
[ 63, 5 ]
python
en
['en', 'en', 'en']
True
help_command
(update: Update, _: CallbackContext)
Send a message when the command /help is issued.
Send a message when the command /help is issued.
def help_command(update: Update, _: CallbackContext) -> None: """Send a message when the command /help is issued.""" update.message.reply_text('Send\n/getotp to send OTP to your phone number\n/log to get the latest log')
[ "def", "help_command", "(", "update", ":", "Update", ",", "_", ":", "CallbackContext", ")", "->", "None", ":", "update", ".", "message", ".", "reply_text", "(", "'Send\\n/getotp to send OTP to your phone number\\n/log to get the latest log'", ")" ]
[ 74, 0 ]
[ 76, 107 ]
python
en
['en', 'en', 'en']
True
main
()
Start the bot.
Start the bot.
def main() -> None: """Start the bot.""" # Create the Updater and pass it your bot's token. updater = Updater(os.getenv('TOKEN')) # Get the dispatcher to register handlers dispatcher = updater.dispatcher # on different commands - answer in Telegram dispatcher.add_handler(CommandHandler("st...
[ "def", "main", "(", ")", "->", "None", ":", "# Create the Updater and pass it your bot's token.", "updater", "=", "Updater", "(", "os", ".", "getenv", "(", "'TOKEN'", ")", ")", "# Get the dispatcher to register handlers", "dispatcher", "=", "updater", ".", "dispatcher...
[ 167, 0 ]
[ 201, 18 ]
python
en
['en', 'no', 'en']
True
filter_html
(html, mode="html", **kwargs)
Replace the editor with a div after markdown is parsed
Replace the editor with a div after markdown is parsed
def filter_html(html, mode="html", **kwargs): """ Replace the editor with a div after markdown is parsed """ if mode == "md": # shouldn't even come up, but just in case... don't do it return html html = re.sub(START_REGEX, START_REPL, html) html = re.sub(END_REGEX, END_REPL, html) ...
[ "def", "filter_html", "(", "html", ",", "mode", "=", "\"html\"", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "==", "\"md\"", ":", "# shouldn't even come up, but just in case... don't do it", "return", "html", "html", "=", "re", ".", "sub", "(", "START_REG...
[ 42, 0 ]
[ 53, 15 ]
python
en
['en', 'error', 'th']
False
test_init_success
(hass)
Test that we can setup with valid config.
Test that we can setup with valid config.
async def test_init_success(hass): """Test that we can setup with valid config.""" mock_nuheat = _get_mock_nuheat() with patch( "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuheat, ): assert await async_setup_component(hass, DOMAIN, VALID_CONFIG) aw...
[ "async", "def", "test_init_success", "(", "hass", ")", ":", "mock_nuheat", "=", "_get_mock_nuheat", "(", ")", "with", "patch", "(", "\"homeassistant.components.nuheat.nuheat.NuHeat\"", ",", "return_value", "=", "mock_nuheat", ",", ")", ":", "assert", "await", "async...
[ 14, 0 ]
[ 23, 42 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the Verisure component.
Set up the Verisure component.
def setup(hass, config): """Set up the Verisure component.""" global HUB # pylint: disable=global-statement HUB = VerisureHub(config[DOMAIN]) HUB.update_overview = Throttle(config[DOMAIN][CONF_SCAN_INTERVAL])( HUB.update_overview ) if not HUB.login(): return False hass.bus.l...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "global", "HUB", "# pylint: disable=global-statement", "HUB", "=", "VerisureHub", "(", "config", "[", "DOMAIN", "]", ")", "HUB", ".", "update_overview", "=", "Throttle", "(", "config", "[", "DOMAIN", "]",...
[ 76, 0 ]
[ 136, 15 ]
python
en
['en', 'fr', 'en']
True
VerisureHub.__init__
(self, domain_config)
Initialize the Verisure hub.
Initialize the Verisure hub.
def __init__(self, domain_config): """Initialize the Verisure hub.""" self.overview = {} self.imageseries = {} self.config = domain_config self._lock = threading.Lock() self.session = verisure.Session( domain_config[CONF_USERNAME], domain_config[CONF_PASSWO...
[ "def", "__init__", "(", "self", ",", "domain_config", ")", ":", "self", ".", "overview", "=", "{", "}", "self", ".", "imageseries", "=", "{", "}", "self", ".", "config", "=", "domain_config", "self", ".", "_lock", "=", "threading", ".", "Lock", "(", ...
[ 142, 4 ]
[ 155, 48 ]
python
en
['en', 'co', 'en']
True
VerisureHub.login
(self)
Login to Verisure.
Login to Verisure.
def login(self): """Login to Verisure.""" try: self.session.login() except verisure.Error as ex: _LOGGER.error("Could not log in to verisure, %s", ex) return False if self.giid: return self.set_giid() return True
[ "def", "login", "(", "self", ")", ":", "try", ":", "self", ".", "session", ".", "login", "(", ")", "except", "verisure", ".", "Error", "as", "ex", ":", "_LOGGER", ".", "error", "(", "\"Could not log in to verisure, %s\"", ",", "ex", ")", "return", "False...
[ 157, 4 ]
[ 166, 19 ]
python
en
['en', 'co', 'en']
True
VerisureHub.logout
(self)
Logout from Verisure.
Logout from Verisure.
def logout(self): """Logout from Verisure.""" try: self.session.logout() except verisure.Error as ex: _LOGGER.error("Could not log out from verisure, %s", ex) return False return True
[ "def", "logout", "(", "self", ")", ":", "try", ":", "self", ".", "session", ".", "logout", "(", ")", "except", "verisure", ".", "Error", "as", "ex", ":", "_LOGGER", ".", "error", "(", "\"Could not log out from verisure, %s\"", ",", "ex", ")", "return", "...
[ 168, 4 ]
[ 175, 19 ]
python
en
['en', 'en', 'en']
True
VerisureHub.set_giid
(self)
Set installation GIID.
Set installation GIID.
def set_giid(self): """Set installation GIID.""" try: self.session.set_giid(self.giid) except verisure.Error as ex: _LOGGER.error("Could not set installation GIID, %s", ex) return False return True
[ "def", "set_giid", "(", "self", ")", ":", "try", ":", "self", ".", "session", ".", "set_giid", "(", "self", ".", "giid", ")", "except", "verisure", ".", "Error", "as", "ex", ":", "_LOGGER", ".", "error", "(", "\"Could not set installation GIID, %s\"", ",",...
[ 177, 4 ]
[ 184, 19 ]
python
sv
['sv', 'sv', 'en']
True
VerisureHub.update_overview
(self)
Update the overview.
Update the overview.
def update_overview(self): """Update the overview.""" try: self.overview = self.session.get_overview() except verisure.ResponseError as ex: _LOGGER.error("Could not read overview, %s", ex) if ex.status_code == HTTP_SERVICE_UNAVAILABLE: # Service unavailable ...
[ "def", "update_overview", "(", "self", ")", ":", "try", ":", "self", ".", "overview", "=", "self", ".", "session", ".", "get_overview", "(", ")", "except", "verisure", ".", "ResponseError", "as", "ex", ":", "_LOGGER", ".", "error", "(", "\"Could not read o...
[ 186, 4 ]
[ 196, 21 ]
python
en
['en', 'en', 'en']
True
VerisureHub.update_smartcam_imageseries
(self)
Update the image series.
Update the image series.
def update_smartcam_imageseries(self): """Update the image series.""" self.imageseries = self.session.get_camera_imageseries()
[ "def", "update_smartcam_imageseries", "(", "self", ")", ":", "self", ".", "imageseries", "=", "self", ".", "session", ".", "get_camera_imageseries", "(", ")" ]
[ 199, 4 ]
[ 201, 64 ]
python
en
['en', 'en', 'en']
True
VerisureHub.smartcam_capture
(self, device_id)
Capture a new image from a smartcam.
Capture a new image from a smartcam.
def smartcam_capture(self, device_id): """Capture a new image from a smartcam.""" self.session.capture_image(device_id)
[ "def", "smartcam_capture", "(", "self", ",", "device_id", ")", ":", "self", ".", "session", ".", "capture_image", "(", "device_id", ")" ]
[ 204, 4 ]
[ 206, 45 ]
python
en
['en', 'en', 'en']
True
VerisureHub.disable_autolock
(self, device_id)
Disable autolock.
Disable autolock.
def disable_autolock(self, device_id): """Disable autolock.""" self.session.set_lock_config(device_id, auto_lock_enabled=False)
[ "def", "disable_autolock", "(", "self", ",", "device_id", ")", ":", "self", ".", "session", ".", "set_lock_config", "(", "device_id", ",", "auto_lock_enabled", "=", "False", ")" ]
[ 208, 4 ]
[ 210, 72 ]
python
de
['de', 'fr', 'en']
False
VerisureHub.enable_autolock
(self, device_id)
Enable autolock.
Enable autolock.
def enable_autolock(self, device_id): """Enable autolock.""" self.session.set_lock_config(device_id, auto_lock_enabled=True)
[ "def", "enable_autolock", "(", "self", ",", "device_id", ")", ":", "self", ".", "session", ".", "set_lock_config", "(", "device_id", ",", "auto_lock_enabled", "=", "True", ")" ]
[ 212, 4 ]
[ 214, 71 ]
python
de
['de', 'xh', 'en']
False
VerisureHub.get
(self, jpath, *args)
Get values from the overview that matches the jsonpath.
Get values from the overview that matches the jsonpath.
def get(self, jpath, *args): """Get values from the overview that matches the jsonpath.""" res = jsonpath(self.overview, jpath % args) return res if res else []
[ "def", "get", "(", "self", ",", "jpath", ",", "*", "args", ")", ":", "res", "=", "jsonpath", "(", "self", ".", "overview", ",", "jpath", "%", "args", ")", "return", "res", "if", "res", "else", "[", "]" ]
[ 216, 4 ]
[ 219, 33 ]
python
en
['en', 'en', 'en']
True
VerisureHub.get_first
(self, jpath, *args)
Get first value from the overview that matches the jsonpath.
Get first value from the overview that matches the jsonpath.
def get_first(self, jpath, *args): """Get first value from the overview that matches the jsonpath.""" res = self.get(jpath, *args) return res[0] if res else None
[ "def", "get_first", "(", "self", ",", "jpath", ",", "*", "args", ")", ":", "res", "=", "self", ".", "get", "(", "jpath", ",", "*", "args", ")", "return", "res", "[", "0", "]", "if", "res", "else", "None" ]
[ 221, 4 ]
[ 224, 38 ]
python
en
['en', 'en', 'en']
True
VerisureHub.get_image_info
(self, jpath, *args)
Get values from the imageseries that matches the jsonpath.
Get values from the imageseries that matches the jsonpath.
def get_image_info(self, jpath, *args): """Get values from the imageseries that matches the jsonpath.""" res = jsonpath(self.imageseries, jpath % args) return res if res else []
[ "def", "get_image_info", "(", "self", ",", "jpath", ",", "*", "args", ")", ":", "res", "=", "jsonpath", "(", "self", ".", "imageseries", ",", "jpath", "%", "args", ")", "return", "res", "if", "res", "else", "[", "]" ]
[ 226, 4 ]
[ 229, 33 ]
python
en
['en', 'en', 'en']
True
minio_client_fixture
()
Patch Minio client.
Patch Minio client.
def minio_client_fixture(): """Patch Minio client.""" with patch("homeassistant.components.minio.minio_helper.Minio") as minio_mock: minio_client_mock = minio_mock.return_value yield minio_client_mock
[ "def", "minio_client_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.minio.minio_helper.Minio\"", ")", "as", "minio_mock", ":", "minio_client_mock", "=", "minio_mock", ".", "return_value", "yield", "minio_client_mock" ]
[ 25, 0 ]
[ 30, 31 ]
python
en
['lt', 'fr', 'en']
False
minio_client_event_fixture
()
Patch helper function for minio notification stream.
Patch helper function for minio notification stream.
def minio_client_event_fixture(): """Patch helper function for minio notification stream.""" with patch("homeassistant.components.minio.minio_helper.Minio") as minio_mock: minio_client_mock = minio_mock.return_value response_mock = MagicMock() stream_mock = MagicMock() stream_m...
[ "def", "minio_client_event_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.minio.minio_helper.Minio\"", ")", "as", "minio_mock", ":", "minio_client_mock", "=", "minio_mock", ".", "return_value", "response_mock", "=", "MagicMock", "(", ")", "st...
[ 34, 0 ]
[ 51, 31 ]
python
en
['en', 'en', 'en']
True
test_minio_services
(hass, caplog, minio_client)
Test Minio services.
Test Minio services.
async def test_minio_services(hass, caplog, minio_client): """Test Minio services.""" hass.config.allowlist_external_dirs = {"/test"} await async_setup_component( hass, DOMAIN, { DOMAIN: { CONF_HOST: "localhost", CONF_PORT: "9000", ...
[ "async", "def", "test_minio_services", "(", "hass", ",", "caplog", ",", "minio_client", ")", ":", "hass", ".", "config", ".", "allowlist_external_dirs", "=", "{", "\"/test\"", "}", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN...
[ 54, 0 ]
[ 104, 29 ]
python
el-Latn
['lt', 'el-Latn', 'en']
False
test_minio_listen
(hass, caplog, minio_client_event)
Test minio listen on notifications.
Test minio listen on notifications.
async def test_minio_listen(hass, caplog, minio_client_event): """Test minio listen on notifications.""" minio_client_event.presigned_get_object.return_value = "http://url" events = [] @callback def event_callback(event): """Handle event callbback.""" events.append(event) hass...
[ "async", "def", "test_minio_listen", "(", "hass", ",", "caplog", ",", "minio_client_event", ")", ":", "minio_client_event", ".", "presigned_get_object", ".", "return_value", "=", "\"http://url\"", "events", "=", "[", "]", "@", "callback", "def", "event_callback", ...
[ 107, 0 ]
[ 152, 43 ]
python
en
['en', 'fi', 'en']
True
test_queue_listener
()
Tests QueueListener firing events on Home Assistant event bus.
Tests QueueListener firing events on Home Assistant event bus.
async def test_queue_listener(): """Tests QueueListener firing events on Home Assistant event bus.""" hass = MagicMock() queue_listener = QueueListener(hass) queue_listener.start() queue_entry = { "event_name": "s3:ObjectCreated:Put", "bucket": "some_bucket", "key": "some_d...
[ "async", "def", "test_queue_listener", "(", ")", ":", "hass", "=", "MagicMock", "(", ")", "queue_listener", "=", "QueueListener", "(", "hass", ")", "queue_listener", ".", "start", "(", ")", "queue_entry", "=", "{", "\"event_name\"", ":", "\"s3:ObjectCreated:Put\...
[ 155, 0 ]
[ 188, 5 ]
python
en
['en', 'en', 'en']
True
mock_discovery
()
No real network traffic allowed.
No real network traffic allowed.
def mock_discovery(): """No real network traffic allowed.""" with patch( "homeassistant.components.unifi.config_flow.async_discover_unifi", return_value=None, ) as mock: yield mock
[ "def", "mock_discovery", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.unifi.config_flow.async_discover_unifi\"", ",", "return_value", "=", "None", ",", ")", "as", "mock", ":", "yield", "mock" ]
[ 7, 0 ]
[ 13, 18 ]
python
en
['en', 'en', 'en']
True
test_default_state
(hass)
Test light group default state.
Test light group default state.
async def test_default_state(hass): """Test light group default state.""" hass.states.async_set("light.kitchen", "on") await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.kitchen", "lig...
[ "async", "def", "test_default_state", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"light.kitchen\"", ",", "\"on\"", ")", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platf...
[ 37, 0 ]
[ 65, 52 ]
python
da
['nl', 'da', 'en']
False
test_state_reporting
(hass)
Test the state reporting.
Test the state reporting.
async def test_state_reporting(hass): """Test the state reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) await ha...
[ "async", "def", "test_state_reporting", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light....
[ 68, 0 ]
[ 102, 74 ]
python
en
['en', 'en', 'en']
True
test_brightness
(hass)
Test brightness reporting.
Test brightness reporting.
async def test_brightness(hass): """Test brightness reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) await hass.a...
[ "async", "def", "test_brightness", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test2...
[ 105, 0 ]
[ 145, 51 ]
python
en
['en', 'sn', 'en']
True
test_color
(hass)
Test RGB reporting.
Test RGB reporting.
async def test_color(hass): """Test RGB reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) await hass.async_block_t...
[ "async", "def", "test_color", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test2\"", ...
[ 148, 0 ]
[ 185, 53 ]
python
en
['en', 'en', 'en']
True
test_white_value
(hass)
Test white value reporting.
Test white value reporting.
async def test_white_value(hass): """Test white value reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) await hass...
[ "async", "def", "test_white_value", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test...
[ 188, 0 ]
[ 223, 52 ]
python
en
['en', 'en', 'en']
True
test_color_temp
(hass)
Test color temp reporting.
Test color temp reporting.
async def test_color_temp(hass): """Test color temp reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) await hass.a...
[ "async", "def", "test_color_temp", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test2...
[ 226, 0 ]
[ 261, 52 ]
python
en
['en', 'en', 'en']
True
test_emulated_color_temp_group
(hass)
Test emulated color temperature in a group.
Test emulated color temperature in a group.
async def test_emulated_color_temp_group(hass): """Test emulated color temperature in a group.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: [ {"platform": "demo"}, { "platform": DOMAIN, ...
[ "async", "def", "test_emulated_color_temp_group", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "[", "{", "\"platform\"", ":", "\"demo\"", "}", ",", "{", "\"platform\"", ":", "DOMAIN", ...
[ 264, 0 ]
[ 315, 62 ]
python
en
['en', 'en', 'en']
True
test_min_max_mireds
(hass)
Test min/max mireds reporting.
Test min/max mireds reporting.
async def test_min_max_mireds(hass): """Test min/max mireds reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) awai...
[ "async", "def", "test_min_max_mireds", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.t...
[ 318, 0 ]
[ 362, 58 ]
python
en
['mt', 'en', 'it']
False
test_effect_list
(hass)
Test effect_list reporting.
Test effect_list reporting.
async def test_effect_list(hass): """Test effect_list reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) await hass...
[ "async", "def", "test_effect_list", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test...
[ 365, 0 ]
[ 417, 5 ]
python
en
['de', 'en', 'en']
True
test_effect
(hass)
Test effect reporting.
Test effect reporting.
async def test_effect(hass): """Test effect reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2", "light.test3"], } }, ) await...
[ "async", "def", "test_effect", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test2\"",...
[ 420, 0 ]
[ 465, 52 ]
python
en
['de', 'en', 'en']
True
test_supported_features
(hass)
Test supported features reporting.
Test supported features reporting.
async def test_supported_features(hass): """Test supported features reporting.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: { "platform": DOMAIN, "entities": ["light.test1", "light.test2"], } }, ) ...
[ "async", "def", "test_supported_features", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"lig...
[ 468, 0 ]
[ 502, 58 ]
python
en
['en', 'en', 'en']
True
test_service_calls
(hass)
Test service calls.
Test service calls.
async def test_service_calls(hass): """Test service calls.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: [ {"platform": "demo"}, { "platform": DOMAIN, "entities": [ ...
[ "async", "def", "test_service_calls", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "[", "{", "\"platform\"", ":", "\"demo\"", "}", ",", "{", "\"platform\"", ":", "DOMAIN", ",", "\"e...
[ 505, 0 ]
[ 588, 61 ]
python
en
['en', 'ca', 'en']
True
test_invalid_service_calls
(hass)
Test invalid service call arguments get discarded.
Test invalid service call arguments get discarded.
async def test_invalid_service_calls(hass): """Test invalid service call arguments get discarded.""" add_entities = MagicMock() await group.async_setup_platform( hass, {"entities": ["light.test1", "light.test2"]}, add_entities ) await hass.async_block_till_done() await hass.async_start()...
[ "async", "def", "test_invalid_service_calls", "(", "hass", ")", ":", "add_entities", "=", "MagicMock", "(", ")", "await", "group", ".", "async_setup_platform", "(", "hass", ",", "{", "\"entities\"", ":", "[", "\"light.test1\"", ",", "\"light.test2\"", "]", "}", ...
[ 591, 0 ]
[ 636, 9 ]
python
en
['en', 'en', 'en']
True
test_reload
(hass)
Test the ability to reload lights.
Test the ability to reload lights.
async def test_reload(hass): """Test the ability to reload lights.""" await async_setup_component( hass, LIGHT_DOMAIN, { LIGHT_DOMAIN: [ {"platform": "demo"}, { "platform": DOMAIN, "entities": [ ...
[ "async", "def", "test_reload", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "LIGHT_DOMAIN", ",", "{", "LIGHT_DOMAIN", ":", "[", "{", "\"platform\"", ":", "\"demo\"", "}", ",", "{", "\"platform\"", ":", "DOMAIN", ",", "\"entities...
[ 639, 0 ]
[ 682, 70 ]
python
en
['en', 'en', 'en']
True