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
interpret_tarball
(x)
>>> interpret_tarball("FREEHAND_TARBALL", "libfreehand-0.1.1.tar.bz2") {'name': 'FREEHAND', 'attrs': {'tarball': 'libfreehand-0.1.1.tar.bz2', 'brief': True}}
>>> interpret_tarball("FREEHAND_TARBALL", "libfreehand-0.1.1.tar.bz2") {'name': 'FREEHAND', 'attrs': {'tarball': 'libfreehand-0.1.1.tar.bz2', 'brief': True}}
def interpret_tarball(x): """ >>> interpret_tarball("FREEHAND_TARBALL", "libfreehand-0.1.1.tar.bz2") {'name': 'FREEHAND', 'attrs': {'tarball': 'libfreehand-0.1.1.tar.bz2', 'brief': True}} """ match = re.match('^(.*)_TARBALL$', x['key']) if match: return {'name': match.group(1), ...
[ "def", "interpret_tarball", "(", "x", ")", ":", "match", "=", "re", ".", "match", "(", "'^(.*)_TARBALL$'", ",", "x", "[", "'key'", "]", ")", "if", "match", ":", "return", "{", "'name'", ":", "match", ".", "group", "(", "1", ")", ",", "'attrs'", ":"...
[ 285, 0 ]
[ 296, 64 ]
python
en
['en', 'error', 'th']
False
interpret_tarball_with_md5
(x)
>>> interpret_tarball_with_md5("CLUCENE_TARBALL",\ "48d647fbd8ef8889e5a7f422c1bfda94-clucene-core-2.3.3.4.tar.gz") {'name': 'CLUCENE', 'attrs': {'tarball': 'clucene-core-2.3.3.4.tar.gz', 'md5': '48d647fbd8ef8889e5a7f422c1bfda94', 'brief': False}}
>>> interpret_tarball_with_md5("CLUCENE_TARBALL",\ "48d647fbd8ef8889e5a7f422c1bfda94-clucene-core-2.3.3.4.tar.gz") {'name': 'CLUCENE', 'attrs': {'tarball': 'clucene-core-2.3.3.4.tar.gz', 'md5': '48d647fbd8ef8889e5a7f422c1bfda94', 'brief': False}}
def interpret_tarball_with_md5(x): """ >>> interpret_tarball_with_md5("CLUCENE_TARBALL",\ "48d647fbd8ef8889e5a7f422c1bfda94-clucene-core-2.3.3.4.tar.gz") {'name': 'CLUCENE', 'attrs': {'tarball': 'clucene-core-2.3.3.4.tar.gz', 'md5': '48d647fbd8ef8889e5a7f422c1bfda94', 'brief': Fa...
[ "def", "interpret_tarball_with_md5", "(", "x", ")", ":", "match", "=", "{", "'key'", ":", "re", ".", "match", "(", "'^(.*)_(TARBALL|JAR)$'", ",", "x", "[", "'key'", "]", ")", ",", "'value'", ":", "re", ".", "match", "(", "'(?P<md5>[0-9a-fA-F]{32})-(?P<tarbal...
[ 306, 0 ]
[ 324, 42 ]
python
en
['en', 'error', 'th']
False
test_form
(hass)
Test that the form is served with valid input.
Test that the form is served with valid input.
async def test_form(hass): """Test that the form is served with valid input.""" mocked_owm = _create_mocked_owm(True) with patch( "pyowm.weatherapi25.weather_manager.WeatherManager", return_value=mocked_owm, ): result = await hass.config_entries.flow.async_init( DOMA...
[ "async", "def", "test_form", "(", "hass", ")", ":", "mocked_owm", "=", "_create_mocked_owm", "(", "True", ")", "with", "patch", "(", "\"pyowm.weatherapi25.weather_manager.WeatherManager\"", ",", "return_value", "=", "mocked_owm", ",", ")", ":", "result", "=", "awa...
[ 34, 0 ]
[ 68, 67 ]
python
en
['en', 'en', 'en']
True
test_form_options
(hass)
Test that the options form.
Test that the options form.
async def test_form_options(hass): """Test that the options form.""" mocked_owm = _create_mocked_owm(True) with patch( "pyowm.weatherapi25.weather_manager.WeatherManager", return_value=mocked_owm, ): config_entry = MockConfigEntry( domain=DOMAIN, unique_id="openweath...
[ "async", "def", "test_form_options", "(", "hass", ")", ":", "mocked_owm", "=", "_create_mocked_owm", "(", "True", ")", "with", "patch", "(", "\"pyowm.weatherapi25.weather_manager.WeatherManager\"", ",", "return_value", "=", "mocked_owm", ",", ")", ":", "config_entry",...
[ 71, 0 ]
[ 125, 45 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_api_key
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_form_invalid_api_key(hass): """Test that the form is served with no input.""" mocked_owm = _create_mocked_owm(True) with patch( "pyowm.weatherapi25.weather_manager.WeatherManager", return_value=mocked_owm, side_effect=UnauthorizedError(""), ): result = awa...
[ "async", "def", "test_form_invalid_api_key", "(", "hass", ")", ":", "mocked_owm", "=", "_create_mocked_owm", "(", "True", ")", "with", "patch", "(", "\"pyowm.weatherapi25.weather_manager.WeatherManager\"", ",", "return_value", "=", "mocked_owm", ",", "side_effect", "=",...
[ 128, 0 ]
[ 141, 62 ]
python
en
['en', 'en', 'en']
True
test_form_api_call_error
(hass)
Test setting up with api call error.
Test setting up with api call error.
async def test_form_api_call_error(hass): """Test setting up with api call error.""" mocked_owm = _create_mocked_owm(True) with patch( "pyowm.weatherapi25.weather_manager.WeatherManager", return_value=mocked_owm, side_effect=APIRequestError(""), ): result = await hass.co...
[ "async", "def", "test_form_api_call_error", "(", "hass", ")", ":", "mocked_owm", "=", "_create_mocked_owm", "(", "True", ")", "with", "patch", "(", "\"pyowm.weatherapi25.weather_manager.WeatherManager\"", ",", "return_value", "=", "mocked_owm", ",", "side_effect", "=", ...
[ 144, 0 ]
[ 157, 61 ]
python
en
['en', 'en', 'en']
True
test_form_api_offline
(hass)
Test setting up with api call error.
Test setting up with api call error.
async def test_form_api_offline(hass): """Test setting up with api call error.""" mocked_owm = _create_mocked_owm(False) with patch( "homeassistant.components.openweathermap.config_flow.OWM", return_value=mocked_owm, ): result = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_form_api_offline", "(", "hass", ")", ":", "mocked_owm", "=", "_create_mocked_owm", "(", "False", ")", "with", "patch", "(", "\"homeassistant.components.openweathermap.config_flow.OWM\"", ",", "return_value", "=", "mocked_owm", ",", ")", ":", "res...
[ 160, 0 ]
[ 172, 62 ]
python
en
['en', 'en', 'en']
True
_generate_secret
()
Generate a secret.
Generate a secret.
def _generate_secret() -> str: """Generate a secret.""" import pyotp # pylint: disable=import-outside-toplevel return str(pyotp.random_base32())
[ "def", "_generate_secret", "(", ")", "->", "str", ":", "import", "pyotp", "# pylint: disable=import-outside-toplevel", "return", "str", "(", "pyotp", ".", "random_base32", "(", ")", ")" ]
[ 47, 0 ]
[ 51, 37 ]
python
co
['en', 'co', 'it']
False
_generate_random
()
Generate a 8 digit number.
Generate a 8 digit number.
def _generate_random() -> int: """Generate a 8 digit number.""" import pyotp # pylint: disable=import-outside-toplevel return int(pyotp.random_base32(length=8, chars=list("1234567890")))
[ "def", "_generate_random", "(", ")", "->", "int", ":", "import", "pyotp", "# pylint: disable=import-outside-toplevel", "return", "int", "(", "pyotp", ".", "random_base32", "(", "length", "=", "8", ",", "chars", "=", "list", "(", "\"1234567890\"", ")", ")", ")"...
[ 54, 0 ]
[ 58, 71 ]
python
en
['en', 'co', 'en']
True
_generate_otp
(secret: str, count: int)
Generate one time password.
Generate one time password.
def _generate_otp(secret: str, count: int) -> str: """Generate one time password.""" import pyotp # pylint: disable=import-outside-toplevel return str(pyotp.HOTP(secret).at(count))
[ "def", "_generate_otp", "(", "secret", ":", "str", ",", "count", ":", "int", ")", "->", "str", ":", "import", "pyotp", "# pylint: disable=import-outside-toplevel", "return", "str", "(", "pyotp", ".", "HOTP", "(", "secret", ")", ".", "at", "(", "count", ")"...
[ 61, 0 ]
[ 65, 44 ]
python
en
['en', 'en', 'en']
True
_verify_otp
(secret: str, otp: str, count: int)
Verify one time password.
Verify one time password.
def _verify_otp(secret: str, otp: str, count: int) -> bool: """Verify one time password.""" import pyotp # pylint: disable=import-outside-toplevel return bool(pyotp.HOTP(secret).verify(otp, count))
[ "def", "_verify_otp", "(", "secret", ":", "str", ",", "otp", ":", "str", ",", "count", ":", "int", ")", "->", "bool", ":", "import", "pyotp", "# pylint: disable=import-outside-toplevel", "return", "bool", "(", "pyotp", ".", "HOTP", "(", "secret", ")", ".",...
[ 68, 0 ]
[ 72, 54 ]
python
en
['en', 'en', 'en']
True
NotifySetupFlow.__init__
( self, auth_module: NotifyAuthModule, setup_schema: vol.Schema, user_id: str, available_notify_services: List[str], )
Initialize the setup flow.
Initialize the setup flow.
def __init__( self, auth_module: NotifyAuthModule, setup_schema: vol.Schema, user_id: str, available_notify_services: List[str], ) -> None: """Initialize the setup flow.""" super().__init__(auth_module, setup_schema, user_id) # to fix typing complaint ...
[ "def", "__init__", "(", "self", ",", "auth_module", ":", "NotifyAuthModule", ",", "setup_schema", ":", "vol", ".", "Schema", ",", "user_id", ":", "str", ",", "available_notify_services", ":", "List", "[", "str", "]", ",", ")", "->", "None", ":", "super", ...
[ 273, 4 ]
[ 288, 42 ]
python
en
['en', 'en', 'en']
True
NotifySetupFlow.async_step_init
( self, user_input: Optional[Dict[str, str]] = None )
Let user select available notify services.
Let user select available notify services.
async def async_step_init( self, user_input: Optional[Dict[str, str]] = None ) -> Dict[str, Any]: """Let user select available notify services.""" errors: Dict[str, str] = {} hass = self._auth_module.hass if user_input: self._notify_service = user_input["notify_s...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "errors", ":", "Dict", "[", "str", ",", "str", "]...
[ 290, 4 ]
[ 314, 9 ]
python
en
['no', 'en', 'en']
True
NotifySetupFlow.async_step_setup
( self, user_input: Optional[Dict[str, str]] = None )
Verify user can receive one-time password.
Verify user can receive one-time password.
async def async_step_setup( self, user_input: Optional[Dict[str, str]] = None ) -> Dict[str, Any]: """Verify user can receive one-time password.""" errors: Dict[str, str] = {} hass = self._auth_module.hass if user_input: verified = await hass.async_add_executor_j...
[ "async", "def", "async_step_setup", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "errors", ":", "Dict", "[", "str", ",", "str", "...
[ 316, 4 ]
[ 355, 9 ]
python
en
['en', 'en', 'en']
True
GPTuner.update_search_space
(self, search_space)
Update the self.bounds and self.types by the search_space.json file. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Update the self.bounds and self.types by the search_space.json file.
def update_search_space(self, search_space): """ Update the self.bounds and self.types by the search_space.json file. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ self._space = TargetSpace(search_space, self._random_state)
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "self", ".", "_space", "=", "TargetSpace", "(", "search_space", ",", "self", ".", "_random_state", ")" ]
[ 99, 4 ]
[ 105, 67 ]
python
en
['en', 'error', 'th']
False
GPTuner.generate_parameters
(self, parameter_id, **kwargs)
Method which provides one set of hyper-parameters. If the number of trial result is lower than cold_start_number, GPTuner will first randomly generate some parameters. Otherwise, choose the parameters by the Gussian Process Model. Override of the abstract method in :class:`~nni.tuner.T...
Method which provides one set of hyper-parameters. If the number of trial result is lower than cold_start_number, GPTuner will first randomly generate some parameters. Otherwise, choose the parameters by the Gussian Process Model.
def generate_parameters(self, parameter_id, **kwargs): """ Method which provides one set of hyper-parameters. If the number of trial result is lower than cold_start_number, GPTuner will first randomly generate some parameters. Otherwise, choose the parameters by the Gussian Process Model...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_space", ".", "len", "(", ")", "<", "self", ".", "_cold_start_num", ":", "results", "=", "self", ".", "_space", ".", "random_sample", ...
[ 107, 4 ]
[ 139, 22 ]
python
en
['en', 'error', 'th']
False
GPTuner.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Method invoked when a trial reports its final result. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Method invoked when a trial reports its final result.
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): """ Method invoked when a trial reports its final result. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ value = extract_scalar_reward(value) if self._optimize_mode == OptimizeM...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "value", "=", "extract_scalar_reward", "(", "value", ")", "if", "self", ".", "_optimize_mode", "==", "OptimizeMode", ".", "Mi...
[ 141, 4 ]
[ 154, 47 ]
python
en
['en', 'error', 'th']
False
GPTuner.import_data
(self, data)
Import additional data for tuning. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Import additional data for tuning.
def import_data(self, data): """ Import additional data for tuning. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ _completed_num = 0 for trial_info in data: logger.info( "Importing data, current processing progress %s / %s"...
[ "def", "import_data", "(", "self", ",", "data", ")", ":", "_completed_num", "=", "0", "for", "trial_info", "in", "data", ":", "logger", ".", "info", "(", "\"Importing data, current processing progress %s / %s\"", ",", "_completed_num", ",", "len", "(", "data", "...
[ 156, 4 ]
[ 180, 60 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass: HomeAssistant, config: dict)
Set up the ONVIF component.
Set up the ONVIF component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the ONVIF component.""" # Import from yaml configs = {} for p_type, p_config in config_per_platform(config, "camera"): if p_type != DOMAIN: continue config = p_config.copy() if config[CONF_HOST] not ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "# Import from yaml", "configs", "=", "{", "}", "for", "p_type", ",", "p_config", "in", "config_per_platform", "(", "config", ",", "\"camera\"", ")", ":",...
[ 38, 0 ]
[ 63, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up ONVIF from a config entry.
Set up ONVIF from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up ONVIF from a config entry.""" if DOMAIN not in hass.data: hass.data[DOMAIN] = {} if not entry.options: await async_populate_options(hass, entry) device = ONVIFDevice(hass, entry) if not await device.as...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "if", "DOMAIN", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "if", "not", "entry", "...
[ 66, 0 ]
[ 100, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" device = hass.data[DOMAIN][entry.unique_id] platforms = ["camera"] if device.capabilities.events and device.events.started: platforms += ["binary_sensor", "sensor"] await device.events.a...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "device", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "unique_id", "]", "platforms", "=", "[", "\"camera\"", "]", "i...
[ 103, 0 ]
[ 120, 5 ]
python
en
['en', 'es', 'en']
True
_get_snapshot_auth
(device)
Determine auth type for snapshots.
Determine auth type for snapshots.
async def _get_snapshot_auth(device): """Determine auth type for snapshots.""" if not device.capabilities.snapshot or not (device.username and device.password): return HTTP_DIGEST_AUTHENTICATION try: snapshot = await device.device.get_snapshot(device.profiles[0].token) if snapshot:...
[ "async", "def", "_get_snapshot_auth", "(", "device", ")", ":", "if", "not", "device", ".", "capabilities", ".", "snapshot", "or", "not", "(", "device", ".", "username", "and", "device", ".", "password", ")", ":", "return", "HTTP_DIGEST_AUTHENTICATION", "try", ...
[ 123, 0 ]
[ 137, 41 ]
python
en
['en', 'en', 'en']
True
async_populate_snapshot_auth
(hass, device, entry)
Check if digest auth for snapshots is possible.
Check if digest auth for snapshots is possible.
async def async_populate_snapshot_auth(hass, device, entry): """Check if digest auth for snapshots is possible.""" auth = await _get_snapshot_auth(device) new_data = {**entry.data, CONF_SNAPSHOT_AUTH: auth} hass.config_entries.async_update_entry(entry, data=new_data)
[ "async", "def", "async_populate_snapshot_auth", "(", "hass", ",", "device", ",", "entry", ")", ":", "auth", "=", "await", "_get_snapshot_auth", "(", "device", ")", "new_data", "=", "{", "*", "*", "entry", ".", "data", ",", "CONF_SNAPSHOT_AUTH", ":", "auth", ...
[ 140, 0 ]
[ 144, 64 ]
python
en
['en', 'en', 'en']
True
async_populate_options
(hass, entry)
Populate default options for device.
Populate default options for device.
async def async_populate_options(hass, entry): """Populate default options for device.""" options = { CONF_EXTRA_ARGUMENTS: DEFAULT_ARGUMENTS, CONF_RTSP_TRANSPORT: RTSP_TRANS_PROTOCOLS[0], } hass.config_entries.async_update_entry(entry, options=options)
[ "async", "def", "async_populate_options", "(", "hass", ",", "entry", ")", ":", "options", "=", "{", "CONF_EXTRA_ARGUMENTS", ":", "DEFAULT_ARGUMENTS", ",", "CONF_RTSP_TRANSPORT", ":", "RTSP_TRANS_PROTOCOLS", "[", "0", "]", ",", "}", "hass", ".", "config_entries", ...
[ 147, 0 ]
[ 154, 66 ]
python
en
['da', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Abode alarm control panel device.
Set up Abode alarm control panel device.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Abode alarm control panel device.""" data = hass.data[DOMAIN] async_add_entities( [AbodeAlarm(data, await hass.async_add_executor_job(data.abode.get_alarm))] )
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "async_add_entities", "(", "[", "AbodeAlarm", "(", "data", ",", "await", "hass", ".", "async_add...
[ 19, 0 ]
[ 24, 5 ]
python
en
['id', 'en', 'en']
True
AbodeAlarm.icon
(self)
Return the icon.
Return the icon.
def icon(self): """Return the icon.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 31, 4 ]
[ 33, 19 ]
python
en
['en', 'sr', 'en']
True
AbodeAlarm.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self._device.is_standby: state = STATE_ALARM_DISARMED elif self._device.is_away: state = STATE_ALARM_ARMED_AWAY elif self._device.is_home: state = STATE_ALARM_ARMED_HOME else: ...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "is_standby", ":", "state", "=", "STATE_ALARM_DISARMED", "elif", "self", ".", "_device", ".", "is_away", ":", "state", "=", "STATE_ALARM_ARMED_AWAY", "elif", "self", ".", "_device", ...
[ 36, 4 ]
[ 46, 20 ]
python
en
['en', 'en', 'en']
True
AbodeAlarm.code_arm_required
(self)
Whether the code is required for arm actions.
Whether the code is required for arm actions.
def code_arm_required(self): """Whether the code is required for arm actions.""" return False
[ "def", "code_arm_required", "(", "self", ")", ":", "return", "False" ]
[ 49, 4 ]
[ 51, 20 ]
python
en
['en', 'en', 'en']
True
AbodeAlarm.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self) -> int: """Return the list of supported features.""" return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY" ]
[ 54, 4 ]
[ 56, 62 ]
python
en
['en', 'en', 'en']
True
AbodeAlarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" self._device.set_standby()
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_device", ".", "set_standby", "(", ")" ]
[ 58, 4 ]
[ 60, 34 ]
python
en
['en', 'pt', 'en']
True
AbodeAlarm.alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
def alarm_arm_home(self, code=None): """Send arm home command.""" self._device.set_home()
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_device", ".", "set_home", "(", ")" ]
[ 62, 4 ]
[ 64, 31 ]
python
en
['en', 'pt', 'en']
True
AbodeAlarm.alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
def alarm_arm_away(self, code=None): """Send arm away command.""" self._device.set_away()
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_device", ".", "set_away", "(", ")" ]
[ 66, 4 ]
[ 68, 31 ]
python
en
['en', 'en', 'en']
True
AbodeAlarm.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return { ATTR_ATTRIBUTION: ATTRIBUTION, "device_id": self._device.device_id, "battery_backup": self._device.battery, "cellular_backup": self._device.is_cellular, }
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", ",", "\"device_id\"", ":", "self", ".", "_device", ".", "device_id", ",", "\"battery_backup\"", ":", "self", ".", "_device", ".", "battery", ",", "\...
[ 71, 4 ]
[ 78, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up the StarLine switch.
Set up the StarLine switch.
async def async_setup_entry(hass, entry, async_add_entities): """Set up the StarLine switch.""" account: StarlineAccount = hass.data[DOMAIN][entry.entry_id] entities = [] for device in account.api.devices.values(): if device.support_state: for key, value in SWITCH_TYPES.items(): ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "account", ":", "StarlineAccount", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "entities", "=", "[", "]", "for", "d...
[ 19, 0 ]
[ 29, 32 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.__init__
( self, account: StarlineAccount, device: StarlineDevice, key: str, name: str, icon_on: str, icon_off: str, )
Initialize the switch.
Initialize the switch.
def __init__( self, account: StarlineAccount, device: StarlineDevice, key: str, name: str, icon_on: str, icon_off: str, ): """Initialize the switch.""" super().__init__(account, device, key, name) self._icon_on = icon_on self._i...
[ "def", "__init__", "(", "self", ",", "account", ":", "StarlineAccount", ",", "device", ":", "StarlineDevice", ",", "key", ":", "str", ",", "name", ":", "str", ",", "icon_on", ":", "str", ",", "icon_off", ":", "str", ",", ")", ":", "super", "(", ")", ...
[ 35, 4 ]
[ 47, 33 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return super().available and self._device.online
[ "def", "available", "(", "self", ")", ":", "return", "super", "(", ")", ".", "available", "and", "self", ".", "_device", ".", "online" ]
[ 50, 4 ]
[ 52, 56 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.device_state_attributes
(self)
Return the state attributes of the switch.
Return the state attributes of the switch.
def device_state_attributes(self): """Return the state attributes of the switch.""" if self._key == "ign": return self._account.engine_attrs(self._device) return None
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "_key", "==", "\"ign\"", ":", "return", "self", ".", "_account", ".", "engine_attrs", "(", "self", ".", "_device", ")", "return", "None" ]
[ 55, 4 ]
[ 59, 19 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.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 self._icon_on if self.is_on else self._icon_off
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon_on", "if", "self", ".", "is_on", "else", "self", ".", "_icon_off" ]
[ 62, 4 ]
[ 64, 62 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.assumed_state
(self)
Return True if unable to access real state of the entity.
Return True if unable to access real state of the entity.
def assumed_state(self): """Return True if unable to access real state of the entity.""" return True
[ "def", "assumed_state", "(", "self", ")", ":", "return", "True" ]
[ 67, 4 ]
[ 69, 19 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.is_on
(self)
Return True if entity is on.
Return True if entity is on.
def is_on(self): """Return True if entity is on.""" if self._key == "poke": return False return self._device.car_state.get(self._key)
[ "def", "is_on", "(", "self", ")", ":", "if", "self", ".", "_key", "==", "\"poke\"", ":", "return", "False", "return", "self", ".", "_device", ".", "car_state", ".", "get", "(", "self", ".", "_key", ")" ]
[ 72, 4 ]
[ 76, 52 ]
python
en
['en', 'cy', 'en']
True
StarlineSwitch.turn_on
(self, **kwargs)
Turn the entity on.
Turn the entity on.
def turn_on(self, **kwargs): """Turn the entity on.""" self._account.api.set_car_state(self._device.device_id, self._key, True)
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_account", ".", "api", ".", "set_car_state", "(", "self", ".", "_device", ".", "device_id", ",", "self", ".", "_key", ",", "True", ")" ]
[ 78, 4 ]
[ 80, 80 ]
python
en
['en', 'en', 'en']
True
StarlineSwitch.turn_off
(self, **kwargs)
Turn the entity off.
Turn the entity off.
def turn_off(self, **kwargs) -> None: """Turn the entity off.""" if self._key == "poke": return self._account.api.set_car_state(self._device.device_id, self._key, False)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "self", ".", "_key", "==", "\"poke\"", ":", "return", "self", ".", "_account", ".", "api", ".", "set_car_state", "(", "self", ".", "_device", ".", "device_id", ","...
[ 82, 4 ]
[ 86, 81 ]
python
en
['en', 'en', 'en']
True
_cv_input_text
(cfg)
Configure validation helper for input box (voluptuous).
Configure validation helper for input box (voluptuous).
def _cv_input_text(cfg): """Configure validation helper for input box (voluptuous).""" minimum = cfg.get(CONF_MIN) maximum = cfg.get(CONF_MAX) if minimum > maximum: raise vol.Invalid( f"Max len ({minimum}) is not greater than min len ({maximum})" ) state = cfg.get(CONF_IN...
[ "def", "_cv_input_text", "(", "cfg", ")", ":", "minimum", "=", "cfg", ".", "get", "(", "CONF_MIN", ")", "maximum", "=", "cfg", ".", "get", "(", "CONF_MAX", ")", "if", "minimum", ">", "maximum", ":", "raise", "vol", ".", "Invalid", "(", "f\"Max len ({mi...
[ 71, 0 ]
[ 84, 14 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up an input text.
Set up an input text.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up an input text.""" component = EntityComponent(_LOGGER, DOMAIN, hass) id_manager = collection.IDManager() yaml_collection = collection.YamlCollection( logging.getLogger(f"{__name__}.yaml_collection"), id_manage...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "component", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ")", "id_manager", "=", "collection", ".", "IDMan...
[ 113, 0 ]
[ 167, 15 ]
python
en
['en', 'lb', 'en']
True
InputTextStorageCollection._process_create_data
(self, data: typing.Dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: typing.Dict) -> typing.Dict: """Validate the config is valid.""" return self.CREATE_SCHEMA(data)
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "typing", ".", "Dict", ")", "->", "typing", ".", "Dict", ":", "return", "self", ".", "CREATE_SCHEMA", "(", "data", ")" ]
[ 176, 4 ]
[ 178, 39 ]
python
en
['en', 'en', 'en']
True
InputTextStorageCollection._get_suggested_id
(self, info: typing.Dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: typing.Dict) -> str: """Suggest an ID based on the config.""" return info[CONF_NAME]
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "typing", ".", "Dict", ")", "->", "str", ":", "return", "info", "[", "CONF_NAME", "]" ]
[ 181, 4 ]
[ 183, 30 ]
python
en
['en', 'en', 'en']
True
InputTextStorageCollection._update_data
(self, data: dict, update_data: typing.Dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: typing.Dict) -> typing.Dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) return _cv_input_text({**data, **update_data})
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "typing", ".", "Dict", ")", "->", "typing", ".", "Dict", ":", "update_data", "=", "self", ".", "UPDATE_SCHEMA", "(", "update_data", ")", "return", "_cv_input_te...
[ 185, 4 ]
[ 188, 54 ]
python
en
['en', 'en', 'en']
True
InputText.__init__
(self, config: typing.Dict)
Initialize a text input.
Initialize a text input.
def __init__(self, config: typing.Dict): """Initialize a text input.""" self._config = config self.editable = True self._current_value = config.get(CONF_INITIAL)
[ "def", "__init__", "(", "self", ",", "config", ":", "typing", ".", "Dict", ")", ":", "self", ".", "_config", "=", "config", "self", ".", "editable", "=", "True", "self", ".", "_current_value", "=", "config", ".", "get", "(", "CONF_INITIAL", ")" ]
[ 194, 4 ]
[ 198, 54 ]
python
en
['en', 'en', 'en']
True
InputText.from_yaml
(cls, config: typing.Dict)
Return entity instance initialized from yaml storage.
Return entity instance initialized from yaml storage.
def from_yaml(cls, config: typing.Dict) -> "InputText": """Return entity instance initialized from yaml storage.""" input_text = cls(config) input_text.entity_id = f"{DOMAIN}.{config[CONF_ID]}" input_text.editable = False return input_text
[ "def", "from_yaml", "(", "cls", ",", "config", ":", "typing", ".", "Dict", ")", "->", "\"InputText\"", ":", "input_text", "=", "cls", "(", "config", ")", "input_text", ".", "entity_id", "=", "f\"{DOMAIN}.{config[CONF_ID]}\"", "input_text", ".", "editable", "="...
[ 201, 4 ]
[ 206, 25 ]
python
en
['en', 'pl', 'en']
True
InputText.should_poll
(self)
If entity should be polled.
If entity should be polled.
def should_poll(self): """If entity should be polled.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 209, 4 ]
[ 211, 20 ]
python
en
['en', 'en', 'en']
True
InputText.name
(self)
Return the name of the text input entity.
Return the name of the text input entity.
def name(self): """Return the name of the text input entity.""" return self._config.get(CONF_NAME)
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_NAME", ")" ]
[ 214, 4 ]
[ 216, 42 ]
python
en
['en', 'en', 'en']
True
InputText.icon
(self)
Return the icon to be used for this entity.
Return the icon to be used for this entity.
def icon(self): """Return the icon to be used for this entity.""" return self._config.get(CONF_ICON)
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ICON", ")" ]
[ 219, 4 ]
[ 221, 42 ]
python
en
['en', 'en', 'en']
True
InputText._maximum
(self)
Return max len of the text.
Return max len of the text.
def _maximum(self) -> int: """Return max len of the text.""" return self._config[CONF_MAX]
[ "def", "_maximum", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_config", "[", "CONF_MAX", "]" ]
[ 224, 4 ]
[ 226, 37 ]
python
en
['en', 'en', 'en']
True
InputText._minimum
(self)
Return min len of the text.
Return min len of the text.
def _minimum(self) -> int: """Return min len of the text.""" return self._config[CONF_MIN]
[ "def", "_minimum", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_config", "[", "CONF_MIN", "]" ]
[ 229, 4 ]
[ 231, 37 ]
python
en
['en', 'lb', 'en']
True
InputText.state
(self)
Return the state of the component.
Return the state of the component.
def state(self): """Return the state of the component.""" return self._current_value
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_current_value" ]
[ 234, 4 ]
[ 236, 34 ]
python
en
['en', 'en', 'en']
True
InputText.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._config.get(CONF_UNIT_OF_MEASUREMENT)
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_UNIT_OF_MEASUREMENT", ")" ]
[ 239, 4 ]
[ 241, 57 ]
python
en
['en', 'en', 'en']
True
InputText.unique_id
(self)
Return unique id for the entity.
Return unique id for the entity.
def unique_id(self) -> typing.Optional[str]: """Return unique id for the entity.""" return self._config[CONF_ID]
[ "def", "unique_id", "(", "self", ")", "->", "typing", ".", "Optional", "[", "str", "]", ":", "return", "self", ".", "_config", "[", "CONF_ID", "]" ]
[ 244, 4 ]
[ 246, 36 ]
python
en
['en', 'en', 'en']
True
InputText.state_attributes
(self)
Return the state attributes.
Return the state attributes.
def state_attributes(self): """Return the state attributes.""" return { ATTR_EDITABLE: self.editable, ATTR_MIN: self._minimum, ATTR_MAX: self._maximum, ATTR_PATTERN: self._config.get(CONF_PATTERN), ATTR_MODE: self._config[CONF_MODE], }
[ "def", "state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_EDITABLE", ":", "self", ".", "editable", ",", "ATTR_MIN", ":", "self", ".", "_minimum", ",", "ATTR_MAX", ":", "self", ".", "_maximum", ",", "ATTR_PATTERN", ":", "self", ".", "_config", ...
[ 249, 4 ]
[ 257, 9 ]
python
en
['en', 'en', 'en']
True
InputText.async_added_to_hass
(self)
Run when entity about to be added to hass.
Run when entity about to be added to hass.
async def async_added_to_hass(self): """Run when entity about to be added to hass.""" await super().async_added_to_hass() if self._current_value is not None: return state = await self.async_get_last_state() value = state and state.state # Check against None ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "self", ".", "_current_value", "is", "not", "None", ":", "return", "state", "=", "await", "self", ".", "async_get_last_state...
[ 259, 4 ]
[ 270, 39 ]
python
en
['en', 'en', 'en']
True
InputText.async_set_value
(self, value)
Select new value.
Select new value.
async def async_set_value(self, value): """Select new value.""" if len(value) < self._minimum or len(value) > self._maximum: _LOGGER.warning( "Invalid value: %s (length range %s - %s)", value, self._minimum, self._maximum, ...
[ "async", "def", "async_set_value", "(", "self", ",", "value", ")", ":", "if", "len", "(", "value", ")", "<", "self", ".", "_minimum", "or", "len", "(", "value", ")", ">", "self", ".", "_maximum", ":", "_LOGGER", ".", "warning", "(", "\"Invalid value: %...
[ 272, 4 ]
[ 283, 35 ]
python
en
['en', 'en', 'en']
True
InputText.async_update_config
(self, config: typing.Dict)
Handle when the config is updated.
Handle when the config is updated.
async def async_update_config(self, config: typing.Dict) -> None: """Handle when the config is updated.""" self._config = config self.async_write_ha_state()
[ "async", "def", "async_update_config", "(", "self", ",", "config", ":", "typing", ".", "Dict", ")", "->", "None", ":", "self", ".", "_config", "=", "config", "self", ".", "async_write_ha_state", "(", ")" ]
[ 285, 4 ]
[ 288, 35 ]
python
en
['en', 'en', 'en']
True
AlbertTokenizer._tokenize
(self, text, sample=False)
Tokenize a string.
Tokenize a string.
def _tokenize(self, text, sample=False): """ Tokenize a string. """ text = self.preprocess_text(text) if not sample: pieces = self.sp_model.EncodeAsPieces(text) else: pieces = self.sp_model.SampleEncodeAsPieces(text, 64, 0.1) new_pieces = [] for p...
[ "def", "_tokenize", "(", "self", ",", "text", ",", "sample", "=", "False", ")", ":", "text", "=", "self", ".", "preprocess_text", "(", "text", ")", "if", "not", "sample", ":", "pieces", "=", "self", ".", "sp_model", ".", "EncodeAsPieces", "(", "text", ...
[ 188, 4 ]
[ 210, 25 ]
python
en
['en', 'gl', 'en']
True
AlbertTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.sp_model.PieceToId(token)
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "sp_model", ".", "PieceToId", "(", "token", ")" ]
[ 212, 4 ]
[ 214, 45 ]
python
en
['en', 'en', 'en']
True
AlbertTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" return self.sp_model.IdToPiece(index)
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "return", "self", ".", "sp_model", ".", "IdToPiece", "(", "index", ")" ]
[ 216, 4 ]
[ 218, 45 ]
python
en
['en', 'en', 'en']
True
AlbertTokenizer.build_inputs_with_special_tokens
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An ALBERT sequence has the following format: - single sequence: ``[CLS] X [SEP]`` - pair of sequences: ``[CLS] A [SEP] B [SEP]`` Args: ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An ALBERT sequence has the following format:
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An ALBERT sequence ha...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[", "...
[ 224, 4 ]
[ 247, 58 ]
python
en
['en', 'error', 'th']
False
AlbertTokenizer.get_special_tokens_mask
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False )
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`List[int]`,...
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method.
def get_special_tokens_mask( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False ) -> List[int]: """ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens ...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ",", "already_has_special_tokens", ":", "bool", "=", "False", ")", "->", ...
[ 249, 4 ]
[ 278, 51 ]
python
en
['en', 'error', 'th']
False
AlbertTokenizer.create_token_type_ids_from_sequences
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT sequence pair mask has the following format: :: 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 | first sequence | second sequence | If :obj:`token_ids_1` is :o...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT sequence pair mask has the following format:
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. An ALBERT sequence pair mask has the following format: ...
[ "def", "create_token_type_ids_from_sequences", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[",...
[ 280, 4 ]
[ 309, 80 ]
python
en
['en', 'error', 'th']
False
test_user_form
(hass)
Test we get the user form.
Test we get the user form.
async def test_user_form(hass): """Test we get the user form.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN...
[ "async", "def", "test_user_form", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notificat...
[ 35, 0 ]
[ 75, 48 ]
python
en
['en', 'da', 'en']
True
test_form_import
(hass)
Test we get the form with import source.
Test we get the form with import source.
async def test_form_import(hass): """Test we get the form with import source.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) import_config = VALID_CONFIG.copy() import_co...
[ "async", "def", "test_form_import", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notific...
[ 78, 0 ]
[ 128, 48 ]
python
en
['en', 'en', 'en']
True
test_form_import_with_zeroconf_already_discovered
(hass)
Test we get the form with import source.
Test we get the form with import source.
async def test_form_import_with_zeroconf_already_discovered(hass): """Test we get the form with import source.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) # Running the ze...
[ "async", "def", "test_form_import_with_zeroconf_already_discovered", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "await", "setup", ".", "async_setup_component", "(", "hass...
[ 131, 0 ]
[ 196, 48 ]
python
en
['en', 'en', 'en']
True
test_form_zeroconf_wrong_oui
(hass)
Test we abort when we get the wrong OUI via zeroconf.
Test we abort when we get the wrong OUI via zeroconf.
async def test_form_zeroconf_wrong_oui(hass): """Test we abort when we get the wrong OUI via zeroconf.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.conf...
[ "async", "def", "test_form_zeroconf_wrong_oui", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persis...
[ 199, 0 ]
[ 217, 52 ]
python
en
['en', 'en', 'en']
True
test_form_zeroconf_link_local_ignored
(hass)
Test we abort when we get a link local address via zeroconf.
Test we abort when we get a link local address via zeroconf.
async def test_form_zeroconf_link_local_ignored(hass): """Test we abort when we get a link local address via zeroconf.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) result =...
[ "async", "def", "test_form_zeroconf_link_local_ignored", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "await", "setup", ".", "async_setup_component", "(", "hass", ",", ...
[ 220, 0 ]
[ 238, 51 ]
python
en
['en', 'de', 'en']
True
test_form_zeroconf_correct_oui
(hass)
Test we can setup from zeroconf with the correct OUI source.
Test we can setup from zeroconf with the correct OUI source.
async def test_form_zeroconf_correct_oui(hass): """Test we can setup from zeroconf with the correct OUI source.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) result = await ...
[ "async", "def", "test_form_zeroconf_correct_oui", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"pers...
[ 241, 0 ]
[ 287, 48 ]
python
en
['en', 'en', 'en']
True
test_form_user_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_user_cannot_connect(hass): """Test we handle cannot connect error.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ...
[ "async", "def", "test_form_user_cannot_connect", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".",...
[ 290, 0 ]
[ 311, 58 ]
python
en
['en', 'en', 'en']
True
test_form_user_invalid_auth
(hass)
Test we handle cannot invalid auth error.
Test we handle cannot invalid auth error.
async def test_form_user_invalid_auth(hass): """Test we handle cannot invalid auth error.""" await hass.async_add_executor_job( init_recorder_component, hass ) # force in memory db result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER...
[ "async", "def", "test_form_user_invalid_auth", "(", "hass", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "init_recorder_component", ",", "hass", ")", "# force in memory db", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", ...
[ 314, 0 ]
[ 338, 56 ]
python
en
['en', 'en', 'en']
True
test_options_flow
(hass)
Test config flow options.
Test config flow options.
async def test_options_flow(hass): """Test config flow options.""" config_entry = MockConfigEntry( domain=DOMAIN, unique_id="abcde12345", data=VALID_CONFIG, options={CONF_EVENTS: ["event1", "event2", "event3"]}, ) config_entry.add_to_hass(hass) with patch( "...
[ "async", "def", "test_options_flow", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"abcde12345\"", ",", "data", "=", "VALID_CONFIG", ",", "options", "=", "{", "CONF_EVENTS", ":", "[", "\...
[ 341, 0 ]
[ 365, 84 ]
python
en
['en', 'fr', 'en']
True
download_wmt_dataset
(src_lang="ro", tgt_lang="en", dataset="wmt16", save_dir=None)
Download a dataset using the datasets package and save it to the format expected by finetune.py Format of save_dir: train.source, train.target, val.source, val.target, test.source, test.target. Args: src_lang: <str> source language tgt_lang: <str> target language dataset: <str> wmt16, w...
Download a dataset using the datasets package and save it to the format expected by finetune.py Format of save_dir: train.source, train.target, val.source, val.target, test.source, test.target.
def download_wmt_dataset(src_lang="ro", tgt_lang="en", dataset="wmt16", save_dir=None) -> None: """Download a dataset using the datasets package and save it to the format expected by finetune.py Format of save_dir: train.source, train.target, val.source, val.target, test.source, test.target. Args: ...
[ "def", "download_wmt_dataset", "(", "src_lang", "=", "\"ro\"", ",", "tgt_lang", "=", "\"en\"", ",", "dataset", "=", "\"wmt16\"", ",", "save_dir", "=", "None", ")", "->", "None", ":", "try", ":", "import", "datasets", "except", "(", "ModuleNotFoundError", ","...
[ 21, 0 ]
[ 62, 51 ]
python
en
['en', 'en', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 26, 0 ]
[ 28, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 32, 0 ]
[ 34, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 38, 0 ]
[ 40, 57 ]
python
en
['en', 'en', 'en']
True
test_get_conditions
(hass, device_reg, entity_reg)
Test we get the expected conditions from a media_player.
Test we get the expected conditions from a media_player.
async def test_get_conditions(hass, device_reg, entity_reg): """Test we get the expected conditions from a media_player.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_conditions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")",...
[ 43, 0 ]
[ 90, 54 ]
python
en
['en', 'en', 'en']
True
test_if_state
(hass, calls)
Test for turn_on and turn_off conditions.
Test for turn_on and turn_off conditions.
async def test_if_state(hass, calls): """Test for turn_on and turn_off conditions.""" hass.states.async_set("media_player.entity", STATE_ON) assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger...
[ "async", "def", "test_if_state", "(", "hass", ",", "calls", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"media_player.entity\"", ",", "STATE_ON", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",",...
[ 93, 0 ]
[ 242, 70 ]
python
en
['en', 'en', 'en']
True
async_register_info
( hass: HomeAssistant, domain: str, info_callback: Callable[[HomeAssistant], Dict], )
Register an info callback. Deprecated.
Register an info callback.
def async_register_info( hass: HomeAssistant, domain: str, info_callback: Callable[[HomeAssistant], Dict], ): """Register an info callback. Deprecated. """ _LOGGER.warning( "system_health.async_register_info is deprecated. Add a system_health platform instead." ) hass.data.s...
[ "def", "async_register_info", "(", "hass", ":", "HomeAssistant", ",", "domain", ":", "str", ",", "info_callback", ":", "Callable", "[", "[", "HomeAssistant", "]", ",", "Dict", "]", ",", ")", ":", "_LOGGER", ".", "warning", "(", "\"system_health.async_register_...
[ 26, 0 ]
[ 39, 77 ]
python
en
['en', 'no', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the System Health component.
Set up the System Health component.
async def async_setup(hass: HomeAssistant, config: ConfigType): """Set up the System Health component.""" hass.components.websocket_api.async_register_command(handle_info) hass.data.setdefault(DOMAIN, {}) await integration_platform.async_process_integration_platforms( hass, DOMAIN, _register_sy...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", ":", "hass", ".", "components", ".", "websocket_api", ".", "async_register_command", "(", "handle_info", ")", "hass", ".", "data", ".", "setdefault", "(", ...
[ 42, 0 ]
[ 51, 15 ]
python
en
['en', 'en', 'en']
True
_register_system_health_platform
(hass, integration_domain, platform)
Register a system health platform.
Register a system health platform.
async def _register_system_health_platform(hass, integration_domain, platform): """Register a system health platform.""" platform.async_register(hass, SystemHealthRegistration(hass, integration_domain))
[ "async", "def", "_register_system_health_platform", "(", "hass", ",", "integration_domain", ",", "platform", ")", ":", "platform", ".", "async_register", "(", "hass", ",", "SystemHealthRegistration", "(", "hass", ",", "integration_domain", ")", ")" ]
[ 54, 0 ]
[ 56, 85 ]
python
en
['en', 'da', 'en']
True
get_integration_info
( hass: HomeAssistant, registration: "SystemHealthRegistration" )
Get integration system health.
Get integration system health.
async def get_integration_info( hass: HomeAssistant, registration: "SystemHealthRegistration" ): """Get integration system health.""" try: with async_timeout.timeout(INFO_CALLBACK_TIMEOUT): data = await registration.info_callback(hass) except asyncio.TimeoutError: data = {"er...
[ "async", "def", "get_integration_info", "(", "hass", ":", "HomeAssistant", ",", "registration", ":", "\"SystemHealthRegistration\"", ")", ":", "try", ":", "with", "async_timeout", ".", "timeout", "(", "INFO_CALLBACK_TIMEOUT", ")", ":", "data", "=", "await", "regis...
[ 59, 0 ]
[ 77, 17 ]
python
da
['da', 'da', 'en']
True
_format_value
(val)
Format a system health value.
Format a system health value.
def _format_value(val): """Format a system health value.""" if isinstance(val, datetime): return {"value": val.isoformat(), "type": "date"} return val
[ "def", "_format_value", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "datetime", ")", ":", "return", "{", "\"value\"", ":", "val", ".", "isoformat", "(", ")", ",", "\"type\"", ":", "\"date\"", "}", "return", "val" ]
[ 81, 0 ]
[ 85, 14 ]
python
en
['sk', 'en', 'en']
True
handle_info
( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: Dict )
Handle an info request via a subscription.
Handle an info request via a subscription.
async def handle_info( hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: Dict ): """Handle an info request via a subscription.""" registrations: Dict[str, SystemHealthRegistration] = hass.data[DOMAIN] data = {} pending_info = {} for domain, domain_data in zip( regist...
[ "async", "def", "handle_info", "(", "hass", ":", "HomeAssistant", ",", "connection", ":", "websocket_api", ".", "ActiveConnection", ",", "msg", ":", "Dict", ")", ":", "registrations", ":", "Dict", "[", "str", ",", "SystemHealthRegistration", "]", "=", "hass", ...
[ 90, 0 ]
[ 180, 5 ]
python
en
['ga', 'fr', 'en']
False
async_check_can_reach_url
( hass: HomeAssistant, url: str, more_info: Optional[str] = None )
Test if the url can be reached.
Test if the url can be reached.
async def async_check_can_reach_url( hass: HomeAssistant, url: str, more_info: Optional[str] = None ) -> str: """Test if the url can be reached.""" session = aiohttp_client.async_get_clientsession(hass) try: await session.get(url, timeout=5) return "ok" except aiohttp.ClientError: ...
[ "async", "def", "async_check_can_reach_url", "(", "hass", ":", "HomeAssistant", ",", "url", ":", "str", ",", "more_info", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "session", "=", "aiohttp_client", ".", "async_get_clientsession", ...
[ 204, 0 ]
[ 217, 19 ]
python
en
['en', 'en', 'en']
True
create_switch_service
(accessory)
Define outlet characteristics.
Define outlet characteristics.
def create_switch_service(accessory): """Define outlet characteristics.""" service = accessory.add_service(ServicesTypes.OUTLET) on_char = service.add_char(CharacteristicsTypes.ON) on_char.value = False outlet_in_use = service.add_char(CharacteristicsTypes.OUTLET_IN_USE) outlet_in_use.value = ...
[ "def", "create_switch_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "OUTLET", ")", "on_char", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "ON", ")", "on_char", ".", "val...
[ 12, 0 ]
[ 20, 31 ]
python
en
['en', 'fr', 'en']
True
create_valve_service
(accessory)
Define valve characteristics.
Define valve characteristics.
def create_valve_service(accessory): """Define valve characteristics.""" service = accessory.add_service(ServicesTypes.VALVE) on_char = service.add_char(CharacteristicsTypes.ACTIVE) on_char.value = False in_use = service.add_char(CharacteristicsTypes.IN_USE) in_use.value = InUseValues.IN_USE ...
[ "def", "create_valve_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "VALVE", ")", "on_char", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "ACTIVE", ")", "on_char", ".", "v...
[ 23, 0 ]
[ 37, 24 ]
python
en
['en', 'et', 'en']
True
test_switch_change_outlet_state
(hass, utcnow)
Test that we can turn a HomeKit outlet on and off again.
Test that we can turn a HomeKit outlet on and off again.
async def test_switch_change_outlet_state(hass, utcnow): """Test that we can turn a HomeKit outlet on and off again.""" helper = await setup_test_component(hass, create_switch_service) await hass.services.async_call( "switch", "turn_on", {"entity_id": "switch.testdevice"}, blocking=True ) a...
[ "async", "def", "test_switch_change_outlet_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_switch_service", ")", "await", "hass", ".", "services", ".", "async_call", "(", "\"switch\"", ",", ...
[ 40, 0 ]
[ 52, 62 ]
python
en
['en', 'en', 'en']
True
test_switch_read_outlet_state
(hass, utcnow)
Test that we can read the state of a HomeKit outlet accessory.
Test that we can read the state of a HomeKit outlet accessory.
async def test_switch_read_outlet_state(hass, utcnow): """Test that we can read the state of a HomeKit outlet accessory.""" helper = await setup_test_component(hass, create_switch_service) # Initial state is that the switch is off and the outlet isn't in use switch_1 = await helper.poll_and_get_state()...
[ "async", "def", "test_switch_read_outlet_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_switch_service", ")", "# Initial state is that the switch is off and the outlet isn't in use", "switch_1", "=", "...
[ 55, 0 ]
[ 79, 55 ]
python
en
['en', 'en', 'en']
True
test_valve_change_active_state
(hass, utcnow)
Test that we can turn a valve on and off again.
Test that we can turn a valve on and off again.
async def test_valve_change_active_state(hass, utcnow): """Test that we can turn a valve on and off again.""" helper = await setup_test_component(hass, create_valve_service) await hass.services.async_call( "switch", "turn_on", {"entity_id": "switch.testdevice"}, blocking=True ) assert helpe...
[ "async", "def", "test_valve_change_active_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_valve_service", ")", "await", "hass", ".", "services", ".", "async_call", "(", "\"switch\"", ",", "\...
[ 82, 0 ]
[ 94, 65 ]
python
en
['en', 'en', 'en']
True
test_valve_read_state
(hass, utcnow)
Test that we can read the state of a valve accessory.
Test that we can read the state of a valve accessory.
async def test_valve_read_state(hass, utcnow): """Test that we can read the state of a valve accessory.""" helper = await setup_test_component(hass, create_valve_service) # Initial state is that the switch is off and the outlet isn't in use switch_1 = await helper.poll_and_get_state() assert switch...
[ "async", "def", "test_valve_read_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_valve_service", ")", "# Initial state is that the switch is off and the outlet isn't in use", "switch_1", "=", "await", ...
[ 97, 0 ]
[ 123, 49 ]
python
en
['en', 'en', 'en']
True
setup_integration
(hass)
Build the mock integration.
Build the mock integration.
async def setup_integration(hass): """Build the mock integration.""" entry = MockConfigEntry( domain=DOMAIN, unique_id=TEST_USERNAME, data=CONFIG, entry_id=ENTRY_ID ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done()
[ "async", "def", "setup_integration", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "TEST_USERNAME", ",", "data", "=", "CONFIG", ",", "entry_id", "=", "ENTRY_ID", ")", "entry", ".", "add_to_hass",...
[ 117, 0 ]
[ 124, 38 ]
python
en
['en', 'da', 'en']
True
test_simple_properties
(hass: HomeAssistant)
Test that simple properties work as intended.
Test that simple properties work as intended.
async def test_simple_properties(hass: HomeAssistant): """Test that simple properties work as intended.""" state = hass.states.get(VAC_ENTITY_ID) registry = await hass.helpers.entity_registry.async_get_registry() entity = registry.async_get(VAC_ENTITY_ID) assert entity assert state assert s...
[ "async", "def", "test_simple_properties", "(", "hass", ":", "HomeAssistant", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "VAC_ENTITY_ID", ")", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registr...
[ 127, 0 ]
[ 136, 48 ]
python
en
['en', 'en', 'en']
True
test_initial_attributes
( hass: HomeAssistant, attribute: str, target_value: Any )
Test initial config attributes.
Test initial config attributes.
async def test_initial_attributes( hass: HomeAssistant, attribute: str, target_value: Any ): """Test initial config attributes.""" state = hass.states.get(VAC_ENTITY_ID) assert state.attributes.get(attribute) == target_value
[ "async", "def", "test_initial_attributes", "(", "hass", ":", "HomeAssistant", ",", "attribute", ":", "str", ",", "target_value", ":", "Any", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "VAC_ENTITY_ID", ")", "assert", "state", ".", "attr...
[ 152, 0 ]
[ 157, 58 ]
python
de
['de', 'la', 'en']
False
test_cleaning_states
(hass: HomeAssistant, service: str, target_state: str)
Test cleaning states.
Test cleaning states.
async def test_cleaning_states(hass: HomeAssistant, service: str, target_state: str): """Test cleaning states.""" service_data = {ATTR_ENTITY_ID: VAC_ENTITY_ID} await hass.services.async_call("vacuum", service, service_data, blocking=True) state = hass.states.get(VAC_ENTITY_ID) assert state.state ==...
[ "async", "def", "test_cleaning_states", "(", "hass", ":", "HomeAssistant", ",", "service", ":", "str", ",", "target_state", ":", "str", ")", ":", "service_data", "=", "{", "ATTR_ENTITY_ID", ":", "VAC_ENTITY_ID", "}", "await", "hass", ".", "services", ".", "a...
[ 169, 0 ]
[ 174, 38 ]
python
en
['en', 'en', 'en']
True
test_fan_speed
(hass: HomeAssistant, fan_speed: str)
Test setting fan speeds.
Test setting fan speeds.
async def test_fan_speed(hass: HomeAssistant, fan_speed: str) -> None: """Test setting fan speeds.""" service_data = {ATTR_ENTITY_ID: VAC_ENTITY_ID, ATTR_FAN_SPEED: fan_speed} await hass.services.async_call( "vacuum", SERVICE_SET_FAN_SPEED, service_data, blocking=True ) state = hass.states.g...
[ "async", "def", "test_fan_speed", "(", "hass", ":", "HomeAssistant", ",", "fan_speed", ":", "str", ")", "->", "None", ":", "service_data", "=", "{", "ATTR_ENTITY_ID", ":", "VAC_ENTITY_ID", ",", "ATTR_FAN_SPEED", ":", "fan_speed", "}", "await", "hass", ".", "...
[ 178, 0 ]
[ 185, 60 ]
python
en
['en', 'fy', 'en']
True