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
MinecraftServerLatencyTimeSensor.__init__
(self, server: MinecraftServer)
Initialize latency time sensor.
Initialize latency time sensor.
def __init__(self, server: MinecraftServer) -> None: """Initialize latency time sensor.""" super().__init__( server=server, type_name=NAME_LATENCY_TIME, icon=ICON_LATENCY_TIME, unit=TIME_MILLISECONDS, )
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "server", "=", "server", ",", "type_name", "=", "NAME_LATENCY_TIME", ",", "icon", "=", "ICON_LATENCY_TIME", ",", "unit",...
[ 113, 4 ]
[ 120, 9 ]
python
en
['en', 'en', 'en']
True
MinecraftServerLatencyTimeSensor.async_update
(self)
Update latency time.
Update latency time.
async def async_update(self) -> None: """Update latency time.""" self._state = self._server.latency_time
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "_server", ".", "latency_time" ]
[ 122, 4 ]
[ 124, 47 ]
python
en
['es', 'en', 'en']
True
MinecraftServerPlayersOnlineSensor.__init__
(self, server: MinecraftServer)
Initialize online players sensor.
Initialize online players sensor.
def __init__(self, server: MinecraftServer) -> None: """Initialize online players sensor.""" super().__init__( server=server, type_name=NAME_PLAYERS_ONLINE, icon=ICON_PLAYERS_ONLINE, unit=UNIT_PLAYERS_ONLINE, )
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "server", "=", "server", ",", "type_name", "=", "NAME_PLAYERS_ONLINE", ",", "icon", "=", "ICON_PLAYERS_ONLINE", ",", "un...
[ 130, 4 ]
[ 137, 9 ]
python
en
['en', 'en', 'en']
True
MinecraftServerPlayersOnlineSensor.async_update
(self)
Update online players state and device state attributes.
Update online players state and device state attributes.
async def async_update(self) -> None: """Update online players state and device state attributes.""" self._state = self._server.players_online device_state_attributes = None players_list = self._server.players_list if players_list is not None: if len(players_list) !...
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "_server", ".", "players_online", "device_state_attributes", "=", "None", "players_list", "=", "self", ".", "_server", ".", "players_list", "if", "p...
[ 139, 4 ]
[ 150, 63 ]
python
en
['en', 'en', 'en']
True
MinecraftServerPlayersOnlineSensor.device_state_attributes
(self)
Return players list in device state attributes.
Return players list in device state attributes.
def device_state_attributes(self) -> Dict[str, Any]: """Return players list in device state attributes.""" return self._device_state_attributes
[ "def", "device_state_attributes", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_device_state_attributes" ]
[ 153, 4 ]
[ 155, 44 ]
python
en
['nl', 'en', 'en']
True
MinecraftServerPlayersMaxSensor.__init__
(self, server: MinecraftServer)
Initialize maximum number of players sensor.
Initialize maximum number of players sensor.
def __init__(self, server: MinecraftServer) -> None: """Initialize maximum number of players sensor.""" super().__init__( server=server, type_name=NAME_PLAYERS_MAX, icon=ICON_PLAYERS_MAX, unit=UNIT_PLAYERS_MAX, )
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "server", "=", "server", ",", "type_name", "=", "NAME_PLAYERS_MAX", ",", "icon", "=", "ICON_PLAYERS_MAX", ",", "unit", ...
[ 161, 4 ]
[ 168, 9 ]
python
en
['en', 'en', 'en']
True
MinecraftServerPlayersMaxSensor.async_update
(self)
Update maximum number of players.
Update maximum number of players.
async def async_update(self) -> None: """Update maximum number of players.""" self._state = self._server.players_max
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "_server", ".", "players_max" ]
[ 170, 4 ]
[ 172, 46 ]
python
en
['en', 'en', 'en']
True
int_range
(rng)
Validate the input array to describe a range by two integers.
Validate the input array to describe a range by two integers.
def int_range(rng): """Validate the input array to describe a range by two integers.""" if not (isinstance(rng[0], int) and isinstance(rng[1], int)): raise vol.Invalid(f"Only integers are allowed: {rng}") if len(rng) != 2: raise vol.Invalid(f"Only two numbers allowed in a range: {rng}") ...
[ "def", "int_range", "(", "rng", ")", ":", "if", "not", "(", "isinstance", "(", "rng", "[", "0", "]", ",", "int", ")", "and", "isinstance", "(", "rng", "[", "1", "]", ",", "int", ")", ")", ":", "raise", "vol", ".", "Invalid", "(", "f\"Only integer...
[ 42, 0 ]
[ 50, 14 ]
python
en
['en', 'en', 'en']
True
float_range
(rng)
Validate the input array to describe a range by two floats.
Validate the input array to describe a range by two floats.
def float_range(rng): """Validate the input array to describe a range by two floats.""" try: coe = vol.Coerce(float) coe(rng[0]) coe(rng[1]) except vol.CoerceInvalid as err: raise vol.Invalid(f"Only int or float values are allowed: {rng}") from err if len(rng) != 2: ...
[ "def", "float_range", "(", "rng", ")", ":", "try", ":", "coe", "=", "vol", ".", "Coerce", "(", "float", ")", "coe", "(", "rng", "[", "0", "]", ")", "coe", "(", "rng", "[", "1", "]", ")", "except", "vol", ".", "CoerceInvalid", "as", "err", ":", ...
[ 53, 0 ]
[ 65, 14 ]
python
en
['en', 'en', 'en']
True
adc_port_number
(num)
Validate input number to be in the range of ADC enabled ports.
Validate input number to be in the range of ADC enabled ports.
def adc_port_number(num): """Validate input number to be in the range of ADC enabled ports.""" try: num = int(num) except ValueError as err: raise vol.Invalid(f"Port numbers must be integers: {num}") from err if num not in range(1, 8): raise vol.Invalid(f"Only port numbers from 1...
[ "def", "adc_port_number", "(", "num", ")", ":", "try", ":", "num", "=", "int", "(", "num", ")", "except", "ValueError", "as", "err", ":", "raise", "vol", ".", "Invalid", "(", "f\"Port numbers must be integers: {num}\"", ")", "from", "err", "if", "num", "no...
[ 68, 0 ]
[ 76, 14 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Initialize the numato integration. Discovers available Numato devices and loads the binary_sensor, sensor and switch platforms. Returns False on error during device discovery (e.g. duplicate ID), otherwise returns True. No exceptions should occur, since the platforms are initialized on a best ...
Initialize the numato integration.
def setup(hass, config): """Initialize the numato integration. Discovers available Numato devices and loads the binary_sensor, sensor and switch platforms. Returns False on error during device discovery (e.g. duplicate ID), otherwise returns True. No exceptions should occur, since the platfor...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "config", "[", "DOMAIN", "]", "try", ":", "gpio", ".", "discover", "(", "config", "[", "DOMAIN", "]", "[", "CONF_DISCOVER", "]", ")", "except", "gpi...
[ 119, 0 ]
[ 164, 15 ]
python
en
['en', 'zu', 'pt']
False
NumatoAPI.__init__
(self)
Initialize API state.
Initialize API state.
def __init__(self): """Initialize API state.""" self.ports_registered = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "ports_registered", "=", "{", "}" ]
[ 171, 4 ]
[ 173, 34 ]
python
en
['en', 'co', 'en']
True
NumatoAPI.check_port_free
(self, device_id, port, direction)
Check whether a port is still free set up. Fail with exception if it has already been registered.
Check whether a port is still free set up.
def check_port_free(self, device_id, port, direction): """Check whether a port is still free set up. Fail with exception if it has already been registered. """ if (device_id, port) not in self.ports_registered: self.ports_registered[(device_id, port)] = direction els...
[ "def", "check_port_free", "(", "self", ",", "device_id", ",", "port", ",", "direction", ")", ":", "if", "(", "device_id", ",", "port", ")", "not", "in", "self", ".", "ports_registered", ":", "self", ".", "ports_registered", "[", "(", "device_id", ",", "p...
[ 175, 4 ]
[ 191, 13 ]
python
en
['en', 'en', 'en']
True
NumatoAPI.check_device_id
(self, device_id)
Check whether a device has been discovered. Fail with exception.
Check whether a device has been discovered.
def check_device_id(self, device_id): """Check whether a device has been discovered. Fail with exception. """ if device_id not in gpio.devices: raise gpio.NumatoGpioError(f"Device {device_id} not available.")
[ "def", "check_device_id", "(", "self", ",", "device_id", ")", ":", "if", "device_id", "not", "in", "gpio", ".", "devices", ":", "raise", "gpio", ".", "NumatoGpioError", "(", "f\"Device {device_id} not available.\"", ")" ]
[ 193, 4 ]
[ 199, 76 ]
python
en
['en', 'en', 'en']
True
NumatoAPI.check_port
(self, device_id, port, direction)
Raise an error if the port setup doesn't match the direction.
Raise an error if the port setup doesn't match the direction.
def check_port(self, device_id, port, direction): """Raise an error if the port setup doesn't match the direction.""" self.check_device_id(device_id) if (device_id, port) not in self.ports_registered: raise gpio.NumatoGpioError( f"Port {port} is not set up for numato ...
[ "def", "check_port", "(", "self", ",", "device_id", ",", "port", ",", "direction", ")", ":", "self", ".", "check_device_id", "(", "device_id", ")", "if", "(", "device_id", ",", "port", ")", "not", "in", "self", ".", "ports_registered", ":", "raise", "gpi...
[ 201, 4 ]
[ 213, 54 ]
python
en
['en', 'en', 'en']
True
NumatoAPI.setup_output
(self, device_id, port)
Set up a GPIO as output.
Set up a GPIO as output.
def setup_output(self, device_id, port): """Set up a GPIO as output.""" self.check_device_id(device_id) self.check_port_free(device_id, port, gpio.OUT) gpio.devices[device_id].setup(port, gpio.OUT)
[ "def", "setup_output", "(", "self", ",", "device_id", ",", "port", ")", ":", "self", ".", "check_device_id", "(", "device_id", ")", "self", ".", "check_port_free", "(", "device_id", ",", "port", ",", "gpio", ".", "OUT", ")", "gpio", ".", "devices", "[", ...
[ 215, 4 ]
[ 219, 53 ]
python
en
['en', 'el-Latn', 'en']
True
NumatoAPI.setup_input
(self, device_id, port)
Set up a GPIO as input.
Set up a GPIO as input.
def setup_input(self, device_id, port): """Set up a GPIO as input.""" self.check_device_id(device_id) gpio.devices[device_id].setup(port, gpio.IN) self.check_port_free(device_id, port, gpio.IN)
[ "def", "setup_input", "(", "self", ",", "device_id", ",", "port", ")", ":", "self", ".", "check_device_id", "(", "device_id", ")", "gpio", ".", "devices", "[", "device_id", "]", ".", "setup", "(", "port", ",", "gpio", ".", "IN", ")", "self", ".", "ch...
[ 221, 4 ]
[ 225, 54 ]
python
en
['en', 'haw', 'en']
True
NumatoAPI.write_output
(self, device_id, port, value)
Write a value to a GPIO.
Write a value to a GPIO.
def write_output(self, device_id, port, value): """Write a value to a GPIO.""" self.check_port(device_id, port, gpio.OUT) gpio.devices[device_id].write(port, value)
[ "def", "write_output", "(", "self", ",", "device_id", ",", "port", ",", "value", ")", ":", "self", ".", "check_port", "(", "device_id", ",", "port", ",", "gpio", ".", "OUT", ")", "gpio", ".", "devices", "[", "device_id", "]", ".", "write", "(", "port...
[ 227, 4 ]
[ 230, 50 ]
python
en
['en', 'pt', 'en']
True
NumatoAPI.read_input
(self, device_id, port)
Read a value from a GPIO.
Read a value from a GPIO.
def read_input(self, device_id, port): """Read a value from a GPIO.""" self.check_port(device_id, port, gpio.IN) return gpio.devices[device_id].read(port)
[ "def", "read_input", "(", "self", ",", "device_id", ",", "port", ")", ":", "self", ".", "check_port", "(", "device_id", ",", "port", ",", "gpio", ".", "IN", ")", "return", "gpio", ".", "devices", "[", "device_id", "]", ".", "read", "(", "port", ")" ]
[ 232, 4 ]
[ 235, 49 ]
python
en
['en', 'en', 'en']
True
NumatoAPI.read_adc_input
(self, device_id, port)
Read an ADC value from a GPIO ADC port.
Read an ADC value from a GPIO ADC port.
def read_adc_input(self, device_id, port): """Read an ADC value from a GPIO ADC port.""" self.check_port(device_id, port, gpio.IN) self.check_device_id(device_id) return gpio.devices[device_id].adc_read(port)
[ "def", "read_adc_input", "(", "self", ",", "device_id", ",", "port", ")", ":", "self", ".", "check_port", "(", "device_id", ",", "port", ",", "gpio", ".", "IN", ")", "self", ".", "check_device_id", "(", "device_id", ")", "return", "gpio", ".", "devices",...
[ 237, 4 ]
[ 241, 53 ]
python
en
['en', 'en', 'en']
True
NumatoAPI.edge_detect
(self, device_id, port, event_callback)
Add detection for RISING and FALLING events.
Add detection for RISING and FALLING events.
def edge_detect(self, device_id, port, event_callback): """Add detection for RISING and FALLING events.""" self.check_port(device_id, port, gpio.IN) gpio.devices[device_id].add_event_detect(port, event_callback, gpio.BOTH) gpio.devices[device_id].notify = True
[ "def", "edge_detect", "(", "self", ",", "device_id", ",", "port", ",", "event_callback", ")", ":", "self", ".", "check_port", "(", "device_id", ",", "port", ",", "gpio", ".", "IN", ")", "gpio", ".", "devices", "[", "device_id", "]", ".", "add_event_detec...
[ 243, 4 ]
[ 247, 45 ]
python
en
['en', 'en', 'en']
True
PFLDTrainer.__init__
( self, model, auxiliarynet, model_optim, criterion, device, device_ids, config, lookup_table, train_loader, valid_loader, n_epochs=300, load_ckpt=False, arch_path=None, logger=None, )
Parameters ---------- model : pytorch model the user model, which has mutables auxiliarynet : pytorch model the auxiliarynet to regress angle model_optim : pytorch optimizer the user defined optimizer criterion : pytorch loss ...
Parameters ---------- model : pytorch model the user model, which has mutables auxiliarynet : pytorch model the auxiliarynet to regress angle model_optim : pytorch optimizer the user defined optimizer criterion : pytorch loss ...
def __init__( self, model, auxiliarynet, model_optim, criterion, device, device_ids, config, lookup_table, train_loader, valid_loader, n_epochs=300, load_ckpt=False, arch_path=None, logger=None, )...
[ "def", "__init__", "(", "self", ",", "model", ",", "auxiliarynet", ",", "model_optim", ",", "criterion", ",", "device", ",", "device_ids", ",", "config", ",", "lookup_table", ",", "train_loader", ",", "valid_loader", ",", "n_epochs", "=", "300", ",", "load_c...
[ 17, 4 ]
[ 87, 36 ]
python
en
['en', 'error', 'th']
False
PFLDTrainer._validate
(self)
Do validation. During validation, LayerChoices use the mixed-op. Returns ------- float, float average loss, average nme
Do validation. During validation, LayerChoices use the mixed-op.
def _validate(self): """ Do validation. During validation, LayerChoices use the mixed-op. Returns ------- float, float average loss, average nme """ # test on validation set under eval mode self.model.eval() self.auxiliarynet.eval() ...
[ "def", "_validate", "(", "self", ")", ":", "# test on validation set under eval mode", "self", ".", "model", ".", "eval", "(", ")", "self", ".", "auxiliarynet", ".", "eval", "(", ")", "losses", ",", "nme", "=", "list", "(", ")", ",", "list", "(", ")", ...
[ 89, 4 ]
[ 139, 44 ]
python
en
['en', 'error', 'th']
False
PFLDTrainer._train_epoch
(self, epoch, optimizer, arch_train=False)
Train one epoch.
Train one epoch.
def _train_epoch(self, epoch, optimizer, arch_train=False): """ Train one epoch. """ # switch to train mode self.model.train() self.auxiliarynet.train() batch_time = AverageMeter("batch_time") data_time = AverageMeter("data_time") losses = Average...
[ "def", "_train_epoch", "(", "self", ",", "epoch", ",", "optimizer", ",", "arch_train", "=", "False", ")", ":", "# switch to train mode", "self", ".", "model", ".", "train", "(", ")", "self", ".", "auxiliarynet", ".", "train", "(", ")", "batch_time", "=", ...
[ 141, 4 ]
[ 202, 43 ]
python
en
['en', 'error', 'th']
False
PFLDTrainer._warm_up
(self)
Warm up the model, while the architecture weights are not trained.
Warm up the model, while the architecture weights are not trained.
def _warm_up(self): """ Warm up the model, while the architecture weights are not trained. """ for epoch in range(self.epoch, self.start_epoch): self.logger.info("\n--------Warmup epoch: %d--------\n", epoch + 1) self._train_epoch(epoch, self.model_optim) ...
[ "def", "_warm_up", "(", "self", ")", ":", "for", "epoch", "in", "range", "(", "self", ".", "epoch", ",", "self", ".", "start_epoch", ")", ":", "self", ".", "logger", ".", "info", "(", "\"\\n--------Warmup epoch: %d--------\\n\"", ",", "epoch", "+", "1", ...
[ 204, 4 ]
[ 220, 53 ]
python
en
['en', 'error', 'th']
False
PFLDTrainer._train
(self)
Train the model, it trains model weights and architecute weights. Architecture weights are trained according to the schedule. Before updating architecture weights, ```requires_grad``` is enabled. Then, it is disabled after the updating, in order not to update architecture weight...
Train the model, it trains model weights and architecute weights. Architecture weights are trained according to the schedule. Before updating architecture weights, ```requires_grad``` is enabled. Then, it is disabled after the updating, in order not to update architecture weight...
def _train(self): """ Train the model, it trains model weights and architecute weights. Architecture weights are trained according to the schedule. Before updating architecture weights, ```requires_grad``` is enabled. Then, it is disabled after the updating, in order not to updat...
[ "def", "_train", "(", "self", ")", ":", "arch_param_num", "=", "self", ".", "mutator", ".", "num_arch_params", "(", ")", "self", ".", "logger", ".", "info", "(", "\"#arch_params: {}\"", ".", "format", "(", "arch_param_num", ")", ")", "self", ".", "epoch", ...
[ 222, 4 ]
[ 267, 64 ]
python
en
['en', 'error', 'th']
False
PFLDTrainer.save_checkpoint
(self, epoch, filename, choice_names=None)
Save checkpoint of the whole model. Saving model weights and architecture weights as ```filename```, and saving currently chosen architecture in ```arch_path```.
Save checkpoint of the whole model. Saving model weights and architecture weights as ```filename```, and saving currently chosen architecture in ```arch_path```.
def save_checkpoint(self, epoch, filename, choice_names=None): """ Save checkpoint of the whole model. Saving model weights and architecture weights as ```filename```, and saving currently chosen architecture in ```arch_path```. """ state = { "pfld_backbone": ...
[ "def", "save_checkpoint", "(", "self", ",", "epoch", ",", "filename", ",", "choice_names", "=", "None", ")", ":", "state", "=", "{", "\"pfld_backbone\"", ":", "self", ".", "model", ".", "state_dict", "(", ")", ",", "\"auxiliarynet\"", ":", "self", ".", "...
[ 269, 4 ]
[ 286, 39 ]
python
en
['en', 'error', 'th']
False
PFLDTrainer.load_checkpoint
(self, filename)
Load the checkpoint from ```filename```.
Load the checkpoint from ```filename```.
def load_checkpoint(self, filename): """ Load the checkpoint from ```filename```. """ ckpt = torch.load(filename) self.epoch = ckpt["epoch"] self.model.load_state_dict(ckpt["pfld_backbone"]) self.auxiliarynet.load_state_dict(ckpt["auxiliarynet"]) self.mode...
[ "def", "load_checkpoint", "(", "self", ",", "filename", ")", ":", "ckpt", "=", "torch", ".", "load", "(", "filename", ")", "self", ".", "epoch", "=", "ckpt", "[", "\"epoch\"", "]", "self", ".", "model", ".", "load_state_dict", "(", "ckpt", "[", "\"pfld...
[ 288, 4 ]
[ 296, 55 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up locks for deCONZ component. Locks are based on the same device class as lights in deCONZ.
Set up locks for deCONZ component.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up locks for deCONZ component. Locks are based on the same device class as lights in deCONZ. """ gateway = get_gateway_from_config_entry(hass, config_entry) gateway.entities[DOMAIN] = set() @callback def async_add_...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "gateway", "=", "get_gateway_from_config_entry", "(", "hass", ",", "config_entry", ")", "gateway", ".", "entities", "[", "DOMAIN", "]", "=", "set", "(", ...
[ 10, 0 ]
[ 37, 47 ]
python
en
['da', 'en', 'en']
True
DeconzLock.is_locked
(self)
Return true if lock is on.
Return true if lock is on.
def is_locked(self): """Return true if lock is on.""" return self._device.state
[ "def", "is_locked", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "state" ]
[ 46, 4 ]
[ 48, 33 ]
python
en
['en', 'fy', 'en']
True
DeconzLock.async_lock
(self, **kwargs)
Lock the lock.
Lock the lock.
async def async_lock(self, **kwargs): """Lock the lock.""" data = {"on": True} await self._device.async_set_state(data)
[ "async", "def", "async_lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"on\"", ":", "True", "}", "await", "self", ".", "_device", ".", "async_set_state", "(", "data", ")" ]
[ 50, 4 ]
[ 53, 48 ]
python
en
['en', 'la', 'en']
True
DeconzLock.async_unlock
(self, **kwargs)
Unlock the lock.
Unlock the lock.
async def async_unlock(self, **kwargs): """Unlock the lock.""" data = {"on": False} await self._device.async_set_state(data)
[ "async", "def", "async_unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"on\"", ":", "False", "}", "await", "self", ".", "_device", ".", "async_set_state", "(", "data", ")" ]
[ 55, 4 ]
[ 58, 48 ]
python
en
['en', 'ms', 'en']
True
mocked_requests
(*args, **kwargs)
Mock requests.get invocations.
Mock requests.get invocations.
def mocked_requests(*args, **kwargs): """Mock requests.get invocations.""" class MockResponse: """Class to represent a mocked response.""" def __init__(self, json_data, status_code): """Initialize the mock response class.""" self.json_data = json_data self.s...
[ "def", "mocked_requests", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "class", "MockResponse", ":", "\"\"\"Class to represent a mocked response.\"\"\"", "def", "__init__", "(", "self", ",", "json_data", ",", "status_code", ")", ":", "\"\"\"Initialize the mo...
[ 22, 0 ]
[ 142, 34 ]
python
en
['en', 'nl', 'en']
True
test_config
(xiaomi_mock, hass)
Testing minimal configuration.
Testing minimal configuration.
async def test_config(xiaomi_mock, hass): """Testing minimal configuration.""" config = { DOMAIN: xiaomi.PLATFORM_SCHEMA( { CONF_PLATFORM: xiaomi.DOMAIN, CONF_HOST: "192.168.0.1", CONF_PASSWORD: "passwordTest", } ) } ...
[ "async", "def", "test_config", "(", "xiaomi_mock", ",", "hass", ")", ":", "config", "=", "{", "DOMAIN", ":", "xiaomi", ".", "PLATFORM_SCHEMA", "(", "{", "CONF_PLATFORM", ":", "xiaomi", ".", "DOMAIN", ",", "CONF_HOST", ":", "\"192.168.0.1\"", ",", "CONF_PASSW...
[ 149, 0 ]
[ 167, 51 ]
python
en
['en', 'ja', 'en']
True
test_config_full
(xiaomi_mock, hass)
Testing full configuration.
Testing full configuration.
async def test_config_full(xiaomi_mock, hass): """Testing full configuration.""" config = { DOMAIN: xiaomi.PLATFORM_SCHEMA( { CONF_PLATFORM: xiaomi.DOMAIN, CONF_HOST: "192.168.0.1", CONF_USERNAME: "alternativeAdminName", CONF_PA...
[ "async", "def", "test_config_full", "(", "xiaomi_mock", ",", "hass", ")", ":", "config", "=", "{", "DOMAIN", ":", "xiaomi", ".", "PLATFORM_SCHEMA", "(", "{", "CONF_PLATFORM", ":", "xiaomi", ".", "DOMAIN", ",", "CONF_HOST", ":", "\"192.168.0.1\"", ",", "CONF_...
[ 174, 0 ]
[ 193, 51 ]
python
en
['en', 'la', 'en']
True
test_invalid_credential
(mock_get, mock_post, hass)
Testing invalid credential handling.
Testing invalid credential handling.
async def test_invalid_credential(mock_get, mock_post, hass): """Testing invalid credential handling.""" config = { DOMAIN: xiaomi.PLATFORM_SCHEMA( { CONF_PLATFORM: xiaomi.DOMAIN, CONF_HOST: "192.168.0.1", CONF_USERNAME: INVALID_USERNAME, ...
[ "async", "def", "test_invalid_credential", "(", "mock_get", ",", "mock_post", ",", "hass", ")", ":", "config", "=", "{", "DOMAIN", ":", "xiaomi", ".", "PLATFORM_SCHEMA", "(", "{", "CONF_PLATFORM", ":", "xiaomi", ".", "DOMAIN", ",", "CONF_HOST", ":", "\"192.1...
[ 198, 0 ]
[ 210, 44 ]
python
en
['en', 'en', 'en']
True
test_valid_credential
(mock_get, mock_post, hass)
Testing valid refresh.
Testing valid refresh.
async def test_valid_credential(mock_get, mock_post, hass): """Testing valid refresh.""" config = { DOMAIN: xiaomi.PLATFORM_SCHEMA( { CONF_PLATFORM: xiaomi.DOMAIN, CONF_HOST: "192.168.0.1", CONF_USERNAME: "admin", CONF_PASSWORD:...
[ "async", "def", "test_valid_credential", "(", "mock_get", ",", "mock_post", ",", "hass", ")", ":", "config", "=", "{", "DOMAIN", ":", "xiaomi", ".", "PLATFORM_SCHEMA", "(", "{", "CONF_PLATFORM", ":", "xiaomi", ".", "DOMAIN", ",", "CONF_HOST", ":", "\"192.168...
[ 215, 0 ]
[ 231, 68 ]
python
en
['nl', 'hmn', 'en']
False
test_token_timed_out
(mock_get, mock_post, hass)
Testing refresh with a timed out token. New token is requested and list is downloaded a second time.
Testing refresh with a timed out token.
async def test_token_timed_out(mock_get, mock_post, hass): """Testing refresh with a timed out token. New token is requested and list is downloaded a second time. """ config = { DOMAIN: xiaomi.PLATFORM_SCHEMA( { CONF_PLATFORM: xiaomi.DOMAIN, CONF_HOST...
[ "async", "def", "test_token_timed_out", "(", "mock_get", ",", "mock_post", ",", "hass", ")", ":", "config", "=", "{", "DOMAIN", ":", "xiaomi", ".", "PLATFORM_SCHEMA", "(", "{", "CONF_PLATFORM", ":", "xiaomi", ".", "DOMAIN", ",", "CONF_HOST", ":", "\"192.168....
[ 236, 0 ]
[ 255, 68 ]
python
en
['en', 'en', 'en']
True
test_abort_if_existing_entry
(hass)
Check flow abort when an entry already exist.
Check flow abort when an entry already exist.
async def test_abort_if_existing_entry(hass): """Check flow abort when an entry already exist.""" MockConfigEntry(domain=DOMAIN).add_to_hass(hass) result = await hass.config_entries.flow.async_init( "xbox", context={"source": config_entries.SOURCE_USER} ) assert result["type"] == data_entry...
[ "async", "def", "test_abort_if_existing_entry", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ")", ".", "add_to_hass", "(", "hass", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "\"...
[ 12, 0 ]
[ 20, 56 ]
python
en
['en', 'en', 'en']
True
test_full_flow
(hass, aiohttp_client, aioclient_mock, current_request)
Check full flow.
Check full flow.
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request): """Check full flow.""" assert await setup.async_setup_component( hass, "xbox", { "xbox": {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET}, "http": {"base_url": "https://exampl...
[ "async", "def", "test_full_flow", "(", "hass", ",", "aiohttp_client", ",", "aioclient_mock", ",", "current_request", ")", ":", "assert", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"xbox\"", ",", "{", "\"xbox\"", ":", "{", "\"client_id\""...
[ 23, 0 ]
[ 68, 42 ]
python
en
['sv', 'no', 'en']
False
setup
(hass, config)
Set up MinioClient and event listeners.
Set up MinioClient and event listeners.
def setup(hass, config): """Set up MinioClient and event listeners.""" conf = config[DOMAIN] host = conf[CONF_HOST] port = conf[CONF_PORT] access_key = conf[CONF_ACCESS_KEY] secret_key = conf[CONF_SECRET_KEY] secure = conf[CONF_SECURE] queue_listener = QueueListener(hass) queue = q...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "host", "=", "conf", "[", "CONF_HOST", "]", "port", "=", "conf", "[", "CONF_PORT", "]", "access_key", "=", "conf", "[", "CONF_ACCESS_KEY", "]", "secret_key...
[ 79, 0 ]
[ 163, 15 ]
python
en
['en', 'en', 'en']
True
get_minio_endpoint
(host: str, port: int)
Create minio endpoint from host and port.
Create minio endpoint from host and port.
def get_minio_endpoint(host: str, port: int) -> str: """Create minio endpoint from host and port.""" return f"{host}:{port}"
[ "def", "get_minio_endpoint", "(", "host", ":", "str", ",", "port", ":", "int", ")", "->", "str", ":", "return", "f\"{host}:{port}\"" ]
[ 166, 0 ]
[ 168, 27 ]
python
en
['en', 'en', 'en']
True
QueueListener.__init__
(self, hass)
Create queue.
Create queue.
def __init__(self, hass): """Create queue.""" super().__init__() self._hass = hass self._queue = Queue()
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_hass", "=", "hass", "self", ".", "_queue", "=", "Queue", "(", ")" ]
[ 174, 4 ]
[ 178, 29 ]
python
en
['fr', 'la', 'en']
False
QueueListener.run
(self)
Listen to queue events, and forward them to Home Assistant event bus.
Listen to queue events, and forward them to Home Assistant event bus.
def run(self): """Listen to queue events, and forward them to Home Assistant event bus.""" _LOGGER.info("Running QueueListener") while True: event = self._queue.get() if event is None: break _, file_name = os.path.split(event[ATTR_KEY]) ...
[ "def", "run", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "\"Running QueueListener\"", ")", "while", "True", ":", "event", "=", "self", ".", "_queue", ".", "get", "(", ")", "if", "event", "is", "None", ":", "break", "_", ",", "file_name", "="...
[ 180, 4 ]
[ 196, 74 ]
python
en
['en', 'en', 'en']
True
QueueListener.queue
(self)
Return wrapped queue.
Return wrapped queue.
def queue(self): """Return wrapped queue.""" return self._queue
[ "def", "queue", "(", "self", ")", ":", "return", "self", ".", "_queue" ]
[ 199, 4 ]
[ 201, 26 ]
python
en
['fr', 'la', 'en']
False
QueueListener.stop
(self)
Stop run by putting None into queue and join the thread.
Stop run by putting None into queue and join the thread.
def stop(self): """Stop run by putting None into queue and join the thread.""" _LOGGER.info("Stopping QueueListener") self._queue.put(None) self.join() _LOGGER.info("Stopped QueueListener")
[ "def", "stop", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "\"Stopping QueueListener\"", ")", "self", ".", "_queue", ".", "put", "(", "None", ")", "self", ".", "join", "(", ")", "_LOGGER", ".", "info", "(", "\"Stopped QueueListener\"", ")" ]
[ 203, 4 ]
[ 208, 45 ]
python
en
['en', 'en', 'en']
True
QueueListener.start_handler
(self, _)
Start handler helper method.
Start handler helper method.
def start_handler(self, _): """Start handler helper method.""" self.start()
[ "def", "start_handler", "(", "self", ",", "_", ")", ":", "self", ".", "start", "(", ")" ]
[ 210, 4 ]
[ 212, 20 ]
python
da
['da', 'no', 'en']
False
QueueListener.stop_handler
(self, _)
Stop handler helper method.
Stop handler helper method.
def stop_handler(self, _): """Stop handler helper method.""" self.stop()
[ "def", "stop_handler", "(", "self", ",", "_", ")", ":", "self", ".", "stop", "(", ")" ]
[ 214, 4 ]
[ 216, 19 ]
python
da
['da', 'nl', 'en']
False
MinioListener.__init__
( self, queue: Queue, endpoint: str, access_key: str, secret_key: str, secure: bool, bucket_name: str, prefix: str, suffix: str, events: List[str], )
Create Listener.
Create Listener.
def __init__( self, queue: Queue, endpoint: str, access_key: str, secret_key: str, secure: bool, bucket_name: str, prefix: str, suffix: str, events: List[str], ): """Create Listener.""" self._queue = queue self._...
[ "def", "__init__", "(", "self", ",", "queue", ":", "Queue", ",", "endpoint", ":", "str", ",", "access_key", ":", "str", ",", "secret_key", ":", "str", ",", "secure", ":", "bool", ",", "bucket_name", ":", "str", ",", "prefix", ":", "str", ",", "suffix...
[ 222, 4 ]
[ 244, 39 ]
python
en
['en', 'et', 'en']
False
MinioListener.start_handler
(self, _)
Create and start the event thread.
Create and start the event thread.
def start_handler(self, _): """Create and start the event thread.""" self._minio_event_thread = MinioEventThread( self._queue, self._endpoint, self._access_key, self._secret_key, self._secure, self._bucket_name, self._pr...
[ "def", "start_handler", "(", "self", ",", "_", ")", ":", "self", ".", "_minio_event_thread", "=", "MinioEventThread", "(", "self", ".", "_queue", ",", "self", ".", "_endpoint", ",", "self", ".", "_access_key", ",", "self", ".", "_secret_key", ",", "self", ...
[ 246, 4 ]
[ 259, 40 ]
python
en
['en', 'en', 'en']
True
MinioListener.stop_handler
(self, _)
Issue stop and wait for thread to join.
Issue stop and wait for thread to join.
def stop_handler(self, _): """Issue stop and wait for thread to join.""" if self._minio_event_thread is not None: self._minio_event_thread.stop()
[ "def", "stop_handler", "(", "self", ",", "_", ")", ":", "if", "self", ".", "_minio_event_thread", "is", "not", "None", ":", "self", ".", "_minio_event_thread", ".", "stop", "(", ")" ]
[ 261, 4 ]
[ 264, 43 ]
python
en
['en', 'en', 'en']
True
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["errors...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 29, 0 ]
[ 66, 48 ]
python
en
['en', 'en', 'en']
True
test_title_without_name_and_prefix
(hass)
Test we set the title to the hostname when the device doesn't have a name.
Test we set the title to the hostname when the device doesn't have a name.
async def test_title_without_name_and_prefix(hass): """Test we set the title to the hostname when the device doesn't have a name.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SO...
[ "async", "def", "test_title_without_name_and_prefix", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ...
[ 69, 0 ]
[ 110, 48 ]
python
en
['en', 'en', 'en']
True
test_form_auth
(hass)
Test manual configuration if auth is required.
Test manual configuration if auth is required.
async def test_form_auth(hass): """Test manual configuration if auth is required.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" assert result["errors"] == {} with patch( "aioshelly....
[ "async", "def", "test_form_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")", "ass...
[ 113, 0 ]
[ 160, 48 ]
python
en
['en', 'en', 'en']
True
test_form_errors_get_info
(hass, error)
Test we handle errors.
Test we handle errors.
async def test_form_errors_get_info(hass, error): """Test we handle errors.""" exc, base_error = error result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("aioshelly.get_info", side_effect=exc): result2 = await hass...
[ "async", "def", "test_form_errors_get_info", "(", "hass", ",", "error", ")", ":", "exc", ",", "base_error", "=", "error", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"sou...
[ 166, 0 ]
[ 180, 52 ]
python
de
['de', 'sr', 'en']
False
test_form_errors_test_connection
(hass, error)
Test we handle errors.
Test we handle errors.
async def test_form_errors_test_connection(hass, error): """Test we handle errors.""" exc, base_error = error result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "aioshelly.get_info", return_value={"mac": "test-mac...
[ "async", "def", "test_form_errors_test_connection", "(", "hass", ",", "error", ")", ":", "exc", ",", "base_error", "=", "error", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", ...
[ 186, 0 ]
[ 202, 52 ]
python
de
['de', 'sr', 'en']
False
test_form_already_configured
(hass)
Test we get the form.
Test we get the form.
async def test_form_already_configured(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0"} ) entry.add_to_hass(hass) result = await hass.config_...
[ "async", "def", "test_form_already_configured", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "\"shelly\"", ",", "u...
[ 205, 0 ]
[ 230, 42 ]
python
en
['en', 'en', 'en']
True
test_form_firmware_unsupported
(hass)
Test we abort if device firmware is unsupported.
Test we abort if device firmware is unsupported.
async def test_form_firmware_unsupported(hass): """Test we abort if device firmware is unsupported.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("aioshelly.get_info", side_effect=aioshelly.FirmwareUnsupported): ...
[ "async", "def", "test_form_firmware_unsupported", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}...
[ 233, 0 ]
[ 246, 58 ]
python
en
['en', 'en', 'en']
True
test_form_auth_errors_test_connection
(hass, error)
Test we handle errors in authenticated devices.
Test we handle errors in authenticated devices.
async def test_form_auth_errors_test_connection(hass, error): """Test we handle errors in authenticated devices.""" exc, base_error = error result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch("aioshelly.get_info", return_va...
[ "async", "def", "test_form_auth_errors_test_connection", "(", "hass", ",", "error", ")", ":", "exc", ",", "base_error", "=", "error", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "...
[ 258, 0 ]
[ 280, 52 ]
python
en
['de', 'en', 'en']
True
test_zeroconf
(hass)
Test we get the form.
Test we get the form.
async def test_zeroconf(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch( "aioshelly.get_info", return_value={"mac": "test-mac", "type": "SHSW-1", "auth": False}, ): result = await hass.config_entries.flow.async...
[ "async", "def", "test_zeroconf", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"aioshelly.get_info\"", ",", "return_value", "=", "{", "\"mac\"",...
[ 283, 0 ]
[ 329, 48 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_with_switch_prefix
(hass)
Test we get remove shelly from the prefix.
Test we get remove shelly from the prefix.
async def test_zeroconf_with_switch_prefix(hass): """Test we get remove shelly from the prefix.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch( "aioshelly.get_info", return_value={"mac": "test-mac", "type": "SHSW-1", "auth": False}, ): resul...
[ "async", "def", "test_zeroconf_with_switch_prefix", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"aioshelly.get_info\"", ",", "return_value", "=", ...
[ 332, 0 ]
[ 352, 72 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_confirm_error
(hass, error)
Test we get the form.
Test we get the form.
async def test_zeroconf_confirm_error(hass, error): """Test we get the form.""" exc, base_error = error await setup.async_setup_component(hass, "persistent_notification", {}) with patch( "aioshelly.get_info", return_value={"mac": "test-mac", "type": "SHSW-1", "auth": False}, ): ...
[ "async", "def", "test_zeroconf_confirm_error", "(", "hass", ",", "error", ")", ":", "exc", ",", "base_error", "=", "error", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(...
[ 358, 0 ]
[ 385, 52 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_already_configured
(hass)
Test we get the form.
Test we get the form.
async def test_zeroconf_already_configured(hass): """Test we get the form.""" await setup.async_setup_component(hass, "persistent_notification", {}) entry = MockConfigEntry( domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0"} ) entry.add_to_hass(hass) with patch( "ai...
[ "async", "def", "test_zeroconf_already_configured", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "entry", "=", "MockConfigEntry", "(", "domain", "=", "\"shelly\"", ",", ...
[ 388, 0 ]
[ 409, 42 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_firmware_unsupported
(hass)
Test we abort if device firmware is unsupported.
Test we abort if device firmware is unsupported.
async def test_zeroconf_firmware_unsupported(hass): """Test we abort if device firmware is unsupported.""" with patch("aioshelly.get_info", side_effect=aioshelly.FirmwareUnsupported): result = await hass.config_entries.flow.async_init( DOMAIN, data=DISCOVERY_INFO, con...
[ "async", "def", "test_zeroconf_firmware_unsupported", "(", "hass", ")", ":", "with", "patch", "(", "\"aioshelly.get_info\"", ",", "side_effect", "=", "aioshelly", ".", "FirmwareUnsupported", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "fl...
[ 412, 0 ]
[ 422, 57 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_cannot_connect
(hass)
Test we get the form.
Test we get the form.
async def test_zeroconf_cannot_connect(hass): """Test we get the form.""" with patch("aioshelly.get_info", side_effect=asyncio.TimeoutError): result = await hass.config_entries.flow.async_init( DOMAIN, data=DISCOVERY_INFO, context={"source": config_entries.SOURCE_ZERO...
[ "async", "def", "test_zeroconf_cannot_connect", "(", "hass", ")", ":", "with", "patch", "(", "\"aioshelly.get_info\"", ",", "side_effect", "=", "asyncio", ".", "TimeoutError", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "...
[ 425, 0 ]
[ 434, 51 ]
python
en
['en', 'en', 'en']
True
test_zeroconf_require_auth
(hass)
Test zeroconf if auth is required.
Test zeroconf if auth is required.
async def test_zeroconf_require_auth(hass): """Test zeroconf if auth is required.""" await setup.async_setup_component(hass, "persistent_notification", {}) with patch( "aioshelly.get_info", return_value={"mac": "test-mac", "type": "SHSW-1", "auth": True}, ): result = await hass....
[ "async", "def", "test_zeroconf_require_auth", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "with", "patch", "(", "\"aioshelly.get_info\"", ",", "return_value", "=", "{",...
[ 437, 0 ]
[ 487, 48 ]
python
en
['nl', 'en', 'en']
True
test_zeroconf_not_shelly
(hass)
Test we filter out non-shelly devices.
Test we filter out non-shelly devices.
async def test_zeroconf_not_shelly(hass): """Test we filter out non-shelly devices.""" result = await hass.config_entries.flow.async_init( DOMAIN, data={"host": "1.1.1.1", "name": "notshelly"}, context={"source": config_entries.SOURCE_ZEROCONF}, ) assert result["type"] == "abort"...
[ "async", "def", "test_zeroconf_not_shelly", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "data", "=", "{", "\"host\"", ":", "\"1.1.1.1\"", ",", "\"name\"", ":", "\"notshelly...
[ 490, 0 ]
[ 498, 43 ]
python
en
['en', 'en', 'en']
True
load_tf_weights_in_bert
(model, tf_checkpoint_path)
Load tf checkpoints in a pytorch model
Load tf checkpoints in a pytorch model
def load_tf_weights_in_bert(model, tf_checkpoint_path): """ Load tf checkpoints in a pytorch model """ try: import re import numpy as np import tensorflow as tf except ImportError: print("Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please ...
[ "def", "load_tf_weights_in_bert", "(", "model", ",", "tf_checkpoint_path", ")", ":", "try", ":", "import", "re", "import", "numpy", "as", "np", "import", "tensorflow", "as", "tf", "except", "ImportError", ":", "print", "(", "\"Loading a TensorFlow models in PyTorch,...
[ 52, 0 ]
[ 110, 16 ]
python
en
['en', 'en', 'en']
True
gelu
(x)
Implementation of the gelu activation function. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) Also see https://arxiv.org/abs/1606.08415
Implementation of the gelu activation function. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) Also see https://arxiv.org/abs/1606.08415
def gelu(x): """Implementation of the gelu activation function. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)))) Also see https://arxiv.org/abs/1606.08415 ...
[ "def", "gelu", "(", "x", ")", ":", "return", "x", "*", "0.5", "*", "(", "1.0", "+", "torch", ".", "erf", "(", "x", "/", "math", ".", "sqrt", "(", "2.0", ")", ")", ")" ]
[ 113, 0 ]
[ 119, 58 ]
python
en
['en', 'en', 'en']
True
BertConfig.__init__
(self, vocab_size_or_config_json_file, hidden_size=768, num_hidden_layers=12, num_attention_heads=12, intermediate_size=3072, hidden_act="gelu", hidden_dropout_prob=0.1, attention_prob...
Constructs BertConfig. Args: vocab_size_or_config_json_file: Vocabulary size of `inputs_ids` in `BertModel`. hidden_size: Size of the encoder layers and the pooler layer. num_hidden_layers: Number of hidden layers in the Transformer encoder. num_attention_heads: ...
Constructs BertConfig.
def __init__(self, vocab_size_or_config_json_file, hidden_size=768, num_hidden_layers=12, num_attention_heads=12, intermediate_size=3072, hidden_act="gelu", hidden_dropout_prob=0.1, at...
[ "def", "__init__", "(", "self", ",", "vocab_size_or_config_json_file", ",", "hidden_size", "=", "768", ",", "num_hidden_layers", "=", "12", ",", "num_attention_heads", "=", "12", ",", "intermediate_size", "=", "3072", ",", "hidden_act", "=", "\"gelu\"", ",", "hi...
[ 132, 4 ]
[ 188, 83 ]
python
en
['en', 'nl', 'it']
False
BertConfig.from_dict
(cls, json_object)
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = BertConfig(vocab_size_or_config_json_file=-1) for key, value in json_object.items(): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "BertConfig", "(", "vocab_size_or_config_json_file", "=", "-", "1", ")", "for", "key", ",", "value", "in", "json_object", ".", "items", "(", ")", ":", "config", ".", "__dict__", ...
[ 191, 4 ]
[ 196, 21 ]
python
en
['en', 'en', 'en']
True
BertConfig.from_json_file
(cls, json_file)
Constructs a `BertConfig` from a json file of parameters.
Constructs a `BertConfig` from a json file of parameters.
def from_json_file(cls, json_file): """Constructs a `BertConfig` from a json file of parameters.""" with open(json_file, "r", encoding='utf-8') as reader: text = reader.read() return cls.from_dict(json.loads(text))
[ "def", "from_json_file", "(", "cls", ",", "json_file", ")", ":", "with", "open", "(", "json_file", ",", "\"r\"", ",", "encoding", "=", "'utf-8'", ")", "as", "reader", ":", "text", "=", "reader", ".", "read", "(", ")", "return", "cls", ".", "from_dict",...
[ 199, 4 ]
[ 203, 46 ]
python
en
['en', 'en', 'en']
True
BertConfig.to_dict
(self)
Serializes this instance to a Python dictionary.
Serializes this instance to a Python dictionary.
def to_dict(self): """Serializes this instance to a Python dictionary.""" output = copy.deepcopy(self.__dict__) return output
[ "def", "to_dict", "(", "self", ")", ":", "output", "=", "copy", ".", "deepcopy", "(", "self", ".", "__dict__", ")", "return", "output" ]
[ 208, 4 ]
[ 211, 21 ]
python
en
['en', 'en', 'en']
True
BertConfig.to_json_string
(self)
Serializes this instance to a JSON string.
Serializes this instance to a JSON string.
def to_json_string(self): """Serializes this instance to a JSON string.""" return json.dumps(self.to_dict(), indent=2, sort_keys=True) + "\n"
[ "def", "to_json_string", "(", "self", ")", ":", "return", "json", ".", "dumps", "(", "self", ".", "to_dict", "(", ")", ",", "indent", "=", "2", ",", "sort_keys", "=", "True", ")", "+", "\"\\n\"" ]
[ 213, 4 ]
[ 215, 74 ]
python
en
['en', 'en', 'en']
True
BertPreTrainedModel.init_bert_weights
(self, module)
Initialize the weights.
Initialize the weights.
def init_bert_weights(self, module): """ Initialize the weights. """ if isinstance(module, (nn.Linear, nn.Embedding)): # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 mod...
[ "def", "init_bert_weights", "(", "self", ",", "module", ")", ":", "if", "isinstance", "(", "module", ",", "(", "nn", ".", "Linear", ",", "nn", ".", "Embedding", ")", ")", ":", "# Slightly different from the TF version which uses truncated_normal for initialization", ...
[ 521, 4 ]
[ 532, 36 ]
python
en
['en', 'en', 'en']
True
BertPreTrainedModel.from_pretrained
(cls, pretrained_model_name_or_path, state_dict=None, cache_dir=None, from_tf=False, *inputs, **kwargs)
Instantiate a BertPreTrainedModel from a pre-trained model file or a pytorch state dict. Download and cache the pre-trained model file if needed. Params: pretrained_model_name_or_path: either: - a str with the name of a pre-trained model to load selected in the list...
Instantiate a BertPreTrainedModel from a pre-trained model file or a pytorch state dict. Download and cache the pre-trained model file if needed.
def from_pretrained(cls, pretrained_model_name_or_path, state_dict=None, cache_dir=None, from_tf=False, *inputs, **kwargs): """ Instantiate a BertPreTrainedModel from a pre-trained model file or a pytorch state dict. Download and cache the pre-trained model file if needed...
[ "def", "from_pretrained", "(", "cls", ",", "pretrained_model_name_or_path", ",", "state_dict", "=", "None", ",", "cache_dir", "=", "None", ",", "from_tf", "=", "False", ",", "*", "inputs", ",", "*", "*", "kwargs", ")", ":", "if", "pretrained_model_name_or_path...
[ 535, 4 ]
[ 655, 20 ]
python
en
['en', 'error', 'th']
False
get_master
()
Get master. Returns: None.
Get master.
def get_master(): """Get master. Returns: None. """ master_details = redis_controller.get_master_details() return master_details
[ "def", "get_master", "(", ")", ":", "master_details", "=", "redis_controller", ".", "get_master_details", "(", ")", "return", "master_details" ]
[ 26, 0 ]
[ 34, 25 ]
python
en
['en', 'de', 'en']
False
create_master
(**kwargs)
Create master. Returns: None.
Create master.
def create_master(**kwargs): """Create master. Returns: None. """ master_details = kwargs["json_dict"] # Create rsa key-pair for master-node communication master_node_key_pair = generate_rsa_openssh_key_pair() save_master_key(private_key=master_node_key_pair["private_key"]) #...
[ "def", "create_master", "(", "*", "*", "kwargs", ")", ":", "master_details", "=", "kwargs", "[", "\"json_dict\"", "]", "# Create rsa key-pair for master-node communication", "master_node_key_pair", "=", "generate_rsa_openssh_key_pair", "(", ")", "save_master_key", "(", "p...
[ 39, 0 ]
[ 58, 25 ]
python
en
['en', 'la', 'en']
False
delete_master
()
Delete master. Returns: None.
Delete master.
def delete_master(): """Delete master. Returns: None. """ redis_controller.delete_master_details() return {}
[ "def", "delete_master", "(", ")", ":", "redis_controller", ".", "delete_master_details", "(", ")", "return", "{", "}" ]
[ 63, 0 ]
[ 71, 13 ]
python
en
['en', 'it', 'en']
False
async_get_geography_id
(geography_dict)
Generate a unique ID from a geography dict.
Generate a unique ID from a geography dict.
def async_get_geography_id(geography_dict): """Generate a unique ID from a geography dict.""" if not geography_dict: return if CONF_CITY in geography_dict: return ", ".join( ( geography_dict[CONF_CITY], geography_dict[CONF_STATE], ...
[ "def", "async_get_geography_id", "(", "geography_dict", ")", ":", "if", "not", "geography_dict", ":", "return", "if", "CONF_CITY", "in", "geography_dict", ":", "return", "\", \"", ".", "join", "(", "(", "geography_dict", "[", "CONF_CITY", "]", ",", "geography_di...
[ 55, 0 ]
[ 70, 5 ]
python
en
['en', 'en', 'en']
True
async_get_cloud_api_update_interval
(hass, api_key, num_consumers)
Get a leveled scan interval for a particular cloud API key. This will shift based on the number of active consumers, thus keeping the user under the monthly API limit.
Get a leveled scan interval for a particular cloud API key.
def async_get_cloud_api_update_interval(hass, api_key, num_consumers): """Get a leveled scan interval for a particular cloud API key. This will shift based on the number of active consumers, thus keeping the user under the monthly API limit. """ # Assuming 10,000 calls per month and a "smallest pos...
[ "def", "async_get_cloud_api_update_interval", "(", "hass", ",", "api_key", ",", "num_consumers", ")", ":", "# Assuming 10,000 calls per month and a \"smallest possible month\" of 28 days; note", "# that we give a buffer of 1500 API calls for any drift, restarts, etc.:", "minutes_between_api_...
[ 74, 0 ]
[ 91, 55 ]
python
en
['en', 'en', 'en']
True
async_get_cloud_coordinators_by_api_key
(hass, api_key)
Get all DataUpdateCoordinator objects related to a particular API key.
Get all DataUpdateCoordinator objects related to a particular API key.
def async_get_cloud_coordinators_by_api_key(hass, api_key): """Get all DataUpdateCoordinator objects related to a particular API key.""" coordinators = [] for entry_id, coordinator in hass.data[DOMAIN][DATA_COORDINATOR].items(): config_entry = hass.config_entries.async_get_entry(entry_id) if...
[ "def", "async_get_cloud_coordinators_by_api_key", "(", "hass", ",", "api_key", ")", ":", "coordinators", "=", "[", "]", "for", "entry_id", ",", "coordinator", "in", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_COORDINATOR", "]", ".", "items", "(", ")"...
[ 95, 0 ]
[ 102, 23 ]
python
en
['en', 'en', 'en']
True
async_sync_geo_coordinator_update_intervals
(hass, api_key)
Sync the update interval for geography-based data coordinators (by API key).
Sync the update interval for geography-based data coordinators (by API key).
def async_sync_geo_coordinator_update_intervals(hass, api_key): """Sync the update interval for geography-based data coordinators (by API key).""" coordinators = async_get_cloud_coordinators_by_api_key(hass, api_key) if not coordinators: return update_interval = async_get_cloud_api_update_inte...
[ "def", "async_sync_geo_coordinator_update_intervals", "(", "hass", ",", "api_key", ")", ":", "coordinators", "=", "async_get_cloud_coordinators_by_api_key", "(", "hass", ",", "api_key", ")", "if", "not", "coordinators", ":", "return", "update_interval", "=", "async_get_...
[ 106, 0 ]
[ 123, 53 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the AirVisual component.
Set up the AirVisual component.
async def async_setup(hass, config): """Set up the AirVisual component.""" hass.data[DOMAIN] = {DATA_COORDINATOR: {}, DATA_LISTENER: {}} return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "DATA_COORDINATOR", ":", "{", "}", ",", "DATA_LISTENER", ":", "{", "}", "}", "return", "True" ]
[ 126, 0 ]
[ 129, 15 ]
python
en
['en', 'en', 'en']
True
_standardize_geography_config_entry
(hass, config_entry)
Ensure that geography config entries have appropriate properties.
Ensure that geography config entries have appropriate properties.
def _standardize_geography_config_entry(hass, config_entry): """Ensure that geography config entries have appropriate properties.""" entry_updates = {} if not config_entry.unique_id: # If the config entry doesn't already have a unique ID, set one: entry_updates["unique_id"] = config_entry.d...
[ "def", "_standardize_geography_config_entry", "(", "hass", ",", "config_entry", ")", ":", "entry_updates", "=", "{", "}", "if", "not", "config_entry", ".", "unique_id", ":", "# If the config entry doesn't already have a unique ID, set one:", "entry_updates", "[", "\"unique_...
[ 133, 0 ]
[ 153, 73 ]
python
en
['en', 'en', 'en']
True
_standardize_node_pro_config_entry
(hass, config_entry)
Ensure that Node/Pro config entries have appropriate properties.
Ensure that Node/Pro config entries have appropriate properties.
def _standardize_node_pro_config_entry(hass, config_entry): """Ensure that Node/Pro config entries have appropriate properties.""" entry_updates = {} if CONF_INTEGRATION_TYPE not in config_entry.data: # If the config entry data doesn't contain the integration type, add it: entry_updates["da...
[ "def", "_standardize_node_pro_config_entry", "(", "hass", ",", "config_entry", ")", ":", "entry_updates", "=", "{", "}", "if", "CONF_INTEGRATION_TYPE", "not", "in", "config_entry", ".", "data", ":", "# If the config entry data doesn't contain the integration type, add it:", ...
[ 157, 0 ]
[ 171, 73 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set up AirVisual as config entry.
Set up AirVisual as config entry.
async def async_setup_entry(hass, config_entry): """Set up AirVisual as config entry.""" if CONF_API_KEY in config_entry.data: _standardize_geography_config_entry(hass, config_entry) websession = aiohttp_client.async_get_clientsession(hass) cloud_api = CloudAPI(config_entry.data[CONF_AP...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "if", "CONF_API_KEY", "in", "config_entry", ".", "data", ":", "_standardize_geography_config_entry", "(", "hass", ",", "config_entry", ")", "websession", "=", "aiohttp_client", ".", "...
[ 174, 0 ]
[ 273, 15 ]
python
en
['en', 'en', 'en']
True
async_migrate_entry
(hass, config_entry)
Migrate an old config entry.
Migrate an old config entry.
async def async_migrate_entry(hass, config_entry): """Migrate an old config entry.""" version = config_entry.version LOGGER.debug("Migrating from version %s", version) # 1 -> 2: One geography per config entry if version == 1: version = config_entry.version = 2 # Update the config ...
[ "async", "def", "async_migrate_entry", "(", "hass", ",", "config_entry", ")", ":", "version", "=", "config_entry", ".", "version", "LOGGER", ".", "debug", "(", "\"Migrating from version %s\"", ",", "version", ")", "# 1 -> 2: One geography per config entry", "if", "ver...
[ 276, 0 ]
[ 311, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, config_entry)
Unload an AirVisual config entry.
Unload an AirVisual config entry.
async def async_unload_entry(hass, config_entry): """Unload an AirVisual config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(config_entry, component) for component in PLATFORMS ] ) )...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "config_entry", ",", "compo...
[ 314, 0 ]
[ 336, 20 ]
python
en
['en', 'en', 'en']
True
async_reload_entry
(hass, config_entry)
Handle an options update.
Handle an options update.
async def async_reload_entry(hass, config_entry): """Handle an options update.""" await hass.config_entries.async_reload(config_entry.entry_id)
[ "async", "def", "async_reload_entry", "(", "hass", ",", "config_entry", ")", ":", "await", "hass", ".", "config_entries", ".", "async_reload", "(", "config_entry", ".", "entry_id", ")" ]
[ 339, 0 ]
[ 341, 65 ]
python
en
['en', 'en', 'en']
True
AirVisualEntity.__init__
(self, coordinator)
Initialize.
Initialize.
def __init__(self, coordinator): """Initialize.""" super().__init__(coordinator) self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION} self._icon = None self._unit = None
[ "def", "__init__", "(", "self", ",", "coordinator", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_attrs", "=", "{", "ATTR_ATTRIBUTION", ":", "DEFAULT_ATTRIBUTION", "}", "self", ".", "_icon", "=", "None", "self", "....
[ 347, 4 ]
[ 352, 25 ]
python
en
['en', 'en', 'it']
False
AirVisualEntity.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" return self._attrs
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_attrs" ]
[ 355, 4 ]
[ 357, 26 ]
python
en
['en', 'en', 'en']
True
AirVisualEntity.icon
(self)
Return the icon.
Return the icon.
def icon(self): """Return the icon.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 360, 4 ]
[ 362, 25 ]
python
en
['en', 'sr', 'en']
True
AirVisualEntity.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 365, 4 ]
[ 367, 25 ]
python
en
['en', 'en', 'en']
True
AirVisualEntity.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" @callback def update(): """Update the state.""" self.update_from_latest_data() self.async_write_ha_state() self.async_on_remove(self.coordinator.async_add_listener(update)) self....
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "@", "callback", "def", "update", "(", ")", ":", "\"\"\"Update the state.\"\"\"", "self", ".", "update_from_latest_data", "(", ")", "self", ".", "async_write_ha_state", "(", ")", "self", ".", "async_o...
[ 369, 4 ]
[ 380, 38 ]
python
en
['en', 'no', 'en']
False
AirVisualEntity.update_from_latest_data
(self)
Update the entity from the latest data.
Update the entity from the latest data.
def update_from_latest_data(self): """Update the entity from the latest data.""" raise NotImplementedError
[ "def", "update_from_latest_data", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 383, 4 ]
[ 385, 33 ]
python
en
['en', 'en', 'en']
True
init_tof_0
(xshut, sensor)
XSHUT port LOW resets the device.
XSHUT port LOW resets the device.
def init_tof_0(xshut, sensor): """XSHUT port LOW resets the device.""" sensor.open() rpi_gpio.setup_output(xshut) rpi_gpio.write_output(xshut, 0)
[ "def", "init_tof_0", "(", "xshut", ",", "sensor", ")", ":", "sensor", ".", "open", "(", ")", "rpi_gpio", ".", "setup_output", "(", "xshut", ")", "rpi_gpio", ".", "write_output", "(", "xshut", ",", "0", ")" ]
[ 34, 0 ]
[ 38, 35 ]
python
en
['en', 'en', 'en']
True
init_tof_1
(xshut)
XSHUT port HIGH enables the device.
XSHUT port HIGH enables the device.
def init_tof_1(xshut): """XSHUT port HIGH enables the device.""" rpi_gpio.setup_output(xshut) rpi_gpio.write_output(xshut, 1)
[ "def", "init_tof_1", "(", "xshut", ")", ":", "rpi_gpio", ".", "setup_output", "(", "xshut", ")", "rpi_gpio", ".", "write_output", "(", "xshut", ",", "1", ")" ]
[ 41, 0 ]
[ 44, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Reset and initialize the VL53L1X ToF Sensor from STMicroelectronics.
Reset and initialize the VL53L1X ToF Sensor from STMicroelectronics.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Reset and initialize the VL53L1X ToF Sensor from STMicroelectronics.""" name = config.get(CONF_NAME) bus_number = config.get(CONF_I2C_BUS) i2c_address = config.get(CONF_I2C_ADDRESS) unit = LENGTH_MILLIMETERS ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "bus_number", "=", "config", ".", "get", "(", "CONF_I2C_BUS...
[ 47, 0 ]
[ 64, 33 ]
python
en
['en', 'en', 'en']
True
VL53L1XSensor.__init__
(self, vl53l1x_sensor, name, unit, i2c_address)
Initialize the sensor.
Initialize the sensor.
def __init__(self, vl53l1x_sensor, name, unit, i2c_address): """Initialize the sensor.""" self._name = name self._unit_of_measurement = unit self.vl53l1x_sensor = vl53l1x_sensor self.i2c_address = i2c_address self._state = None self.init = True
[ "def", "__init__", "(", "self", ",", "vl53l1x_sensor", ",", "name", ",", "unit", ",", "i2c_address", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_unit_of_measurement", "=", "unit", "self", ".", "vl53l1x_sensor", "=", "vl53l1x_sensor", "self", ...
[ 70, 4 ]
[ 77, 24 ]
python
en
['en', 'en', 'en']
True