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
generate_h264_video
(container_format="mp4", audio_codec=None)
Generate a test video. See: http://docs.mikeboers.com/pyav/develop/cookbook/numpy.html
Generate a test video.
def generate_h264_video(container_format="mp4", audio_codec=None): """ Generate a test video. See: http://docs.mikeboers.com/pyav/develop/cookbook/numpy.html """ def generate_audio_frame(pcm_mulaw=False): """Generate a blank audio frame.""" if pcm_mulaw: audio_frame = a...
[ "def", "generate_h264_video", "(", "container_format", "=", "\"mp4\"", ",", "audio_codec", "=", "None", ")", ":", "def", "generate_audio_frame", "(", "pcm_mulaw", "=", "False", ")", ":", "\"\"\"Generate a blank audio frame.\"\"\"", "if", "pcm_mulaw", ":", "audio_frame...
[ 13, 0 ]
[ 94, 17 ]
python
en
['en', 'error', 'th']
False
preload_stream
(hass, stream_source)
Preload a stream for use in tests.
Preload a stream for use in tests.
def preload_stream(hass, stream_source): """Preload a stream for use in tests.""" stream = Stream(hass, stream_source) hass.data[DOMAIN][ATTR_STREAMS][stream_source] = stream return stream
[ "def", "preload_stream", "(", "hass", ",", "stream_source", ")", ":", "stream", "=", "Stream", "(", "hass", ",", "stream_source", ")", "hass", ".", "data", "[", "DOMAIN", "]", "[", "ATTR_STREAMS", "]", "[", "stream_source", "]", "=", "stream", "return", ...
[ 97, 0 ]
[ 101, 17 ]
python
en
['en', 'en', 'en']
True
provider
(hass)
Home Assistant auth provider.
Home Assistant auth provider.
def provider(hass): """Home Assistant auth provider.""" provider = hass.loop.run_until_complete( register_auth_provider(hass, {"type": "homeassistant"}) ) hass.loop.run_until_complete(provider.async_initialize()) return provider
[ "def", "provider", "(", "hass", ")", ":", "provider", "=", "hass", ".", "loop", ".", "run_until_complete", "(", "register_auth_provider", "(", "hass", ",", "{", "\"type\"", ":", "\"homeassistant\"", "}", ")", ")", "hass", ".", "loop", ".", "run_until_complet...
[ 11, 0 ]
[ 17, 19 ]
python
en
['fr', 'en', 'en']
True
test_list_user
(hass, provider, capsys)
Test we can list users.
Test we can list users.
async def test_list_user(hass, provider, capsys): """Test we can list users.""" data = provider.data data.add_auth("test-user", "test-pass") data.add_auth("second-user", "second-pass") await script_auth.list_users(hass, provider, None) captured = capsys.readouterr() assert captured.out ==...
[ "async", "def", "test_list_user", "(", "hass", ",", "provider", ",", "capsys", ")", ":", "data", "=", "provider", ".", "data", "data", ".", "add_auth", "(", "\"test-user\"", ",", "\"test-pass\"", ")", "data", ".", "add_auth", "(", "\"second-user\"", ",", "...
[ 20, 0 ]
[ 32, 5 ]
python
en
['en', 'en', 'en']
True
test_add_user
(hass, provider, capsys, hass_storage)
Test we can add a user.
Test we can add a user.
async def test_add_user(hass, provider, capsys, hass_storage): """Test we can add a user.""" data = provider.data await script_auth.add_user( hass, provider, Mock(username="paulus", password="test-pass") ) assert len(hass_storage[hass_auth.STORAGE_KEY]["data"]["users"]) == 1 captured =...
[ "async", "def", "test_add_user", "(", "hass", ",", "provider", ",", "capsys", ",", "hass_storage", ")", ":", "data", "=", "provider", ".", "data", "await", "script_auth", ".", "add_user", "(", "hass", ",", "provider", ",", "Mock", "(", "username", "=", "...
[ 35, 0 ]
[ 48, 46 ]
python
en
['en', 'en', 'en']
True
test_validate_login
(hass, provider, capsys)
Test we can validate a user login.
Test we can validate a user login.
async def test_validate_login(hass, provider, capsys): """Test we can validate a user login.""" data = provider.data data.add_auth("test-user", "test-pass") await script_auth.validate_login( hass, provider, Mock(username="test-user", password="test-pass") ) captured = capsys.readouterr(...
[ "async", "def", "test_validate_login", "(", "hass", ",", "provider", ",", "capsys", ")", ":", "data", "=", "provider", ".", "data", "data", ".", "add_auth", "(", "\"test-user\"", ",", "\"test-pass\"", ")", "await", "script_auth", ".", "validate_login", "(", ...
[ 51, 0 ]
[ 72, 43 ]
python
en
['en', 'en', 'en']
True
test_change_password
(hass, provider, capsys, hass_storage)
Test we can change a password.
Test we can change a password.
async def test_change_password(hass, provider, capsys, hass_storage): """Test we can change a password.""" data = provider.data data.add_auth("test-user", "test-pass") await script_auth.change_password( hass, provider, Mock(username="test-user", new_password="new-pass") ) assert len(ha...
[ "async", "def", "test_change_password", "(", "hass", ",", "provider", ",", "capsys", ",", "hass_storage", ")", ":", "data", "=", "provider", ".", "data", "data", ".", "add_auth", "(", "\"test-user\"", ",", "\"test-pass\"", ")", "await", "script_auth", ".", "...
[ 75, 0 ]
[ 89, 53 ]
python
en
['en', 'en', 'en']
True
test_change_password_invalid_user
(hass, provider, capsys, hass_storage)
Test changing password of non-existing user.
Test changing password of non-existing user.
async def test_change_password_invalid_user(hass, provider, capsys, hass_storage): """Test changing password of non-existing user.""" data = provider.data data.add_auth("test-user", "test-pass") await script_auth.change_password( hass, provider, Mock(username="invalid-user", new_password="new-p...
[ "async", "def", "test_change_password_invalid_user", "(", "hass", ",", "provider", ",", "capsys", ",", "hass_storage", ")", ":", "data", "=", "provider", ".", "data", "data", ".", "add_auth", "(", "\"test-user\"", ",", "\"test-pass\"", ")", "await", "script_auth...
[ 92, 0 ]
[ 106, 55 ]
python
en
['en', 'en', 'en']
True
test_parsing_args
(loop)
Test we parse args correctly.
Test we parse args correctly.
def test_parsing_args(loop): """Test we parse args correctly.""" called = False async def mock_func(hass, provider, args2): """Mock function to be called.""" nonlocal called called = True assert provider.hass.config.config_dir == "/somewhere/config" assert args2 is a...
[ "def", "test_parsing_args", "(", "loop", ")", ":", "called", "=", "False", "async", "def", "mock_func", "(", "hass", ",", "provider", ",", "args2", ")", ":", "\"\"\"Mock function to be called.\"\"\"", "nonlocal", "called", "called", "=", "True", "assert", "provi...
[ 109, 0 ]
[ 125, 53 ]
python
en
['en', 'en', 'en']
True
get_update_manager
(device)
Return an update manager for a given Broadlink device.
Return an update manager for a given Broadlink device.
def get_update_manager(device): """Return an update manager for a given Broadlink device.""" if device.api.model.startswith("RM mini"): return BroadlinkRMMini3UpdateManager(device) update_managers = { "A1": BroadlinkA1UpdateManager, "BG1": BroadlinkBG1UpdateManager, "MP1": B...
[ "def", "get_update_manager", "(", "device", ")", ":", "if", "device", ".", "api", ".", "model", ".", "startswith", "(", "\"RM mini\"", ")", ":", "return", "BroadlinkRMMini3UpdateManager", "(", "device", ")", "update_managers", "=", "{", "\"A1\"", ":", "Broadli...
[ 21, 0 ]
[ 37, 51 ]
python
en
['en', 'en', 'en']
True
BroadlinkUpdateManager.__init__
(self, device)
Initialize the update manager.
Initialize the update manager.
def __init__(self, device): """Initialize the update manager.""" self.device = device self.coordinator = DataUpdateCoordinator( device.hass, _LOGGER, name=f"{device.name} ({device.api.model} at {device.api.host[0]})", update_method=self.async_updat...
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "device", "=", "device", "self", ".", "coordinator", "=", "DataUpdateCoordinator", "(", "device", ".", "hass", ",", "_LOGGER", ",", "name", "=", "f\"{device.name} ({device.api.model} at {devic...
[ 49, 4 ]
[ 60, 31 ]
python
en
['en', 'en', 'en']
True
BroadlinkUpdateManager.async_update
(self)
Fetch data from the device and update availability.
Fetch data from the device and update availability.
async def async_update(self): """Fetch data from the device and update availability.""" try: data = await self.async_fetch_data() except (BroadlinkException, OSError) as err: if self.available and ( dt.utcnow() - self.last_update > self.SCAN_INTERVAL * 3 ...
[ "async", "def", "async_update", "(", "self", ")", ":", "try", ":", "data", "=", "await", "self", ".", "async_fetch_data", "(", ")", "except", "(", "BroadlinkException", ",", "OSError", ")", "as", "err", ":", "if", "self", ".", "available", "and", "(", ...
[ 62, 4 ]
[ 91, 23 ]
python
en
['en', 'en', 'en']
True
BroadlinkUpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device."""
[ "async", "def", "async_fetch_data", "(", "self", ")", ":" ]
[ 94, 4 ]
[ 95, 41 ]
python
en
['en', 'en', 'en']
True
BroadlinkA1UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" return await self.device.async_request(self.device.api.check_sensors_raw)
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "return", "await", "self", ".", "device", ".", "async_request", "(", "self", ".", "device", ".", "api", ".", "check_sensors_raw", ")" ]
[ 103, 4 ]
[ 105, 81 ]
python
en
['en', 'en', 'en']
True
BroadlinkMP1UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" return await self.device.async_request(self.device.api.check_power)
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "return", "await", "self", ".", "device", ".", "async_request", "(", "self", ".", "device", ".", "api", ".", "check_power", ")" ]
[ 111, 4 ]
[ 113, 75 ]
python
en
['en', 'en', 'en']
True
BroadlinkRMMini3UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" hello = partial( blk.discover, discover_ip_address=self.device.api.host[0], timeout=self.device.api.timeout, ) devices = await self.device.hass.async_add_executor_job(hello) if...
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "hello", "=", "partial", "(", "blk", ".", "discover", ",", "discover_ip_address", "=", "self", ".", "device", ".", "api", ".", "host", "[", "0", "]", ",", "timeout", "=", "self", ".", "device",...
[ 119, 4 ]
[ 129, 17 ]
python
en
['en', 'en', 'en']
True
BroadlinkRMUpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" return await self.device.async_request(self.device.api.check_sensors)
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "return", "await", "self", ".", "device", ".", "async_request", "(", "self", ".", "device", ".", "api", ".", "check_sensors", ")" ]
[ 135, 4 ]
[ 137, 77 ]
python
en
['en', 'en', 'en']
True
BroadlinkSP1UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" return None
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "return", "None" ]
[ 143, 4 ]
[ 145, 19 ]
python
en
['en', 'en', 'en']
True
BroadlinkSP2UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" data = {} data["state"] = await self.device.async_request(self.device.api.check_power) try: data["load_power"] = await self.device.async_request( self.device.api.get_energy ) ...
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "data", "=", "{", "}", "data", "[", "\"state\"", "]", "=", "await", "self", ".", "device", ".", "async_request", "(", "self", ".", "device", ".", "api", ".", "check_power", ")", "try", ":", "...
[ 151, 4 ]
[ 161, 19 ]
python
en
['en', 'en', 'en']
True
BroadlinkBG1UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" return await self.device.async_request(self.device.api.get_state)
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "return", "await", "self", ".", "device", ".", "async_request", "(", "self", ".", "device", ".", "api", ".", "get_state", ")" ]
[ 167, 4 ]
[ 169, 73 ]
python
en
['en', 'en', 'en']
True
BroadlinkSP4UpdateManager.async_fetch_data
(self)
Fetch data from the device.
Fetch data from the device.
async def async_fetch_data(self): """Fetch data from the device.""" return await self.device.async_request(self.device.api.get_state)
[ "async", "def", "async_fetch_data", "(", "self", ")", ":", "return", "await", "self", ".", "device", ".", "async_request", "(", "self", ".", "device", ".", "api", ".", "get_state", ")" ]
[ 175, 4 ]
[ 177, 73 ]
python
en
['en', 'en', 'en']
True
sort_dict
(value)
Sort a dictionary.
Sort a dictionary.
def sort_dict(value): """Sort a dictionary.""" return OrderedDict((key, value[key]) for key in sorted(value))
[ "def", "sort_dict", "(", "value", ")", ":", "return", "OrderedDict", "(", "(", "key", ",", "value", "[", "key", "]", ")", "for", "key", "in", "sorted", "(", "value", ")", ")" ]
[ 19, 0 ]
[ 21, 66 ]
python
it
['it', 'ca', 'it']
True
generate_and_validate
(integrations: Dict[str, Integration])
Validate and generate ssdp data.
Validate and generate ssdp data.
def generate_and_validate(integrations: Dict[str, Integration]): """Validate and generate ssdp data.""" data = defaultdict(list) for domain in sorted(integrations): integration = integrations[domain] if not integration.manifest: continue ssdp = integration.manifest.ge...
[ "def", "generate_and_validate", "(", "integrations", ":", "Dict", "[", "str", ",", "Integration", "]", ")", ":", "data", "=", "defaultdict", "(", "list", ")", "for", "domain", "in", "sorted", "(", "integrations", ")", ":", "integration", "=", "integrations",...
[ 24, 0 ]
[ 43, 50 ]
python
en
['en', 'en', 'en']
True
validate
(integrations: Dict[str, Integration], config: Config)
Validate ssdp file.
Validate ssdp file.
def validate(integrations: Dict[str, Integration], config: Config): """Validate ssdp file.""" ssdp_path = config.root / "homeassistant/generated/ssdp.py" config.cache["ssdp"] = content = generate_and_validate(integrations) if config.specific_integrations: return with open(str(ssdp_path)) a...
[ "def", "validate", "(", "integrations", ":", "Dict", "[", "str", ",", "Integration", "]", ",", "config", ":", "Config", ")", ":", "ssdp_path", "=", "config", ".", "root", "/", "\"homeassistant/generated/ssdp.py\"", "config", ".", "cache", "[", "\"ssdp\"", "]...
[ 46, 0 ]
[ 61, 14 ]
python
en
['en', 'et', 'it']
False
generate
(integrations: Dict[str, Integration], config: Config)
Generate ssdp file.
Generate ssdp file.
def generate(integrations: Dict[str, Integration], config: Config): """Generate ssdp file.""" ssdp_path = config.root / "homeassistant/generated/ssdp.py" with open(str(ssdp_path), "w") as fp: fp.write(f"{config.cache['ssdp']}\n")
[ "def", "generate", "(", "integrations", ":", "Dict", "[", "str", ",", "Integration", "]", ",", "config", ":", "Config", ")", ":", "ssdp_path", "=", "config", ".", "root", "/", "\"homeassistant/generated/ssdp.py\"", "with", "open", "(", "str", "(", "ssdp_path...
[ 64, 0 ]
[ 68, 45 ]
python
en
['en', 'id', 'it']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Kira platform.
Set up the Kira platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Kira platform.""" if discovery_info: name = discovery_info.get(CONF_NAME) device = discovery_info.get(CONF_DEVICE) kira = hass.data[DOMAIN][CONF_REMOTE][name] add_entities([KiraRemote(device, kira...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", ":", "name", "=", "discovery_info", ".", "get", "(", "CONF_NAME", ")", "device", "=", "discovery_info", ".", "get"...
[ 15, 0 ]
[ 23, 15 ]
python
en
['en', 'su', 'en']
True
KiraRemote.__init__
(self, name, kira)
Initialize KiraRemote class.
Initialize KiraRemote class.
def __init__(self, name, kira): """Initialize KiraRemote class.""" _LOGGER.debug("KiraRemote device init started for: %s", name) self._name = name self._kira = kira
[ "def", "__init__", "(", "self", ",", "name", ",", "kira", ")", ":", "_LOGGER", ".", "debug", "(", "\"KiraRemote device init started for: %s\"", ",", "name", ")", "self", ".", "_name", "=", "name", "self", ".", "_kira", "=", "kira" ]
[ 29, 4 ]
[ 33, 25 ]
python
co
['en', 'co', 'it']
False
KiraRemote.name
(self)
Return the Kira device's name.
Return the Kira device's name.
def name(self): """Return the Kira device's name.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 36, 4 ]
[ 38, 25 ]
python
en
['en', 'sq', 'en']
True
KiraRemote.send_command
(self, command, **kwargs)
Send a command to one device.
Send a command to one device.
def send_command(self, command, **kwargs): """Send a command to one device.""" for single_command in command: code_tuple = (single_command, kwargs.get(remote.ATTR_DEVICE)) _LOGGER.info("Sending Command: %s to %s", *code_tuple) self._kira.sendCode(code_tuple)
[ "def", "send_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "for", "single_command", "in", "command", ":", "code_tuple", "=", "(", "single_command", ",", "kwargs", ".", "get", "(", "remote", ".", "ATTR_DEVICE", ")", ")", "_LOGG...
[ 43, 4 ]
[ 48, 43 ]
python
en
['en', 'en', 'en']
True
KiraRemote.async_send_command
(self, command, **kwargs)
Send a command to a device.
Send a command to a device.
async def async_send_command(self, command, **kwargs): """Send a command to a device.""" return await self.hass.async_add_executor_job( ft.partial(self.send_command, command, **kwargs) )
[ "async", "def", "async_send_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "ft", ".", "partial", "(", "self", ".", "send_command", ",", "command", ",", ...
[ 50, 4 ]
[ 54, 9 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the Pi-hole integration.
Set up the Pi-hole integration.
async def async_setup(hass, config): """Set up the Pi-hole integration.""" hass.data[DOMAIN] = {} # import if DOMAIN in config: for conf in config[DOMAIN]: hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SO...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "# import", "if", "DOMAIN", "in", "config", ":", "for", "conf", "in", "config", "[", "DOMAIN", "]", ":", "hass", ".", "asyn...
[ 59, 0 ]
[ 73, 15 ]
python
en
['en', 'haw', 'en']
True
async_setup_entry
(hass, entry)
Set up Pi-hole entry.
Set up Pi-hole entry.
async def async_setup_entry(hass, entry): """Set up Pi-hole entry.""" name = entry.data[CONF_NAME] host = entry.data[CONF_HOST] use_tls = entry.data[CONF_SSL] verify_tls = entry.data[CONF_VERIFY_SSL] location = entry.data[CONF_LOCATION] api_key = entry.data.get(CONF_API_KEY) _LOGGER.deb...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "name", "=", "entry", ".", "data", "[", "CONF_NAME", "]", "host", "=", "entry", ".", "data", "[", "CONF_HOST", "]", "use_tls", "=", "entry", ".", "data", "[", "CONF_SSL", "]", ...
[ 76, 0 ]
[ 126, 15 ]
python
en
['en', 'zu', 'en']
True
async_unload_entry
(hass, entry)
Unload Pi-hole entry.
Unload Pi-hole entry.
async def async_unload_entry(hass, entry): """Unload Pi-hole entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in _async_platforms(entry) ] ) ) if unload...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "platform", ")", ...
[ 129, 0 ]
[ 141, 20 ]
python
en
['es', 'en', 'en']
True
_async_platforms
(entry)
Return platforms to be loaded / unloaded.
Return platforms to be loaded / unloaded.
def _async_platforms(entry): """Return platforms to be loaded / unloaded.""" platforms = ["sensor"] if entry.data.get(CONF_API_KEY): platforms.append("switch") else: platforms.append("binary_sensor") return platforms
[ "def", "_async_platforms", "(", "entry", ")", ":", "platforms", "=", "[", "\"sensor\"", "]", "if", "entry", ".", "data", ".", "get", "(", "CONF_API_KEY", ")", ":", "platforms", ".", "append", "(", "\"switch\"", ")", "else", ":", "platforms", ".", "append...
[ 145, 0 ]
[ 152, 20 ]
python
en
['en', 'da', 'en']
True
PiHoleEntity.__init__
(self, api, coordinator, name, server_unique_id)
Initialize a Pi-hole entity.
Initialize a Pi-hole entity.
def __init__(self, api, coordinator, name, server_unique_id): """Initialize a Pi-hole entity.""" super().__init__(coordinator) self.api = api self._name = name self._server_unique_id = server_unique_id
[ "def", "__init__", "(", "self", ",", "api", ",", "coordinator", ",", "name", ",", "server_unique_id", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "api", "=", "api", "self", ".", "_name", "=", "name", "self", "....
[ 158, 4 ]
[ 163, 49 ]
python
en
['en', 'haw', 'it']
False
PiHoleEntity.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return "mdi:pi-hole"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:pi-hole\"" ]
[ 166, 4 ]
[ 168, 28 ]
python
en
['en', 'en', 'en']
True
PiHoleEntity.device_info
(self)
Return the device information of the entity.
Return the device information of the entity.
def device_info(self): """Return the device information of the entity.""" return { "identifiers": {(DOMAIN, self._server_unique_id)}, "name": self._name, "manufacturer": "Pi-hole", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_server_unique_id", ")", "}", ",", "\"name\"", ":", "self", ".", "_name", ",", "\"manufacturer\"", ":", "\"Pi-hole\"", ",", "}" ]
[ 171, 4 ]
[ 177, 9 ]
python
en
['en', 'en', 'en']
True
setup_no_ip
(hass, aioclient_mock)
Fixture that sets up NO-IP.
Fixture that sets up NO-IP.
def setup_no_ip(hass, aioclient_mock): """Fixture that sets up NO-IP.""" aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="good 0.0.0.0") hass.loop.run_until_complete( async_setup_component( hass, no_ip.DOMAIN, { no_ip.DOMAIN: { ...
[ "def", "setup_no_ip", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "UPDATE_URL", ",", "params", "=", "{", "\"hostname\"", ":", "DOMAIN", "}", ",", "text", "=", "\"good 0.0.0.0\"", ")", "hass", ".", "loop", ".", "run_unti...
[ 21, 0 ]
[ 37, 5 ]
python
en
['en', 'ca', 'en']
True
test_setup
(hass, aioclient_mock)
Test setup works if update passes.
Test setup works if update passes.
async def test_setup(hass, aioclient_mock): """Test setup works if update passes.""" aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nochg 0.0.0.0") result = await async_setup_component( hass, no_ip.DOMAIN, {no_ip.DOMAIN: {"domain": DOMAIN, "username": USERNAME, "p...
[ "async", "def", "test_setup", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "UPDATE_URL", ",", "params", "=", "{", "\"hostname\"", ":", "DOMAIN", "}", ",", "text", "=", "\"nochg 0.0.0.0\"", ")", "result", "=", "await", "a...
[ 40, 0 ]
[ 54, 41 ]
python
en
['en', 'en', 'en']
True
test_setup_fails_if_update_fails
(hass, aioclient_mock)
Test setup fails if first update fails.
Test setup fails if first update fails.
async def test_setup_fails_if_update_fails(hass, aioclient_mock): """Test setup fails if first update fails.""" aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="nohost") result = await async_setup_component( hass, no_ip.DOMAIN, {no_ip.DOMAIN: {"domain": DOMAIN, "use...
[ "async", "def", "test_setup_fails_if_update_fails", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "UPDATE_URL", ",", "params", "=", "{", "\"hostname\"", ":", "DOMAIN", "}", ",", "text", "=", "\"nohost\"", ")", "result", "=", ...
[ 57, 0 ]
[ 67, 41 ]
python
en
['ms', 'lb', 'en']
False
test_setup_fails_if_wrong_auth
(hass, aioclient_mock)
Test setup fails if first update fails through wrong authentication.
Test setup fails if first update fails through wrong authentication.
async def test_setup_fails_if_wrong_auth(hass, aioclient_mock): """Test setup fails if first update fails through wrong authentication.""" aioclient_mock.get(UPDATE_URL, params={"hostname": DOMAIN}, text="badauth") result = await async_setup_component( hass, no_ip.DOMAIN, {no_ip.DOM...
[ "async", "def", "test_setup_fails_if_wrong_auth", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "UPDATE_URL", ",", "params", "=", "{", "\"hostname\"", ":", "DOMAIN", "}", ",", "text", "=", "\"badauth\"", ")", "result", "=", ...
[ 70, 0 ]
[ 80, 41 ]
python
en
['en', 'en', 'en']
True
AbstractConversationAgent.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return None
[ "def", "attribution", "(", "self", ")", ":", "return", "None" ]
[ 12, 4 ]
[ 14, 19 ]
python
en
['en', 'ja', 'en']
True
AbstractConversationAgent.async_get_onboarding
(self)
Get onboard data.
Get onboard data.
async def async_get_onboarding(self): """Get onboard data.""" return None
[ "async", "def", "async_get_onboarding", "(", "self", ")", ":", "return", "None" ]
[ 16, 4 ]
[ 18, 19 ]
python
en
['en', 'nl', 'en']
True
AbstractConversationAgent.async_set_onboarding
(self, shown)
Set onboard data.
Set onboard data.
async def async_set_onboarding(self, shown): """Set onboard data.""" return True
[ "async", "def", "async_set_onboarding", "(", "self", ",", "shown", ")", ":", "return", "True" ]
[ 20, 4 ]
[ 22, 19 ]
python
en
['en', 'fy', 'en']
True
AbstractConversationAgent.async_process
( self, text: str, context: Context, conversation_id: Optional[str] = None )
Process a sentence.
Process a sentence.
async def async_process( self, text: str, context: Context, conversation_id: Optional[str] = None ) -> intent.IntentResponse: """Process a sentence."""
[ "async", "def", "async_process", "(", "self", ",", "text", ":", "str", ",", "context", ":", "Context", ",", "conversation_id", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "intent", ".", "IntentResponse", ":" ]
[ 25, 4 ]
[ 28, 33 ]
python
en
['en', 'mk', 'en']
True
test_sensors
(hass)
Test we get sensor data.
Test we get sensor data.
async def test_sensors(hass): """Test we get sensor data.""" await init_integration(hass) test_username_glucose_value = hass.states.get( "sensor.dexcom_test_username_glucose_value" ) assert test_username_glucose_value.state == str(GLUCOSE_READING.value) test_username_glucose_trend = has...
[ "async", "def", "test_sensors", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "test_username_glucose_value", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.dexcom_test_username_glucose_value\"", ")", "assert", "test_username_glucose_value...
[ 15, 0 ]
[ 26, 81 ]
python
da
['nl', 'da', 'en']
False
test_sensors_unknown
(hass)
Test we handle sensor state unknown.
Test we handle sensor state unknown.
async def test_sensors_unknown(hass): """Test we handle sensor state unknown.""" await init_integration(hass) with patch( "homeassistant.components.dexcom.Dexcom.get_current_glucose_reading", return_value=None, ): await hass.helpers.entity_component.async_update_entity( ...
[ "async", "def", "test_sensors_unknown", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.dexcom.Dexcom.get_current_glucose_reading\"", ",", "return_value", "=", "None", ",", ")", ":", "await", "has...
[ 29, 0 ]
[ 51, 61 ]
python
en
['en', 'en', 'en']
True
test_sensors_update_failed
(hass)
Test we handle sensor update failed.
Test we handle sensor update failed.
async def test_sensors_update_failed(hass): """Test we handle sensor update failed.""" await init_integration(hass) with patch( "homeassistant.components.dexcom.Dexcom.get_current_glucose_reading", side_effect=SessionError, ): await hass.helpers.entity_component.async_update_ent...
[ "async", "def", "test_sensors_update_failed", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.dexcom.Dexcom.get_current_glucose_reading\"", ",", "side_effect", "=", "SessionError", ",", ")", ":", "a...
[ 54, 0 ]
[ 76, 65 ]
python
en
['en', 'et', 'en']
True
test_sensors_options_changed
(hass)
Test we handle sensor unavailable.
Test we handle sensor unavailable.
async def test_sensors_options_changed(hass): """Test we handle sensor unavailable.""" entry = await init_integration(hass) test_username_glucose_value = hass.states.get( "sensor.dexcom_test_username_glucose_value" ) assert test_username_glucose_value.state == str(GLUCOSE_READING.value) ...
[ "async", "def", "test_sensors_options_changed", "(", "hass", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "test_username_glucose_value", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.dexcom_test_username_glucose_value\"", ")", "asser...
[ 79, 0 ]
[ 114, 81 ]
python
es
['es', 'nl', 'it']
False
setup_fritzbox
(hass: HomeAssistantType, config: dict)
Set up mock AVM Fritz!Box.
Set up mock AVM Fritz!Box.
async def setup_fritzbox(hass: HomeAssistantType, config: dict): """Set up mock AVM Fritz!Box.""" assert await async_setup_component(hass, FB_DOMAIN, config) await hass.async_block_till_done()
[ "async", "def", "setup_fritzbox", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "dict", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "FB_DOMAIN", ",", "config", ")", "await", "hass", ".", "async_block_till_done", "(", ")...
[ 36, 0 ]
[ 39, 38 ]
python
en
['en', 'zu', 'en']
True
test_setup
(hass: HomeAssistantType, fritz: Mock)
Test setup of platform.
Test setup of platform.
async def test_setup(hass: HomeAssistantType, fritz: Mock): """Test setup of platform.""" device = FritzDeviceSwitchMock() fritz().get_devices.return_value = [device] await setup_fritzbox(hass, MOCK_CONFIG) state = hass.states.get(ENTITY_ID) assert state assert state.state == STATE_ON ...
[ "async", "def", "test_setup", "(", "hass", ":", "HomeAssistantType", ",", "fritz", ":", "Mock", ")", ":", "device", "=", "FritzDeviceSwitchMock", "(", ")", "fritz", "(", ")", ".", "get_devices", ".", "return_value", "=", "[", "device", "]", "await", "setup...
[ 42, 0 ]
[ 59, 81 ]
python
en
['en', 'da', 'en']
True
test_turn_on
(hass: HomeAssistantType, fritz: Mock)
Test turn device on.
Test turn device on.
async def test_turn_on(hass: HomeAssistantType, fritz: Mock): """Test turn device on.""" device = FritzDeviceSwitchMock() fritz().get_devices.return_value = [device] await setup_fritzbox(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENT...
[ "async", "def", "test_turn_on", "(", "hass", ":", "HomeAssistantType", ",", "fritz", ":", "Mock", ")", ":", "device", "=", "FritzDeviceSwitchMock", "(", ")", "fritz", "(", ")", ".", "get_devices", ".", "return_value", "=", "[", "device", "]", "await", "set...
[ 62, 0 ]
[ 72, 53 ]
python
en
['es', 'en', 'en']
True
test_turn_off
(hass: HomeAssistantType, fritz: Mock)
Test turn device off.
Test turn device off.
async def test_turn_off(hass: HomeAssistantType, fritz: Mock): """Test turn device off.""" device = FritzDeviceSwitchMock() fritz().get_devices.return_value = [device] await setup_fritzbox(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ...
[ "async", "def", "test_turn_off", "(", "hass", ":", "HomeAssistantType", ",", "fritz", ":", "Mock", ")", ":", "device", "=", "FritzDeviceSwitchMock", "(", ")", "fritz", "(", ")", ".", "get_devices", ".", "return_value", "=", "[", "device", "]", "await", "se...
[ 75, 0 ]
[ 85, 54 ]
python
en
['en', 'en', 'en']
True
test_update
(hass: HomeAssistantType, fritz: Mock)
Test update with error.
Test update with error.
async def test_update(hass: HomeAssistantType, fritz: Mock): """Test update with error.""" device = FritzDeviceSwitchMock() fritz().get_devices.return_value = [device] await setup_fritzbox(hass, MOCK_CONFIG) assert device.update.call_count == 0 assert fritz().login.call_count == 1 next_upd...
[ "async", "def", "test_update", "(", "hass", ":", "HomeAssistantType", ",", "fritz", ":", "Mock", ")", ":", "device", "=", "FritzDeviceSwitchMock", "(", ")", "fritz", "(", ")", ".", "get_devices", ".", "return_value", "=", "[", "device", "]", "await", "setu...
[ 88, 0 ]
[ 102, 40 ]
python
en
['en', 'de', 'en']
True
test_update_error
(hass: HomeAssistantType, fritz: Mock)
Test update with error.
Test update with error.
async def test_update_error(hass: HomeAssistantType, fritz: Mock): """Test update with error.""" device = FritzDeviceSwitchMock() device.update.side_effect = HTTPError("Boom") fritz().get_devices.return_value = [device] await setup_fritzbox(hass, MOCK_CONFIG) assert device.update.call_count == ...
[ "async", "def", "test_update_error", "(", "hass", ":", "HomeAssistantType", ",", "fritz", ":", "Mock", ")", ":", "device", "=", "FritzDeviceSwitchMock", "(", ")", "device", ".", "update", ".", "side_effect", "=", "HTTPError", "(", "\"Boom\"", ")", "fritz", "...
[ 105, 0 ]
[ 120, 40 ]
python
en
['en', 'de', 'en']
True
clear_secret_cache
()
Clear the secret cache. Async friendly.
Clear the secret cache.
def clear_secret_cache() -> None: """Clear the secret cache. Async friendly. """ __SECRET_CACHE.clear()
[ "def", "clear_secret_cache", "(", ")", "->", "None", ":", "__SECRET_CACHE", ".", "clear", "(", ")" ]
[ 35, 0 ]
[ 40, 26 ]
python
en
['en', 'fr', 'en']
True
load_yaml
(fname: str)
Load a YAML file.
Load a YAML file.
def load_yaml(fname: str) -> JSON_TYPE: """Load a YAML file.""" try: with open(fname, encoding="utf-8") as conf_file: return parse_yaml(conf_file) except UnicodeDecodeError as exc: _LOGGER.error("Unable to read file %s: %s", fname, exc) raise HomeAssistantError(exc) from ...
[ "def", "load_yaml", "(", "fname", ":", "str", ")", "->", "JSON_TYPE", ":", "try", ":", "with", "open", "(", "fname", ",", "encoding", "=", "\"utf-8\"", ")", "as", "conf_file", ":", "return", "parse_yaml", "(", "conf_file", ")", "except", "UnicodeDecodeErro...
[ 54, 0 ]
[ 61, 46 ]
python
en
['en', 'ny', 'it']
False
parse_yaml
(content: Union[str, TextIO])
Load a YAML file.
Load a YAML file.
def parse_yaml(content: Union[str, TextIO]) -> JSON_TYPE: """Load a YAML file.""" try: # If configuration file is empty YAML returns None # We convert that to an empty dict return yaml.load(content, Loader=SafeLineLoader) or OrderedDict() except yaml.YAMLError as exc: _LOGGER...
[ "def", "parse_yaml", "(", "content", ":", "Union", "[", "str", ",", "TextIO", "]", ")", "->", "JSON_TYPE", ":", "try", ":", "# If configuration file is empty YAML returns None", "# We convert that to an empty dict", "return", "yaml", ".", "load", "(", "content", ","...
[ 64, 0 ]
[ 72, 46 ]
python
en
['en', 'ny', 'it']
False
_add_reference
(obj, loader: SafeLineLoader, node: yaml.nodes.Node)
Add file reference information to an object.
Add file reference information to an object.
def _add_reference(obj, loader: SafeLineLoader, node: yaml.nodes.Node): # type: ignore """Add file reference information to an object.""" if isinstance(obj, list): obj = NodeListClass(obj) if isinstance(obj, str): obj = NodeStrClass(obj) setattr(obj, "__config_file__", loader.name) ...
[ "def", "_add_reference", "(", "obj", ",", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", ":", "# type: ignore", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "obj", "=", "NodeListClass", "(", "obj", ...
[ 96, 0 ]
[ 104, 14 ]
python
en
['en', 'en', 'en']
True
_include_yaml
(loader: SafeLineLoader, node: yaml.nodes.Node)
Load another YAML file and embeds it using the !include tag. Example: device_tracker: !include device_tracker.yaml
Load another YAML file and embeds it using the !include tag.
def _include_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE: """Load another YAML file and embeds it using the !include tag. Example: device_tracker: !include device_tracker.yaml """ fname = os.path.join(os.path.dirname(loader.name), node.value) try: return _add_r...
[ "def", "_include_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "JSON_TYPE", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "loader", ".", ...
[ 107, 0 ]
[ 120, 18 ]
python
en
['en', 'en', 'en']
True
_is_file_valid
(name: str)
Decide if a file is valid.
Decide if a file is valid.
def _is_file_valid(name: str) -> bool: """Decide if a file is valid.""" return not name.startswith(".")
[ "def", "_is_file_valid", "(", "name", ":", "str", ")", "->", "bool", ":", "return", "not", "name", ".", "startswith", "(", "\".\"", ")" ]
[ 123, 0 ]
[ 125, 35 ]
python
en
['en', 'en', 'en']
True
_find_files
(directory: str, pattern: str)
Recursively load files in a directory.
Recursively load files in a directory.
def _find_files(directory: str, pattern: str) -> Iterator[str]: """Recursively load files in a directory.""" for root, dirs, files in os.walk(directory, topdown=True): dirs[:] = [d for d in dirs if _is_file_valid(d)] for basename in sorted(files): if _is_file_valid(basename) and fnma...
[ "def", "_find_files", "(", "directory", ":", "str", ",", "pattern", ":", "str", ")", "->", "Iterator", "[", "str", "]", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "directory", ",", "topdown", "=", "True", ")", ":",...
[ 128, 0 ]
[ 135, 30 ]
python
en
['en', 'en', 'en']
True
_include_dir_named_yaml
( loader: SafeLineLoader, node: yaml.nodes.Node )
Load multiple files from directory as a dictionary.
Load multiple files from directory as a dictionary.
def _include_dir_named_yaml( loader: SafeLineLoader, node: yaml.nodes.Node ) -> OrderedDict: """Load multiple files from directory as a dictionary.""" mapping: OrderedDict = OrderedDict() loc = os.path.join(os.path.dirname(loader.name), node.value) for fname in _find_files(loc, "*.yaml"): fi...
[ "def", "_include_dir_named_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "OrderedDict", ":", "mapping", ":", "OrderedDict", "=", "OrderedDict", "(", ")", "loc", "=", "os", ".", "path", ".", "...
[ 138, 0 ]
[ 149, 48 ]
python
en
['en', 'en', 'en']
True
_include_dir_merge_named_yaml
( loader: SafeLineLoader, node: yaml.nodes.Node )
Load multiple files from directory as a merged dictionary.
Load multiple files from directory as a merged dictionary.
def _include_dir_merge_named_yaml( loader: SafeLineLoader, node: yaml.nodes.Node ) -> OrderedDict: """Load multiple files from directory as a merged dictionary.""" mapping: OrderedDict = OrderedDict() loc = os.path.join(os.path.dirname(loader.name), node.value) for fname in _find_files(loc, "*.yaml"...
[ "def", "_include_dir_merge_named_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "OrderedDict", ":", "mapping", ":", "OrderedDict", "=", "OrderedDict", "(", ")", "loc", "=", "os", ".", "path", "....
[ 152, 0 ]
[ 164, 48 ]
python
en
['en', 'en', 'en']
True
_include_dir_list_yaml
( loader: SafeLineLoader, node: yaml.nodes.Node )
Load multiple files from directory as a list.
Load multiple files from directory as a list.
def _include_dir_list_yaml( loader: SafeLineLoader, node: yaml.nodes.Node ) -> List[JSON_TYPE]: """Load multiple files from directory as a list.""" loc = os.path.join(os.path.dirname(loader.name), node.value) return [ load_yaml(f) for f in _find_files(loc, "*.yaml") if os.path.ba...
[ "def", "_include_dir_list_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "List", "[", "JSON_TYPE", "]", ":", "loc", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirna...
[ 167, 0 ]
[ 176, 5 ]
python
en
['en', 'en', 'en']
True
_include_dir_merge_list_yaml
( loader: SafeLineLoader, node: yaml.nodes.Node )
Load multiple files from directory as a merged list.
Load multiple files from directory as a merged list.
def _include_dir_merge_list_yaml( loader: SafeLineLoader, node: yaml.nodes.Node ) -> JSON_TYPE: """Load multiple files from directory as a merged list.""" loc: str = os.path.join(os.path.dirname(loader.name), node.value) merged_list: List[JSON_TYPE] = [] for fname in _find_files(loc, "*.yaml"): ...
[ "def", "_include_dir_merge_list_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "JSON_TYPE", ":", "loc", ":", "str", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname...
[ 179, 0 ]
[ 191, 52 ]
python
en
['en', 'en', 'en']
True
_ordered_dict
(loader: SafeLineLoader, node: yaml.nodes.MappingNode)
Load YAML mappings into an ordered dictionary to preserve key order.
Load YAML mappings into an ordered dictionary to preserve key order.
def _ordered_dict(loader: SafeLineLoader, node: yaml.nodes.MappingNode) -> OrderedDict: """Load YAML mappings into an ordered dictionary to preserve key order.""" loader.flatten_mapping(node) nodes = loader.construct_pairs(node) seen: Dict = {} for (key, _), (child_node, _) in zip(nodes, node.value...
[ "def", "_ordered_dict", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "MappingNode", ")", "->", "OrderedDict", ":", "loader", ".", "flatten_mapping", "(", "node", ")", "nodes", "=", "loader", ".", "construct_pairs", "(", ...
[ 194, 0 ]
[ 223, 59 ]
python
en
['en', 'en', 'en']
True
_construct_seq
(loader: SafeLineLoader, node: yaml.nodes.Node)
Add line number and file name to Load YAML sequence.
Add line number and file name to Load YAML sequence.
def _construct_seq(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE: """Add line number and file name to Load YAML sequence.""" (obj,) = loader.construct_yaml_seq(node) return _add_reference(obj, loader, node)
[ "def", "_construct_seq", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "JSON_TYPE", ":", "(", "obj", ",", ")", "=", "loader", ".", "construct_yaml_seq", "(", "node", ")", "return", "_add_reference", ...
[ 226, 0 ]
[ 229, 44 ]
python
en
['en', 'en', 'en']
True
_env_var_yaml
(loader: SafeLineLoader, node: yaml.nodes.Node)
Load environment variables and embed it into the configuration YAML.
Load environment variables and embed it into the configuration YAML.
def _env_var_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> str: """Load environment variables and embed it into the configuration YAML.""" args = node.value.split() # Check for a default value if len(args) > 1: return os.getenv(args[0], " ".join(args[1:])) if args[0] in os.environ:...
[ "def", "_env_var_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "str", ":", "args", "=", "node", ".", "value", ".", "split", "(", ")", "# Check for a default value", "if", "len", "(", "args", ...
[ 232, 0 ]
[ 242, 40 ]
python
en
['en', 'en', 'en']
True
_load_secret_yaml
(secret_path: str)
Load the secrets yaml from path.
Load the secrets yaml from path.
def _load_secret_yaml(secret_path: str) -> JSON_TYPE: """Load the secrets yaml from path.""" secret_path = os.path.join(secret_path, SECRET_YAML) if secret_path in __SECRET_CACHE: return __SECRET_CACHE[secret_path] _LOGGER.debug("Loading %s", secret_path) try: secrets = load_yaml(se...
[ "def", "_load_secret_yaml", "(", "secret_path", ":", "str", ")", "->", "JSON_TYPE", ":", "secret_path", "=", "os", ".", "path", ".", "join", "(", "secret_path", ",", "SECRET_YAML", ")", "if", "secret_path", "in", "__SECRET_CACHE", ":", "return", "__SECRET_CACH...
[ 245, 0 ]
[ 269, 18 ]
python
en
['en', 'en', 'en']
True
secret_yaml
(loader: SafeLineLoader, node: yaml.nodes.Node)
Load secrets and embed it into the configuration YAML.
Load secrets and embed it into the configuration YAML.
def secret_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE: """Load secrets and embed it into the configuration YAML.""" secret_path = os.path.dirname(loader.name) while True: secrets = _load_secret_yaml(secret_path) if node.value in secrets: _LOGGER.debug( ...
[ "def", "secret_yaml", "(", "loader", ":", "SafeLineLoader", ",", "node", ":", "yaml", ".", "nodes", ".", "Node", ")", "->", "JSON_TYPE", ":", "secret_path", "=", "os", ".", "path", ".", "dirname", "(", "loader", ".", "name", ")", "while", "True", ":", ...
[ 272, 0 ]
[ 315, 64 ]
python
en
['en', 'en', 'en']
True
SafeLineLoader.compose_node
(self, parent: yaml.nodes.Node, index: int)
Annotate a node with the first line it was seen.
Annotate a node with the first line it was seen.
def compose_node(self, parent: yaml.nodes.Node, index: int) -> yaml.nodes.Node: """Annotate a node with the first line it was seen.""" last_line: int = self.line node: yaml.nodes.Node = super().compose_node(parent, index) node.__line__ = last_line + 1 # type: ignore return node
[ "def", "compose_node", "(", "self", ",", "parent", ":", "yaml", ".", "nodes", ".", "Node", ",", "index", ":", "int", ")", "->", "yaml", ".", "nodes", ".", "Node", ":", "last_line", ":", "int", "=", "self", ".", "line", "node", ":", "yaml", ".", "...
[ 46, 4 ]
[ 51, 19 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the raspihats component.
Set up the raspihats component.
def setup(hass, config): """Set up the raspihats component.""" hass.data[I2C_HATS_MANAGER] = I2CHatsManager() def start_i2c_hats_keep_alive(event): """Start I2C-HATs keep alive.""" hass.data[I2C_HATS_MANAGER].start_keep_alive() def stop_i2c_hats_keep_alive(event): """Stop I2C-H...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "I2C_HATS_MANAGER", "]", "=", "I2CHatsManager", "(", ")", "def", "start_i2c_hats_keep_alive", "(", "event", ")", ":", "\"\"\"Start I2C-HATs keep alive.\"\"\"", "hass", ".", "data", ...
[ 31, 0 ]
[ 45, 15 ]
python
en
['en', 'bg', 'en']
True
log_message
(source, *parts)
Build log message.
Build log message.
def log_message(source, *parts): """Build log message.""" message = source.__class__.__name__ for part in parts: message += f": {part!s}" return message
[ "def", "log_message", "(", "source", ",", "*", "parts", ")", ":", "message", "=", "source", ".", "__class__", ".", "__name__", "for", "part", "in", "parts", ":", "message", "+=", "f\": {part!s}\"", "return", "message" ]
[ 48, 0 ]
[ 53, 18 ]
python
da
['da', 'da', 'en']
True
I2CHatsDIScanner.setup
(self, i2c_hat)
Set up the I2C-HAT instance for digital inputs scanner.
Set up the I2C-HAT instance for digital inputs scanner.
def setup(self, i2c_hat): """Set up the I2C-HAT instance for digital inputs scanner.""" if hasattr(i2c_hat, self._DIGITAL_INPUTS): digital_inputs = getattr(i2c_hat, self._DIGITAL_INPUTS) old_value = None # Add old value attribute setattr(digital_inputs, se...
[ "def", "setup", "(", "self", ",", "i2c_hat", ")", ":", "if", "hasattr", "(", "i2c_hat", ",", "self", ".", "_DIGITAL_INPUTS", ")", ":", "digital_inputs", "=", "getattr", "(", "i2c_hat", ",", "self", ".", "_DIGITAL_INPUTS", ")", "old_value", "=", "None", "...
[ 67, 4 ]
[ 75, 56 ]
python
en
['en', 'da', 'en']
True
I2CHatsDIScanner.register_callback
(self, i2c_hat, channel, callback)
Register edge callback.
Register edge callback.
def register_callback(self, i2c_hat, channel, callback): """Register edge callback.""" if hasattr(i2c_hat, self._DIGITAL_INPUTS): digital_inputs = getattr(i2c_hat, self._DIGITAL_INPUTS) callbacks = getattr(digital_inputs, self._CALLBACKS) callbacks[channel] = callback...
[ "def", "register_callback", "(", "self", ",", "i2c_hat", ",", "channel", ",", "callback", ")", ":", "if", "hasattr", "(", "i2c_hat", ",", "self", ".", "_DIGITAL_INPUTS", ")", ":", "digital_inputs", "=", "getattr", "(", "i2c_hat", ",", "self", ".", "_DIGITA...
[ 77, 4 ]
[ 83, 63 ]
python
da
['da', 'no', 'en']
False
I2CHatsDIScanner.scan
(self, i2c_hat)
Scan I2C-HATs digital inputs and fire callbacks.
Scan I2C-HATs digital inputs and fire callbacks.
def scan(self, i2c_hat): """Scan I2C-HATs digital inputs and fire callbacks.""" if hasattr(i2c_hat, self._DIGITAL_INPUTS): digital_inputs = getattr(i2c_hat, self._DIGITAL_INPUTS) callbacks = getattr(digital_inputs, self._CALLBACKS) old_value = getattr(digital_inputs, ...
[ "def", "scan", "(", "self", ",", "i2c_hat", ")", ":", "if", "hasattr", "(", "i2c_hat", ",", "self", ".", "_DIGITAL_INPUTS", ")", ":", "digital_inputs", "=", "getattr", "(", "i2c_hat", ",", "self", ".", "_DIGITAL_INPUTS", ")", "callbacks", "=", "getattr", ...
[ 85, 4 ]
[ 100, 59 ]
python
en
['en', 'bg', 'en']
True
I2CHatsManager.__init__
(self)
Init I2C-HATs Manager.
Init I2C-HATs Manager.
def __init__(self): """Init I2C-HATs Manager.""" threading.Thread.__init__(self) self._lock = threading.Lock() self._i2c_hats = {} self._run = False self._di_scanner = I2CHatsDIScanner()
[ "def", "__init__", "(", "self", ")", ":", "threading", ".", "Thread", ".", "__init__", "(", "self", ")", "self", ".", "_lock", "=", "threading", ".", "Lock", "(", ")", "self", ".", "_i2c_hats", "=", "{", "}", "self", ".", "_run", "=", "False", "sel...
[ 109, 4 ]
[ 115, 45 ]
python
en
['en', 'en', 'en']
True
I2CHatsManager.register_board
(self, board, address)
Register I2C-HAT.
Register I2C-HAT.
def register_board(self, board, address): """Register I2C-HAT.""" with self._lock: i2c_hat = self._i2c_hats.get(address) if i2c_hat is None: # This is a Pi module and can't be installed in CI without # breaking the build. # pylint: ...
[ "def", "register_board", "(", "self", ",", "board", ",", "address", ")", ":", "with", "self", ".", "_lock", ":", "i2c_hat", "=", "self", ".", "_i2c_hats", ".", "get", "(", "address", ")", "if", "i2c_hat", "is", "None", ":", "# This is a Pi module and can't...
[ 117, 4 ]
[ 138, 83 ]
python
en
['en', 'da', 'en']
False
I2CHatsManager.run
(self)
Keep alive for I2C-HATs.
Keep alive for I2C-HATs.
def run(self): """Keep alive for I2C-HATs.""" # This is a Pi module and can't be installed in CI without # breaking the build. # pylint: disable=import-outside-toplevel,import-error from raspihats.i2c_hats import ResponseException _LOGGER.info(log_message(self, "starting...
[ "def", "run", "(", "self", ")", ":", "# This is a Pi module and can't be installed in CI without", "# breaking the build.", "# pylint: disable=import-outside-toplevel,import-error", "from", "raspihats", ".", "i2c_hats", "import", "ResponseException", "_LOGGER", ".", "info", "(", ...
[ 140, 4 ]
[ 171, 50 ]
python
en
['en', 'en', 'en']
True
I2CHatsManager._read_status
(self, i2c_hat)
Read I2C-HATs status.
Read I2C-HATs status.
def _read_status(self, i2c_hat): """Read I2C-HATs status.""" status_word = i2c_hat.status if status_word.value != 0x00: _LOGGER.error(log_message(self, i2c_hat, status_word))
[ "def", "_read_status", "(", "self", ",", "i2c_hat", ")", ":", "status_word", "=", "i2c_hat", ".", "status", "if", "status_word", ".", "value", "!=", "0x00", ":", "_LOGGER", ".", "error", "(", "log_message", "(", "self", ",", "i2c_hat", ",", "status_word", ...
[ 173, 4 ]
[ 177, 66 ]
python
en
['en', 'bg', 'en']
True
I2CHatsManager.start_keep_alive
(self)
Start keep alive mechanism.
Start keep alive mechanism.
def start_keep_alive(self): """Start keep alive mechanism.""" self._run = True threading.Thread.start(self)
[ "def", "start_keep_alive", "(", "self", ")", ":", "self", ".", "_run", "=", "True", "threading", ".", "Thread", ".", "start", "(", "self", ")" ]
[ 179, 4 ]
[ 182, 36 ]
python
en
['en', 'lb', 'en']
True
I2CHatsManager.stop_keep_alive
(self)
Stop keep alive mechanism.
Stop keep alive mechanism.
def stop_keep_alive(self): """Stop keep alive mechanism.""" self._run = False self.join()
[ "def", "stop_keep_alive", "(", "self", ")", ":", "self", ".", "_run", "=", "False", "self", ".", "join", "(", ")" ]
[ 184, 4 ]
[ 187, 19 ]
python
en
['en', 'nl', 'en']
True
I2CHatsManager.register_di_callback
(self, address, channel, callback)
Register I2C-HAT digital input edge callback.
Register I2C-HAT digital input edge callback.
def register_di_callback(self, address, channel, callback): """Register I2C-HAT digital input edge callback.""" with self._lock: i2c_hat = self._i2c_hats[address] self._di_scanner.register_callback(i2c_hat, channel, callback)
[ "def", "register_di_callback", "(", "self", ",", "address", ",", "channel", ",", "callback", ")", ":", "with", "self", ".", "_lock", ":", "i2c_hat", "=", "self", ".", "_i2c_hats", "[", "address", "]", "self", ".", "_di_scanner", ".", "register_callback", "...
[ 189, 4 ]
[ 193, 74 ]
python
bg
['da', 'bg', 'en']
False
I2CHatsManager.register_online_callback
(self, address, channel, callback)
Register I2C-HAT online callback.
Register I2C-HAT online callback.
def register_online_callback(self, address, channel, callback): """Register I2C-HAT online callback.""" with self._lock: i2c_hat = self._i2c_hats[address] callbacks = getattr(i2c_hat, self._CALLBACKS) callbacks[channel] = callback setattr(i2c_hat, self._CA...
[ "def", "register_online_callback", "(", "self", ",", "address", ",", "channel", ",", "callback", ")", ":", "with", "self", ".", "_lock", ":", "i2c_hat", "=", "self", ".", "_i2c_hats", "[", "address", "]", "callbacks", "=", "getattr", "(", "i2c_hat", ",", ...
[ 195, 4 ]
[ 201, 56 ]
python
da
['it', 'da', 'en']
False
I2CHatsManager.read_di
(self, address, channel)
Read a value from a I2C-HAT digital input.
Read a value from a I2C-HAT digital input.
def read_di(self, address, channel): """Read a value from a I2C-HAT digital input.""" # This is a Pi module and can't be installed in CI without # breaking the build. # pylint: disable=import-outside-toplevel,import-error from raspihats.i2c_hats import ResponseException ...
[ "def", "read_di", "(", "self", ",", "address", ",", "channel", ")", ":", "# This is a Pi module and can't be installed in CI without", "# breaking the build.", "# pylint: disable=import-outside-toplevel,import-error", "from", "raspihats", ".", "i2c_hats", "import", "ResponseExcep...
[ 203, 4 ]
[ 216, 55 ]
python
en
['en', 'en', 'en']
True
I2CHatsManager.write_dq
(self, address, channel, value)
Write a value to a I2C-HAT digital output.
Write a value to a I2C-HAT digital output.
def write_dq(self, address, channel, value): """Write a value to a I2C-HAT digital output.""" # This is a Pi module and can't be installed in CI without # breaking the build. # pylint: disable=import-outside-toplevel,import-error from raspihats.i2c_hats import ResponseException ...
[ "def", "write_dq", "(", "self", ",", "address", ",", "channel", ",", "value", ")", ":", "# This is a Pi module and can't be installed in CI without", "# breaking the build.", "# pylint: disable=import-outside-toplevel,import-error", "from", "raspihats", ".", "i2c_hats", "import...
[ 218, 4 ]
[ 230, 55 ]
python
en
['en', 'haw', 'en']
True
I2CHatsManager.read_dq
(self, address, channel)
Read a value from a I2C-HAT digital output.
Read a value from a I2C-HAT digital output.
def read_dq(self, address, channel): """Read a value from a I2C-HAT digital output.""" # This is a Pi module and can't be installed in CI without # breaking the build. # pylint: disable=import-outside-toplevel,import-error from raspihats.i2c_hats import ResponseException ...
[ "def", "read_dq", "(", "self", ",", "address", ",", "channel", ")", ":", "# This is a Pi module and can't be installed in CI without", "# breaking the build.", "# pylint: disable=import-outside-toplevel,import-error", "from", "raspihats", ".", "i2c_hats", "import", "ResponseExcep...
[ 232, 4 ]
[ 244, 55 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Modbus binary sensors.
Set up the Modbus binary sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Modbus binary sensors.""" sensors = [] for entry in config[CONF_INPUTS]: hub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]] sensors.append( ModbusBinarySensor( hub, ent...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "sensors", "=", "[", "]", "for", "entry", "in", "config", "[", "CONF_INPUTS", "]", ":", "hub", "=", "hass", ".", "data", "[", "MODBU...
[ 53, 0 ]
[ 69, 25 ]
python
en
['en', 'mk', 'en']
True
ModbusBinarySensor.__init__
(self, hub, name, slave, address, device_class, input_type)
Initialize the Modbus binary sensor.
Initialize the Modbus binary sensor.
def __init__(self, hub, name, slave, address, device_class, input_type): """Initialize the Modbus binary sensor.""" self._hub = hub self._name = name self._slave = int(slave) if slave else None self._address = int(address) self._device_class = device_class self._i...
[ "def", "__init__", "(", "self", ",", "hub", ",", "name", ",", "slave", ",", "address", ",", "device_class", ",", "input_type", ")", ":", "self", ".", "_hub", "=", "hub", "self", ".", "_name", "=", "name", "self", ".", "_slave", "=", "int", "(", "sl...
[ 75, 4 ]
[ 84, 30 ]
python
en
['en', 'pl', 'en']
True
ModbusBinarySensor.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" ]
[ 87, 4 ]
[ 89, 25 ]
python
en
['en', 'mi', 'en']
True
ModbusBinarySensor.is_on
(self)
Return the state of the sensor.
Return the state of the sensor.
def is_on(self): """Return the state of the sensor.""" return self._value
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_value" ]
[ 92, 4 ]
[ 94, 26 ]
python
en
['en', 'en', 'en']
True
ModbusBinarySensor.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self) -> Optional[str]: """Return the device class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_device_class" ]
[ 97, 4 ]
[ 99, 33 ]
python
en
['en', 'en', 'en']
True
ModbusBinarySensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 102, 4 ]
[ 104, 30 ]
python
en
['en', 'en', 'en']
True
ModbusBinarySensor.update
(self)
Update the state of the sensor.
Update the state of the sensor.
def update(self): """Update the state of the sensor.""" try: if self._input_type == CALL_TYPE_COIL: result = self._hub.read_coils(self._slave, self._address, 1) else: result = self._hub.read_discrete_inputs(self._slave, self._address, 1) ex...
[ "def", "update", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_input_type", "==", "CALL_TYPE_COIL", ":", "result", "=", "self", ".", "_hub", ".", "read_coils", "(", "self", ".", "_slave", ",", "self", ".", "_address", ",", "1", ")", "else",...
[ 106, 4 ]
[ 122, 30 ]
python
en
['en', 'en', 'en']
True
test_sensors
(hass, nzbget_api)
Test the creation and values of the sensors.
Test the creation and values of the sensors.
async def test_sensors(hass, nzbget_api) -> None: """Test the creation and values of the sensors.""" now = dt_util.utcnow().replace(microsecond=0) with patch("homeassistant.components.nzbget.sensor.utcnow", return_value=now): entry = await init_integration(hass) registry = await hass.helpers.en...
[ "async", "def", "test_sensors", "(", "hass", ",", "nzbget_api", ")", "->", "None", ":", "now", "=", "dt_util", ".", "utcnow", "(", ")", ".", "replace", "(", "microsecond", "=", "0", ")", "with", "patch", "(", "\"homeassistant.components.nzbget.sensor.utcnow\""...
[ 16, 0 ]
[ 53, 37 ]
python
en
['en', 'en', 'en']
True
mock_auth
()
Mock authenticate.
Mock authenticate.
def mock_auth(): """Mock authenticate.""" with patch( "homeassistant.components.tradfri.config_flow.authenticate" ) as mock_auth: yield mock_auth
[ "def", "mock_auth", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.tradfri.config_flow.authenticate\"", ")", "as", "mock_auth", ":", "yield", "mock_auth" ]
[ 11, 0 ]
[ 16, 23 ]
python
en
['de', 'en', 'en']
False
test_user_connection_successful
(hass, mock_auth, mock_entry_setup)
Test a successful connection.
Test a successful connection.
async def test_user_connection_successful(hass, mock_auth, mock_entry_setup): """Test a successful connection.""" mock_auth.side_effect = lambda hass, host, code: {"host": host, "gateway_id": "bla"} flow = await hass.config_entries.flow.async_init( "tradfri", context={"source": "user"} ) r...
[ "async", "def", "test_user_connection_successful", "(", "hass", ",", "mock_auth", ",", "mock_entry_setup", ")", ":", "mock_auth", ".", "side_effect", "=", "lambda", "hass", ",", "host", ",", "code", ":", "{", "\"host\"", ":", "host", ",", "\"gateway_id\"", ":"...
[ 19, 0 ]
[ 38, 5 ]
python
en
['en', 'en', 'en']
True
test_user_connection_timeout
(hass, mock_auth, mock_entry_setup)
Test a connection timeout.
Test a connection timeout.
async def test_user_connection_timeout(hass, mock_auth, mock_entry_setup): """Test a connection timeout.""" mock_auth.side_effect = config_flow.AuthError("timeout") flow = await hass.config_entries.flow.async_init( "tradfri", context={"source": "user"} ) result = await hass.config_entries....
[ "async", "def", "test_user_connection_timeout", "(", "hass", ",", "mock_auth", ",", "mock_entry_setup", ")", ":", "mock_auth", ".", "side_effect", "=", "config_flow", ".", "AuthError", "(", "\"timeout\"", ")", "flow", "=", "await", "hass", ".", "config_entries", ...
[ 41, 0 ]
[ 56, 50 ]
python
en
['en', 'en', 'en']
True
test_user_connection_bad_key
(hass, mock_auth, mock_entry_setup)
Test a connection with bad key.
Test a connection with bad key.
async def test_user_connection_bad_key(hass, mock_auth, mock_entry_setup): """Test a connection with bad key.""" mock_auth.side_effect = config_flow.AuthError("invalid_security_code") flow = await hass.config_entries.flow.async_init( "tradfri", context={"source": "user"} ) result = await h...
[ "async", "def", "test_user_connection_bad_key", "(", "hass", ",", "mock_auth", ",", "mock_entry_setup", ")", ":", "mock_auth", ".", "side_effect", "=", "config_flow", ".", "AuthError", "(", "\"invalid_security_code\"", ")", "flow", "=", "await", "hass", ".", "conf...
[ 59, 0 ]
[ 74, 73 ]
python
en
['en', 'en', 'en']
True