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
async_unload_entry
( hass: HomeAssistant, config_entry: config_entries.ConfigEntry )
Will be called once we remove it.
Will be called once we remove it.
async def async_unload_entry( hass: HomeAssistant, config_entry: config_entries.ConfigEntry ) -> bool: """Will be called once we remove it.""" return True
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ")", "->", "bool", ":", "return", "True" ]
[ 272, 0 ]
[ 276, 15 ]
python
en
['en', 'en', 'en']
True
ZoneStorageCollection._process_create_data
(self, data: dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: dict) -> dict: """Validate the config is valid.""" return cast(dict, self.CREATE_SCHEMA(data))
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "dict", ")", "->", "dict", ":", "return", "cast", "(", "dict", ",", "self", ".", "CREATE_SCHEMA", "(", "data", ")", ")" ]
[ 164, 4 ]
[ 166, 51 ]
python
en
['en', 'en', 'en']
True
ZoneStorageCollection._get_suggested_id
(self, info: dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: dict) -> str: """Suggest an ID based on the config.""" return cast(str, info[CONF_NAME])
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "dict", ")", "->", "str", ":", "return", "cast", "(", "str", ",", "info", "[", "CONF_NAME", "]", ")" ]
[ 169, 4 ]
[ 171, 41 ]
python
en
['en', 'en', 'en']
True
ZoneStorageCollection._update_data
(self, data: dict, update_data: dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: dict) -> dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) return {**data, **update_data}
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "dict", ")", "->", "dict", ":", "update_data", "=", "self", ".", "UPDATE_SCHEMA", "(", "update_data", ")", "return", "{", "*", "*", "data", ",", "*", "*", ...
[ 173, 4 ]
[ 176, 38 ]
python
en
['en', 'en', 'en']
True
Zone.__init__
(self, config: dict)
Initialize the zone.
Initialize the zone.
def __init__(self, config: dict) -> None: """Initialize the zone.""" self._config = config self.editable = True self._attrs: dict | None = None self._generate_attrs()
[ "def", "__init__", "(", "self", ",", "config", ":", "dict", ")", "->", "None", ":", "self", ".", "_config", "=", "config", "self", ".", "editable", "=", "True", "self", ".", "_attrs", ":", "dict", "|", "None", "=", "None", "self", ".", "_generate_att...
[ 282, 4 ]
[ 287, 30 ]
python
en
['en', 'en', 'en']
True
Zone.from_yaml
(cls, config: dict)
Return entity instance initialized from yaml storage.
Return entity instance initialized from yaml storage.
def from_yaml(cls, config: dict) -> Zone: """Return entity instance initialized from yaml storage.""" zone = cls(config) zone.editable = False zone._generate_attrs() return zone
[ "def", "from_yaml", "(", "cls", ",", "config", ":", "dict", ")", "->", "Zone", ":", "zone", "=", "cls", "(", "config", ")", "zone", ".", "editable", "=", "False", "zone", ".", "_generate_attrs", "(", ")", "return", "zone" ]
[ 290, 4 ]
[ 295, 19 ]
python
en
['en', 'pl', 'en']
True
Zone.state
(self)
Return the state property really does nothing for a zone.
Return the state property really does nothing for a zone.
def state(self) -> str: """Return the state property really does nothing for a zone.""" return "zoning"
[ "def", "state", "(", "self", ")", "->", "str", ":", "return", "\"zoning\"" ]
[ 298, 4 ]
[ 300, 23 ]
python
en
['en', 'en', 'en']
True
Zone.name
(self)
Return name.
Return name.
def name(self) -> str: """Return name.""" return cast(str, self._config[CONF_NAME])
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "cast", "(", "str", ",", "self", ".", "_config", "[", "CONF_NAME", "]", ")" ]
[ 303, 4 ]
[ 305, 49 ]
python
en
['en', 'ig', 'en']
False
Zone.unique_id
(self)
Return unique ID.
Return unique ID.
def unique_id(self) -> str | None: """Return unique ID.""" return self._config.get(CONF_ID)
[ "def", "unique_id", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ID", ")" ]
[ 308, 4 ]
[ 310, 40 ]
python
en
['fr', 'la', 'en']
False
Zone.icon
(self)
Return the icon if any.
Return the icon if any.
def icon(self) -> str | None: """Return the icon if any.""" return self._config.get(CONF_ICON)
[ "def", "icon", "(", "self", ")", "->", "str", "|", "None", ":", "return", "self", ".", "_config", ".", "get", "(", "CONF_ICON", ")" ]
[ 313, 4 ]
[ 315, 42 ]
python
en
['en', 'en', 'en']
True
Zone.extra_state_attributes
(self)
Return the state attributes of the zone.
Return the state attributes of the zone.
def extra_state_attributes(self) -> dict | None: """Return the state attributes of the zone.""" return self._attrs
[ "def", "extra_state_attributes", "(", "self", ")", "->", "dict", "|", "None", ":", "return", "self", ".", "_attrs" ]
[ 318, 4 ]
[ 320, 26 ]
python
en
['en', 'en', 'en']
True
Zone.should_poll
(self)
Zone does not poll.
Zone does not poll.
def should_poll(self) -> bool: """Zone does not poll.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 323, 4 ]
[ 325, 20 ]
python
en
['it', 'en', 'en']
True
Zone.async_update_config
(self, config: dict)
Handle when the config is updated.
Handle when the config is updated.
async def async_update_config(self, config: dict) -> None: """Handle when the config is updated.""" if self._config == config: return self._config = config self._generate_attrs() self.async_write_ha_state()
[ "async", "def", "async_update_config", "(", "self", ",", "config", ":", "dict", ")", "->", "None", ":", "if", "self", ".", "_config", "==", "config", ":", "return", "self", ".", "_config", "=", "config", "self", ".", "_generate_attrs", "(", ")", "self", ...
[ 327, 4 ]
[ 333, 35 ]
python
en
['en', 'en', 'en']
True
Zone._generate_attrs
(self)
Generate new attrs based on config.
Generate new attrs based on config.
def _generate_attrs(self) -> None: """Generate new attrs based on config.""" self._attrs = { ATTR_LATITUDE: self._config[CONF_LATITUDE], ATTR_LONGITUDE: self._config[CONF_LONGITUDE], ATTR_RADIUS: self._config[CONF_RADIUS], ATTR_PASSIVE: self._config[CONF_P...
[ "def", "_generate_attrs", "(", "self", ")", "->", "None", ":", "self", ".", "_attrs", "=", "{", "ATTR_LATITUDE", ":", "self", ".", "_config", "[", "CONF_LATITUDE", "]", ",", "ATTR_LONGITUDE", ":", "self", ".", "_config", "[", "CONF_LONGITUDE", "]", ",", ...
[ 336, 4 ]
[ 344, 9 ]
python
en
['en', 'en', 'en']
True
validate_github_profile
(value)
validate github profile
validate github profile
def validate_github_profile(value): """validate github profile""" pattern = r'^github.com\/[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*\/?$' if re.search(pattern, value) is None: raise ValidationError( _('%(value)s is not a valid github profile.'), params={'value': value}, )
[ "def", "validate_github_profile", "(", "value", ")", ":", "pattern", "=", "r'^github.com\\/[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*\\/?$'", "if", "re", ".", "search", "(", "pattern", ",", "value", ")", "is", "None", ":", "raise", "ValidationError", "(", "_", "(", "'%(value)...
[ 12, 0 ]
[ 20, 9 ]
python
en
['en', 'et', 'sw']
False
ChildDogAllOf.openapi_types
()
This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type.
This must be a method because a model may have properties that are of type self, this must run after the class is loaded
def openapi_types(): """ This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type. """ retu...
[ "def", "openapi_types", "(", ")", ":", "return", "{", "'bark'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "}" ]
[ 64, 4 ]
[ 75, 9 ]
python
en
['en', 'error', 'th']
False
ChildDogAllOf.__init__
(self, *args, **kwargs)
ChildDogAllOf - a model defined in OpenAPI Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. ...
ChildDogAllOf - a model defined in OpenAPI
def __init__(self, *args, **kwargs): # noqa: E501 """ChildDogAllOf - a model defined in OpenAPI Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be rai...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ".", "pop", "(", "'_spec_property...
[ 98, 4 ]
[ 165, 46 ]
python
en
['en', 'it', 'en']
True
async_describe_on_off_states
( hass: HomeAssistant, registry: GroupIntegrationRegistry )
Describe group on off states.
Describe group on off states.
def async_describe_on_off_states( hass: HomeAssistant, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states({STATE_LOCKED}, STATE_UNLOCKED)
[ "def", "async_describe_on_off_states", "(", "hass", ":", "HomeAssistant", ",", "registry", ":", "GroupIntegrationRegistry", ")", "->", "None", ":", "registry", ".", "on_off_states", "(", "{", "STATE_LOCKED", "}", ",", "STATE_UNLOCKED", ")" ]
[ 9, 0 ]
[ 13, 58 ]
python
en
['en', 'en', 'en']
True
test_bad_posting
(hass, hass_client_no_auth)
Test that posting to wrong api endpoint fails.
Test that posting to wrong api endpoint fails.
async def test_bad_posting(hass, hass_client_no_auth): """Test that posting to wrong api endpoint fails.""" await async_process_ha_core_config( hass, {"external_url": "http://example.com"}, ) await async_setup_component( hass, "camera", { "camera": { ...
[ "async", "def", "test_bad_posting", "(", "hass", ",", "hass_client_no_auth", ")", ":", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"external_url\"", ":", "\"http://example.com\"", "}", ",", ")", "await", "async_setup_component", "(", "hass", ",...
[ 11, 0 ]
[ 39, 39 ]
python
en
['en', 'en', 'en']
True
test_posting_url
(hass, hass_client_no_auth)
Test that posting to api endpoint works.
Test that posting to api endpoint works.
async def test_posting_url(hass, hass_client_no_auth): """Test that posting to api endpoint works.""" await async_process_ha_core_config( hass, {"external_url": "http://example.com"}, ) await async_setup_component( hass, "camera", { "camera": { ...
[ "async", "def", "test_posting_url", "(", "hass", ",", "hass_client_no_auth", ")", ":", "await", "async_process_ha_core_config", "(", "hass", ",", "{", "\"external_url\"", ":", "\"http://example.com\"", "}", ",", ")", "await", "async_setup_component", "(", "hass", ",...
[ 42, 0 ]
[ 84, 39 ]
python
en
['en', 'en', 'en']
True
test_x86_enabled_documentation
()
Here we test the examples in the documentation automatically using doctest. We set up an environment which is similar to what a rule writer might see - a '/sys/devices/system/cpu/vulnerabilities/*' output that has been passed in as a parameter to the rule declaration.
Here we test the examples in the documentation automatically using doctest. We set up an environment which is similar to what a rule writer might see - a '/sys/devices/system/cpu/vulnerabilities/*' output that has been passed in as a parameter to the rule declaration.
def test_x86_enabled_documentation(): """ Here we test the examples in the documentation automatically using doctest. We set up an environment which is similar to what a rule writer might see - a '/sys/devices/system/cpu/vulnerabilities/*' output that has been passed in as a parameter to the rule d...
[ "def", "test_x86_enabled_documentation", "(", ")", ":", "parser1", "=", "CpuVulns", "(", "INPUT1", ")", "parser2", "=", "CpuVulns", "(", "INPUT2", ")", "env", "=", "{", "'cvb'", ":", "CpuVulnsAll", "(", "[", "parser1", ",", "parser2", "]", ")", "}", "fai...
[ 100, 0 ]
[ 112, 22 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up a MJPEG IP Camera.
Set up a MJPEG IP Camera.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up a MJPEG IP Camera.""" filter_urllib3_logging() if discovery_info: config = PLATFORM_SCHEMA(discovery_info) async_add_entities([MjpegCamera(config)])
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "filter_urllib3_logging", "(", ")", "if", "discovery_info", ":", "config", "=", "PLATFORM_SCHEMA", "(", "discovery_info", "...
[ 53, 0 ]
[ 59, 45 ]
python
en
['en', 'cs', 'en']
True
filter_urllib3_logging
()
Filter header errors from urllib3 due to a urllib3 bug.
Filter header errors from urllib3 due to a urllib3 bug.
def filter_urllib3_logging(): """Filter header errors from urllib3 due to a urllib3 bug.""" urllib3_logger = logging.getLogger("urllib3.connectionpool") if not any(isinstance(x, NoHeaderErrorFilter) for x in urllib3_logger.filters): urllib3_logger.addFilter(NoHeaderErrorFilter())
[ "def", "filter_urllib3_logging", "(", ")", ":", "urllib3_logger", "=", "logging", ".", "getLogger", "(", "\"urllib3.connectionpool\"", ")", "if", "not", "any", "(", "isinstance", "(", "x", ",", "NoHeaderErrorFilter", ")", "for", "x", "in", "urllib3_logger", ".",...
[ 62, 0 ]
[ 66, 55 ]
python
en
['en', 'sv', 'en']
True
extract_image_from_mjpeg
(stream)
Take in a MJPEG stream object, return the jpg from it.
Take in a MJPEG stream object, return the jpg from it.
def extract_image_from_mjpeg(stream): """Take in a MJPEG stream object, return the jpg from it.""" data = b"" for chunk in stream: data += chunk jpg_end = data.find(b"\xff\xd9") if jpg_end == -1: continue jpg_start = data.find(b"\xff\xd8") if jpg_start...
[ "def", "extract_image_from_mjpeg", "(", "stream", ")", ":", "data", "=", "b\"\"", "for", "chunk", "in", "stream", ":", "data", "+=", "chunk", "jpg_end", "=", "data", ".", "find", "(", "b\"\\xff\\xd9\"", ")", "if", "jpg_end", "==", "-", "1", ":", "continu...
[ 69, 0 ]
[ 85, 44 ]
python
en
['en', 'fy', 'en']
True
MjpegCamera.__init__
(self, device_info)
Initialize a MJPEG camera.
Initialize a MJPEG camera.
def __init__(self, device_info): """Initialize a MJPEG camera.""" super().__init__() self._name = device_info.get(CONF_NAME) self._authentication = device_info.get(CONF_AUTHENTICATION) self._username = device_info.get(CONF_USERNAME) self._password = device_info.get(CONF_P...
[ "def", "__init__", "(", "self", ",", "device_info", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_name", "=", "device_info", ".", "get", "(", "CONF_NAME", ")", "self", ".", "_authentication", "=", "device_info", ".", "get", "("...
[ 91, 4 ]
[ 108, 59 ]
python
cs
['en', 'cs', 'it']
False
MjpegCamera.async_camera_image
( self, width: int | None = None, height: int | None = None )
Return a still image response from the camera.
Return a still image response from the camera.
async def async_camera_image( self, width: int | None = None, height: int | None = None ) -> bytes | None: """Return a still image response from the camera.""" # DigestAuth is not supported if ( self._authentication == HTTP_DIGEST_AUTHENTICATION or self._still...
[ "async", "def", "async_camera_image", "(", "self", ",", "width", ":", "int", "|", "None", "=", "None", ",", "height", ":", "int", "|", "None", "=", "None", ")", "->", "bytes", "|", "None", ":", "# DigestAuth is not supported", "if", "(", "self", ".", "...
[ 110, 4 ]
[ 136, 19 ]
python
en
['en', 'en', 'en']
True
MjpegCamera.camera_image
( self, width: int | None = None, height: int | None = None )
Return a still image response from the camera.
Return a still image response from the camera.
def camera_image( self, width: int | None = None, height: int | None = None ) -> bytes | None: """Return a still image response from the camera.""" if self._username and self._password: if self._authentication == HTTP_DIGEST_AUTHENTICATION: auth: HTTPDigestAuth | ...
[ "def", "camera_image", "(", "self", ",", "width", ":", "int", "|", "None", "=", "None", ",", "height", ":", "int", "|", "None", "=", "None", ")", "->", "bytes", "|", "None", ":", "if", "self", ".", "_username", "and", "self", ".", "_password", ":",...
[ 138, 4 ]
[ 160, 74 ]
python
en
['en', 'en', 'en']
True
MjpegCamera.handle_async_mjpeg_stream
(self, request)
Generate an HTTP MJPEG stream from the camera.
Generate an HTTP MJPEG stream from the camera.
async def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" # aiohttp don't support DigestAuth -> Fallback if self._authentication == HTTP_DIGEST_AUTHENTICATION: return await super().handle_async_mjpeg_stream(request) # connect to...
[ "async", "def", "handle_async_mjpeg_stream", "(", "self", ",", "request", ")", ":", "# aiohttp don't support DigestAuth -> Fallback", "if", "self", ".", "_authentication", "==", "HTTP_DIGEST_AUTHENTICATION", ":", "return", "await", "super", "(", ")", ".", "handle_async_...
[ 162, 4 ]
[ 172, 77 ]
python
en
['en', 'en', 'en']
True
MjpegCamera.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" ]
[ 175, 4 ]
[ 177, 25 ]
python
en
['en', 'en', 'en']
True
NoHeaderErrorFilter.filter
(self, record)
Filter out Header Parsing Errors.
Filter out Header Parsing Errors.
def filter(self, record): """Filter out Header Parsing Errors.""" return "Failed to parse headers" not in record.getMessage()
[ "def", "filter", "(", "self", ",", "record", ")", ":", "return", "\"Failed to parse headers\"", "not", "in", "record", ".", "getMessage", "(", ")" ]
[ 183, 4 ]
[ 185, 67 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return a HUAWEI scanner.
Validate the configuration and return a HUAWEI scanner.
def get_scanner(hass, config): """Validate the configuration and return a HUAWEI scanner.""" scanner = HuaweiDeviceScanner(config[DOMAIN]) return scanner
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "HuaweiDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner" ]
[ 28, 0 ]
[ 32, 18 ]
python
en
['en', 'en', 'en']
True
HuaweiDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = base64.b64encode(bytes(config[CONF_PASSWORD], "utf-8")) self.last_results = []
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "password", "=", "base64", ".", "b64encode", "(", "bytes...
[ 54, 4 ]
[ 60, 30 ]
python
en
['en', 'en', 'en']
True
HuaweiDeviceScanner.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.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "client", ".", "mac", "for", "client", "in", "self", ".", "last_results", "]" ]
[ 62, 4 ]
[ 65, 59 ]
python
en
['en', 'en', 'en']
True
HuaweiDeviceScanner.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.""" if not self.last_results: return None for client in self.last_results: if client.mac == device: return client.name return None
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "if", "not", "self", ".", "last_results", ":", "return", "None", "for", "client", "in", "self", ".", "last_results", ":", "if", "client", ".", "mac", "==", "device", ":", "return", "client",...
[ 67, 4 ]
[ 74, 19 ]
python
en
['en', 'en', 'en']
True
HuaweiDeviceScanner._update_info
(self)
Ensure the information from the router is up to date. Return boolean if scanning successful.
Ensure the information from the router is up to date.
def _update_info(self): """Ensure the information from the router is up to date. Return boolean if scanning successful. """ data = self._get_data() if not data: return False active_clients = [client for client in data if client.state] self.last_resul...
[ "def", "_update_info", "(", "self", ")", ":", "data", "=", "self", ".", "_get_data", "(", ")", "if", "not", "data", ":", "return", "False", "active_clients", "=", "[", "client", "for", "client", "in", "data", "if", "client", ".", "state", "]", "self", ...
[ 76, 4 ]
[ 92, 19 ]
python
en
['en', 'en', 'en']
True
HuaweiDeviceScanner._get_data
(self)
Get the devices' data from the router. Returns a list with all the devices known to the router DHCP server.
Get the devices' data from the router.
def _get_data(self): """Get the devices' data from the router. Returns a list with all the devices known to the router DHCP server. """ array_regex_res = self.ARRAY_REGEX.search(self._get_devices_response()) devices = [] if array_regex_res: device_regex_res ...
[ "def", "_get_data", "(", "self", ")", ":", "array_regex_res", "=", "self", ".", "ARRAY_REGEX", ".", "search", "(", "self", ".", "_get_devices_response", "(", ")", ")", "devices", "=", "[", "]", "if", "array_regex_res", ":", "device_regex_res", "=", "self", ...
[ 94, 4 ]
[ 117, 22 ]
python
en
['en', 'en', 'en']
True
HuaweiDeviceScanner._get_devices_response
(self)
Get the raw string with the devices from the router.
Get the raw string with the devices from the router.
def _get_devices_response(self): """Get the raw string with the devices from the router.""" cnt = requests.post(f"http://{self.host}/asp/GetRandCount.asp") cnt_str = str(cnt.content, cnt.apparent_encoding, errors="replace") _LOGGER.debug("Logging in") cookie = requests.post( ...
[ "def", "_get_devices_response", "(", "self", ")", ":", "cnt", "=", "requests", ".", "post", "(", "f\"http://{self.host}/asp/GetRandCount.asp\"", ")", "cnt_str", "=", "str", "(", "cnt", ".", "content", ",", "cnt", ".", "apparent_encoding", ",", "errors", "=", "...
[ 119, 4 ]
[ 155, 9 ]
python
en
['en', 'en', 'en']
True
NumberOnly.openapi_types
()
This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type.
This must be a method because a model may have properties that are of type self, this must run after the class is loaded
def openapi_types(): """ This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type. """ retu...
[ "def", "openapi_types", "(", ")", ":", "return", "{", "'just_number'", ":", "(", "float", ",", ")", ",", "# noqa: E501", "}" ]
[ 64, 4 ]
[ 75, 9 ]
python
en
['en', 'error', 'th']
False
NumberOnly.__init__
(self, *args, **kwargs)
NumberOnly - a model defined in OpenAPI Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. D...
NumberOnly - a model defined in OpenAPI
def __init__(self, *args, **kwargs): # noqa: E501 """NumberOnly - a model defined in OpenAPI Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ".", "pop", "(", "'_spec_property...
[ 98, 4 ]
[ 165, 46 ]
python
en
['en', 'en', 'en']
True
get_active_lines
(lines, comment_char="#")
Returns lines, or parts of lines, from content that are not commented out or completely empty. The resulting lines are all individually stripped. This is useful for parsing many config files such as ifcfg. Parameters: lines (list): List of strings to parse. comment_char (str): String...
Returns lines, or parts of lines, from content that are not commented out or completely empty. The resulting lines are all individually stripped.
def get_active_lines(lines, comment_char="#"): """ Returns lines, or parts of lines, from content that are not commented out or completely empty. The resulting lines are all individually stripped. This is useful for parsing many config files such as ifcfg. Parameters: lines (list): List o...
[ "def", "get_active_lines", "(", "lines", ",", "comment_char", "=", "\"#\"", ")", ":", "return", "list", "(", "filter", "(", "None", ",", "(", "line", ".", "split", "(", "comment_char", ",", "1", ")", "[", "0", "]", ".", "strip", "(", ")", "for", "l...
[ 29, 0 ]
[ 55, 89 ]
python
en
['en', 'error', 'th']
False
optlist_to_dict
(optlist, opt_sep=',', kv_sep='=', strip_quotes=False)
Parse an option list into a dictionary. Takes a list of options separated by ``opt_sep`` and places them into a dictionary with the default value of ``True``. If ``kv_sep`` option is specified then key/value options ``key=value`` are parsed. Useful for parsing options such as mount options in the for...
Parse an option list into a dictionary.
def optlist_to_dict(optlist, opt_sep=',', kv_sep='=', strip_quotes=False): """Parse an option list into a dictionary. Takes a list of options separated by ``opt_sep`` and places them into a dictionary with the default value of ``True``. If ``kv_sep`` option is specified then key/value options ``key=va...
[ "def", "optlist_to_dict", "(", "optlist", ",", "opt_sep", "=", "','", ",", "kv_sep", "=", "'='", ",", "strip_quotes", "=", "False", ")", ":", "def", "make_kv", "(", "opt", ")", ":", "if", "kv_sep", "is", "not", "None", "and", "kv_sep", "in", "opt", "...
[ 58, 0 ]
[ 98, 63 ]
python
en
['it', 'en', 'en']
True
split_kv_pairs
(lines, comment_char="#", filter_string=None, split_on="=", use_partition=False, ordered=False)
Split lines of a list into key/value pairs Use this function to filter and split all lines of a list of strings into a dictionary. Named arguments may be used to control how the line is split, how lines are filtered and the type of output returned. See parameters for more information. When splitting ...
Split lines of a list into key/value pairs
def split_kv_pairs(lines, comment_char="#", filter_string=None, split_on="=", use_partition=False, ordered=False): """Split lines of a list into key/value pairs Use this function to filter and split all lines of a list of strings into a dictionary. Named arguments may be used to control how the line is spl...
[ "def", "split_kv_pairs", "(", "lines", ",", "comment_char", "=", "\"#\"", ",", "filter_string", "=", "None", ",", "split_on", "=", "\"=\"", ",", "use_partition", "=", "False", ",", "ordered", "=", "False", ")", ":", "_lines", "=", "lines", "if", "comment_c...
[ 101, 0 ]
[ 175, 19 ]
python
en
['en', 'en', 'en']
True
unsplit_lines
(lines, cont_char='\\', keep_cont_char=False)
Recombine lines having a continuation character at end. Generator that recombines lines in the list that have the char `cont_char` at the end of a line. If `cont_char` is found in a line then then next line will be appended to the current line, this will continue for multiple continuation lines until ...
Recombine lines having a continuation character at end.
def unsplit_lines(lines, cont_char='\\', keep_cont_char=False): """Recombine lines having a continuation character at end. Generator that recombines lines in the list that have the char `cont_char` at the end of a line. If `cont_char` is found in a line then then next line will be appended to the curr...
[ "def", "unsplit_lines", "(", "lines", ",", "cont_char", "=", "'\\\\'", ",", "keep_cont_char", "=", "False", ")", ":", "unsplit_lines", "=", "[", "]", "for", "line", "in", "lines", ":", "line", "=", "line", ".", "rstrip", "(", ")", "if", "line", ".", ...
[ 178, 0 ]
[ 219, 36 ]
python
en
['en', 'en', 'en']
True
calc_offset
(lines, target, invert_search=False)
Function to search for a line in a list starting with a target string. If `target` is `None` or an empty string then `0` is returned. This allows checking `target` here instead of having to check for an empty target in the calling function. Each line is stripped of leading spaces prior to comparis...
Function to search for a line in a list starting with a target string. If `target` is `None` or an empty string then `0` is returned. This allows checking `target` here instead of having to check for an empty target in the calling function. Each line is stripped of leading spaces prior to comparis...
def calc_offset(lines, target, invert_search=False): """ Function to search for a line in a list starting with a target string. If `target` is `None` or an empty string then `0` is returned. This allows checking `target` here instead of having to check for an empty target in the calling function. E...
[ "def", "calc_offset", "(", "lines", ",", "target", ",", "invert_search", "=", "False", ")", ":", "if", "target", "and", "target", "[", "0", "]", "is", "not", "None", ":", "for", "offset", ",", "line", "in", "enumerate", "(", "l", ".", "strip", "(", ...
[ 222, 0 ]
[ 278, 16 ]
python
en
['en', 'error', 'th']
False
parse_fixed_table
(table_lines, heading_ignore=[], header_substitute=[], trailing_ignore=[], empty_exception=False)
Function to parse table data containing column headings in the first row and data in fixed positions in each remaining row of table data. Table columns must not contain spaces within the column name. Column headings are assumed to be left justified and the column data width is the width of the hea...
Function to parse table data containing column headings in the first row and data in fixed positions in each remaining row of table data. Table columns must not contain spaces within the column name. Column headings are assumed to be left justified and the column data width is the width of the hea...
def parse_fixed_table(table_lines, heading_ignore=[], header_substitute=[], trailing_ignore=[], empty_exception=False): """ Function to parse table data containing column headings in the first row and data in fixed posit...
[ "def", "parse_fixed_table", "(", "table_lines", ",", "heading_ignore", "=", "[", "]", ",", "header_substitute", "=", "[", "]", ",", "trailing_ignore", "=", "[", "]", ",", "empty_exception", "=", "False", ")", ":", "def", "calc_column_indices", "(", "line", "...
[ 281, 0 ]
[ 368, 21 ]
python
en
['en', 'error', 'th']
False
parse_delimited_table
(table_lines, delim=None, max_splits=-1, strip=True, header_delim='same as delimiter', heading_ignore=None, header_substitute=None, traili...
Parses table-like text. Uses the first (non-ignored) row as the list of column names, which cannot contain the delimiter. Fields cannot contain the delimiter but can be blank if a printable delimiter is used. Arguments: table_lines (list): List of strings with the first line containing ...
Parses table-like text. Uses the first (non-ignored) row as the list of column names, which cannot contain the delimiter. Fields cannot contain the delimiter but can be blank if a printable delimiter is used.
def parse_delimited_table(table_lines, delim=None, max_splits=-1, strip=True, header_delim='same as delimiter', heading_ignore=None, header_substitute=None, ...
[ "def", "parse_delimited_table", "(", "table_lines", ",", "delim", "=", "None", ",", "max_splits", "=", "-", "1", ",", "strip", "=", "True", ",", "header_delim", "=", "'same as delimiter'", ",", "heading_ignore", "=", "None", ",", "header_substitute", "=", "Non...
[ 371, 0 ]
[ 457, 12 ]
python
en
['en', 'error', 'th']
False
keyword_search
(rows, **kwargs)
Takes a list of dictionaries and finds all the dictionaries where the keys and values match those found in the keyword arguments. Keys in the row data have ' ' and '-' replaced with '_', so they can match the keyword argument parsing. For example, the keyword argument 'fix_up_path' will match a k...
Takes a list of dictionaries and finds all the dictionaries where the keys and values match those found in the keyword arguments.
def keyword_search(rows, **kwargs): """ Takes a list of dictionaries and finds all the dictionaries where the keys and values match those found in the keyword arguments. Keys in the row data have ' ' and '-' replaced with '_', so they can match the keyword argument parsing. For example, the keywor...
[ "def", "keyword_search", "(", "rows", ",", "*", "*", "kwargs", ")", ":", "results", "=", "[", "]", "if", "not", "kwargs", ":", "return", "results", "# Allows us to transform the key and do lookups like __contains and", "# __startswith", "matchers", "=", "{", "'defau...
[ 460, 0 ]
[ 538, 15 ]
python
en
['en', 'error', 'th']
False
valid_integration_path
(integration_path)
Test if it's a valid integration.
Test if it's a valid integration.
def valid_integration_path(integration_path): """Test if it's a valid integration.""" path = pathlib.Path(integration_path) if not path.is_dir(): raise argparse.ArgumentTypeError(f"{integration_path} is not a directory.") return path
[ "def", "valid_integration_path", "(", "integration_path", ")", ":", "path", "=", "pathlib", ".", "Path", "(", "integration_path", ")", "if", "not", "path", ".", "is_dir", "(", ")", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "f\"{integration_path} i...
[ 46, 0 ]
[ 52, 15 ]
python
en
['en', 'en', 'en']
True
get_config
()
Return config.
Return config.
def get_config() -> Config: """Return config.""" parser = argparse.ArgumentParser(description="Hassfest") parser.add_argument( "--action", type=str, choices=["validate", "generate"], default=None ) parser.add_argument( "--integration-path", action="append", type=valid...
[ "def", "get_config", "(", ")", "->", "Config", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Hassfest\"", ")", "parser", ".", "add_argument", "(", "\"--action\"", ",", "type", "=", "str", ",", "choices", "=", "[", "\"va...
[ 55, 0 ]
[ 93, 5 ]
python
en
['en', 'la', 'en']
False
main
()
Validate manifests.
Validate manifests.
def main(): """Validate manifests.""" try: config = get_config() except RuntimeError as err: print(err) return 1 plugins = [*INTEGRATION_PLUGINS] if config.specific_integrations: integrations = {} for int_path in config.specific_integrations: in...
[ "def", "main", "(", ")", ":", "try", ":", "config", "=", "get_config", "(", ")", "except", "RuntimeError", "as", "err", ":", "print", "(", "err", ")", "return", "1", "plugins", "=", "[", "*", "INTEGRATION_PLUGINS", "]", "if", "config", ".", "specific_i...
[ 96, 0 ]
[ 181, 12 ]
python
bg
['en', 'et', 'bg']
False
print_integrations_status
(config, integrations, *, show_fixable_errors=True)
Print integration status.
Print integration status.
def print_integrations_status(config, integrations, *, show_fixable_errors=True): """Print integration status.""" for integration in sorted(integrations, key=lambda itg: itg.domain): extra = f" - {integration.path}" if config.specific_integrations else "" print(f"Integration {integration.domain}...
[ "def", "print_integrations_status", "(", "config", ",", "integrations", ",", "*", ",", "show_fixable_errors", "=", "True", ")", ":", "for", "integration", "in", "sorted", "(", "integrations", ",", "key", "=", "lambda", "itg", ":", "itg", ".", "domain", ")", ...
[ 184, 0 ]
[ 194, 15 ]
python
en
['en', 'ja', 'en']
True
Tag.__init__
(self, id: int=None, name: str=None)
Tag - a model defined in OpenAPI :param id: The id of this Tag. :param name: The name of this Tag.
Tag - a model defined in OpenAPI
def __init__(self, id: int=None, name: str=None): """Tag - a model defined in OpenAPI :param id: The id of this Tag. :param name: The name of this Tag. """ self.openapi_types = { 'id': int, 'name': str } self.attribute_map = { ...
[ "def", "__init__", "(", "self", ",", "id", ":", "int", "=", "None", ",", "name", ":", "str", "=", "None", ")", ":", "self", ".", "openapi_types", "=", "{", "'id'", ":", "int", ",", "'name'", ":", "str", "}", "self", ".", "attribute_map", "=", "{"...
[ 16, 4 ]
[ 33, 25 ]
python
en
['en', 'en', 'en']
True
Tag.from_dict
(cls, dikt: dict)
Returns the dict as a model :param dikt: A dict. :return: The Tag of this Tag.
Returns the dict as a model
def from_dict(cls, dikt: dict) -> 'Tag': """Returns the dict as a model :param dikt: A dict. :return: The Tag of this Tag. """ return util.deserialize_model(dikt, cls)
[ "def", "from_dict", "(", "cls", ",", "dikt", ":", "dict", ")", "->", "'Tag'", ":", "return", "util", ".", "deserialize_model", "(", "dikt", ",", "cls", ")" ]
[ 36, 4 ]
[ 42, 48 ]
python
en
['en', 'en', 'en']
True
Tag.id
(self)
Gets the id of this Tag. :return: The id of this Tag. :rtype: int
Gets the id of this Tag.
def id(self): """Gets the id of this Tag. :return: The id of this Tag. :rtype: int """ return self._id
[ "def", "id", "(", "self", ")", ":", "return", "self", ".", "_id" ]
[ 45, 4 ]
[ 52, 23 ]
python
en
['en', 'en', 'en']
True
Tag.id
(self, id)
Sets the id of this Tag. :param id: The id of this Tag. :type id: int
Sets the id of this Tag.
def id(self, id): """Sets the id of this Tag. :param id: The id of this Tag. :type id: int """ self._id = id
[ "def", "id", "(", "self", ",", "id", ")", ":", "self", ".", "_id", "=", "id" ]
[ 55, 4 ]
[ 63, 21 ]
python
en
['en', 'en', 'en']
True
Tag.name
(self)
Gets the name of this Tag. :return: The name of this Tag. :rtype: str
Gets the name of this Tag.
def name(self): """Gets the name of this Tag. :return: The name of this Tag. :rtype: str """ return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 66, 4 ]
[ 73, 25 ]
python
en
['en', 'en', 'en']
True
Tag.name
(self, name)
Sets the name of this Tag. :param name: The name of this Tag. :type name: str
Sets the name of this Tag.
def name(self, name): """Sets the name of this Tag. :param name: The name of this Tag. :type name: str """ self._name = name
[ "def", "name", "(", "self", ",", "name", ")", ":", "self", ".", "_name", "=", "name" ]
[ 76, 4 ]
[ 84, 25 ]
python
en
['en', 'en', 'en']
True
cli
(ctx, background=False, no_yeast=False)
Launch a chado docker image. Output: None
Launch a chado docker image.
def cli(ctx, background=False, no_yeast=False): """Launch a chado docker image. Output: None """ return ctx.gi.util.launch_docker_image(background=background, no_yeast=no_yeast)
[ "def", "cli", "(", "ctx", ",", "background", "=", "False", ",", "no_yeast", "=", "False", ")", ":", "return", "ctx", ".", "gi", ".", "util", ".", "launch_docker_image", "(", "background", "=", "background", ",", "no_yeast", "=", "no_yeast", ")" ]
[ 19, 0 ]
[ 26, 84 ]
python
pt
['pt', 'zh-Latn', 'pt']
True
config_entry
(hass)
Config entry version 1 fixture.
Config entry version 1 fixture.
def config_entry(hass): """Config entry version 1 fixture.""" return MockConfigEntry( domain=FLO_DOMAIN, data={CONF_USERNAME: TEST_USER_ID, CONF_PASSWORD: TEST_PASSWORD}, version=1, )
[ "def", "config_entry", "(", "hass", ")", ":", "return", "MockConfigEntry", "(", "domain", "=", "FLO_DOMAIN", ",", "data", "=", "{", "CONF_USERNAME", ":", "TEST_USER_ID", ",", "CONF_PASSWORD", ":", "TEST_PASSWORD", "}", ",", "version", "=", "1", ",", ")" ]
[ 15, 0 ]
[ 21, 5 ]
python
en
['en', 'es', 'en']
True
aioclient_mock_fixture
(aioclient_mock)
Fixture to provide a aioclient mocker.
Fixture to provide a aioclient mocker.
def aioclient_mock_fixture(aioclient_mock): """Fixture to provide a aioclient mocker.""" now = round(time.time()) # Mocks the login response for flo. aioclient_mock.post( "https://api.meetflo.com/api/v1/users/auth", text=json.dumps( { "token": TEST_TOKEN, ...
[ "def", "aioclient_mock_fixture", "(", "aioclient_mock", ")", ":", "now", "=", "round", "(", "time", ".", "time", "(", ")", ")", "# Mocks the login response for flo.", "aioclient_mock", ".", "post", "(", "\"https://api.meetflo.com/api/v1/users/auth\"", ",", "text", "="...
[ 25, 0 ]
[ 139, 5 ]
python
en
['en', 'en', 'en']
True
skip_notifications_fixture
()
Skip notification calls.
Skip notification calls.
def skip_notifications_fixture(): """Skip notification calls.""" with patch("homeassistant.components.persistent_notification.async_create"), patch( "homeassistant.components.persistent_notification.async_dismiss" ): yield
[ "def", "skip_notifications_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.persistent_notification.async_create\"", ")", ",", "patch", "(", "\"homeassistant.components.persistent_notification.async_dismiss\"", ")", ":", "yield" ]
[ 10, 0 ]
[ 15, 13 ]
python
ca
['ro', 'ca', 'en']
False
climacell_config_flow_connect
()
Mock valid climacell config flow setup.
Mock valid climacell config flow setup.
def climacell_config_flow_connect(): """Mock valid climacell config flow setup.""" with patch( "homeassistant.components.climacell.config_flow.ClimaCellV3.realtime", return_value={}, ), patch( "homeassistant.components.climacell.config_flow.ClimaCellV4.realtime", return_value...
[ "def", "climacell_config_flow_connect", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.climacell.config_flow.ClimaCellV3.realtime\"", ",", "return_value", "=", "{", "}", ",", ")", ",", "patch", "(", "\"homeassistant.components.climacell.config_flow.ClimaCellV4...
[ 19, 0 ]
[ 28, 13 ]
python
en
['en', 'da', 'en']
True
climacell_config_entry_update_fixture
()
Mock valid climacell config entry setup.
Mock valid climacell config entry setup.
def climacell_config_entry_update_fixture(): """Mock valid climacell config entry setup.""" with patch( "homeassistant.components.climacell.ClimaCellV3.realtime", return_value=json.loads(load_fixture("climacell/v3_realtime.json")), ), patch( "homeassistant.components.climacell.ClimaC...
[ "def", "climacell_config_entry_update_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.climacell.ClimaCellV3.realtime\"", ",", "return_value", "=", "json", ".", "loads", "(", "load_fixture", "(", "\"climacell/v3_realtime.json\"", ")", ")", ",", "...
[ 32, 0 ]
[ 50, 13 ]
python
en
['en', 'da', 'en']
True
setup_frontend
(hass)
Fixture to setup the frontend.
Fixture to setup the frontend.
def setup_frontend(hass): """Fixture to setup the frontend.""" hass.loop.run_until_complete(async_setup_component(hass, "frontend", {}))
[ "def", "setup_frontend", "(", "hass", ")", ":", "hass", ".", "loop", ".", "run_until_complete", "(", "async_setup_component", "(", "hass", ",", "\"frontend\"", ",", "{", "}", ")", ")" ]
[ 8, 0 ]
[ 10, 77 ]
python
en
['en', 'en', 'en']
True
test_get_user_data_empty
(hass, hass_ws_client, hass_storage)
Test get_user_data command.
Test get_user_data command.
async def test_get_user_data_empty(hass, hass_ws_client, hass_storage): """Test get_user_data command.""" client = await hass_ws_client(hass) await client.send_json( {"id": 5, "type": "frontend/get_user_data", "key": "non-existing-key"} ) res = await client.receive_json() assert res["s...
[ "async", "def", "test_get_user_data_empty", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":"...
[ 13, 0 ]
[ 23, 41 ]
python
en
['nl', 'en', 'en']
True
test_get_user_data
(hass, hass_ws_client, hass_admin_user, hass_storage)
Test get_user_data command.
Test get_user_data command.
async def test_get_user_data(hass, hass_ws_client, hass_admin_user, hass_storage): """Test get_user_data command.""" storage_key = f"{DOMAIN}.user_data_{hass_admin_user.id}" hass_storage[storage_key] = { "key": storage_key, "version": 1, "data": {"test-key": "test-value", "test-compl...
[ "async", "def", "test_get_user_data", "(", "hass", ",", "hass_ws_client", ",", "hass_admin_user", ",", "hass_storage", ")", ":", "storage_key", "=", "f\"{DOMAIN}.user_data_{hass_admin_user.id}\"", "hass_storage", "[", "storage_key", "]", "=", "{", "\"key\"", ":", "sto...
[ 26, 0 ]
[ 64, 68 ]
python
en
['nl', 'en', 'en']
True
test_set_user_data_empty
(hass, hass_ws_client, hass_storage)
Test set_user_data command.
Test set_user_data command.
async def test_set_user_data_empty(hass, hass_ws_client, hass_storage): """Test set_user_data command.""" client = await hass_ws_client(hass) # test creating await client.send_json( {"id": 6, "type": "frontend/get_user_data", "key": "test-key"} ) res = await client.receive_json() ...
[ "async", "def", "test_set_user_data_empty", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "# test creating", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "6", ","...
[ 67, 0 ]
[ 99, 49 ]
python
en
['en', 'no', 'en']
True
test_set_user_data
(hass, hass_ws_client, hass_storage, hass_admin_user)
Test set_user_data command with initial data.
Test set_user_data command with initial data.
async def test_set_user_data(hass, hass_ws_client, hass_storage, hass_admin_user): """Test set_user_data command with initial data.""" storage_key = f"{DOMAIN}.user_data_{hass_admin_user.id}" hass_storage[storage_key] = { "version": 1, "data": {"test-key": "test-value", "test-complex": "stri...
[ "async", "def", "test_set_user_data", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ",", "hass_admin_user", ")", ":", "storage_key", "=", "f\"{DOMAIN}.user_data_{hass_admin_user.id}\"", "hass_storage", "[", "storage_key", "]", "=", "{", "\"version\"", ":", ...
[ 102, 0 ]
[ 164, 49 ]
python
en
['en', 'en', 'en']
True
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """ Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. """ session = async_get_clientsession(hass) client = WebServiceAPI(data[CONF_API_KEY], session=session) lat = dat...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "session", "=", "async_get_clientsession", "(", "hass", ")", "client", "=", "WebServiceAPI", "(", "data", "[", "CONF_API_KEY", "]", ",", "session", "=", ...
[ 17, 0 ]
[ 43, 15 ]
python
en
['en', 'error', 'th']
False
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: # Set a unique id based on latitude/longitude await self.async_set_unique_id( f"{user_input[CONF_LATITUDE]}-{user_input[CONF_LONGITUDE]}...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "# Set a unique id based on latitude/longitude", "await", "self", ".", "async_set_unique_id", "(", "f...
[ 51, 4 ]
[ 96, 9 ]
python
en
['en', 'en', 'en']
True
parse_path
(path)
Convert possible symbolic link into a source -> target pair. Args: path (str): The path portion of an ls output line. Returns: A (path, link) tuple where path is always populated and link is a non empty string if the original path is a symoblic link.
Convert possible symbolic link into a source -> target pair.
def parse_path(path): """ Convert possible symbolic link into a source -> target pair. Args: path (str): The path portion of an ls output line. Returns: A (path, link) tuple where path is always populated and link is a non empty string if the original path is a symoblic link. ...
[ "def", "parse_path", "(", "path", ")", ":", "path", ",", "_", ",", "link", "=", "path", ".", "partition", "(", "\" -> \"", ")", "return", "path", ",", "link" ]
[ 7, 0 ]
[ 19, 21 ]
python
en
['en', 'error', 'th']
False
parse_non_selinux
(parts)
Parse part of an ls output line that isn't selinux. Args: parts (list): A four element list of strings representing the initial parts of an ls line after the permission bits. The parts are link count, owner, group, and everything else. Returns: A dict containing li...
Parse part of an ls output line that isn't selinux.
def parse_non_selinux(parts): """ Parse part of an ls output line that isn't selinux. Args: parts (list): A four element list of strings representing the initial parts of an ls line after the permission bits. The parts are link count, owner, group, and everything else. ...
[ "def", "parse_non_selinux", "(", "parts", ")", ":", "links", ",", "owner", ",", "group", ",", "last", "=", "parts", "result", "=", "{", "\"links\"", ":", "int", "(", "links", ")", ",", "\"owner\"", ":", "owner", ",", "\"group\"", ":", "group", ",", "...
[ 22, 0 ]
[ 64, 17 ]
python
en
['en', 'error', 'th']
False
parse_selinux
(parts)
Parse part of an ls output line that is selinux. Args: parts (list): A four element list of strings representing the initial parts of an ls line after the permission bits. The parts are owner group, selinux info, and the path. Returns: A dict containing owner, grou...
Parse part of an ls output line that is selinux.
def parse_selinux(parts): """ Parse part of an ls output line that is selinux. Args: parts (list): A four element list of strings representing the initial parts of an ls line after the permission bits. The parts are owner group, selinux info, and the path. Returns: ...
[ "def", "parse_selinux", "(", "parts", ")", ":", "owner", ",", "group", "=", "parts", "[", ":", "2", "]", "selinux", "=", "parts", "[", "2", "]", ".", "split", "(", "\":\"", ")", "lsel", "=", "len", "(", "selinux", ")", "path", ",", "link", "=", ...
[ 67, 0 ]
[ 97, 17 ]
python
en
['en', 'error', 'th']
False
parse_rhel8_selinux
(parts)
Parse part of an ls output line that is selinux on RHEL8. Args: parts (list): A four element list of strings representing the initial parts of an ls line after the permission bits. The parts are link count, owner, group, and everything else Returns: A dict containi...
Parse part of an ls output line that is selinux on RHEL8.
def parse_rhel8_selinux(parts): """ Parse part of an ls output line that is selinux on RHEL8. Args: parts (list): A four element list of strings representing the initial parts of an ls line after the permission bits. The parts are link count, owner, group, and everything els...
[ "def", "parse_rhel8_selinux", "(", "parts", ")", ":", "links", ",", "owner", ",", "group", ",", "last", "=", "parts", "selinux", "=", "parts", "[", "3", "]", ".", "split", "(", "\":\"", ")", "lsel", "=", "len", "(", "selinux", ")", "selinux", ",", ...
[ 100, 0 ]
[ 138, 17 ]
python
en
['en', 'error', 'th']
False
parse
(lines, root=None)
Parses a list of lines from ls into dictionaries representing their components. Args: lines (list): A list of lines generated by ls. root (str): The directory name to be used for ls output stanzas that don't have a name. Returns: A dictionary representing the ls ou...
Parses a list of lines from ls into dictionaries representing their components.
def parse(lines, root=None): """ Parses a list of lines from ls into dictionaries representing their components. Args: lines (list): A list of lines generated by ls. root (str): The directory name to be used for ls output stanzas that don't have a name. Returns: ...
[ "def", "parse", "(", "lines", ",", "root", "=", "None", ")", ":", "doc", "=", "{", "}", "entries", "=", "[", "]", "name", "=", "None", "total", "=", "None", "for", "line", "in", "lines", ":", "line", "=", "line", ".", "strip", "(", ")", "if", ...
[ 231, 0 ]
[ 275, 14 ]
python
en
['en', 'error', 'th']
False
API.find
(self, cur, query, request)
Executes query against embeddings index and/or SQLite, depending on the query. Args: cur: open database cursor query: query text request: FastAPI request Returns: query results
Executes query against embeddings index and/or SQLite, depending on the query.
def find(self, cur, query, request): """ Executes query against embeddings index and/or SQLite, depending on the query. Args: cur: open database cursor query: query text request: FastAPI request Returns: query results """ ...
[ "def", "find", "(", "self", ",", "cur", ",", "query", ",", "request", ")", ":", "if", "not", "query", ":", "return", "cur", ".", "execute", "(", "\"SELECT id, 1.0 as score FROM articles ORDER BY date DESC LIMIT 100\"", ")", ".", "fetchall", "(", ")", "elif", "...
[ 14, 4 ]
[ 41, 84 ]
python
en
['en', 'error', 'th']
False
API.search
(self, query, request)
Extends txtai API to enrich results with content. Args: query: query text request: FastAPI request Returns: query results
Extends txtai API to enrich results with content.
def search(self, query, request): """ Extends txtai API to enrich results with content. Args: query: query text request: FastAPI request Returns: query results """ results, filters = [], [] # Unpack filters if "filte...
[ "def", "search", "(", "self", ",", "query", ",", "request", ")", ":", "results", ",", "filters", "=", "[", "]", ",", "[", "]", "# Unpack filters", "if", "\"filters\"", "in", "request", ".", "query_params", ":", "filters", "=", "request", ".", "query_para...
[ 43, 4 ]
[ 96, 22 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, entry, async_add_entities)
Set up OwnTracks based off an entry.
Set up OwnTracks based off an entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up OwnTracks based off an entry.""" # Restore previously loaded devices dev_reg = await device_registry.async_get_registry(hass) dev_ids = { identifier[1] for device in dev_reg.devices.values() for identifier in...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "# Restore previously loaded devices", "dev_reg", "=", "await", "device_registry", ".", "async_get_registry", "(", "hass", ")", "dev_ids", "=", "{", "identifier", "[...
[ 20, 0 ]
[ 53, 15 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.__init__
(self, dev_id, data=None)
Set up OwnTracks entity.
Set up OwnTracks entity.
def __init__(self, dev_id, data=None): """Set up OwnTracks entity.""" self._dev_id = dev_id self._data = data or {} self.entity_id = f"{DOMAIN}.{dev_id}"
[ "def", "__init__", "(", "self", ",", "dev_id", ",", "data", "=", "None", ")", ":", "self", ".", "_dev_id", "=", "dev_id", "self", ".", "_data", "=", "data", "or", "{", "}", "self", ".", "entity_id", "=", "f\"{DOMAIN}.{dev_id}\"" ]
[ 59, 4 ]
[ 63, 45 ]
python
en
['en', 'zu', 'en']
True
OwnTracksEntity.unique_id
(self)
Return the unique ID.
Return the unique ID.
def unique_id(self): """Return the unique ID.""" return self._dev_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_dev_id" ]
[ 66, 4 ]
[ 68, 27 ]
python
en
['en', 'la', 'en']
True
OwnTracksEntity.battery_level
(self)
Return the battery level of the device.
Return the battery level of the device.
def battery_level(self): """Return the battery level of the device.""" return self._data.get("battery")
[ "def", "battery_level", "(", "self", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "\"battery\"", ")" ]
[ 71, 4 ]
[ 73, 40 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.extra_state_attributes
(self)
Return device specific attributes.
Return device specific attributes.
def extra_state_attributes(self): """Return device specific attributes.""" return self._data.get("attributes")
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "\"attributes\"", ")" ]
[ 76, 4 ]
[ 78, 43 ]
python
en
['fr', 'it', 'en']
False
OwnTracksEntity.location_accuracy
(self)
Return the gps accuracy of the device.
Return the gps accuracy of the device.
def location_accuracy(self): """Return the gps accuracy of the device.""" return self._data.get("gps_accuracy")
[ "def", "location_accuracy", "(", "self", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "\"gps_accuracy\"", ")" ]
[ 81, 4 ]
[ 83, 45 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.latitude
(self)
Return latitude value of the device.
Return latitude value of the device.
def latitude(self): """Return latitude value of the device.""" # Check with "get" instead of "in" because value can be None if self._data.get("gps"): return self._data["gps"][0] return None
[ "def", "latitude", "(", "self", ")", ":", "# Check with \"get\" instead of \"in\" because value can be None", "if", "self", ".", "_data", ".", "get", "(", "\"gps\"", ")", ":", "return", "self", ".", "_data", "[", "\"gps\"", "]", "[", "0", "]", "return", "None"...
[ 86, 4 ]
[ 92, 19 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.longitude
(self)
Return longitude value of the device.
Return longitude value of the device.
def longitude(self): """Return longitude value of the device.""" # Check with "get" instead of "in" because value can be None if self._data.get("gps"): return self._data["gps"][1] return None
[ "def", "longitude", "(", "self", ")", ":", "# Check with \"get\" instead of \"in\" because value can be None", "if", "self", ".", "_data", ".", "get", "(", "\"gps\"", ")", ":", "return", "self", ".", "_data", "[", "\"gps\"", "]", "[", "1", "]", "return", "None...
[ 95, 4 ]
[ 101, 19 ]
python
en
['en', 'zu', 'en']
True
OwnTracksEntity.location_name
(self)
Return a location name for the current location of the device.
Return a location name for the current location of the device.
def location_name(self): """Return a location name for the current location of the device.""" return self._data.get("location_name")
[ "def", "location_name", "(", "self", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "\"location_name\"", ")" ]
[ 104, 4 ]
[ 106, 46 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._data.get("host_name")
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "\"host_name\"", ")" ]
[ 109, 4 ]
[ 111, 42 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.source_type
(self)
Return the source type, eg gps or router, of the device.
Return the source type, eg gps or router, of the device.
def source_type(self): """Return the source type, eg gps or router, of the device.""" return self._data.get("source_type", SOURCE_TYPE_GPS)
[ "def", "source_type", "(", "self", ")", ":", "return", "self", ".", "_data", ".", "get", "(", "\"source_type\"", ",", "SOURCE_TYPE_GPS", ")" ]
[ 114, 4 ]
[ 116, 61 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return {"name": self.name, "identifiers": {(OT_DOMAIN, self._dev_id)}}
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "name", ",", "\"identifiers\"", ":", "{", "(", "OT_DOMAIN", ",", "self", ".", "_dev_id", ")", "}", "}" ]
[ 119, 4 ]
[ 121, 78 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.async_added_to_hass
(self)
Call when entity about to be added to Home Assistant.
Call when entity about to be added to Home Assistant.
async def async_added_to_hass(self): """Call when entity about to be added to Home Assistant.""" await super().async_added_to_hass() # Don't restore if we got set up with data. if self._data: return state = await self.async_get_last_state() if state is None...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "# Don't restore if we got set up with data.", "if", "self", ".", "_data", ":", "return", "state", "=", "await", "self", ".", "async_g...
[ 123, 4 ]
[ 143, 9 ]
python
en
['en', 'en', 'en']
True
OwnTracksEntity.update_data
(self, data)
Mark the device as seen.
Mark the device as seen.
def update_data(self, data): """Mark the device as seen.""" self._data = data if self.hass: self.async_write_ha_state()
[ "def", "update_data", "(", "self", ",", "data", ")", ":", "self", ".", "_data", "=", "data", "if", "self", ".", "hass", ":", "self", ".", "async_write_ha_state", "(", ")" ]
[ 146, 4 ]
[ 150, 39 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the emulated_kasa component.
Set up the emulated_kasa component.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the emulated_kasa component.""" conf = config.get(DOMAIN) if not conf: return True entity_configs = conf[CONF_ENTITIES] def devices(): """Devices to be emulated.""" yield from get_plug_devices(...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "if", "not", "conf", ":", "return", "True", "entity_configs", "=", "conf", ...
[ 51, 0 ]
[ 78, 15 ]
python
en
['en', 'en', 'en']
True
validate_configs
(hass, entity_configs)
Validate that entities exist and ensure templates are ready to use.
Validate that entities exist and ensure templates are ready to use.
async def validate_configs(hass, entity_configs): """Validate that entities exist and ensure templates are ready to use.""" entity_registry = await hass.helpers.entity_registry.async_get_registry() for entity_id, entity_config in entity_configs.items(): state = hass.states.get(entity_id) if ...
[ "async", "def", "validate_configs", "(", "hass", ",", "entity_configs", ")", ":", "entity_registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "for", "entity_id", ",", "entity_config", "in", "entity_configs"...
[ 81, 0 ]
[ 113, 70 ]
python
en
['en', 'en', 'en']
True
get_system_unique_id
(entity: RegistryEntry)
Determine the system wide unique_id for an entity.
Determine the system wide unique_id for an entity.
def get_system_unique_id(entity: RegistryEntry): """Determine the system wide unique_id for an entity.""" return f"{entity.platform}.{entity.domain}.{entity.unique_id}"
[ "def", "get_system_unique_id", "(", "entity", ":", "RegistryEntry", ")", ":", "return", "f\"{entity.platform}.{entity.domain}.{entity.unique_id}\"" ]
[ 116, 0 ]
[ 118, 66 ]
python
en
['en', 'en', 'en']
True
get_plug_devices
(hass, entity_configs)
Produce list of plug devices from config entities.
Produce list of plug devices from config entities.
def get_plug_devices(hass, entity_configs): """Produce list of plug devices from config entities.""" for entity_id, entity_config in entity_configs.items(): state = hass.states.get(entity_id) if state is None: continue name = entity_config.get(CONF_NAME, state.name) ...
[ "def", "get_plug_devices", "(", "hass", ",", "entity_configs", ")", ":", "for", "entity_id", ",", "entity_config", "in", "entity_configs", ".", "items", "(", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "entity_id", ")", "if", "state", ...
[ 121, 0 ]
[ 150, 9 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Initialize OwnTracks component.
Initialize OwnTracks component.
async def async_setup(hass, config): """Initialize OwnTracks component.""" hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None} if not hass.config_entries.async_entries(DOMAIN): hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, c...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "\"config\"", ":", "config", "[", "DOMAIN", "]", ",", "\"devices\"", ":", "{", "}", ",", "\"unsub\"", ":", "None", "}", "if", "n...
[ 59, 0 ]
[ 69, 15 ]
python
en
['de', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up OwnTracks entry.
Set up OwnTracks entry.
async def async_setup_entry(hass, entry): """Set up OwnTracks entry.""" config = hass.data[DOMAIN]["config"] max_gps_accuracy = config.get(CONF_MAX_GPS_ACCURACY) waypoint_import = config.get(CONF_WAYPOINT_IMPORT) waypoint_whitelist = config.get(CONF_WAYPOINT_WHITELIST) secret = config.get(CONF_S...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "config", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"config\"", "]", "max_gps_accuracy", "=", "config", ".", "get", "(", "CONF_MAX_GPS_ACCURACY", ")", "waypoint_import", "="...
[ 72, 0 ]
[ 110, 15 ]
python
en
['en', 'da', 'en']
True
async_unload_entry
(hass, entry)
Unload an OwnTracks config entry.
Unload an OwnTracks config entry.
async def async_unload_entry(hass, entry): """Unload an OwnTracks config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) hass.data[DOMAIN]["unsub"]() return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_unregister", "(", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ")", "unload_ok", "=", "await", "hass", ".", "config_entrie...
[ 113, 0 ]
[ 119, 20 ]
python
en
['en', 'en', 'en']
True
async_remove_entry
(hass, entry)
Remove an OwnTracks config entry.
Remove an OwnTracks config entry.
async def async_remove_entry(hass, entry): """Remove an OwnTracks config entry.""" if not entry.data.get("cloudhook"): return await hass.components.cloud.async_delete_cloudhook(entry.data[CONF_WEBHOOK_ID])
[ "async", "def", "async_remove_entry", "(", "hass", ",", "entry", ")", ":", "if", "not", "entry", ".", "data", ".", "get", "(", "\"cloudhook\"", ")", ":", "return", "await", "hass", ".", "components", ".", "cloud", ".", "async_delete_cloudhook", "(", "entry...
[ 122, 0 ]
[ 127, 83 ]
python
en
['en', 'en', 'en']
True
async_connect_mqtt
(hass, component)
Subscribe to MQTT topic.
Subscribe to MQTT topic.
async def async_connect_mqtt(hass, component): """Subscribe to MQTT topic.""" context = hass.data[DOMAIN]["context"] async def async_handle_mqtt_message(msg): """Handle incoming OwnTracks message.""" try: message = json.loads(msg.payload) except ValueError: #...
[ "async", "def", "async_connect_mqtt", "(", "hass", ",", "component", ")", ":", "context", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"context\"", "]", "async", "def", "async_handle_mqtt_message", "(", "msg", ")", ":", "\"\"\"Handle incoming OwnTracks m...
[ 130, 0 ]
[ 150, 15 ]
python
en
['en', 'en', 'en']
True