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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ConfigFlowHandler._already_configured | (self, user_input: Dict[str, Any]) | See if we already have a router matching user input configured. | See if we already have a router matching user input configured. | def _already_configured(self, user_input: Dict[str, Any]) -> bool:
"""See if we already have a router matching user input configured."""
existing_urls = {
url_normalize(entry.data[CONF_URL], default_scheme="http")
for entry in self._async_current_entries()
}
retur... | [
"def",
"_already_configured",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"existing_urls",
"=",
"{",
"url_normalize",
"(",
"entry",
".",
"data",
"[",
"CONF_URL",
"]",
",",
"default_scheme",
"=",
"\"ht... | [
103,
4
] | [
109,
52
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlowHandler.async_step_user | (
self, user_input: Optional[Dict[str, Any]] = None
) | Handle user initiated config flow. | Handle user initiated config flow. | async def async_step_user(
self, user_input: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""Handle user initiated config flow."""
if user_input is None:
return await self._async_show_user_form()
errors = {}
# Normalize URL
user_input[CONF_URL] =... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"a... | [
111,
4
] | [
225,
68
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlowHandler.async_step_ssdp | ( # type: ignore # mypy says signature incompatible with supertype, but it's the same?
self, discovery_info: Dict[str, Any]
) | Handle SSDP initiated config flow. | Handle SSDP initiated config flow. | async def async_step_ssdp( # type: ignore # mypy says signature incompatible with supertype, but it's the same?
self, discovery_info: Dict[str, Any]
) -> Dict[str, Any]:
"""Handle SSDP initiated config flow."""
await self.async_set_unique_id(discovery_info[ssdp.ATTR_UPNP_UDN])
self... | [
"async",
"def",
"async_step_ssdp",
"(",
"# type: ignore # mypy says signature incompatible with supertype, but it's the same?",
"self",
",",
"discovery_info",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"await",
"s... | [
227,
4
] | [
260,
59
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
266,
4
] | [
268,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (
self, user_input: Optional[Dict[str, Any]] = None
) | Handle options flow. | Handle options flow. | async def async_step_init(
self, user_input: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""Handle options flow."""
# Recipients are persisted as a list, but handled as comma separated string in UI
if user_input is not None:
# Preserve existing options, for exa... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# Recipients are persisted as a list, but handled as comma sep... | [
270,
4
] | [
302,
76
] | python | en | ['en', 'nl', 'en'] | True |
TestCitibike.test_trips_without_shortage | (self) | Normal case without shortage, case_1 | Normal case without shortage, case_1 | def test_trips_without_shortage(self):
"""Normal case without shortage, case_1"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
eb, be = setup_case("case_1", max_tick=10)
next_step(eb, be, 0)
station_num = len(b... | [
"def",
"test_trips_without_shortage",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"eb",
",",
"be",
"=",
"setup_case",
"(",
"\"case_1\"",
",",
"max_t... | [
48,
4
] | [
108,
75
] | python | en | ['en', 'en', 'en'] | True |
TestCitibike.test_trips_on_multiple_epsiode | (self) | Test if total trips of multiple episodes with same config are same | Test if total trips of multiple episodes with same config are same | def test_trips_on_multiple_epsiode(self):
"""Test if total trips of multiple episodes with same config are same"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
max_ep = 100
eb, be = setup_case("case_1", max_tick=100)
... | [
"def",
"test_trips_on_multiple_epsiode",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"max_ep",
"=",
"100",
"eb",
",",
"be",
"=",
"setup_case",
"(",
... | [
110,
4
] | [
137,
66
] | python | en | ['en', 'en', 'en'] | True |
TestCitibike.test_trips_with_shortage | (self) | Test if shortage states correct | Test if shortage states correct | def test_trips_with_shortage(self):
"""Test if shortage states correct"""
for backend_name in backends_to_test:
os.environ["DEFAULT_BACKEND_NAME"] = backend_name
eb, be = setup_case("case_2", max_tick=5)
stations_snapshots = be.snapshots["stations"]
be_... | [
"def",
"test_trips_with_shortage",
"(",
"self",
")",
":",
"for",
"backend_name",
"in",
"backends_to_test",
":",
"os",
".",
"environ",
"[",
"\"DEFAULT_BACKEND_NAME\"",
"]",
"=",
"backend_name",
"eb",
",",
"be",
"=",
"setup_case",
"(",
"\"case_2\"",
",",
"max_tick... | [
139,
4
] | [
166,
52
] | python | en | ['en', 'zu', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Zigbee Home Automation binary sensor from config entry. | Set up the Zigbee Home Automation binary sensor from config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Zigbee Home Automation binary sensor from config entry."""
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
unsub = async_dispatcher_connect(
hass,
SIGNAL_ADD_ENTITIES,
functools.partial(
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities_to_create",
"=",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]",
"[",
"DOMAIN",
"]",
"unsub",
"=",
"async_dispatcher_connect",
"(",
"hass",
",",
"S... | [
49,
0
] | [
60,
59
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.__init__ | (self, unique_id, zha_device, channels, **kwargs) | Initialize the ZHA binary sensor. | Initialize the ZHA binary sensor. | def __init__(self, unique_id, zha_device, channels, **kwargs):
"""Initialize the ZHA binary sensor."""
super().__init__(unique_id, zha_device, channels, **kwargs)
self._channel = channels[0]
self._device_class = self.DEVICE_CLASS | [
"def",
"__init__",
"(",
"self",
",",
"unique_id",
",",
"zha_device",
",",
"channels",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"unique_id",
",",
"zha_device",
",",
"channels",
",",
"*",
"*",
"kwargs",
")",
"self",
"... | [
69,
4
] | [
73,
46
] | python | en | ['en', 'zh-Latn', 'en'] | True |
BinarySensor.get_device_class | (self) | Get the HA device class from the channel. | Get the HA device class from the channel. | async def get_device_class(self):
"""Get the HA device class from the channel.""" | [
"async",
"def",
"get_device_class",
"(",
"self",
")",
":"
] | [
75,
4
] | [
76,
55
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_added_to_hass | (self) | Run when about to be added to hass. | Run when about to be added to hass. | async def async_added_to_hass(self):
"""Run when about to be added to hass."""
await super().async_added_to_hass()
await self.get_device_class()
self.async_accept_signal(
self._channel, SIGNAL_ATTR_UPDATED, self.async_set_state
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"get_device_class",
"(",
")",
"self",
".",
"async_accept_signal",
"(",
"self",
".",
"_channel",
",",
"SIGNAL... | [
78,
4
] | [
84,
9
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_restore_last_state | (self, last_state) | Restore previous state. | Restore previous state. | def async_restore_last_state(self, last_state):
"""Restore previous state."""
super().async_restore_last_state(last_state)
self._state = last_state.state == STATE_ON | [
"def",
"async_restore_last_state",
"(",
"self",
",",
"last_state",
")",
":",
"super",
"(",
")",
".",
"async_restore_last_state",
"(",
"last_state",
")",
"self",
".",
"_state",
"=",
"last_state",
".",
"state",
"==",
"STATE_ON"
] | [
87,
4
] | [
90,
50
] | python | it | ['it', 'it', 'en'] | True |
BinarySensor.is_on | (self) | Return True if the switch is on based on the state machine. | Return True if the switch is on based on the state machine. | def is_on(self) -> bool:
"""Return True if the switch is on based on the state machine."""
if self._state is None:
return False
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_state"
] | [
93,
4
] | [
97,
26
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.device_class | (self) | Return device class from component DEVICE_CLASSES. | Return device class from component DEVICE_CLASSES. | def device_class(self) -> str:
"""Return device class from component DEVICE_CLASSES."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device_class"
] | [
100,
4
] | [
102,
33
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_set_state | (self, attr_id, attr_name, value) | Set the state. | Set the state. | def async_set_state(self, attr_id, attr_name, value):
"""Set the state."""
if self.SENSOR_ATTR is None or self.SENSOR_ATTR != attr_name:
return
self._state = bool(value)
self.async_write_ha_state() | [
"def",
"async_set_state",
"(",
"self",
",",
"attr_id",
",",
"attr_name",
",",
"value",
")",
":",
"if",
"self",
".",
"SENSOR_ATTR",
"is",
"None",
"or",
"self",
".",
"SENSOR_ATTR",
"!=",
"attr_name",
":",
"return",
"self",
".",
"_state",
"=",
"bool",
"(",
... | [
105,
4
] | [
110,
35
] | python | en | ['en', 'en', 'en'] | True |
BinarySensor.async_update | (self) | Attempt to retrieve on off state from the binary sensor. | Attempt to retrieve on off state from the binary sensor. | async def async_update(self):
"""Attempt to retrieve on off state from the binary sensor."""
await super().async_update()
attribute = getattr(self._channel, "value_attribute", "on_off")
attr_value = await self._channel.get_attribute_value(attribute)
if attr_value is not None:
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_update",
"(",
")",
"attribute",
"=",
"getattr",
"(",
"self",
".",
"_channel",
",",
"\"value_attribute\"",
",",
"\"on_off\"",
")",
"attr_value",
"=",
"await",
"se... | [
112,
4
] | [
118,
36
] | python | en | ['en', 'en', 'en'] | True |
load_xsum_checkpoint | (checkpoint_path) | Checkpoint path should end in model.pt | Checkpoint path should end in model.pt | def load_xsum_checkpoint(checkpoint_path):
"""Checkpoint path should end in model.pt"""
sd = torch.load(checkpoint_path, map_location="cpu")
hub_interface = torch.hub.load("pytorch/fairseq", "bart.large.cnn").eval()
hub_interface.model.load_state_dict(sd["model"])
return hub_interface | [
"def",
"load_xsum_checkpoint",
"(",
"checkpoint_path",
")",
":",
"sd",
"=",
"torch",
".",
"load",
"(",
"checkpoint_path",
",",
"map_location",
"=",
"\"cpu\"",
")",
"hub_interface",
"=",
"torch",
".",
"hub",
".",
"load",
"(",
"\"pytorch/fairseq\"",
",",
"\"bart... | [
72,
0
] | [
77,
24
] | python | en | ['en', 'en', 'en'] | True |
convert_bart_checkpoint | (checkpoint_path, pytorch_dump_folder_path, hf_checkpoint_name=None) |
Copy/paste/tweak model's weights to our BERT structure.
|
Copy/paste/tweak model's weights to our BERT structure.
| def convert_bart_checkpoint(checkpoint_path, pytorch_dump_folder_path, hf_checkpoint_name=None):
"""
Copy/paste/tweak model's weights to our BERT structure.
"""
if not os.path.exists(checkpoint_path):
bart = torch.hub.load("pytorch/fairseq", checkpoint_path).eval()
else:
bart = load_... | [
"def",
"convert_bart_checkpoint",
"(",
"checkpoint_path",
",",
"pytorch_dump_folder_path",
",",
"hf_checkpoint_name",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"checkpoint_path",
")",
":",
"bart",
"=",
"torch",
".",
"hub",
".",... | [
88,
0
] | [
135,
51
] | python | en | ['en', 'error', 'th'] | False |
LcnServiceCall.__init__ | (self, hass) | Initialize service call. | Initialize service call. | def __init__(self, hass):
"""Initialize service call."""
self.connections = hass.data[DATA_LCN][CONF_CONNECTIONS] | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"self",
".",
"connections",
"=",
"hass",
".",
"data",
"[",
"DATA_LCN",
"]",
"[",
"CONF_CONNECTIONS",
"]"
] | [
54,
4
] | [
56,
64
] | python | en | ['en', 'en', 'en'] | True |
LcnServiceCall.get_address_connection | (self, call) | Get address connection object. | Get address connection object. | def get_address_connection(self, call):
"""Get address connection object."""
addr, connection_id = call.data[CONF_ADDRESS]
addr = pypck.lcn_addr.LcnAddr(*addr)
if connection_id is None:
connection = self.connections[0]
else:
connection = get_connection(sel... | [
"def",
"get_address_connection",
"(",
"self",
",",
"call",
")",
":",
"addr",
",",
"connection_id",
"=",
"call",
".",
"data",
"[",
"CONF_ADDRESS",
"]",
"addr",
"=",
"pypck",
".",
"lcn_addr",
".",
"LcnAddr",
"(",
"*",
"addr",
")",
"if",
"connection_id",
"i... | [
58,
4
] | [
67,
48
] | python | en | ['en', 'en', 'en'] | True |
OutputAbs.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
output = pypck.lcn_defs.OutputPort[call.data[CONF_OUTPUT]]
brightness = call.data[CONF_BRIGHTNESS]
transition = pypck.lcn_defs.time_to_ramp_value(
call.data[CONF_TRANSITION] * 1000
)
address_connection = s... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"OutputPort",
"[",
"call",
".",
"data",
"[",
"CONF_OUTPUT",
"]",
"]",
"brightness",
"=",
"call",
".",
"data",
"[",
"CONF_BRIGHTNESS",
"]",
"transition",
... | [
85,
4
] | [
94,
75
] | python | en | ['ro', 'gl', 'en'] | False |
OutputRel.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
output = pypck.lcn_defs.OutputPort[call.data[CONF_OUTPUT]]
brightness = call.data[CONF_BRIGHTNESS]
address_connection = self.get_address_connection(call)
address_connection.rel_output(output.value, brightness) | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"OutputPort",
"[",
"call",
".",
"data",
"[",
"CONF_OUTPUT",
"]",
"]",
"brightness",
"=",
"call",
".",
"data",
"[",
"CONF_BRIGHTNESS",
"]",
"address_conne... | [
109,
4
] | [
115,
63
] | python | en | ['ro', 'gl', 'en'] | False |
OutputToggle.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
output = pypck.lcn_defs.OutputPort[call.data[CONF_OUTPUT]]
transition = pypck.lcn_defs.time_to_ramp_value(
call.data[CONF_TRANSITION] * 1000
)
address_connection = self.get_address_connection(call)
address... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"output",
"=",
"pypck",
".",
"lcn_defs",
".",
"OutputPort",
"[",
"call",
".",
"data",
"[",
"CONF_OUTPUT",
"]",
"]",
"transition",
"=",
"pypck",
".",
"lcn_defs",
".",
"time_to_ramp_value",
"(",
"call"... | [
130,
4
] | [
138,
66
] | python | en | ['ro', 'gl', 'en'] | False |
Relays.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
states = [
pypck.lcn_defs.RelayStateModifier[state] for state in call.data[CONF_STATE]
]
address_connection = self.get_address_connection(call)
address_connection.control_relays(states) | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"RelayStateModifier",
"[",
"state",
"]",
"for",
"state",
"in",
"call",
".",
"data",
"[",
"CONF_STATE",
"]",
"]",
"address_connection",
"=",
"self",
... | [
148,
4
] | [
155,
49
] | python | en | ['ro', 'gl', 'en'] | False |
Led.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
led = pypck.lcn_defs.LedPort[call.data[CONF_LED]]
led_state = pypck.lcn_defs.LedStatus[call.data[CONF_STATE]]
address_connection = self.get_address_connection(call)
address_connection.control_led(led, led_state) | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"led",
"=",
"pypck",
".",
"lcn_defs",
".",
"LedPort",
"[",
"call",
".",
"data",
"[",
"CONF_LED",
"]",
"]",
"led_state",
"=",
"pypck",
".",
"lcn_defs",
".",
"LedStatus",
"[",
"call",
".",
"data",
... | [
168,
4
] | [
174,
54
] | python | en | ['ro', 'gl', 'en'] | False |
VarAbs.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
var = pypck.lcn_defs.Var[call.data[CONF_VARIABLE]]
value = call.data[CONF_VALUE]
unit = pypck.lcn_defs.VarUnit.parse(call.data[CONF_UNIT_OF_MEASUREMENT])
address_connection = self.get_address_connection(call)
address_... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"var",
"=",
"pypck",
".",
"lcn_defs",
".",
"Var",
"[",
"call",
".",
"data",
"[",
"CONF_VARIABLE",
"]",
"]",
"value",
"=",
"call",
".",
"data",
"[",
"CONF_VALUE",
"]",
"unit",
"=",
"pypck",
".",... | [
196,
4
] | [
203,
52
] | python | en | ['ro', 'gl', 'en'] | False |
VarReset.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
var = pypck.lcn_defs.Var[call.data[CONF_VARIABLE]]
address_connection = self.get_address_connection(call)
address_connection.var_reset(var) | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"var",
"=",
"pypck",
".",
"lcn_defs",
".",
"Var",
"[",
"call",
".",
"data",
"[",
"CONF_VARIABLE",
"]",
"]",
"address_connection",
"=",
"self",
".",
"get_address_connection",
"(",
"call",
")",
"addres... | [
213,
4
] | [
218,
41
] | python | en | ['ro', 'gl', 'en'] | False |
VarRel.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
var = pypck.lcn_defs.Var[call.data[CONF_VARIABLE]]
value = call.data[CONF_VALUE]
unit = pypck.lcn_defs.VarUnit.parse(call.data[CONF_UNIT_OF_MEASUREMENT])
value_ref = pypck.lcn_defs.RelVarRef[call.data[CONF_RELVARREF]]
... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"var",
"=",
"pypck",
".",
"lcn_defs",
".",
"Var",
"[",
"call",
".",
"data",
"[",
"CONF_VARIABLE",
"]",
"]",
"value",
"=",
"call",
".",
"data",
"[",
"CONF_VALUE",
"]",
"unit",
"=",
"pypck",
".",... | [
239,
4
] | [
247,
63
] | python | en | ['ro', 'gl', 'en'] | False |
LockRegulator.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
setpoint = pypck.lcn_defs.Var[call.data[CONF_SETPOINT]]
state = call.data[CONF_STATE]
reg_id = pypck.lcn_defs.Var.to_set_point_id(setpoint)
address_connection = self.get_address_connection(call)
address_connection.loc... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"setpoint",
"=",
"pypck",
".",
"lcn_defs",
".",
"Var",
"[",
"call",
".",
"data",
"[",
"CONF_SETPOINT",
"]",
"]",
"state",
"=",
"call",
".",
"data",
"[",
"CONF_STATE",
"]",
"reg_id",
"=",
"pypck",... | [
260,
4
] | [
267,
56
] | python | en | ['ro', 'gl', 'en'] | False |
SendKeys.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
address_connection = self.get_address_connection(call)
keys = [[False] * 8 for i in range(4)]
key_strings = zip(call.data[CONF_KEYS][::2], call.data[CONF_KEYS][1::2])
for table, key in key_strings:
table_id = or... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"address_connection",
"=",
"self",
".",
"get_address_connection",
"(",
"call",
")",
"keys",
"=",
"[",
"[",
"False",
"]",
"*",
"8",
"for",
"i",
"in",
"range",
"(",
"4",
")",
"]",
"key_strings",
"=... | [
288,
4
] | [
312,
53
] | python | en | ['ro', 'gl', 'en'] | False |
LockKeys.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
address_connection = self.get_address_connection(call)
states = [
pypck.lcn_defs.KeyLockStateModifier[state]
for state in call.data[CONF_STATE]
]
table_id = ord(call.data[CONF_TABLE]) - 65
del... | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"address_connection",
"=",
"self",
".",
"get_address_connection",
"(",
"call",
")",
"states",
"=",
"[",
"pypck",
".",
"lcn_defs",
".",
"KeyLockStateModifier",
"[",
"state",
"]",
"for",
"state",
"in",
"... | [
331,
4
] | [
352,
63
] | python | en | ['ro', 'gl', 'en'] | False |
DynText.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
row_id = call.data[CONF_ROW] - 1
text = call.data[CONF_TEXT]
address_connection = self.get_address_connection(call)
address_connection.dyn_text(row_id, text) | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"row_id",
"=",
"call",
".",
"data",
"[",
"CONF_ROW",
"]",
"-",
"1",
"text",
"=",
"call",
".",
"data",
"[",
"CONF_TEXT",
"]",
"address_connection",
"=",
"self",
".",
"get_address_connection",
"(",
"... | [
365,
4
] | [
371,
49
] | python | en | ['ro', 'gl', 'en'] | False |
Pck.__call__ | (self, call) | Execute service call. | Execute service call. | def __call__(self, call):
"""Execute service call."""
pck = call.data[CONF_PCK]
address_connection = self.get_address_connection(call)
address_connection.pck(pck) | [
"def",
"__call__",
"(",
"self",
",",
"call",
")",
":",
"pck",
"=",
"call",
".",
"data",
"[",
"CONF_PCK",
"]",
"address_connection",
"=",
"self",
".",
"get_address_connection",
"(",
"call",
")",
"address_connection",
".",
"pck",
"(",
"pck",
")"
] | [
379,
4
] | [
383,
35
] | python | en | ['ro', 'gl', 'en'] | False |
PlexServer.__init__ | (
self, hass, server_config, known_server_id=None, options=None, entry_id=None
) | Initialize a Plex server instance. | Initialize a Plex server instance. | def __init__(
self, hass, server_config, known_server_id=None, options=None, entry_id=None
):
"""Initialize a Plex server instance."""
self.hass = hass
self.entry_id = entry_id
self._plex_account = None
self._plex_server = None
self._created_clients = set()
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"server_config",
",",
"known_server_id",
"=",
"None",
",",
"options",
"=",
"None",
",",
"entry_id",
"=",
"None",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"entry_id",
"=",
"entry_id",
"se... | [
67,
4
] | [
104,
66
] | python | en | ['en', 'fr', 'en'] | True |
PlexServer.account | (self) | Return a MyPlexAccount instance. | Return a MyPlexAccount instance. | def account(self):
"""Return a MyPlexAccount instance."""
if not self._plex_account and self._use_plex_tv:
try:
self._plex_account = plexapi.myplex.MyPlexAccount(token=self._token)
except (BadRequest, Unauthorized):
self._use_plex_tv = False
... | [
"def",
"account",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_plex_account",
"and",
"self",
".",
"_use_plex_tv",
":",
"try",
":",
"self",
".",
"_plex_account",
"=",
"plexapi",
".",
"myplex",
".",
"MyPlexAccount",
"(",
"token",
"=",
"self",
".",
... | [
107,
4
] | [
116,
33
] | python | en | ['en', 'cy', 'en'] | True |
PlexServer.plextv_clients | (self) | Return available clients linked to Plex account. | Return available clients linked to Plex account. | def plextv_clients(self):
"""Return available clients linked to Plex account."""
if self.account is None:
return []
now = time.time()
if now - self._plextv_client_timestamp > PLEXTV_THROTTLE:
self._plextv_client_timestamp = now
self._plextv_clients = ... | [
"def",
"plextv_clients",
"(",
"self",
")",
":",
"if",
"self",
".",
"account",
"is",
"None",
":",
"return",
"[",
"]",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"now",
"-",
"self",
".",
"_plextv_client_timestamp",
">",
"PLEXTV_THROTTLE",
":",
"sel... | [
118,
4
] | [
134,
35
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.connect | (self) | Connect to a Plex server directly, obtaining direct URL if necessary. | Connect to a Plex server directly, obtaining direct URL if necessary. | def connect(self):
"""Connect to a Plex server directly, obtaining direct URL if necessary."""
config_entry_update_needed = False
def _connect_with_token():
available_servers = [
(x.name, x.clientIdentifier)
for x in self.account.resources()
... | [
"def",
"connect",
"(",
"self",
")",
":",
"config_entry_update_needed",
"=",
"False",
"def",
"_connect_with_token",
"(",
")",
":",
"available_servers",
"=",
"[",
"(",
"x",
".",
"name",
",",
"x",
".",
"clientIdentifier",
")",
"for",
"x",
"in",
"self",
".",
... | [
136,
4
] | [
231,
41
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.async_refresh_entity | (self, machine_identifier, device, session) | Forward refresh dispatch to media_player. | Forward refresh dispatch to media_player. | def async_refresh_entity(self, machine_identifier, device, session):
"""Forward refresh dispatch to media_player."""
unique_id = f"{self.machine_identifier}:{machine_identifier}"
_LOGGER.debug("Refreshing %s", unique_id)
async_dispatcher_send(
self.hass,
PLEX_UPDA... | [
"def",
"async_refresh_entity",
"(",
"self",
",",
"machine_identifier",
",",
"device",
",",
"session",
")",
":",
"unique_id",
"=",
"f\"{self.machine_identifier}:{machine_identifier}\"",
"_LOGGER",
".",
"debug",
"(",
"\"Refreshing %s\"",
",",
"unique_id",
")",
"async_disp... | [
234,
4
] | [
243,
9
] | python | en | ['en', 'en', 'en'] | True |
PlexServer._fetch_platform_data | (self) | Fetch all data from the Plex server in a single method. | Fetch all data from the Plex server in a single method. | def _fetch_platform_data(self):
"""Fetch all data from the Plex server in a single method."""
return (
self._plex_server.clients(),
self._plex_server.sessions(),
self.plextv_clients(),
) | [
"def",
"_fetch_platform_data",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_plex_server",
".",
"clients",
"(",
")",
",",
"self",
".",
"_plex_server",
".",
"sessions",
"(",
")",
",",
"self",
".",
"plextv_clients",
"(",
")",
",",
")"
] | [
245,
4
] | [
251,
9
] | python | en | ['en', 'en', 'en'] | True |
PlexServer._async_update_platforms | (self) | Update the platform entities. | Update the platform entities. | async def _async_update_platforms(self):
"""Update the platform entities."""
_LOGGER.debug("Updating devices")
available_clients = {}
ignored_clients = set()
new_clients = set()
monitored_users = self.accounts
known_accounts = set(self.option_monitored_users)
... | [
"async",
"def",
"_async_update_platforms",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating devices\"",
")",
"available_clients",
"=",
"{",
"}",
"ignored_clients",
"=",
"set",
"(",
")",
"new_clients",
"=",
"set",
"(",
")",
"monitored_users",
"=... | [
253,
4
] | [
439,
9
] | python | en | ['en', 'af', 'en'] | True |
PlexServer.plex_server | (self) | Return the plexapi PlexServer instance. | Return the plexapi PlexServer instance. | def plex_server(self):
"""Return the plexapi PlexServer instance."""
return self._plex_server | [
"def",
"plex_server",
"(",
"self",
")",
":",
"return",
"self",
".",
"_plex_server"
] | [
442,
4
] | [
444,
32
] | python | en | ['en', 'ru-Latn', 'en'] | True |
PlexServer.accounts | (self) | Return accounts associated with the Plex server. | Return accounts associated with the Plex server. | def accounts(self):
"""Return accounts associated with the Plex server."""
return set(self._accounts) | [
"def",
"accounts",
"(",
"self",
")",
":",
"return",
"set",
"(",
"self",
".",
"_accounts",
")"
] | [
447,
4
] | [
449,
34
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.owner | (self) | Return the Plex server owner username. | Return the Plex server owner username. | def owner(self):
"""Return the Plex server owner username."""
return self._owner_username | [
"def",
"owner",
"(",
"self",
")",
":",
"return",
"self",
".",
"_owner_username"
] | [
452,
4
] | [
454,
35
] | python | en | ['en', 'no', 'en'] | True |
PlexServer.version | (self) | Return the version of the Plex server. | Return the version of the Plex server. | def version(self):
"""Return the version of the Plex server."""
return self._version | [
"def",
"version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_version"
] | [
457,
4
] | [
459,
28
] | python | en | ['en', 'sd', 'en'] | True |
PlexServer.friendly_name | (self) | Return name of connected Plex server. | Return name of connected Plex server. | def friendly_name(self):
"""Return name of connected Plex server."""
return self._plex_server.friendlyName | [
"def",
"friendly_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"friendlyName"
] | [
462,
4
] | [
464,
45
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.machine_identifier | (self) | Return unique identifier of connected Plex server. | Return unique identifier of connected Plex server. | def machine_identifier(self):
"""Return unique identifier of connected Plex server."""
return self._plex_server.machineIdentifier | [
"def",
"machine_identifier",
"(",
"self",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"machineIdentifier"
] | [
467,
4
] | [
469,
50
] | python | en | ['en', 'la', 'en'] | True |
PlexServer.url_in_use | (self) | Return URL used for connected Plex server. | Return URL used for connected Plex server. | def url_in_use(self):
"""Return URL used for connected Plex server."""
return self._plex_server._baseurl | [
"def",
"url_in_use",
"(",
"self",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"_baseurl"
] | [
472,
4
] | [
474,
41
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.option_ignore_new_shared_users | (self) | Return ignore_new_shared_users option. | Return ignore_new_shared_users option. | def option_ignore_new_shared_users(self):
"""Return ignore_new_shared_users option."""
return self.options[MP_DOMAIN].get(CONF_IGNORE_NEW_SHARED_USERS, False) | [
"def",
"option_ignore_new_shared_users",
"(",
"self",
")",
":",
"return",
"self",
".",
"options",
"[",
"MP_DOMAIN",
"]",
".",
"get",
"(",
"CONF_IGNORE_NEW_SHARED_USERS",
",",
"False",
")"
] | [
477,
4
] | [
479,
79
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.option_use_episode_art | (self) | Return use_episode_art option. | Return use_episode_art option. | def option_use_episode_art(self):
"""Return use_episode_art option."""
return self.options[MP_DOMAIN].get(CONF_USE_EPISODE_ART, False) | [
"def",
"option_use_episode_art",
"(",
"self",
")",
":",
"return",
"self",
".",
"options",
"[",
"MP_DOMAIN",
"]",
".",
"get",
"(",
"CONF_USE_EPISODE_ART",
",",
"False",
")"
] | [
482,
4
] | [
484,
71
] | python | da | ['nl', 'da', 'en'] | False |
PlexServer.option_monitored_users | (self) | Return dict of monitored users option. | Return dict of monitored users option. | def option_monitored_users(self):
"""Return dict of monitored users option."""
return self.options[MP_DOMAIN].get(CONF_MONITORED_USERS, {}) | [
"def",
"option_monitored_users",
"(",
"self",
")",
":",
"return",
"self",
".",
"options",
"[",
"MP_DOMAIN",
"]",
".",
"get",
"(",
"CONF_MONITORED_USERS",
",",
"{",
"}",
")"
] | [
487,
4
] | [
489,
68
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.option_ignore_plexweb_clients | (self) | Return ignore_plex_web_clients option. | Return ignore_plex_web_clients option. | def option_ignore_plexweb_clients(self):
"""Return ignore_plex_web_clients option."""
return self.options[MP_DOMAIN].get(CONF_IGNORE_PLEX_WEB_CLIENTS, False) | [
"def",
"option_ignore_plexweb_clients",
"(",
"self",
")",
":",
"return",
"self",
".",
"options",
"[",
"MP_DOMAIN",
"]",
".",
"get",
"(",
"CONF_IGNORE_PLEX_WEB_CLIENTS",
",",
"False",
")"
] | [
492,
4
] | [
494,
79
] | python | en | ['en', 'fr', 'en'] | True |
PlexServer.library | (self) | Return library attribute from server object. | Return library attribute from server object. | def library(self):
"""Return library attribute from server object."""
return self._plex_server.library | [
"def",
"library",
"(",
"self",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"library"
] | [
497,
4
] | [
499,
40
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.playlist | (self, title) | Return playlist from server object. | Return playlist from server object. | def playlist(self, title):
"""Return playlist from server object."""
return self._plex_server.playlist(title) | [
"def",
"playlist",
"(",
"self",
",",
"title",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"playlist",
"(",
"title",
")"
] | [
501,
4
] | [
503,
48
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.playlists | (self) | Return available playlists from server object. | Return available playlists from server object. | def playlists(self):
"""Return available playlists from server object."""
return self._plex_server.playlists() | [
"def",
"playlists",
"(",
"self",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"playlists",
"(",
")"
] | [
505,
4
] | [
507,
44
] | python | en | ['en', 'en', 'en'] | True |
PlexServer.create_playqueue | (self, media, **kwargs) | Create playqueue on Plex server. | Create playqueue on Plex server. | def create_playqueue(self, media, **kwargs):
"""Create playqueue on Plex server."""
return plexapi.playqueue.PlayQueue.create(self._plex_server, media, **kwargs) | [
"def",
"create_playqueue",
"(",
"self",
",",
"media",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"plexapi",
".",
"playqueue",
".",
"PlayQueue",
".",
"create",
"(",
"self",
".",
"_plex_server",
",",
"media",
",",
"*",
"*",
"kwargs",
")"
] | [
509,
4
] | [
511,
85
] | python | en | ['en', 'et', 'en'] | True |
PlexServer.fetch_item | (self, item) | Fetch item from Plex server. | Fetch item from Plex server. | def fetch_item(self, item):
"""Fetch item from Plex server."""
return self._plex_server.fetchItem(item) | [
"def",
"fetch_item",
"(",
"self",
",",
"item",
")",
":",
"return",
"self",
".",
"_plex_server",
".",
"fetchItem",
"(",
"item",
")"
] | [
513,
4
] | [
515,
48
] | python | en | ['en', 'mt', 'en'] | True |
PlexServer.lookup_media | (self, media_type, **kwargs) | Lookup a piece of media. | Lookup a piece of media. | def lookup_media(self, media_type, **kwargs):
"""Lookup a piece of media."""
media_type = media_type.lower()
if isinstance(kwargs.get("plex_key"), int):
key = kwargs["plex_key"]
try:
return self.fetch_item(key)
except NotFound:
... | [
"def",
"lookup_media",
"(",
"self",
",",
"media_type",
",",
"*",
"*",
"kwargs",
")",
":",
"media_type",
"=",
"media_type",
".",
"lower",
"(",
")",
"if",
"isinstance",
"(",
"kwargs",
".",
"get",
"(",
"\"plex_key\"",
")",
",",
"int",
")",
":",
"key",
"... | [
517,
4
] | [
572,
23
] | python | en | ['en', 'es', 'en'] | True |
build_tf_to_pytorch_map | (model, config) |
A map of modules from TF to PyTorch. This time I use a map to keep the PyTorch model as identical to the original
PyTorch model as possible.
|
A map of modules from TF to PyTorch. This time I use a map to keep the PyTorch model as identical to the original
PyTorch model as possible.
| def build_tf_to_pytorch_map(model, config):
"""
A map of modules from TF to PyTorch. This time I use a map to keep the PyTorch model as identical to the original
PyTorch model as possible.
"""
tf_to_pt_map = {}
if hasattr(model, "transformer"):
# We are loading in a TransfoXLLMHeadModel... | [
"def",
"build_tf_to_pytorch_map",
"(",
"model",
",",
"config",
")",
":",
"tf_to_pt_map",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"model",
",",
"\"transformer\"",
")",
":",
"# We are loading in a TransfoXLLMHeadModel => we will load also the Adaptive Softmax",
"tf_to_pt_map",
... | [
51,
0
] | [
116,
23
] | python | en | ['en', 'error', 'th'] | False |
load_tf_weights_in_transfo_xl | (model, config, tf_path) | Load tf checkpoints in a pytorch model | Load tf checkpoints in a pytorch model | def load_tf_weights_in_transfo_xl(model, config, tf_path):
"""Load tf checkpoints in a pytorch model"""
try:
import numpy as np
import tensorflow as tf
except ImportError:
logger.error(
"Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please s... | [
"def",
"load_tf_weights_in_transfo_xl",
"(",
"model",
",",
"config",
",",
"tf_path",
")",
":",
"try",
":",
"import",
"numpy",
"as",
"np",
"import",
"tensorflow",
"as",
"tf",
"except",
"ImportError",
":",
"logger",
".",
"error",
"(",
"\"Loading a TensorFlow model... | [
119,
0
] | [
175,
16
] | python | en | ['en', 'en', 'en'] | True |
TransfoXLPreTrainedModel._init_weights | (self, m) | Initialize the weights. | Initialize the weights. | def _init_weights(self, m):
"""Initialize the weights."""
classname = m.__class__.__name__
if classname.find("Linear") != -1:
if hasattr(m, "weight") and m.weight is not None:
self._init_weight(m.weight)
if hasattr(m, "bias") and m.bias is not None:
... | [
"def",
"_init_weights",
"(",
"self",
",",
"m",
")",
":",
"classname",
"=",
"m",
".",
"__class__",
".",
"__name__",
"if",
"classname",
".",
"find",
"(",
"\"Linear\"",
")",
"!=",
"-",
"1",
":",
"if",
"hasattr",
"(",
"m",
",",
"\"weight\"",
")",
"and",
... | [
483,
4
] | [
521,
41
] | python | en | ['en', 'en', 'en'] | True |
TransfoXLPreTrainedModel.resize_token_embeddings | (self, new_num_tokens: Optional[int] = None, layer: Optional[int] = -1) |
Resize input token embeddings matrix of the model if new_num_tokens != config.vocab_size. Take care of tying
weights embeddings afterwards if the model class has a `tie_weights()` method.
Arguments:
new_num_tokens: (`optional`) int:
New number of tokens in the embe... |
Resize input token embeddings matrix of the model if new_num_tokens != config.vocab_size. Take care of tying
weights embeddings afterwards if the model class has a `tie_weights()` method. | def resize_token_embeddings(self, new_num_tokens: Optional[int] = None, layer: Optional[int] = -1):
"""
Resize input token embeddings matrix of the model if new_num_tokens != config.vocab_size. Take care of tying
weights embeddings afterwards if the model class has a `tie_weights()` method.
... | [
"def",
"resize_token_embeddings",
"(",
"self",
",",
"new_num_tokens",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"layer",
":",
"Optional",
"[",
"int",
"]",
"=",
"-",
"1",
")",
":",
"base_model",
"=",
"getattr",
"(",
"self",
",",
"self",
".",
... | [
523,
4
] | [
561,
27
] | python | en | ['en', 'error', 'th'] | False |
test_reload | (hass) | Verify we can reload history_stats sensors. | Verify we can reload history_stats sensors. | async def test_reload(hass):
"""Verify we can reload history_stats sensors."""
await hass.async_add_executor_job(
init_recorder_component, hass
) # force in memory db
hass.state = ha.CoreState.not_running
hass.states.async_set("binary_sensor.test_id", "on")
await async_setup_component... | [
"async",
"def",
"test_reload",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"init_recorder_component",
",",
"hass",
")",
"# force in memory db",
"hass",
".",
"state",
"=",
"ha",
".",
"CoreState",
".",
"not_running",
"hass",
".",
... | [
262,
0
] | [
310,
48
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.setUp | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.addCleanup(self.hass.stop) | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"addCleanup",
"(",
"self",
".",
"hass",
".",
"stop",
")"
] | [
25,
4
] | [
28,
39
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.test_setup | (self) | Test the history statistics sensor setup. | Test the history statistics sensor setup. | def test_setup(self):
"""Test the history statistics sensor setup."""
self.init_recorder()
config = {
"history": {},
"sensor": {
"platform": "history_stats",
"entity_id": "binary_sensor.test_id",
"state": "on",
... | [
"def",
"test_setup",
"(",
"self",
")",
":",
"self",
".",
"init_recorder",
"(",
")",
"config",
"=",
"{",
"\"history\"",
":",
"{",
"}",
",",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"history_stats\"",
",",
"\"entity_id\"",
":",
"\"binary_sensor.test_id\"",... | [
30,
4
] | [
50,
43
] | python | en | ['en', 'bs', 'en'] | True |
TestHistoryStatsSensor.test_period_parsing | (self, mock) | Test the conversion from templates to period. | Test the conversion from templates to period. | def test_period_parsing(self, mock):
"""Test the conversion from templates to period."""
now = datetime(2019, 1, 1, 23, 30, 0, tzinfo=pytz.utc)
with patch("homeassistant.util.dt.now", return_value=now):
today = Template(
"{{ now().replace(hour=0).replace(minute=0).rep... | [
"def",
"test_period_parsing",
"(",
"self",
",",
"mock",
")",
":",
"now",
"=",
"datetime",
"(",
"2019",
",",
"1",
",",
"1",
",",
"23",
",",
"30",
",",
"0",
",",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"with",
"patch",
"(",
"\"homeassistant.util.dt.now... | [
56,
4
] | [
96,
38
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.test_measure | (self) | Test the history statistics sensor measure. | Test the history statistics sensor measure. | def test_measure(self):
"""Test the history statistics sensor measure."""
t0 = dt_util.utcnow() - timedelta(minutes=40)
t1 = t0 + timedelta(minutes=20)
t2 = dt_util.utcnow() - timedelta(minutes=10)
# Start t0 t1 t2 End
# |--20min--|--20min--|--10... | [
"def",
"test_measure",
"(",
"self",
")",
":",
"t0",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"minutes",
"=",
"40",
")",
"t1",
"=",
"t0",
"+",
"timedelta",
"(",
"minutes",
"=",
"20",
")",
"t2",
"=",
"dt_util",
".",
"utcnow",
... | [
98,
4
] | [
152,
34
] | python | en | ['en', 'et', 'en'] | True |
TestHistoryStatsSensor.test_wrong_date | (self) | Test when start or end value is not a timestamp or a date. | Test when start or end value is not a timestamp or a date. | def test_wrong_date(self):
"""Test when start or end value is not a timestamp or a date."""
good = Template("{{ now() }}", self.hass)
bad = Template("{{ TEST }}", self.hass)
sensor1 = HistoryStatsSensor(
self.hass, "test", "on", good, bad, None, "time", "Test"
)
... | [
"def",
"test_wrong_date",
"(",
"self",
")",
":",
"good",
"=",
"Template",
"(",
"\"{{ now() }}\"",
",",
"self",
".",
"hass",
")",
"bad",
"=",
"Template",
"(",
"\"{{ TEST }}\"",
",",
"self",
".",
"hass",
")",
"sensor1",
"=",
"HistoryStatsSensor",
"(",
"self"... | [
154,
4
] | [
173,
48
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.test_wrong_duration | (self) | Test when duration value is not a timedelta. | Test when duration value is not a timedelta. | def test_wrong_duration(self):
"""Test when duration value is not a timedelta."""
self.init_recorder()
config = {
"history": {},
"sensor": {
"platform": "history_stats",
"entity_id": "binary_sensor.test_id",
"name": "Test",
... | [
"def",
"test_wrong_duration",
"(",
"self",
")",
":",
"self",
".",
"init_recorder",
"(",
")",
"config",
"=",
"{",
"\"history\"",
":",
"{",
"}",
",",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"history_stats\"",
",",
"\"entity_id\"",
":",
"\"binary_sensor.te... | [
175,
4
] | [
193,
58
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.test_bad_template | (self) | Test Exception when the template cannot be parsed. | Test Exception when the template cannot be parsed. | def test_bad_template(self):
"""Test Exception when the template cannot be parsed."""
bad = Template("{{ x - 12 }}", self.hass) # x is undefined
duration = "01:00"
sensor1 = HistoryStatsSensor(
self.hass, "test", "on", bad, None, duration, "time", "Test"
)
s... | [
"def",
"test_bad_template",
"(",
"self",
")",
":",
"bad",
"=",
"Template",
"(",
"\"{{ x - 12 }}\"",
",",
"self",
".",
"hass",
")",
"# x is undefined",
"duration",
"=",
"\"01:00\"",
"sensor1",
"=",
"HistoryStatsSensor",
"(",
"self",
".",
"hass",
",",
"\"test\""... | [
195,
4
] | [
214,
48
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.test_not_enough_arguments | (self) | Test config when not enough arguments provided. | Test config when not enough arguments provided. | def test_not_enough_arguments(self):
"""Test config when not enough arguments provided."""
self.init_recorder()
config = {
"history": {},
"sensor": {
"platform": "history_stats",
"entity_id": "binary_sensor.test_id",
"name":... | [
"def",
"test_not_enough_arguments",
"(",
"self",
")",
":",
"self",
".",
"init_recorder",
"(",
")",
"config",
"=",
"{",
"\"history\"",
":",
"{",
"}",
",",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"history_stats\"",
",",
"\"entity_id\"",
":",
"\"binary_sen... | [
216,
4
] | [
233,
58
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.test_too_many_arguments | (self) | Test config when too many arguments provided. | Test config when too many arguments provided. | def test_too_many_arguments(self):
"""Test config when too many arguments provided."""
self.init_recorder()
config = {
"history": {},
"sensor": {
"platform": "history_stats",
"entity_id": "binary_sensor.test_id",
"name": "Te... | [
"def",
"test_too_many_arguments",
"(",
"self",
")",
":",
"self",
".",
"init_recorder",
"(",
")",
"config",
"=",
"{",
"\"history\"",
":",
"{",
"}",
",",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"history_stats\"",
",",
"\"entity_id\"",
":",
"\"binary_senso... | [
235,
4
] | [
254,
58
] | python | en | ['en', 'en', 'en'] | True |
TestHistoryStatsSensor.init_recorder | (self) | Initialize the recorder. | Initialize the recorder. | def init_recorder(self):
"""Initialize the recorder."""
init_recorder_component(self.hass)
self.hass.start() | [
"def",
"init_recorder",
"(",
"self",
")",
":",
"init_recorder_component",
"(",
"self",
".",
"hass",
")",
"self",
".",
"hass",
".",
"start",
"(",
")"
] | [
256,
4
] | [
259,
25
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the velux component. | Set up the velux component. | async def async_setup(hass, config):
"""Set up the velux component."""
try:
hass.data[DATA_VELUX] = VeluxModule(hass, config[DOMAIN])
hass.data[DATA_VELUX].setup()
await hass.data[DATA_VELUX].async_start()
except PyVLXException as ex:
_LOGGER.exception("Can't connect to velu... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"try",
":",
"hass",
".",
"data",
"[",
"DATA_VELUX",
"]",
"=",
"VeluxModule",
"(",
"hass",
",",
"config",
"[",
"DOMAIN",
"]",
")",
"hass",
".",
"data",
"[",
"DATA_VELUX",
"]",
".",
... | [
25,
0
] | [
40,
15
] | python | en | ['en', 'en', 'en'] | True |
VeluxModule.__init__ | (self, hass, domain_config) | Initialize for velux component. | Initialize for velux component. | def __init__(self, hass, domain_config):
"""Initialize for velux component."""
self.pyvlx = None
self._hass = hass
self._domain_config = domain_config | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"domain_config",
")",
":",
"self",
".",
"pyvlx",
"=",
"None",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_domain_config",
"=",
"domain_config"
] | [
46,
4
] | [
50,
43
] | python | en | ['da', 'en', 'en'] | True |
VeluxModule.setup | (self) | Velux component setup. | Velux component setup. | def setup(self):
"""Velux component setup."""
async def on_hass_stop(event):
"""Close connection when hass stops."""
_LOGGER.debug("Velux interface terminated")
await self.pyvlx.disconnect()
self._hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_... | [
"def",
"setup",
"(",
"self",
")",
":",
"async",
"def",
"on_hass_stop",
"(",
"event",
")",
":",
"\"\"\"Close connection when hass stops.\"\"\"",
"_LOGGER",
".",
"debug",
"(",
"\"Velux interface terminated\"",
")",
"await",
"self",
".",
"pyvlx",
".",
"disconnect",
"... | [
52,
4
] | [
63,
56
] | python | en | ['en', 'da', 'en'] | True |
VeluxModule.async_start | (self) | Start velux component. | Start velux component. | async def async_start(self):
"""Start velux component."""
_LOGGER.debug("Velux interface started")
await self.pyvlx.load_scenes()
await self.pyvlx.load_nodes() | [
"async",
"def",
"async_start",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Velux interface started\"",
")",
"await",
"self",
".",
"pyvlx",
".",
"load_scenes",
"(",
")",
"await",
"self",
".",
"pyvlx",
".",
"load_nodes",
"(",
")"
] | [
65,
4
] | [
69,
37
] | python | de | ['mt', 'de', 'tr'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Load Tradfri lights based on a config entry. | Load Tradfri lights based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Load Tradfri lights based on a config entry."""
gateway_id = config_entry.data[CONF_GATEWAY_ID]
tradfri_data = hass.data[DOMAIN][config_entry.entry_id]
api = tradfri_data[KEY_API]
devices = tradfri_data[DEVICES]
lights = [d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"gateway_id",
"=",
"config_entry",
".",
"data",
"[",
"CONF_GATEWAY_ID",
"]",
"tradfri_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_... | [
30,
0
] | [
44,
88
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.__init__ | (self, device, api, gateway_id) | Initialize a Group. | Initialize a Group. | def __init__(self, device, api, gateway_id):
"""Initialize a Group."""
super().__init__(device, api, gateway_id)
self._unique_id = f"group-{gateway_id}-{device.id}"
self._refresh(device) | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"api",
",",
"gateway_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"api",
",",
"gateway_id",
")",
"self",
".",
"_unique_id",
"=",
"f\"group-{gateway_id}-{device.id}\"",
"self",
".... | [
50,
4
] | [
56,
29
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.should_poll | (self) | Poll needed for tradfri groups. | Poll needed for tradfri groups. | def should_poll(self):
"""Poll needed for tradfri groups."""
return True | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"True"
] | [
59,
4
] | [
61,
19
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.async_update | (self) | Fetch new state data for the group.
This method is required for groups to update properly.
| Fetch new state data for the group. | async def async_update(self):
"""Fetch new state data for the group.
This method is required for groups to update properly.
"""
await self._api(self._device.update()) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device",
".",
"update",
"(",
")",
")"
] | [
63,
4
] | [
68,
46
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORTED_GROUP_FEATURES | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORTED_GROUP_FEATURES"
] | [
71,
4
] | [
73,
39
] | python | en | ['da', 'en', 'en'] | True |
TradfriGroup.is_on | (self) | Return true if group lights are on. | Return true if group lights are on. | def is_on(self):
"""Return true if group lights are on."""
return self._device.state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state"
] | [
76,
4
] | [
78,
33
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.brightness | (self) | Return the brightness of the group lights. | Return the brightness of the group lights. | def brightness(self):
"""Return the brightness of the group lights."""
return self._device.dimmer | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"dimmer"
] | [
81,
4
] | [
83,
34
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.async_turn_off | (self, **kwargs) | Instruct the group lights to turn off. | Instruct the group lights to turn off. | async def async_turn_off(self, **kwargs):
"""Instruct the group lights to turn off."""
await self._api(self._device.set_state(0)) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_api",
"(",
"self",
".",
"_device",
".",
"set_state",
"(",
"0",
")",
")"
] | [
85,
4
] | [
87,
50
] | python | en | ['en', 'en', 'en'] | True |
TradfriGroup.async_turn_on | (self, **kwargs) | Instruct the group lights to turn on, or dim. | Instruct the group lights to turn on, or dim. | async def async_turn_on(self, **kwargs):
"""Instruct the group lights to turn on, or dim."""
keys = {}
if ATTR_TRANSITION in kwargs:
keys["transition_time"] = int(kwargs[ATTR_TRANSITION]) * 10
if ATTR_BRIGHTNESS in kwargs:
if kwargs[ATTR_BRIGHTNESS] == 255:
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"keys",
"=",
"{",
"}",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"keys",
"[",
"\"transition_time\"",
"]",
"=",
"int",
"(",
"kwargs",
"[",
"ATTR_TRANSITION",
"]",
")",
... | [
89,
4
] | [
101,
54
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.__init__ | (self, device, api, gateway_id) | Initialize a Light. | Initialize a Light. | def __init__(self, device, api, gateway_id):
"""Initialize a Light."""
super().__init__(device, api, gateway_id)
self._unique_id = f"light-{gateway_id}-{device.id}"
self._hs_color = None
# Calculate supported features
_features = SUPPORTED_LIGHT_FEATURES
if devic... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"api",
",",
"gateway_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"api",
",",
"gateway_id",
")",
"self",
".",
"_unique_id",
"=",
"f\"light-{gateway_id}-{device.id}\"",
"self",
".... | [
107,
4
] | [
123,
29
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.min_mireds | (self) | Return the coldest color_temp that this light supports. | Return the coldest color_temp that this light supports. | def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
return self._device_control.min_mireds | [
"def",
"min_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_control",
".",
"min_mireds"
] | [
126,
4
] | [
128,
46
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.max_mireds | (self) | Return the warmest color_temp that this light supports. | Return the warmest color_temp that this light supports. | def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
return self._device_control.max_mireds | [
"def",
"max_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_control",
".",
"max_mireds"
] | [
131,
4
] | [
133,
46
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return self._features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_features"
] | [
136,
4
] | [
138,
29
] | python | en | ['da', 'en', 'en'] | True |
TradfriLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self):
"""Return true if light is on."""
return self._device_data.state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_data",
".",
"state"
] | [
141,
4
] | [
143,
38
] | python | en | ['en', 'et', 'en'] | True |
TradfriLight.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self):
"""Return the brightness of the light."""
return self._device_data.dimmer | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_data",
".",
"dimmer"
] | [
146,
4
] | [
148,
39
] | python | en | ['en', 'no', 'en'] | True |
TradfriLight.color_temp | (self) | Return the color temp value in mireds. | Return the color temp value in mireds. | def color_temp(self):
"""Return the color temp value in mireds."""
return self._device_data.color_temp | [
"def",
"color_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_data",
".",
"color_temp"
] | [
151,
4
] | [
153,
43
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.hs_color | (self) | HS color of the light. | HS color of the light. | def hs_color(self):
"""HS color of the light."""
if self._device_control.can_set_color:
hsbxy = self._device_data.hsb_xy_color
hue = hsbxy[0] / (self._device_control.max_hue / 360)
sat = hsbxy[1] / (self._device_control.max_saturation / 100)
if hue is not ... | [
"def",
"hs_color",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_control",
".",
"can_set_color",
":",
"hsbxy",
"=",
"self",
".",
"_device_data",
".",
"hsb_xy_color",
"hue",
"=",
"hsbxy",
"[",
"0",
"]",
"/",
"(",
"self",
".",
"_device_control",
".",
... | [
156,
4
] | [
163,
31
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.async_turn_off | (self, **kwargs) | Instruct the light to turn off. | Instruct the light to turn off. | async def async_turn_off(self, **kwargs):
"""Instruct the light to turn off."""
# This allows transitioning to off, but resets the brightness
# to 1 for the next set_state(True) command
transition_time = None
if ATTR_TRANSITION in kwargs:
transition_time = int(kwargs[... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# This allows transitioning to off, but resets the brightness",
"# to 1 for the next set_state(True) command",
"transition_time",
"=",
"None",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"t... | [
165,
4
] | [
176,
66
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight.async_turn_on | (self, **kwargs) | Instruct the light to turn on. | Instruct the light to turn on. | async def async_turn_on(self, **kwargs):
"""Instruct the light to turn on."""
transition_time = None
if ATTR_TRANSITION in kwargs:
transition_time = int(kwargs[ATTR_TRANSITION]) * 10
dimmer_command = None
if ATTR_BRIGHTNESS in kwargs:
brightness = kwargs[... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"transition_time",
"=",
"None",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"transition_time",
"=",
"int",
"(",
"kwargs",
"[",
"ATTR_TRANSITION",
"]",
")",
"*",
"10",
"dimme... | [
178,
4
] | [
257,
40
] | python | en | ['en', 'en', 'en'] | True |
TradfriLight._refresh | (self, device) | Refresh the light data. | Refresh the light data. | def _refresh(self, device):
"""Refresh the light data."""
super()._refresh(device)
# Caching of LightControl and light object
self._device_control = device.light_control
self._device_data = device.light_control.lights[0] | [
"def",
"_refresh",
"(",
"self",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"_refresh",
"(",
"device",
")",
"# Caching of LightControl and light object",
"self",
".",
"_device_control",
"=",
"device",
".",
"light_control",
"self",
".",
"_device_data",
"=",
... | [
259,
4
] | [
265,
58
] | python | en | ['en', 'no', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Ebus sensor. | Set up the Ebus sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Ebus sensor."""
ebusd_api = hass.data[DOMAIN]
monitored_conditions = discovery_info["monitored_conditions"]
name = discovery_info["client_name"]
dev = []
for condition in monitored_conditions:
dev.append(... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"ebusd_api",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"monitored_conditions",
"=",
"discovery_info",
"[",
"\"monitored_conditions\"",
"]"... | [
21,
0
] | [
33,
27
] | python | en | ['en', 'pt', 'en'] | True |
EbusdSensor.__init__ | (self, data, sensor, name) | Initialize the sensor. | Initialize the sensor. | def __init__(self, data, sensor, name):
"""Initialize the sensor."""
self._state = None
self._client_name = name
self._name, self._unit_of_measurement, self._icon, self._type = sensor
self.data = data | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"sensor",
",",
"name",
")",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_client_name",
"=",
"name",
"self",
".",
"_name",
",",
"self",
".",
"_unit_of_measurement",
",",
"self",
".",
"_icon",
... | [
39,
4
] | [
44,
24
] | python | en | ['en', 'en', 'en'] | True |
EbusdSensor.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}\""
] | [
47,
4
] | [
49,
50
] | python | en | ['en', 'mi', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.