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
main
(params)
Main function, build mnist network, run and send result to NNI.
Main function, build mnist network, run and send result to NNI.
def main(params): ''' Main function, build mnist network, run and send result to NNI. ''' # Import data mnist = download_mnist_retry(params['data_dir']) print('Mnist download data done.') logger.debug('Mnist download data done.') # Create the model # Build the graph for the deep net...
[ "def", "main", "(", "params", ")", ":", "# Import data", "mnist", "=", "download_mnist_retry", "(", "params", "[", "'data_dir'", "]", ")", "print", "(", "'Mnist download data done.'", ")", "logger", ".", "debug", "(", "'Mnist download data done.'", ")", "# Create ...
[ 167, 0 ]
[ 224, 47 ]
python
en
['en', 'error', 'th']
False
generate_defualt_params
()
Generate default parameters for mnist network.
Generate default parameters for mnist network.
def generate_defualt_params(): ''' Generate default parameters for mnist network. ''' params = { 'data_dir': '/tmp/tensorflow/mnist/input_data', 'dropout_rate': 0.5, 'channel_1_num': 32, 'channel_2_num': 64, 'conv_size': 5, 'pool_size': 2, 'hidden_...
[ "def", "generate_defualt_params", "(", ")", ":", "params", "=", "{", "'data_dir'", ":", "'/tmp/tensorflow/mnist/input_data'", ",", "'dropout_rate'", ":", "0.5", ",", "'channel_1_num'", ":", "32", ",", "'channel_2_num'", ":", "64", ",", "'conv_size'", ":", "5", "...
[ 227, 0 ]
[ 241, 17 ]
python
en
['en', 'error', 'th']
False
MnistNetwork.__init__
(self, channel_1_num, channel_2_num, conv_size, hidden_size, pool_size, learning_rate, x_dim=784, y_dim=10)
@nni.variable(nni.choice(2, 3, 5, 7),name=self.conv_size)
def __init__(self, channel_1_num, channel_2_num, conv_size, hidden_size, pool_size, learning_rate, x_dim=784, y_dim=10): self.channel_1_num = channel_1_num self.channel...
[ "def", "__init__", "(", "self", ",", "channel_1_num", ",", "channel_2_num", ",", "conv_size", ",", "hidden_size", ",", "pool_size", ",", "learning_rate", ",", "x_dim", "=", "784", ",", "y_dim", "=", "10", ")", ":", "self", ".", "channel_1_num", "=", "chann...
[ 24, 4 ]
[ 50, 28 ]
python
ceb
['en', 'ceb', 'sw']
False
MnistNetwork.build_network
(self)
Building network for mnist
Building network for mnist
def build_network(self): ''' Building network for mnist ''' # Reshape to use within a convolutional neural net. # Last dimension is for "features" - there is only one here, since images are # grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc. with tf.n...
[ "def", "build_network", "(", "self", ")", ":", "# Reshape to use within a convolutional neural net.", "# Last dimension is for \"features\" - there is only one here, since images are", "# grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc.", "with", "tf", ".", "name_scope", "(", ...
[ 52, 4 ]
[ 128, 56 ]
python
en
['en', 'error', 'th']
False
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 37, 0 ]
[ 78, 48 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) mocked_roomba = _create_mocked_roomba( connect=RoombaConnectionError, roomba_connecte...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 81, 0 ]
[ 103, 58 ]
python
en
['en', 'en', 'en']
True
test_form_import
(hass)
Test we can import yaml config.
Test we can import yaml config.
async def test_form_import(hass): """Test we can import yaml config.""" mocked_roomba = _create_mocked_roomba( roomba_connected=True, master_state={"state": {"reported": {"name": "imported_roomba"}}}, ) with patch( "homeassistant.components.roomba.config_flow.Roomba", r...
[ "async", "def", "test_form_import", "(", "hass", ")", ":", "mocked_roomba", "=", "_create_mocked_roomba", "(", "roomba_connected", "=", "True", ",", "master_state", "=", "{", "\"state\"", ":", "{", "\"reported\"", ":", "{", "\"name\"", ":", "\"imported_roomba\"", ...
[ 106, 0 ]
[ 142, 48 ]
python
en
['en', 'en', 'sw']
True
test_form_import_dupe
(hass)
Test we get abort on duplicate import.
Test we get abort on duplicate import.
async def test_form_import_dupe(hass): """Test we get abort on duplicate import.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry(domain=DOMAIN, data=VALID_CONFIG, unique_id="blid") entry.add_to_hass(hass) result = await hass.config_entries.flow.asy...
[ "async", "def", "test_form_import_dupe", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "="...
[ 145, 0 ]
[ 158, 51 ]
python
en
['nl', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Dyson fan components.
Set up the Dyson fan components.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dyson fan components.""" if discovery_info is None: return known_devices = hass.data.setdefault(DYSON_KNOWN_CLIMATE_DEVICES, set()) # Get Dyson Devices from parent component new_entities = [] for device...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "known_devices", "=", "hass", ".", "data", ".", "setdefault", "(", "DYSON_KNOWN_CLIMATE...
[ 65, 0 ]
[ 86, 30 ]
python
en
['en', 'fr', 'en']
True
DysonPureHotCoolLinkEntity.__init__
(self, device)
Initialize the fan.
Initialize the fan.
def __init__(self, device): """Initialize the fan.""" self._device = device self._current_temp = None
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "_device", "=", "device", "self", ".", "_current_temp", "=", "None" ]
[ 92, 4 ]
[ 95, 33 ]
python
en
['en', 'fy', 'en']
True
DysonPureHotCoolLinkEntity.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self._device.add_message_listener(self.on_message)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_device", ".", "add_message_listener", "(", "self", ".", "on_message", ")" ]
[ 97, 4 ]
[ 99, 58 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.on_message
(self, message)
Call when new messages received from the climate.
Call when new messages received from the climate.
def on_message(self, message): """Call when new messages received from the climate.""" if isinstance(message, DysonPureHotCoolState): _LOGGER.debug( "Message received for climate device %s : %s", self.name, message ) self.schedule_update_ha_state()
[ "def", "on_message", "(", "self", ",", "message", ")", ":", "if", "isinstance", "(", "message", ",", "DysonPureHotCoolState", ")", ":", "_LOGGER", ".", "debug", "(", "\"Message received for climate device %s : %s\"", ",", "self", ".", "name", ",", "message", ")"...
[ 101, 4 ]
[ 107, 43 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 110, 4 ]
[ 112, 20 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return SUPPORT_FLAGS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_FLAGS" ]
[ 115, 4 ]
[ 117, 28 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.name
(self)
Return the display name of this climate.
Return the display name of this climate.
def name(self): """Return the display name of this climate.""" return self._device.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "name" ]
[ 120, 4 ]
[ 122, 32 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 125, 4 ]
[ 127, 27 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolLinkEntity.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" if self._device.environmental_state: temperature_kelvin = self._device.environmental_state.temperature if temperature_kelvin != 0: self._current_temp = float(f"{(temperature_kelvin - 273):.1f}") ...
[ "def", "current_temperature", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ":", "temperature_kelvin", "=", "self", ".", "_device", ".", "environmental_state", ".", "temperature", "if", "temperature_kelvin", "!=", "0", ":", "se...
[ 130, 4 ]
[ 136, 33 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolLinkEntity.target_temperature
(self)
Return the target temperature.
Return the target temperature.
def target_temperature(self): """Return the target temperature.""" heat_target = int(self._device.state.heat_target) / 10 return int(heat_target - 273)
[ "def", "target_temperature", "(", "self", ")", ":", "heat_target", "=", "int", "(", "self", ".", "_device", ".", "state", ".", "heat_target", ")", "/", "10", "return", "int", "(", "heat_target", "-", "273", ")" ]
[ 139, 4 ]
[ 142, 37 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolLinkEntity.current_humidity
(self)
Return the current humidity.
Return the current humidity.
def current_humidity(self): """Return the current humidity.""" if self._device.environmental_state: if self._device.environmental_state.humidity == 0: return None return self._device.environmental_state.humidity return None
[ "def", "current_humidity", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ":", "if", "self", ".", "_device", ".", "environmental_state", ".", "humidity", "==", "0", ":", "return", "None", "return", "self", ".", "_device", ...
[ 145, 4 ]
[ 151, 19 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.hvac_mode
(self)
Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*.
Return hvac operation ie. heat, cool mode.
def hvac_mode(self): """Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*. """ if self._device.state.heat_mode == HeatMode.HEAT_ON.value: return HVAC_MODE_HEAT return HVAC_MODE_COOL
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ".", "heat_mode", "==", "HeatMode", ".", "HEAT_ON", ".", "value", ":", "return", "HVAC_MODE_HEAT", "return", "HVAC_MODE_COOL" ]
[ 154, 4 ]
[ 161, 29 ]
python
bg
['en', 'bg', 'bg']
True
DysonPureHotCoolLinkEntity.hvac_modes
(self)
Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES.
Return the list of available hvac operation modes.
def hvac_modes(self): """Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES. """ return SUPPORT_HVAG
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "SUPPORT_HVAG" ]
[ 164, 4 ]
[ 169, 27 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.hvac_action
(self)
Return the current running hvac operation if supported. Need to be one of CURRENT_HVAC_*.
Return the current running hvac operation if supported.
def hvac_action(self): """Return the current running hvac operation if supported. Need to be one of CURRENT_HVAC_*. """ if self._device.state.heat_mode == HeatMode.HEAT_ON.value: if self._device.state.heat_state == HeatState.HEAT_STATE_ON.value: return CURREN...
[ "def", "hvac_action", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ".", "heat_mode", "==", "HeatMode", ".", "HEAT_ON", ".", "value", ":", "if", "self", ".", "_device", ".", "state", ".", "heat_state", "==", "HeatState", ".", "HEAT...
[ 172, 4 ]
[ 181, 32 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.fan_mode
(self)
Return the fan setting.
Return the fan setting.
def fan_mode(self): """Return the fan setting.""" if self._device.state.focus_mode == FocusMode.FOCUS_ON.value: return FAN_FOCUS return FAN_DIFFUSE
[ "def", "fan_mode", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ".", "focus_mode", "==", "FocusMode", ".", "FOCUS_ON", ".", "value", ":", "return", "FAN_FOCUS", "return", "FAN_DIFFUSE" ]
[ 184, 4 ]
[ 188, 26 ]
python
en
['en', 'fy', 'en']
True
DysonPureHotCoolLinkEntity.fan_modes
(self)
Return the list of available fan modes.
Return the list of available fan modes.
def fan_modes(self): """Return the list of available fan modes.""" return SUPPORT_FAN
[ "def", "fan_modes", "(", "self", ")", ":", "return", "SUPPORT_FAN" ]
[ 191, 4 ]
[ 193, 26 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolLinkEntity.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs): """Set new target temperature.""" target_temp = kwargs.get(ATTR_TEMPERATURE) if target_temp is None: return target_temp = int(target_temp) _LOGGER.debug("Set %s temperature %s", self.name, target_temp) # Limit the target te...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "target_temp", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "if", "target_temp", "is", "None", ":", "return", "target_temp", "=", "int", "(", "target_temp", ")", "_LOGGER...
[ 195, 4 ]
[ 207, 9 ]
python
en
['en', 'ca', 'en']
True
DysonPureHotCoolLinkEntity.set_fan_mode
(self, fan_mode)
Set new fan mode.
Set new fan mode.
def set_fan_mode(self, fan_mode): """Set new fan mode.""" _LOGGER.debug("Set %s focus mode %s", self.name, fan_mode) if fan_mode == FAN_FOCUS: self._device.set_configuration(focus_mode=FocusMode.FOCUS_ON) elif fan_mode == FAN_DIFFUSE: self._device.set_configuratio...
[ "def", "set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "_LOGGER", ".", "debug", "(", "\"Set %s focus mode %s\"", ",", "self", ".", "name", ",", "fan_mode", ")", "if", "fan_mode", "==", "FAN_FOCUS", ":", "self", ".", "_device", ".", "set_configuration...
[ 209, 4 ]
[ 215, 74 ]
python
en
['id', 'fy', 'en']
False
DysonPureHotCoolLinkEntity.set_hvac_mode
(self, hvac_mode)
Set new target hvac mode.
Set new target hvac mode.
def set_hvac_mode(self, hvac_mode): """Set new target hvac mode.""" _LOGGER.debug("Set %s heat mode %s", self.name, hvac_mode) if hvac_mode == HVAC_MODE_HEAT: self._device.set_configuration(heat_mode=HeatMode.HEAT_ON) elif hvac_mode == HVAC_MODE_COOL: self._device...
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "_LOGGER", ".", "debug", "(", "\"Set %s heat mode %s\"", ",", "self", ".", "name", ",", "hvac_mode", ")", "if", "hvac_mode", "==", "HVAC_MODE_HEAT", ":", "self", ".", "_device", ".", "set_confi...
[ 217, 4 ]
[ 223, 71 ]
python
da
['da', 'su', 'en']
False
DysonPureHotCoolLinkEntity.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self): """Return the minimum temperature.""" return 1
[ "def", "min_temp", "(", "self", ")", ":", "return", "1" ]
[ 226, 4 ]
[ 228, 16 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolLinkEntity.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self): """Return the maximum temperature.""" return 37
[ "def", "max_temp", "(", "self", ")", ":", "return", "37" ]
[ 231, 4 ]
[ 233, 17 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolEntity.__init__
(self, device)
Initialize the fan.
Initialize the fan.
def __init__(self, device): """Initialize the fan.""" self._device = device
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "_device", "=", "device" ]
[ 239, 4 ]
[ 241, 29 ]
python
en
['en', 'fy', 'en']
True
DysonPureHotCoolEntity.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self._device.add_message_listener(self.on_message)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_device", ".", "add_message_listener", "(", "self", ".", "on_message", ")" ]
[ 243, 4 ]
[ 245, 58 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.on_message
(self, message)
Call when new messages received from the climate device.
Call when new messages received from the climate device.
def on_message(self, message): """Call when new messages received from the climate device.""" if isinstance(message, DysonPureHotCoolV2State): _LOGGER.debug( "Message received for climate device %s : %s", self.name, message ) self.schedule_update_ha_st...
[ "def", "on_message", "(", "self", ",", "message", ")", ":", "if", "isinstance", "(", "message", ",", "DysonPureHotCoolV2State", ")", ":", "_LOGGER", ".", "debug", "(", "\"Message received for climate device %s : %s\"", ",", "self", ".", "name", ",", "message", "...
[ 247, 4 ]
[ 253, 43 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 256, 4 ]
[ 258, 20 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return SUPPORT_FLAGS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_FLAGS" ]
[ 261, 4 ]
[ 263, 28 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.name
(self)
Return the display name of this climate.
Return the display name of this climate.
def name(self): """Return the display name of this climate.""" return self._device.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "name" ]
[ 266, 4 ]
[ 268, 32 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 271, 4 ]
[ 273, 27 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolEntity.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" if self._device.environmental_state.temperature is not None: temperature_kelvin = self._device.environmental_state.temperature if temperature_kelvin != 0: return float("{:.1f}".format(temperature...
[ "def", "current_temperature", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ".", "temperature", "is", "not", "None", ":", "temperature_kelvin", "=", "self", ".", "_device", ".", "environmental_state", ".", "temperature", "if", ...
[ 276, 4 ]
[ 282, 19 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolEntity.target_temperature
(self)
Return the target temperature.
Return the target temperature.
def target_temperature(self): """Return the target temperature.""" heat_target = int(self._device.state.heat_target) / 10 return int(heat_target - 273)
[ "def", "target_temperature", "(", "self", ")", ":", "heat_target", "=", "int", "(", "self", ".", "_device", ".", "state", ".", "heat_target", ")", "/", "10", "return", "int", "(", "heat_target", "-", "273", ")" ]
[ 285, 4 ]
[ 288, 37 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolEntity.current_humidity
(self)
Return the current humidity.
Return the current humidity.
def current_humidity(self): """Return the current humidity.""" if self._device.environmental_state.humidity is not None: if self._device.environmental_state.humidity != 0: return self._device.environmental_state.humidity return None
[ "def", "current_humidity", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ".", "humidity", "is", "not", "None", ":", "if", "self", ".", "_device", ".", "environmental_state", ".", "humidity", "!=", "0", ":", "return", "sel...
[ 291, 4 ]
[ 296, 19 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.hvac_mode
(self)
Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*.
Return hvac operation ie. heat, cool mode.
def hvac_mode(self): """Return hvac operation ie. heat, cool mode. Need to be one of HVAC_MODE_*. """ if self._device.state.fan_power == FanPower.POWER_OFF.value: return HVAC_MODE_OFF if self._device.state.heat_mode == HeatMode.HEAT_ON.value: return HVAC_...
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ".", "fan_power", "==", "FanPower", ".", "POWER_OFF", ".", "value", ":", "return", "HVAC_MODE_OFF", "if", "self", ".", "_device", ".", "state", ".", "heat_mode", "==",...
[ 299, 4 ]
[ 308, 29 ]
python
bg
['en', 'bg', 'bg']
True
DysonPureHotCoolEntity.hvac_modes
(self)
Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES.
Return the list of available hvac operation modes.
def hvac_modes(self): """Return the list of available hvac operation modes. Need to be a subset of HVAC_MODES. """ return SUPPORT_HVAC_PCOOL
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "SUPPORT_HVAC_PCOOL" ]
[ 311, 4 ]
[ 316, 33 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.hvac_action
(self)
Return the current running hvac operation if supported. Need to be one of CURRENT_HVAC_*.
Return the current running hvac operation if supported.
def hvac_action(self): """Return the current running hvac operation if supported. Need to be one of CURRENT_HVAC_*. """ if self._device.state.fan_power == FanPower.POWER_OFF.value: return CURRENT_HVAC_OFF if self._device.state.heat_mode == HeatMode.HEAT_ON.value: ...
[ "def", "hvac_action", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ".", "fan_power", "==", "FanPower", ".", "POWER_OFF", ".", "value", ":", "return", "CURRENT_HVAC_OFF", "if", "self", ".", "_device", ".", "state", ".", "heat_mode", ...
[ 319, 4 ]
[ 330, 32 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.fan_mode
(self)
Return the fan setting.
Return the fan setting.
def fan_mode(self): """Return the fan setting.""" if self._device.state.fan_state == FanState.FAN_OFF.value: return FAN_OFF return SPEED_MAP[self._device.state.speed]
[ "def", "fan_mode", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ".", "fan_state", "==", "FanState", ".", "FAN_OFF", ".", "value", ":", "return", "FAN_OFF", "return", "SPEED_MAP", "[", "self", ".", "_device", ".", "state", ".", "sp...
[ 333, 4 ]
[ 338, 50 ]
python
en
['en', 'fy', 'en']
True
DysonPureHotCoolEntity.fan_modes
(self)
Return the list of available fan modes.
Return the list of available fan modes.
def fan_modes(self): """Return the list of available fan modes.""" return SUPPORT_FAN_PCOOL
[ "def", "fan_modes", "(", "self", ")", ":", "return", "SUPPORT_FAN_PCOOL" ]
[ 341, 4 ]
[ 343, 32 ]
python
en
['en', 'en', 'en']
True
DysonPureHotCoolEntity.set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
def set_temperature(self, **kwargs): """Set new target temperature.""" target_temp = kwargs.get(ATTR_TEMPERATURE) if target_temp is None: _LOGGER.error("Missing target temperature %s", kwargs) return target_temp = int(target_temp) _LOGGER.debug("Set %s tem...
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "target_temp", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "if", "target_temp", "is", "None", ":", "_LOGGER", ".", "error", "(", "\"Missing target temperature %s\"", ",", ...
[ 345, 4 ]
[ 356, 69 ]
python
en
['en', 'ca', 'en']
True
DysonPureHotCoolEntity.set_fan_mode
(self, fan_mode)
Set new fan mode.
Set new fan mode.
def set_fan_mode(self, fan_mode): """Set new fan mode.""" _LOGGER.debug("Set %s focus mode %s", self.name, fan_mode) if fan_mode == FAN_OFF: self._device.turn_off() elif fan_mode == FAN_LOW: self._device.set_fan_speed(FanSpeed.FAN_SPEED_4) elif fan_mode ==...
[ "def", "set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "_LOGGER", ".", "debug", "(", "\"Set %s focus mode %s\"", ",", "self", ".", "name", ",", "fan_mode", ")", "if", "fan_mode", "==", "FAN_OFF", ":", "self", ".", "_device", ".", "turn_off", "(", ...
[ 358, 4 ]
[ 370, 63 ]
python
en
['id', 'fy', 'en']
False
DysonPureHotCoolEntity.set_hvac_mode
(self, hvac_mode)
Set new target hvac mode.
Set new target hvac mode.
def set_hvac_mode(self, hvac_mode): """Set new target hvac mode.""" _LOGGER.debug("Set %s heat mode %s", self.name, hvac_mode) if hvac_mode == HVAC_MODE_OFF: self._device.turn_off() elif self._device.state.fan_power == FanPower.POWER_OFF.value: self._device.turn_o...
[ "def", "set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "_LOGGER", ".", "debug", "(", "\"Set %s heat mode %s\"", ",", "self", ".", "name", ",", "hvac_mode", ")", "if", "hvac_mode", "==", "HVAC_MODE_OFF", ":", "self", ".", "_device", ".", "turn_off",...
[ 372, 4 ]
[ 382, 44 ]
python
da
['da', 'su', 'en']
False
DysonPureHotCoolEntity.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self): """Return the minimum temperature.""" return 1
[ "def", "min_temp", "(", "self", ")", ":", "return", "1" ]
[ 385, 4 ]
[ 387, 16 ]
python
en
['en', 'la', 'en']
True
DysonPureHotCoolEntity.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self): """Return the maximum temperature.""" return 37
[ "def", "max_temp", "(", "self", ")", ":", "return", "37" ]
[ 390, 4 ]
[ 392, 17 ]
python
en
['en', 'la', 'en']
True
_get_dyson_account_device_available
()
Return a valid device provide by Dyson web services.
Return a valid device provide by Dyson web services.
def _get_dyson_account_device_available(): """Return a valid device provide by Dyson web services.""" device = mock.Mock() load_mock_device(device) device.connect = mock.Mock(return_value=True) device.auto_connect = mock.Mock(return_value=True) return device
[ "def", "_get_dyson_account_device_available", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", ")", "load_mock_device", "(", "device", ")", "device", ".", "connect", "=", "mock", ".", "Mock", "(", "return_value", "=", "True", ")", "device", ".", "au...
[ 11, 0 ]
[ 17, 17 ]
python
en
['en', 'en', 'en']
True
_get_dyson_account_device_not_available
()
Return an invalid device provide by Dyson web services.
Return an invalid device provide by Dyson web services.
def _get_dyson_account_device_not_available(): """Return an invalid device provide by Dyson web services.""" device = mock.Mock() load_mock_device(device) device.connect = mock.Mock(return_value=False) device.auto_connect = mock.Mock(return_value=False) return device
[ "def", "_get_dyson_account_device_not_available", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", ")", "load_mock_device", "(", "device", ")", "device", ".", "connect", "=", "mock", ".", "Mock", "(", "return_value", "=", "False", ")", "device", ".", ...
[ 20, 0 ]
[ 26, 17 ]
python
en
['en', 'en', 'en']
True
_get_dyson_account_device_error
()
Return an invalid device raising OSError while connecting.
Return an invalid device raising OSError while connecting.
def _get_dyson_account_device_error(): """Return an invalid device raising OSError while connecting.""" device = mock.Mock() load_mock_device(device) device.connect = mock.Mock(side_effect=OSError("Network error")) return device
[ "def", "_get_dyson_account_device_error", "(", ")", ":", "device", "=", "mock", ".", "Mock", "(", ")", "load_mock_device", "(", "device", ")", "device", ".", "connect", "=", "mock", ".", "Mock", "(", "side_effect", "=", "OSError", "(", "\"Network error\"", "...
[ 29, 0 ]
[ 34, 17 ]
python
en
['en', 'en', 'en']
True
DysonTest.setUp
(self)
Set up things to be run when tests are started.
Set up things to be run when tests are started.
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant() self.addCleanup(self.tear_down_cleanup)
[ "def", "setUp", "(", "self", ")", ":", "# pylint: disable=invalid-name", "self", ".", "hass", "=", "get_test_home_assistant", "(", ")", "self", ".", "addCleanup", "(", "self", ".", "tear_down_cleanup", ")" ]
[ 40, 4 ]
[ 43, 47 ]
python
en
['en', 'en', 'en']
True
DysonTest.tear_down_cleanup
(self)
Stop everything that was started.
Stop everything that was started.
def tear_down_cleanup(self): """Stop everything that was started.""" self.hass.stop()
[ "def", "tear_down_cleanup", "(", "self", ")", ":", "self", ".", "hass", ".", "stop", "(", ")" ]
[ 45, 4 ]
[ 47, 24 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_login_failed
(self, mocked_login)
Test if Dyson connection failed.
Test if Dyson connection failed.
def test_dyson_login_failed(self, mocked_login): """Test if Dyson connection failed.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson.CONF_PASSWORD: "password", dyson.CONF_...
[ "def", "test_dyson_login_failed", "(", "self", ",", "mocked_login", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\"email\"", ",", "dyson", ".", "CONF_PASSWORD", ...
[ 50, 4 ]
[ 62, 43 ]
python
en
['ms', 'ga', 'en']
False
DysonTest.test_dyson_login
(self, mocked_login, mocked_devices)
Test valid connection to dyson web service.
Test valid connection to dyson web service.
def test_dyson_login(self, mocked_login, mocked_devices): """Test valid connection to dyson web service.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson.CONF_PASSWORD: "password", ...
[ "def", "test_dyson_login", "(", "self", ",", "mocked_login", ",", "mocked_devices", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\"email\"", ",", "dyson", ".",...
[ 66, 4 ]
[ 80, 60 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_custom_conf
(self, mocked_login, mocked_devices, mocked_discovery)
Test device connection using custom configuration.
Test device connection using custom configuration.
def test_dyson_custom_conf(self, mocked_login, mocked_devices, mocked_discovery): """Test device connection using custom configuration.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson.CONF_PA...
[ "def", "test_dyson_custom_conf", "(", "self", ",", "mocked_login", ",", "mocked_devices", ",", "mocked_discovery", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\...
[ 88, 4 ]
[ 106, 47 ]
python
en
['fr', 'en', 'en']
True
DysonTest.test_dyson_custom_conf_device_not_available
(self, mocked_login, mocked_devices)
Test device connection with an invalid device.
Test device connection with an invalid device.
def test_dyson_custom_conf_device_not_available(self, mocked_login, mocked_devices): """Test device connection with an invalid device.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson.CONF_PAS...
[ "def", "test_dyson_custom_conf_device_not_available", "(", "self", ",", "mocked_login", ",", "mocked_devices", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\"email\"...
[ 113, 4 ]
[ 130, 60 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_custom_conf_device_error
(self, mocked_login, mocked_devices)
Test device connection with device raising an exception.
Test device connection with device raising an exception.
def test_dyson_custom_conf_device_error(self, mocked_login, mocked_devices): """Test device connection with device raising an exception.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson.CONF_P...
[ "def", "test_dyson_custom_conf_device_error", "(", "self", ",", "mocked_login", ",", "mocked_devices", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\"email\"", ","...
[ 137, 4 ]
[ 154, 60 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_custom_conf_with_unknown_device
( self, mocked_login, mocked_devices, mocked_discovery )
Test device connection with custom conf and unknown device.
Test device connection with custom conf and unknown device.
def test_dyson_custom_conf_with_unknown_device( self, mocked_login, mocked_devices, mocked_discovery ): """Test device connection with custom conf and unknown device.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME:...
[ "def", "test_dyson_custom_conf_with_unknown_device", "(", "self", ",", "mocked_login", ",", "mocked_devices", ",", "mocked_discovery", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_US...
[ 162, 4 ]
[ 182, 47 ]
python
en
['en', 'en', 'en']
True
DysonTest.test_dyson_discovery
(self, mocked_login, mocked_devices, mocked_discovery)
Test device connection using discovery.
Test device connection using discovery.
def test_dyson_discovery(self, mocked_login, mocked_devices, mocked_discovery): """Test device connection using discovery.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson.CONF_PASSWORD: "pass...
[ "def", "test_dyson_discovery", "(", "self", ",", "mocked_login", ",", "mocked_devices", ",", "mocked_discovery", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\"e...
[ 190, 4 ]
[ 207, 47 ]
python
en
['id', 'en', 'en']
True
DysonTest.test_dyson_discovery_device_not_available
(self, mocked_login, mocked_devices)
Test device connection with discovery and invalid device.
Test device connection with discovery and invalid device.
def test_dyson_discovery_device_not_available(self, mocked_login, mocked_devices): """Test device connection with discovery and invalid device.""" dyson.setup( self.hass, { dyson.DOMAIN: { dyson.CONF_USERNAME: "email", dyson...
[ "def", "test_dyson_discovery_device_not_available", "(", "self", ",", "mocked_login", ",", "mocked_devices", ")", ":", "dyson", ".", "setup", "(", "self", ".", "hass", ",", "{", "dyson", ".", "DOMAIN", ":", "{", "dyson", ".", "CONF_USERNAME", ":", "\"email\"",...
[ 214, 4 ]
[ 230, 60 ]
python
en
['en', 'en', 'en']
True
auth_manager_from_config
( hass: HomeAssistant, provider_configs: List[Dict[str, Any]], module_configs: List[Dict[str, Any]], )
Initialize an auth manager from config. CORE_CONFIG_SCHEMA will make sure do duplicated auth providers or mfa modules exist in configs.
Initialize an auth manager from config.
async def auth_manager_from_config( hass: HomeAssistant, provider_configs: List[Dict[str, Any]], module_configs: List[Dict[str, Any]], ) -> "AuthManager": """Initialize an auth manager from config. CORE_CONFIG_SCHEMA will make sure do duplicated auth providers or mfa modules exist in configs. ...
[ "async", "def", "auth_manager_from_config", "(", "hass", ":", "HomeAssistant", ",", "provider_configs", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", "module_configs", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", ...
[ 26, 0 ]
[ 64, 18 ]
python
en
['en', 'en', 'en']
True
AuthManagerFlowManager.__init__
(self, hass: HomeAssistant, auth_manager: "AuthManager")
Init auth manager flows.
Init auth manager flows.
def __init__(self, hass: HomeAssistant, auth_manager: "AuthManager"): """Init auth manager flows.""" super().__init__(hass) self.auth_manager = auth_manager
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "auth_manager", ":", "\"AuthManager\"", ")", ":", "super", "(", ")", ".", "__init__", "(", "hass", ")", "self", ".", "auth_manager", "=", "auth_manager" ]
[ 70, 4 ]
[ 73, 40 ]
python
en
['da', 'en', 'en']
True
AuthManagerFlowManager.async_create_flow
( self, handler_key: Any, *, context: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, )
Create a login flow.
Create a login flow.
async def async_create_flow( self, handler_key: Any, *, context: Optional[Dict[str, Any]] = None, data: Optional[Dict[str, Any]] = None, ) -> data_entry_flow.FlowHandler: """Create a login flow.""" auth_provider = self.auth_manager.get_auth_provider(*handler_k...
[ "async", "def", "async_create_flow", "(", "self", ",", "handler_key", ":", "Any", ",", "*", ",", "context", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", "data", ":", "Optional", "[", "Dict", "[", "str", ",", "An...
[ 75, 4 ]
[ 86, 60 ]
python
co
['es', 'co', 'en']
False
AuthManagerFlowManager.async_finish_flow
( self, flow: data_entry_flow.FlowHandler, result: Dict[str, Any] )
Return a user as result of login flow.
Return a user as result of login flow.
async def async_finish_flow( self, flow: data_entry_flow.FlowHandler, result: Dict[str, Any] ) -> Dict[str, Any]: """Return a user as result of login flow.""" flow = cast(LoginFlow, flow) if result["type"] != data_entry_flow.RESULT_TYPE_CREATE_ENTRY: return result ...
[ "async", "def", "async_finish_flow", "(", "self", ",", "flow", ":", "data_entry_flow", ".", "FlowHandler", ",", "result", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "flow", "=", "cast", "(", "LoginF...
[ 88, 4 ]
[ 127, 21 ]
python
en
['en', 'da', 'en']
True
AuthManager.__init__
( self, hass: HomeAssistant, store: auth_store.AuthStore, providers: _ProviderDict, mfa_modules: _MfaModuleDict, )
Initialize the auth manager.
Initialize the auth manager.
def __init__( self, hass: HomeAssistant, store: auth_store.AuthStore, providers: _ProviderDict, mfa_modules: _MfaModuleDict, ) -> None: """Initialize the auth manager.""" self.hass = hass self._store = store self._providers = providers ...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "store", ":", "auth_store", ".", "AuthStore", ",", "providers", ":", "_ProviderDict", ",", "mfa_modules", ":", "_MfaModuleDict", ",", ")", "->", "None", ":", "self", ".", "hass", "=", ...
[ 133, 4 ]
[ 145, 60 ]
python
en
['en', 'en', 'en']
True
AuthManager.auth_providers
(self)
Return a list of available auth providers.
Return a list of available auth providers.
def auth_providers(self) -> List[AuthProvider]: """Return a list of available auth providers.""" return list(self._providers.values())
[ "def", "auth_providers", "(", "self", ")", "->", "List", "[", "AuthProvider", "]", ":", "return", "list", "(", "self", ".", "_providers", ".", "values", "(", ")", ")" ]
[ 148, 4 ]
[ 150, 45 ]
python
en
['en', 'en', 'en']
True
AuthManager.auth_mfa_modules
(self)
Return a list of available auth modules.
Return a list of available auth modules.
def auth_mfa_modules(self) -> List[MultiFactorAuthModule]: """Return a list of available auth modules.""" return list(self._mfa_modules.values())
[ "def", "auth_mfa_modules", "(", "self", ")", "->", "List", "[", "MultiFactorAuthModule", "]", ":", "return", "list", "(", "self", ".", "_mfa_modules", ".", "values", "(", ")", ")" ]
[ 153, 4 ]
[ 155, 47 ]
python
en
['en', 'en', 'en']
True
AuthManager.get_auth_provider
( self, provider_type: str, provider_id: str )
Return an auth provider, None if not found.
Return an auth provider, None if not found.
def get_auth_provider( self, provider_type: str, provider_id: str ) -> Optional[AuthProvider]: """Return an auth provider, None if not found.""" return self._providers.get((provider_type, provider_id))
[ "def", "get_auth_provider", "(", "self", ",", "provider_type", ":", "str", ",", "provider_id", ":", "str", ")", "->", "Optional", "[", "AuthProvider", "]", ":", "return", "self", ".", "_providers", ".", "get", "(", "(", "provider_type", ",", "provider_id", ...
[ 157, 4 ]
[ 161, 64 ]
python
en
['en', 'en', 'en']
True
AuthManager.get_auth_providers
(self, provider_type: str)
Return a List of auth provider of one type, Empty if not found.
Return a List of auth provider of one type, Empty if not found.
def get_auth_providers(self, provider_type: str) -> List[AuthProvider]: """Return a List of auth provider of one type, Empty if not found.""" return [ provider for (p_type, _), provider in self._providers.items() if p_type == provider_type ]
[ "def", "get_auth_providers", "(", "self", ",", "provider_type", ":", "str", ")", "->", "List", "[", "AuthProvider", "]", ":", "return", "[", "provider", "for", "(", "p_type", ",", "_", ")", ",", "provider", "in", "self", ".", "_providers", ".", "items", ...
[ 163, 4 ]
[ 169, 9 ]
python
en
['en', 'en', 'en']
True
AuthManager.get_auth_mfa_module
(self, module_id: str)
Return a multi-factor auth module, None if not found.
Return a multi-factor auth module, None if not found.
def get_auth_mfa_module(self, module_id: str) -> Optional[MultiFactorAuthModule]: """Return a multi-factor auth module, None if not found.""" return self._mfa_modules.get(module_id)
[ "def", "get_auth_mfa_module", "(", "self", ",", "module_id", ":", "str", ")", "->", "Optional", "[", "MultiFactorAuthModule", "]", ":", "return", "self", ".", "_mfa_modules", ".", "get", "(", "module_id", ")" ]
[ 171, 4 ]
[ 173, 47 ]
python
en
['en', 'co', 'en']
True
AuthManager.async_get_users
(self)
Retrieve all users.
Retrieve all users.
async def async_get_users(self) -> List[models.User]: """Retrieve all users.""" return await self._store.async_get_users()
[ "async", "def", "async_get_users", "(", "self", ")", "->", "List", "[", "models", ".", "User", "]", ":", "return", "await", "self", ".", "_store", ".", "async_get_users", "(", ")" ]
[ 175, 4 ]
[ 177, 50 ]
python
en
['en', 'sk', 'en']
True
AuthManager.async_get_user
(self, user_id: str)
Retrieve a user.
Retrieve a user.
async def async_get_user(self, user_id: str) -> Optional[models.User]: """Retrieve a user.""" return await self._store.async_get_user(user_id)
[ "async", "def", "async_get_user", "(", "self", ",", "user_id", ":", "str", ")", "->", "Optional", "[", "models", ".", "User", "]", ":", "return", "await", "self", ".", "_store", ".", "async_get_user", "(", "user_id", ")" ]
[ 179, 4 ]
[ 181, 56 ]
python
en
['es', 'pt', 'en']
False
AuthManager.async_get_owner
(self)
Retrieve the owner.
Retrieve the owner.
async def async_get_owner(self) -> Optional[models.User]: """Retrieve the owner.""" users = await self.async_get_users() return next((user for user in users if user.is_owner), None)
[ "async", "def", "async_get_owner", "(", "self", ")", "->", "Optional", "[", "models", ".", "User", "]", ":", "users", "=", "await", "self", ".", "async_get_users", "(", ")", "return", "next", "(", "(", "user", "for", "user", "in", "users", "if", "user"...
[ 183, 4 ]
[ 186, 68 ]
python
en
['en', 'be', 'en']
True
AuthManager.async_get_group
(self, group_id: str)
Retrieve all groups.
Retrieve all groups.
async def async_get_group(self, group_id: str) -> Optional[models.Group]: """Retrieve all groups.""" return await self._store.async_get_group(group_id)
[ "async", "def", "async_get_group", "(", "self", ",", "group_id", ":", "str", ")", "->", "Optional", "[", "models", ".", "Group", "]", ":", "return", "await", "self", ".", "_store", ".", "async_get_group", "(", "group_id", ")" ]
[ 188, 4 ]
[ 190, 58 ]
python
en
['en', 'ga', 'en']
True
AuthManager.async_get_user_by_credentials
( self, credentials: models.Credentials )
Get a user by credential, return None if not found.
Get a user by credential, return None if not found.
async def async_get_user_by_credentials( self, credentials: models.Credentials ) -> Optional[models.User]: """Get a user by credential, return None if not found.""" for user in await self.async_get_users(): for creds in user.credentials: if creds.id == credentials...
[ "async", "def", "async_get_user_by_credentials", "(", "self", ",", "credentials", ":", "models", ".", "Credentials", ")", "->", "Optional", "[", "models", ".", "User", "]", ":", "for", "user", "in", "await", "self", ".", "async_get_users", "(", ")", ":", "...
[ 192, 4 ]
[ 201, 19 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_create_system_user
( self, name: str, group_ids: Optional[List[str]] = None )
Create a system user.
Create a system user.
async def async_create_system_user( self, name: str, group_ids: Optional[List[str]] = None ) -> models.User: """Create a system user.""" user = await self._store.async_create_user( name=name, system_generated=True, is_active=True, group_ids=group_ids or [] ) self...
[ "async", "def", "async_create_system_user", "(", "self", ",", "name", ":", "str", ",", "group_ids", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ")", "->", "models", ".", "User", ":", "user", "=", "await", "self", ".", "_store", "...
[ 203, 4 ]
[ 213, 19 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_create_user
( self, name: str, group_ids: Optional[List[str]] = None )
Create a user.
Create a user.
async def async_create_user( self, name: str, group_ids: Optional[List[str]] = None ) -> models.User: """Create a user.""" kwargs: Dict[str, Any] = { "name": name, "is_active": True, "group_ids": group_ids or [], } if await self._user_shou...
[ "async", "def", "async_create_user", "(", "self", ",", "name", ":", "str", ",", "group_ids", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ")", "->", "models", ".", "User", ":", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]",...
[ 215, 4 ]
[ 232, 19 ]
python
co
['es', 'co', 'en']
False
AuthManager.async_get_or_create_user
( self, credentials: models.Credentials )
Get or create a user.
Get or create a user.
async def async_get_or_create_user( self, credentials: models.Credentials ) -> models.User: """Get or create a user.""" if not credentials.is_new: user = await self.async_get_user_by_credentials(credentials) if user is None: raise ValueError("Unable to...
[ "async", "def", "async_get_or_create_user", "(", "self", ",", "credentials", ":", "models", ".", "Credentials", ")", "->", "models", ".", "User", ":", "if", "not", "credentials", ".", "is_new", ":", "user", "=", "await", "self", ".", "async_get_user_by_credent...
[ 234, 4 ]
[ 260, 19 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_link_user
( self, user: models.User, credentials: models.Credentials )
Link credentials to an existing user.
Link credentials to an existing user.
async def async_link_user( self, user: models.User, credentials: models.Credentials ) -> None: """Link credentials to an existing user.""" await self._store.async_link_user(user, credentials)
[ "async", "def", "async_link_user", "(", "self", ",", "user", ":", "models", ".", "User", ",", "credentials", ":", "models", ".", "Credentials", ")", "->", "None", ":", "await", "self", ".", "_store", ".", "async_link_user", "(", "user", ",", "credentials",...
[ 262, 4 ]
[ 266, 60 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_remove_user
(self, user: models.User)
Remove a user.
Remove a user.
async def async_remove_user(self, user: models.User) -> None: """Remove a user.""" tasks = [ self.async_remove_credentials(credentials) for credentials in user.credentials ] if tasks: await asyncio.wait(tasks) await self._store.async_remove_u...
[ "async", "def", "async_remove_user", "(", "self", ",", "user", ":", "models", ".", "User", ")", "->", "None", ":", "tasks", "=", "[", "self", ".", "async_remove_credentials", "(", "credentials", ")", "for", "credentials", "in", "user", ".", "credentials", ...
[ 268, 4 ]
[ 280, 74 ]
python
en
['es', 'it', 'en']
False
AuthManager.async_update_user
( self, user: models.User, name: Optional[str] = None, group_ids: Optional[List[str]] = None, )
Update a user.
Update a user.
async def async_update_user( self, user: models.User, name: Optional[str] = None, group_ids: Optional[List[str]] = None, ) -> None: """Update a user.""" kwargs: Dict[str, Any] = {} if name is not None: kwargs["name"] = name if group_ids is ...
[ "async", "def", "async_update_user", "(", "self", ",", "user", ":", "models", ".", "User", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ",", "group_ids", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", ")", "->"...
[ 282, 4 ]
[ 294, 59 ]
python
co
['es', 'co', 'en']
False
AuthManager.async_activate_user
(self, user: models.User)
Activate a user.
Activate a user.
async def async_activate_user(self, user: models.User) -> None: """Activate a user.""" await self._store.async_activate_user(user)
[ "async", "def", "async_activate_user", "(", "self", ",", "user", ":", "models", ".", "User", ")", "->", "None", ":", "await", "self", ".", "_store", ".", "async_activate_user", "(", "user", ")" ]
[ 296, 4 ]
[ 298, 51 ]
python
en
['es', 'en', 'en']
True
AuthManager.async_deactivate_user
(self, user: models.User)
Deactivate a user.
Deactivate a user.
async def async_deactivate_user(self, user: models.User) -> None: """Deactivate a user.""" if user.is_owner: raise ValueError("Unable to deactivate the owner") await self._store.async_deactivate_user(user)
[ "async", "def", "async_deactivate_user", "(", "self", ",", "user", ":", "models", ".", "User", ")", "->", "None", ":", "if", "user", ".", "is_owner", ":", "raise", "ValueError", "(", "\"Unable to deactivate the owner\"", ")", "await", "self", ".", "_store", ...
[ 300, 4 ]
[ 304, 53 ]
python
es
['es', 'gl', 'pt']
False
AuthManager.async_remove_credentials
(self, credentials: models.Credentials)
Remove credentials.
Remove credentials.
async def async_remove_credentials(self, credentials: models.Credentials) -> None: """Remove credentials.""" provider = self._async_get_auth_provider(credentials) if provider is not None and hasattr(provider, "async_will_remove_credentials"): # https://github.com/python/mypy/issues/...
[ "async", "def", "async_remove_credentials", "(", "self", ",", "credentials", ":", "models", ".", "Credentials", ")", "->", "None", ":", "provider", "=", "self", ".", "_async_get_auth_provider", "(", "credentials", ")", "if", "provider", "is", "not", "None", "a...
[ 306, 4 ]
[ 314, 63 ]
python
en
['en', 'it', 'en']
False
AuthManager.async_enable_user_mfa
( self, user: models.User, mfa_module_id: str, data: Any )
Enable a multi-factor auth module for user.
Enable a multi-factor auth module for user.
async def async_enable_user_mfa( self, user: models.User, mfa_module_id: str, data: Any ) -> None: """Enable a multi-factor auth module for user.""" if user.system_generated: raise ValueError( "System generated users cannot enable multi-factor auth module." ...
[ "async", "def", "async_enable_user_mfa", "(", "self", ",", "user", ":", "models", ".", "User", ",", "mfa_module_id", ":", "str", ",", "data", ":", "Any", ")", "->", "None", ":", "if", "user", ".", "system_generated", ":", "raise", "ValueError", "(", "\"S...
[ 316, 4 ]
[ 329, 52 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_disable_user_mfa
( self, user: models.User, mfa_module_id: str )
Disable a multi-factor auth module for user.
Disable a multi-factor auth module for user.
async def async_disable_user_mfa( self, user: models.User, mfa_module_id: str ) -> None: """Disable a multi-factor auth module for user.""" if user.system_generated: raise ValueError( "System generated users cannot disable multi-factor auth module." ) ...
[ "async", "def", "async_disable_user_mfa", "(", "self", ",", "user", ":", "models", ".", "User", ",", "mfa_module_id", ":", "str", ")", "->", "None", ":", "if", "user", ".", "system_generated", ":", "raise", "ValueError", "(", "\"System generated users cannot dis...
[ 331, 4 ]
[ 344, 47 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_get_enabled_mfa
(self, user: models.User)
List enabled mfa modules for user.
List enabled mfa modules for user.
async def async_get_enabled_mfa(self, user: models.User) -> Dict[str, str]: """List enabled mfa modules for user.""" modules: Dict[str, str] = OrderedDict() for module_id, module in self._mfa_modules.items(): if await module.async_is_user_setup(user.id): modules[modul...
[ "async", "def", "async_get_enabled_mfa", "(", "self", ",", "user", ":", "models", ".", "User", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "modules", ":", "Dict", "[", "str", ",", "str", "]", "=", "OrderedDict", "(", ")", "for", "module_id",...
[ 346, 4 ]
[ 352, 22 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_create_refresh_token
( self, user: models.User, client_id: Optional[str] = None, client_name: Optional[str] = None, client_icon: Optional[str] = None, token_type: Optional[str] = None, access_token_expiration: timedelta = ACCESS_TOKEN_EXPIRATION, )
Create a new refresh token for a user.
Create a new refresh token for a user.
async def async_create_refresh_token( self, user: models.User, client_id: Optional[str] = None, client_name: Optional[str] = None, client_icon: Optional[str] = None, token_type: Optional[str] = None, access_token_expiration: timedelta = ACCESS_TOKEN_EXPIRATION, ...
[ "async", "def", "async_create_refresh_token", "(", "self", ",", "user", ":", "models", ".", "User", ",", "client_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "client_name", ":", "Optional", "[", "str", "]", "=", "None", ",", "client_icon", ":...
[ 354, 4 ]
[ 410, 9 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_get_refresh_token
( self, token_id: str )
Get refresh token by id.
Get refresh token by id.
async def async_get_refresh_token( self, token_id: str ) -> Optional[models.RefreshToken]: """Get refresh token by id.""" return await self._store.async_get_refresh_token(token_id)
[ "async", "def", "async_get_refresh_token", "(", "self", ",", "token_id", ":", "str", ")", "->", "Optional", "[", "models", ".", "RefreshToken", "]", ":", "return", "await", "self", ".", "_store", ".", "async_get_refresh_token", "(", "token_id", ")" ]
[ 412, 4 ]
[ 416, 66 ]
python
en
['en', 'en', 'en']
True
AuthManager.async_get_refresh_token_by_token
( self, token: str )
Get refresh token by token.
Get refresh token by token.
async def async_get_refresh_token_by_token( self, token: str ) -> Optional[models.RefreshToken]: """Get refresh token by token.""" return await self._store.async_get_refresh_token_by_token(token)
[ "async", "def", "async_get_refresh_token_by_token", "(", "self", ",", "token", ":", "str", ")", "->", "Optional", "[", "models", ".", "RefreshToken", "]", ":", "return", "await", "self", ".", "_store", ".", "async_get_refresh_token_by_token", "(", "token", ")" ]
[ 418, 4 ]
[ 422, 72 ]
python
en
['en', 'nl', 'en']
True
AuthManager.async_remove_refresh_token
( self, refresh_token: models.RefreshToken )
Delete a refresh token.
Delete a refresh token.
async def async_remove_refresh_token( self, refresh_token: models.RefreshToken ) -> None: """Delete a refresh token.""" await self._store.async_remove_refresh_token(refresh_token)
[ "async", "def", "async_remove_refresh_token", "(", "self", ",", "refresh_token", ":", "models", ".", "RefreshToken", ")", "->", "None", ":", "await", "self", ".", "_store", ".", "async_remove_refresh_token", "(", "refresh_token", ")" ]
[ 424, 4 ]
[ 428, 67 ]
python
en
['en', 'gl', 'en']
True
AuthManager.async_create_access_token
( self, refresh_token: models.RefreshToken, remote_ip: Optional[str] = None )
Create a new access token.
Create a new access token.
def async_create_access_token( self, refresh_token: models.RefreshToken, remote_ip: Optional[str] = None ) -> str: """Create a new access token.""" self._store.async_log_refresh_token_usage(refresh_token, remote_ip) now = dt_util.utcnow() return jwt.encode( { ...
[ "def", "async_create_access_token", "(", "self", ",", "refresh_token", ":", "models", ".", "RefreshToken", ",", "remote_ip", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "self", ".", "_store", ".", "async_log_refresh_token_usage", "(",...
[ 431, 4 ]
[ 446, 18 ]
python
en
['en', 'gl', 'en']
True
AuthManager.async_validate_access_token
( self, token: str )
Return refresh token if an access token is valid.
Return refresh token if an access token is valid.
async def async_validate_access_token( self, token: str ) -> Optional[models.RefreshToken]: """Return refresh token if an access token is valid.""" try: unverif_claims = jwt.decode(token, verify=False) except jwt.InvalidTokenError: return None refresh...
[ "async", "def", "async_validate_access_token", "(", "self", ",", "token", ":", "str", ")", "->", "Optional", "[", "models", ".", "RefreshToken", "]", ":", "try", ":", "unverif_claims", "=", "jwt", ".", "decode", "(", "token", ",", "verify", "=", "False", ...
[ 448, 4 ]
[ 476, 28 ]
python
en
['en', 'lb', 'en']
True
AuthManager._async_get_auth_provider
( self, credentials: models.Credentials )
Get auth provider from a set of credentials.
Get auth provider from a set of credentials.
def _async_get_auth_provider( self, credentials: models.Credentials ) -> Optional[AuthProvider]: """Get auth provider from a set of credentials.""" auth_provider_key = ( credentials.auth_provider_type, credentials.auth_provider_id, ) return self._provi...
[ "def", "_async_get_auth_provider", "(", "self", ",", "credentials", ":", "models", ".", "Credentials", ")", "->", "Optional", "[", "AuthProvider", "]", ":", "auth_provider_key", "=", "(", "credentials", ".", "auth_provider_type", ",", "credentials", ".", "auth_pro...
[ 479, 4 ]
[ 487, 53 ]
python
en
['en', 'en', 'en']
True
AuthManager._user_should_be_owner
(self)
Determine if user should be owner. A user should be an owner if it is the first non-system user that is being created.
Determine if user should be owner.
async def _user_should_be_owner(self) -> bool: """Determine if user should be owner. A user should be an owner if it is the first non-system user that is being created. """ for user in await self._store.async_get_users(): if not user.system_generated: ...
[ "async", "def", "_user_should_be_owner", "(", "self", ")", "->", "bool", ":", "for", "user", "in", "await", "self", ".", "_store", ".", "async_get_users", "(", ")", ":", "if", "not", "user", ".", "system_generated", ":", "return", "False", "return", "True"...
[ 489, 4 ]
[ 499, 19 ]
python
en
['en', 'en', 'en']
True
dsmr_connection_fixture
(hass)
Fixture that mocks serial connection.
Fixture that mocks serial connection.
async def dsmr_connection_fixture(hass): """Fixture that mocks serial connection.""" transport = MagicMock(spec=asyncio.Transport) protocol = MagicMock(spec=DSMRProtocol) async def connection_factory(*args, **kwargs): """Return mocked out Asyncio classes.""" return (transport, protocol...
[ "async", "def", "dsmr_connection_fixture", "(", "hass", ")", ":", "transport", "=", "MagicMock", "(", "spec", "=", "asyncio", ".", "Transport", ")", "protocol", "=", "MagicMock", "(", "spec", "=", "DSMRProtocol", ")", "async", "def", "connection_factory", "(",...
[ 12, 0 ]
[ 30, 55 ]
python
en
['en', 'en', 'en']
True
dsmr_connection_send_validate_fixture
(hass)
Fixture that mocks serial connection.
Fixture that mocks serial connection.
async def dsmr_connection_send_validate_fixture(hass): """Fixture that mocks serial connection.""" transport = MagicMock(spec=asyncio.Transport) protocol = MagicMock(spec=DSMRProtocol) async def connection_factory(*args, **kwargs): """Return mocked out Asyncio classes.""" return (trans...
[ "async", "def", "dsmr_connection_send_validate_fixture", "(", "hass", ")", ":", "transport", "=", "MagicMock", "(", "spec", "=", "asyncio", ".", "Transport", ")", "protocol", "=", "MagicMock", "(", "spec", "=", "DSMRProtocol", ")", "async", "def", "connection_fa...
[ 34, 0 ]
[ 70, 55 ]
python
en
['en', 'en', 'en']
True
load_tf_weights_in_lxmert
(model, config, tf_checkpoint_path)
Load tf checkpoints in a pytorch model.
Load tf checkpoints in a pytorch model.
def load_tf_weights_in_lxmert(model, config, tf_checkpoint_path): """Load tf checkpoints in a pytorch model.""" try: import re import numpy as np import tensorflow as tf except ImportError: logger.error( "Loading a TensorFlow model in PyTorch, requires TensorFlow...
[ "def", "load_tf_weights_in_lxmert", "(", "model", ",", "config", ",", "tf_checkpoint_path", ")", ":", "try", ":", "import", "re", "import", "numpy", "as", "np", "import", "tensorflow", "as", "tf", "except", "ImportError", ":", "logger", ".", "error", "(", "\...
[ 193, 0 ]
[ 269, 16 ]
python
en
['en', 'en', 'en']
True