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
MCP23017Switch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 61, 4 ]
[ 63, 25 ]
python
en
['en', 'en', 'en']
True
MCP23017Switch.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 66, 4 ]
[ 68, 20 ]
python
en
['en', 'en', 'en']
True
MCP23017Switch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 71, 4 ]
[ 73, 26 ]
python
en
['en', 'fy', 'en']
True
MCP23017Switch.assumed_state
(self)
Return true if optimistic updates are used.
Return true if optimistic updates are used.
def assumed_state(self): """Return true if optimistic updates are used.""" return True
[ "def", "assumed_state", "(", "self", ")", ":", "return", "True" ]
[ 76, 4 ]
[ 78, 19 ]
python
en
['en', 'la', 'en']
True
MCP23017Switch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" self._pin.value = not self._invert_logic self._state = True self.schedule_update_ha_state()
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_pin", ".", "value", "=", "not", "self", ".", "_invert_logic", "self", ".", "_state", "=", "True", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 80, 4 ]
[ 84, 39 ]
python
en
['en', 'en', 'en']
True
MCP23017Switch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" self._pin.value = self._invert_logic self._state = False self.schedule_update_ha_state()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_pin", ".", "value", "=", "self", ".", "_invert_logic", "self", ".", "_state", "=", "False", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 86, 4 ]
[ 90, 39 ]
python
en
['en', 'en', 'en']
True
_id
(value: str)
Coerce id by removing '-'.
Coerce id by removing '-'.
def _id(value: str) -> str: """Coerce id by removing '-'.""" return value.replace("-", "")
[ "def", "_id", "(", "value", ":", "str", ")", "->", "str", ":", "return", "value", ".", "replace", "(", "\"-\"", ",", "\"\"", ")" ]
[ 37, 0 ]
[ 39, 33 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, hass_config)
Set up the GPSLogger component.
Set up the GPSLogger component.
async def async_setup(hass, hass_config): """Set up the GPSLogger component.""" hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}} return True
[ "async", "def", "async_setup", "(", "hass", ",", "hass_config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "\"devices\"", ":", "set", "(", ")", ",", "\"unsub_device_tracker\"", ":", "{", "}", "}", "return", "True" ]
[ 58, 0 ]
[ 61, 15 ]
python
en
['en', 'en', 'en']
True
handle_webhook
(hass, webhook_id, request)
Handle incoming webhook with GPSLogger request.
Handle incoming webhook with GPSLogger request.
async def handle_webhook(hass, webhook_id, request): """Handle incoming webhook with GPSLogger request.""" try: data = WEBHOOK_SCHEMA(dict(await request.post())) except vol.MultipleInvalid as error: return web.Response(text=error.error_message, status=HTTP_UNPROCESSABLE_ENTITY) attrs = ...
[ "async", "def", "handle_webhook", "(", "hass", ",", "webhook_id", ",", "request", ")", ":", "try", ":", "data", "=", "WEBHOOK_SCHEMA", "(", "dict", "(", "await", "request", ".", "post", "(", ")", ")", ")", "except", "vol", ".", "MultipleInvalid", "as", ...
[ 64, 0 ]
[ 91, 78 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Configure based on config entry.
Configure based on config entry.
async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, "GPSLogger", entry.data[CONF_WEBHOOK_ID], handle_webhook ) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER) ) ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_register", "(", "DOMAIN", ",", "\"GPSLogger\"", ",", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ",", "handle_webhook", ")...
[ 94, 0 ]
[ 103, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)() await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_unregister", "(", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ")", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"u...
[ 106, 0 ]
[ 111, 15 ]
python
en
['en', 'es', 'en']
True
test_serialize_text
()
Test serializing a text response.
Test serializing a text response.
def test_serialize_text(): """Test serializing a text response.""" response = web.Response(status=201, text="Hello") assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": "Hello", "headers": {"Content-Type": "text/plain; charset=utf-8"}, }
[ "def", "test_serialize_text", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "text", "=", "\"Hello\"", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":", "...
[ 6, 0 ]
[ 13, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_body_str
()
Test serializing a response with a str as body.
Test serializing a response with a str as body.
def test_serialize_body_str(): """Test serializing a response with a str as body.""" response = web.Response(status=201, body="Hello") assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": "Hello", "headers": {"Content-Length": "5", "Content-Type": "text/plain...
[ "def", "test_serialize_body_str", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "body", "=", "\"Hello\"", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":",...
[ 16, 0 ]
[ 23, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_body_None
()
Test serializing a response with a str as body.
Test serializing a response with a str as body.
def test_serialize_body_None(): """Test serializing a response with a str as body.""" response = web.Response(status=201, body=None) assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": None, "headers": {}, }
[ "def", "test_serialize_body_None", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "body", "=", "None", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":", "...
[ 26, 0 ]
[ 33, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_body_bytes
()
Test serializing a response with a str as body.
Test serializing a response with a str as body.
def test_serialize_body_bytes(): """Test serializing a response with a str as body.""" response = web.Response(status=201, body=b"Hello") assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": "Hello", "headers": {}, }
[ "def", "test_serialize_body_bytes", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "body", "=", "b\"Hello\"", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", "...
[ 36, 0 ]
[ 43, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_json
()
Test serializing a JSON response.
Test serializing a JSON response.
def test_serialize_json(): """Test serializing a JSON response.""" response = web.json_response({"how": "what"}) assert utils.aiohttp_serialize_response(response) == { "status": 200, "body": '{"how": "what"}', "headers": {"Content-Type": "application/json; charset=utf-8"}, }
[ "def", "test_serialize_json", "(", ")", ":", "response", "=", "web", ".", "json_response", "(", "{", "\"how\"", ":", "\"what\"", "}", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":", "200", ",", ...
[ 46, 0 ]
[ 53, 5 ]
python
en
['en', 'en', 'en']
True
Errors.args_error
(error = "")
Exits because of args error
Exits because of args error
def args_error(error = ""): """Exits because of args error""" print("Usage: python api.py -m MOVIE_NAME FORMAT LANGUAGE") print("Usage: python api.py -s SERIES_NAME FORMAT LANGUAGE SEASON_Number Episode_Number") if error: print(error) exit(1)
[ "def", "args_error", "(", "error", "=", "\"\"", ")", ":", "print", "(", "\"Usage: python api.py -m MOVIE_NAME FORMAT LANGUAGE\"", ")", "print", "(", "\"Usage: python api.py -s SERIES_NAME FORMAT LANGUAGE SEASON_Number Episode_Number\"", ")", "if", "error", ":", "print", "(", ...
[ 3, 4 ]
[ 10, 15 ]
python
en
['en', 'en', 'en']
True
Errors.location_error
(error = "")
Exits because of location error (the location couldn't be found or anything else)
Exits because of location error (the location couldn't be found or anything else)
def location_error(error = ""): """Exits because of location error (the location couldn't be found or anything else)""" print("There was a problem during writing to the specified location!") if error: print(error) exit(1)
[ "def", "location_error", "(", "error", "=", "\"\"", ")", ":", "print", "(", "\"There was a problem during writing to the specified location!\"", ")", "if", "error", ":", "print", "(", "error", ")", "exit", "(", "1", ")" ]
[ 13, 4 ]
[ 19, 15 ]
python
en
['en', 'en', 'en']
True
validate_input
(hass: core.HomeAssistant, auth)
Validate the user input allows us to connect.
Validate the user input allows us to connect.
def validate_input(hass: core.HomeAssistant, auth): """Validate the user input allows us to connect.""" try: auth.startup() except (LoginError, TokenRefreshFailed) as err: raise InvalidAuth from err if auth.check_key_required(): raise Require2FA
[ "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "auth", ")", ":", "try", ":", "auth", ".", "startup", "(", ")", "except", "(", "LoginError", ",", "TokenRefreshFailed", ")", "as", "err", ":", "raise", "InvalidAuth", "from", "...
[ 24, 0 ]
[ 31, 24 ]
python
en
['en', 'en', 'en']
True
_send_blink_2fa_pin
(auth, pin)
Send 2FA pin to blink servers.
Send 2FA pin to blink servers.
def _send_blink_2fa_pin(auth, pin): """Send 2FA pin to blink servers.""" blink = Blink() blink.auth = auth blink.setup_urls() return auth.send_auth_key(blink, pin)
[ "def", "_send_blink_2fa_pin", "(", "auth", ",", "pin", ")", ":", "blink", "=", "Blink", "(", ")", "blink", ".", "auth", "=", "auth", "blink", ".", "setup_urls", "(", ")", "return", "auth", ".", "send_auth_key", "(", "blink", ",", "pin", ")" ]
[ 34, 0 ]
[ 39, 41 ]
python
en
['en', 'en', 'en']
True
BlinkConfigFlow.__init__
(self)
Initialize the blink flow.
Initialize the blink flow.
def __init__(self): """Initialize the blink flow.""" self.auth = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "auth", "=", "None" ]
[ 48, 4 ]
[ 50, 24 ]
python
en
['en', 'en', 'en']
True
BlinkConfigFlow.async_get_options_flow
(config_entry)
Get options flow for this handler.
Get options flow for this handler.
def async_get_options_flow(config_entry): """Get options flow for this handler.""" return BlinkOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "BlinkOptionsFlowHandler", "(", "config_entry", ")" ]
[ 54, 4 ]
[ 56, 52 ]
python
en
['en', 'en', 'en']
True
BlinkConfigFlow.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" errors = {} data = {CONF_USERNAME: "", CONF_PASSWORD: "", "device_id": DEVICE_ID} if user_input is not None: data[CONF_USERNAME] = user_input["username"] data[CONF_PASSWOR...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "data", "=", "{", "CONF_USERNAME", ":", "\"\"", ",", "CONF_PASSWORD", ":", "\"\"", ",", "\"device_id\"", ":", "DEVICE_ID", "}", "if", "user...
[ 58, 4 ]
[ 91, 9 ]
python
en
['en', 'en', 'en']
True
BlinkConfigFlow.async_step_2fa
(self, user_input=None)
Handle 2FA step.
Handle 2FA step.
async def async_step_2fa(self, user_input=None): """Handle 2FA step.""" errors = {} if user_input is not None: pin = user_input.get(CONF_PIN) try: valid_token = await self.hass.async_add_executor_job( _send_blink_2fa_pin, self.auth, pin...
[ "async", "def", "async_step_2fa", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "pin", "=", "user_input", ".", "get", "(", "CONF_PIN", ")", "try", ":", "valid_token", "=", ...
[ 93, 4 ]
[ 119, 9 ]
python
en
['en', 'sm', 'en']
True
BlinkConfigFlow.async_step_reauth
(self, entry_data)
Perform reauth upon migration of old entries.
Perform reauth upon migration of old entries.
async def async_step_reauth(self, entry_data): """Perform reauth upon migration of old entries.""" return await self.async_step_user(entry_data)
[ "async", "def", "async_step_reauth", "(", "self", ",", "entry_data", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "entry_data", ")" ]
[ 121, 4 ]
[ 123, 53 ]
python
en
['en', 'en', 'en']
True
BlinkConfigFlow._async_finish_flow
(self)
Finish with setup.
Finish with setup.
def _async_finish_flow(self): """Finish with setup.""" return self.async_create_entry(title=DOMAIN, data=self.auth.login_attributes)
[ "def", "_async_finish_flow", "(", "self", ")", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "DOMAIN", ",", "data", "=", "self", ".", "auth", ".", "login_attributes", ")" ]
[ 126, 4 ]
[ 128, 85 ]
python
en
['en', 'zu', 'en']
True
BlinkOptionsFlowHandler.__init__
(self, config_entry)
Initialize Blink options flow.
Initialize Blink options flow.
def __init__(self, config_entry): """Initialize Blink options flow.""" self.config_entry = config_entry self.options = dict(config_entry.options) self.blink = None
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "options", "=", "dict", "(", "config_entry", ".", "options", ")", "self", ".", "blink", "=", "None" ]
[ 134, 4 ]
[ 138, 25 ]
python
en
['en', 'en', 'en']
True
BlinkOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the Blink options.
Manage the Blink options.
async def async_step_init(self, user_input=None): """Manage the Blink options.""" self.blink = self.hass.data[DOMAIN][self.config_entry.entry_id] self.options[CONF_SCAN_INTERVAL] = self.blink.refresh_rate return await self.async_step_simple_options()
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "self", ".", "blink", "=", "self", ".", "hass", ".", "data", "[", "DOMAIN", "]", "[", "self", ".", "config_entry", ".", "entry_id", "]", "self", ".", "options", ...
[ 140, 4 ]
[ 145, 53 ]
python
en
['en', 'en', 'en']
True
BlinkOptionsFlowHandler.async_step_simple_options
(self, user_input=None)
For simple options.
For simple options.
async def async_step_simple_options(self, user_input=None): """For simple options.""" if user_input is not None: self.options.update(user_input) self.blink.refresh_rate = user_input[CONF_SCAN_INTERVAL] return self.async_create_entry(title="", data=self.options) ...
[ "async", "def", "async_step_simple_options", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "options", ".", "update", "(", "user_input", ")", "self", ".", "blink", ".", "refresh_rate", "=",...
[ 147, 4 ]
[ 167, 9 ]
python
en
['en', 'en', 'en']
True
test_import_from_yaml
(hass)
Test import from YAML.
Test import from YAML.
async def test_import_from_yaml(hass) -> None: """Test import from YAML.""" with _patch_version(), _patch_status(), _patch_history(), _patch_async_setup_entry(): assert await async_setup_component(hass, DOMAIN, {DOMAIN: YAML_CONFIG}) await hass.async_block_till_done() entries = hass.config_...
[ "async", "def", "test_import_from_yaml", "(", "hass", ")", "->", "None", ":", "with", "_patch_version", "(", ")", ",", "_patch_status", "(", ")", ",", "_patch_history", "(", ")", ",", "_patch_async_setup_entry", "(", ")", ":", "assert", "await", "async_setup_c...
[ 26, 0 ]
[ 37, 45 ]
python
en
['en', 'en', 'en']
True
test_unload_entry
(hass, nzbget_api)
Test successful unload of entry.
Test successful unload of entry.
async def test_unload_entry(hass, nzbget_api): """Test successful unload of entry.""" entry = await init_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state == ENTRY_STATE_LOADED assert await hass.config_entries.async_unload(entry.entry_id) await has...
[ "async", "def", "test_unload_entry", "(", "hass", ",", "nzbget_api", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ")", "==", "1", "asse...
[ 40, 0 ]
[ 51, 36 ]
python
en
['en', 'en', 'en']
True
test_async_setup_raises_entry_not_ready
(hass)
Test that it throws ConfigEntryNotReady when exception occurs during setup.
Test that it throws ConfigEntryNotReady when exception occurs during setup.
async def test_async_setup_raises_entry_not_ready(hass): """Test that it throws ConfigEntryNotReady when exception occurs during setup.""" config_entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG) config_entry.add_to_hass(hass) with _patch_version(), patch( "homeassistant.components.nzbg...
[ "async", "def", "test_async_setup_raises_entry_not_ready", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "ENTRY_CONFIG", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")", "with", "_patch_ver...
[ 54, 0 ]
[ 65, 56 ]
python
en
['en', 'en', 'en']
True
main
(args)
The main function for supernet pre-training and subnet fine-tuning.
The main function for supernet pre-training and subnet fine-tuning.
def main(args): """ The main function for supernet pre-training and subnet fine-tuning. """ logging.basicConfig( format="[%(asctime)s] [p%(process)s] [%(pathname)s\ :%(lineno)d] [%(levelname)s] %(message)s", level=logging.INFO, handlers=[ logging.FileHandler(args....
[ "def", "main", "(", "args", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "\"[%(asctime)s] [p%(process)s] [%(pathname)s\\\n :%(lineno)d] [%(levelname)s] %(message)s\"", ",", "level", "=", "logging", ".", "INFO", ",", "handlers", "=", "[", "logg...
[ 24, 0 ]
[ 148, 19 ]
python
en
['en', 'en', 'en']
True
parse_args
()
Parse the user arguments.
Parse the user arguments.
def parse_args(): """ Parse the user arguments. """ parser = argparse.ArgumentParser(description="FBNet for PFLD") parser.add_argument("--dev_id", dest="dev_id", default="0", type=str) parser.add_argument("--opt", default="rms", type=str) parser.add_argument("--base_lr", default=0.0001, type=int) ...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"FBNet for PFLD\"", ")", "parser", ".", "add_argument", "(", "\"--dev_id\"", ",", "dest", "=", "\"dev_id\"", ",", "default", "=", "\"0\"", ",", "...
[ 151, 0 ]
[ 180, 15 ]
python
en
['en', 'en', 'en']
True
HangoutsCredentials.__init__
(self, email, password, pin=None, auth_code=None)
Google account credentials. :param email: Google account email address. :param password: Google account password. :param pin: Google account verification code.
Google account credentials.
def __init__(self, email, password, pin=None, auth_code=None): """Google account credentials. :param email: Google account email address. :param password: Google account password. :param pin: Google account verification code. """ self._email = email self._passwor...
[ "def", "__init__", "(", "self", ",", "email", ",", "password", ",", "pin", "=", "None", ",", "auth_code", "=", "None", ")", ":", "self", ".", "_email", "=", "email", "self", ".", "_password", "=", "password", "self", ".", "_pin", "=", "pin", "self", ...
[ 15, 4 ]
[ 25, 35 ]
python
en
['en', 'ca', 'en']
True
HangoutsCredentials.get_email
(self)
Return email. :return: Google account email address.
Return email.
def get_email(self): """Return email. :return: Google account email address. """ return self._email
[ "def", "get_email", "(", "self", ")", ":", "return", "self", ".", "_email" ]
[ 27, 4 ]
[ 32, 26 ]
python
en
['es', 'en', 'en']
False
HangoutsCredentials.get_password
(self)
Return password. :return: Google account password.
Return password.
def get_password(self): """Return password. :return: Google account password. """ return self._password
[ "def", "get_password", "(", "self", ")", ":", "return", "self", ".", "_password" ]
[ 34, 4 ]
[ 39, 29 ]
python
en
['fr', 'la', 'en']
False
HangoutsCredentials.get_verification_code
(self)
Return the verification code. :return: Google account verification code.
Return the verification code.
def get_verification_code(self): """Return the verification code. :return: Google account verification code. """ if self._pin is None: raise Google2FAError() return self._pin
[ "def", "get_verification_code", "(", "self", ")", ":", "if", "self", ".", "_pin", "is", "None", ":", "raise", "Google2FAError", "(", ")", "return", "self", ".", "_pin" ]
[ 41, 4 ]
[ 48, 24 ]
python
en
['en', 'sn', 'en']
True
HangoutsCredentials.set_verification_code
(self, pin)
Set the verification code. :param pin: Google account verification code.
Set the verification code.
def set_verification_code(self, pin): """Set the verification code. :param pin: Google account verification code. """ self._pin = pin
[ "def", "set_verification_code", "(", "self", ",", "pin", ")", ":", "self", ".", "_pin", "=", "pin" ]
[ 50, 4 ]
[ 55, 23 ]
python
en
['en', 'fr', 'en']
True
HangoutsCredentials.get_authorization_code
(self)
Return the oauth authorization code. :return: Google oauth code.
Return the oauth authorization code.
def get_authorization_code(self): """Return the oauth authorization code. :return: Google oauth code. """ return self._auth_code
[ "def", "get_authorization_code", "(", "self", ")", ":", "return", "self", ".", "_auth_code" ]
[ 57, 4 ]
[ 62, 30 ]
python
en
['en', 'sn', 'en']
True
HangoutsCredentials.set_authorization_code
(self, code)
Set the google oauth authorization code. :param code: Oauth code returned after authentication with google.
Set the google oauth authorization code.
def set_authorization_code(self, code): """Set the google oauth authorization code. :param code: Oauth code returned after authentication with google. """ self._auth_code = code
[ "def", "set_authorization_code", "(", "self", ",", "code", ")", ":", "self", ".", "_auth_code", "=", "code" ]
[ 64, 4 ]
[ 69, 30 ]
python
en
['en', 'en', 'en']
True
HangoutsRefreshToken.__init__
(self, token)
Memory-based cache for refresh token. :param token: Initial refresh token.
Memory-based cache for refresh token.
def __init__(self, token): """Memory-based cache for refresh token. :param token: Initial refresh token. """ super().__init__("") self._token = token
[ "def", "__init__", "(", "self", ",", "token", ")", ":", "super", "(", ")", ".", "__init__", "(", "\"\"", ")", "self", ".", "_token", "=", "token" ]
[ 75, 4 ]
[ 81, 27 ]
python
en
['en', 'no', 'en']
True
HangoutsRefreshToken.get
(self)
Get cached refresh token. :return: Cached refresh token.
Get cached refresh token.
def get(self): """Get cached refresh token. :return: Cached refresh token. """ return self._token
[ "def", "get", "(", "self", ")", ":", "return", "self", ".", "_token" ]
[ 83, 4 ]
[ 88, 26 ]
python
en
['en', 'en', 'en']
True
HangoutsRefreshToken.set
(self, refresh_token)
Cache a refresh token. :param refresh_token: Refresh token to cache.
Cache a refresh token.
def set(self, refresh_token): """Cache a refresh token. :param refresh_token: Refresh token to cache. """ self._token = refresh_token
[ "def", "set", "(", "self", ",", "refresh_token", ")", ":", "self", ".", "_token", "=", "refresh_token" ]
[ 90, 4 ]
[ 95, 35 ]
python
en
['en', 'gl', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up AdvantageAir sensor platform.
Set up AdvantageAir sensor platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up AdvantageAir sensor platform.""" instance = hass.data[ADVANTAGE_AIR_DOMAIN][config_entry.entry_id] entities = [] for ac_key, ac_device in instance["coordinator"].data["aircons"].items(): entities.append(AdvantageAir...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "instance", "=", "hass", ".", "data", "[", "ADVANTAGE_AIR_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "entities", "=", "[", "]", "for", "...
[ 16, 0 ]
[ 39, 5 ]
python
en
['en', 'lv', 'en']
True
AdvantageAirTimeTo.__init__
(self, instance, ac_key, action)
Initialize the Advantage Air timer control.
Initialize the Advantage Air timer control.
def __init__(self, instance, ac_key, action): """Initialize the Advantage Air timer control.""" super().__init__(instance, ac_key) self.action = action self._time_key = f"countDownTo{self.action}"
[ "def", "__init__", "(", "self", ",", "instance", ",", "ac_key", ",", "action", ")", ":", "super", "(", ")", ".", "__init__", "(", "instance", ",", "ac_key", ")", "self", ".", "action", "=", "action", "self", ".", "_time_key", "=", "f\"countDownTo{self.ac...
[ 45, 4 ]
[ 49, 52 ]
python
en
['en', 'en', 'en']
True
AdvantageAirTimeTo.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f'{self._ac["name"]} Time To {self.action}'
[ "def", "name", "(", "self", ")", ":", "return", "f'{self._ac[\"name\"]} Time To {self.action}'" ]
[ 52, 4 ]
[ 54, 58 ]
python
en
['en', 'ig', 'en']
True
AdvantageAirTimeTo.unique_id
(self)
Return a unique id.
Return a unique id.
def unique_id(self): """Return a unique id.""" return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-timeto{self.action}'
[ "def", "unique_id", "(", "self", ")", ":", "return", "f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-timeto{self.action}'" ]
[ 57, 4 ]
[ 59, 92 ]
python
ca
['fr', 'ca', 'en']
False
AdvantageAirTimeTo.state
(self)
Return the current value.
Return the current value.
def state(self): """Return the current value.""" return self._ac[self._time_key]
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_ac", "[", "self", ".", "_time_key", "]" ]
[ 62, 4 ]
[ 64, 39 ]
python
en
['en', 'en', 'en']
True
AdvantageAirTimeTo.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return ADVANTAGE_AIR_SET_COUNTDOWN_UNIT
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "ADVANTAGE_AIR_SET_COUNTDOWN_UNIT" ]
[ 67, 4 ]
[ 69, 47 ]
python
en
['en', 'la', 'en']
True
AdvantageAirTimeTo.icon
(self)
Return a representative icon of the timer.
Return a representative icon of the timer.
def icon(self): """Return a representative icon of the timer.""" if self._ac[self._time_key] > 0: return "mdi:timer-outline" return "mdi:timer-off-outline"
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_ac", "[", "self", ".", "_time_key", "]", ">", "0", ":", "return", "\"mdi:timer-outline\"", "return", "\"mdi:timer-off-outline\"" ]
[ 72, 4 ]
[ 76, 38 ]
python
en
['en', 'it', 'en']
True
AdvantageAirTimeTo.set_time_to
(self, **kwargs)
Set the timer value.
Set the timer value.
async def set_time_to(self, **kwargs): """Set the timer value.""" value = min(720, max(0, int(kwargs[ADVANTAGE_AIR_SET_COUNTDOWN_VALUE]))) await self.async_change({self.ac_key: {"info": {self._time_key: value}}})
[ "async", "def", "set_time_to", "(", "self", ",", "*", "*", "kwargs", ")", ":", "value", "=", "min", "(", "720", ",", "max", "(", "0", ",", "int", "(", "kwargs", "[", "ADVANTAGE_AIR_SET_COUNTDOWN_VALUE", "]", ")", ")", ")", "await", "self", ".", "asyn...
[ 78, 4 ]
[ 81, 81 ]
python
en
['en', 'da', 'en']
True
AdvantageAirZoneVent.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f'{self._zone["name"]} Vent'
[ "def", "name", "(", "self", ")", ":", "return", "f'{self._zone[\"name\"]} Vent'" ]
[ 88, 4 ]
[ 90, 43 ]
python
en
['en', 'ig', 'en']
True
AdvantageAirZoneVent.unique_id
(self)
Return a unique id.
Return a unique id.
def unique_id(self): """Return a unique id.""" return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-{self.zone_key}-vent'
[ "def", "unique_id", "(", "self", ")", ":", "return", "f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-{self.zone_key}-vent'" ]
[ 93, 4 ]
[ 95, 93 ]
python
ca
['fr', 'ca', 'en']
False
AdvantageAirZoneVent.state
(self)
Return the current value of the air vent.
Return the current value of the air vent.
def state(self): """Return the current value of the air vent.""" if self._zone["state"] == ADVANTAGE_AIR_STATE_OPEN: return self._zone["value"] return 0
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_zone", "[", "\"state\"", "]", "==", "ADVANTAGE_AIR_STATE_OPEN", ":", "return", "self", ".", "_zone", "[", "\"value\"", "]", "return", "0" ]
[ 98, 4 ]
[ 102, 16 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.unit_of_measurement
(self)
Return the percent sign.
Return the percent sign.
def unit_of_measurement(self): """Return the percent sign.""" return PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 105, 4 ]
[ 107, 25 ]
python
en
['en', 'bg', 'en']
True
AdvantageAirZoneVent.icon
(self)
Return a representative icon.
Return a representative icon.
def icon(self): """Return a representative icon.""" if self._zone["state"] == ADVANTAGE_AIR_STATE_OPEN: return "mdi:fan" return "mdi:fan-off"
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_zone", "[", "\"state\"", "]", "==", "ADVANTAGE_AIR_STATE_OPEN", ":", "return", "\"mdi:fan\"", "return", "\"mdi:fan-off\"" ]
[ 110, 4 ]
[ 114, 28 ]
python
en
['en', 'it', 'en']
True
AdvantageAirZoneSignal.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f'{self._zone["name"]} Signal'
[ "def", "name", "(", "self", ")", ":", "return", "f'{self._zone[\"name\"]} Signal'" ]
[ 121, 4 ]
[ 123, 45 ]
python
en
['en', 'ig', 'en']
True
AdvantageAirZoneSignal.unique_id
(self)
Return a unique id.
Return a unique id.
def unique_id(self): """Return a unique id.""" return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-{self.zone_key}-signal'
[ "def", "unique_id", "(", "self", ")", ":", "return", "f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-{self.zone_key}-signal'" ]
[ 126, 4 ]
[ 128, 95 ]
python
ca
['fr', 'ca', 'en']
False
AdvantageAirZoneSignal.state
(self)
Return the current value of the wireless signal.
Return the current value of the wireless signal.
def state(self): """Return the current value of the wireless signal.""" return self._zone["rssi"]
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_zone", "[", "\"rssi\"", "]" ]
[ 131, 4 ]
[ 133, 33 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneSignal.unit_of_measurement
(self)
Return the percent sign.
Return the percent sign.
def unit_of_measurement(self): """Return the percent sign.""" return PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 136, 4 ]
[ 138, 25 ]
python
en
['en', 'bg', 'en']
True
AdvantageAirZoneSignal.icon
(self)
Return a representative icon.
Return a representative icon.
def icon(self): """Return a representative icon.""" if self._zone["rssi"] >= 80: return "mdi:wifi-strength-4" if self._zone["rssi"] >= 60: return "mdi:wifi-strength-3" if self._zone["rssi"] >= 40: return "mdi:wifi-strength-2" if self._zone["rss...
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_zone", "[", "\"rssi\"", "]", ">=", "80", ":", "return", "\"mdi:wifi-strength-4\"", "if", "self", ".", "_zone", "[", "\"rssi\"", "]", ">=", "60", ":", "return", "\"mdi:wifi-strength-3\"", "if", "s...
[ 141, 4 ]
[ 151, 42 ]
python
en
['en', 'it', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up a sensor for a raincloud device.
Set up a sensor for a raincloud device.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up a sensor for a raincloud device.""" raincloud = hass.data[DATA_RAINCLOUD].data sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): if sensor_type == "status": sensors.append(RainCloudBi...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "raincloud", "=", "hass", ".", "data", "[", "DATA_RAINCLOUD", "]", ".", "data", "sensors", "=", "[", "]", "for", "sensor_type", "in", ...
[ 22, 0 ]
[ 40, 15 ]
python
en
['en', 'ca', 'en']
True
RainCloudBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 47, 4 ]
[ 49, 26 ]
python
en
['en', 'fy', 'en']
True
RainCloudBinarySensor.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" _LOGGER.debug("Updating RainCloud sensor: %s", self._name) self._state = getattr(self.data, self._sensor_type) if self._sensor_type == "status": self._state = self._state == "Online"
[ "def", "update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating RainCloud sensor: %s\"", ",", "self", ".", "_name", ")", "self", ".", "_state", "=", "getattr", "(", "self", ".", "data", ",", "self", ".", "_sensor_type", ")", "if", "self...
[ 51, 4 ]
[ 56, 49 ]
python
en
['en', 'en', 'en']
True
RainCloudBinarySensor.icon
(self)
Return the icon of this device.
Return the icon of this device.
def icon(self): """Return the icon of this device.""" if self._sensor_type == "is_watering": return "mdi:water" if self.is_on else "mdi:water-off" if self._sensor_type == "status": return "mdi:pipe" if self.is_on else "mdi:pipe-disconnected" return ICON_MAP.get(se...
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_sensor_type", "==", "\"is_watering\"", ":", "return", "\"mdi:water\"", "if", "self", ".", "is_on", "else", "\"mdi:water-off\"", "if", "self", ".", "_sensor_type", "==", "\"status\"", ":", "return", "...
[ 59, 4 ]
[ 65, 46 ]
python
en
['en', 'en', 'en']
True
test_device_setup
(hass)
Test a successful setup.
Test a successful setup.
async def test_device_setup(hass): """Test a successful setup.""" device = get_device("Office") with patch.object( hass.config_entries, "async_forward_entry_setup" ) as mock_forward, patch.object( hass.config_entries.flow, "async_init" ) as mock_init: mock_api, mock_entry = ...
[ "async", "def", "test_device_setup", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "with", "patch", ".", "object", "(", "hass", ".", "config_entries", ",", "\"async_forward_entry_setup\"", ")", "as", "mock_forward", ",", "patch", ...
[ 19, 0 ]
[ 37, 36 ]
python
en
['en', 'co', 'en']
True
test_device_setup_authentication_error
(hass)
Test we handle an authentication error.
Test we handle an authentication error.
async def test_device_setup_authentication_error(hass): """Test we handle an authentication error.""" device = get_device("Living Room") mock_api = device.get_mock_api() mock_api.auth.side_effect = blke.AuthenticationError() with patch.object( hass.config_entries, "async_forward_entry_setup...
[ "async", "def", "test_device_setup_authentication_error", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Living Room\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "auth", ".", "side_effect", "=", "blke", ".", ...
[ 40, 0 ]
[ 61, 5 ]
python
en
['de', 'en', 'en']
True
test_device_setup_network_timeout
(hass)
Test we handle a network timeout.
Test we handle a network timeout.
async def test_device_setup_network_timeout(hass): """Test we handle a network timeout.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.auth.side_effect = blke.NetworkTimeoutError() with patch.object( hass.config_entries, "async_forward_entry_setup" ) as mock_...
[ "async", "def", "test_device_setup_network_timeout", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "auth", ".", "side_effect", "=", "blke", ".", "NetworkTi...
[ 64, 0 ]
[ 80, 36 ]
python
en
['en', 'en', 'en']
True
test_device_setup_os_error
(hass)
Test we handle an OS error.
Test we handle an OS error.
async def test_device_setup_os_error(hass): """Test we handle an OS error.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.auth.side_effect = OSError() with patch.object( hass.config_entries, "async_forward_entry_setup" ) as mock_forward, patch.object( ...
[ "async", "def", "test_device_setup_os_error", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "auth", ".", "side_effect", "=", "OSError", "(", ")", "with",...
[ 83, 0 ]
[ 99, 36 ]
python
en
['en', 'ga', 'en']
True
test_device_setup_broadlink_exception
(hass)
Test we handle a Broadlink exception.
Test we handle a Broadlink exception.
async def test_device_setup_broadlink_exception(hass): """Test we handle a Broadlink exception.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.auth.side_effect = blke.BroadlinkException() with patch.object( hass.config_entries, "async_forward_entry_setup" ) a...
[ "async", "def", "test_device_setup_broadlink_exception", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "auth", ".", "side_effect", "=", "blke", ".", "Broad...
[ 102, 0 ]
[ 118, 36 ]
python
en
['en', 'en', 'en']
True
test_device_setup_update_network_timeout
(hass)
Test we handle a network timeout in the update step.
Test we handle a network timeout in the update step.
async def test_device_setup_update_network_timeout(hass): """Test we handle a network timeout in the update step.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.check_sensors.side_effect = blke.NetworkTimeoutError() with patch.object( hass.config_entries, "async_...
[ "async", "def", "test_device_setup_update_network_timeout", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "check_sensors", ".", "side_effect", "=", "blke", "...
[ 121, 0 ]
[ 138, 36 ]
python
en
['en', 'en', 'en']
True
test_device_setup_update_authorization_error
(hass)
Test we handle an authorization error in the update step.
Test we handle an authorization error in the update step.
async def test_device_setup_update_authorization_error(hass): """Test we handle an authorization error in the update step.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.check_sensors.side_effect = (blke.AuthorizationError(), None) with patch.object( hass.config_...
[ "async", "def", "test_device_setup_update_authorization_error", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "check_sensors", ".", "side_effect", "=", "(", ...
[ 141, 0 ]
[ 161, 36 ]
python
en
['en', 'en', 'en']
True
test_device_setup_update_authentication_error
(hass)
Test we handle an authentication error in the update step.
Test we handle an authentication error in the update step.
async def test_device_setup_update_authentication_error(hass): """Test we handle an authentication error in the update step.""" device = get_device("Garage") mock_api = device.get_mock_api() mock_api.check_sensors.side_effect = blke.AuthorizationError() mock_api.auth.side_effect = (None, blke.Authen...
[ "async", "def", "test_device_setup_update_authentication_error", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Garage\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "check_sensors", ".", "side_effect", "=", "blke"...
[ 164, 0 ]
[ 187, 5 ]
python
en
['en', 'en', 'en']
True
test_device_setup_update_broadlink_exception
(hass)
Test we handle a Broadlink exception in the update step.
Test we handle a Broadlink exception in the update step.
async def test_device_setup_update_broadlink_exception(hass): """Test we handle a Broadlink exception in the update step.""" device = get_device("Garage") mock_api = device.get_mock_api() mock_api.check_sensors.side_effect = blke.BroadlinkException() with patch.object( hass.config_entries, ...
[ "async", "def", "test_device_setup_update_broadlink_exception", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Garage\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "check_sensors", ".", "side_effect", "=", "blke",...
[ 190, 0 ]
[ 207, 36 ]
python
en
['en', 'en', 'en']
True
test_device_setup_get_fwversion_broadlink_exception
(hass)
Test we load the device even if we cannot read the firmware version.
Test we load the device even if we cannot read the firmware version.
async def test_device_setup_get_fwversion_broadlink_exception(hass): """Test we load the device even if we cannot read the firmware version.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.get_fwversion.side_effect = blke.BroadlinkException() with patch.object(hass.config...
[ "async", "def", "test_device_setup_get_fwversion_broadlink_exception", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "get_fwversion", ".", "side_effect", "=", ...
[ 210, 0 ]
[ 223, 37 ]
python
en
['en', 'en', 'en']
True
test_device_setup_get_fwversion_os_error
(hass)
Test we load the device even if we cannot read the firmware version.
Test we load the device even if we cannot read the firmware version.
async def test_device_setup_get_fwversion_os_error(hass): """Test we load the device even if we cannot read the firmware version.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.get_fwversion.side_effect = OSError() with patch.object(hass.config_entries, "async_forward_en...
[ "async", "def", "test_device_setup_get_fwversion_os_error", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "get_fwversion", ".", "side_effect", "=", "OSError", ...
[ 226, 0 ]
[ 239, 37 ]
python
en
['en', 'en', 'en']
True
test_device_setup_registry
(hass)
Test we register the device and the entries correctly.
Test we register the device and the entries correctly.
async def test_device_setup_registry(hass): """Test we register the device and the entries correctly.""" device = get_device("Office") device_registry = mock_device_registry(hass) entity_registry = mock_registry(hass) _, mock_entry = await device.setup_entry(hass) await hass.async_block_till_d...
[ "async", "def", "test_device_setup_registry", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "device_registry", "=", "mock_device_registry", "(", "hass", ")", "entity_registry", "=", "mock_registry", "(", "hass", ")", "_", ",", "mock...
[ 242, 0 ]
[ 264, 58 ]
python
en
['en', 'en', 'en']
True
test_device_unload_works
(hass)
Test we unload the device.
Test we unload the device.
async def test_device_unload_works(hass): """Test we unload the device.""" device = get_device("Office") with patch.object(hass.config_entries, "async_forward_entry_setup"): mock_api, mock_entry = await device.setup_entry(hass) with patch.object( hass.config_entries, "async_forward_ent...
[ "async", "def", "test_device_unload_works", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "with", "patch", ".", "object", "(", "hass", ".", "config_entries", ",", "\"async_forward_entry_setup\"", ")", ":", "mock_api", ",", "mock_ent...
[ 267, 0 ]
[ 283, 37 ]
python
en
['en', 'en', 'en']
True
test_device_unload_authentication_error
(hass)
Test we unload a device that failed the authentication step.
Test we unload a device that failed the authentication step.
async def test_device_unload_authentication_error(hass): """Test we unload a device that failed the authentication step.""" device = get_device("Living Room") mock_api = device.get_mock_api() mock_api.auth.side_effect = blke.AuthenticationError() with patch.object(hass.config_entries, "async_forwar...
[ "async", "def", "test_device_unload_authentication_error", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Living Room\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "auth", ".", "side_effect", "=", "blke", ".", ...
[ 286, 0 ]
[ 303, 39 ]
python
en
['en', 'en', 'en']
True
test_device_unload_update_failed
(hass)
Test we unload a device that failed the update step.
Test we unload a device that failed the update step.
async def test_device_unload_update_failed(hass): """Test we unload a device that failed the update step.""" device = get_device("Office") mock_api = device.get_mock_api() mock_api.check_sensors.side_effect = blke.NetworkTimeoutError() with patch.object(hass.config_entries, "async_forward_entry_set...
[ "async", "def", "test_device_unload_update_failed", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "mock_api", "=", "device", ".", "get_mock_api", "(", ")", "mock_api", ".", "check_sensors", ".", "side_effect", "=", "blke", ".", "N...
[ 306, 0 ]
[ 321, 39 ]
python
en
['en', 'en', 'en']
True
test_device_update_listener
(hass)
Test we update device and entity registry when the entry is renamed.
Test we update device and entity registry when the entry is renamed.
async def test_device_update_listener(hass): """Test we update device and entity registry when the entry is renamed.""" device = get_device("Office") device_registry = mock_device_registry(hass) entity_registry = mock_registry(hass) mock_api, mock_entry = await device.setup_entry(hass) await h...
[ "async", "def", "test_device_update_listener", "(", "hass", ")", ":", "device", "=", "get_device", "(", "\"Office\"", ")", "device_registry", "=", "mock_device_registry", "(", "hass", ")", "entity_registry", "=", "mock_registry", "(", "hass", ")", "mock_api", ",",...
[ 324, 0 ]
[ 345, 57 ]
python
en
['en', 'en', 'en']
True
get_entry_client
(hass, entry)
Retrieve client associated with a config entry.
Retrieve client associated with a config entry.
def get_entry_client(hass, entry): """Retrieve client associated with a config entry.""" return hass.data[DOMAIN_DATA_ENTRIES][entry.entry_id]
[ "def", "get_entry_client", "(", "hass", ",", "entry", ")", ":", "return", "hass", ".", "data", "[", "DOMAIN_DATA_ENTRIES", "]", "[", "entry", ".", "entry_id", "]" ]
[ 15, 0 ]
[ 17, 57 ]
python
en
['en', 'pt', 'en']
True
Subscriber.__init__
(self, name, callback)
Initiate the subscriber.
Initiate the subscriber.
def __init__(self, name, callback): """Initiate the subscriber.""" self.name = name self.callback = callback
[ "def", "__init__", "(", "self", ",", "name", ",", "callback", ")", ":", "self", ".", "name", "=", "name", "self", ".", "callback", "=", "callback" ]
[ 10, 4 ]
[ 13, 32 ]
python
en
['en', 'en', 'en']
True
Subscriber.update
(self, message)
Trigger hass to update the device.
Trigger hass to update the device.
def update(self, message): """Trigger hass to update the device.""" _LOGGER.debug('%s got message "%s"', self.name, message) self.callback(message)
[ "def", "update", "(", "self", ",", "message", ")", ":", "_LOGGER", ".", "debug", "(", "'%s got message \"%s\"'", ",", "self", ".", "name", ",", "message", ")", "self", ".", "callback", "(", "message", ")" ]
[ 15, 4 ]
[ 18, 30 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Shodan sensor.
Set up the Shodan sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Shodan sensor.""" api_key = config.get(CONF_API_KEY) name = config.get(CONF_NAME) query = config.get(CONF_QUERY) data = ShodanData(shodan.Shodan(api_key), query) try: data.update() except shodan.excep...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "api_key", "=", "config", ".", "get", "(", "CONF_API_KEY", ")", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "query", "="...
[ 33, 0 ]
[ 46, 50 ]
python
en
['en', 'sq', 'en']
True
ShodanSensor.__init__
(self, data, name)
Initialize the Shodan sensor.
Initialize the Shodan sensor.
def __init__(self, data, name): """Initialize the Shodan sensor.""" self.data = data self._name = name self._state = None self._unit_of_measurement = "Hits"
[ "def", "__init__", "(", "self", ",", "data", ",", "name", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "_unit_of_measurement", "=", "\"Hits\"" ]
[ 52, 4 ]
[ 57, 42 ]
python
en
['en', 'zh-Latn', 'en']
True
ShodanSensor.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" ]
[ 60, 4 ]
[ 62, 25 ]
python
en
['en', 'mi', 'en']
True
ShodanSensor.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" ]
[ 65, 4 ]
[ 67, 26 ]
python
en
['en', 'en', 'en']
True
ShodanSensor.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 70, 4 ]
[ 72, 40 ]
python
en
['en', 'en', 'en']
True
ShodanSensor.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 75, 4 ]
[ 77, 19 ]
python
en
['en', 'en', 'en']
True
ShodanSensor.device_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def device_state_attributes(self): """Return the state attributes of the sensor.""" return {ATTR_ATTRIBUTION: ATTRIBUTION}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", "}" ]
[ 80, 4 ]
[ 82, 46 ]
python
en
['en', 'en', 'en']
True
ShodanSensor.update
(self)
Get the latest data and updates the states.
Get the latest data and updates the states.
def update(self): """Get the latest data and updates the states.""" self.data.update() self._state = self.data.details["total"]
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "self", ".", "_state", "=", "self", ".", "data", ".", "details", "[", "\"total\"", "]" ]
[ 84, 4 ]
[ 87, 48 ]
python
en
['en', 'en', 'en']
True
ShodanData.__init__
(self, api, query)
Initialize the data object.
Initialize the data object.
def __init__(self, api, query): """Initialize the data object.""" self._api = api self._query = query self.details = None
[ "def", "__init__", "(", "self", ",", "api", ",", "query", ")", ":", "self", ".", "_api", "=", "api", "self", ".", "_query", "=", "query", "self", ".", "details", "=", "None" ]
[ 93, 4 ]
[ 97, 27 ]
python
en
['en', 'en', 'en']
True
ShodanData.update
(self)
Get the latest data from shodan.io.
Get the latest data from shodan.io.
def update(self): """Get the latest data from shodan.io.""" self.details = self._api.count(self._query)
[ "def", "update", "(", "self", ")", ":", "self", ".", "details", "=", "self", ".", "_api", ".", "count", "(", "self", ".", "_query", ")" ]
[ 99, 4 ]
[ 101, 51 ]
python
en
['en', 'en', 'en']
True
conv2d
(x_input, w_matrix)
conv2d returns a 2d convolution layer with full stride.
conv2d returns a 2d convolution layer with full stride.
def conv2d(x_input, w_matrix): """conv2d returns a 2d convolution layer with full stride.""" return tf.nn.conv2d(x_input, w_matrix, strides=[1, 1, 1, 1], padding='SAME')
[ "def", "conv2d", "(", "x_input", ",", "w_matrix", ")", ":", "return", "tf", ".", "nn", ".", "conv2d", "(", "x_input", ",", "w_matrix", ",", "strides", "=", "[", "1", ",", "1", ",", "1", ",", "1", "]", ",", "padding", "=", "'SAME'", ")" ]
[ 131, 0 ]
[ 133, 80 ]
python
en
['en', 'en', 'en']
True
max_pool
(x_input, pool_size)
max_pool downsamples a feature map by 2X.
max_pool downsamples a feature map by 2X.
def max_pool(x_input, pool_size): """max_pool downsamples a feature map by 2X.""" return tf.nn.max_pool(x_input, ksize=[1, pool_size, pool_size, 1], strides=[1, pool_size, pool_size, 1], padding='SAME')
[ "def", "max_pool", "(", "x_input", ",", "pool_size", ")", ":", "return", "tf", ".", "nn", ".", "max_pool", "(", "x_input", ",", "ksize", "=", "[", "1", ",", "pool_size", ",", "pool_size", ",", "1", "]", ",", "strides", "=", "[", "1", ",", "pool_siz...
[ 136, 0 ]
[ 139, 79 ]
python
en
['en', 'en', 'en']
True
weight_variable
(shape)
weight_variable generates a weight variable of a given shape.
weight_variable generates a weight variable of a given shape.
def weight_variable(shape): """weight_variable generates a weight variable of a given shape.""" initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial)
[ "def", "weight_variable", "(", "shape", ")", ":", "initial", "=", "tf", ".", "truncated_normal", "(", "shape", ",", "stddev", "=", "0.1", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
[ 147, 0 ]
[ 150, 31 ]
python
en
['en', 'en', 'en']
True
bias_variable
(shape)
bias_variable generates a bias variable of a given shape.
bias_variable generates a bias variable of a given shape.
def bias_variable(shape): """bias_variable generates a bias variable of a given shape.""" initial = tf.constant(0.1, shape=shape) return tf.Variable(initial)
[ "def", "bias_variable", "(", "shape", ")", ":", "initial", "=", "tf", ".", "constant", "(", "0.1", ",", "shape", "=", "shape", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
[ 153, 0 ]
[ 156, 31 ]
python
en
['en', 'en', 'en']
True
download_mnist_retry
(data_dir, max_num_retries=20)
Try to download mnist dataset and avoid errors
Try to download mnist dataset and avoid errors
def download_mnist_retry(data_dir, max_num_retries=20): """Try to download mnist dataset and avoid errors""" for _ in range(max_num_retries): try: return input_data.read_data_sets(data_dir, one_hot=True) except tf.errors.AlreadyExistsError: time.sleep(1) raise Excepti...
[ "def", "download_mnist_retry", "(", "data_dir", ",", "max_num_retries", "=", "20", ")", ":", "for", "_", "in", "range", "(", "max_num_retries", ")", ":", "try", ":", "return", "input_data", ".", "read_data_sets", "(", "data_dir", ",", "one_hot", "=", "True",...
[ 158, 0 ]
[ 165, 48 ]
python
en
['en', 'en', 'en']
True