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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
EcoalSwitch.__init__ | (self, ecoal_contr, name, state_attr) |
Initialize switch.
Sets HA switch to state as read from controller.
|
Initialize switch. | def __init__(self, ecoal_contr, name, state_attr):
"""
Initialize switch.
Sets HA switch to state as read from controller.
"""
self._ecoal_contr = ecoal_contr
self._name = name
self._state_attr = state_attr
# Ecoalcotroller holds convention that same post... | [
"def",
"__init__",
"(",
"self",
",",
"ecoal_contr",
",",
"name",
",",
"state_attr",
")",
":",
"self",
".",
"_ecoal_contr",
"=",
"ecoal_contr",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state_attr",
"=",
"state_attr",
"# Ecoalcotroller holds convention th... | [
23,
4
] | [
39,
26
] | python | en | ['en', 'error', 'th'] | False |
EcoalSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self) -> Optional[str]:
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_name"
] | [
42,
4
] | [
44,
25
] | python | en | ['en', 'en', 'en'] | True |
EcoalSwitch.update | (self) | Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
| Fetch new state data for the sensor. | def update(self):
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
"""
status = self._ecoal_contr.get_cached_status()
self._state = getattr(status, self._state_attr) | [
"def",
"update",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"_ecoal_contr",
".",
"get_cached_status",
"(",
")",
"self",
".",
"_state",
"=",
"getattr",
"(",
"status",
",",
"self",
".",
"_state_attr",
")"
] | [
46,
4
] | [
52,
55
] | python | en | ['en', 'en', 'en'] | True |
EcoalSwitch.invalidate_ecoal_cache | (self) | Invalidate ecoal interface cache.
Forces that next read from ecaol interface to not use cache.
| Invalidate ecoal interface cache. | def invalidate_ecoal_cache(self):
"""Invalidate ecoal interface cache.
Forces that next read from ecaol interface to not use cache.
"""
self._ecoal_contr.status = None | [
"def",
"invalidate_ecoal_cache",
"(",
"self",
")",
":",
"self",
".",
"_ecoal_contr",
".",
"status",
"=",
"None"
] | [
54,
4
] | [
59,
39
] | python | en | ['es', 'en', 'en'] | True |
EcoalSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self) -> bool:
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_state"
] | [
62,
4
] | [
64,
26
] | python | en | ['en', 'fy', 'en'] | True |
EcoalSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs) -> None:
"""Turn the device on."""
self._contr_set_fun(1)
self.invalidate_ecoal_cache() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"_contr_set_fun",
"(",
"1",
")",
"self",
".",
"invalidate_ecoal_cache",
"(",
")"
] | [
66,
4
] | [
69,
37
] | python | en | ['en', 'en', 'en'] | True |
EcoalSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs) -> None:
"""Turn the device off."""
self._contr_set_fun(0)
self.invalidate_ecoal_cache() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"_contr_set_fun",
"(",
"0",
")",
"self",
".",
"invalidate_ecoal_cache",
"(",
")"
] | [
71,
4
] | [
74,
37
] | python | en | ['en', 'en', 'en'] | True |
get_percentile_min_max | (input, lower_percentile, upper_percentile, output_tensor=False) |
Calculate the percentile max and min values in a given tensor
Args:
input (:obj:`torch.Tensor`):
The target tensor to calculate percentile max and min.
lower_percentile (:obj:`float`):
If 0.1, means we return the value of the smallest 0.1% value in the tensor as percent... |
Calculate the percentile max and min values in a given tensor | def get_percentile_min_max(input, lower_percentile, upper_percentile, output_tensor=False):
"""
Calculate the percentile max and min values in a given tensor
Args:
input (:obj:`torch.Tensor`):
The target tensor to calculate percentile max and min.
lower_percentile (:obj:`float`)... | [
"def",
"get_percentile_min_max",
"(",
"input",
",",
"lower_percentile",
",",
"upper_percentile",
",",
"output_tensor",
"=",
"False",
")",
":",
"input_length",
"=",
"input",
".",
"shape",
"[",
"0",
"]",
"lower_index",
"=",
"round",
"(",
"input_length",
"*",
"("... | [
535,
0
] | [
568,
35
] | python | en | ['en', 'error', 'th'] | False |
linear_quantize | (input, scale, zero_point, inplace=False) |
Quantize single-precision input tensor to integers with the given scaling factor and zeropoint.
Args:
input (:obj:`torch.Tensor`):
Single-precision input tensor to be quantized.
scale (:obj:`torch.Tensor`):
Scaling factor for quantization.
zero_pint (:obj:`torch... |
Quantize single-precision input tensor to integers with the given scaling factor and zeropoint. | def linear_quantize(input, scale, zero_point, inplace=False):
"""
Quantize single-precision input tensor to integers with the given scaling factor and zeropoint.
Args:
input (:obj:`torch.Tensor`):
Single-precision input tensor to be quantized.
scale (:obj:`torch.Tensor`):
... | [
"def",
"linear_quantize",
"(",
"input",
",",
"scale",
",",
"zero_point",
",",
"inplace",
"=",
"False",
")",
":",
"# reshape scale and zeropoint for convolutional weights and activation",
"if",
"len",
"(",
"input",
".",
"shape",
")",
"==",
"4",
":",
"scale",
"=",
... | [
571,
0
] | [
603,
56
] | python | en | ['en', 'error', 'th'] | False |
symmetric_linear_quantization_params | (num_bits, saturation_min, saturation_max, per_channel=False) |
Compute the scaling factor with the given quantization range for symmetric quantization.
Args:
saturation_min (:obj:`torch.Tensor`):
Lower bound for quantization range.
saturation_max (:obj:`torch.Tensor`):
Upper bound for quantization range.
per_channel (:obj:`... |
Compute the scaling factor with the given quantization range for symmetric quantization. | def symmetric_linear_quantization_params(num_bits, saturation_min, saturation_max, per_channel=False):
"""
Compute the scaling factor with the given quantization range for symmetric quantization.
Args:
saturation_min (:obj:`torch.Tensor`):
Lower bound for quantization range.
sat... | [
"def",
"symmetric_linear_quantization_params",
"(",
"num_bits",
",",
"saturation_min",
",",
"saturation_max",
",",
"per_channel",
"=",
"False",
")",
":",
"# in this part, we do not need any gradient computation,",
"# in order to enfore this, we put torch.no_grad()",
"with",
"torch"... | [
606,
0
] | [
635,
16
] | python | en | ['en', 'error', 'th'] | False |
batch_frexp | (inputs, max_bit=31) |
Decompose the scaling factor into mantissa and twos exponent.
Args:
scaling_factor (:obj:`torch.Tensor`):
Target scaling factor to decompose.
Returns:
:obj:``Tuple(torch.Tensor, torch.Tensor)`: mantisa and exponent
|
Decompose the scaling factor into mantissa and twos exponent. | def batch_frexp(inputs, max_bit=31):
"""
Decompose the scaling factor into mantissa and twos exponent.
Args:
scaling_factor (:obj:`torch.Tensor`):
Target scaling factor to decompose.
Returns:
:obj:``Tuple(torch.Tensor, torch.Tensor)`: mantisa and exponent
"""
shape... | [
"def",
"batch_frexp",
"(",
"inputs",
",",
"max_bit",
"=",
"31",
")",
":",
"shape_of_input",
"=",
"inputs",
".",
"size",
"(",
")",
"# trans the input to be a 1-d tensor",
"inputs",
"=",
"inputs",
".",
"view",
"(",
"-",
"1",
")",
"output_m",
",",
"output_e",
... | [
712,
0
] | [
743,
5
] | python | en | ['en', 'error', 'th'] | False |
IntLayerNorm.overflow_fallback | (self, y_int) |
This fallback function is called when overflow is detected during training time, and adjusts the `self.shift`
to avoid overflow in the subsequent runs.
|
This fallback function is called when overflow is detected during training time, and adjusts the `self.shift`
to avoid overflow in the subsequent runs.
| def overflow_fallback(self, y_int):
"""
This fallback function is called when overflow is detected during training time, and adjusts the `self.shift`
to avoid overflow in the subsequent runs.
"""
self.set_shift(y_int) # adjusts `self.shift`
y_int_shifted = floor_ste.appl... | [
"def",
"overflow_fallback",
"(",
"self",
",",
"y_int",
")",
":",
"self",
".",
"set_shift",
"(",
"y_int",
")",
"# adjusts `self.shift`",
"y_int_shifted",
"=",
"floor_ste",
".",
"apply",
"(",
"y_int",
"/",
"2",
"**",
"self",
".",
"shift",
")",
"y_sq_int",
"=... | [
475,
4
] | [
484,
22
] | python | en | ['en', 'error', 'th'] | False |
SymmetricQuantFunction.forward | (ctx, x, k, percentile_mode, scale) |
Args:
x (:obj:`torch.Tensor`):
Floating point tensor to be quantized.
k (:obj:`int`):
Quantization bitwidth.
percentile_mode (:obj:`bool`):
Whether or not to use percentile calibration.
scale (:obj:`torch.Tensor`):
... |
Args:
x (:obj:`torch.Tensor`):
Floating point tensor to be quantized.
k (:obj:`int`):
Quantization bitwidth.
percentile_mode (:obj:`bool`):
Whether or not to use percentile calibration.
scale (:obj:`torch.Tensor`):
... | def forward(ctx, x, k, percentile_mode, scale):
"""
Args:
x (:obj:`torch.Tensor`):
Floating point tensor to be quantized.
k (:obj:`int`):
Quantization bitwidth.
percentile_mode (:obj:`bool`):
Whether or not to use percen... | [
"def",
"forward",
"(",
"ctx",
",",
"x",
",",
"k",
",",
"percentile_mode",
",",
"scale",
")",
":",
"zero_point",
"=",
"torch",
".",
"tensor",
"(",
"0.0",
")",
".",
"to",
"(",
"scale",
".",
"device",
")",
"n",
"=",
"2",
"**",
"(",
"k",
"-",
"1",
... | [
644,
4
] | [
667,
26
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up mysq covers. | Set up mysq covers. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up mysq covers."""
data = hass.data[DOMAIN][config_entry.entry_id]
myq = data[MYQ_GATEWAY]
coordinator = data[MYQ_COORDINATOR]
entities = []
for device in myq.devices.values():
if device.device_json[MYQ_DEVICE_... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"myq",
"=",
"data",
"[",
"MYQ_GATEWAY",
"]",
"coord... | [
19,
0
] | [
31,
38
] | python | en | ['en', 'bg', 'en'] | True |
MyQBinarySensorEntity.__init__ | (self, coordinator, device) | Initialize with API object, device id. | Initialize with API object, device id. | def __init__(self, coordinator, device):
"""Initialize with API object, device id."""
super().__init__(coordinator)
self._device = device | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_device",
"=",
"device"
] | [
37,
4
] | [
40,
29
] | python | en | ['en', 'en', 'en'] | True |
MyQBinarySensorEntity.device_class | (self) | We track connectivity for gateways. | We track connectivity for gateways. | def device_class(self):
"""We track connectivity for gateways."""
return DEVICE_CLASS_CONNECTIVITY | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_CONNECTIVITY"
] | [
43,
4
] | [
45,
40
] | python | en | ['en', 'en', 'en'] | True |
MyQBinarySensorEntity.name | (self) | Return the name of the garage door if any. | Return the name of the garage door if any. | def name(self):
"""Return the name of the garage door if any."""
return f"{self._device.name} MyQ Gateway" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._device.name} MyQ Gateway\""
] | [
48,
4
] | [
50,
49
] | python | en | ['en', 'en', 'en'] | True |
MyQBinarySensorEntity.is_on | (self) | Return if the device is online. | Return if the device is online. | def is_on(self):
"""Return if the device is online."""
if not self.coordinator.last_update_success:
return False
# Not all devices report online so assume True if its missing
return self._device.device_json[MYQ_DEVICE_STATE].get(
MYQ_DEVICE_STATE_ONLINE, True
... | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"coordinator",
".",
"last_update_success",
":",
"return",
"False",
"# Not all devices report online so assume True if its missing",
"return",
"self",
".",
"_device",
".",
"device_json",
"[",
"MYQ_DEVICE_... | [
53,
4
] | [
61,
9
] | python | en | ['en', 'en', 'en'] | True |
MyQBinarySensorEntity.available | (self) | Entity is always available. | Entity is always available. | def available(self) -> bool:
"""Entity is always available."""
return True | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
64,
4
] | [
66,
19
] | python | en | ['en', 'en', 'en'] | True |
MyQBinarySensorEntity.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return self._device.device_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"device_id"
] | [
69,
4
] | [
71,
37
] | python | en | ['en', 'en', 'en'] | True |
MyQBinarySensorEntity.device_info | (self) | Return the device_info of the device. | Return the device_info of the device. | def device_info(self):
"""Return the device_info of the device."""
device_info = {
"identifiers": {(DOMAIN, self._device.device_id)},
"name": self.name,
"manufacturer": MANUFACTURER,
"sw_version": self._device.firmware_version,
}
model = KN... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device_info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"device_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
"MANUFACTU... | [
74,
4
] | [
86,
26
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the RainMachine component. | Set up the RainMachine component. | async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the RainMachine component."""
hass.data[DOMAIN] = {DATA_COORDINATOR: {}}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"DATA_COORDINATOR",
":",
"{",
"}",
"}",
"return",
"True"
] | [
22,
0
] | [
25,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up RainMachine as config entry. | Set up RainMachine as config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up RainMachine as config entry."""
session = aiohttp_client.async_get_clientsession(hass)
client = Client(
entry.data[CONF_PLACE_ID], entry.data[CONF_SERVICE_ID], session=session
)
async def async_get_picku... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"session",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
")",
"client",
"=",
"Client",
"(",
"entry",
".",
... | [
28,
0
] | [
66,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload an RainMachine config entry. | Unload an RainMachine config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload an RainMachine config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_fo... | [
69,
0
] | [
82,
20
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler._set_headers | (self) | Setting up the header response upon connection establishment.
| Setting up the header response upon connection establishment.
| def _set_headers(self):
'''Setting up the header response upon connection establishment.
'''
self.send_response(200)
self.send_header('Content-type','text/json')
# reads the length of the Headers
length = int(self.headers['Content-Length'])
# re... | [
"def",
"_set_headers",
"(",
"self",
")",
":",
"self",
".",
"send_response",
"(",
"200",
")",
"self",
".",
"send_header",
"(",
"'Content-type'",
",",
"'text/json'",
")",
"# reads the length of the Headers\r",
"length",
"=",
"int",
"(",
"self",
".",
"headers",
"... | [
16,
4
] | [
29,
24
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_VIEW | (self) | Uses VIEW Method to show the value for a given Key from the cb-exporter's targets.json file.
Sample Curl Query: curl -X VIEW --data "tild23.pld.ai" server-url:port-no
| Uses VIEW Method to show the value for a given Key from the cb-exporter's targets.json file.
Sample Curl Query: curl -X VIEW --data "tild23.pld.ai" server-url:port-no
| def do_VIEW(self):
'''Uses VIEW Method to show the value for a given Key from the cb-exporter's targets.json file.
Sample Curl Query: curl -X VIEW --data "tild23.pld.ai" server-url:port-no
'''
# defining all the headers.
display = {}
data_strm = sel... | [
"def",
"do_VIEW",
"(",
"self",
")",
":",
"# defining all the headers.\r",
"display",
"=",
"{",
"}",
"data_strm",
"=",
"self",
".",
"_set_headers",
"(",
")",
"display",
"[",
"data_strm",
"]",
"=",
"get_util",
"(",
"data_strm",
")",
"self",
".",
"send_response... | [
32,
4
] | [
46,
54
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_GET | (self) | Uses GET Method to show all the keys and their respective values from the cb-exporter's targets.json file.
Sample Curl Query: curl -X GET server-url:port-no
| Uses GET Method to show all the keys and their respective values from the cb-exporter's targets.json file.
Sample Curl Query: curl -X GET server-url:port-no
| def do_GET(self):
'''Uses GET Method to show all the keys and their respective values from the cb-exporter's targets.json file.
Sample Curl Query: curl -X GET server-url:port-no
'''
# defining all the headers.
self.send_response(200)
self.send_head... | [
"def",
"do_GET",
"(",
"self",
")",
":",
"# defining all the headers.\r",
"self",
".",
"send_response",
"(",
"200",
")",
"self",
".",
"send_header",
"(",
"'Content-type'",
",",
"'text/json'",
")",
"self",
".",
"end_headers",
"(",
")",
"# prints all the keys and val... | [
49,
4
] | [
60,
57
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_POST | (self) | Uses POST Method to get empty port-no to start cb-exporter process & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X POST --data "Hostname,UserName,Password" server-url:port-no
| Uses POST Method to get empty port-no to start cb-exporter process & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X POST --data "Hostname,UserName,Password" server-url:port-no
| def do_POST(self):
'''Uses POST Method to get empty port-no to start cb-exporter process & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X POST --data "Hostname,UserName,Password" server-url:port-no
'''
data_strm = self._set... | [
"def",
"do_POST",
"(",
"self",
")",
":",
"data_strm",
"=",
"self",
".",
"_set_headers",
"(",
")",
"data_strm_list",
"=",
"data_strm",
".",
"split",
"(",
"','",
")",
"# get free port number\r",
"port_no",
"=",
"get_empty_port",
"(",
")",
"# store key,values in re... | [
63,
4
] | [
81,
49
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_DELETE | (self) | Uses DELETE Method to kill a cb-exporter process baed on port-no & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X DELETE --data "Hostname" server-url:port-no
| Uses DELETE Method to kill a cb-exporter process baed on port-no & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X DELETE --data "Hostname" server-url:port-no
| def do_DELETE(self):
'''Uses DELETE Method to kill a cb-exporter process baed on port-no & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X DELETE --data "Hostname" server-url:port-no
'''
# receive hostname value as key
... | [
"def",
"do_DELETE",
"(",
"self",
")",
":",
"# receive hostname value as key\r",
"data_strm",
"=",
"self",
".",
"_set_headers",
"(",
")",
"# delete value from cb-exporter's reference file.\r",
"str_val",
",",
"port_no",
"=",
"del_util",
"(",
"data_strm",
")",
"eff_mssg",... | [
84,
4
] | [
100,
49
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the DHT sensor. | Set up the DHT sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the DHT sensor."""
SENSOR_TYPES[SENSOR_TEMPERATURE][1] = hass.config.units.temperature_unit
available_sensors = {
"AM2302": Adafruit_DHT.AM2302,
"DHT11": Adafruit_DHT.DHT11,
"DHT22": Adafruit_DHT.DHT22,
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"SENSOR_TYPES",
"[",
"SENSOR_TEMPERATURE",
"]",
"[",
"1",
"]",
"=",
"hass",
".",
"config",
".",
"units",
".",
"temperature_unit",
"availab... | [
56,
0
] | [
93,
27
] | python | en | ['en', 'sq', 'en'] | True |
DHTSensor.__init__ | (
self,
dht_client,
sensor_type,
temp_unit,
name,
temperature_offset,
humidity_offset,
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self,
dht_client,
sensor_type,
temp_unit,
name,
temperature_offset,
humidity_offset,
):
"""Initialize the sensor."""
self.client_name = name
self._name = SENSOR_TYPES[sensor_type][0]
self.dht_client = dht_client
... | [
"def",
"__init__",
"(",
"self",
",",
"dht_client",
",",
"sensor_type",
",",
"temp_unit",
",",
"name",
",",
"temperature_offset",
",",
"humidity_offset",
",",
")",
":",
"self",
".",
"client_name",
"=",
"name",
"self",
".",
"_name",
"=",
"SENSOR_TYPES",
"[",
... | [
99,
4
] | [
117,
64
] | python | en | ['en', 'en', 'en'] | True |
DHTSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self.client_name} {self._name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.client_name} {self._name}\""
] | [
120,
4
] | [
122,
49
] | python | en | ['en', 'mi', 'en'] | True |
DHTSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
125,
4
] | [
127,
26
] | python | en | ['en', 'en', 'en'] | True |
DHTSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
130,
4
] | [
132,
40
] | python | en | ['en', 'en', 'en'] | True |
DHTSensor.update | (self) | Get the latest data from the DHT and updates the states. | Get the latest data from the DHT and updates the states. | def update(self):
"""Get the latest data from the DHT and updates the states."""
self.dht_client.update()
temperature_offset = self.temperature_offset
humidity_offset = self.humidity_offset
data = self.dht_client.data
if self.type == SENSOR_TEMPERATURE and SENSOR_TEMPERA... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"dht_client",
".",
"update",
"(",
")",
"temperature_offset",
"=",
"self",
".",
"temperature_offset",
"humidity_offset",
"=",
"self",
".",
"humidity_offset",
"data",
"=",
"self",
".",
"dht_client",
".",
"da... | [
134,
4
] | [
156,
66
] | python | en | ['en', 'en', 'en'] | True |
DHTClient.__init__ | (self, adafruit_dht, sensor, pin) | Initialize the sensor. | Initialize the sensor. | def __init__(self, adafruit_dht, sensor, pin):
"""Initialize the sensor."""
self.adafruit_dht = adafruit_dht
self.sensor = sensor
self.pin = pin
self.data = {} | [
"def",
"__init__",
"(",
"self",
",",
"adafruit_dht",
",",
"sensor",
",",
"pin",
")",
":",
"self",
".",
"adafruit_dht",
"=",
"adafruit_dht",
"self",
".",
"sensor",
"=",
"sensor",
"self",
".",
"pin",
"=",
"pin",
"self",
".",
"data",
"=",
"{",
"}"
] | [
162,
4
] | [
167,
22
] | python | en | ['en', 'en', 'en'] | True |
DHTClient.update | (self) | Get the latest data the DHT sensor. | Get the latest data the DHT sensor. | def update(self):
"""Get the latest data the DHT sensor."""
humidity, temperature = self.adafruit_dht.read_retry(self.sensor, self.pin)
if temperature:
self.data[SENSOR_TEMPERATURE] = temperature
if humidity:
self.data[SENSOR_HUMIDITY] = humidity | [
"def",
"update",
"(",
"self",
")",
":",
"humidity",
",",
"temperature",
"=",
"self",
".",
"adafruit_dht",
".",
"read_retry",
"(",
"self",
".",
"sensor",
",",
"self",
".",
"pin",
")",
"if",
"temperature",
":",
"self",
".",
"data",
"[",
"SENSOR_TEMPERATURE... | [
170,
4
] | [
176,
49
] | python | en | ['en', 'en', 'en'] | True |
TestSummarizationDistiller.test_hub_configs | (self) | I put require_torch_gpu cause I only want this to run with self-scheduled. | I put require_torch_gpu cause I only want this to run with self-scheduled. | def test_hub_configs(self):
"""I put require_torch_gpu cause I only want this to run with self-scheduled."""
model_list = HfApi().model_list()
org = "sshleifer"
model_ids = [x.modelId for x in model_list if x.modelId.startswith(org)]
allowed_to_be_broken = ["sshleifer/blenderbot... | [
"def",
"test_hub_configs",
"(",
"self",
")",
":",
"model_list",
"=",
"HfApi",
"(",
")",
".",
"model_list",
"(",
")",
"org",
"=",
"\"sshleifer\"",
"model_ids",
"=",
"[",
"x",
".",
"modelId",
"for",
"x",
"in",
"model_list",
"if",
"x",
".",
"modelId",
"."... | [
128,
4
] | [
143,
103
] | python | en | ['en', 'en', 'en'] | True |
_system_admin_group | () | Create system admin group. | Create system admin group. | def _system_admin_group() -> models.Group:
"""Create system admin group."""
return models.Group(
name=GROUP_NAME_ADMIN,
id=GROUP_ID_ADMIN,
policy=system_policies.ADMIN_POLICY,
system_generated=True,
) | [
"def",
"_system_admin_group",
"(",
")",
"->",
"models",
".",
"Group",
":",
"return",
"models",
".",
"Group",
"(",
"name",
"=",
"GROUP_NAME_ADMIN",
",",
"id",
"=",
"GROUP_ID_ADMIN",
",",
"policy",
"=",
"system_policies",
".",
"ADMIN_POLICY",
",",
"system_genera... | [
570,
0
] | [
577,
5
] | python | en | ['nl', 'en', 'en'] | True |
_system_user_group | () | Create system user group. | Create system user group. | def _system_user_group() -> models.Group:
"""Create system user group."""
return models.Group(
name=GROUP_NAME_USER,
id=GROUP_ID_USER,
policy=system_policies.USER_POLICY,
system_generated=True,
) | [
"def",
"_system_user_group",
"(",
")",
"->",
"models",
".",
"Group",
":",
"return",
"models",
".",
"Group",
"(",
"name",
"=",
"GROUP_NAME_USER",
",",
"id",
"=",
"GROUP_ID_USER",
",",
"policy",
"=",
"system_policies",
".",
"USER_POLICY",
",",
"system_generated"... | [
580,
0
] | [
587,
5
] | python | en | ['da', 'en', 'en'] | True |
_system_read_only_group | () | Create read only group. | Create read only group. | def _system_read_only_group() -> models.Group:
"""Create read only group."""
return models.Group(
name=GROUP_NAME_READ_ONLY,
id=GROUP_ID_READ_ONLY,
policy=system_policies.READ_ONLY_POLICY,
system_generated=True,
) | [
"def",
"_system_read_only_group",
"(",
")",
"->",
"models",
".",
"Group",
":",
"return",
"models",
".",
"Group",
"(",
"name",
"=",
"GROUP_NAME_READ_ONLY",
",",
"id",
"=",
"GROUP_ID_READ_ONLY",
",",
"policy",
"=",
"system_policies",
".",
"READ_ONLY_POLICY",
",",
... | [
590,
0
] | [
597,
5
] | python | en | ['en', 'en', 'en'] | True |
AuthStore.__init__ | (self, hass: HomeAssistant) | Initialize the auth store. | Initialize the auth store. | def __init__(self, hass: HomeAssistant) -> None:
"""Initialize the auth store."""
self.hass = hass
self._users: Optional[Dict[str, models.User]] = None
self._groups: Optional[Dict[str, models.Group]] = None
self._perm_lookup: Optional[PermissionLookup] = None
self._store ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_users",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"models",
".",
"User",
"]",
"]",
"=",
"None",
"self",... | [
33,
4
] | [
42,
35
] | python | en | ['en', 'en', 'en'] | True |
AuthStore.async_get_groups | (self) | Retrieve all users. | Retrieve all users. | async def async_get_groups(self) -> List[models.Group]:
"""Retrieve all users."""
if self._groups is None:
await self._async_load()
assert self._groups is not None
return list(self._groups.values()) | [
"async",
"def",
"async_get_groups",
"(",
"self",
")",
"->",
"List",
"[",
"models",
".",
"Group",
"]",
":",
"if",
"self",
".",
"_groups",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",
".",
"_groups",
"is",
"not",
... | [
44,
4
] | [
50,
42
] | python | en | ['en', 'sk', 'en'] | True |
AuthStore.async_get_group | (self, group_id: str) | Retrieve all users. | Retrieve all users. | async def async_get_group(self, group_id: str) -> Optional[models.Group]:
"""Retrieve all users."""
if self._groups is None:
await self._async_load()
assert self._groups is not None
return self._groups.get(group_id) | [
"async",
"def",
"async_get_group",
"(",
"self",
",",
"group_id",
":",
"str",
")",
"->",
"Optional",
"[",
"models",
".",
"Group",
"]",
":",
"if",
"self",
".",
"_groups",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",... | [
52,
4
] | [
58,
41
] | python | en | ['en', 'sk', 'en'] | True |
AuthStore.async_get_users | (self) | Retrieve all users. | Retrieve all users. | async def async_get_users(self) -> List[models.User]:
"""Retrieve all users."""
if self._users is None:
await self._async_load()
assert self._users is not None
return list(self._users.values()) | [
"async",
"def",
"async_get_users",
"(",
"self",
")",
"->",
"List",
"[",
"models",
".",
"User",
"]",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",
".",
"_users",
"is",
"not",
"Non... | [
60,
4
] | [
66,
41
] | python | en | ['en', 'sk', 'en'] | True |
AuthStore.async_get_user | (self, user_id: str) | Retrieve a user by id. | Retrieve a user by id. | async def async_get_user(self, user_id: str) -> Optional[models.User]:
"""Retrieve a user by id."""
if self._users is None:
await self._async_load()
assert self._users is not None
return self._users.get(user_id) | [
"async",
"def",
"async_get_user",
"(",
"self",
",",
"user_id",
":",
"str",
")",
"->",
"Optional",
"[",
"models",
".",
"User",
"]",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",
"... | [
68,
4
] | [
74,
39
] | python | en | ['en', 'sk', 'en'] | True |
AuthStore.async_create_user | (
self,
name: Optional[str],
is_owner: Optional[bool] = None,
is_active: Optional[bool] = None,
system_generated: Optional[bool] = None,
credentials: Optional[models.Credentials] = None,
group_ids: Optional[List[str]] = None,
) | Create a new user. | Create a new user. | async def async_create_user(
self,
name: Optional[str],
is_owner: Optional[bool] = None,
is_active: Optional[bool] = None,
system_generated: Optional[bool] = None,
credentials: Optional[models.Credentials] = None,
group_ids: Optional[List[str]] = None,
) -> mo... | [
"async",
"def",
"async_create_user",
"(",
"self",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
",",
"is_owner",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"is_active",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"system_generated",
... | [
76,
4
] | [
126,
23
] | python | en | ['en', 'en', 'en'] | True |
AuthStore.async_link_user | (
self, user: models.User, credentials: models.Credentials
) | Add credentials to an existing user. | Add credentials to an existing user. | async def async_link_user(
self, user: models.User, credentials: models.Credentials
) -> None:
"""Add credentials to an existing user."""
user.credentials.append(credentials)
self._async_schedule_save()
credentials.is_new = False | [
"async",
"def",
"async_link_user",
"(",
"self",
",",
"user",
":",
"models",
".",
"User",
",",
"credentials",
":",
"models",
".",
"Credentials",
")",
"->",
"None",
":",
"user",
".",
"credentials",
".",
"append",
"(",
"credentials",
")",
"self",
".",
"_asy... | [
128,
4
] | [
134,
34
] | python | en | ['en', 'en', 'en'] | True |
AuthStore.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."""
if self._users is None:
await self._async_load()
assert self._users is not None
self._users.pop(user.id)
self._async_schedule_save() | [
"async",
"def",
"async_remove_user",
"(",
"self",
",",
"user",
":",
"models",
".",
"User",
")",
"->",
"None",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",
".",
"_users",
"is",
"... | [
136,
4
] | [
143,
35
] | python | en | ['es', 'it', 'en'] | False |
AuthStore.async_update_user | (
self,
user: models.User,
name: Optional[str] = None,
is_active: Optional[bool] = 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,
is_active: Optional[bool] = None,
group_ids: Optional[List[str]] = None,
) -> None:
"""Update a user."""
assert self._groups is not None
if group_ids is not None:
... | [
"async",
"def",
"async_update_user",
"(",
"self",
",",
"user",
":",
"models",
".",
"User",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"is_active",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"group_ids",
":",
"Optional",
... | [
145,
4
] | [
170,
35
] | python | co | ['es', 'co', 'en'] | False |
AuthStore.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."""
user.is_active = True
self._async_schedule_save() | [
"async",
"def",
"async_activate_user",
"(",
"self",
",",
"user",
":",
"models",
".",
"User",
")",
"->",
"None",
":",
"user",
".",
"is_active",
"=",
"True",
"self",
".",
"_async_schedule_save",
"(",
")"
] | [
172,
4
] | [
175,
35
] | python | en | ['es', 'en', 'en'] | True |
AuthStore.async_deactivate_user | (self, user: models.User) | Activate a user. | Activate a user. | async def async_deactivate_user(self, user: models.User) -> None:
"""Activate a user."""
user.is_active = False
self._async_schedule_save() | [
"async",
"def",
"async_deactivate_user",
"(",
"self",
",",
"user",
":",
"models",
".",
"User",
")",
"->",
"None",
":",
"user",
".",
"is_active",
"=",
"False",
"self",
".",
"_async_schedule_save",
"(",
")"
] | [
177,
4
] | [
180,
35
] | python | en | ['es', 'en', 'en'] | True |
AuthStore.async_remove_credentials | (self, credentials: models.Credentials) | Remove credentials. | Remove credentials. | async def async_remove_credentials(self, credentials: models.Credentials) -> None:
"""Remove credentials."""
if self._users is None:
await self._async_load()
assert self._users is not None
for user in self._users.values():
found = None
for index,... | [
"async",
"def",
"async_remove_credentials",
"(",
"self",
",",
"credentials",
":",
"models",
".",
"Credentials",
")",
"->",
"None",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",
".",
... | [
182,
4
] | [
200,
35
] | python | en | ['en', 'it', 'en'] | False |
AuthStore.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: str = models.TOKEN_TYPE_NORMAL,
access_token_expiration: timedelta = ACCESS_TOKEN_EXPIRATION,
) | Create a new token for a user. | Create a new 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: str = models.TOKEN_TYPE_NORMAL,
access_token_expiration: timedelta = ACCESS_TOKEN_EXPI... | [
"async",
"def",
"async_create_refresh_token",
"(",
"self",
",",
"user",
":",
"models",
".",
"User",
",",
"client_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"client_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"client_icon",
":... | [
202,
4
] | [
227,
28
] | python | en | ['en', 'en', 'en'] | True |
AuthStore.async_remove_refresh_token | (
self, refresh_token: models.RefreshToken
) | Remove a refresh token. | Remove a refresh token. | async def async_remove_refresh_token(
self, refresh_token: models.RefreshToken
) -> None:
"""Remove a refresh token."""
if self._users is None:
await self._async_load()
assert self._users is not None
for user in self._users.values():
if user.refre... | [
"async",
"def",
"async_remove_refresh_token",
"(",
"self",
",",
"refresh_token",
":",
"models",
".",
"RefreshToken",
")",
"->",
"None",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"assert",
"self",
".... | [
229,
4
] | [
240,
21
] | python | en | ['en', 'gl', 'en'] | True |
AuthStore.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."""
if self._users is None:
await self._async_load()
assert self._users is not None
for user in self._users.values():
refresh_tok... | [
"async",
"def",
"async_get_refresh_token",
"(",
"self",
",",
"token_id",
":",
"str",
")",
"->",
"Optional",
"[",
"models",
".",
"RefreshToken",
"]",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
"asse... | [
242,
4
] | [
255,
19
] | python | en | ['en', 'en', 'en'] | True |
AuthStore.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."""
if self._users is None:
await self._async_load()
assert self._users is not None
found = None
for user in self._users.va... | [
"async",
"def",
"async_get_refresh_token_by_token",
"(",
"self",
",",
"token",
":",
"str",
")",
"->",
"Optional",
"[",
"models",
".",
"RefreshToken",
"]",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"await",
"self",
".",
"_async_load",
"(",
")",
... | [
257,
4
] | [
272,
20
] | python | en | ['en', 'nl', 'en'] | True |
AuthStore.async_log_refresh_token_usage | (
self, refresh_token: models.RefreshToken, remote_ip: Optional[str] = None
) | Update refresh token last used information. | Update refresh token last used information. | def async_log_refresh_token_usage(
self, refresh_token: models.RefreshToken, remote_ip: Optional[str] = None
) -> None:
"""Update refresh token last used information."""
refresh_token.last_used_at = dt_util.utcnow()
refresh_token.last_used_ip = remote_ip
self._async_schedule_... | [
"def",
"async_log_refresh_token_usage",
"(",
"self",
",",
"refresh_token",
":",
"models",
".",
"RefreshToken",
",",
"remote_ip",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"refresh_token",
".",
"last_used_at",
"=",
"dt_util",
".",
... | [
275,
4
] | [
281,
35
] | python | en | ['en', 'af', 'en'] | True |
AuthStore._async_load | (self) | Load the users. | Load the users. | async def _async_load(self) -> None:
"""Load the users."""
async with self._lock:
if self._users is not None:
return
await self._async_load_task() | [
"async",
"def",
"_async_load",
"(",
"self",
")",
"->",
"None",
":",
"async",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_users",
"is",
"not",
"None",
":",
"return",
"await",
"self",
".",
"_async_load_task",
"(",
")"
] | [
283,
4
] | [
288,
41
] | python | en | ['en', 'en', 'en'] | True |
AuthStore._async_load_task | (self) | Load the users. | Load the users. | async def _async_load_task(self) -> None:
"""Load the users."""
[ent_reg, dev_reg, data] = await asyncio.gather(
self.hass.helpers.entity_registry.async_get_registry(),
self.hass.helpers.device_registry.async_get_registry(),
self._store.async_load(),
)
... | [
"async",
"def",
"_async_load_task",
"(",
"self",
")",
"->",
"None",
":",
"[",
"ent_reg",
",",
"dev_reg",
",",
"data",
"]",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
... | [
290,
4
] | [
475,
27
] | python | en | ['en', 'en', 'en'] | True |
AuthStore._async_schedule_save | (self) | Save users. | Save users. | def _async_schedule_save(self) -> None:
"""Save users."""
if self._users is None:
return
self._store.async_delay_save(self._data_to_save, 1) | [
"def",
"_async_schedule_save",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_users",
"is",
"None",
":",
"return",
"self",
".",
"_store",
".",
"async_delay_save",
"(",
"self",
".",
"_data_to_save",
",",
"1",
")"
] | [
478,
4
] | [
483,
59
] | python | en | ['en', 'tg', 'en'] | False |
AuthStore._data_to_save | (self) | Return the data to store. | Return the data to store. | def _data_to_save(self) -> Dict:
"""Return the data to store."""
assert self._users is not None
assert self._groups is not None
users = [
{
"id": user.id,
"group_ids": [group.id for group in user.groups],
"is_owner": user.is_ow... | [
"def",
"_data_to_save",
"(",
"self",
")",
"->",
"Dict",
":",
"assert",
"self",
".",
"_users",
"is",
"not",
"None",
"assert",
"self",
".",
"_groups",
"is",
"not",
"None",
"users",
"=",
"[",
"{",
"\"id\"",
":",
"user",
".",
"id",
",",
"\"group_ids\"",
... | [
486,
4
] | [
554,
9
] | python | en | ['en', 'en', 'en'] | True |
AuthStore._set_defaults | (self) | Set default values for auth store. | Set default values for auth store. | def _set_defaults(self) -> None:
"""Set default values for auth store."""
self._users = OrderedDict()
groups: Dict[str, models.Group] = OrderedDict()
admin_group = _system_admin_group()
groups[admin_group.id] = admin_group
user_group = _system_user_group()
groups... | [
"def",
"_set_defaults",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_users",
"=",
"OrderedDict",
"(",
")",
"groups",
":",
"Dict",
"[",
"str",
",",
"models",
".",
"Group",
"]",
"=",
"OrderedDict",
"(",
")",
"admin_group",
"=",
"_system_admin_group"... | [
556,
4
] | [
567,
29
] | python | fr | ['fr', 'fr', 'en'] | True |
generate_random_sparsity | (model) |
generate a random sparsity for all conv layers in the
model.
|
generate a random sparsity for all conv layers in the
model.
| def generate_random_sparsity(model):
"""
generate a random sparsity for all conv layers in the
model.
"""
cfg_list = []
for name, module in model.named_modules():
if isinstance(module, nn.Conv2d):
sparsity = np.random.uniform(0.5, 0.99)
cfg_list.append({'op_types'... | [
"def",
"generate_random_sparsity",
"(",
"model",
")",
":",
"cfg_list",
"=",
"[",
"]",
"for",
"name",
",",
"module",
"in",
"model",
".",
"named_modules",
"(",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Conv2d",
")",
":",
"sparsity",
"... | [
21,
0
] | [
32,
19
] | python | en | ['en', 'error', 'th'] | False |
generate_random_sparsity_v2 | (model) |
only generate a random sparsity for some conv layers in
in the model.
|
only generate a random sparsity for some conv layers in
in the model.
| def generate_random_sparsity_v2(model):
"""
only generate a random sparsity for some conv layers in
in the model.
"""
cfg_list = []
for name, module in model.named_modules():
# randomly pick 50% layers
if isinstance(module, nn.Conv2d) and random.uniform(0, 1) > 0.5:
s... | [
"def",
"generate_random_sparsity_v2",
"(",
"model",
")",
":",
"cfg_list",
"=",
"[",
"]",
"for",
"name",
",",
"module",
"in",
"model",
".",
"named_modules",
"(",
")",
":",
"# randomly pick 50% layers",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Conv2... | [
34,
0
] | [
46,
19
] | python | en | ['en', 'error', 'th'] | False |
CpuReader._switch_to_next_file_name | (self, data_path) | Switch to next file name. | Switch to next file name. | def _switch_to_next_file_name(self, data_path) -> str:
"""Switch to next file name."""
file_name = data_path.split("-")
file_name[2] = str(int(file_name[2]) + 1)
new_data_path = "-".join(file_name)
return new_data_path | [
"def",
"_switch_to_next_file_name",
"(",
"self",
",",
"data_path",
")",
"->",
"str",
":",
"file_name",
"=",
"data_path",
".",
"split",
"(",
"\"-\"",
")",
"file_name",
"[",
"2",
"]",
"=",
"str",
"(",
"int",
"(",
"file_name",
"[",
"2",
"]",
")",
"+",
"... | [
24,
4
] | [
30,
28
] | python | en | ['en', 'en', 'en'] | True |
CpuReader._switch | (self) | Switch to a new binary reader. | Switch to a new binary reader. | def _switch(self):
"""Switch to a new binary reader."""
self._data_path = self._switch_to_next_file_name(self._data_path)
self._cpu_reader = BinaryReader(self._data_path)
self._cpu_item_picker = self._cpu_reader.items_tick_picker(
start_time_offset=0,
end_time_off... | [
"def",
"_switch",
"(",
"self",
")",
":",
"self",
".",
"_data_path",
"=",
"self",
".",
"_switch_to_next_file_name",
"(",
"self",
".",
"_data_path",
")",
"self",
".",
"_cpu_reader",
"=",
"BinaryReader",
"(",
"self",
".",
"_data_path",
")",
"self",
".",
"_cpu... | [
32,
4
] | [
40,
9
] | python | en | ['en', 'en', 'en'] | True |
handle_webhook | (hass, webhook_id, request) | Handle webhook callback. | Handle webhook callback. | async def handle_webhook(hass, webhook_id, request):
"""Handle webhook callback."""
try:
data = await request.json()
except ValueError as err:
_LOGGER.error("Error in data: %s", err)
return None
_LOGGER.debug("Got webhook data: %s", data)
event_type = data.get(ATTR_EVENT_TY... | [
"async",
"def",
"handle_webhook",
"(",
"hass",
",",
"webhook_id",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"await",
"request",
".",
"json",
"(",
")",
"except",
"ValueError",
"as",
"err",
":",
"_LOGGER",
".",
"error",
"(",
"\"Error in data: %s\"",... | [
27,
0
] | [
46,
40
] | python | en | ['en', 'xh', 'en'] | True |
async_evaluate_event | (hass, event_data) | Evaluate events from webhook. | Evaluate events from webhook. | def async_evaluate_event(hass, event_data):
"""Evaluate events from webhook."""
event_type = event_data.get(ATTR_EVENT_TYPE)
if event_type == "person":
for person in event_data.get(ATTR_PERSONS):
person_event_data = dict(event_data)
person_event_data[ATTR_ID] = person.get(AT... | [
"def",
"async_evaluate_event",
"(",
"hass",
",",
"event_data",
")",
":",
"event_type",
"=",
"event_data",
".",
"get",
"(",
"ATTR_EVENT_TYPE",
")",
"if",
"event_type",
"==",
"\"person\"",
":",
"for",
"person",
"in",
"event_data",
".",
"get",
"(",
"ATTR_PERSONS"... | [
50,
0
] | [
68,
54
] | python | en | ['en', 'en', 'en'] | True |
async_send_event | (hass, event_type, data) | Send events. | Send events. | def async_send_event(hass, event_type, data):
"""Send events."""
hass.bus.async_fire(
event_type=NETATMO_EVENT, event_data={"type": event_type, "data": data}
)
async_dispatcher_send(
hass,
f"signal-{DOMAIN}-webhook-{event_type}",
{"type": event_type, "data": data},
) | [
"def",
"async_send_event",
"(",
"hass",
",",
"event_type",
",",
"data",
")",
":",
"hass",
".",
"bus",
".",
"async_fire",
"(",
"event_type",
"=",
"NETATMO_EVENT",
",",
"event_data",
"=",
"{",
"\"type\"",
":",
"event_type",
",",
"\"data\"",
":",
"data",
"}",... | [
72,
0
] | [
81,
5
] | python | en | ['en', 'en', 'en'] | False |
main | () | @nni.mutable_layers(
{
layer_choice: [add_one(), add_two(), add_three(), add_four()],
optional_inputs: [images],
optional_input_size: 1,
layer_output: layer_1_out
},
{
layer_choice: [add_one(), add_two(), add_three(), add_four()],
optional_inputs: [layer_1_out... | def main():
images = 5
"""@nni.mutable_layers(
{
layer_choice: [add_one(), add_two(), add_three(), add_four()],
optional_inputs: [images],
optional_input_size: 1,
layer_output: layer_1_out
},
{
layer_choice: [add_one(), add_two(), add_three(), add_four()],
... | [
"def",
"main",
"(",
")",
":",
"images",
"=",
"5",
"\"\"\"@nni.report_intermediate_result(layer_1_out)\"\"\"",
"time",
".",
"sleep",
"(",
"2",
")",
"\"\"\"@nni.report_intermediate_result(layer_2_out)\"\"\"",
"time",
".",
"sleep",
"(",
"2",
")",
"\"\"\"@nni.report_intermedi... | [
15,
0
] | [
49,
47
] | python | sw | ['en', 'sw', 'sw'] | False | |
AbsLearner.run | (self) | Main learning loop is implemented here. | Main learning loop is implemented here. | def run(self):
"""Main learning loop is implemented here."""
return NotImplementedError | [
"def",
"run",
"(",
"self",
")",
":",
"return",
"NotImplementedError"
] | [
46,
4
] | [
48,
34
] | python | en | ['en', 'en', 'en'] | True |
async_create_person | (hass, name, *, user_id=None, device_trackers=None) | Create a new person. | Create a new person. | async def async_create_person(hass, name, *, user_id=None, device_trackers=None):
"""Create a new person."""
await hass.data[DOMAIN][1].async_create_item(
{
ATTR_NAME: name,
ATTR_USER_ID: user_id,
CONF_DEVICE_TRACKERS: device_trackers or [],
}
) | [
"async",
"def",
"async_create_person",
"(",
"hass",
",",
"name",
",",
"*",
",",
"user_id",
"=",
"None",
",",
"device_trackers",
"=",
"None",
")",
":",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"1",
"]",
".",
"async_create_item",
"(",
"{",
... | [
93,
0
] | [
101,
5
] | python | en | ['en', 'it', 'en'] | True |
async_add_user_device_tracker | (
hass: HomeAssistant, user_id: str, device_tracker_entity_id: str
) | Add a device tracker to a person linked to a user. | Add a device tracker to a person linked to a user. | async def async_add_user_device_tracker(
hass: HomeAssistant, user_id: str, device_tracker_entity_id: str
):
"""Add a device tracker to a person linked to a user."""
coll = cast(PersonStorageCollection, hass.data[DOMAIN][1])
for person in coll.async_items():
if person.get(ATTR_USER_ID) != user_... | [
"async",
"def",
"async_add_user_device_tracker",
"(",
"hass",
":",
"HomeAssistant",
",",
"user_id",
":",
"str",
",",
"device_tracker_entity_id",
":",
"str",
")",
":",
"coll",
"=",
"cast",
"(",
"PersonStorageCollection",
",",
"hass",
".",
"data",
"[",
"DOMAIN",
... | [
105,
0
] | [
124,
13
] | python | en | ['en', 'en', 'en'] | True |
filter_yaml_data | (hass: HomeAssistantType, persons: List[dict]) | Validate YAML data that we can't validate via schema. | Validate YAML data that we can't validate via schema. | async def filter_yaml_data(hass: HomeAssistantType, persons: List[dict]) -> List[dict]:
"""Validate YAML data that we can't validate via schema."""
filtered = []
person_invalid_user = []
for person_conf in persons:
user_id = person_conf.get(CONF_USER_ID)
if user_id is not None:
... | [
"async",
"def",
"filter_yaml_data",
"(",
"hass",
":",
"HomeAssistantType",
",",
"persons",
":",
"List",
"[",
"dict",
"]",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"filtered",
"=",
"[",
"]",
"person_invalid_user",
"=",
"[",
"]",
"for",
"person_conf",
"in... | [
261,
0
] | [
293,
19
] | python | en | ['en', 'sn', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Set up the person component. | Set up the person component. | async def async_setup(hass: HomeAssistantType, config: ConfigType):
"""Set up the person component."""
entity_component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
yaml_collection = collection.YamlCollection(
logging.getLogger(f"{__name__}.yaml_collection"), id_m... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
":",
"entity_component",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"id_manager",
"=",
"collection",
".",
"IDManager",
"(... | [
296,
0
] | [
356,
15
] | python | en | ['en', 'en', 'en'] | True |
ws_list_person | (
hass: HomeAssistantType, connection: websocket_api.ActiveConnection, msg
) | List persons. | List persons. | def ws_list_person(
hass: HomeAssistantType, connection: websocket_api.ActiveConnection, msg
):
"""List persons."""
yaml, storage = hass.data[DOMAIN]
connection.send_result(
msg[ATTR_ID], {"storage": storage.async_items(), "config": yaml.async_items()}
) | [
"def",
"ws_list_person",
"(",
"hass",
":",
"HomeAssistantType",
",",
"connection",
":",
"websocket_api",
".",
"ActiveConnection",
",",
"msg",
")",
":",
"yaml",
",",
"storage",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"connection",
".",
"send_result",
"(... | [
511,
0
] | [
518,
5
] | python | en | ['en', 'en', 'en'] | False |
_get_latest | (prev: Optional[State], curr: State) | Get latest state. | Get latest state. | def _get_latest(prev: Optional[State], curr: State):
"""Get latest state."""
if prev is None or curr.last_updated > prev.last_updated:
return curr
return prev | [
"def",
"_get_latest",
"(",
"prev",
":",
"Optional",
"[",
"State",
"]",
",",
"curr",
":",
"State",
")",
":",
"if",
"prev",
"is",
"None",
"or",
"curr",
".",
"last_updated",
">",
"prev",
".",
"last_updated",
":",
"return",
"curr",
"return",
"prev"
] | [
521,
0
] | [
525,
15
] | python | en | ['fr', 'en', 'en'] | True |
PersonStore._async_migrate_func | (self, old_version, old_data) | Migrate to the new version.
Migrate storage to use format of collection helper.
| Migrate to the new version. | async def _async_migrate_func(self, old_version, old_data):
"""Migrate to the new version.
Migrate storage to use format of collection helper.
"""
return {"items": old_data["persons"]} | [
"async",
"def",
"_async_migrate_func",
"(",
"self",
",",
"old_version",
",",
"old_data",
")",
":",
"return",
"{",
"\"items\"",
":",
"old_data",
"[",
"\"persons\"",
"]",
"}"
] | [
150,
4
] | [
155,
45
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection.__init__ | (
self,
store: Store,
logger: logging.Logger,
id_manager: collection.IDManager,
yaml_collection: collection.YamlCollection,
) | Initialize a person storage collection. | Initialize a person storage collection. | def __init__(
self,
store: Store,
logger: logging.Logger,
id_manager: collection.IDManager,
yaml_collection: collection.YamlCollection,
):
"""Initialize a person storage collection."""
super().__init__(store, logger, id_manager)
self.yaml_collection = ... | [
"def",
"__init__",
"(",
"self",
",",
"store",
":",
"Store",
",",
"logger",
":",
"logging",
".",
"Logger",
",",
"id_manager",
":",
"collection",
".",
"IDManager",
",",
"yaml_collection",
":",
"collection",
".",
"YamlCollection",
",",
")",
":",
"super",
"(",... | [
164,
4
] | [
173,
46
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection._async_load_data | (self) | Load the data.
A past bug caused onboarding to create invalid person objects.
This patches it up.
| Load the data. | async def _async_load_data(self) -> Optional[dict]:
"""Load the data.
A past bug caused onboarding to create invalid person objects.
This patches it up.
"""
data = await super()._async_load_data()
if data is None:
return data
for person in data["ite... | [
"async",
"def",
"_async_load_data",
"(",
"self",
")",
"->",
"Optional",
"[",
"dict",
"]",
":",
"data",
"=",
"await",
"super",
"(",
")",
".",
"_async_load_data",
"(",
")",
"if",
"data",
"is",
"None",
":",
"return",
"data",
"for",
"person",
"in",
"data",... | [
175,
4
] | [
190,
19
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection.async_load | (self) | Load the Storage collection. | Load the Storage collection. | async def async_load(self) -> None:
"""Load the Storage collection."""
await super().async_load()
self.hass.bus.async_listen(
entity_registry.EVENT_ENTITY_REGISTRY_UPDATED, self._entity_registry_updated
) | [
"async",
"def",
"async_load",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_load",
"(",
")",
"self",
".",
"hass",
".",
"bus",
".",
"async_listen",
"(",
"entity_registry",
".",
"EVENT_ENTITY_REGISTRY_UPDATED",
",",
"self",
"."... | [
192,
4
] | [
197,
9
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection._entity_registry_updated | (self, event) | Handle entity registry updated. | Handle entity registry updated. | async def _entity_registry_updated(self, event) -> None:
"""Handle entity registry updated."""
if event.data["action"] != "remove":
return
entity_id = event.data[ATTR_ENTITY_ID]
if split_entity_id(entity_id)[0] != "device_tracker":
return
for person in ... | [
"async",
"def",
"_entity_registry_updated",
"(",
"self",
",",
"event",
")",
"->",
"None",
":",
"if",
"event",
".",
"data",
"[",
"\"action\"",
"]",
"!=",
"\"remove\"",
":",
"return",
"entity_id",
"=",
"event",
".",
"data",
"[",
"ATTR_ENTITY_ID",
"]",
"if",
... | [
199,
4
] | [
222,
13
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection._process_create_data | (self, data: dict) | Validate the config is valid. | Validate the config is valid. | async def _process_create_data(self, data: dict) -> dict:
"""Validate the config is valid."""
data = self.CREATE_SCHEMA(data)
user_id = data.get(CONF_USER_ID)
if user_id is not None:
await self._validate_user_id(user_id)
return data | [
"async",
"def",
"_process_create_data",
"(",
"self",
",",
"data",
":",
"dict",
")",
"->",
"dict",
":",
"data",
"=",
"self",
".",
"CREATE_SCHEMA",
"(",
"data",
")",
"user_id",
"=",
"data",
".",
"get",
"(",
"CONF_USER_ID",
")",
"if",
"user_id",
"is",
"no... | [
224,
4
] | [
233,
19
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection._get_suggested_id | (self, info: dict) | Suggest an ID based on the config. | Suggest an ID based on the config. | def _get_suggested_id(self, info: dict) -> str:
"""Suggest an ID based on the config."""
return info[CONF_NAME] | [
"def",
"_get_suggested_id",
"(",
"self",
",",
"info",
":",
"dict",
")",
"->",
"str",
":",
"return",
"info",
"[",
"CONF_NAME",
"]"
] | [
236,
4
] | [
238,
30
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection._update_data | (self, data: dict, update_data: dict) | Return a new updated data object. | Return a new updated data object. | async def _update_data(self, data: dict, update_data: dict) -> dict:
"""Return a new updated data object."""
update_data = self.UPDATE_SCHEMA(update_data)
user_id = update_data.get(CONF_USER_ID)
if user_id is not None and user_id != data.get(CONF_USER_ID):
await self._valid... | [
"async",
"def",
"_update_data",
"(",
"self",
",",
"data",
":",
"dict",
",",
"update_data",
":",
"dict",
")",
"->",
"dict",
":",
"update_data",
"=",
"self",
".",
"UPDATE_SCHEMA",
"(",
"update_data",
")",
"user_id",
"=",
"update_data",
".",
"get",
"(",
"CO... | [
240,
4
] | [
249,
38
] | python | en | ['en', 'en', 'en'] | True |
PersonStorageCollection._validate_user_id | (self, user_id) | Validate the used user_id. | Validate the used user_id. | async def _validate_user_id(self, user_id):
"""Validate the used user_id."""
if await self.hass.auth.async_get_user(user_id) is None:
raise ValueError("User does not exist")
for persons in (self.data.values(), self.yaml_collection.async_items()):
if any(person for person... | [
"async",
"def",
"_validate_user_id",
"(",
"self",
",",
"user_id",
")",
":",
"if",
"await",
"self",
".",
"hass",
".",
"auth",
".",
"async_get_user",
"(",
"user_id",
")",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"User does not exist\"",
")",
"for",
"... | [
251,
4
] | [
258,
54
] | python | en | ['en', 'et', 'en'] | True |
Person.__init__ | (self, config, editable) | Set up person. | Set up person. | def __init__(self, config, editable):
"""Set up person."""
self._config = config
self._editable = editable
self._latitude = None
self._longitude = None
self._gps_accuracy = None
self._source = None
self._state = None
self._unsub_track_device = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"editable",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_editable",
"=",
"editable",
"self",
".",
"_latitude",
"=",
"None",
"self",
".",
"_longitude",
"=",
"None",
"self",
".",
"_gp... | [
362,
4
] | [
371,
39
] | python | en | ['en', 'en', 'en'] | True |
Person.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
374,
4
] | [
376,
38
] | python | en | ['en', 'en', 'en'] | True |
Person.entity_picture | (self) | Return entity picture. | Return entity picture. | def entity_picture(self) -> Optional[str]:
"""Return entity picture."""
return self._config.get(CONF_PICTURE) | [
"def",
"entity_picture",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_PICTURE",
")"
] | [
379,
4
] | [
381,
45
] | python | en | ['en', 'en', 'en'] | True |
Person.should_poll | (self) | Return True if entity has to be polled for state.
False if entity pushes its state to HA.
| Return True if entity has to be polled for state. | def should_poll(self):
"""Return True if entity has to be polled for state.
False if entity pushes its state to HA.
"""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
384,
4
] | [
389,
20
] | python | en | ['en', 'en', 'en'] | True |
Person.state | (self) | Return the state of the person. | Return the state of the person. | def state(self):
"""Return the state of the person."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
392,
4
] | [
394,
26
] | python | en | ['en', 'en', 'en'] | True |
Person.state_attributes | (self) | Return the state attributes of the person. | Return the state attributes of the person. | def state_attributes(self):
"""Return the state attributes of the person."""
data = {ATTR_EDITABLE: self._editable, ATTR_ID: self.unique_id}
if self._latitude is not None:
data[ATTR_LATITUDE] = self._latitude
if self._longitude is not None:
data[ATTR_LONGITUDE] = ... | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"{",
"ATTR_EDITABLE",
":",
"self",
".",
"_editable",
",",
"ATTR_ID",
":",
"self",
".",
"unique_id",
"}",
"if",
"self",
".",
"_latitude",
"is",
"not",
"None",
":",
"data",
"[",
"ATTR_LATITUDE"... | [
397,
4
] | [
411,
19
] | python | en | ['en', 'en', 'en'] | True |
Person.unique_id | (self) | Return a unique ID for the person. | Return a unique ID for the person. | def unique_id(self):
"""Return a unique ID for the person."""
return self._config[CONF_ID] | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_ID",
"]"
] | [
414,
4
] | [
416,
36
] | python | en | ['en', 'it', 'en'] | True |
Person.async_added_to_hass | (self) | Register device trackers. | Register device trackers. | async def async_added_to_hass(self):
"""Register device trackers."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state:
self._parse_source_state(state)
if self.hass.is_running:
# Update person now if hass is already ru... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
":",
"self",
".",
"_parse_source_state",
"(",... | [
418,
4
] | [
436,
13
] | python | en | ['da', 'en', 'en'] | True |
Person.async_update_config | (self, config) | Handle when the config is updated. | Handle when the config is updated. | async def async_update_config(self, config):
"""Handle when the config is updated."""
self._config = config
if self._unsub_track_device is not None:
self._unsub_track_device()
self._unsub_track_device = None
trackers = self._config[CONF_DEVICE_TRACKERS]
... | [
"async",
"def",
"async_update_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_config",
"=",
"config",
"if",
"self",
".",
"_unsub_track_device",
"is",
"not",
"None",
":",
"self",
".",
"_unsub_track_device",
"(",
")",
"self",
".",
"_unsub_track_d... | [
438,
4
] | [
455,
28
] | python | en | ['en', 'en', 'en'] | True |
Person._async_handle_tracker_update | (self, event) | Handle the device tracker state changes. | Handle the device tracker state changes. | def _async_handle_tracker_update(self, event):
"""Handle the device tracker state changes."""
self._update_state() | [
"def",
"_async_handle_tracker_update",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_update_state",
"(",
")"
] | [
458,
4
] | [
460,
28
] | python | en | ['en', 'en', 'en'] | True |
Person._update_state | (self) | Update the state. | Update the state. | def _update_state(self):
"""Update the state."""
latest_non_gps_home = latest_not_home = latest_gps = latest = None
for entity_id in self._config[CONF_DEVICE_TRACKERS]:
state = self.hass.states.get(entity_id)
if not state or state.state in IGNORE_STATES:
... | [
"def",
"_update_state",
"(",
"self",
")",
":",
"latest_non_gps_home",
"=",
"latest_not_home",
"=",
"latest_gps",
"=",
"latest",
"=",
"None",
"for",
"entity_id",
"in",
"self",
".",
"_config",
"[",
"CONF_DEVICE_TRACKERS",
"]",
":",
"state",
"=",
"self",
".",
"... | [
463,
4
] | [
495,
35
] | python | en | ['en', 'en', 'en'] | True |
Person._parse_source_state | (self, state) | Parse source state and set person attributes.
This is a device tracker state or the restored person state.
| Parse source state and set person attributes. | def _parse_source_state(self, state):
"""Parse source state and set person attributes.
This is a device tracker state or the restored person state.
"""
self._state = state.state
self._source = state.entity_id
self._latitude = state.attributes.get(ATTR_LATITUDE)
s... | [
"def",
"_parse_source_state",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_state",
"=",
"state",
".",
"state",
"self",
".",
"_source",
"=",
"state",
".",
"entity_id",
"self",
".",
"_latitude",
"=",
"state",
".",
"attributes",
".",
"get",
"(",
"A... | [
498,
4
] | [
507,
68
] | python | en | ['en', 'en', 'en'] | True |
test_admin_policy | () | Test admin policy works. | Test admin policy works. | def test_admin_policy():
"""Test admin policy works."""
# Make sure it's valid
POLICY_SCHEMA(system_policies.ADMIN_POLICY)
perms = PolicyPermissions(system_policies.ADMIN_POLICY, None)
assert perms.check_entity("light.kitchen", "read")
assert perms.check_entity("light.kitchen", "control")
a... | [
"def",
"test_admin_policy",
"(",
")",
":",
"# Make sure it's valid",
"POLICY_SCHEMA",
"(",
"system_policies",
".",
"ADMIN_POLICY",
")",
"perms",
"=",
"PolicyPermissions",
"(",
"system_policies",
".",
"ADMIN_POLICY",
",",
"None",
")",
"assert",
"perms",
".",
"check_e... | [
8,
0
] | [
16,
54
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.