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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SingleStatisticSpanRejection.get_configuratron_exclusions | (self, save_to_file=None) |
Creates exclusions to be used by configuratron on next dataset loading.
Parameters
----------
save_to_file : str (path)
If not None, will save the exlcusions as a yaml file for use by the configuratron.
Returns
-------
exclusions
|
Creates exclusions to be used by configuratron on next dataset loading. | def get_configuratron_exclusions(self, save_to_file=None):
"""
Creates exclusions to be used by configuratron on next dataset loading.
Parameters
----------
save_to_file : str (path)
If not None, will save the exlcusions as a yaml file for use by the config... | [
"def",
"get_configuratron_exclusions",
"(",
"self",
",",
"save_to_file",
"=",
"None",
")",
":",
"def",
"get_start_end",
"(",
"tid",
",",
"sid",
",",
"trial_id",
")",
":",
"stride",
"=",
"self",
".",
"dataset",
".",
"thinkers",
"[",
"tid",
"]",
".",
"sess... | [
307,
4
] | [
350,
27
] | python | en | ['en', 'error', 'th'] | False |
setup | (hass, config) | Set up the Dweet.io component. | Set up the Dweet.io component. | def setup(hass, config):
"""Set up the Dweet.io component."""
conf = config[DOMAIN]
name = conf.get(CONF_NAME)
whitelist = conf.get(CONF_WHITELIST)
json_body = {}
def dweet_event_listener(event):
"""Listen for new messages on the bus and sends them to Dweet.io."""
state = event.... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"name",
"=",
"conf",
".",
"get",
"(",
"CONF_NAME",
")",
"whitelist",
"=",
"conf",
".",
"get",
"(",
"CONF_WHITELIST",
")",
"json_body",
"=",
"{",
"}",
"... | [
39,
0
] | [
67,
15
] | python | en | ['en', 'en', 'en'] | True |
send_data | (name, msg) | Send the collected data to Dweet.io. | Send the collected data to Dweet.io. | def send_data(name, msg):
"""Send the collected data to Dweet.io."""
try:
dweepy.dweet_for(name, msg)
except dweepy.DweepyError:
_LOGGER.error("Error saving data to Dweet.io: %s", msg) | [
"def",
"send_data",
"(",
"name",
",",
"msg",
")",
":",
"try",
":",
"dweepy",
".",
"dweet_for",
"(",
"name",
",",
"msg",
")",
"except",
"dweepy",
".",
"DweepyError",
":",
"_LOGGER",
".",
"error",
"(",
"\"Error saving data to Dweet.io: %s\"",
",",
"msg",
")"... | [
71,
0
] | [
76,
63
] | python | en | ['en', 'en', 'en'] | True |
gcm_api_deprecated | (value) | Warn user that GCM API config is deprecated. | Warn user that GCM API config is deprecated. | def gcm_api_deprecated(value):
"""Warn user that GCM API config is deprecated."""
if value:
_LOGGER.warning(
"Configuring html5_push_notifications via the GCM api"
" has been deprecated and will stop working after April 11,"
" 2019. Use the VAPID configuration instead... | [
"def",
"gcm_api_deprecated",
"(",
"value",
")",
":",
"if",
"value",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Configuring html5_push_notifications via the GCM api\"",
"\" has been deprecated and will stop working after April 11,\"",
"\" 2019. Use the VAPID configuration instead. For inst... | [
51,
0
] | [
60,
16
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the HTML5 push notification service. | Get the HTML5 push notification service. | def get_service(hass, config, discovery_info=None):
"""Get the HTML5 push notification service."""
json_path = hass.config.path(REGISTRATIONS_FILE)
registrations = _load_config(json_path)
if registrations is None:
return None
vapid_pub_key = config.get(ATTR_VAPID_PUB_KEY)
vapid_prv_ke... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"json_path",
"=",
"hass",
".",
"config",
".",
"path",
"(",
"REGISTRATIONS_FILE",
")",
"registrations",
"=",
"_load_config",
"(",
"json_path",
")",
"if",
"registra... | [
168,
0
] | [
199,
5
] | python | en | ['en', 'en', 'en'] | True |
_load_config | (filename) | Load configuration. | Load configuration. | def _load_config(filename):
"""Load configuration."""
try:
return load_json(filename)
except HomeAssistantError:
pass
return {} | [
"def",
"_load_config",
"(",
"filename",
")",
":",
"try",
":",
"return",
"load_json",
"(",
"filename",
")",
"except",
"HomeAssistantError",
":",
"pass",
"return",
"{",
"}"
] | [
202,
0
] | [
208,
13
] | python | en | ['en', 'sm', 'en'] | False |
add_jwt | (timestamp, target, tag, jwt_secret) | Create JWT json to put into payload. | Create JWT json to put into payload. | def add_jwt(timestamp, target, tag, jwt_secret):
"""Create JWT json to put into payload."""
jwt_exp = datetime.fromtimestamp(timestamp) + timedelta(days=JWT_VALID_DAYS)
jwt_claims = {
"exp": jwt_exp,
"nbf": timestamp,
"iat": timestamp,
ATTR_TARGET: target,
ATTR_TAG: ... | [
"def",
"add_jwt",
"(",
"timestamp",
",",
"target",
",",
"tag",
",",
"jwt_secret",
")",
":",
"jwt_exp",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"timestamp",
")",
"+",
"timedelta",
"(",
"days",
"=",
"JWT_VALID_DAYS",
")",
"jwt_claims",
"=",
"{",
"\"exp\"... | [
551,
0
] | [
562,
61
] | python | en | ['en', 'en', 'en'] | True |
create_vapid_headers | (vapid_email, subscription_info, vapid_private_key) | Create encrypted headers to send to WebPusher. | Create encrypted headers to send to WebPusher. | def create_vapid_headers(vapid_email, subscription_info, vapid_private_key):
"""Create encrypted headers to send to WebPusher."""
if vapid_email and vapid_private_key and ATTR_ENDPOINT in subscription_info:
url = urlparse(subscription_info.get(ATTR_ENDPOINT))
vapid_claims = {
"sub":... | [
"def",
"create_vapid_headers",
"(",
"vapid_email",
",",
"subscription_info",
",",
"vapid_private_key",
")",
":",
"if",
"vapid_email",
"and",
"vapid_private_key",
"and",
"ATTR_ENDPOINT",
"in",
"subscription_info",
":",
"url",
"=",
"urlparse",
"(",
"subscription_info",
... | [
565,
0
] | [
576,
15
] | python | en | ['en', 'en', 'en'] | True |
HTML5PushRegistrationView.__init__ | (self, registrations, json_path) | Init HTML5PushRegistrationView. | Init HTML5PushRegistrationView. | def __init__(self, registrations, json_path):
"""Init HTML5PushRegistrationView."""
self.registrations = registrations
self.json_path = json_path | [
"def",
"__init__",
"(",
"self",
",",
"registrations",
",",
"json_path",
")",
":",
"self",
".",
"registrations",
"=",
"registrations",
"self",
".",
"json_path",
"=",
"json_path"
] | [
217,
4
] | [
220,
34
] | python | en | ['en', 'ru-Latn', 'en'] | False |
HTML5PushRegistrationView.post | (self, request) | Accept the POST request for push registrations from a browser. | Accept the POST request for push registrations from a browser. | async def post(self, request):
"""Accept the POST request for push registrations from a browser."""
try:
data = await request.json()
except ValueError:
return self.json_message("Invalid JSON", HTTP_BAD_REQUEST)
try:
data = REGISTER_SCHEMA(data)
... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"await",
"request",
".",
"json",
"(",
")",
"except",
"ValueError",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Invalid JSON\"",
",",
"HTTP_BAD_REQUEST",
")",
... | [
222,
4
] | [
256,
13
] | python | en | ['en', 'en', 'en'] | True |
HTML5PushRegistrationView.find_registration_name | (self, data, suggested=None) | Find a registration name matching data or generate a unique one. | Find a registration name matching data or generate a unique one. | def find_registration_name(self, data, suggested=None):
"""Find a registration name matching data or generate a unique one."""
endpoint = data.get(ATTR_SUBSCRIPTION).get(ATTR_ENDPOINT)
for key, registration in self.registrations.items():
subscription = registration.get(ATTR_SUBSCRIPT... | [
"def",
"find_registration_name",
"(",
"self",
",",
"data",
",",
"suggested",
"=",
"None",
")",
":",
"endpoint",
"=",
"data",
".",
"get",
"(",
"ATTR_SUBSCRIPTION",
")",
".",
"get",
"(",
"ATTR_ENDPOINT",
")",
"for",
"key",
",",
"registration",
"in",
"self",
... | [
258,
4
] | [
265,
86
] | python | en | ['en', 'en', 'en'] | True |
HTML5PushRegistrationView.delete | (self, request) | Delete a registration. | Delete a registration. | async def delete(self, request):
"""Delete a registration."""
try:
data = await request.json()
except ValueError:
return self.json_message("Invalid JSON", HTTP_BAD_REQUEST)
subscription = data.get(ATTR_SUBSCRIPTION)
found = None
for key, registr... | [
"async",
"def",
"delete",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"await",
"request",
".",
"json",
"(",
")",
"except",
"ValueError",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Invalid JSON\"",
",",
"HTTP_BAD_REQUEST",
")",
... | [
267,
4
] | [
301,
78
] | python | en | ['en', 'da', 'en'] | True |
HTML5PushCallbackView.__init__ | (self, registrations) | Init HTML5PushCallbackView. | Init HTML5PushCallbackView. | def __init__(self, registrations):
"""Init HTML5PushCallbackView."""
self.registrations = registrations | [
"def",
"__init__",
"(",
"self",
",",
"registrations",
")",
":",
"self",
".",
"registrations",
"=",
"registrations"
] | [
311,
4
] | [
313,
42
] | python | en | ['en', 'zu', 'en'] | False |
HTML5PushCallbackView.decode_jwt | (self, token) | Find the registration that signed this JWT and return it. | Find the registration that signed this JWT and return it. | def decode_jwt(self, token):
"""Find the registration that signed this JWT and return it."""
# 1. Check claims w/o verifying to see if a target is in there.
# 2. If target in claims, attempt to verify against the given name.
# 2a. If decode is successful, return the payload.
#... | [
"def",
"decode_jwt",
"(",
"self",
",",
"token",
")",
":",
"# 1. Check claims w/o verifying to see if a target is in there.",
"# 2. If target in claims, attempt to verify against the given name.",
"# 2a. If decode is successful, return the payload.",
"# 2b. If decode is unsuccessful, return a... | [
315,
4
] | [
334,
9
] | python | en | ['en', 'en', 'en'] | True |
HTML5PushCallbackView.check_authorization_header | (self, request) | Check the authorization header. | Check the authorization header. | def check_authorization_header(self, request):
"""Check the authorization header."""
auth = request.headers.get(AUTHORIZATION)
if not auth:
return self.json_message(
"Authorization header is expected", status_code=HTTP_UNAUTHORIZED
)
parts = auth... | [
"def",
"check_authorization_header",
"(",
"self",
",",
"request",
")",
":",
"auth",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"AUTHORIZATION",
")",
"if",
"not",
"auth",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Authorization header is expected\"... | [
338,
4
] | [
365,
22
] | python | en | ['en', 'en', 'en'] | True |
HTML5PushCallbackView.post | (self, request) | Accept the POST request for push registrations event callback. | Accept the POST request for push registrations event callback. | async def post(self, request):
"""Accept the POST request for push registrations event callback."""
auth_check = self.check_authorization_header(request)
if not isinstance(auth_check, dict):
return auth_check
try:
data = await request.json()
except ValueE... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"auth_check",
"=",
"self",
".",
"check_authorization_header",
"(",
"request",
")",
"if",
"not",
"isinstance",
"(",
"auth_check",
",",
"dict",
")",
":",
"return",
"auth_check",
"try",
":",
"data... | [
367,
4
] | [
400,
77
] | python | en | ['en', 'en', 'en'] | True |
HTML5NotificationService.__init__ | (self, hass, gcm_key, vapid_prv, vapid_email, registrations, json_path) | Initialize the service. | Initialize the service. | def __init__(self, hass, gcm_key, vapid_prv, vapid_email, registrations, json_path):
"""Initialize the service."""
self._gcm_key = gcm_key
self._vapid_prv = vapid_prv
self._vapid_email = vapid_email
self.registrations = registrations
self.registrations_json_path = json_pa... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"gcm_key",
",",
"vapid_prv",
",",
"vapid_email",
",",
"registrations",
",",
"json_path",
")",
":",
"self",
".",
"_gcm_key",
"=",
"gcm_key",
"self",
".",
"_vapid_prv",
"=",
"vapid_prv",
"self",
".",
"_vapid_... | [
406,
4
] | [
432,
9
] | python | en | ['en', 'en', 'en'] | True |
HTML5NotificationService.targets | (self) | Return a dictionary of registered targets. | Return a dictionary of registered targets. | def targets(self):
"""Return a dictionary of registered targets."""
targets = {}
for registration in self.registrations:
targets[registration] = registration
return targets | [
"def",
"targets",
"(",
"self",
")",
":",
"targets",
"=",
"{",
"}",
"for",
"registration",
"in",
"self",
".",
"registrations",
":",
"targets",
"[",
"registration",
"]",
"=",
"registration",
"return",
"targets"
] | [
435,
4
] | [
440,
22
] | python | en | ['en', 'en', 'en'] | True |
HTML5NotificationService.dismiss | (self, **kwargs) | Dismisses a notification. | Dismisses a notification. | def dismiss(self, **kwargs):
"""Dismisses a notification."""
data = kwargs.get(ATTR_DATA)
tag = data.get(ATTR_TAG) if data else ""
payload = {ATTR_TAG: tag, ATTR_DISMISS: True, ATTR_DATA: {}}
self._push_message(payload, **kwargs) | [
"def",
"dismiss",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"tag",
"=",
"data",
".",
"get",
"(",
"ATTR_TAG",
")",
"if",
"data",
"else",
"\"\"",
"payload",
"=",
"{",
"ATTR_TAG",
":",
... | [
442,
4
] | [
448,
45
] | python | en | ['en', 'fr', 'en'] | True |
HTML5NotificationService.async_dismiss | (self, **kwargs) | Dismisses a notification.
This method must be run in the event loop.
| Dismisses a notification. | async def async_dismiss(self, **kwargs):
"""Dismisses a notification.
This method must be run in the event loop.
"""
await self.hass.async_add_executor_job(partial(self.dismiss, **kwargs)) | [
"async",
"def",
"async_dismiss",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"partial",
"(",
"self",
".",
"dismiss",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
450,
4
] | [
455,
79
] | python | en | ['en', 'fr', 'en'] | True |
HTML5NotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
tag = str(uuid.uuid4())
payload = {
"badge": "/static/images/notification-badge.png",
"body": message,
ATTR_DATA: {},
"icon": "/static/icons/favicon-192x192.png",
... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"tag",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"payload",
"=",
"{",
"\"badge\"",
":",
"\"/static/images/notification-badge.png\"",
",",
"\"b... | [
457,
4
] | [
491,
45
] | python | en | ['en', 'en', 'en'] | True |
HTML5NotificationService._push_message | (self, payload, **kwargs) | Send the message. | Send the message. | def _push_message(self, payload, **kwargs):
"""Send the message."""
timestamp = int(time.time())
ttl = int(kwargs.get(ATTR_TTL, DEFAULT_TTL))
priority = kwargs.get(ATTR_PRIORITY, DEFAULT_PRIORITY)
if priority not in ["normal", "high"]:
priority = DEFAULT_PRIORITY
... | [
"def",
"_push_message",
"(",
"self",
",",
"payload",
",",
"*",
"*",
"kwargs",
")",
":",
"timestamp",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"ttl",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_TTL",
",",
"DEFAULT_TTL",
")",
")",
... | [
493,
4
] | [
548,
55
] | python | en | ['en', 'en', 'en'] | True |
exists | (value) | Check if value exists. | Check if value exists. | def exists(value):
"""Check if value exists."""
if value is None:
raise vol.Invalid("Value cannot be None")
return value | [
"def",
"exists",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"raise",
"vol",
".",
"Invalid",
"(",
"\"Value cannot be None\"",
")",
"return",
"value"
] | [
16,
0
] | [
20,
16
] | python | en | ['es', 'en', 'en'] | True |
grep_dir | (path: pathlib.Path, glob_pattern: str, search_pattern: str) | Recursively go through a dir and it's children and find the regex. | Recursively go through a dir and it's children and find the regex. | def grep_dir(path: pathlib.Path, glob_pattern: str, search_pattern: str) -> bool:
"""Recursively go through a dir and it's children and find the regex."""
pattern = re.compile(search_pattern)
for fil in path.glob(glob_pattern):
if not fil.is_file():
continue
if pattern.search(f... | [
"def",
"grep_dir",
"(",
"path",
":",
"pathlib",
".",
"Path",
",",
"glob_pattern",
":",
"str",
",",
"search_pattern",
":",
"str",
")",
"->",
"bool",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"search_pattern",
")",
"for",
"fil",
"in",
"path",
".",
... | [
44,
0
] | [
55,
16
] | python | en | ['en', 'en', 'en'] | True |
validate_services | (integration: Integration) | Validate services. | Validate services. | def validate_services(integration: Integration):
"""Validate services."""
# Find if integration uses services
has_services = grep_dir(
integration.path, "**/*.py", r"hass\.services\.(register|async_register)"
)
if not has_services:
return
try:
data = load_yaml(str(integ... | [
"def",
"validate_services",
"(",
"integration",
":",
"Integration",
")",
":",
"# Find if integration uses services",
"has_services",
"=",
"grep_dir",
"(",
"integration",
".",
"path",
",",
"\"**/*.py\"",
",",
"r\"hass\\.services\\.(register|async_register)\"",
")",
"if",
"... | [
58,
0
] | [
84,
9
] | python | en | ['en', 'en', 'en'] | False |
validate | (integrations: Dict[str, Integration], config) | Handle dependencies for integrations. | Handle dependencies for integrations. | def validate(integrations: Dict[str, Integration], config):
"""Handle dependencies for integrations."""
# check services.yaml is cool
for integration in integrations.values():
if not integration.manifest:
continue
validate_services(integration) | [
"def",
"validate",
"(",
"integrations",
":",
"Dict",
"[",
"str",
",",
"Integration",
"]",
",",
"config",
")",
":",
"# check services.yaml is cool",
"for",
"integration",
"in",
"integrations",
".",
"values",
"(",
")",
":",
"if",
"not",
"integration",
".",
"ma... | [
87,
0
] | [
94,
38
] | python | en | ['fr', 'nl', 'en'] | False |
test_humanify_alexa_event | (hass) | Test humanifying Alexa event. | Test humanifying Alexa event. | async def test_humanify_alexa_event(hass):
"""Test humanifying Alexa event."""
hass.config.components.add("recorder")
await async_setup_component(hass, "alexa", {})
await async_setup_component(hass, "logbook", {})
hass.states.async_set("light.kitchen", "on", {"friendly_name": "Kitchen Light"})
e... | [
"async",
"def",
"test_humanify_alexa_event",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"recorder\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"alexa\"",
",",
"{",
"}",
")",
"await",
"async_setup_compo... | [
8,
0
] | [
68,
54
] | python | en | ['xh', 'en', 'en'] | True |
env_without_wheel_links | () | Return env without wheel links. | Return env without wheel links. | def env_without_wheel_links():
"""Return env without wheel links."""
env = dict(os.environ)
env.pop("WHEEL_LINKS", None)
return env | [
"def",
"env_without_wheel_links",
"(",
")",
":",
"env",
"=",
"dict",
"(",
"os",
".",
"environ",
")",
"env",
".",
"pop",
"(",
"\"WHEEL_LINKS\"",
",",
"None",
")",
"return",
"env"
] | [
17,
0
] | [
21,
14
] | python | en | ['en', 'en', 'en'] | True |
test_requirement_installed_in_venv | (hass) | Test requirement installed in virtual environment. | Test requirement installed in virtual environment. | async def test_requirement_installed_in_venv(hass):
"""Test requirement installed in virtual environment."""
with patch("os.path.dirname", return_value="ha_package_path"), patch(
"homeassistant.util.package.is_virtual_env", return_value=True
), patch("homeassistant.util.package.is_docker_env", retur... | [
"async",
"def",
"test_requirement_installed_in_venv",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"os.path.dirname\"",
",",
"return_value",
"=",
"\"ha_package_path\"",
")",
",",
"patch",
"(",
"\"homeassistant.util.package.is_virtual_env\"",
",",
"return_value",
"=",
... | [
24,
0
] | [
41,
9
] | python | en | ['en', 'en', 'en'] | True |
test_requirement_installed_in_deps | (hass) | Test requirement installed in deps directory. | Test requirement installed in deps directory. | async def test_requirement_installed_in_deps(hass):
"""Test requirement installed in deps directory."""
with patch("os.path.dirname", return_value="ha_package_path"), patch(
"homeassistant.util.package.is_virtual_env", return_value=False
), patch("homeassistant.util.package.is_docker_env", return_va... | [
"async",
"def",
"test_requirement_installed_in_deps",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"os.path.dirname\"",
",",
"return_value",
"=",
"\"ha_package_path\"",
")",
",",
"patch",
"(",
"\"homeassistant.util.package.is_virtual_env\"",
",",
"return_value",
"=",
... | [
44,
0
] | [
62,
9
] | python | en | ['en', 'en', 'en'] | True |
test_install_existing_package | (hass) | Test an install attempt on an existing package. | Test an install attempt on an existing package. | async def test_install_existing_package(hass):
"""Test an install attempt on an existing package."""
with patch(
"homeassistant.util.package.install_package", return_value=True
) as mock_inst:
await async_process_requirements(hass, "test_component", ["hello==1.0.0"])
assert len(mock_ins... | [
"async",
"def",
"test_install_existing_package",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.util.package.install_package\"",
",",
"return_value",
"=",
"True",
")",
"as",
"mock_inst",
":",
"await",
"async_process_requirements",
"(",
"hass",
",",
"\"t... | [
65,
0
] | [
79,
41
] | python | en | ['en', 'en', 'en'] | True |
test_install_missing_package | (hass) | Test an install attempt on an existing package. | Test an install attempt on an existing package. | async def test_install_missing_package(hass):
"""Test an install attempt on an existing package."""
with patch(
"homeassistant.util.package.install_package", return_value=False
) as mock_inst:
with pytest.raises(RequirementsNotFound):
await async_process_requirements(hass, "test_... | [
"async",
"def",
"test_install_missing_package",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.util.package.install_package\"",
",",
"return_value",
"=",
"False",
")",
"as",
"mock_inst",
":",
"with",
"pytest",
".",
"raises",
"(",
"RequirementsNotFound",... | [
82,
0
] | [
90,
41
] | python | en | ['en', 'en', 'en'] | True |
test_get_integration_with_requirements | (hass) | Check getting an integration with loaded requirements. | Check getting an integration with loaded requirements. | async def test_get_integration_with_requirements(hass):
"""Check getting an integration with loaded requirements."""
hass.config.skip_pip = False
mock_integration(
hass, MockModule("test_component_dep", requirements=["test-comp-dep==1.0.0"])
)
mock_integration(
hass,
MockModu... | [
"async",
"def",
"test_get_integration_with_requirements",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"skip_pip",
"=",
"False",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"\"test_component_dep\"",
",",
"requirements",
"=",
"[",
"\"test-comp-dep=... | [
93,
0
] | [
139,
5
] | python | en | ['en', 'en', 'en'] | True |
test_install_with_wheels_index | (hass) | Test an install attempt with wheels index URL. | Test an install attempt with wheels index URL. | async def test_install_with_wheels_index(hass):
"""Test an install attempt with wheels index URL."""
hass.config.skip_pip = False
mock_integration(hass, MockModule("comp", requirements=["hello==1.0.0"]))
with patch("homeassistant.util.package.is_installed", return_value=False), patch(
"homeassi... | [
"async",
"def",
"test_install_with_wheels_index",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"skip_pip",
"=",
"False",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"\"comp\"",
",",
"requirements",
"=",
"[",
"\"hello==1.0.0\"",
"]",
")",
")"... | [
142,
0
] | [
163,
9
] | python | en | ['en', 'en', 'en'] | True |
test_install_on_docker | (hass) | Test an install attempt on an docker system env. | Test an install attempt on an docker system env. | async def test_install_on_docker(hass):
"""Test an install attempt on an docker system env."""
hass.config.skip_pip = False
mock_integration(hass, MockModule("comp", requirements=["hello==1.0.0"]))
with patch("homeassistant.util.package.is_installed", return_value=False), patch(
"homeassistant.... | [
"async",
"def",
"test_install_on_docker",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"skip_pip",
"=",
"False",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"\"comp\"",
",",
"requirements",
"=",
"[",
"\"hello==1.0.0\"",
"]",
")",
")",
"wit... | [
166,
0
] | [
186,
9
] | python | en | ['en', 'lb', 'en'] | True |
test_discovery_requirements_mqtt | (hass) | Test that we load discovery requirements. | Test that we load discovery requirements. | async def test_discovery_requirements_mqtt(hass):
"""Test that we load discovery requirements."""
hass.config.skip_pip = False
mqtt = await loader.async_get_integration(hass, "mqtt")
mock_integration(
hass, MockModule("mqtt_comp", partial_manifest={"mqtt": ["foo/discovery"]})
)
with pat... | [
"async",
"def",
"test_discovery_requirements_mqtt",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"skip_pip",
"=",
"False",
"mqtt",
"=",
"await",
"loader",
".",
"async_get_integration",
"(",
"hass",
",",
"\"mqtt\"",
")",
"mock_integration",
"(",
"hass",
"... | [
189,
0
] | [
203,
64
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_requirements_ssdp | (hass) | Test that we load discovery requirements. | Test that we load discovery requirements. | async def test_discovery_requirements_ssdp(hass):
"""Test that we load discovery requirements."""
hass.config.skip_pip = False
ssdp = await loader.async_get_integration(hass, "ssdp")
mock_integration(
hass, MockModule("ssdp_comp", partial_manifest={"ssdp": [{"st": "roku:ecp"}]})
)
with ... | [
"async",
"def",
"test_discovery_requirements_ssdp",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"skip_pip",
"=",
"False",
"ssdp",
"=",
"await",
"loader",
".",
"async_get_integration",
"(",
"hass",
",",
"\"ssdp\"",
")",
"mock_integration",
"(",
"hass",
"... | [
206,
0
] | [
222,
57
] | python | en | ['en', 'en', 'en'] | True |
test_discovery_requirements_zeroconf | (hass, partial_manifest) | Test that we load discovery requirements. | Test that we load discovery requirements. | async def test_discovery_requirements_zeroconf(hass, partial_manifest):
"""Test that we load discovery requirements."""
hass.config.skip_pip = False
zeroconf = await loader.async_get_integration(hass, "zeroconf")
mock_integration(
hass,
MockModule("comp", partial_manifest=partial_manife... | [
"async",
"def",
"test_discovery_requirements_zeroconf",
"(",
"hass",
",",
"partial_manifest",
")",
":",
"hass",
".",
"config",
".",
"skip_pip",
"=",
"False",
"zeroconf",
"=",
"await",
"loader",
".",
"async_get_integration",
"(",
"hass",
",",
"\"zeroconf\"",
")",
... | [
229,
0
] | [
245,
68
] | python | en | ['en', 'en', 'en'] | True |
test_component_unload_config_entry | (hass, config_entry) | Test that loading and unloading of a config entry works. | Test that loading and unloading of a config entry works. | async def test_component_unload_config_entry(hass, config_entry):
"""Test that loading and unloading of a config entry works."""
config_entry.add_to_hass(hass)
with patch("aio_georss_gdacs.GdacsFeedManager.update") as mock_feed_manager_update:
# Load config entry.
assert await hass.config_en... | [
"async",
"def",
"test_component_unload_config_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"aio_georss_gdacs.GdacsFeedManager.update\"",
")",
"as",
"mock_feed_manager_update",
":",
"# L... | [
6,
0
] | [
18,
73
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up sensors for UniFi integration. | Set up sensors for UniFi integration. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up sensors for UniFi integration."""
controller = hass.data[UNIFI_DOMAIN][config_entry.entry_id]
controller.entities[DOMAIN] = {
RX_SENSOR: set(),
TX_SENSOR: set(),
UPTIME_SENSOR: set(),
}
@callback
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"controller",
"=",
"hass",
".",
"data",
"[",
"UNIFI_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"controller",
".",
"entities",
"[",
"DOMAIN... | [
15,
0
] | [
38,
17
] | python | en | ['en', 'da', 'en'] | True |
add_bandwith_entities | (controller, async_add_entities, clients) | Add new sensor entities from the controller. | Add new sensor entities from the controller. | def add_bandwith_entities(controller, async_add_entities, clients):
"""Add new sensor entities from the controller."""
sensors = []
for mac in clients:
for sensor_class in (UniFiRxBandwidthSensor, UniFiTxBandwidthSensor):
if mac in controller.entities[DOMAIN][sensor_class.TYPE]:
... | [
"def",
"add_bandwith_entities",
"(",
"controller",
",",
"async_add_entities",
",",
"clients",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"mac",
"in",
"clients",
":",
"for",
"sensor_class",
"in",
"(",
"UniFiRxBandwidthSensor",
",",
"UniFiTxBandwidthSensor",
")",
... | [
42,
0
] | [
55,
35
] | python | en | ['en', 'en', 'en'] | True |
add_uptime_entities | (controller, async_add_entities, clients) | Add new sensor entities from the controller. | Add new sensor entities from the controller. | def add_uptime_entities(controller, async_add_entities, clients):
"""Add new sensor entities from the controller."""
sensors = []
for mac in clients:
if mac in controller.entities[DOMAIN][UniFiUpTimeSensor.TYPE]:
continue
client = controller.api.clients[mac]
sensors.app... | [
"def",
"add_uptime_entities",
"(",
"controller",
",",
"async_add_entities",
",",
"clients",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"mac",
"in",
"clients",
":",
"if",
"mac",
"in",
"controller",
".",
"entities",
"[",
"DOMAIN",
"]",
"[",
"UniFiUpTimeSensor"... | [
59,
0
] | [
71,
35
] | python | en | ['en', 'en', 'en'] | True |
UniFiBandwidthSensor.name | (self) | Return the name of the client. | Return the name of the client. | def name(self) -> str:
"""Return the name of the client."""
return f"{super().name} {self.TYPE.upper()}" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{super().name} {self.TYPE.upper()}\""
] | [
80,
4
] | [
82,
52
] | python | en | ['en', 'en', 'en'] | True |
UniFiBandwidthSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity. | Return the unit of measurement of this entity. | def unit_of_measurement(self) -> str:
"""Return the unit of measurement of this entity."""
return DATA_MEGABYTES | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DATA_MEGABYTES"
] | [
85,
4
] | [
87,
29
] | python | en | ['en', 'en', 'en'] | True |
UniFiBandwidthSensor.options_updated | (self) | Config entry options are updated, remove entity if option is disabled. | Config entry options are updated, remove entity if option is disabled. | async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
if not self.controller.option_allow_bandwidth_sensors:
await self.remove_item({self.client.mac}) | [
"async",
"def",
"options_updated",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"controller",
".",
"option_allow_bandwidth_sensors",
":",
"await",
"self",
".",
"remove_item",
"(",
"{",
"self",
".",
"client",
".",
"mac",
"}",
")"
] | [
89,
4
] | [
92,
53
] | python | en | ['en', 'en', 'en'] | True |
UniFiRxBandwidthSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
if self._is_wired:
return self.client.wired_rx_bytes / 1000000
return self.client.rx_bytes / 1000000 | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"_is_wired",
":",
"return",
"self",
".",
"client",
".",
"wired_rx_bytes",
"/",
"1000000",
"return",
"self",
".",
"client",
".",
"rx_bytes",
"/",
"1000000"
] | [
101,
4
] | [
105,
45
] | python | en | ['en', 'en', 'en'] | True |
UniFiTxBandwidthSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
if self._is_wired:
return self.client.wired_tx_bytes / 1000000
return self.client.tx_bytes / 1000000 | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"_is_wired",
":",
"return",
"self",
".",
"client",
".",
"wired_tx_bytes",
"/",
"1000000",
"return",
"self",
".",
"client",
".",
"tx_bytes",
"/",
"1000000"
] | [
114,
4
] | [
118,
45
] | python | en | ['en', 'en', 'en'] | True |
UniFiUpTimeSensor.device_class | (self) | Return device class. | Return device class. | def device_class(self) -> str:
"""Return device class."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
128,
4
] | [
130,
37
] | python | en | ['es', 'zh', 'en'] | False |
UniFiUpTimeSensor.name | (self) | Return the name of the client. | Return the name of the client. | def name(self) -> str:
"""Return the name of the client."""
return f"{super().name} {self.TYPE.capitalize()}" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{super().name} {self.TYPE.capitalize()}\""
] | [
133,
4
] | [
135,
57
] | python | en | ['en', 'en', 'en'] | True |
UniFiUpTimeSensor.state | (self) | Return the uptime of the client. | Return the uptime of the client. | def state(self) -> int:
"""Return the uptime of the client."""
return dt_util.utc_from_timestamp(float(self.client.uptime)).isoformat() | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"dt_util",
".",
"utc_from_timestamp",
"(",
"float",
"(",
"self",
".",
"client",
".",
"uptime",
")",
")",
".",
"isoformat",
"(",
")"
] | [
138,
4
] | [
140,
80
] | python | en | ['en', 'en', 'en'] | True |
UniFiUpTimeSensor.options_updated | (self) | Config entry options are updated, remove entity if option is disabled. | Config entry options are updated, remove entity if option is disabled. | async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
if not self.controller.option_allow_uptime_sensors:
await self.remove_item({self.client.mac}) | [
"async",
"def",
"options_updated",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"controller",
".",
"option_allow_uptime_sensors",
":",
"await",
"self",
".",
"remove_item",
"(",
"{",
"self",
".",
"client",
".",
"mac",
"}",
")"
] | [
142,
4
] | [
145,
53
] | python | en | ['en', 'en', 'en'] | True |
DependencyAwarePruner._dependency_calc_mask | (self, wrappers, channel_dsets, wrappers_idx=None) |
calculate the masks for the conv layers in the same
channel dependecy set. All the layers passed in have
the same number of channels.
Parameters
----------
wrappers: list
The list of the wrappers that in the same channel dependency
set.
w... |
calculate the masks for the conv layers in the same
channel dependecy set. All the layers passed in have
the same number of channels. | def _dependency_calc_mask(self, wrappers, channel_dsets, wrappers_idx=None):
"""
calculate the masks for the conv layers in the same
channel dependecy set. All the layers passed in have
the same number of channels.
Parameters
----------
wrappers: list
... | [
"def",
"_dependency_calc_mask",
"(",
"self",
",",
"wrappers",
",",
"channel_dsets",
",",
"wrappers_idx",
"=",
"None",
")",
":",
"# The number of the groups for each conv layers",
"# Note that, this number may be different from its",
"# original number of groups of filters.",
"group... | [
99,
4
] | [
132,
20
] | python | en | ['en', 'error', 'th'] | False |
DependencyAwarePruner._dependency_update_mask | (self) |
In the original update_mask, the wraper of each layer will update its
own mask according to the sparsity specified in the config_list. However, in
the _dependency_update_mask, we may prune several layers at the same
time according the sparsities and the channel/group dependencies.
... |
In the original update_mask, the wraper of each layer will update its
own mask according to the sparsity specified in the config_list. However, in
the _dependency_update_mask, we may prune several layers at the same
time according the sparsities and the channel/group dependencies.
... | def _dependency_update_mask(self):
"""
In the original update_mask, the wraper of each layer will update its
own mask according to the sparsity specified in the config_list. However, in
the _dependency_update_mask, we may prune several layers at the same
time according the sparsi... | [
"def",
"_dependency_update_mask",
"(",
"self",
")",
":",
"name2wrapper",
"=",
"{",
"x",
".",
"name",
":",
"x",
"for",
"x",
"in",
"self",
".",
"get_modules_wrapper",
"(",
")",
"}",
"wrapper2index",
"=",
"{",
"x",
":",
"i",
"for",
"i",
",",
"x",
"in",
... | [
134,
4
] | [
161,
88
] | python | en | ['en', 'error', 'th'] | False |
get_args | () | get args from command line
| get args from command line
| def get_args():
""" get args from command line
"""
parser = argparse.ArgumentParser("cifar10")
parser.add_argument("--batch_size", type=int, default=128, help="batch size")
parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer")
parser.add_argument("--epochs", type=int, def... | [
"def",
"get_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"\"cifar10\"",
")",
"parser",
".",
"add_argument",
"(",
"\"--batch_size\"",
",",
"type",
"=",
"int",
",",
"default",
"=",
"128",
",",
"help",
"=",
"\"batch size\"",
")... | [
54,
0
] | [
70,
30
] | python | en | ['en', 'en', 'en'] | True |
build_graph_from_json | (ir_model_json) | build model from json representation
| build model from json representation
| def build_graph_from_json(ir_model_json):
"""build model from json representation
"""
graph = json_to_graph(ir_model_json)
logging.debug(graph.operation_history)
model = graph.produce_keras_model()
return model | [
"def",
"build_graph_from_json",
"(",
"ir_model_json",
")",
":",
"graph",
"=",
"json_to_graph",
"(",
"ir_model_json",
")",
"logging",
".",
"debug",
"(",
"graph",
".",
"operation_history",
")",
"model",
"=",
"graph",
".",
"produce_keras_model",
"(",
")",
"return",... | [
80,
0
] | [
86,
16
] | python | en | ['en', 'en', 'en'] | True |
parse_rev_args | (receive_msg) | parse reveive msgs to global variable
| parse reveive msgs to global variable
| def parse_rev_args(receive_msg):
""" parse reveive msgs to global variable
"""
global trainloader
global testloader
global net
# Loading Data
logger.debug("Preparing data..")
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
y_train = to_categorical(y_train, 10)
y_test... | [
"def",
"parse_rev_args",
"(",
"receive_msg",
")",
":",
"global",
"trainloader",
"global",
"testloader",
"global",
"net",
"# Loading Data",
"logger",
".",
"debug",
"(",
"\"Preparing data..\"",
")",
"(",
"x_train",
",",
"y_train",
")",
",",
"(",
"x_test",
",",
"... | [
89,
0
] | [
139,
12
] | python | en | ['en', 'en', 'en'] | True |
train_eval | () | train and eval the model
| train and eval the model
| def train_eval():
""" train and eval the model
"""
global trainloader
global testloader
global net
(x_train, y_train) = trainloader
(x_test, y_test) = testloader
# train procedure
net.fit(
x=x_train,
y=y_train,
batch_size=args.batch_size,
validation... | [
"def",
"train_eval",
"(",
")",
":",
"global",
"trainloader",
"global",
"testloader",
"global",
"net",
"(",
"x_train",
",",
"y_train",
")",
"=",
"trainloader",
"(",
"x_test",
",",
"y_test",
")",
"=",
"testloader",
"# train procedure",
"net",
".",
"fit",
"(",
... | [
162,
0
] | [
191,
32
] | python | en | ['en', 'en', 'en'] | True |
SendMetrics.on_epoch_end | (self, epoch, logs=None) |
Run on end of each epoch
|
Run on end of each epoch
| def on_epoch_end(self, epoch, logs=None):
"""
Run on end of each epoch
"""
if logs is None:
logs = dict()
logger.debug(logs)
# TensorFlow 2.0 API reference claims the key is `val_acc`, but in fact it's `val_accuracy`
if 'val_acc' in logs:
n... | [
"def",
"on_epoch_end",
"(",
"self",
",",
"epoch",
",",
"logs",
"=",
"None",
")",
":",
"if",
"logs",
"is",
"None",
":",
"logs",
"=",
"dict",
"(",
")",
"logger",
".",
"debug",
"(",
"logs",
")",
"# TensorFlow 2.0 API reference claims the key is `val_acc`, but in ... | [
147,
4
] | [
158,
64
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass: HomeAssistantType, config: dict) | Set up the Tasmota component. | Set up the Tasmota component. | async def async_setup(hass: HomeAssistantType, config: dict):
"""Set up the Tasmota component."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"dict",
")",
":",
"return",
"True"
] | [
40,
0
] | [
42,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, entry) | Set up Tasmota from a config entry. | Set up Tasmota from a config entry. | async def async_setup_entry(hass, entry):
"""Set up Tasmota from a config entry."""
websocket_api.async_register_command(hass, websocket_remove_device)
hass.data[DATA_UNSUB] = []
def _publish(*args, **kwds):
mqtt.async_publish(hass, *args, **kwds)
async def _subscribe_topics(sub_state, top... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_remove_device",
")",
"hass",
".",
"data",
"[",
"DATA_UNSUB",
"]",
"=",
"[",
"]",
"def",
"_publish",
"(",
"*... | [
45,
0
] | [
105,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
# cleanup platforms
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
)... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"# cleanup platforms",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",... | [
108,
0
] | [
139,
15
] | python | en | ['en', 'es', 'en'] | True |
_remove_device | (hass, config_entry, mac, tasmota_mqtt, device_registry) | Remove device from device registry. | Remove device from device registry. | def _remove_device(hass, config_entry, mac, tasmota_mqtt, device_registry):
"""Remove device from device registry."""
device = device_registry.async_get_device(set(), {(CONNECTION_NETWORK_MAC, mac)})
if device is None:
return
_LOGGER.debug("Removing tasmota device %s", mac)
device_registry... | [
"def",
"_remove_device",
"(",
"hass",
",",
"config_entry",
",",
"mac",
",",
"tasmota_mqtt",
",",
"device_registry",
")",
":",
"device",
"=",
"device_registry",
".",
"async_get_device",
"(",
"set",
"(",
")",
",",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"mac",
... | [
142,
0
] | [
151,
86
] | python | en | ['en', 'en', 'en'] | True |
_update_device | (hass, config_entry, config, device_registry) | Add or update device registry. | Add or update device registry. | def _update_device(hass, config_entry, config, device_registry):
"""Add or update device registry."""
config_entry_id = config_entry.entry_id
device_info = {
"connections": {(CONNECTION_NETWORK_MAC, config[CONF_MAC])},
"manufacturer": config[CONF_MANUFACTURER],
"model": config[CONF_M... | [
"def",
"_update_device",
"(",
"hass",
",",
"config_entry",
",",
"config",
",",
"device_registry",
")",
":",
"config_entry_id",
"=",
"config_entry",
".",
"entry_id",
"device_info",
"=",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"config",... | [
154,
0
] | [
166,
54
] | python | en | ['en', 'fy', 'en'] | True |
async_setup_device | (hass, mac, config, config_entry, tasmota_mqtt, device_registry) | Set up the Tasmota device. | Set up the Tasmota device. | def async_setup_device(hass, mac, config, config_entry, tasmota_mqtt, device_registry):
"""Set up the Tasmota device."""
if not config:
_remove_device(hass, config_entry, mac, tasmota_mqtt, device_registry)
else:
_update_device(hass, config_entry, config, device_registry) | [
"def",
"async_setup_device",
"(",
"hass",
",",
"mac",
",",
"config",
",",
"config_entry",
",",
"tasmota_mqtt",
",",
"device_registry",
")",
":",
"if",
"not",
"config",
":",
"_remove_device",
"(",
"hass",
",",
"config_entry",
",",
"mac",
",",
"tasmota_mqtt",
... | [
169,
0
] | [
174,
67
] | python | en | ['en', 'hi-Latn', 'en'] | True |
websocket_remove_device | (hass, connection, msg) | Delete device. | Delete device. | async def websocket_remove_device(hass, connection, msg):
"""Delete device."""
device_id = msg["device_id"]
dev_registry = await hass.helpers.device_registry.async_get_registry()
device = dev_registry.async_get(device_id)
if not device:
connection.send_error(
msg["id"], websocke... | [
"async",
"def",
"websocket_remove_device",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"dev_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
"... | [
181,
0
] | [
203,
5
] | python | it | ['it', 'it', 'en'] | False |
get_service | (hass, config, discovery_info=None) | Get the Telegram notification service. | Get the Telegram notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Telegram notification service."""
setup_reload_service(hass, TELEGRAM_DOMAIN, PLATFORMS)
chat_id = config.get(CONF_CHAT_ID)
return TelegramNotificationService(hass, chat_id) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"setup_reload_service",
"(",
"hass",
",",
"TELEGRAM_DOMAIN",
",",
"PLATFORMS",
")",
"chat_id",
"=",
"config",
".",
"get",
"(",
"CONF_CHAT_ID",
")",
"return",
"Tel... | [
32,
0
] | [
37,
53
] | python | en | ['en', 'de', 'en'] | True |
TelegramNotificationService.__init__ | (self, hass, chat_id) | Initialize the service. | Initialize the service. | def __init__(self, hass, chat_id):
"""Initialize the service."""
self._chat_id = chat_id
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"chat_id",
")",
":",
"self",
".",
"_chat_id",
"=",
"chat_id",
"self",
".",
"hass",
"=",
"hass"
] | [
43,
4
] | [
46,
24
] | python | en | ['en', 'en', 'en'] | True |
TelegramNotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
service_data = {ATTR_TARGET: kwargs.get(ATTR_TARGET, self._chat_id)}
if ATTR_TITLE in kwargs:
service_data.update({ATTR_TITLE: kwargs.get(ATTR_TITLE)})
if message:
service_data.update({A... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"service_data",
"=",
"{",
"ATTR_TARGET",
":",
"kwargs",
".",
"get",
"(",
"ATTR_TARGET",
",",
"self",
".",
"_chat_id",
")",
"}",
"if",
"ATTR_TITLE",
"in"... | [
48,
4
] | [
99,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Obihai sensor platform. | Set up the Obihai sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Obihai sensor platform."""
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
host = config[CONF_HOST]
sensors = []
pyobihai = PyObihai(host, username, password)
login = pyobihai.check_accou... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"config",
"[",
"CONF_PASSWORD",
"]",
"host",
"=",
"config",
"[",
... | [
34,
0
] | [
68,
25
] | python | en | ['en', 'pt', 'en'] | True |
ObihaiServiceSensors.__init__ | (self, pyobihai, serial, service_name) | Initialize monitor sensor. | Initialize monitor sensor. | def __init__(self, pyobihai, serial, service_name):
"""Initialize monitor sensor."""
self._service_name = service_name
self._state = None
self._name = f"{OBIHAI} {self._service_name}"
self._pyobihai = pyobihai
self._unique_id = f"{serial}-{self._service_name}" | [
"def",
"__init__",
"(",
"self",
",",
"pyobihai",
",",
"serial",
",",
"service_name",
")",
":",
"self",
".",
"_service_name",
"=",
"service_name",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_name",
"=",
"f\"{OBIHAI} {self._service_name}\"",
"self",
".",
... | [
74,
4
] | [
80,
58
] | python | en | ['en', 'zu', 'it'] | False |
ObihaiServiceSensors.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
83,
4
] | [
85,
25
] | python | en | ['en', 'mi', 'en'] | True |
ObihaiServiceSensors.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"
] | [
88,
4
] | [
90,
26
] | python | en | ['en', 'en', 'en'] | True |
ObihaiServiceSensors.available | (self) | Return if sensor is available. | Return if sensor is available. | def available(self):
"""Return if sensor is available."""
if self._state is not None:
return True
return False | [
"def",
"available",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"is",
"not",
"None",
":",
"return",
"True",
"return",
"False"
] | [
93,
4
] | [
97,
20
] | python | en | ['en', 'en', 'en'] | True |
ObihaiServiceSensors.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"
] | [
100,
4
] | [
102,
30
] | python | en | ['en', 'la', 'en'] | True |
ObihaiServiceSensors.device_class | (self) | Return the device class for uptime sensor. | Return the device class for uptime sensor. | def device_class(self):
"""Return the device class for uptime sensor."""
if self._service_name == "Last Reboot":
return DEVICE_CLASS_TIMESTAMP
return None | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"_service_name",
"==",
"\"Last Reboot\"",
":",
"return",
"DEVICE_CLASS_TIMESTAMP",
"return",
"None"
] | [
105,
4
] | [
109,
19
] | python | en | ['en', 'en', 'en'] | True |
ObihaiServiceSensors.icon | (self) | Return an icon. | Return an icon. | def icon(self):
"""Return an icon."""
if self._service_name == "Call Direction":
if self._state == "No Active Calls":
return "mdi:phone-off"
if self._state == "Inbound Call":
return "mdi:phone-incoming"
return "mdi:phone-outgoing"
... | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_service_name",
"==",
"\"Call Direction\"",
":",
"if",
"self",
".",
"_state",
"==",
"\"No Active Calls\"",
":",
"return",
"\"mdi:phone-off\"",
"if",
"self",
".",
"_state",
"==",
"\"Inbound Call\"",
":",... | [
112,
4
] | [
138,
26
] | python | en | ['en', 'gd', 'en'] | True |
ObihaiServiceSensors.update | (self) | Update the sensor. | Update the sensor. | def update(self):
"""Update the sensor."""
services = self._pyobihai.get_state()
if self._service_name in services:
self._state = services.get(self._service_name)
services = self._pyobihai.get_line_state()
if services is not None:
if self._service_name ... | [
"def",
"update",
"(",
"self",
")",
":",
"services",
"=",
"self",
".",
"_pyobihai",
".",
"get_state",
"(",
")",
"if",
"self",
".",
"_service_name",
"in",
"services",
":",
"self",
".",
"_state",
"=",
"services",
".",
"get",
"(",
"self",
".",
"_service_na... | [
140,
4
] | [
156,
64
] | python | en | ['en', 'nl', 'en'] | True |
validate_http | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect over HTTP. | Validate the user input allows us to connect over HTTP. | async def validate_http(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect over HTTP."""
host = data[CONF_HOST]
port = data[CONF_PORT]
username = data.get(CONF_USERNAME)
password = data.get(CONF_PASSWORD)
ssl = data.get(CONF_SSL)
session = async_get_clientsessi... | [
"async",
"def",
"validate_http",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"host",
"=",
"data",
"[",
"CONF_HOST",
"]",
"port",
"=",
"data",
"[",
"CONF_PORT",
"]",
"username",
"=",
"data",
".",
"get",
"(",
"CONF_USERNAME",
"... | [
32,
0
] | [
52,
36
] | python | en | ['en', 'en', 'en'] | True |
validate_ws | (hass: core.HomeAssistant, data) | Validate the user input allows us to connect over WS. | Validate the user input allows us to connect over WS. | async def validate_ws(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect over WS."""
ws_port = data.get(CONF_WS_PORT)
if not ws_port:
return
host = data[CONF_HOST]
port = data[CONF_PORT]
username = data.get(CONF_USERNAME)
password = data.get(CONF_PASSWO... | [
"async",
"def",
"validate_ws",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"data",
")",
":",
"ws_port",
"=",
"data",
".",
"get",
"(",
"CONF_WS_PORT",
")",
"if",
"not",
"ws_port",
":",
"return",
"host",
"=",
"data",
"[",
"CONF_HOST",
"]",
"port... | [
55,
0
] | [
81,
40
] | python | en | ['en', 'en', 'en'] | True |
KodiConfigFlow.__init__ | (self) | Initialize flow. | Initialize flow. | def __init__(self):
"""Initialize flow."""
self._host: Optional[str] = None
self._port: Optional[int] = DEFAULT_PORT
self._ws_port: Optional[int] = DEFAULT_WS_PORT
self._name: Optional[str] = None
self._username: Optional[str] = None
self._password: Optional[str] ... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_host",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
"self",
".",
"_port",
":",
"Optional",
"[",
"int",
"]",
"=",
"DEFAULT_PORT",
"self",
".",
"_ws_port",
":",
"Optional",
"[",
"int",
"]",
"... | [
90,
4
] | [
99,
50
] | python | en | ['en', 'pl', 'en'] | False |
KodiConfigFlow.async_step_zeroconf | (self, discovery_info: DiscoveryInfoType) | Handle zeroconf discovery. | Handle zeroconf discovery. | async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType):
"""Handle zeroconf discovery."""
self._host = discovery_info["host"]
self._port = int(discovery_info["port"])
self._name = discovery_info["hostname"][: -len(".local.")]
uuid = discovery_info["properties"]["uu... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
":",
"DiscoveryInfoType",
")",
":",
"self",
".",
"_host",
"=",
"discovery_info",
"[",
"\"host\"",
"]",
"self",
".",
"_port",
"=",
"int",
"(",
"discovery_info",
"[",
"\"port\"",
"]",
"... | [
101,
4
] | [
134,
56
] | python | de | ['de', 'sr', 'en'] | False |
KodiConfigFlow.async_step_discovery_confirm | (self, user_input=None) | Handle user-confirmation of discovered node. | Handle user-confirmation of discovered node. | async def async_step_discovery_confirm(self, user_input=None):
"""Handle user-confirmation of discovered node."""
if user_input is None:
return self.async_show_form(
step_id="discovery_confirm",
description_placeholders={"name": self._name},
)
... | [
"async",
"def",
"async_step_discovery_confirm",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"discovery_confirm\"",
",",
"description_placeholders",
"... | [
136,
4
] | [
144,
35
] | python | en | ['en', 'en', 'en'] | True |
KodiConfigFlow.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:
self._host = user_input[CONF_HOST]
self._port = user_input[CONF_PORT]
self._ssl = user_input[CONF_SSL]
try:
aw... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"_host",
"=",
"user_input",
"[",
"CONF_HOST",
"]",
"self",
".",
"_port",
"=",
... | [
146,
4
] | [
170,
43
] | python | en | ['en', 'en', 'en'] | True |
KodiConfigFlow.async_step_credentials | (self, user_input=None) | Handle username and password input. | Handle username and password input. | async def async_step_credentials(self, user_input=None):
"""Handle username and password input."""
errors = {}
if user_input is not None:
self._username = user_input.get(CONF_USERNAME)
self._password = user_input.get(CONF_PASSWORD)
try:
await... | [
"async",
"def",
"async_step_credentials",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"_username",
"=",
"user_input",
".",
"get",
"(",
"CONF_USERNAME",
")",
"s... | [
172,
4
] | [
195,
50
] | python | en | ['en', 'en', 'en'] | True |
KodiConfigFlow.async_step_ws_port | (self, user_input=None) | Handle websocket port of discovered node. | Handle websocket port of discovered node. | async def async_step_ws_port(self, user_input=None):
"""Handle websocket port of discovered node."""
errors = {}
if user_input is not None:
self._ws_port = user_input.get(CONF_WS_PORT)
# optional ints return 0 rather than None when empty
if self._ws_port == ... | [
"async",
"def",
"async_step_ws_port",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"self",
".",
"_ws_port",
"=",
"user_input",
".",
"get",
"(",
"CONF_WS_PORT",
")",
"# optio... | [
197,
4
] | [
218,
46
] | python | en | ['en', 'da', 'en'] | True |
KodiConfigFlow.async_step_import | (self, data) | Handle import from YAML. | Handle import from YAML. | async def async_step_import(self, data):
"""Handle import from YAML."""
reason = None
try:
await validate_http(self.hass, data)
await validate_ws(self.hass, data)
except InvalidAuth:
_LOGGER.exception("Invalid Kodi credentials")
reason = "i... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"data",
")",
":",
"reason",
"=",
"None",
"try",
":",
"await",
"validate_http",
"(",
"self",
".",
"hass",
",",
"data",
")",
"await",
"validate_ws",
"(",
"self",
".",
"hass",
",",
"data",
")",
"excep... | [
220,
4
] | [
238,
46
] | python | en | ['en', 'en', 'en'] | True |
fake_zones | () | Fixture for fake zones.
Returns:
list: List of fake zones
| Fixture for fake zones. | def fake_zones():
"""Fixture for fake zones.
Returns:
list: List of fake zones
"""
return [
{"name": "front", "number": 1},
{"name": "back", "number": 2},
{"name": "inside", "number": 3},
] | [
"def",
"fake_zones",
"(",
")",
":",
"return",
"[",
"{",
"\"name\"",
":",
"\"front\"",
",",
"\"number\"",
":",
"1",
"}",
",",
"{",
"\"name\"",
":",
"\"back\"",
",",
"\"number\"",
":",
"2",
"}",
",",
"{",
"\"name\"",
":",
"\"inside\"",
",",
"\"number\"",... | [
16,
0
] | [
26,
5
] | python | en | ['en', 'en', 'en'] | True |
client | (fake_zones) | Fixture for client.
Args:
fake_zones (list): Fixture of fake zones
Yields:
MagicMock: Client Mock
| Fixture for client. | def client(fake_zones):
"""Fixture for client.
Args:
fake_zones (list): Fixture of fake zones
Yields:
MagicMock: Client Mock
"""
with mock.patch.object(nx584_client, "Client") as _mock_client:
client = nx584_client.Client.return_value
client.list_zones.return_value ... | [
"def",
"client",
"(",
"fake_zones",
")",
":",
"with",
"mock",
".",
"patch",
".",
"object",
"(",
"nx584_client",
",",
"\"Client\"",
")",
"as",
"_mock_client",
":",
"client",
"=",
"nx584_client",
".",
"Client",
".",
"return_value",
"client",
".",
"list_zones",... | [
30,
0
] | [
44,
26
] | python | en | ['en', 'fr', 'en'] | True |
test_nx584_sensor_setup_defaults | (mock_nx, mock_watcher, hass, fake_zones) | Test the setup with no configuration. | Test the setup with no configuration. | def test_nx584_sensor_setup_defaults(mock_nx, mock_watcher, hass, fake_zones):
"""Test the setup with no configuration."""
add_entities = mock.MagicMock()
config = {
"host": nx584.DEFAULT_HOST,
"port": nx584.DEFAULT_PORT,
"exclude_zones": [],
"zone_types": {},
}
asser... | [
"def",
"test_nx584_sensor_setup_defaults",
"(",
"mock_nx",
",",
"mock_watcher",
",",
"hass",
",",
"fake_zones",
")",
":",
"add_entities",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"config",
"=",
"{",
"\"host\"",
":",
"nx584",
".",
"DEFAULT_HOST",
",",
"\"port\"... | [
50,
0
] | [
63,
78
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_sensor_setup_full_config | (mock_nx, mock_watcher, hass, fake_zones) | Test the setup with full configuration. | Test the setup with full configuration. | def test_nx584_sensor_setup_full_config(mock_nx, mock_watcher, hass, fake_zones):
"""Test the setup with full configuration."""
config = {
"host": "foo",
"port": 123,
"exclude_zones": [2],
"zone_types": {3: "motion"},
}
add_entities = mock.MagicMock()
assert nx584.set... | [
"def",
"test_nx584_sensor_setup_full_config",
"(",
"mock_nx",
",",
"mock_watcher",
",",
"hass",
",",
"fake_zones",
")",
":",
"config",
"=",
"{",
"\"host\"",
":",
"\"foo\"",
",",
"\"port\"",
":",
"123",
",",
"\"exclude_zones\"",
":",
"[",
"2",
"]",
",",
"\"zo... | [
69,
0
] | [
88,
30
] | python | en | ['en', 'en', 'en'] | True |
_test_assert_graceful_fail | (hass, config) | Test the failing. | Test the failing. | async def _test_assert_graceful_fail(hass, config):
"""Test the failing."""
assert not await async_setup_component(hass, "nx584", config) | [
"async",
"def",
"_test_assert_graceful_fail",
"(",
"hass",
",",
"config",
")",
":",
"assert",
"not",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"nx584\"",
",",
"config",
")"
] | [
91,
0
] | [
93,
65
] | python | en | ['en', 'sm', 'en'] | True |
test_nx584_sensor_setup_bad_config | (hass, config) | Test the setup with bad configuration. | Test the setup with bad configuration. | async def test_nx584_sensor_setup_bad_config(hass, config):
"""Test the setup with bad configuration."""
await _test_assert_graceful_fail(hass, config) | [
"async",
"def",
"test_nx584_sensor_setup_bad_config",
"(",
"hass",
",",
"config",
")",
":",
"await",
"_test_assert_graceful_fail",
"(",
"hass",
",",
"config",
")"
] | [
106,
0
] | [
108,
50
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_sensor_setup_with_exceptions | (hass, exception_type) | Test the setup handles exceptions. | Test the setup handles exceptions. | async def test_nx584_sensor_setup_with_exceptions(hass, exception_type):
"""Test the setup handles exceptions."""
nx584_client.Client.return_value.list_zones.side_effect = exception_type
await _test_assert_graceful_fail(hass, {}) | [
"async",
"def",
"test_nx584_sensor_setup_with_exceptions",
"(",
"hass",
",",
"exception_type",
")",
":",
"nx584_client",
".",
"Client",
".",
"return_value",
".",
"list_zones",
".",
"side_effect",
"=",
"exception_type",
"await",
"_test_assert_graceful_fail",
"(",
"hass",... | [
119,
0
] | [
122,
46
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_sensor_setup_version_too_old | (hass) | Test if version is too old. | Test if version is too old. | async def test_nx584_sensor_setup_version_too_old(hass):
"""Test if version is too old."""
nx584_client.Client.return_value.get_version.return_value = "1.0"
await _test_assert_graceful_fail(hass, {}) | [
"async",
"def",
"test_nx584_sensor_setup_version_too_old",
"(",
"hass",
")",
":",
"nx584_client",
".",
"Client",
".",
"return_value",
".",
"get_version",
".",
"return_value",
"=",
"\"1.0\"",
"await",
"_test_assert_graceful_fail",
"(",
"hass",
",",
"{",
"}",
")"
] | [
126,
0
] | [
129,
46
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_sensor_setup_no_zones | (hass) | Test the setup with no zones. | Test the setup with no zones. | def test_nx584_sensor_setup_no_zones(hass):
"""Test the setup with no zones."""
nx584_client.Client.return_value.list_zones.return_value = []
add_entities = mock.MagicMock()
assert nx584.setup_platform(hass, {}, add_entities)
assert not add_entities.called | [
"def",
"test_nx584_sensor_setup_no_zones",
"(",
"hass",
")",
":",
"nx584_client",
".",
"Client",
".",
"return_value",
".",
"list_zones",
".",
"return_value",
"=",
"[",
"]",
"add_entities",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"assert",
"nx584",
".",
"setup... | [
133,
0
] | [
138,
34
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_zone_sensor_normal | () | Test for the NX584 zone sensor. | Test for the NX584 zone sensor. | def test_nx584_zone_sensor_normal():
"""Test for the NX584 zone sensor."""
zone = {"number": 1, "name": "foo", "state": True}
sensor = nx584.NX584ZoneSensor(zone, "motion")
assert "foo" == sensor.name
assert not sensor.should_poll
assert sensor.is_on
assert sensor.device_state_attributes["zo... | [
"def",
"test_nx584_zone_sensor_normal",
"(",
")",
":",
"zone",
"=",
"{",
"\"number\"",
":",
"1",
",",
"\"name\"",
":",
"\"foo\"",
",",
"\"state\"",
":",
"True",
"}",
"sensor",
"=",
"nx584",
".",
"NX584ZoneSensor",
"(",
"zone",
",",
"\"motion\"",
")",
"asse... | [
141,
0
] | [
151,
27
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_watcher_process_zone_event | (mock_update) | Test the processing of zone events. | Test the processing of zone events. | def test_nx584_watcher_process_zone_event(mock_update):
"""Test the processing of zone events."""
zone1 = {"number": 1, "name": "foo", "state": True}
zone2 = {"number": 2, "name": "bar", "state": True}
zones = {
1: nx584.NX584ZoneSensor(zone1, "motion"),
2: nx584.NX584ZoneSensor(zone2, "... | [
"def",
"test_nx584_watcher_process_zone_event",
"(",
"mock_update",
")",
":",
"zone1",
"=",
"{",
"\"number\"",
":",
"1",
",",
"\"name\"",
":",
"\"foo\"",
",",
"\"state\"",
":",
"True",
"}",
"zone2",
"=",
"{",
"\"number\"",
":",
"2",
",",
"\"name\"",
":",
"... | [
155,
0
] | [
166,
38
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_watcher_process_zone_event_missing_zone | (mock_update) | Test the processing of zone events with missing zones. | Test the processing of zone events with missing zones. | def test_nx584_watcher_process_zone_event_missing_zone(mock_update):
"""Test the processing of zone events with missing zones."""
watcher = nx584.NX584Watcher(None, {})
watcher._process_zone_event({"zone": 1, "zone_state": False})
assert not mock_update.called | [
"def",
"test_nx584_watcher_process_zone_event_missing_zone",
"(",
"mock_update",
")",
":",
"watcher",
"=",
"nx584",
".",
"NX584Watcher",
"(",
"None",
",",
"{",
"}",
")",
"watcher",
".",
"_process_zone_event",
"(",
"{",
"\"zone\"",
":",
"1",
",",
"\"zone_state\"",
... | [
170,
0
] | [
174,
33
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_watcher_run_with_zone_events | () | Test the zone events. | Test the zone events. | def test_nx584_watcher_run_with_zone_events():
"""Test the zone events."""
empty_me = [1, 2]
def fake_get_events():
"""Return nothing twice, then some events."""
if empty_me:
empty_me.pop()
else:
return fake_events
client = mock.MagicMock()
fake_even... | [
"def",
"test_nx584_watcher_run_with_zone_events",
"(",
")",
":",
"empty_me",
"=",
"[",
"1",
",",
"2",
"]",
"def",
"fake_get_events",
"(",
")",
":",
"\"\"\"Return nothing twice, then some events.\"\"\"",
"if",
"empty_me",
":",
"empty_me",
".",
"pop",
"(",
")",
"els... | [
177,
0
] | [
206,
44
] | python | en | ['en', 'en', 'en'] | True |
test_nx584_watcher_run_retries_failures | (mock_sleep) | Test the retries with failures. | Test the retries with failures. | def test_nx584_watcher_run_retries_failures(mock_sleep):
"""Test the retries with failures."""
empty_me = [1, 2]
def fake_run():
"""Fake runner."""
if empty_me:
empty_me.pop()
raise requests.exceptions.ConnectionError()
raise StopMe()
watcher = nx584.NX5... | [
"def",
"test_nx584_watcher_run_retries_failures",
"(",
"mock_sleep",
")",
":",
"empty_me",
"=",
"[",
"1",
",",
"2",
"]",
"def",
"fake_run",
"(",
")",
":",
"\"\"\"Fake runner.\"\"\"",
"if",
"empty_me",
":",
"empty_me",
".",
"pop",
"(",
")",
"raise",
"requests",... | [
210,
0
] | [
227,
63
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.