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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
LcnRegulatorLockSensor.input_received | (self, input_obj) | Set sensor value when LCN input object (command) is received. | Set sensor value when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set sensor value when LCN input object (command) is received."""
if (
not isinstance(input_obj, pypck.inputs.ModStatusVar)
or input_obj.get_var() != self.setpoint_variable
):
return
self._value = input_obj.get_v... | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusVar",
")",
"or",
"input_obj",
".",
"get_var",
"(",
")",
"!=",
"self",
".",
"setpoint_variable",
... | [
61,
4
] | [
70,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnBinarySensor.__init__ | (self, config, address_connection) | Initialize the LCN binary sensor. | Initialize the LCN binary sensor. | def __init__(self, config, address_connection):
"""Initialize the LCN binary sensor."""
super().__init__(config, address_connection)
self.bin_sensor_port = pypck.lcn_defs.BinSensorPort[config[CONF_SOURCE]]
self._value = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"bin_sensor_port",
"=",
"pypck",
".",
"lcn_defs",
".",
"BinSensorPort",
"[",
... | [
76,
4
] | [
82,
26
] | python | en | ['en', 'zh-Latn', 'en'] | True |
LcnBinarySensor.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(
self.bin_sensor_port
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"bin_sensor_port",
")"
] | [
84,
4
] | [
89,
9
] | python | en | ['en', 'en', 'en'] | True |
LcnBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._value | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value"
] | [
92,
4
] | [
94,
26
] | python | en | ['en', 'fy', 'en'] | True |
LcnBinarySensor.input_received | (self, input_obj) | Set sensor value when LCN input object (command) is received. | Set sensor value when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set sensor value when LCN input object (command) is received."""
if not isinstance(input_obj, pypck.inputs.ModStatusBinSensors):
return
self._value = input_obj.get_state(self.bin_sensor_port.value)
self.async_write_ha_state() | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusBinSensors",
")",
":",
"return",
"self",
".",
"_value",
"=",
"input_obj",
".",
"get_state",
"(",
"sel... | [
96,
4
] | [
102,
35
] | python | en | ['en', 'en', 'en'] | True |
LcnLockKeysSensor.__init__ | (self, config, address_connection) | Initialize the LCN sensor. | Initialize the LCN sensor. | def __init__(self, config, address_connection):
"""Initialize the LCN sensor."""
super().__init__(config, address_connection)
self.source = pypck.lcn_defs.Key[config[CONF_SOURCE]]
self._value = None | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"address_connection",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config",
",",
"address_connection",
")",
"self",
".",
"source",
"=",
"pypck",
".",
"lcn_defs",
".",
"Key",
"[",
"config",
"[",
... | [
108,
4
] | [
113,
26
] | python | en | ['en', 'fy', 'en'] | True |
LcnLockKeysSensor.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
await super().async_added_to_hass()
await self.address_connection.activate_status_request_handler(self.source) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"address_connection",
".",
"activate_status_request_handler",
"(",
"self",
".",
"source",
")"
] | [
115,
4
] | [
118,
82
] | python | en | ['en', 'en', 'en'] | True |
LcnLockKeysSensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._value | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value"
] | [
121,
4
] | [
123,
26
] | python | en | ['en', 'fy', 'en'] | True |
LcnLockKeysSensor.input_received | (self, input_obj) | Set sensor value when LCN input object (command) is received. | Set sensor value when LCN input object (command) is received. | def input_received(self, input_obj):
"""Set sensor value when LCN input object (command) is received."""
if (
not isinstance(input_obj, pypck.inputs.ModStatusKeyLocks)
or self.source not in pypck.lcn_defs.Key
):
return
table_id = ord(self.source.name[... | [
"def",
"input_received",
"(",
"self",
",",
"input_obj",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"input_obj",
",",
"pypck",
".",
"inputs",
".",
"ModStatusKeyLocks",
")",
"or",
"self",
".",
"source",
"not",
"in",
"pypck",
".",
"lcn_defs",
".",
"Key"... | [
125,
4
] | [
137,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the deCONZ sensors. | Set up the deCONZ sensors. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the deCONZ sensors."""
gateway = get_gateway_from_config_entry(hass, config_entry)
gateway.entities[DOMAIN] = set()
battery_handler = DeconzBatteryHandler(gateway)
@callback
def async_add_sensor(sensors):
""... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"gateway",
".",
"entities",
"[",
"DOMAIN",
"]",
"=",
"set",
"(",
... | [
70,
0
] | [
121,
5
] | python | en | ['en', 'ca', 'en'] | True |
DeconzSensor.async_update_callback | (self, force_update=False) | Update the sensor's state. | Update the sensor's state. | def async_update_callback(self, force_update=False):
"""Update the sensor's state."""
keys = {"on", "reachable", "state"}
if force_update or self._device.changed_keys.intersection(keys):
super().async_update_callback(force_update=force_update) | [
"def",
"async_update_callback",
"(",
"self",
",",
"force_update",
"=",
"False",
")",
":",
"keys",
"=",
"{",
"\"on\"",
",",
"\"reachable\"",
",",
"\"state\"",
"}",
"if",
"force_update",
"or",
"self",
".",
"_device",
".",
"changed_keys",
".",
"intersection",
"... | [
130,
4
] | [
134,
68
] | python | en | ['en', 'en', 'en'] | True |
DeconzSensor.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._device.state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state"
] | [
137,
4
] | [
139,
33
] | python | en | ['en', 'en', 'en'] | True |
DeconzSensor.device_class | (self) | Return the class of the sensor. | Return the class of the sensor. | def device_class(self):
"""Return the class of the sensor."""
return DEVICE_CLASS.get(type(self._device)) | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS",
".",
"get",
"(",
"type",
"(",
"self",
".",
"_device",
")",
")"
] | [
142,
4
] | [
144,
51
] | python | en | ['en', 'pt', 'en'] | True |
DeconzSensor.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return ICON.get(type(self._device)) | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON",
".",
"get",
"(",
"type",
"(",
"self",
".",
"_device",
")",
")"
] | [
147,
4
] | [
149,
43
] | python | en | ['en', 'en', 'en'] | True |
DeconzSensor.unit_of_measurement | (self) | Return the unit of measurement of this sensor. | Return the unit of measurement of this sensor. | def unit_of_measurement(self):
"""Return the unit of measurement of this sensor."""
return UNIT_OF_MEASUREMENT.get(type(self._device)) | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"UNIT_OF_MEASUREMENT",
".",
"get",
"(",
"type",
"(",
"self",
".",
"_device",
")",
")"
] | [
152,
4
] | [
154,
58
] | python | en | ['en', 'id', 'en'] | True |
DeconzSensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
attr = {}
if self._device.on is not None:
attr[ATTR_ON] = self._device.on
if self._device.secondary_temperature is not None:
attr[ATTR_TEMPERATURE] = self._device.secondary_tempe... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"if",
"self",
".",
"_device",
".",
"on",
"is",
"not",
"None",
":",
"attr",
"[",
"ATTR_ON",
"]",
"=",
"self",
".",
"_device",
".",
"on",
"if",
"self",
".",
"_device",
".... | [
157,
4
] | [
185,
19
] | python | en | ['en', 'en', 'en'] | True |
DeconzBattery.async_update_callback | (self, force_update=False) | Update the battery's state, if needed. | Update the battery's state, if needed. | def async_update_callback(self, force_update=False):
"""Update the battery's state, if needed."""
keys = {"battery", "reachable"}
if force_update or self._device.changed_keys.intersection(keys):
super().async_update_callback(force_update=force_update) | [
"def",
"async_update_callback",
"(",
"self",
",",
"force_update",
"=",
"False",
")",
":",
"keys",
"=",
"{",
"\"battery\"",
",",
"\"reachable\"",
"}",
"if",
"force_update",
"or",
"self",
".",
"_device",
".",
"changed_keys",
".",
"intersection",
"(",
"keys",
"... | [
194,
4
] | [
198,
68
] | python | en | ['en', 'en', 'en'] | True |
DeconzBattery.unique_id | (self) | Return a unique identifier for this device. | Return a unique identifier for this device. | def unique_id(self):
"""Return a unique identifier for this device."""
return f"{self.serial}-battery" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.serial}-battery\""
] | [
201,
4
] | [
203,
39
] | python | en | ['en', 'en', 'en'] | True |
DeconzBattery.state | (self) | Return the state of the battery. | Return the state of the battery. | def state(self):
"""Return the state of the battery."""
return self._device.battery | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"battery"
] | [
206,
4
] | [
208,
35
] | python | en | ['en', 'en', 'en'] | True |
DeconzBattery.name | (self) | Return the name of the battery. | Return the name of the battery. | def name(self):
"""Return the name of the battery."""
return f"{self._device.name} Battery Level" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._device.name} Battery Level\""
] | [
211,
4
] | [
213,
51
] | python | en | ['en', 'en', 'en'] | True |
DeconzBattery.device_class | (self) | Return the class of the sensor. | Return the class of the sensor. | def device_class(self):
"""Return the class of the sensor."""
return DEVICE_CLASS_BATTERY | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_BATTERY"
] | [
216,
4
] | [
218,
35
] | python | en | ['en', 'pt', 'en'] | True |
DeconzBattery.unit_of_measurement | (self) | Return the unit of measurement of this entity. | Return the unit of measurement of this entity. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity."""
return PERCENTAGE | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"PERCENTAGE"
] | [
221,
4
] | [
223,
25
] | python | en | ['en', 'en', 'en'] | True |
DeconzBattery.device_state_attributes | (self) | Return the state attributes of the battery. | Return the state attributes of the battery. | def device_state_attributes(self):
"""Return the state attributes of the battery."""
attr = {}
if self._device.type in Switch.ZHATYPE:
for event in self.gateway.events:
if self._device == event.device:
attr[ATTR_EVENT_ID] = event.event_id
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"if",
"self",
".",
"_device",
".",
"type",
"in",
"Switch",
".",
"ZHATYPE",
":",
"for",
"event",
"in",
"self",
".",
"gateway",
".",
"events",
":",
"if",
"self",
".",
"_dev... | [
226,
4
] | [
235,
19
] | python | en | ['en', 'en', 'en'] | True |
DeconzSensorStateTracker.__init__ | (self, sensor, gateway) | Set up tracker. | Set up tracker. | def __init__(self, sensor, gateway):
"""Set up tracker."""
self.sensor = sensor
self.gateway = gateway
sensor.register_callback(self.async_update_callback) | [
"def",
"__init__",
"(",
"self",
",",
"sensor",
",",
"gateway",
")",
":",
"self",
".",
"sensor",
"=",
"sensor",
"self",
".",
"gateway",
"=",
"gateway",
"sensor",
".",
"register_callback",
"(",
"self",
".",
"async_update_callback",
")"
] | [
241,
4
] | [
245,
60
] | python | en | ['en', 'ko', 'en'] | True |
DeconzSensorStateTracker.close | (self) | Clean up tracker. | Clean up tracker. | def close(self):
"""Clean up tracker."""
self.sensor.remove_callback(self.async_update_callback)
self.gateway = None
self.sensor = None | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"sensor",
".",
"remove_callback",
"(",
"self",
".",
"async_update_callback",
")",
"self",
".",
"gateway",
"=",
"None",
"self",
".",
"sensor",
"=",
"None"
] | [
248,
4
] | [
252,
26
] | python | en | ['en', 'en', 'en'] | True |
DeconzSensorStateTracker.async_update_callback | (self, ignore_update=False) | Sensor state updated. | Sensor state updated. | def async_update_callback(self, ignore_update=False):
"""Sensor state updated."""
if "battery" in self.sensor.changed_keys:
async_dispatcher_send(
self.gateway.hass,
self.gateway.async_signal_new_device(NEW_SENSOR),
[self.sensor],
) | [
"def",
"async_update_callback",
"(",
"self",
",",
"ignore_update",
"=",
"False",
")",
":",
"if",
"\"battery\"",
"in",
"self",
".",
"sensor",
".",
"changed_keys",
":",
"async_dispatcher_send",
"(",
"self",
".",
"gateway",
".",
"hass",
",",
"self",
".",
"gatew... | [
255,
4
] | [
262,
13
] | python | en | ['en', 'hr', 'en'] | True |
DeconzBatteryHandler.__init__ | (self, gateway) | Set up battery handler. | Set up battery handler. | def __init__(self, gateway):
"""Set up battery handler."""
self.gateway = gateway
self._trackers = set() | [
"def",
"__init__",
"(",
"self",
",",
"gateway",
")",
":",
"self",
".",
"gateway",
"=",
"gateway",
"self",
".",
"_trackers",
"=",
"set",
"(",
")"
] | [
268,
4
] | [
271,
30
] | python | en | ['en', 'da', 'en'] | True |
DeconzBatteryHandler.create_tracker | (self, sensor) | Create new tracker for battery state. | Create new tracker for battery state. | def create_tracker(self, sensor):
"""Create new tracker for battery state."""
for tracker in self._trackers:
if sensor == tracker.sensor:
return
self._trackers.add(DeconzSensorStateTracker(sensor, self.gateway)) | [
"def",
"create_tracker",
"(",
"self",
",",
"sensor",
")",
":",
"for",
"tracker",
"in",
"self",
".",
"_trackers",
":",
"if",
"sensor",
"==",
"tracker",
".",
"sensor",
":",
"return",
"self",
".",
"_trackers",
".",
"add",
"(",
"DeconzSensorStateTracker",
"(",... | [
274,
4
] | [
279,
74
] | python | en | ['en', 'en', 'en'] | True |
DeconzBatteryHandler.remove_tracker | (self, sensor) | Remove tracker of battery state. | Remove tracker of battery state. | def remove_tracker(self, sensor):
"""Remove tracker of battery state."""
for tracker in self._trackers:
if sensor == tracker.sensor:
tracker.close()
self._trackers.remove(tracker)
break | [
"def",
"remove_tracker",
"(",
"self",
",",
"sensor",
")",
":",
"for",
"tracker",
"in",
"self",
".",
"_trackers",
":",
"if",
"sensor",
"==",
"tracker",
".",
"sensor",
":",
"tracker",
".",
"close",
"(",
")",
"self",
".",
"_trackers",
".",
"remove",
"(",
... | [
282,
4
] | [
288,
21
] | python | en | ['en', 'en', 'en'] | True |
test_reproducing_states | (hass, caplog) | Test reproducing Counter states. | Test reproducing Counter states. | async def test_reproducing_states(hass, caplog):
"""Test reproducing Counter states."""
hass.states.async_set("counter.entity", "5", {})
hass.states.async_set(
"counter.entity_attr",
"8",
{"initial": 12, "minimum": 5, "maximum": 15, "step": 3},
)
configure_calls = async_mock... | [
"async",
"def",
"test_reproducing_states",
"(",
"hass",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"counter.entity\"",
",",
"\"5\"",
",",
"{",
"}",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"counter.entity_attr\"",
",... | [
6,
0
] | [
68,
37
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Volvo On Call component. | Set up the Volvo On Call component. | async def async_setup(hass, config):
"""Set up the Volvo On Call component."""
session = async_get_clientsession(hass)
connection = Connection(
session=session,
username=config[DOMAIN].get(CONF_USERNAME),
password=config[DOMAIN].get(CONF_PASSWORD),
service_url=config[DOMAIN]... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
")",
"connection",
"=",
"Connection",
"(",
"session",
"=",
"session",
",",
"username",
"=",
"config",
"[",
"DOMAIN",
"]",
".",
"get... | [
116,
0
] | [
181,
33
] | python | en | ['en', 'en', 'en'] | True |
VolvoData.__init__ | (self, config) | Initialize the component state. | Initialize the component state. | def __init__(self, config):
"""Initialize the component state."""
self.vehicles = set()
self.instruments = set()
self.config = config[DOMAIN]
self.names = self.config.get(CONF_NAME) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"vehicles",
"=",
"set",
"(",
")",
"self",
".",
"instruments",
"=",
"set",
"(",
")",
"self",
".",
"config",
"=",
"config",
"[",
"DOMAIN",
"]",
"self",
".",
"names",
"=",
"self",
... | [
187,
4
] | [
192,
47
] | python | en | ['en', 'en', 'en'] | True |
VolvoData.instrument | (self, vin, component, attr) | Return corresponding instrument. | Return corresponding instrument. | def instrument(self, vin, component, attr):
"""Return corresponding instrument."""
return next(
(
instrument
for instrument in self.instruments
if instrument.vehicle.vin == vin
and instrument.component == component
... | [
"def",
"instrument",
"(",
"self",
",",
"vin",
",",
"component",
",",
"attr",
")",
":",
"return",
"next",
"(",
"(",
"instrument",
"for",
"instrument",
"in",
"self",
".",
"instruments",
"if",
"instrument",
".",
"vehicle",
".",
"vin",
"==",
"vin",
"and",
... | [
194,
4
] | [
205,
9
] | python | en | ['en', 'no', 'en'] | True |
VolvoData.vehicle_name | (self, vehicle) | Provide a friendly name for a vehicle. | Provide a friendly name for a vehicle. | def vehicle_name(self, vehicle):
"""Provide a friendly name for a vehicle."""
if (
vehicle.registration_number and vehicle.registration_number.lower()
) in self.names:
return self.names[vehicle.registration_number.lower()]
if vehicle.vin and vehicle.vin.lower() in... | [
"def",
"vehicle_name",
"(",
"self",
",",
"vehicle",
")",
":",
"if",
"(",
"vehicle",
".",
"registration_number",
"and",
"vehicle",
".",
"registration_number",
".",
"lower",
"(",
")",
")",
"in",
"self",
".",
"names",
":",
"return",
"self",
".",
"names",
"[... | [
207,
4
] | [
219,
17
] | python | en | ['en', 'en', 'en'] | True |
VolvoEntity.__init__ | (self, data, vin, component, attribute) | Initialize the entity. | Initialize the entity. | def __init__(self, data, vin, component, attribute):
"""Initialize the entity."""
self.data = data
self.vin = vin
self.component = component
self.attribute = attribute | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"vin",
",",
"component",
",",
"attribute",
")",
":",
"self",
".",
"data",
"=",
"data",
"self",
".",
"vin",
"=",
"vin",
"self",
".",
"component",
"=",
"component",
"self",
".",
"attribute",
"=",
"attri... | [
225,
4
] | [
230,
34
] | python | en | ['en', 'en', 'en'] | True |
VolvoEntity.async_added_to_hass | (self) | Register update dispatcher. | Register update dispatcher. | async def async_added_to_hass(self):
"""Register update dispatcher."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_STATE_UPDATED, self.async_write_ha_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_STATE_UPDATED",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
232,
4
] | [
238,
9
] | python | de | ['it', 'de', 'en'] | False |
VolvoEntity.instrument | (self) | Return corresponding instrument. | Return corresponding instrument. | def instrument(self):
"""Return corresponding instrument."""
return self.data.instrument(self.vin, self.component, self.attribute) | [
"def",
"instrument",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
".",
"instrument",
"(",
"self",
".",
"vin",
",",
"self",
".",
"component",
",",
"self",
".",
"attribute",
")"
] | [
241,
4
] | [
243,
77
] | python | en | ['en', 'no', 'en'] | True |
VolvoEntity.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
return self.instrument.icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"instrument",
".",
"icon"
] | [
246,
4
] | [
248,
35
] | python | en | ['en', 'sr', 'en'] | True |
VolvoEntity.vehicle | (self) | Return vehicle. | Return vehicle. | def vehicle(self):
"""Return vehicle."""
return self.instrument.vehicle | [
"def",
"vehicle",
"(",
"self",
")",
":",
"return",
"self",
".",
"instrument",
".",
"vehicle"
] | [
251,
4
] | [
253,
38
] | python | en | ['en', 'et', 'en'] | False |
VolvoEntity.name | (self) | Return full name of the entity. | Return full name of the entity. | def name(self):
"""Return full name of the entity."""
return f"{self._vehicle_name} {self._entity_name}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._vehicle_name} {self._entity_name}\""
] | [
264,
4
] | [
266,
58
] | python | en | ['en', 'ig', 'en'] | True |
VolvoEntity.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
269,
4
] | [
271,
20
] | python | en | ['en', 'en', 'en'] | True |
VolvoEntity.assumed_state | (self) | Return true if unable to access real state of entity. | Return true if unable to access real state of entity. | def assumed_state(self):
"""Return true if unable to access real state of entity."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
274,
4
] | [
276,
19
] | python | en | ['en', 'en', 'en'] | True |
VolvoEntity.device_state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def device_state_attributes(self):
"""Return device specific state attributes."""
return dict(
self.instrument.attributes,
model=f"{self.vehicle.vehicle_type}/{self.vehicle.model_year}",
) | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"self",
".",
"instrument",
".",
"attributes",
",",
"model",
"=",
"f\"{self.vehicle.vehicle_type}/{self.vehicle.model_year}\"",
",",
")"
] | [
279,
4
] | [
284,
9
] | python | en | ['fr', 'en', 'en'] | True |
VolvoEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self.vin}-{self.component}-{self.attribute}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self.vin}-{self.component}-{self.attribute}\""
] | [
287,
4
] | [
289,
62
] | python | ca | ['fr', 'ca', 'en'] | False |
client_context | () | Return an SSL context for making requests. | Return an SSL context for making requests. | def client_context() -> ssl.SSLContext:
"""Return an SSL context for making requests."""
# Reuse environment variable definition from requests, since it's already a requirement
# If the environment variable has no value, fall back to using certs from certifi package
cafile = environ.get("REQUESTS_CA_BU... | [
"def",
"client_context",
"(",
")",
"->",
"ssl",
".",
"SSLContext",
":",
"# Reuse environment variable definition from requests, since it's already a requirement",
"# If the environment variable has no value, fall back to using certs from certifi package",
"cafile",
"=",
"environ",
".",
... | [
7,
0
] | [
15,
18
] | python | en | ['en', 'en', 'en'] | True |
server_context_modern | () | Return an SSL context following the Mozilla recommendations.
TLS configuration follows the best-practice guidelines specified here:
https://wiki.mozilla.org/Security/Server_Side_TLS
Modern guidelines are followed.
| Return an SSL context following the Mozilla recommendations. | def server_context_modern() -> ssl.SSLContext:
"""Return an SSL context following the Mozilla recommendations.
TLS configuration follows the best-practice guidelines specified here:
https://wiki.mozilla.org/Security/Server_Side_TLS
Modern guidelines are followed.
"""
context = ssl.SSLContext(ss... | [
"def",
"server_context_modern",
"(",
")",
"->",
"ssl",
".",
"SSLContext",
":",
"context",
"=",
"ssl",
".",
"SSLContext",
"(",
"ssl",
".",
"PROTOCOL_TLS",
")",
"# pylint: disable=no-member",
"context",
".",
"options",
"|=",
"(",
"ssl",
".",
"OP_NO_SSLv2",
"|",
... | [
18,
0
] | [
45,
18
] | python | en | ['en', 'en', 'en'] | True |
server_context_intermediate | () | Return an SSL context following the Mozilla recommendations.
TLS configuration follows the best-practice guidelines specified here:
https://wiki.mozilla.org/Security/Server_Side_TLS
Intermediate guidelines are followed.
| Return an SSL context following the Mozilla recommendations. | def server_context_intermediate() -> ssl.SSLContext:
"""Return an SSL context following the Mozilla recommendations.
TLS configuration follows the best-practice guidelines specified here:
https://wiki.mozilla.org/Security/Server_Side_TLS
Intermediate guidelines are followed.
"""
context = ssl.S... | [
"def",
"server_context_intermediate",
"(",
")",
"->",
"ssl",
".",
"SSLContext",
":",
"context",
"=",
"ssl",
".",
"SSLContext",
"(",
"ssl",
".",
"PROTOCOL_TLS",
")",
"# pylint: disable=no-member",
"context",
".",
"options",
"|=",
"(",
"ssl",
".",
"OP_NO_SSLv2",
... | [
48,
0
] | [
97,
18
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Establish connection with Daikin. | Establish connection with Daikin. | async def async_setup(hass, config):
"""Establish connection with Daikin."""
if DOMAIN not in config:
return True
hosts = config[DOMAIN][CONF_HOSTS]
if not hosts:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_I... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"hosts",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_HOSTS",
"]",
"if",
"not",
"hosts",
":",
"hass",
".",
"async_create... | [
47,
0
] | [
65,
15
] | python | en | ['en', 'de', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Establish connection with Daikin. | Establish connection with Daikin. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Establish connection with Daikin."""
conf = entry.data
# For backwards compat, set unique ID
if entry.unique_id is None:
hass.config_entries.async_update_entry(entry, unique_id=conf[KEY_MAC])
elif ".local" in entry.... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"conf",
"=",
"entry",
".",
"data",
"# For backwards compat, set unique ID",
"if",
"entry",
".",
"unique_id",
"is",
"None",
":",
"hass",
".",
... | [
68,
0
] | [
90,
15
] | python | en | ['en', 'de', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
await asyncio.wait(
[
hass.config_entries.async_forward_entry_unload(config_entry, component)
for component in COMPONENT_TYPES
]
)
hass.data[DOMAIN].pop(config_entry.entry_id)
if no... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"await",
"asyncio",
".",
"wait",
"(",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"config_entry",
",",
"component",
")",
"for",
"component",
"in",
... | [
93,
0
] | [
104,
15
] | python | en | ['en', 'es', 'en'] | True |
daikin_api_setup | (hass, host, key, uuid, password) | Create a Daikin instance only once. | Create a Daikin instance only once. | async def daikin_api_setup(hass, host, key, uuid, password):
"""Create a Daikin instance only once."""
session = hass.helpers.aiohttp_client.async_get_clientsession()
try:
with timeout(TIMEOUT):
device = await Appliance.factory(
host, session, key=key, uuid=uuid, passwor... | [
"async",
"def",
"daikin_api_setup",
"(",
"hass",
",",
"host",
",",
"key",
",",
"uuid",
",",
"password",
")",
":",
"session",
"=",
"hass",
".",
"helpers",
".",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
")",
"try",
":",
"with",
"timeout",
"(",
... | [
107,
0
] | [
128,
14
] | python | en | ['en', 'en', 'en'] | True |
DaikinApi.__init__ | (self, device: Appliance) | Initialize the Daikin Handle. | Initialize the Daikin Handle. | def __init__(self, device: Appliance):
"""Initialize the Daikin Handle."""
self.device = device
self.name = device.values.get("name", "Daikin AC")
self.ip_address = device.device_ip
self._available = True | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"Appliance",
")",
":",
"self",
".",
"device",
"=",
"device",
"self",
".",
"name",
"=",
"device",
".",
"values",
".",
"get",
"(",
"\"name\"",
",",
"\"Daikin AC\"",
")",
"self",
".",
"ip_address",
"=",
... | [
134,
4
] | [
139,
30
] | python | en | ['en', 'zh-Latn', 'en'] | True |
DaikinApi.async_update | (self, **kwargs) | Pull the latest data from Daikin. | Pull the latest data from Daikin. | async def async_update(self, **kwargs):
"""Pull the latest data from Daikin."""
try:
await self.device.update_status()
self._available = True
except ClientConnectionError:
_LOGGER.warning("Connection failed for %s", self.ip_address)
self._available... | [
"async",
"def",
"async_update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"await",
"self",
".",
"device",
".",
"update_status",
"(",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"ClientConnectionError",
":",
"_LOGGER",
".",
"w... | [
142,
4
] | [
149,
35
] | python | en | ['en', 'ha', 'en'] | True |
DaikinApi.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
152,
4
] | [
154,
30
] | python | en | ['en', 'en', 'en'] | True |
DaikinApi.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
info = self.device.values
return {
"connections": {(CONNECTION_NETWORK_MAC, self.device.mac)},
"manufacturer": "Daikin",
"model": info.get("model"),
"name": info.get("nam... | [
"def",
"device_info",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"device",
".",
"values",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"device",
".",
"mac",
")",
"}",
",",
"\"manufacturer\"",
":",
"\"... | [
157,
4
] | [
166,
9
] | python | en | ['ro', 'fr', 'en'] | False |
async_setup | (hass, config) | Set up the REST command component. | Set up the REST command component. | async def async_setup(hass, config):
"""Set up the REST command component."""
@callback
def async_register_rest_command(name, command_config):
"""Create service for rest command."""
websession = async_get_clientsession(hass, command_config.get(CONF_VERIFY_SSL))
timeout = command_con... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"@",
"callback",
"def",
"async_register_rest_command",
"(",
"name",
",",
"command_config",
")",
":",
"\"\"\"Create service for rest command.\"\"\"",
"websession",
"=",
"async_get_clientsession",
"(",
... | [
56,
0
] | [
154,
15
] | python | en | ['en', 'en', 'en'] | True |
async_get_service | (hass, config, discovery_info=None) | Get the Flock notification service. | Get the Flock notification service. | async def async_get_service(hass, config, discovery_info=None):
"""Get the Flock notification service."""
access_token = config.get(CONF_ACCESS_TOKEN)
url = f"{_RESOURCE}{access_token}"
session = async_get_clientsession(hass)
return FlockNotificationService(url, session) | [
"async",
"def",
"async_get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"access_token",
"=",
"config",
".",
"get",
"(",
"CONF_ACCESS_TOKEN",
")",
"url",
"=",
"f\"{_RESOURCE}{access_token}\"",
"session",
"=",
"async_get_client... | [
18,
0
] | [
24,
49
] | python | en | ['en', 'en', 'en'] | True |
FlockNotificationService.__init__ | (self, url, session) | Initialize the Flock notification service. | Initialize the Flock notification service. | def __init__(self, url, session):
"""Initialize the Flock notification service."""
self._url = url
self._session = session | [
"def",
"__init__",
"(",
"self",
",",
"url",
",",
"session",
")",
":",
"self",
".",
"_url",
"=",
"url",
"self",
".",
"_session",
"=",
"session"
] | [
30,
4
] | [
33,
31
] | python | en | ['en', 'en', 'en'] | True |
FlockNotificationService.async_send_message | (self, message, **kwargs) | Send the message to the user. | Send the message to the user. | async def async_send_message(self, message, **kwargs):
"""Send the message to the user."""
payload = {"text": message}
_LOGGER.debug("Attempting to call Flock at %s", self._url)
try:
with async_timeout.timeout(10):
response = await self._session.post(self._u... | [
"async",
"def",
"async_send_message",
"(",
"self",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"payload",
"=",
"{",
"\"text\"",
":",
"message",
"}",
"_LOGGER",
".",
"debug",
"(",
"\"Attempting to call Flock at %s\"",
",",
"self",
".",
"_url",
")",
"... | [
35,
4
] | [
53,
69
] | python | en | ['en', 'en', 'en'] | True |
test_fetching_url | (aioclient_mock, hass, hass_client) | Test that it fetches the given url. | Test that it fetches the given url. | async def test_fetching_url(aioclient_mock, hass, hass_client):
"""Test that it fetches the given url."""
aioclient_mock.get("http://example.com", text="hello world")
await async_setup_component(
hass,
"camera",
{
"camera": {
"name": "config_test",
... | [
"async",
"def",
"test_fetching_url",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.com\"",
",",
"text",
"=",
"\"hello world\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"cam... | [
17,
0
] | [
46,
41
] | python | en | ['en', 'en', 'en'] | True |
test_fetching_without_verify_ssl | (aioclient_mock, hass, hass_client) | Test that it fetches the given url when ssl verify is off. | Test that it fetches the given url when ssl verify is off. | async def test_fetching_without_verify_ssl(aioclient_mock, hass, hass_client):
"""Test that it fetches the given url when ssl verify is off."""
aioclient_mock.get("https://example.com", text="hello world")
await async_setup_component(
hass,
"camera",
{
"camera": {
... | [
"async",
"def",
"test_fetching_without_verify_ssl",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"https://example.com\"",
",",
"text",
"=",
"\"hello world\"",
")",
"await",
"async_setup_component",
"(",
"hass",... | [
49,
0
] | [
73,
29
] | python | en | ['en', 'en', 'en'] | True |
test_fetching_url_with_verify_ssl | (aioclient_mock, hass, hass_client) | Test that it fetches the given url when ssl verify is explicitly on. | Test that it fetches the given url when ssl verify is explicitly on. | async def test_fetching_url_with_verify_ssl(aioclient_mock, hass, hass_client):
"""Test that it fetches the given url when ssl verify is explicitly on."""
aioclient_mock.get("https://example.com", text="hello world")
await async_setup_component(
hass,
"camera",
{
"camera... | [
"async",
"def",
"test_fetching_url_with_verify_ssl",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"https://example.com\"",
",",
"text",
"=",
"\"hello world\"",
")",
"await",
"async_setup_component",
"(",
"hass"... | [
76,
0
] | [
100,
29
] | python | en | ['en', 'en', 'en'] | True |
test_limit_refetch | (aioclient_mock, hass, hass_client) | Test that it fetches the given url. | Test that it fetches the given url. | async def test_limit_refetch(aioclient_mock, hass, hass_client):
"""Test that it fetches the given url."""
aioclient_mock.get("http://example.com/5a", text="hello world")
aioclient_mock.get("http://example.com/10a", text="hello world")
aioclient_mock.get("http://example.com/15a", text="hello planet")
... | [
"async",
"def",
"test_limit_refetch",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.com/5a\"",
",",
"text",
"=",
"\"hello world\"",
")",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.com... | [
103,
0
] | [
164,
33
] | python | en | ['en', 'en', 'en'] | True |
test_stream_source | (aioclient_mock, hass, hass_client, hass_ws_client) | Test that the stream source is rendered. | Test that the stream source is rendered. | async def test_stream_source(aioclient_mock, hass, hass_client, hass_ws_client):
"""Test that the stream source is rendered."""
assert await async_setup_component(
hass,
"camera",
{
"camera": {
"name": "config_test",
"platform": "generic",
... | [
"async",
"def",
"test_stream_source",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
",",
"hass_ws_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"\"camera\"",
":",
"{",
"\"name\"",
":",
"\"confi... | [
167,
0
] | [
223,
9
] | python | en | ['en', 'en', 'en'] | True |
test_no_stream_source | (aioclient_mock, hass, hass_client, hass_ws_client) | Test a stream request without stream source option set. | Test a stream request without stream source option set. | async def test_no_stream_source(aioclient_mock, hass, hass_client, hass_ws_client):
"""Test a stream request without stream source option set."""
assert await async_setup_component(
hass,
"camera",
{
"camera": {
"name": "config_test",
"platform... | [
"async",
"def",
"test_no_stream_source",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
",",
"hass_ws_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera\"",
",",
"{",
"\"camera\"",
":",
"{",
"\"name\"",
":",
"\"co... | [
226,
0
] | [
262,
9
] | python | en | ['en', 'en', 'en'] | True |
test_camera_content_type | (aioclient_mock, hass, hass_client) | Test generic camera with custom content_type. | Test generic camera with custom content_type. | async def test_camera_content_type(aioclient_mock, hass, hass_client):
"""Test generic camera with custom content_type."""
svg_image = "<some image>"
urlsvg = "https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg"
aioclient_mock.get(urlsvg, text=svg_image)
cam_config_svg = {
"na... | [
"async",
"def",
"test_camera_content_type",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
")",
":",
"svg_image",
"=",
"\"<some image>\"",
"urlsvg",
"=",
"\"https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg\"",
"aioclient_mock",
".",
"get",
"(",
"url... | [
265,
0
] | [
300,
28
] | python | en | ['en', 'en', 'en'] | True |
test_reloading | (aioclient_mock, hass, hass_client) | Test we can cleanly reload. | Test we can cleanly reload. | async def test_reloading(aioclient_mock, hass, hass_client):
"""Test we can cleanly reload."""
aioclient_mock.get("http://example.com", text="hello world")
await async_setup_component(
hass,
"camera",
{
"camera": {
"name": "config_test",
"... | [
"async",
"def",
"test_reloading",
"(",
"aioclient_mock",
",",
"hass",
",",
"hass_client",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"\"http://example.com\"",
",",
"text",
"=",
"\"hello world\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"camera... | [
303,
0
] | [
356,
32
] | python | en | ['en', 'en', 'en'] | True |
serve_command_factory | (args: Namespace) |
Factory function used to instantiate serving server from provided command line arguments.
Returns: ServeCommand
|
Factory function used to instantiate serving server from provided command line arguments. | def serve_command_factory(args: Namespace):
"""
Factory function used to instantiate serving server from provided command line arguments.
Returns: ServeCommand
"""
nlp = pipeline(
task=args.task,
model=args.model if args.model else None,
config=args.config,
tokenizer... | [
"def",
"serve_command_factory",
"(",
"args",
":",
"Namespace",
")",
":",
"nlp",
"=",
"pipeline",
"(",
"task",
"=",
"args",
".",
"task",
",",
"model",
"=",
"args",
".",
"model",
"if",
"args",
".",
"model",
"else",
"None",
",",
"config",
"=",
"args",
"... | [
42,
0
] | [
55,
64
] | python | en | ['en', 'error', 'th'] | False |
ServeCommand.register_subcommand | (parser: ArgumentParser) |
Register this command to argparse so it's available for the transformer-cli
Args:
parser: Root parser to register command-specific arguments
|
Register this command to argparse so it's available for the transformer-cli | def register_subcommand(parser: ArgumentParser):
"""
Register this command to argparse so it's available for the transformer-cli
Args:
parser: Root parser to register command-specific arguments
"""
serve_parser = parser.add_parser(
"serve", help="CLI tool... | [
"def",
"register_subcommand",
"(",
"parser",
":",
"ArgumentParser",
")",
":",
"serve_parser",
"=",
"parser",
".",
"add_parser",
"(",
"\"serve\"",
",",
"help",
"=",
"\"CLI tool to run inference requests through REST and GraphQL endpoints.\"",
")",
"serve_parser",
".",
"add... | [
93,
4
] | [
118,
61
] | python | en | ['en', 'error', 'th'] | False |
ServeCommand.tokenize | (self, text_input: str = Body(None, embed=True), return_ids: bool = Body(False, embed=True)) |
Tokenize the provided input and eventually returns corresponding tokens id: - **text_input**: String to
tokenize - **return_ids**: Boolean flags indicating if the tokens have to be converted to their integer
mapping.
|
Tokenize the provided input and eventually returns corresponding tokens id: - **text_input**: String to
tokenize - **return_ids**: Boolean flags indicating if the tokens have to be converted to their integer
mapping.
| def tokenize(self, text_input: str = Body(None, embed=True), return_ids: bool = Body(False, embed=True)):
"""
Tokenize the provided input and eventually returns corresponding tokens id: - **text_input**: String to
tokenize - **return_ids**: Boolean flags indicating if the tokens have to be conve... | [
"def",
"tokenize",
"(",
"self",
",",
"text_input",
":",
"str",
"=",
"Body",
"(",
"None",
",",
"embed",
"=",
"True",
")",
",",
"return_ids",
":",
"bool",
"=",
"Body",
"(",
"False",
",",
"embed",
"=",
"True",
")",
")",
":",
"try",
":",
"tokens_txt",
... | [
176,
4
] | [
192,
87
] | python | en | ['en', 'error', 'th'] | False |
ServeCommand.detokenize | (
self,
tokens_ids: List[int] = Body(None, embed=True),
skip_special_tokens: bool = Body(False, embed=True),
cleanup_tokenization_spaces: bool = Body(True, embed=True),
) |
Detokenize the provided tokens ids to readable text: - **tokens_ids**: List of tokens ids -
**skip_special_tokens**: Flag indicating to not try to decode special tokens - **cleanup_tokenization_spaces**:
Flag indicating to remove all leading/trailing spaces and intermediate ones.
|
Detokenize the provided tokens ids to readable text: - **tokens_ids**: List of tokens ids -
**skip_special_tokens**: Flag indicating to not try to decode special tokens - **cleanup_tokenization_spaces**:
Flag indicating to remove all leading/trailing spaces and intermediate ones.
| def detokenize(
self,
tokens_ids: List[int] = Body(None, embed=True),
skip_special_tokens: bool = Body(False, embed=True),
cleanup_tokenization_spaces: bool = Body(True, embed=True),
):
"""
Detokenize the provided tokens ids to readable text: - **tokens_ids**: List of... | [
"def",
"detokenize",
"(",
"self",
",",
"tokens_ids",
":",
"List",
"[",
"int",
"]",
"=",
"Body",
"(",
"None",
",",
"embed",
"=",
"True",
")",
",",
"skip_special_tokens",
":",
"bool",
"=",
"Body",
"(",
"False",
",",
"embed",
"=",
"True",
")",
",",
"c... | [
194,
4
] | [
209,
87
] | python | en | ['en', 'error', 'th'] | False |
ServeCommand.forward | (self, inputs=Body(None, embed=True)) |
**inputs**:
**attention_mask**:
**tokens_type_ids**:
|
**inputs**:
**attention_mask**:
**tokens_type_ids**:
| async def forward(self, inputs=Body(None, embed=True)):
"""
**inputs**:
**attention_mask**:
**tokens_type_ids**:
"""
# Check we don't have empty string
if len(inputs) == 0:
return ServeForwardResult(output=[], attention=[])
try:
#... | [
"async",
"def",
"forward",
"(",
"self",
",",
"inputs",
"=",
"Body",
"(",
"None",
",",
"embed",
"=",
"True",
")",
")",
":",
"# Check we don't have empty string",
"if",
"len",
"(",
"inputs",
")",
"==",
"0",
":",
"return",
"ServeForwardResult",
"(",
"output",... | [
211,
4
] | [
227,
55
] | python | en | ['en', 'error', 'th'] | False |
trim_batch | (
input_ids,
pad_token_id,
attention_mask=None,
) | Remove columns that are populated exclusively by pad_token_id | Remove columns that are populated exclusively by pad_token_id | def trim_batch(
input_ids,
pad_token_id,
attention_mask=None,
):
"""Remove columns that are populated exclusively by pad_token_id"""
keep_column_mask = input_ids.ne(pad_token_id).any(dim=0)
if attention_mask is None:
return input_ids[:, keep_column_mask]
else:
return (input_i... | [
"def",
"trim_batch",
"(",
"input_ids",
",",
"pad_token_id",
",",
"attention_mask",
"=",
"None",
",",
")",
":",
"keep_column_mask",
"=",
"input_ids",
".",
"ne",
"(",
"pad_token_id",
")",
".",
"any",
"(",
"dim",
"=",
"0",
")",
"if",
"attention_mask",
"is",
... | [
34,
0
] | [
44,
84
] | python | en | ['en', 'en', 'en'] | True |
save_git_info | (folder_path: str) | Save git information to output_dir/git_log.json | Save git information to output_dir/git_log.json | def save_git_info(folder_path: str) -> None:
"""Save git information to output_dir/git_log.json"""
repo_infos = get_git_info()
save_json(repo_infos, os.path.join(folder_path, "git_log.json")) | [
"def",
"save_git_info",
"(",
"folder_path",
":",
"str",
")",
"->",
"None",
":",
"repo_infos",
"=",
"get_git_info",
"(",
")",
"save_json",
"(",
"repo_infos",
",",
"os",
".",
"path",
".",
"join",
"(",
"folder_path",
",",
"\"git_log.json\"",
")",
")"
] | [
142,
0
] | [
145,
68
] | python | en | ['en', 'su', 'sw'] | False |
lmap | (f: Callable, x: Iterable) | list(map(f, x)) | list(map(f, x)) | def lmap(f: Callable, x: Iterable) -> List:
"""list(map(f, x))"""
return list(map(f, x)) | [
"def",
"lmap",
"(",
"f",
":",
"Callable",
",",
"x",
":",
"Iterable",
")",
"->",
"List",
":",
"return",
"list",
"(",
"map",
"(",
"f",
",",
"x",
")",
")"
] | [
169,
0
] | [
171,
26
] | python | en | ['en', 'mt', 'en'] | False |
pickle_save | (obj, path) | pickle.dump(obj, path) | pickle.dump(obj, path) | def pickle_save(obj, path):
"""pickle.dump(obj, path)"""
with open(path, "wb") as f:
return pickle.dump(obj, f) | [
"def",
"pickle_save",
"(",
"obj",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"\"wb\"",
")",
"as",
"f",
":",
"return",
"pickle",
".",
"dump",
"(",
"obj",
",",
"f",
")"
] | [
174,
0
] | [
177,
34
] | python | en | ['en', 'gd', 'hi'] | False |
normalize_answer | (s) | Lower text and remove punctuation, articles and extra whitespace. | Lower text and remove punctuation, articles and extra whitespace. | def normalize_answer(s):
"""Lower text and remove punctuation, articles and extra whitespace."""
def remove_articles(text):
return re.sub(r"\b(a|an|the)\b", " ", text)
def white_space_fix(text):
return " ".join(text.split())
def remove_punc(text):
exclude = set(string.punctuat... | [
"def",
"normalize_answer",
"(",
"s",
")",
":",
"def",
"remove_articles",
"(",
"text",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r\"\\b(a|an|the)\\b\"",
",",
"\" \"",
",",
"text",
")",
"def",
"white_space_fix",
"(",
"text",
")",
":",
"return",
"\" \"",
... | [
180,
0
] | [
196,
66
] | python | en | ['en', 'en', 'en'] | True |
get_scanner | (hass, config) | Return the Salt device scanner. | Return the Salt device scanner. | def get_scanner(hass, config):
"""Return the Salt device scanner."""
scanner = SaltDeviceScanner(config[DOMAIN])
# Test whether the router is accessible.
data = scanner.get_salt_data()
return scanner if data is not None else None | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"scanner",
"=",
"SaltDeviceScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"# Test whether the router is accessible.",
"data",
"=",
"scanner",
".",
"get_salt_data",
"(",
")",
"return",
"scanner",
"if"... | [
25,
0
] | [
31,
48
] | python | en | ['en', 'da', 'en'] | True |
SaltDeviceScanner.__init__ | (self, config) | Initialize the scanner. | Initialize the scanner. | def __init__(self, config):
"""Initialize the scanner."""
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
self.saltbox = SaltBox(f"http://{host}", username, password)
self.online_clients = [] | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"config",
"[",
"CONF_PASSWORD",
"]",
"self",
".",
"saltbox",
"=",
"SaltBox",
"("... | [
37,
4
] | [
43,
32
] | python | en | ['en', 'en', 'en'] | True |
SaltDeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
return [client["mac"] for client in self.online_clients] | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"_update_info",
"(",
")",
"return",
"[",
"client",
"[",
"\"mac\"",
"]",
"for",
"client",
"in",
"self",
".",
"online_clients",
"]"
] | [
45,
4
] | [
48,
64
] | python | en | ['en', 'en', 'en'] | True |
SaltDeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
for client in self.online_clients:
if client["mac"] == device:
return client["name"]
return None | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"for",
"client",
"in",
"self",
".",
"online_clients",
":",
"if",
"client",
"[",
"\"mac\"",
"]",
"==",
"device",
":",
"return",
"client",
"[",
"\"name\"",
"]",
"return",
"None"
] | [
50,
4
] | [
55,
19
] | python | en | ['en', 'en', 'en'] | True |
SaltDeviceScanner.get_salt_data | (self) | Retrieve data from Salt router and return parsed result. | Retrieve data from Salt router and return parsed result. | def get_salt_data(self):
"""Retrieve data from Salt router and return parsed result."""
try:
clients = self.saltbox.get_online_clients()
return clients
except (RouterLoginException, RouterNotReachableException) as error:
_LOGGER.warning(error)
retu... | [
"def",
"get_salt_data",
"(",
"self",
")",
":",
"try",
":",
"clients",
"=",
"self",
".",
"saltbox",
".",
"get_online_clients",
"(",
")",
"return",
"clients",
"except",
"(",
"RouterLoginException",
",",
"RouterNotReachableException",
")",
"as",
"error",
":",
"_L... | [
57,
4
] | [
64,
23
] | python | en | ['en', 'en', 'en'] | True |
SaltDeviceScanner._update_info | (self) | Pull the current information from the Salt router. | Pull the current information from the Salt router. | def _update_info(self):
"""Pull the current information from the Salt router."""
_LOGGER.debug("Loading data from Salt Fiber Box")
data = self.get_salt_data()
self.online_clients = data or [] | [
"def",
"_update_info",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Loading data from Salt Fiber Box\"",
")",
"data",
"=",
"self",
".",
"get_salt_data",
"(",
")",
"self",
".",
"online_clients",
"=",
"data",
"or",
"[",
"]"
] | [
66,
4
] | [
70,
40
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the derivative sensor. | Set up the derivative sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the derivative sensor."""
derivative = DerivativeSensor(
source_entity=config[CONF_SOURCE],
name=config.get(CONF_NAME),
round_digits=config[CONF_ROUND_DIGITS],
unit_prefix=config[CONF... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"derivative",
"=",
"DerivativeSensor",
"(",
"source_entity",
"=",
"config",
"[",
"CONF_SOURCE",
"]",
",",
"name",
"=",
... | [
73,
0
] | [
85,
36
] | python | en | ['en', 'ca', 'en'] | True |
DerivativeSensor.__init__ | (
self,
source_entity,
name,
round_digits,
unit_prefix,
unit_time,
unit_of_measurement,
time_window,
) | Initialize the derivative sensor. | Initialize the derivative sensor. | def __init__(
self,
source_entity,
name,
round_digits,
unit_prefix,
unit_time,
unit_of_measurement,
time_window,
):
"""Initialize the derivative sensor."""
self._sensor_source_id = source_entity
self._round_digits = round_digits... | [
"def",
"__init__",
"(",
"self",
",",
"source_entity",
",",
"name",
",",
"round_digits",
",",
"unit_prefix",
",",
"unit_time",
",",
"unit_of_measurement",
",",
"time_window",
",",
")",
":",
"self",
".",
"_sensor_source_id",
"=",
"source_entity",
"self",
".",
"_... | [
91,
4
] | [
119,
55
] | python | en | ['en', 'co', 'en'] | True |
DerivativeSensor.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state is not None:
try:
self._state = Decimal(state.state)
except SyntaxError as err:
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
"is",
"not",
"None",
":",
"try",
":",
"se... | [
121,
4
] | [
190,
9
] | python | en | ['en', 'en', 'en'] | True |
DerivativeSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
193,
4
] | [
195,
25
] | python | en | ['en', 'mi', 'en'] | True |
DerivativeSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return round(self._state, self._round_digits) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"round",
"(",
"self",
".",
"_state",
",",
"self",
".",
"_round_digits",
")"
] | [
198,
4
] | [
200,
53
] | python | en | ['en', 'en', 'en'] | True |
DerivativeSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
203,
4
] | [
205,
40
] | python | en | ['en', 'en', 'en'] | True |
DerivativeSensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
208,
4
] | [
210,
20
] | python | en | ['en', 'en', 'en'] | True |
DerivativeSensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return {ATTR_SOURCE_ID: self._sensor_source_id} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_SOURCE_ID",
":",
"self",
".",
"_sensor_source_id",
"}"
] | [
213,
4
] | [
215,
55
] | python | en | ['en', 'en', 'en'] | True |
DerivativeSensor.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
218,
4
] | [
220,
19
] | python | en | ['en', 'en', 'en'] | True |
teardown | () | Stop everything that was started. | Stop everything that was started. | def teardown():
"""Stop everything that was started."""
dt_util.set_default_time_zone(DEFAULT_TIME_ZONE) | [
"def",
"teardown",
"(",
")",
":",
"dt_util",
".",
"set_default_time_zone",
"(",
"DEFAULT_TIME_ZONE",
")"
] | [
11,
0
] | [
13,
52
] | python | en | ['en', 'en', 'en'] | True |
test_get_time_zone_retrieves_valid_time_zone | () | Test getting a time zone. | Test getting a time zone. | def test_get_time_zone_retrieves_valid_time_zone():
"""Test getting a time zone."""
time_zone = dt_util.get_time_zone(TEST_TIME_ZONE)
assert time_zone is not None
assert TEST_TIME_ZONE == time_zone.zone | [
"def",
"test_get_time_zone_retrieves_valid_time_zone",
"(",
")",
":",
"time_zone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"TEST_TIME_ZONE",
")",
"assert",
"time_zone",
"is",
"not",
"None",
"assert",
"TEST_TIME_ZONE",
"==",
"time_zone",
".",
"zone"
] | [
16,
0
] | [
21,
43
] | python | en | ['nl', 'en', 'en'] | True |
test_get_time_zone_returns_none_for_garbage_time_zone | () | Test getting a non existing time zone. | Test getting a non existing time zone. | def test_get_time_zone_returns_none_for_garbage_time_zone():
"""Test getting a non existing time zone."""
time_zone = dt_util.get_time_zone("Non existing time zone")
assert time_zone is None | [
"def",
"test_get_time_zone_returns_none_for_garbage_time_zone",
"(",
")",
":",
"time_zone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"\"Non existing time zone\"",
")",
"assert",
"time_zone",
"is",
"None"
] | [
24,
0
] | [
28,
28
] | python | en | ['nl', 'en', 'en'] | True |
test_set_default_time_zone | () | Test setting default time zone. | Test setting default time zone. | def test_set_default_time_zone():
"""Test setting default time zone."""
time_zone = dt_util.get_time_zone(TEST_TIME_ZONE)
dt_util.set_default_time_zone(time_zone)
# We cannot compare the timezones directly because of DST
assert time_zone.zone == dt_util.now().tzinfo.zone | [
"def",
"test_set_default_time_zone",
"(",
")",
":",
"time_zone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"TEST_TIME_ZONE",
")",
"dt_util",
".",
"set_default_time_zone",
"(",
"time_zone",
")",
"# We cannot compare the timezones directly because of DST",
"assert",
"time_zo... | [
31,
0
] | [
38,
54
] | python | en | ['nl', 'en', 'en'] | True |
test_utcnow | () | Test the UTC now method. | Test the UTC now method. | def test_utcnow():
"""Test the UTC now method."""
assert abs(dt_util.utcnow().replace(tzinfo=None) - datetime.utcnow()) < timedelta(
seconds=1
) | [
"def",
"test_utcnow",
"(",
")",
":",
"assert",
"abs",
"(",
"dt_util",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"-",
"datetime",
".",
"utcnow",
"(",
")",
")",
"<",
"timedelta",
"(",
"seconds",
"=",
"1",
")"
] | [
41,
0
] | [
45,
5
] | python | en | ['en', 'sr', 'en'] | True |
test_now | () | Test the now method. | Test the now method. | def test_now():
"""Test the now method."""
dt_util.set_default_time_zone(dt_util.get_time_zone(TEST_TIME_ZONE))
assert abs(
dt_util.as_utc(dt_util.now()).replace(tzinfo=None) - datetime.utcnow()
) < timedelta(seconds=1) | [
"def",
"test_now",
"(",
")",
":",
"dt_util",
".",
"set_default_time_zone",
"(",
"dt_util",
".",
"get_time_zone",
"(",
"TEST_TIME_ZONE",
")",
")",
"assert",
"abs",
"(",
"dt_util",
".",
"as_utc",
"(",
"dt_util",
".",
"now",
"(",
")",
")",
".",
"replace",
"... | [
48,
0
] | [
54,
28
] | python | en | ['en', 'en', 'en'] | True |
test_as_utc_with_naive_object | () | Test the now method. | Test the now method. | def test_as_utc_with_naive_object():
"""Test the now method."""
utcnow = datetime.utcnow()
assert utcnow == dt_util.as_utc(utcnow).replace(tzinfo=None) | [
"def",
"test_as_utc_with_naive_object",
"(",
")",
":",
"utcnow",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"assert",
"utcnow",
"==",
"dt_util",
".",
"as_utc",
"(",
"utcnow",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")"
] | [
57,
0
] | [
61,
64
] | python | en | ['en', 'en', 'en'] | True |
test_as_utc_with_utc_object | () | Test UTC time with UTC object. | Test UTC time with UTC object. | def test_as_utc_with_utc_object():
"""Test UTC time with UTC object."""
utcnow = dt_util.utcnow()
assert utcnow == dt_util.as_utc(utcnow) | [
"def",
"test_as_utc_with_utc_object",
"(",
")",
":",
"utcnow",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"assert",
"utcnow",
"==",
"dt_util",
".",
"as_utc",
"(",
"utcnow",
")"
] | [
64,
0
] | [
68,
43
] | python | en | ['en', 'pl', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.