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
MqttCover.async_set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
async def async_set_cover_position(self, **kwargs): """Move the cover to a specific position.""" set_position_template = self._config.get(CONF_SET_POSITION_TEMPLATE) position = kwargs[ATTR_POSITION] percentage_position = position if set_position_template is not None: ...
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "set_position_template", "=", "self", ".", "_config", ".", "get", "(", "CONF_SET_POSITION_TEMPLATE", ")", "position", "=", "kwargs", "[", "ATTR_POSITION", "]", "percentag...
[ 553, 4 ]
[ 577, 39 ]
python
en
['en', 'en', 'en']
True
MqttCover.async_toggle_tilt
(self, **kwargs)
Toggle the entity.
Toggle the entity.
async def async_toggle_tilt(self, **kwargs): """Toggle the entity.""" if self.is_tilt_closed(): await self.async_open_cover_tilt(**kwargs) else: await self.async_close_cover_tilt(**kwargs)
[ "async", "def", "async_toggle_tilt", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "is_tilt_closed", "(", ")", ":", "await", "self", ".", "async_open_cover_tilt", "(", "*", "*", "kwargs", ")", "else", ":", "await", "self", ".", "as...
[ 579, 4 ]
[ 584, 55 ]
python
en
['en', 'sm', 'en']
True
MqttCover.is_tilt_closed
(self)
Return if the cover is tilted closed.
Return if the cover is tilted closed.
def is_tilt_closed(self): """Return if the cover is tilted closed.""" return self._tilt_value == self.find_percentage_in_range( float(self._config[CONF_TILT_CLOSED_POSITION]) )
[ "def", "is_tilt_closed", "(", "self", ")", ":", "return", "self", ".", "_tilt_value", "==", "self", ".", "find_percentage_in_range", "(", "float", "(", "self", ".", "_config", "[", "CONF_TILT_CLOSED_POSITION", "]", ")", ")" ]
[ 586, 4 ]
[ 590, 9 ]
python
en
['en', 'en', 'en']
True
MqttCover.find_percentage_in_range
(self, position, range_type=TILT_PAYLOAD)
Find the 0-100% value within the specified range.
Find the 0-100% value within the specified range.
def find_percentage_in_range(self, position, range_type=TILT_PAYLOAD): """Find the 0-100% value within the specified range.""" # the range of motion as defined by the min max values if range_type == COVER_PAYLOAD: max_range = self._config[CONF_POSITION_OPEN] min_range = s...
[ "def", "find_percentage_in_range", "(", "self", ",", "position", ",", "range_type", "=", "TILT_PAYLOAD", ")", ":", "# the range of motion as defined by the min max values", "if", "range_type", "==", "COVER_PAYLOAD", ":", "max_range", "=", "self", ".", "_config", "[", ...
[ 592, 4 ]
[ 611, 34 ]
python
en
['en', 'en', 'en']
True
MqttCover.find_in_range_from_percent
(self, percentage, range_type=TILT_PAYLOAD)
Find the adjusted value for 0-100% within the specified range. if the range is 80-180 and the percentage is 90 this method would determine the value to send on the topic by offsetting the max and min, getting the percentage value and returning the offset
Find the adjusted value for 0-100% within the specified range.
def find_in_range_from_percent(self, percentage, range_type=TILT_PAYLOAD): """ Find the adjusted value for 0-100% within the specified range. if the range is 80-180 and the percentage is 90 this method would determine the value to send on the topic by offsetting the max and min,...
[ "def", "find_in_range_from_percent", "(", "self", ",", "percentage", ",", "range_type", "=", "TILT_PAYLOAD", ")", ":", "if", "range_type", "==", "COVER_PAYLOAD", ":", "max_range", "=", "self", ".", "_config", "[", "CONF_POSITION_OPEN", "]", "min_range", "=", "se...
[ 613, 4 ]
[ 635, 23 ]
python
en
['en', 'error', 'th']
False
MqttCover.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 638, 4 ]
[ 640, 30 ]
python
ca
['fr', 'ca', 'en']
False
TFLayoutLMEmbeddings.call
( self, input_ids: tf.Tensor = None, bbox: tf.Tensor = None, position_ids: tf.Tensor = None, token_type_ids: tf.Tensor = None, inputs_embeds: tf.Tensor = None, training: bool = False, )
Applies embedding based on inputs tensor. Returns: final_embeddings (:obj:`tf.Tensor`): output embedding tensor.
Applies embedding based on inputs tensor.
def call( self, input_ids: tf.Tensor = None, bbox: tf.Tensor = None, position_ids: tf.Tensor = None, token_type_ids: tf.Tensor = None, inputs_embeds: tf.Tensor = None, training: bool = False, ) -> tf.Tensor: """ Applies embedding based on input...
[ "def", "call", "(", "self", ",", "input_ids", ":", "tf", ".", "Tensor", "=", "None", ",", "bbox", ":", "tf", ".", "Tensor", "=", "None", ",", "position_ids", ":", "tf", ".", "Tensor", "=", "None", ",", "token_type_ids", ":", "tf", ".", "Tensor", "=...
[ 126, 4 ]
[ 188, 31 ]
python
en
['en', 'error', 'th']
False
_retrieve_device_battery_state
(detail)
Get the latest state of the sensor.
Get the latest state of the sensor.
def _retrieve_device_battery_state(detail): """Get the latest state of the sensor.""" return detail.battery_level
[ "def", "_retrieve_device_battery_state", "(", "detail", ")", ":", "return", "detail", ".", "battery_level" ]
[ 29, 0 ]
[ 31, 31 ]
python
en
['en', 'en', 'en']
True
_retrieve_linked_keypad_battery_state
(detail)
Get the latest state of the sensor.
Get the latest state of the sensor.
def _retrieve_linked_keypad_battery_state(detail): """Get the latest state of the sensor.""" return detail.battery_percentage
[ "def", "_retrieve_linked_keypad_battery_state", "(", "detail", ")", ":", "return", "detail", ".", "battery_percentage" ]
[ 34, 0 ]
[ 36, 36 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the August sensors.
Set up the August sensors.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the August sensors.""" data = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST] devices = [] migrate_unique_id_devices = [] operation_sensors = [] batteries = { "device_battery": [], "linked_keypad...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", "DATA_AUGUST", "]", "devices", "=", "[", "]", ...
[ 45, 0 ]
[ 101, 37 ]
python
en
['en', 'en', 'en']
True
_async_migrate_old_unique_ids
(hass, devices)
Keypads now have their own serial number.
Keypads now have their own serial number.
async def _async_migrate_old_unique_ids(hass, devices): """Keypads now have their own serial number.""" registry = await async_get_registry(hass) for device in devices: old_entity_id = registry.async_get_entity_id( "sensor", DOMAIN, device.old_unique_id ) if old_entity_id...
[ "async", "def", "_async_migrate_old_unique_ids", "(", "hass", ",", "devices", ")", ":", "registry", "=", "await", "async_get_registry", "(", "hass", ")", "for", "device", "in", "devices", ":", "old_entity_id", "=", "registry", ".", "async_get_entity_id", "(", "\...
[ 104, 0 ]
[ 117, 87 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.__init__
(self, data, device)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, device): """Initialize the sensor.""" super().__init__(data, device) self._data = data self._device = device self._state = None self._operated_remote = None self._operated_keypad = None self._operated_autorelock = None self...
[ "def", "__init__", "(", "self", ",", "data", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "data", ",", "device", ")", "self", ".", "_data", "=", "data", "self", ".", "_device", "=", "device", "self", ".", "_state", "=", "None",...
[ 123, 4 ]
[ 135, 32 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.available
(self)
Return the availability of this sensor.
Return the availability of this sensor.
def available(self): """Return the availability of this sensor.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 138, 4 ]
[ 140, 30 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 143, 4 ]
[ 145, 26 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.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._device.device_name} Operator"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._device.device_name} Operator\"" ]
[ 148, 4 ]
[ 150, 53 ]
python
en
['en', 'mi', 'en']
True
AugustOperatorSensor._update_from_data
(self)
Get the latest state of the sensor and update activity.
Get the latest state of the sensor and update activity.
def _update_from_data(self): """Get the latest state of the sensor and update activity.""" lock_activity = self._data.activity_stream.get_latest_device_activity( self._device_id, [ActivityType.LOCK_OPERATION] ) if lock_activity is not None: self._available = True...
[ "def", "_update_from_data", "(", "self", ")", ":", "lock_activity", "=", "self", ".", "_data", ".", "activity_stream", ".", "get_latest_device_activity", "(", "self", ".", "_device_id", ",", "[", "ActivityType", ".", "LOCK_OPERATION", "]", ")", "if", "lock_activ...
[ 153, 4 ]
[ 165, 71 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.device_state_attributes
(self)
Return the device specific state attributes.
Return the device specific state attributes.
def device_state_attributes(self): """Return the device specific state attributes.""" attributes = {} if self._operated_remote is not None: attributes[ATTR_OPERATION_REMOTE] = self._operated_remote if self._operated_keypad is not None: attributes[ATTR_OPERATION_K...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "if", "self", ".", "_operated_remote", "is", "not", "None", ":", "attributes", "[", "ATTR_OPERATION_REMOTE", "]", "=", "self", ".", "_operated_remote", "if", "self", ".", "...
[ 168, 4 ]
[ 188, 25 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.async_added_to_hass
(self)
Restore ATTR_CHANGED_BY on startup since it is likely no longer in the activity log.
Restore ATTR_CHANGED_BY on startup since it is likely no longer in the activity log.
async def async_added_to_hass(self): """Restore ATTR_CHANGED_BY on startup since it is likely no longer in the activity log.""" await super().async_added_to_hass() last_state = await self.async_get_last_state() if not last_state: return self._state = last_state.stat...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "last_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", "not", "last_state", ":", "return", "self", ".", ...
[ 190, 4 ]
[ 206, 88 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.entity_picture
(self)
Return the entity picture to use in the frontend, if any.
Return the entity picture to use in the frontend, if any.
def entity_picture(self): """Return the entity picture to use in the frontend, if any.""" return self._entity_picture
[ "def", "entity_picture", "(", "self", ")", ":", "return", "self", ".", "_entity_picture" ]
[ 209, 4 ]
[ 211, 35 ]
python
en
['en', 'en', 'en']
True
AugustOperatorSensor.unique_id
(self)
Get the unique id of the device sensor.
Get the unique id of the device sensor.
def unique_id(self) -> str: """Get the unique id of the device sensor.""" return f"{self._device_id}_lock_operator"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device_id}_lock_operator\"" ]
[ 214, 4 ]
[ 216, 49 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.__init__
(self, data, sensor_type, device, old_device)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, sensor_type, device, old_device): """Initialize the sensor.""" super().__init__(data, device) self._data = data self._sensor_type = sensor_type self._device = device self._old_device = old_device self._state = None self._available ...
[ "def", "__init__", "(", "self", ",", "data", ",", "sensor_type", ",", "device", ",", "old_device", ")", ":", "super", "(", ")", ".", "__init__", "(", "data", ",", "device", ")", "self", ".", "_data", "=", "data", "self", ".", "_sensor_type", "=", "se...
[ 222, 4 ]
[ 231, 32 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.available
(self)
Return the availability of this sensor.
Return the availability of this sensor.
def available(self): """Return the availability of this sensor.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 234, 4 ]
[ 236, 30 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 239, 4 ]
[ 241, 26 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 244, 4 ]
[ 246, 25 ]
python
en
['en', 'la', 'en']
True
AugustBatterySensor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" return DEVICE_CLASS_BATTERY
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_BATTERY" ]
[ 249, 4 ]
[ 251, 35 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" device_name = self._device.device_name return f"{device_name} Battery"
[ "def", "name", "(", "self", ")", ":", "device_name", "=", "self", ".", "_device", ".", "device_name", "return", "f\"{device_name} Battery\"" ]
[ 254, 4 ]
[ 257, 39 ]
python
en
['en', 'mi', 'en']
True
AugustBatterySensor._update_from_data
(self)
Get the latest state of the sensor.
Get the latest state of the sensor.
def _update_from_data(self): """Get the latest state of the sensor.""" state_provider = SENSOR_TYPES_BATTERY[self._sensor_type]["state_provider"] self._state = state_provider(self._detail) self._available = self._state is not None
[ "def", "_update_from_data", "(", "self", ")", ":", "state_provider", "=", "SENSOR_TYPES_BATTERY", "[", "self", ".", "_sensor_type", "]", "[", "\"state_provider\"", "]", "self", ".", "_state", "=", "state_provider", "(", "self", ".", "_detail", ")", "self", "."...
[ 260, 4 ]
[ 264, 49 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.unique_id
(self)
Get the unique id of the device sensor.
Get the unique id of the device sensor.
def unique_id(self) -> str: """Get the unique id of the device sensor.""" return f"{self._device_id}_{self._sensor_type}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device_id}_{self._sensor_type}\"" ]
[ 267, 4 ]
[ 269, 55 ]
python
en
['en', 'en', 'en']
True
AugustBatterySensor.old_unique_id
(self)
Get the old unique id of the device sensor.
Get the old unique id of the device sensor.
def old_unique_id(self) -> str: """Get the old unique id of the device sensor.""" return f"{self._old_device.device_id}_{self._sensor_type}"
[ "def", "old_unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._old_device.device_id}_{self._sensor_type}\"" ]
[ 272, 4 ]
[ 274, 66 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Proxy camera platform.
Set up the Proxy camera platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Proxy camera platform.""" async_add_entities([ProxyCamera(hass, config)])
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities", "(", "[", "ProxyCamera", "(", "hass", ",", "config", ")", "]", ")" ]
[ 61, 0 ]
[ 63, 51 ]
python
en
['en', 'cs', 'en']
True
_precheck_image
(image, opts)
Perform some pre-checks on the given image.
Perform some pre-checks on the given image.
def _precheck_image(image, opts): """Perform some pre-checks on the given image.""" if not opts: raise ValueError() try: img = Image.open(io.BytesIO(image)) except OSError as err: _LOGGER.warning("Failed to open image") raise ValueError() from err imgfmt = str(img.for...
[ "def", "_precheck_image", "(", "image", ",", "opts", ")", ":", "if", "not", "opts", ":", "raise", "ValueError", "(", ")", "try", ":", "img", "=", "Image", ".", "open", "(", "io", ".", "BytesIO", "(", "image", ")", ")", "except", "OSError", "as", "e...
[ 66, 0 ]
[ 81, 14 ]
python
en
['en', 'en', 'en']
True
_resize_image
(image, opts)
Resize image.
Resize image.
def _resize_image(image, opts): """Resize image.""" try: img = _precheck_image(image, opts) except ValueError: return image quality = opts.quality or DEFAULT_QUALITY new_width = opts.max_width (old_width, old_height) = img.size old_size = len(image) if old_width <= new_w...
[ "def", "_resize_image", "(", "image", ",", "opts", ")", ":", "try", ":", "img", "=", "_precheck_image", "(", "image", ",", "opts", ")", "except", "ValueError", ":", "return", "image", "quality", "=", "opts", ".", "quality", "or", "DEFAULT_QUALITY", "new_wi...
[ 84, 0 ]
[ 126, 19 ]
python
en
['en', 'zu', 'en']
False
_crop_image
(image, opts)
Crop image.
Crop image.
def _crop_image(image, opts): """Crop image.""" try: img = _precheck_image(image, opts) except ValueError: return image quality = opts.quality or DEFAULT_QUALITY (old_width, old_height) = img.size old_size = len(image) if opts.top is None: opts.top = 0 if opts.le...
[ "def", "_crop_image", "(", "image", ",", "opts", ")", ":", "try", ":", "img", "=", "_precheck_image", "(", "image", ",", "opts", ")", "except", "ValueError", ":", "return", "image", "quality", "=", "opts", ".", "quality", "or", "DEFAULT_QUALITY", "(", "o...
[ 129, 0 ]
[ 164, 19 ]
python
en
['en', 'nl', 'en']
False
ImageOpts.__init__
(self, max_width, max_height, left, top, quality, force_resize)
Initialize image options.
Initialize image options.
def __init__(self, max_width, max_height, left, top, quality, force_resize): """Initialize image options.""" self.max_width = max_width self.max_height = max_height self.left = left self.top = top self.quality = quality self.force_resize = force_resize
[ "def", "__init__", "(", "self", ",", "max_width", ",", "max_height", ",", "left", ",", "top", ",", "quality", ",", "force_resize", ")", ":", "self", ".", "max_width", "=", "max_width", "self", ".", "max_height", "=", "max_height", "self", ".", "left", "=...
[ 170, 4 ]
[ 177, 40 ]
python
en
['en', 'en', 'en']
True
ImageOpts.__bool__
(self)
Bool evaluation rules.
Bool evaluation rules.
def __bool__(self): """Bool evaluation rules.""" return bool(self.max_width or self.quality)
[ "def", "__bool__", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "max_width", "or", "self", ".", "quality", ")" ]
[ 179, 4 ]
[ 181, 51 ]
python
en
['ro', 'en', 'en']
True
ProxyCamera.__init__
(self, hass, config)
Initialize a proxy camera component.
Initialize a proxy camera component.
def __init__(self, hass, config): """Initialize a proxy camera component.""" super().__init__() self.hass = hass self._proxied_camera = config.get(CONF_ENTITY_ID) self._name = ( config.get(CONF_NAME) or f"{DEFAULT_BASENAME} - {self._proxied_camera}" ) ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "hass", "=", "hass", "self", ".", "_proxied_camera", "=", "config", ".", "get", "(", "CONF_ENTITY_ID", ")", "self", ".", ...
[ 187, 4 ]
[ 219, 42 ]
python
en
['es', 'en', 'it']
False
ProxyCamera.camera_image
(self)
Return camera image.
Return camera image.
def camera_image(self): """Return camera image.""" return asyncio.run_coroutine_threadsafe( self.async_camera_image(), self.hass.loop ).result()
[ "def", "camera_image", "(", "self", ")", ":", "return", "asyncio", ".", "run_coroutine_threadsafe", "(", "self", ".", "async_camera_image", "(", ")", ",", "self", ".", "hass", ".", "loop", ")", ".", "result", "(", ")" ]
[ 221, 4 ]
[ 225, 18 ]
python
bs
['es', 'bs', 'en']
False
ProxyCamera.async_camera_image
(self)
Return a still image response from the camera.
Return a still image response from the camera.
async def async_camera_image(self): """Return a still image response from the camera.""" now = dt_util.utcnow() if self._image_refresh_rate and now < self._last_image_time + timedelta( seconds=self._image_refresh_rate ): return self._last_image self._las...
[ "async", "def", "async_camera_image", "(", "self", ")", ":", "now", "=", "dt_util", ".", "utcnow", "(", ")", "if", "self", ".", "_image_refresh_rate", "and", "now", "<", "self", ".", "_last_image_time", "+", "timedelta", "(", "seconds", "=", "self", ".", ...
[ 227, 4 ]
[ 252, 20 ]
python
en
['en', 'en', 'en']
True
ProxyCamera.handle_async_mjpeg_stream
(self, request)
Generate an HTTP MJPEG stream from camera images.
Generate an HTTP MJPEG stream from camera images.
async def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from camera images.""" if not self._stream_opts: return await async_get_mjpeg_stream( self.hass, request, self._proxied_camera ) return await async_get_still_stream( ...
[ "async", "def", "handle_async_mjpeg_stream", "(", "self", ",", "request", ")", ":", "if", "not", "self", ".", "_stream_opts", ":", "return", "await", "async_get_mjpeg_stream", "(", "self", ".", "hass", ",", "request", ",", "self", ".", "_proxied_camera", ")", ...
[ 254, 4 ]
[ 263, 9 ]
python
en
['en', 'en', 'en']
True
ProxyCamera.name
(self)
Return the name of this camera.
Return the name of this camera.
def name(self): """Return the name of this camera.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 266, 4 ]
[ 268, 25 ]
python
en
['en', 'en', 'en']
True
ProxyCamera._async_stream_image
(self)
Return a still image response from the camera.
Return a still image response from the camera.
async def _async_stream_image(self): """Return a still image response from the camera.""" try: image = await async_get_image(self.hass, self._proxied_camera) if not image: return None except HomeAssistantError as err: raise asyncio.CancelledErr...
[ "async", "def", "_async_stream_image", "(", "self", ")", ":", "try", ":", "image", "=", "await", "async_get_image", "(", "self", ".", "hass", ",", "self", ".", "_proxied_camera", ")", "if", "not", "image", ":", "return", "None", "except", "HomeAssistantError...
[ 270, 4 ]
[ 285, 9 ]
python
en
['en', 'en', 'en']
True
_no_duplicate_auth_provider
( configs: Sequence[Dict[str, Any]] )
No duplicate auth provider config allowed in a list. Each type of auth provider can only have one config without optional id. Unique id is required if same type of auth provider used multiple times.
No duplicate auth provider config allowed in a list.
def _no_duplicate_auth_provider( configs: Sequence[Dict[str, Any]] ) -> Sequence[Dict[str, Any]]: """No duplicate auth provider config allowed in a list. Each type of auth provider can only have one config without optional id. Unique id is required if same type of auth provider used multiple times. ...
[ "def", "_no_duplicate_auth_provider", "(", "configs", ":", "Sequence", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "Sequence", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "config_keys", ":", "Set", "[", "Tuple", "[", "str", ",",...
[ 106, 0 ]
[ 124, 18 ]
python
en
['en', 'en', 'en']
True
_no_duplicate_auth_mfa_module
( configs: Sequence[Dict[str, Any]] )
No duplicate auth mfa module item allowed in a list. Each type of mfa module can only have one config without optional id. A global unique id is required if same type of mfa module used multiple times. Note: this is different than auth provider
No duplicate auth mfa module item allowed in a list.
def _no_duplicate_auth_mfa_module( configs: Sequence[Dict[str, Any]] ) -> Sequence[Dict[str, Any]]: """No duplicate auth mfa module item allowed in a list. Each type of mfa module can only have one config without optional id. A global unique id is required if same type of mfa module used multiple t...
[ "def", "_no_duplicate_auth_mfa_module", "(", "configs", ":", "Sequence", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "Sequence", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "config_keys", ":", "Set", "[", "str", "]", "=", "set",...
[ 127, 0 ]
[ 147, 18 ]
python
en
['en', 'co', 'en']
True
get_default_config_dir
()
Put together the default configuration directory based on the OS.
Put together the default configuration directory based on the OS.
def get_default_config_dir() -> str: """Put together the default configuration directory based on the OS.""" data_dir = os.getenv("APPDATA") if os.name == "nt" else os.path.expanduser("~") return os.path.join(data_dir, CONFIG_DIR_NAME)
[ "def", "get_default_config_dir", "(", ")", "->", "str", ":", "data_dir", "=", "os", ".", "getenv", "(", "\"APPDATA\"", ")", "if", "os", ".", "name", "==", "\"nt\"", "else", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "return", "os", ".", ...
[ 232, 0 ]
[ 235, 50 ]
python
en
['en', 'en', 'en']
True
async_ensure_config_exists
(hass: HomeAssistant)
Ensure a configuration file exists in given configuration directory. Creating a default one if needed. Return boolean if configuration dir is ready to go.
Ensure a configuration file exists in given configuration directory.
async def async_ensure_config_exists(hass: HomeAssistant) -> bool: """Ensure a configuration file exists in given configuration directory. Creating a default one if needed. Return boolean if configuration dir is ready to go. """ config_path = hass.config.path(YAML_CONFIG_FILE) if os.path.isfil...
[ "async", "def", "async_ensure_config_exists", "(", "hass", ":", "HomeAssistant", ")", "->", "bool", ":", "config_path", "=", "hass", ".", "config", ".", "path", "(", "YAML_CONFIG_FILE", ")", "if", "os", ".", "path", ".", "isfile", "(", "config_path", ")", ...
[ 238, 0 ]
[ 252, 50 ]
python
en
['en', 'en', 'en']
True
async_create_default_config
(hass: HomeAssistant)
Create a default configuration file in given configuration directory. Return if creation was successful.
Create a default configuration file in given configuration directory.
async def async_create_default_config(hass: HomeAssistant) -> bool: """Create a default configuration file in given configuration directory. Return if creation was successful. """ return await hass.async_add_executor_job( _write_default_config, hass.config.config_dir )
[ "async", "def", "async_create_default_config", "(", "hass", ":", "HomeAssistant", ")", "->", "bool", ":", "return", "await", "hass", ".", "async_add_executor_job", "(", "_write_default_config", ",", "hass", ".", "config", ".", "config_dir", ")" ]
[ 255, 0 ]
[ 262, 5 ]
python
en
['en', 'en', 'en']
True
_write_default_config
(config_dir: str)
Write the default config.
Write the default config.
def _write_default_config(config_dir: str) -> bool: """Write the default config.""" config_path = os.path.join(config_dir, YAML_CONFIG_FILE) secret_path = os.path.join(config_dir, SECRET_YAML) version_path = os.path.join(config_dir, VERSION_FILE) group_yaml_path = os.path.join(config_dir, GROUP_CONF...
[ "def", "_write_default_config", "(", "config_dir", ":", "str", ")", "->", "bool", ":", "config_path", "=", "os", ".", "path", ".", "join", "(", "config_dir", ",", "YAML_CONFIG_FILE", ")", "secret_path", "=", "os", ".", "path", ".", "join", "(", "config_dir...
[ 265, 0 ]
[ 303, 20 ]
python
en
['en', 'pt', 'en']
True
async_hass_config_yaml
(hass: HomeAssistant)
Load YAML from a Home Assistant configuration file. This function allow a component inside the asyncio loop to reload its configuration by itself. Include package merge.
Load YAML from a Home Assistant configuration file.
async def async_hass_config_yaml(hass: HomeAssistant) -> Dict: """Load YAML from a Home Assistant configuration file. This function allow a component inside the asyncio loop to reload its configuration by itself. Include package merge. """ # Not using async_add_executor_job because this is an inter...
[ "async", "def", "async_hass_config_yaml", "(", "hass", ":", "HomeAssistant", ")", "->", "Dict", ":", "# Not using async_add_executor_job because this is an internal method.", "config", "=", "await", "hass", ".", "loop", ".", "run_in_executor", "(", "None", ",", "load_ya...
[ 306, 0 ]
[ 318, 17 ]
python
en
['en', 'en', 'en']
True
load_yaml_config_file
(config_path: str)
Parse a YAML configuration file. Raises FileNotFoundError or HomeAssistantError. This method needs to run in an executor.
Parse a YAML configuration file.
def load_yaml_config_file(config_path: str) -> Dict[Any, Any]: """Parse a YAML configuration file. Raises FileNotFoundError or HomeAssistantError. This method needs to run in an executor. """ conf_dict = load_yaml(config_path) if not isinstance(conf_dict, dict): msg = ( f"...
[ "def", "load_yaml_config_file", "(", "config_path", ":", "str", ")", "->", "Dict", "[", "Any", ",", "Any", "]", ":", "conf_dict", "=", "load_yaml", "(", "config_path", ")", "if", "not", "isinstance", "(", "conf_dict", ",", "dict", ")", ":", "msg", "=", ...
[ 321, 0 ]
[ 341, 20 ]
python
en
['en', 'ny', 'en']
True
process_ha_config_upgrade
(hass: HomeAssistant)
Upgrade configuration if necessary. This method needs to run in an executor.
Upgrade configuration if necessary.
def process_ha_config_upgrade(hass: HomeAssistant) -> None: """Upgrade configuration if necessary. This method needs to run in an executor. """ version_path = hass.config.path(VERSION_FILE) try: with open(version_path) as inp: conf_version = inp.readline().strip() except Fi...
[ "def", "process_ha_config_upgrade", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "version_path", "=", "hass", ".", "config", ".", "path", "(", "VERSION_FILE", ")", "try", ":", "with", "open", "(", "version_path", ")", "as", "inp", ":", "conf_...
[ 344, 0 ]
[ 397, 31 ]
python
en
['es', 'ky', 'en']
False
async_log_exception
( ex: Exception, domain: str, config: Dict, hass: HomeAssistant, link: Optional[str] = None, )
Log an error for configuration validation. This method must be run in the event loop.
Log an error for configuration validation.
def async_log_exception( ex: Exception, domain: str, config: Dict, hass: HomeAssistant, link: Optional[str] = None, ) -> None: """Log an error for configuration validation. This method must be run in the event loop. """ if hass is not None: async_notify_setup_error(hass, dom...
[ "def", "async_log_exception", "(", "ex", ":", "Exception", ",", "domain", ":", "str", ",", "config", ":", "Dict", ",", "hass", ":", "HomeAssistant", ",", "link", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "None", ":", "if", "hass"...
[ 401, 0 ]
[ 414, 65 ]
python
en
['da', 'en', 'en']
True
_format_config_error
( ex: Exception, domain: str, config: Dict, link: Optional[str] = None )
Generate log exception for configuration validation. This method must be run in the event loop.
Generate log exception for configuration validation.
def _format_config_error( ex: Exception, domain: str, config: Dict, link: Optional[str] = None ) -> str: """Generate log exception for configuration validation. This method must be run in the event loop. """ message = f"Invalid config for [{domain}]: " if isinstance(ex, vol.Invalid): if...
[ "def", "_format_config_error", "(", "ex", ":", "Exception", ",", "domain", ":", "str", ",", "config", ":", "Dict", ",", "link", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "message", "=", "f\"Invalid config for [{domain}]: \"", "i...
[ 418, 0 ]
[ 451, 18 ]
python
en
['da', 'en', 'en']
True
async_process_ha_core_config
(hass: HomeAssistant, config: Dict)
Process the [homeassistant] section from the configuration. This method is a coroutine.
Process the [homeassistant] section from the configuration.
async def async_process_ha_core_config(hass: HomeAssistant, config: Dict) -> None: """Process the [homeassistant] section from the configuration. This method is a coroutine. """ config = CORE_CONFIG_SCHEMA(config) # Only load auth during startup. if not hasattr(hass, "auth"): auth_conf...
[ "async", "def", "async_process_ha_core_config", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "Dict", ")", "->", "None", ":", "config", "=", "CORE_CONFIG_SCHEMA", "(", "config", ")", "# Only load auth during startup.", "if", "not", "hasattr", "(", "hass",...
[ 454, 0 ]
[ 580, 9 ]
python
en
['en', 'en', 'en']
True
_log_pkg_error
(package: str, component: str, config: Dict, message: str)
Log an error while merging packages.
Log an error while merging packages.
def _log_pkg_error(package: str, component: str, config: Dict, message: str) -> None: """Log an error while merging packages.""" message = f"Package {package} setup failed. Integration {component} {message}" pack_config = config[CONF_CORE][CONF_PACKAGES].get(package, config) message += ( f" (Se...
[ "def", "_log_pkg_error", "(", "package", ":", "str", ",", "component", ":", "str", ",", "config", ":", "Dict", ",", "message", ":", "str", ")", "->", "None", ":", "message", "=", "f\"Package {package} setup failed. Integration {component} {message}\"", "pack_config"...
[ 583, 0 ]
[ 593, 26 ]
python
en
['en', 'en', 'en']
True
_identify_config_schema
(module: ModuleType)
Extract the schema and identify list or dict based.
Extract the schema and identify list or dict based.
def _identify_config_schema(module: ModuleType) -> Optional[str]: """Extract the schema and identify list or dict based.""" if not isinstance(module.CONFIG_SCHEMA, vol.Schema): # type: ignore return None schema = module.CONFIG_SCHEMA.schema # type: ignore if isinstance(schema, vol.All): ...
[ "def", "_identify_config_schema", "(", "module", ":", "ModuleType", ")", "->", "Optional", "[", "str", "]", ":", "if", "not", "isinstance", "(", "module", ".", "CONFIG_SCHEMA", ",", "vol", ".", "Schema", ")", ":", "# type: ignore", "return", "None", "schema"...
[ 596, 0 ]
[ 641, 15 ]
python
en
['en', 'en', 'en']
True
_recursive_merge
(conf: Dict[str, Any], package: Dict[str, Any])
Merge package into conf, recursively.
Merge package into conf, recursively.
def _recursive_merge(conf: Dict[str, Any], package: Dict[str, Any]) -> Union[bool, str]: """Merge package into conf, recursively.""" error: Union[bool, str] = False for key, pack_conf in package.items(): if isinstance(pack_conf, dict): if not pack_conf: continue ...
[ "def", "_recursive_merge", "(", "conf", ":", "Dict", "[", "str", ",", "Any", "]", ",", "package", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Union", "[", "bool", ",", "str", "]", ":", "error", ":", "Union", "[", "bool", ",", "str", "...
[ 644, 0 ]
[ 663, 16 ]
python
en
['it', 'en', 'en']
True
merge_packages_config
( hass: HomeAssistant, config: Dict, packages: Dict[str, Any], _log_pkg_error: Callable = _log_pkg_error, )
Merge packages into the top-level configuration. Mutate config.
Merge packages into the top-level configuration. Mutate config.
async def merge_packages_config( hass: HomeAssistant, config: Dict, packages: Dict[str, Any], _log_pkg_error: Callable = _log_pkg_error, ) -> Dict: """Merge packages into the top-level configuration. Mutate config.""" PACKAGES_CONFIG_SCHEMA(packages) for pack_name, pack_conf in packages.item...
[ "async", "def", "merge_packages_config", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "Dict", ",", "packages", ":", "Dict", "[", "str", ",", "Any", "]", ",", "_log_pkg_error", ":", "Callable", "=", "_log_pkg_error", ",", ")", "->", "Dict", ":", ...
[ 666, 0 ]
[ 729, 17 ]
python
en
['en', 'en', 'en']
True
async_process_component_config
( hass: HomeAssistant, config: Dict, integration: Integration )
Check component configuration and return processed configuration. Returns None on error. This method must be run in the event loop.
Check component configuration and return processed configuration.
async def async_process_component_config( hass: HomeAssistant, config: Dict, integration: Integration ) -> Optional[Dict]: """Check component configuration and return processed configuration. Returns None on error. This method must be run in the event loop. """ domain = integration.domain ...
[ "async", "def", "async_process_component_config", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "Dict", ",", "integration", ":", "Integration", ")", "->", "Optional", "[", "Dict", "]", ":", "domain", "=", "integration", ".", "domain", "try", ":", "c...
[ 732, 0 ]
[ 855, 17 ]
python
en
['en', 'en', 'en']
True
config_without_domain
(config: Dict, domain: str)
Return a config with all configuration for a domain removed.
Return a config with all configuration for a domain removed.
def config_without_domain(config: Dict, domain: str) -> Dict: """Return a config with all configuration for a domain removed.""" filter_keys = extract_domain_configs(config, domain) return {key: value for key, value in config.items() if key not in filter_keys}
[ "def", "config_without_domain", "(", "config", ":", "Dict", ",", "domain", ":", "str", ")", "->", "Dict", ":", "filter_keys", "=", "extract_domain_configs", "(", "config", ",", "domain", ")", "return", "{", "key", ":", "value", "for", "key", ",", "value", ...
[ 859, 0 ]
[ 862, 82 ]
python
en
['en', 'en', 'en']
True
async_check_ha_config_file
(hass: HomeAssistant)
Check if Home Assistant configuration file is valid. This method is a coroutine.
Check if Home Assistant configuration file is valid.
async def async_check_ha_config_file(hass: HomeAssistant) -> Optional[str]: """Check if Home Assistant configuration file is valid. This method is a coroutine. """ # pylint: disable=import-outside-toplevel import homeassistant.helpers.check_config as check_config res = await check_config.async...
[ "async", "def", "async_check_ha_config_file", "(", "hass", ":", "HomeAssistant", ")", "->", "Optional", "[", "str", "]", ":", "# pylint: disable=import-outside-toplevel", "import", "homeassistant", ".", "helpers", ".", "check_config", "as", "check_config", "res", "=",...
[ 865, 0 ]
[ 877, 24 ]
python
en
['en', 'en', 'en']
True
async_notify_setup_error
( hass: HomeAssistant, component: str, display_link: Optional[str] = None )
Print a persistent notification. This method must be run in the event loop.
Print a persistent notification.
def async_notify_setup_error( hass: HomeAssistant, component: str, display_link: Optional[str] = None ) -> None: """Print a persistent notification. This method must be run in the event loop. """ # pylint: disable=import-outside-toplevel from homeassistant.components import persistent_notificat...
[ "def", "async_notify_setup_error", "(", "hass", ":", "HomeAssistant", ",", "component", ":", "str", ",", "display_link", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "# pylint: disable=import-outside-toplevel", "from", "homeassistant", "....
[ 881, 0 ]
[ 908, 5 ]
python
en
['en', 'en', 'en']
True
_call_nix_update
(pkg, version)
calls nix-update from nixpkgs root dir
calls nix-update from nixpkgs root dir
def _call_nix_update(pkg, version): """calls nix-update from nixpkgs root dir""" nixpkgs_path = pathlib.Path(__file__).parent / '../../../../' return subprocess.check_output(['nix-update', pkg, '--version', version], cwd=nixpkgs_path)
[ "def", "_call_nix_update", "(", "pkg", ",", "version", ")", ":", "nixpkgs_path", "=", "pathlib", ".", "Path", "(", "__file__", ")", ".", "parent", "/", "'../../../../'", "return", "subprocess", ".", "check_output", "(", "[", "'nix-update'", ",", "pkg", ",", ...
[ 57, 0 ]
[ 60, 95 ]
python
en
['en', 'id', 'sw']
False
print_diffs
(rev, reverse)
Print out diffs for files used as templates for the NixOS module. The current package version found in the nixpkgs worktree the script is run from will be used to download the "from" file and REV used to download the "to" file for the diff, unless the '--reverse' flag is specified. REV should be t...
Print out diffs for files used as templates for the NixOS module.
def print_diffs(rev, reverse): """Print out diffs for files used as templates for the NixOS module. The current package version found in the nixpkgs worktree the script is run from will be used to download the "from" file and REV used to download the "to" file for the diff, unless the '--reverse' f...
[ "def", "print_diffs", "(", "rev", ",", "reverse", ")", ":", "if", "rev", "==", "'latest'", ":", "repo", "=", "DiscourseRepo", "(", ")", "rev", "=", "repo", ".", "tags", "[", "0", "]", "old_version", "=", "_get_current_package_version", "(", "'discourse'", ...
[ 106, 0 ]
[ 129, 47 ]
python
en
['en', 'en', 'en']
True
update
(rev)
Update gem files and version. REV should be the git rev to update to ('vX.Y.Z') or 'latest'; defaults to 'latest'.
Update gem files and version.
def update(rev): """Update gem files and version. REV should be the git rev to update to ('vX.Y.Z') or 'latest'; defaults to 'latest'. """ repo = DiscourseRepo() if rev == 'latest': rev = repo.tags[0] logger.debug(f"Using rev {rev}") version = repo.rev2version(rev) logger...
[ "def", "update", "(", "rev", ")", ":", "repo", "=", "DiscourseRepo", "(", ")", "if", "rev", "==", "'latest'", ":", "rev", "=", "repo", ".", "tags", "[", "0", "]", "logger", ".", "debug", "(", "f\"Using rev {rev}\"", ")", "version", "=", "repo", ".", ...
[ 134, 0 ]
[ 159, 56 ]
python
en
['en', 'en', 'en']
True
DiscourseRepo.rev2version
(tag: str)
normalize a tag to a version number. This obviously isn't very smart if we don't pass something that looks like a tag :param tag: the tag to normalize :return: a normalized version number
normalize a tag to a version number. This obviously isn't very smart if we don't pass something that looks like a tag :param tag: the tag to normalize :return: a normalized version number
def rev2version(tag: str) -> str: """ normalize a tag to a version number. This obviously isn't very smart if we don't pass something that looks like a tag :param tag: the tag to normalize :return: a normalized version number """ # strip v prefix return re...
[ "def", "rev2version", "(", "tag", ":", "str", ")", "->", "str", ":", "# strip v prefix", "return", "re", ".", "sub", "(", "r'^v'", ",", "''", ",", "tag", ")" ]
[ 38, 4 ]
[ 46, 37 ]
python
en
['en', 'error', 'th']
False
DiscourseRepo.get_file
(self, filepath, rev)
returns file contents at a given rev :param filepath: the path to the file, relative to the repo root :param rev: the rev to fetch at :return:
returns file contents at a given rev :param filepath: the path to the file, relative to the repo root :param rev: the rev to fetch at :return:
def get_file(self, filepath, rev): """returns file contents at a given rev :param filepath: the path to the file, relative to the repo root :param rev: the rev to fetch at :return: """ return requests.get(f'https://raw.githubusercontent.com/{self.owner}/{self.repo}/{rev}/{filepa...
[ "def", "get_file", "(", "self", ",", "filepath", ",", "rev", ")", ":", "return", "requests", ".", "get", "(", "f'https://raw.githubusercontent.com/{self.owner}/{self.repo}/{rev}/{filepath}'", ")", ".", "text" ]
[ 48, 4 ]
[ 54, 112 ]
python
en
['en', 'en', 'en']
True
DictRegistry.register
( self, name: Union[int, str], item: Union[str, CALLABLE_T] = None )
Return decorator to register item with a specific name.
Return decorator to register item with a specific name.
def register( self, name: Union[int, str], item: Union[str, CALLABLE_T] = None ) -> Callable[[CALLABLE_T], CALLABLE_T]: """Return decorator to register item with a specific name.""" def decorator(channel: CALLABLE_T) -> CALLABLE_T: """Register decorated channel or item.""" ...
[ "def", "register", "(", "self", ",", "name", ":", "Union", "[", "int", ",", "str", "]", ",", "item", ":", "Union", "[", "str", ",", "CALLABLE_T", "]", "=", "None", ")", "->", "Callable", "[", "[", "CALLABLE_T", "]", ",", "CALLABLE_T", "]", ":", "...
[ 9, 4 ]
[ 22, 24 ]
python
en
['en', 'en', 'en']
True
SetRegistry.register
(self, name: Union[int, str])
Return decorator to register item with a specific name.
Return decorator to register item with a specific name.
def register(self, name: Union[int, str]) -> Callable[[CALLABLE_T], CALLABLE_T]: """Return decorator to register item with a specific name.""" def decorator(channel: CALLABLE_T) -> CALLABLE_T: """Register decorated channel or item.""" self.add(name) return channel ...
[ "def", "register", "(", "self", ",", "name", ":", "Union", "[", "int", ",", "str", "]", ")", "->", "Callable", "[", "[", "CALLABLE_T", "]", ",", "CALLABLE_T", "]", ":", "def", "decorator", "(", "channel", ":", "CALLABLE_T", ")", "->", "CALLABLE_T", "...
[ 28, 4 ]
[ 36, 24 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Demo binary sensor platform.
Set up the Demo binary sensor platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Demo binary sensor platform.""" async_add_entities( [ DemoBinarySensor( "binary_1", "Basement Floor Wet", False, DEVICE_CLASS_MOISTURE ), DemoBinarySen...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities", "(", "[", "DemoBinarySensor", "(", "\"binary_1\"", ",", "\"Basement Floor Wet\"", ",", "False", ",", ...
[ 10, 0 ]
[ 21, 5 ]
python
en
['en', 'pt', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Demo config entry.
Set up the Demo config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Demo config entry.""" await async_setup_platform(hass, {}, async_add_entities)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "await", "async_setup_platform", "(", "hass", ",", "{", "}", ",", "async_add_entities", ")" ]
[ 24, 0 ]
[ 26, 60 ]
python
en
['en', 'en', 'en']
True
DemoBinarySensor.__init__
(self, unique_id, name, state, device_class)
Initialize the demo sensor.
Initialize the demo sensor.
def __init__(self, unique_id, name, state, device_class): """Initialize the demo sensor.""" self._unique_id = unique_id self._name = name self._state = state self._sensor_type = device_class
[ "def", "__init__", "(", "self", ",", "unique_id", ",", "name", ",", "state", ",", "device_class", ")", ":", "self", ".", "_unique_id", "=", "unique_id", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "state", "self", ".", "_sensor_type", ...
[ 32, 4 ]
[ 37, 40 ]
python
en
['en', 'pt', 'en']
True
DemoBinarySensor.device_info
(self)
Return device info.
Return device info.
def device_info(self): """Return device info.""" return { "identifiers": { # Serial numbers are unique identifiers within a specific domain (DOMAIN, self.unique_id) }, "name": self.name, }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "# Serial numbers are unique identifiers within a specific domain", "(", "DOMAIN", ",", "self", ".", "unique_id", ")", "}", ",", "\"name\"", ":", "self", ".", "name", ",", "...
[ 40, 4 ]
[ 48, 9 ]
python
en
['es', 'hr', 'en']
False
DemoBinarySensor.unique_id
(self)
Return the unique id.
Return the unique id.
def unique_id(self): """Return the unique id.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 51, 4 ]
[ 53, 30 ]
python
en
['en', 'la', 'en']
True
DemoBinarySensor.device_class
(self)
Return the class of this sensor.
Return the class of this sensor.
def device_class(self): """Return the class of this sensor.""" return self._sensor_type
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_sensor_type" ]
[ 56, 4 ]
[ 58, 32 ]
python
en
['en', 'en', 'en']
True
DemoBinarySensor.should_poll
(self)
No polling needed for a demo binary sensor.
No polling needed for a demo binary sensor.
def should_poll(self): """No polling needed for a demo binary sensor.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 61, 4 ]
[ 63, 20 ]
python
en
['en', 'pt', 'en']
True
DemoBinarySensor.name
(self)
Return the name of the binary sensor.
Return the name of the binary sensor.
def name(self): """Return the name of the binary sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 66, 4 ]
[ 68, 25 ]
python
en
['en', 'mi', 'en']
True
DemoBinarySensor.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._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 71, 4 ]
[ 73, 26 ]
python
en
['en', 'fy', 'en']
True
get_pairs
(word)
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
Return set of symbol pairs in a word.
def get_pairs(word): """ Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). """ pairs = set() prev_char = word[0] for char in word[1:]: pairs.add((prev_char, char)) prev_char = char pairs = set(pairs) ...
[ "def", "get_pairs", "(", "word", ")", ":", "pairs", "=", "set", "(", ")", "prev_char", "=", "word", "[", "0", "]", "for", "char", "in", "word", "[", "1", ":", "]", ":", "pairs", ".", "add", "(", "(", "prev_char", ",", "char", ")", ")", "prev_ch...
[ 51, 0 ]
[ 64, 16 ]
python
en
['en', 'error', 'th']
False
_replace_html_entities
(text, keep=(), remove_illegal=True, encoding="utf-8")
Remove entities from text by converting them to their corresponding unicode character. Args: text: A unicode string or a byte string encoded in the given `encoding` (which defaults to 'utf-8'). keep (list): List of entity names which should not be replaced. This support...
Remove entities from text by converting them to their corresponding unicode character.
def _replace_html_entities(text, keep=(), remove_illegal=True, encoding="utf-8"): """ Remove entities from text by converting them to their corresponding unicode character. Args: text: A unicode string or a byte string encoded in the given `encoding` (which defaults to 'utf-8'). ...
[ "def", "_replace_html_entities", "(", "text", ",", "keep", "=", "(", ")", ",", "remove_illegal", "=", "True", ",", "encoding", "=", "\"utf-8\"", ")", ":", "def", "_convert_entity", "(", "match", ")", ":", "entity_body", "=", "match", ".", "group", "(", "...
[ 620, 0 ]
[ 671, 71 ]
python
en
['en', 'error', 'th']
False
reduce_lengthening
(text)
Replace repeated character sequences of length 3 or greater with sequences of length 3.
Replace repeated character sequences of length 3 or greater with sequences of length 3.
def reduce_lengthening(text): """ Replace repeated character sequences of length 3 or greater with sequences of length 3. """ pattern = regex.compile(r"(.)\1{2,}") return pattern.sub(r"\1\1\1", text)
[ "def", "reduce_lengthening", "(", "text", ")", ":", "pattern", "=", "regex", ".", "compile", "(", "r\"(.)\\1{2,}\"", ")", "return", "pattern", ".", "sub", "(", "r\"\\1\\1\\1\"", ",", "text", ")" ]
[ 731, 0 ]
[ 736, 39 ]
python
en
['en', 'error', 'th']
False
remove_handles
(text)
Remove Twitter username handles from text.
Remove Twitter username handles from text.
def remove_handles(text): """ Remove Twitter username handles from text. """ pattern = regex.compile( r"(?<![A-Za-z0-9_!@#\$%&*])@(([A-Za-z0-9_]){20}(?!@))|(?<![A-Za-z0-9_!@#\$%&*])@(([A-Za-z0-9_]){1,19})(?![A-Za-z0-9_]*@)" ) # Substitute handles with ' ' to ensure that text on either si...
[ "def", "remove_handles", "(", "text", ")", ":", "pattern", "=", "regex", ".", "compile", "(", "r\"(?<![A-Za-z0-9_!@#\\$%&*])@(([A-Za-z0-9_]){20}(?!@))|(?<![A-Za-z0-9_!@#\\$%&*])@(([A-Za-z0-9_]){1,19})(?![A-Za-z0-9_]*@)\"", ")", "# Substitute handles with ' ' to ensure that text on either...
[ 739, 0 ]
[ 747, 33 ]
python
en
['en', 'error', 'th']
False
casual_tokenize
(text, preserve_case=True, reduce_len=False, strip_handles=False)
Convenience function for wrapping the tokenizer.
Convenience function for wrapping the tokenizer.
def casual_tokenize(text, preserve_case=True, reduce_len=False, strip_handles=False): """ Convenience function for wrapping the tokenizer. """ return TweetTokenizer(preserve_case=preserve_case, reduce_len=reduce_len, strip_handles=strip_handles).tokenize( text )
[ "def", "casual_tokenize", "(", "text", ",", "preserve_case", "=", "True", ",", "reduce_len", "=", "False", ",", "strip_handles", "=", "False", ")", ":", "return", "TweetTokenizer", "(", "preserve_case", "=", "preserve_case", ",", "reduce_len", "=", "reduce_len",...
[ 755, 0 ]
[ 761, 5 ]
python
en
['en', 'error', 'th']
False
BertweetTokenizer.build_inputs_with_special_tokens
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A BERTweet sequence has the following format: - single sequence: ``<s> X </s>`` - pair of sequences: ``<s> A </s></s> B </s>`` Args: ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A BERTweet sequence has the following format:
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A BERTweet sequence h...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "if", "token_ids_1", ...
[ 176, 4 ]
[ 200, 64 ]
python
en
['en', 'error', 'th']
False
BertweetTokenizer.get_special_tokens_mask
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False )
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`List[int]`,...
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method.
def get_special_tokens_mask( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False ) -> List[int]: """ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens ...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ",", "already_has_special_tokens", ":", "bool", "=", "False", ")", "->", ...
[ 202, 4 ]
[ 231, 87 ]
python
en
['en', 'error', 'th']
False
BertweetTokenizer.create_token_type_ids_from_sequences
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Create a mask from the two sequences passed to be used in a sequence-pair classification task. BERTweet does not make use of token type ids, therefore a list of zeros is returned. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`List...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. BERTweet does not make use of token type ids, therefore a list of zeros is returned.
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. BERTweet does not make use of token type ids, therefore a...
[ "def", "create_token_type_ids_from_sequences", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[",...
[ 233, 4 ]
[ 255, 75 ]
python
en
['en', 'error', 'th']
False
BertweetTokenizer._tokenize
(self, text)
Tokenize a string.
Tokenize a string.
def _tokenize(self, text): """Tokenize a string.""" if self.normalization: # Perform Tweet normalization before performing BPE text = self.normalizeTweet(text) split_tokens = [] words = re.findall(r"\S+\n?", text) for token in words: split_tokens.extend(...
[ "def", "_tokenize", "(", "self", ",", "text", ")", ":", "if", "self", ".", "normalization", ":", "# Perform Tweet normalization before performing BPE", "text", "=", "self", ".", "normalizeTweet", "(", "text", ")", "split_tokens", "=", "[", "]", "words", "=", "...
[ 308, 4 ]
[ 317, 27 ]
python
en
['en', 'gl', 'en']
True
BertweetTokenizer.normalizeTweet
(self, tweet)
Normalize a raw Tweet
Normalize a raw Tweet
def normalizeTweet(self, tweet): """ Normalize a raw Tweet """ for punct in self.special_puncts: tweet = tweet.replace(punct, self.special_puncts[punct]) tokens = self.tweetPreprocessor.tokenize(tweet) normTweet = " ".join([self.normalizeToken(token) for toke...
[ "def", "normalizeTweet", "(", "self", ",", "tweet", ")", ":", "for", "punct", "in", "self", ".", "special_puncts", ":", "tweet", "=", "tweet", ".", "replace", "(", "punct", ",", "self", ".", "special_puncts", "[", "punct", "]", ")", "tokens", "=", "sel...
[ 319, 4 ]
[ 351, 42 ]
python
en
['en', 'error', 'th']
False
BertweetTokenizer.normalizeToken
(self, token)
Normalize tokens in a Tweet
Normalize tokens in a Tweet
def normalizeToken(self, token): """ Normalize tokens in a Tweet """ lowercased_token = token.lower() if token.startswith("@"): return "@USER" elif lowercased_token.startswith("http") or lowercased_token.startswith("www"): return "HTTPURL" ...
[ "def", "normalizeToken", "(", "self", ",", "token", ")", ":", "lowercased_token", "=", "token", ".", "lower", "(", ")", "if", "token", ".", "startswith", "(", "\"@\"", ")", ":", "return", "\"@USER\"", "elif", "lowercased_token", ".", "startswith", "(", "\"...
[ 353, 4 ]
[ 370, 24 ]
python
en
['en', 'error', 'th']
False
BertweetTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.encoder.get(token, self.encoder.get(self.unk_token))
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "encoder", ".", "get", "(", "token", ",", "self", ".", "encoder", ".", "get", "(", "self", ".", "unk_token", ")", ")" ]
[ 372, 4 ]
[ 374, 72 ]
python
en
['en', 'en', 'en']
True
BertweetTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" return self.decoder.get(index, self.unk_token)
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "return", "self", ".", "decoder", ".", "get", "(", "index", ",", "self", ".", "unk_token", ")" ]
[ 376, 4 ]
[ 378, 54 ]
python
en
['en', 'en', 'en']
True
BertweetTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (string) in a single string.
Converts a sequence of tokens (string) in a single string.
def convert_tokens_to_string(self, tokens): """ Converts a sequence of tokens (string) in a single string. """ out_string = " ".join(tokens).replace("@@ ", "").strip() return out_string
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "out_string", "=", "\" \"", ".", "join", "(", "tokens", ")", ".", "replace", "(", "\"@@ \"", ",", "\"\"", ")", ".", "strip", "(", ")", "return", "out_string" ]
[ 380, 4 ]
[ 383, 25 ]
python
en
['en', 'en', 'en']
True
BertweetTokenizer.add_from_file
(self, f)
Loads a pre-existing dictionary from a text file and adds its symbols to this instance.
Loads a pre-existing dictionary from a text file and adds its symbols to this instance.
def add_from_file(self, f): """ Loads a pre-existing dictionary from a text file and adds its symbols to this instance. """ if isinstance(f, str): try: with open(f, "r", encoding="utf-8") as fd: self.add_from_file(fd) except Fil...
[ "def", "add_from_file", "(", "self", ",", "f", ")", ":", "if", "isinstance", "(", "f", ",", "str", ")", ":", "try", ":", "with", "open", "(", "f", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "fd", ":", "self", ".", "add_from_file", ...
[ 410, 4 ]
[ 431, 50 ]
python
en
['en', 'error', 'th']
False
TweetTokenizer.tokenize
(self, text)
Args: text: str Returns: list(str) A tokenized list of strings; concatenating this list returns the original string if `preserve_case=False`
Args: text: str
def tokenize(self, text): """ Args: text: str Returns: list(str) A tokenized list of strings; concatenating this list returns the original string if `preserve_case=False` """ # Fix HTML character entities: text = _replace_html_entities(text) #...
[ "def", "tokenize", "(", "self", ",", "text", ")", ":", "# Fix HTML character entities:", "text", "=", "_replace_html_entities", "(", "text", ")", "# Remove username handles", "if", "self", ".", "strip_handles", ":", "text", "=", "remove_handles", "(", "text", ")",...
[ 700, 4 ]
[ 723, 20 ]
python
en
['en', 'error', 'th']
False
get_master_gateway
(hass)
Return the gateway which is marked as master.
Return the gateway which is marked as master.
def get_master_gateway(hass): """Return the gateway which is marked as master.""" for gateway in hass.data[DOMAIN].values(): if gateway.master: return gateway
[ "def", "get_master_gateway", "(", "hass", ")", ":", "for", "gateway", "in", "hass", ".", "data", "[", "DOMAIN", "]", ".", "values", "(", ")", ":", "if", "gateway", ".", "master", ":", "return", "gateway" ]
[ 38, 0 ]
[ 42, 26 ]
python
en
['en', 'en', 'en']
True
DeconzFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return DeconzOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "DeconzOptionsFlowHandler", "(", "config_entry", ")" ]
[ 55, 4 ]
[ 57, 53 ]
python
en
['en', 'en', 'en']
True
DeconzFlowHandler.__init__
(self)
Initialize the deCONZ config flow.
Initialize the deCONZ config flow.
def __init__(self): """Initialize the deCONZ config flow.""" self.bridge_id = None self.bridges = [] self.deconz_config = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "bridge_id", "=", "None", "self", ".", "bridges", "=", "[", "]", "self", ".", "deconz_config", "=", "{", "}" ]
[ 59, 4 ]
[ 63, 31 ]
python
en
['en', 'fr', 'en']
True
DeconzFlowHandler.async_step_user
(self, user_input=None)
Handle a deCONZ config flow start. Let user choose between discovered bridges and manual configuration. If no bridge is found allow user to manually input configuration.
Handle a deCONZ config flow start.
async def async_step_user(self, user_input=None): """Handle a deCONZ config flow start. Let user choose between discovered bridges and manual configuration. If no bridge is found allow user to manually input configuration. """ if user_input is not None: if CONF_MANU...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "if", "CONF_MANUAL_INPUT", "==", "user_input", "[", "CONF_HOST", "]", ":", "return", "await", "self", ".", "async_step_man...
[ 65, 4 ]
[ 109, 51 ]
python
en
['en', 'lb', 'pt']
False
DeconzFlowHandler.async_step_manual_input
(self, user_input=None)
Manual configuration.
Manual configuration.
async def async_step_manual_input(self, user_input=None): """Manual configuration.""" if user_input: self.deconz_config = user_input return await self.async_step_link() return self.async_show_form( step_id="manual_input", data_schema=vol.Schema( ...
[ "async", "def", "async_step_manual_input", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", ":", "self", ".", "deconz_config", "=", "user_input", "return", "await", "self", ".", "async_step_link", "(", ")", "return", "self", ".", "a...
[ 111, 4 ]
[ 125, 9 ]
python
en
['en', 'sm', 'en']
False
DeconzFlowHandler.async_step_link
(self, user_input=None)
Attempt to link with the deCONZ bridge.
Attempt to link with the deCONZ bridge.
async def async_step_link(self, user_input=None): """Attempt to link with the deCONZ bridge.""" errors = {} LOGGER.debug( "Preparing linking with deCONZ gateway %s", pformat(self.deconz_config) ) if user_input is not None: session = aiohttp_client.async_...
[ "async", "def", "async_step_link", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "LOGGER", ".", "debug", "(", "\"Preparing linking with deCONZ gateway %s\"", ",", "pformat", "(", "self", ".", "deconz_config", ")", ")", "if", ...
[ 127, 4 ]
[ 149, 66 ]
python
en
['en', 'en', 'en']
True
DeconzFlowHandler._create_entry
(self)
Create entry for gateway.
Create entry for gateway.
async def _create_entry(self): """Create entry for gateway.""" if not self.bridge_id: session = aiohttp_client.async_get_clientsession(self.hass) try: with async_timeout.timeout(10): self.bridge_id = await async_get_bridge_id( ...
[ "async", "def", "_create_entry", "(", "self", ")", ":", "if", "not", "self", ".", "bridge_id", ":", "session", "=", "aiohttp_client", ".", "async_get_clientsession", "(", "self", ".", "hass", ")", "try", ":", "with", "async_timeout", ".", "timeout", "(", "...
[ 151, 4 ]
[ 177, 85 ]
python
en
['en', 'en', 'en']
True