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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_replace_special | (text) |
Replaces brackets and spaces by similar IRC-representable characters.
|
Replaces brackets and spaces by similar IRC-representable characters.
| def _replace_special(text):
"""
Replaces brackets and spaces by similar IRC-representable characters.
"""
for pair in {('(', '['), (')', ']'), (' ', FALLBACK_CHARACTER), ('<', '['), ('>', ']')}:
text = text.replace(pair[0], pair[1])
return text | [
"def",
"_replace_special",
"(",
"text",
")",
":",
"for",
"pair",
"in",
"{",
"(",
"'('",
",",
"'['",
")",
",",
"(",
"')'",
",",
"']'",
")",
",",
"(",
"' '",
",",
"FALLBACK_CHARACTER",
")",
",",
"(",
"'<'",
",",
"'['",
")",
",",
"(",
"'>'",
",",
... | [
135,
0
] | [
141,
15
] | python | en | ['en', 'error', 'th'] | False |
_sanitize | (text, extrachars='') | Replaces characters not in IRC_ASCII_ALLOWED_CHARS with FALLBACK_CHARACTER. | Replaces characters not in IRC_ASCII_ALLOWED_CHARS with FALLBACK_CHARACTER. | def _sanitize(text, extrachars=''):
"""Replaces characters not in IRC_ASCII_ALLOWED_CHARS with FALLBACK_CHARACTER."""
whitelist = IRC_ASCII_ALLOWED_CHARS + extrachars
for char in text:
if char not in whitelist:
text = text.replace(char, FALLBACK_CHARACTER)
return text | [
"def",
"_sanitize",
"(",
"text",
",",
"extrachars",
"=",
"''",
")",
":",
"whitelist",
"=",
"IRC_ASCII_ALLOWED_CHARS",
"+",
"extrachars",
"for",
"char",
"in",
"text",
":",
"if",
"char",
"not",
"in",
"whitelist",
":",
"text",
"=",
"text",
".",
"replace",
"... | [
143,
0
] | [
149,
15
] | python | en | ['en', 'en', 'en'] | True |
normalize_nick | (irc, netname, nick, times_tagged=0, uid='') |
Creates a normalized nickname for the given nick suitable for introduction to a remote network
(as a relay client).
UID is optional for checking regular nick changes, to make sure that the sender doesn't get
marked as nick-colliding with itself.
|
Creates a normalized nickname for the given nick suitable for introduction to a remote network
(as a relay client). | def normalize_nick(irc, netname, nick, times_tagged=0, uid=''):
"""
Creates a normalized nickname for the given nick suitable for introduction to a remote network
(as a relay client).
UID is optional for checking regular nick changes, to make sure that the sender doesn't get
marked as nick-collidin... | [
"def",
"normalize_nick",
"(",
"irc",
",",
"netname",
",",
"nick",
",",
"times_tagged",
"=",
"0",
",",
"uid",
"=",
"''",
")",
":",
"if",
"irc",
".",
"has_cap",
"(",
"'freeform-nicks'",
")",
":",
"# ☺",
"return",
"nick",
"is_unicode_capable",
"=",
"irc",
... | [
151,
0
] | [
264,
15
] | python | en | ['en', 'error', 'th'] | False |
normalize_host | (irc, host) | Creates a normalized hostname for the given host suitable for
introduction to a remote network (as a relay client). | Creates a normalized hostname for the given host suitable for
introduction to a remote network (as a relay client). | def normalize_host(irc, host):
"""Creates a normalized hostname for the given host suitable for
introduction to a remote network (as a relay client)."""
log.debug('(%s) relay.normalize_host: IRCd=%s, host=%s', irc.name, irc.protoname, host)
allowed_chars = string.ascii_letters + string.digits + '-.:'
... | [
"def",
"normalize_host",
"(",
"irc",
",",
"host",
")",
":",
"log",
".",
"debug",
"(",
"'(%s) relay.normalize_host: IRCd=%s, host=%s'",
",",
"irc",
".",
"name",
",",
"irc",
".",
"protoname",
",",
"host",
")",
"allowed_chars",
"=",
"string",
".",
"ascii_letters"... | [
266,
0
] | [
284,
20
] | python | en | ['en', 'en', 'en'] | True |
get_prefix_modes | (irc, remoteirc, channel, user, mlist=None) |
Fetches all prefix modes for a user in a channel that are supported by the
remote IRC network given.
Optionally, an mlist argument can be given to look at an earlier state of
the channel, e.g. for checking the op status of a mode setter before their
modes are processed and added to the channel sta... |
Fetches all prefix modes for a user in a channel that are supported by the
remote IRC network given. | def get_prefix_modes(irc, remoteirc, channel, user, mlist=None):
"""
Fetches all prefix modes for a user in a channel that are supported by the
remote IRC network given.
Optionally, an mlist argument can be given to look at an earlier state of
the channel, e.g. for checking the op status of a mode ... | [
"def",
"get_prefix_modes",
"(",
"irc",
",",
"remoteirc",
",",
"channel",
",",
"user",
",",
"mlist",
"=",
"None",
")",
":",
"modes",
"=",
"''",
"if",
"channel",
"in",
"irc",
".",
"channels",
"and",
"user",
"in",
"irc",
".",
"channels",
"[",
"channel",
... | [
286,
0
] | [
302,
16
] | python | en | ['en', 'error', 'th'] | False |
spawn_relay_server | (irc, remoteirc) |
Spawns a relay server representing "remoteirc" on "irc".
|
Spawns a relay server representing "remoteirc" on "irc".
| def spawn_relay_server(irc, remoteirc):
"""
Spawns a relay server representing "remoteirc" on "irc".
"""
if irc.connected.is_set():
try:
suffix = irc.serverdata.get('relay_server_suffix', conf.conf.get('relay', {}).get('server_suffix', 'relay'))
# Strip any leading .'s
... | [
"def",
"spawn_relay_server",
"(",
"irc",
",",
"remoteirc",
")",
":",
"if",
"irc",
".",
"connected",
".",
"is_set",
"(",
")",
":",
"try",
":",
"suffix",
"=",
"irc",
".",
"serverdata",
".",
"get",
"(",
"'relay_server_suffix'",
",",
"conf",
".",
"conf",
"... | [
304,
0
] | [
347,
60
] | python | en | ['en', 'error', 'th'] | False |
get_relay_server_sid | (irc, remoteirc, spawn_if_missing=True) |
Fetches the relay server SID representing remoteirc on irc, spawning
a new server if it doesn't exist and spawn_if_missing is enabled.
|
Fetches the relay server SID representing remoteirc on irc, spawning
a new server if it doesn't exist and spawn_if_missing is enabled.
| def get_relay_server_sid(irc, remoteirc, spawn_if_missing=True):
"""
Fetches the relay server SID representing remoteirc on irc, spawning
a new server if it doesn't exist and spawn_if_missing is enabled.
"""
log.debug('(%s) Grabbing spawnlocks_servers[%s] from thread %r in function %r', irc.name, i... | [
"def",
"get_relay_server_sid",
"(",
"irc",
",",
"remoteirc",
",",
"spawn_if_missing",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"'(%s) Grabbing spawnlocks_servers[%s] from thread %r in function %r'",
",",
"irc",
".",
"name",
",",
"irc",
".",
"name",
",",
"t... | [
349,
0
] | [
374,
18
] | python | en | ['en', 'error', 'th'] | False |
_has_common_pool | (sourcenet, targetnet, namespace) |
Returns the source network and target networks are in a pool under the given namespace
(e.g. "ip_share_pools").
|
Returns the source network and target networks are in a pool under the given namespace
(e.g. "ip_share_pools").
| def _has_common_pool(sourcenet, targetnet, namespace):
"""
Returns the source network and target networks are in a pool under the given namespace
(e.g. "ip_share_pools").
"""
if 'relay' not in conf.conf:
return False
for pool in (conf.conf['relay'].get(namespace) or []):
if sour... | [
"def",
"_has_common_pool",
"(",
"sourcenet",
",",
"targetnet",
",",
"namespace",
")",
":",
"if",
"'relay'",
"not",
"in",
"conf",
".",
"conf",
":",
"return",
"False",
"for",
"pool",
"in",
"(",
"conf",
".",
"conf",
"[",
"'relay'",
"]",
".",
"get",
"(",
... | [
376,
0
] | [
389,
16
] | python | en | ['en', 'error', 'th'] | False |
spawn_relay_user | (irc, remoteirc, user, times_tagged=0, reuse_sid=None) |
Spawns a relay user representing "user" from "irc" (the local network) on remoteirc (the target network).
|
Spawns a relay user representing "user" from "irc" (the local network) on remoteirc (the target network).
| def spawn_relay_user(irc, remoteirc, user, times_tagged=0, reuse_sid=None):
"""
Spawns a relay user representing "user" from "irc" (the local network) on remoteirc (the target network).
"""
userobj = irc.users.get(user)
if userobj is None:
# The query wasn't actually a valid user, or the net... | [
"def",
"spawn_relay_user",
"(",
"irc",
",",
"remoteirc",
",",
"user",
",",
"times_tagged",
"=",
"0",
",",
"reuse_sid",
"=",
"None",
")",
":",
"userobj",
"=",
"irc",
".",
"users",
".",
"get",
"(",
"user",
")",
"if",
"userobj",
"is",
"None",
":",
"# Th... | [
391,
0
] | [
479,
12
] | python | en | ['en', 'error', 'th'] | False |
get_remote_user | (irc, remoteirc, user, spawn_if_missing=True, times_tagged=0, reuse_sid=None) |
Fetches and returns the relay client UID representing "user" on the remote network "remoteirc",
spawning a new user if one doesn't exist and spawn_if_missing is True.
|
Fetches and returns the relay client UID representing "user" on the remote network "remoteirc",
spawning a new user if one doesn't exist and spawn_if_missing is True.
| def get_remote_user(irc, remoteirc, user, spawn_if_missing=True, times_tagged=0, reuse_sid=None):
"""
Fetches and returns the relay client UID representing "user" on the remote network "remoteirc",
spawning a new user if one doesn't exist and spawn_if_missing is True.
"""
# Wait until the network i... | [
"def",
"get_remote_user",
"(",
"irc",
",",
"remoteirc",
",",
"user",
",",
"spawn_if_missing",
"=",
"True",
",",
"times_tagged",
"=",
"0",
",",
"reuse_sid",
"=",
"None",
")",
":",
"# Wait until the network is working before trying to spawn anything.",
"if",
"irc",
".... | [
481,
0
] | [
522,
60
] | python | en | ['en', 'error', 'th'] | False |
get_orig_user | (irc, user, targetirc=None) |
Given the UID of a relay client, returns a tuple of the home network name
and original UID of the user it was spawned for.
If targetirc is given, get_remote_user() is called to get the relay client
representing the original user on that target network. |
Given the UID of a relay client, returns a tuple of the home network name
and original UID of the user it was spawned for. | def get_orig_user(irc, user, targetirc=None):
"""
Given the UID of a relay client, returns a tuple of the home network name
and original UID of the user it was spawned for.
If targetirc is given, get_remote_user() is called to get the relay client
representing the original user on that target netwo... | [
"def",
"get_orig_user",
"(",
"irc",
",",
"user",
",",
"targetirc",
"=",
"None",
")",
":",
"try",
":",
"remoteuser",
"=",
"irc",
".",
"users",
"[",
"user",
"]",
".",
"remote",
"except",
"(",
"AttributeError",
",",
"KeyError",
")",
":",
"remoteuser",
"="... | [
524,
0
] | [
556,
29
] | python | en | ['en', 'error', 'th'] | False |
get_relay | (irc, channel) | Finds the matching relay entry name for the given network, channel
pair, if one exists. | Finds the matching relay entry name for the given network, channel
pair, if one exists. | def get_relay(irc, channel):
"""Finds the matching relay entry name for the given network, channel
pair, if one exists."""
chanpair = (irc.name, irc.to_lower(str(channel)))
if chanpair in db: # This chanpair is a shared channel; others link to it
return chanpair
# This chanpair is linked ... | [
"def",
"get_relay",
"(",
"irc",
",",
"channel",
")",
":",
"chanpair",
"=",
"(",
"irc",
".",
"name",
",",
"irc",
".",
"to_lower",
"(",
"str",
"(",
"channel",
")",
")",
")",
"if",
"chanpair",
"in",
"db",
":",
"# This chanpair is a shared channel; others link... | [
558,
0
] | [
569,
23
] | python | en | ['en', 'en', 'en'] | True |
get_remote_channel | (irc, remoteirc, channel) | Returns the linked channel name for the given channel on remoteirc,
if one exists. | Returns the linked channel name for the given channel on remoteirc,
if one exists. | def get_remote_channel(irc, remoteirc, channel):
"""Returns the linked channel name for the given channel on remoteirc,
if one exists."""
remotenetname = remoteirc.name
chanpair = get_relay(irc, channel)
if chanpair is None:
return
if chanpair[0] == remotenetname:
return chanpai... | [
"def",
"get_remote_channel",
"(",
"irc",
",",
"remoteirc",
",",
"channel",
")",
":",
"remotenetname",
"=",
"remoteirc",
".",
"name",
"chanpair",
"=",
"get_relay",
"(",
"irc",
",",
"channel",
")",
"if",
"chanpair",
"is",
"None",
":",
"return",
"if",
"chanpa... | [
571,
0
] | [
584,
30
] | python | en | ['en', 'en', 'en'] | True |
initialize_channel | (irc, channel) | Initializes a relay channel (merge local/remote users, set modes, etc.). | Initializes a relay channel (merge local/remote users, set modes, etc.). | def initialize_channel(irc, channel):
"""Initializes a relay channel (merge local/remote users, set modes, etc.)."""
# We're initializing a relay that already exists. This can be done at
# ENDBURST, or on the LINK command.
relay = get_relay(irc, channel)
log.debug('(%s) relay.initialize_channel be... | [
"def",
"initialize_channel",
"(",
"irc",
",",
"channel",
")",
":",
"# We're initializing a relay that already exists. This can be done at",
"# ENDBURST, or on the LINK command.",
"relay",
"=",
"get_relay",
"(",
"irc",
",",
"channel",
")",
"log",
".",
"debug",
"(",
"'(%s) ... | [
586,
0
] | [
633,
82
] | python | en | ['en', 'en', 'en'] | True |
remove_channel | (irc, channel) | Destroys a relay channel by parting all of its users. | Destroys a relay channel by parting all of its users. | def remove_channel(irc, channel):
"""Destroys a relay channel by parting all of its users."""
if irc is None:
return
try:
world.services['pylink'].remove_persistent_channel(irc, 'relay', channel, part_reason=CHANNEL_DELINKED_MSG)
except KeyError:
log.warning('(%s) relay: failed ... | [
"def",
"remove_channel",
"(",
"irc",
",",
"channel",
")",
":",
"if",
"irc",
"is",
"None",
":",
"return",
"try",
":",
"world",
".",
"services",
"[",
"'pylink'",
"]",
".",
"remove_persistent_channel",
"(",
"irc",
",",
"'relay'",
",",
"channel",
",",
"part_... | [
635,
0
] | [
667,
67
] | python | en | ['en', 'en', 'en'] | True |
_claim_should_bounce | (irc, channel) |
Returns whether we should bounce the next action that fails CLAIM.
This is used to prevent kick/mode/topic wars with services.
|
Returns whether we should bounce the next action that fails CLAIM.
This is used to prevent kick/mode/topic wars with services.
| def _claim_should_bounce(irc, channel):
"""
Returns whether we should bounce the next action that fails CLAIM.
This is used to prevent kick/mode/topic wars with services.
"""
with claim_bounce_cache_lock:
if irc.name not in claim_bounce_cache: # Nothing in the cache to worry about
... | [
"def",
"_claim_should_bounce",
"(",
"irc",
",",
"channel",
")",
":",
"with",
"claim_bounce_cache_lock",
":",
"if",
"irc",
".",
"name",
"not",
"in",
"claim_bounce_cache",
":",
"# Nothing in the cache to worry about",
"return",
"True",
"limit",
"=",
"irc",
".",
"get... | [
669,
0
] | [
690,
22
] | python | en | ['en', 'error', 'th'] | False |
check_claim | (irc, channel, sender, chanobj=None) |
Checks whether the sender of a kick/mode/topic change passes CLAIM checks for
a given channel. This returns True if any of the following criteria are met:
1) No relay exists for the channel in question.
2) The originating network is the one that created the relay.
3) The CLAIM list for the relay i... |
Checks whether the sender of a kick/mode/topic change passes CLAIM checks for
a given channel. This returns True if any of the following criteria are met: | def check_claim(irc, channel, sender, chanobj=None):
"""
Checks whether the sender of a kick/mode/topic change passes CLAIM checks for
a given channel. This returns True if any of the following criteria are met:
1) No relay exists for the channel in question.
2) The originating network is the one t... | [
"def",
"check_claim",
"(",
"irc",
",",
"channel",
",",
"sender",
",",
"chanobj",
"=",
"None",
")",
":",
"relay",
"=",
"get_relay",
"(",
"irc",
",",
"channel",
")",
"try",
":",
"mlist",
"=",
"chanobj",
".",
"prefixmodes",
"except",
"AttributeError",
":",
... | [
692,
0
] | [
730,
18
] | python | en | ['en', 'error', 'th'] | False |
get_supported_umodes | (irc, remoteirc, modes) | Given a list of user modes, filters out all of those not supported by the
remote network. | Given a list of user modes, filters out all of those not supported by the
remote network. | def get_supported_umodes(irc, remoteirc, modes):
"""Given a list of user modes, filters out all of those not supported by the
remote network."""
supported_modes = []
# Iterate over all mode pairs.
for modepair in modes:
try:
# Get the prefix and the actual mode character (the pr... | [
"def",
"get_supported_umodes",
"(",
"irc",
",",
"remoteirc",
",",
"modes",
")",
":",
"supported_modes",
"=",
"[",
"]",
"# Iterate over all mode pairs.",
"for",
"modepair",
"in",
"modes",
":",
"try",
":",
"# Get the prefix and the actual mode character (the prefix being + ... | [
732,
0
] | [
779,
26
] | python | en | ['en', 'en', 'en'] | True |
is_relay_client | (irc, user) | Returns whether the given user is a relay client. | Returns whether the given user is a relay client. | def is_relay_client(irc, user):
"""Returns whether the given user is a relay client."""
return user in irc.users and hasattr(irc.users[user], 'remote') | [
"def",
"is_relay_client",
"(",
"irc",
",",
"user",
")",
":",
"return",
"user",
"in",
"irc",
".",
"users",
"and",
"hasattr",
"(",
"irc",
".",
"users",
"[",
"user",
"]",
",",
"'remote'",
")"
] | [
781,
0
] | [
783,
67
] | python | en | ['en', 'en', 'en'] | True |
iterate_all | (origirc, func, extra_args=(), kwargs=None) |
Runs the given function 'func' on all connected networks. 'func' must take at least two arguments: the original network object and the remote network object.
|
Runs the given function 'func' on all connected networks. 'func' must take at least two arguments: the original network object and the remote network object.
| def iterate_all(origirc, func, extra_args=(), kwargs=None):
"""
Runs the given function 'func' on all connected networks. 'func' must take at least two arguments: the original network object and the remote network object.
"""
if kwargs is None:
kwargs = {}
for name, remoteirc in world.netwo... | [
"def",
"iterate_all",
"(",
"origirc",
",",
"func",
",",
"extra_args",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
")",
":",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"for",
"name",
",",
"remoteirc",
"in",
"world",
".",
"networkobject... | [
786,
0
] | [
798,
55
] | python | en | ['en', 'error', 'th'] | False |
iterate_all_present | (origirc, origuser, func, extra_args=(), kwargs=None) |
Runs the given function 'func' on all networks where the UID 'origuser'
from 'origirc' has a relay client.
'func' must take at least three arguments: the original network object,
the remote network object, and the UID on the remote network to work on.
|
Runs the given function 'func' on all networks where the UID 'origuser'
from 'origirc' has a relay client. | def iterate_all_present(origirc, origuser, func, extra_args=(), kwargs=None):
"""
Runs the given function 'func' on all networks where the UID 'origuser'
from 'origirc' has a relay client.
'func' must take at least three arguments: the original network object,
the remote network object, and the UID... | [
"def",
"iterate_all_present",
"(",
"origirc",
",",
"origuser",
",",
"func",
",",
"extra_args",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
")",
":",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"for",
"netname",
",",
"user",
"in",
"rela... | [
800,
0
] | [
813,
61
] | python | en | ['en', 'error', 'th'] | False |
relay_joins | (irc, channel, users, ts, targetirc=None, **kwargs) |
Relays one or more users' joins from a channel to its relay links. If targetirc is given, only burst
to that specific network.
|
Relays one or more users' joins from a channel to its relay links. If targetirc is given, only burst
to that specific network.
| def relay_joins(irc, channel, users, ts, targetirc=None, **kwargs):
"""
Relays one or more users' joins from a channel to its relay links. If targetirc is given, only burst
to that specific network.
"""
log.debug('(%s) relay.relay_joins: called on %r with users %r, targetirc=%s', irc.name, channel,... | [
"def",
"relay_joins",
"(",
"irc",
",",
"channel",
",",
"users",
",",
"ts",
",",
"targetirc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'(%s) relay.relay_joins: called on %r with users %r, targetirc=%s'",
",",
"irc",
".",
"name"... | [
817,
0
] | [
945,
91
] | python | en | ['en', 'error', 'th'] | False |
relay_part | (irc, *args, **kwargs) |
Relays a user part from a channel to its relay links, as part of a channel delink.
|
Relays a user part from a channel to its relay links, as part of a channel delink.
| def relay_part(irc, *args, **kwargs):
"""
Relays a user part from a channel to its relay links, as part of a channel delink.
"""
def _relay_part_loop(irc, remoteirc, channel, user):
remotechan = get_remote_channel(irc, remoteirc, channel)
log.debug('(%s) relay.relay_part: looking for %s/... | [
"def",
"relay_part",
"(",
"irc",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_relay_part_loop",
"(",
"irc",
",",
"remoteirc",
",",
"channel",
",",
"user",
")",
":",
"remotechan",
"=",
"get_remote_channel",
"(",
"irc",
",",
"remoteirc",
... | [
947,
0
] | [
980,
70
] | python | en | ['en', 'error', 'th'] | False |
get_supported_cmodes | (irc, remoteirc, channel, modes) |
Filters a channel mode change to the modes supported by the target IRCd.
|
Filters a channel mode change to the modes supported by the target IRCd.
| def get_supported_cmodes(irc, remoteirc, channel, modes):
"""
Filters a channel mode change to the modes supported by the target IRCd.
"""
remotechan = get_remote_channel(irc, remoteirc, channel)
if not remotechan: # Not a relay channel
return []
# Handle Clientbot-specific mode whitel... | [
"def",
"get_supported_cmodes",
"(",
"irc",
",",
"remoteirc",
",",
"channel",
",",
"modes",
")",
":",
"remotechan",
"=",
"get_remote_channel",
"(",
"irc",
",",
"remoteirc",
",",
"channel",
")",
"if",
"not",
"remotechan",
":",
"# Not a relay channel",
"return",
... | [
1050,
0
] | [
1264,
26
] | python | en | ['en', 'error', 'th'] | False |
handle_relay_whois | (irc, source, command, args) |
WHOIS handler for the relay plugin.
|
WHOIS handler for the relay plugin.
| def handle_relay_whois(irc, source, command, args):
"""
WHOIS handler for the relay plugin.
"""
target = args['target']
server = args['server']
targetuser = irc.users[target]
def wreply(num, text):
"""Convenience wrapper to return WHOIS replies."""
# WHOIS replies are by con... | [
"def",
"handle_relay_whois",
"(",
"irc",
",",
"source",
",",
"command",
",",
"args",
")",
":",
"target",
"=",
"args",
"[",
"'target'",
"]",
"server",
"=",
"args",
"[",
"'server'",
"]",
"targetuser",
"=",
"irc",
".",
"users",
"[",
"target",
"]",
"def",
... | [
1268,
0
] | [
1312,
70
] | python | en | ['en', 'error', 'th'] | False |
handle_operup | (irc, numeric, command, args) |
Handles setting oper types on relay clients during oper up.
|
Handles setting oper types on relay clients during oper up.
| def handle_operup(irc, numeric, command, args):
"""
Handles setting oper types on relay clients during oper up.
"""
newtype = '%s (on %s)' % (args['text'], irc.get_full_network_name())
def _handle_operup_func(irc, remoteirc, user):
log.debug('(%s) relay.handle_opertype: setting OPERTYPE of ... | [
"def",
"handle_operup",
"(",
"irc",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"newtype",
"=",
"'%s (on %s)'",
"%",
"(",
"args",
"[",
"'text'",
"]",
",",
"irc",
".",
"get_full_network_name",
"(",
")",
")",
"def",
"_handle_operup_func",
"(",
"... | [
1316,
0
] | [
1327,
58
] | python | en | ['en', 'error', 'th'] | False |
handle_squit | (irc, numeric, command, args) |
Handles SQUITs over relay.
|
Handles SQUITs over relay.
| def handle_squit(irc, numeric, command, args):
"""
Handles SQUITs over relay.
"""
users = args['users']
target = args['target']
# Someone /SQUIT one of our relay subservers. Bad! Rejoin them!
if target in relayservers[irc.name].values():
sname = args['name']
remotenet = snam... | [
"def",
"handle_squit",
"(",
"irc",
",",
"numeric",
",",
"command",
",",
"args",
")",
":",
"users",
"=",
"args",
"[",
"'users'",
"]",
"target",
"=",
"args",
"[",
"'target'",
"]",
"# Someone /SQUIT one of our relay subservers. Bad! Rejoin them!",
"if",
"target",
"... | [
1405,
0
] | [
1445,
59
] | python | en | ['en', 'error', 'th'] | False |
add_switch_entities | (new_unique_ids, coordinator, add_entities) | Add switch entities to the platform.
Args:
new_unique_ids (set): Unique identifiers of entities to be added to Home Assistant.
coordinator (DataUpdateCoordinator): Data coordinator of this platform.
add_entities (function): Method called to add entities to Home Assistant.
| Add switch entities to the platform. | def add_switch_entities(new_unique_ids, coordinator, add_entities):
"""Add switch entities to the platform.
Args:
new_unique_ids (set): Unique identifiers of entities to be added to Home Assistant.
coordinator (DataUpdateCoordinator): Data coordinator of this platform.
add_entities (fun... | [
"def",
"add_switch_entities",
"(",
"new_unique_ids",
",",
"coordinator",
",",
"add_entities",
")",
":",
"new_entities",
"=",
"[",
"]",
"for",
"uid",
"in",
"new_unique_ids",
":",
"new_ent",
"=",
"HomeControlSwitchEntity",
"(",
"coordinator",
",",
"uid",
")",
"new... | [
16,
0
] | [
28,
30
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Legrand Home+ Control Switch platform in HomeAssistant.
Args:
hass (HomeAssistant): HomeAssistant core object.
config_entry (ConfigEntry): ConfigEntry object that configures this platform.
async_add_entities (function): Function called to add entities of this platform.
| Set up the Legrand Home+ Control Switch platform in HomeAssistant. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Legrand Home+ Control Switch platform in HomeAssistant.
Args:
hass (HomeAssistant): HomeAssistant core object.
config_entry (ConfigEntry): ConfigEntry object that configures this platform.
async_add_entit... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"partial_add_switch_entities",
"=",
"partial",
"(",
"add_switch_entities",
",",
"add_entities",
"=",
"async_add_entities",
")",
"# Connect the dispatcher for the swit... | [
31,
0
] | [
47,
5
] | python | en | ['en', 'en', 'en'] | True |
HomeControlSwitchEntity.__init__ | (self, coordinator, idx) | Pass coordinator to CoordinatorEntity. | Pass coordinator to CoordinatorEntity. | def __init__(self, coordinator, idx):
"""Pass coordinator to CoordinatorEntity."""
super().__init__(coordinator)
self.idx = idx
self.module = self.coordinator.data[self.idx] | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"idx",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"idx",
"=",
"idx",
"self",
".",
"module",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
... | [
64,
4
] | [
68,
53
] | python | en | ['en', 'ky', 'en'] | True |
HomeControlSwitchEntity.name | (self) | Name of the device. | Name of the device. | def name(self):
"""Name of the device."""
return self.module.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"module",
".",
"name"
] | [
71,
4
] | [
73,
31
] | python | en | ['en', 'en', 'en'] | True |
HomeControlSwitchEntity.unique_id | (self) | ID (unique) of the device. | ID (unique) of the device. | def unique_id(self):
"""ID (unique) of the device."""
return self.idx | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"idx"
] | [
76,
4
] | [
78,
23
] | python | en | ['en', 'en', 'en'] | True |
HomeControlSwitchEntity.device_info | (self) | Device information. | Device information. | def device_info(self):
"""Device information."""
return {
"identifiers": {
# Unique identifiers within the domain
(DOMAIN, self.unique_id)
},
"name": self.name,
"manufacturer": "Legrand",
"model": HW_TYPE.get(sel... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"# Unique identifiers within the domain",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
... | [
81,
4
] | [
92,
9
] | python | en | ['en', 'en', 'en'] | False |
HomeControlSwitchEntity.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
if self.module.device == "plug":
return DEVICE_CLASS_OUTLET
return DEVICE_CLASS_SWITCH | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"module",
".",
"device",
"==",
"\"plug\"",
":",
"return",
"DEVICE_CLASS_OUTLET",
"return",
"DEVICE_CLASS_SWITCH"
] | [
95,
4
] | [
99,
34
] | python | en | ['en', 'en', 'en'] | True |
HomeControlSwitchEntity.available | (self) | Return if entity is available.
This is the case when the coordinator is able to update the data successfully
AND the switch entity is reachable.
This method overrides the one of the CoordinatorEntity
| Return if entity is available. | def available(self) -> bool:
"""Return if entity is available.
This is the case when the coordinator is able to update the data successfully
AND the switch entity is reachable.
This method overrides the one of the CoordinatorEntity
"""
return self.coordinator.last_updat... | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"self",
".",
"module",
".",
"reachable"
] | [
102,
4
] | [
110,
77
] | python | en | ['en', 'en', 'en'] | True |
HomeControlSwitchEntity.is_on | (self) | Return entity state. | Return entity state. | def is_on(self):
"""Return entity state."""
return self.module.status == "on" | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"module",
".",
"status",
"==",
"\"on\""
] | [
113,
4
] | [
115,
41
] | python | en | ['en', 'cy', 'en'] | True |
HomeControlSwitchEntity.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs):
"""Turn the light on."""
# Do the turning on.
await self.module.turn_on()
# Update the data
await self.coordinator.async_request_refresh() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Do the turning on.",
"await",
"self",
".",
"module",
".",
"turn_on",
"(",
")",
"# Update the data",
"await",
"self",
".",
"coordinator",
".",
"async_request_refresh",
"(",
")"
... | [
117,
4
] | [
122,
54
] | python | en | ['en', 'et', 'en'] | True |
HomeControlSwitchEntity.async_turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
await self.module.turn_off()
# Update the data
await self.coordinator.async_request_refresh() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"module",
".",
"turn_off",
"(",
")",
"# Update the data",
"await",
"self",
".",
"coordinator",
".",
"async_request_refresh",
"(",
")"
] | [
124,
4
] | [
128,
54
] | python | en | ['en', 'en', 'en'] | True |
TestConfiguration.test_configuration | (self) | Test configuration
Test host settings # noqa: E501
| Test configuration | def test_configuration(self):
"""Test configuration
Test host settings # noqa: E501
"""
host_settings = self.config.get_host_settings()
self.assertEqual('http://{server}.swagger.io:{port}/v2', host_settings[0]['url'])
self.assertEqual('petstore', host_settings[0]['varia... | [
"def",
"test_configuration",
"(",
"self",
")",
":",
"host_settings",
"=",
"self",
".",
"config",
".",
"get_host_settings",
"(",
")",
"self",
".",
"assertEqual",
"(",
"'http://{server}.swagger.io:{port}/v2'",
",",
"host_settings",
"[",
"0",
"]",
"[",
"'url'",
"]"... | [
30,
4
] | [
41,
89
] | python | en | ['en', 'fr', 'en'] | False |
TestConfiguration.test_get_host_from_settings | (self) | Test get_host_from_settings
Test get URL from host settings
| Test get_host_from_settings | def test_get_host_from_settings(self):
""" Test get_host_from_settings
Test get URL from host settings
"""
self.assertEqual("http://petstore.swagger.io:80/v2", self.config.get_host_from_settings(0))
self.assertEqual("http://petstore.swagger.io:8080/v2", self.config.get_host_from... | [
"def",
"test_get_host_from_settings",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"\"http://petstore.swagger.io:80/v2\"",
",",
"self",
".",
"config",
".",
"get_host_from_settings",
"(",
"0",
")",
")",
"self",
".",
"assertEqual",
"(",
"\"http://petstore.s... | [
43,
4
] | [
50,
149
] | python | en | ['en', 'en', 'en'] | False |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Plugwise components from a config entry. | Set up Plugwise components from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Plugwise components from a config entry."""
if entry.data.get(CONF_HOST):
return await async_setup_entry_gw(hass, entry)
# PLACEHOLDER USB entry setup
return False | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"if",
"entry",
".",
"data",
".",
"get",
"(",
"CONF_HOST",
")",
":",
"return",
"await",
"async_setup_entry_gw",
"(",
"hass",
",... | [
9,
0
] | [
14,
16
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload the Plugwise components. | Unload the Plugwise components. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload the Plugwise components."""
if entry.data.get(CONF_HOST):
return await async_unload_entry_gw(hass, entry)
# PLACEHOLDER USB entry setup
return False | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"if",
"entry",
".",
"data",
".",
"get",
"(",
"CONF_HOST",
")",
":",
"return",
"await",
"async_unload_entry_gw",
"(",
"hass",
",",
"entry",
... | [
17,
0
] | [
22,
16
] | python | en | ['en', 'en', 'en'] | True |
fake_pass | (*_unused, **_unused2) | Do nothing. | Do nothing. | def fake_pass(*_unused, **_unused2):
"""Do nothing."""
pass | [
"def",
"fake_pass",
"(",
"*",
"_unused",
",",
"*",
"*",
"_unused2",
")",
":",
"pass"
] | [
29,
0
] | [
31,
8
] | python | en | ['en', 'zu', 'en'] | False |
fake_bomb | (*a, **kw) | Always raise. | Always raise. | def fake_bomb(*a, **kw):
"""Always raise."""
raise AssertionError('Should not happen', a, kw) | [
"def",
"fake_bomb",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"raise",
"AssertionError",
"(",
"'Should not happen'",
",",
"a",
",",
"kw",
")"
] | [
33,
0
] | [
35,
52
] | python | fi | ['fi', 'fi', 'en'] | False |
ScenarioTest.fake_check | (self, *cmd) | Log the command. | Log the command. | def fake_check(self, *cmd):
"""Log the command."""
self.callstack.append(string.join(cmd)) | [
"def",
"fake_check",
"(",
"self",
",",
"*",
"cmd",
")",
":",
"self",
".",
"callstack",
".",
"append",
"(",
"string",
".",
"join",
"(",
"cmd",
")",
")"
] | [
73,
4
] | [
75,
47
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.fake_sha | (key, default) | fake base and pull sha. | fake base and pull sha. | def fake_sha(key, default):
"""fake base and pull sha."""
if key == 'PULL_BASE_SHA':
return '12345'
if key == 'PULL_PULL_SHA':
return '67890'
return os.getenv(key, default) | [
"def",
"fake_sha",
"(",
"key",
",",
"default",
")",
":",
"if",
"key",
"==",
"'PULL_BASE_SHA'",
":",
"return",
"'12345'",
"if",
"key",
"==",
"'PULL_PULL_SHA'",
":",
"return",
"'67890'",
"return",
"os",
".",
"getenv",
"(",
"key",
",",
"default",
")"
] | [
78,
4
] | [
84,
38
] | python | en | ['en', 'fil', 'en'] | True |
ScenarioTest.fake_version | () | return a fake version | return a fake version | def fake_version():
"""return a fake version"""
return 'v1.0+abcde' | [
"def",
"fake_version",
"(",
")",
":",
"return",
"'v1.0+abcde'"
] | [
87,
4
] | [
89,
27
] | python | en | ['en', 'hi-Latn', 'en'] | True |
ScenarioTest.fake_query | (_self, _kind, selected, changed) | Simple filter selected by changed. | Simple filter selected by changed. | def fake_query(_self, _kind, selected, changed):
"""Simple filter selected by changed."""
if changed == []:
return changed
if not changed:
return selected
if not selected:
return changed
ret = []
for pkg in selected:
if pkg... | [
"def",
"fake_query",
"(",
"_self",
",",
"_kind",
",",
"selected",
",",
"changed",
")",
":",
"if",
"changed",
"==",
"[",
"]",
":",
"return",
"changed",
"if",
"not",
"changed",
":",
"return",
"selected",
"if",
"not",
"selected",
":",
"return",
"changed",
... | [
92,
4
] | [
106,
18
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.fake_changed_valid | (_base, _pull) | Return fake affected targets. | Return fake affected targets. | def fake_changed_valid(_base, _pull):
"""Return fake affected targets."""
return ['//foo', '//bar'] | [
"def",
"fake_changed_valid",
"(",
"_base",
",",
"_pull",
")",
":",
"return",
"[",
"'//foo'",
",",
"'//bar'",
"]"
] | [
109,
4
] | [
111,
33
] | python | en | ['en', 'da', 'en'] | True |
ScenarioTest.fake_changed_empty | (_base, _pull) | Return fake affected targets. | Return fake affected targets. | def fake_changed_empty(_base, _pull):
"""Return fake affected targets."""
return [] | [
"def",
"fake_changed_empty",
"(",
"_base",
",",
"_pull",
")",
":",
"return",
"[",
"]"
] | [
114,
4
] | [
116,
17
] | python | en | ['en', 'da', 'en'] | True |
ScenarioTest.fake_clean | (_dirname, _filename) | Don't clean | Don't clean | def fake_clean(_dirname, _filename):
"""Don't clean"""
pass | [
"def",
"fake_clean",
"(",
"_dirname",
",",
"_filename",
")",
":",
"pass"
] | [
119,
4
] | [
121,
12
] | python | en | ['en', 'en', 'en'] | False |
ScenarioTest.test_expand | (self) | Make sure flags are expanded properly. | Make sure flags are expanded properly. | def test_expand(self):
"""Make sure flags are expanded properly."""
args = kubernetes_bazel.parse_args([
'--build=//b/... -//b/bb/... //c/...'
])
kubernetes_bazel.main(args)
call = self.callstack[-2]
self.assertIn('//b/...', call)
self.assertIn('-... | [
"def",
"test_expand",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--build=//b/... -//b/bb/... //c/...'",
"]",
")",
"kubernetes_bazel",
".",
"main",
"(",
"args",
")",
"call",
"=",
"self",
".",
"callstack",
"[",
"-",
... | [
123,
4
] | [
133,
38
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_query | (self) | Make sure query is constructed properly. | Make sure query is constructed properly. | def test_query(self):
"""Make sure query is constructed properly."""
args = kubernetes_bazel.parse_args([
'--build=//b/... -//b/bb/... //c/...'
])
# temporarily un-stub query
with Stub(kubernetes_bazel.Bazel, 'query', self.boiler['query'].old):
def che... | [
"def",
"test_query",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--build=//b/... -//b/bb/... //c/...'",
"]",
")",
"# temporarily un-stub query",
"with",
"Stub",
"(",
"kubernetes_bazel",
".",
"Bazel",
",",
"'query'",
",",
... | [
136,
4
] | [
151,
43
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_expand_arg | (self) | Make sure flags are expanded properly. | Make sure flags are expanded properly. | def test_expand_arg(self):
"""Make sure flags are expanded properly."""
args = kubernetes_bazel.parse_args([
'--test-args=--foo',
'--test-args=--bar',
'--test=//b/... //c/...'
])
kubernetes_bazel.main(args)
call = self.callstack[-2]
... | [
"def",
"test_expand_arg",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--test-args=--foo'",
",",
"'--test-args=--bar'",
",",
"'--test=//b/... //c/...'",
"]",
")",
"kubernetes_bazel",
".",
"main",
"(",
"args",
")",
"call",
... | [
153,
4
] | [
166,
38
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_all_bazel | (self) | Make sure all commands starts with bazel except for coarse. | Make sure all commands starts with bazel except for coarse. | def test_all_bazel(self):
"""Make sure all commands starts with bazel except for coarse."""
args = kubernetes_bazel.parse_args([
'--build=//a',
'--test=//b',
'--release=//c'
])
kubernetes_bazel.main(args)
for call in self.callstack[:-2]:
... | [
"def",
"test_all_bazel",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--build=//a'",
",",
"'--test=//b'",
",",
"'--release=//c'",
"]",
")",
"kubernetes_bazel",
".",
"main",
"(",
"args",
")",
"for",
"call",
"in",
"sel... | [
168,
4
] | [
178,
59
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_install | (self) | Make sure install is called as 1st scenario call. | Make sure install is called as 1st scenario call. | def test_install(self):
"""Make sure install is called as 1st scenario call."""
with tempfile.NamedTemporaryFile(delete=False) as fp:
install = fp.name
args = kubernetes_bazel.parse_args([
'--install=%s' % install,
])
kubernetes_bazel.main(args)
... | [
"def",
"test_install",
"(",
"self",
")",
":",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
"as",
"fp",
":",
"install",
"=",
"fp",
".",
"name",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--install=%s'... | [
180,
4
] | [
189,
49
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_install_fail | (self) | Make sure install fails if path does not exist. | Make sure install fails if path does not exist. | def test_install_fail(self):
"""Make sure install fails if path does not exist."""
args = kubernetes_bazel.parse_args([
'--install=foo',
])
with self.assertRaises(ValueError):
kubernetes_bazel.main(args) | [
"def",
"test_install_fail",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--install=foo'",
",",
"]",
")",
"with",
"self",
".",
"assertRaises",
"(",
"ValueError",
")",
":",
"kubernetes_bazel",
".",
"main",
"(",
"args",... | [
191,
4
] | [
197,
39
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_affected | (self) | --test=affected will work. | --test=affected will work. | def test_affected(self):
"""--test=affected will work."""
args = kubernetes_bazel.parse_args([
'--affected',
])
with self.assertRaises(ValueError):
kubernetes_bazel.main(args)
with Stub(kubernetes_bazel, 'get_changed', self.fake_changed_valid):
... | [
"def",
"test_affected",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--affected'",
",",
"]",
")",
"with",
"self",
".",
"assertRaises",
"(",
"ValueError",
")",
":",
"kubernetes_bazel",
".",
"main",
"(",
"args",
")",... | [
199,
4
] | [
216,
45
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_affected_empty | (self) | if --affected returns nothing, then nothing should be triggered | if --affected returns nothing, then nothing should be triggered | def test_affected_empty(self):
"""if --affected returns nothing, then nothing should be triggered"""
args = kubernetes_bazel.parse_args([
'--affected',
])
with Stub(kubernetes_bazel, 'get_changed', self.fake_changed_empty):
with Stub(os, 'getenv', self.fake_sh... | [
"def",
"test_affected_empty",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--affected'",
",",
"]",
")",
"with",
"Stub",
"(",
"kubernetes_bazel",
",",
"'get_changed'",
",",
"self",
".",
"fake_changed_empty",
")",
":",
... | [
218,
4
] | [
230,
56
] | python | en | ['en', 'en', 'en'] | True |
ScenarioTest.test_affected_filter | (self) | --test=affected will work. | --test=affected will work. | def test_affected_filter(self):
"""--test=affected will work."""
args = kubernetes_bazel.parse_args([
'--affected',
'--build=//foo',
'--test=//foo',
])
with Stub(kubernetes_bazel, 'get_changed', self.fake_changed_valid):
with Stub(os, '... | [
"def",
"test_affected_filter",
"(",
"self",
")",
":",
"args",
"=",
"kubernetes_bazel",
".",
"parse_args",
"(",
"[",
"'--affected'",
",",
"'--build=//foo'",
",",
"'--test=//foo'",
",",
"]",
")",
"with",
"Stub",
"(",
"kubernetes_bazel",
",",
"'get_changed'",
",",
... | [
232,
4
] | [
248,
48
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the HTU21D sensor. | Set up the HTU21D sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the HTU21D sensor."""
name = config.get(CONF_NAME)
bus_number = config.get(CONF_I2C_BUS)
bus = smbus.SMBus(config.get(CONF_I2C_BUS))
sensor = await hass.async_add_executor_job(partial(HTU21D, bus, logge... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"bus_number",
"=",
"config",
".",
"get",
"(",
"CONF_I2C_BUS... | [
59,
0
] | [
76,
32
] | python | en | ['en', 'ca', 'en'] | True |
HTU21DHandler.__init__ | (self, sensor) | Initialize the sensor handler. | Initialize the sensor handler. | def __init__(self, sensor):
"""Initialize the sensor handler."""
self.sensor = sensor
self.sensor.update() | [
"def",
"__init__",
"(",
"self",
",",
"sensor",
")",
":",
"self",
".",
"sensor",
"=",
"sensor",
"self",
".",
"sensor",
".",
"update",
"(",
")"
] | [
82,
4
] | [
85,
28
] | python | en | ['en', 'pt', 'en'] | True |
HTU21DHandler.update | (self) | Read raw data and calculate temperature and humidity. | Read raw data and calculate temperature and humidity. | def update(self):
"""Read raw data and calculate temperature and humidity."""
self.sensor.update() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"sensor",
".",
"update",
"(",
")"
] | [
88,
4
] | [
90,
28
] | python | en | ['en', 'en', 'en'] | True |
HTU21DSensor.__init__ | (self, htu21d_client, name, description: SensorEntityDescription) | Initialize the sensor. | Initialize the sensor. | def __init__(self, htu21d_client, name, description: SensorEntityDescription):
"""Initialize the sensor."""
self.entity_description = description
self._client = htu21d_client
self._attr_name = f"{name}_{description.key}" | [
"def",
"__init__",
"(",
"self",
",",
"htu21d_client",
",",
"name",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"_client",
"=",
"htu21d_client",
"self",
".",
"_attr_name",
"=",
... | [
96,
4
] | [
101,
53
] | python | en | ['en', 'en', 'en'] | True |
HTU21DSensor.async_update | (self) | Get the latest data from the HTU21D sensor and update the state. | Get the latest data from the HTU21D sensor and update the state. | async def async_update(self):
"""Get the latest data from the HTU21D sensor and update the state."""
await self.hass.async_add_executor_job(self._client.update)
if self._client.sensor.sample_ok:
if self.entity_description.key == SENSOR_TEMPERATURE:
value = round(self.... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_client",
".",
"update",
")",
"if",
"self",
".",
"_client",
".",
"sensor",
".",
"sample_ok",
":",
"if",
"self",
".",
... | [
103,
4
] | [
113,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Find and return LightWave lights. | Find and return LightWave lights. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Find and return LightWave lights."""
if not discovery_info:
return
lights = []
lwlink = hass.data[LIGHTWAVE_LINK]
for device_id, device_config in discovery_info.items():
name = device_config[C... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"not",
"discovery_info",
":",
"return",
"lights",
"=",
"[",
"]",
"lwlink",
"=",
"hass",
".",
"data",
"[",
"LI... | [
13,
0
] | [
25,
30
] | python | en | ['en', 'da', 'en'] | True |
LWRFLight.__init__ | (self, name, device_id, lwlink) | Initialize LWRFLight entity. | Initialize LWRFLight entity. | def __init__(self, name, device_id, lwlink):
"""Initialize LWRFLight entity."""
self._name = name
self._device_id = device_id
self._state = None
self._brightness = MAX_BRIGHTNESS
self._lwlink = lwlink | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"device_id",
",",
"lwlink",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_device_id",
"=",
"device_id",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_brightness",
"=",
"MAX_BRIGHTNESS",... | [
31,
4
] | [
37,
29
] | python | en | ['en', 'fy', 'it'] | False |
LWRFLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_BRIGHTNESS"
] | [
40,
4
] | [
42,
33
] | python | en | ['da', 'en', 'en'] | True |
LWRFLight.should_poll | (self) | No polling needed for a LightWave light. | No polling needed for a LightWave light. | def should_poll(self):
"""No polling needed for a LightWave light."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
45,
4
] | [
47,
20
] | python | en | ['en', 'en', 'en'] | True |
LWRFLight.name | (self) | Lightwave light name. | Lightwave light name. | def name(self):
"""Lightwave light name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
50,
4
] | [
52,
25
] | python | en | ['en', 'da', 'en'] | True |
LWRFLight.brightness | (self) | Brightness of this light between 0..MAX_BRIGHTNESS. | Brightness of this light between 0..MAX_BRIGHTNESS. | def brightness(self):
"""Brightness of this light between 0..MAX_BRIGHTNESS."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
55,
4
] | [
57,
31
] | python | en | ['en', 'ky', 'en'] | True |
LWRFLight.is_on | (self) | Lightwave light is on state. | Lightwave light is on state. | def is_on(self):
"""Lightwave light is on state."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
60,
4
] | [
62,
26
] | python | en | ['en', 'da', 'en'] | True |
LWRFLight.async_turn_on | (self, **kwargs) | Turn the LightWave light on. | Turn the LightWave light on. | async def async_turn_on(self, **kwargs):
"""Turn the LightWave light on."""
self._state = True
if ATTR_BRIGHTNESS in kwargs:
self._brightness = kwargs[ATTR_BRIGHTNESS]
if self._brightness != MAX_BRIGHTNESS:
self._lwlink.turn_on_with_brightness(
s... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"True",
"if",
"ATTR_BRIGHTNESS",
"in",
"kwargs",
":",
"self",
".",
"_brightness",
"=",
"kwargs",
"[",
"ATTR_BRIGHTNESS",
"]",
"if",
"self",
".",
... | [
64,
4
] | [
78,
35
] | python | en | ['en', 'da', 'en'] | True |
LWRFLight.async_turn_off | (self, **kwargs) | Turn the LightWave light off. | Turn the LightWave light off. | async def async_turn_off(self, **kwargs):
"""Turn the LightWave light off."""
self._state = False
self._lwlink.turn_off(self._device_id, self._name)
self.async_write_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_lwlink",
".",
"turn_off",
"(",
"self",
".",
"_device_id",
",",
"self",
".",
"_name",
")",
"self",
".",
"async_write_ha... | [
80,
4
] | [
84,
35
] | python | en | ['en', 'da', 'en'] | True |
mock_config_entry_fixture | (hass) | Mock a config entry. | Mock a config entry. | def mock_config_entry_fixture(hass):
"""Mock a config entry."""
mock_entry = MockConfigEntry(
domain="netatmo",
data={
"auth_implementation": "cloud",
"token": {
"refresh_token": "mock-refresh-token",
"access_token": "mock-access-token",
... | [
"def",
"mock_config_entry_fixture",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"netatmo\"",
",",
"data",
"=",
"{",
"\"auth_implementation\"",
":",
"\"cloud\"",
",",
"\"token\"",
":",
"{",
"\"refresh_token\"",
":",
"\"mock-re... | [
12,
0
] | [
52,
21
] | python | en | ['en', 'gl', 'en'] | True |
netatmo_auth | () | Restrict loaded platforms to list given. | Restrict loaded platforms to list given. | def netatmo_auth():
"""Restrict loaded platforms to list given."""
with patch(
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth"
) as mock_auth:
mock_auth.return_value.async_post_request.side_effect = fake_post_request
mock_auth.return_value.async_addwebhook.side_eff... | [
"def",
"netatmo_auth",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth\"",
")",
"as",
"mock_auth",
":",
"mock_auth",
".",
"return_value",
".",
"async_post_request",
".",
"side_effect",
"=",
"fake_post_request",
"moc... | [
56,
0
] | [
64,
13
] | python | en | ['en', 'en', 'en'] | True |
getTreeBuilder | (treeType, implementation=None, **kwargs) | Get a TreeBuilder class for various types of trees with built-in support
:arg treeType: the name of the tree type required (case-insensitive). Supported
values are:
* "dom" - A generic builder for DOM implementations, defaulting to a
xml.dom.minidom based implementation.
* "etree... | Get a TreeBuilder class for various types of trees with built-in support | def getTreeBuilder(treeType, implementation=None, **kwargs):
"""Get a TreeBuilder class for various types of trees with built-in support
:arg treeType: the name of the tree type required (case-insensitive). Supported
values are:
* "dom" - A generic builder for DOM implementations, defaulting t... | [
"def",
"getTreeBuilder",
"(",
"treeType",
",",
"implementation",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"treeType",
"=",
"treeType",
".",
"lower",
"(",
")",
"if",
"treeType",
"not",
"in",
"treeBuilderCache",
":",
"if",
"treeType",
"==",
"\"dom\"",... | [
38,
0
] | [
87,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Somfy climate platform. | Set up the Somfy climate platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Somfy climate platform."""
domain_data = hass.data[DOMAIN]
coordinator = domain_data[COORDINATOR]
climates = [
SomfyClimate(coordinator, device_id)
for device_id, device in coordinator.data.items()
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"domain_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"coordinator",
"=",
"domain_data",
"[",
"COORDINATOR",
"]",
"climates",
"=",
"[",
"SomfyCli... | [
47,
0
] | [
58,
32
] | python | en | ['en', 'da', 'en'] | True |
SomfyClimate.__init__ | (self, coordinator, device_id) | Initialize the Somfy device. | Initialize the Somfy device. | def __init__(self, coordinator, device_id):
"""Initialize the Somfy device."""
super().__init__(coordinator, device_id)
self._climate = None
self._create_device() | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"device_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
",",
"device_id",
")",
"self",
".",
"_climate",
"=",
"None",
"self",
".",
"_create_device",
"(",
")"
] | [
64,
4
] | [
68,
29
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate._create_device | (self) | Update the device with the latest data. | Update the device with the latest data. | def _create_device(self):
"""Update the device with the latest data."""
self._climate = Thermostat(self.device, self.coordinator.client) | [
"def",
"_create_device",
"(",
"self",
")",
":",
"self",
".",
"_climate",
"=",
"Thermostat",
"(",
"self",
".",
"device",
",",
"self",
".",
"coordinator",
".",
"client",
")"
] | [
70,
4
] | [
72,
72
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_TARGET_TEMPERATURE",
"|",
"SUPPORT_PRESET_MODE"
] | [
75,
4
] | [
77,
63
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.temperature_unit | (self) | Return the unit of measurement used by the platform. | Return the unit of measurement used by the platform. | def temperature_unit(self):
"""Return the unit of measurement used by the platform."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
80,
4
] | [
82,
27
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self):
"""Return the current temperature."""
return self._climate.get_ambient_temperature() | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_climate",
".",
"get_ambient_temperature",
"(",
")"
] | [
85,
4
] | [
87,
54
] | python | en | ['en', 'la', 'en'] | True |
SomfyClimate.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
return self._climate.get_target_temperature() | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"self",
".",
"_climate",
".",
"get_target_temperature",
"(",
")"
] | [
90,
4
] | [
92,
53
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | def set_temperature(self, **kwargs) -> None:
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
self._climate.set_target(TargetMode.MANUAL, temperature, DurationType.NEXT_MODE) | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"temperature",
"is",
"None",
":",
"return",
"self",
".",
"_climate",
".",
"set_target",
... | [
94,
4
] | [
100,
88
] | python | en | ['en', 'ca', 'en'] | True |
SomfyClimate.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self) -> float:
"""Return the maximum temperature."""
return 26.0 | [
"def",
"max_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"26.0"
] | [
103,
4
] | [
105,
19
] | python | en | ['en', 'la', 'en'] | True |
SomfyClimate.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self) -> float:
"""Return the minimum temperature."""
return 15.0 | [
"def",
"min_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"15.0"
] | [
108,
4
] | [
110,
19
] | python | en | ['en', 'la', 'en'] | True |
SomfyClimate.current_humidity | (self) | Return the current humidity. | Return the current humidity. | def current_humidity(self):
"""Return the current humidity."""
return self._climate.get_humidity() | [
"def",
"current_humidity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_climate",
".",
"get_humidity",
"(",
")"
] | [
113,
4
] | [
115,
43
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.hvac_mode | (self) | Return hvac operation ie. heat, cool mode. | Return hvac operation ie. heat, cool mode. | def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode."""
if self._climate.get_regulation_state() == RegulationState.TIMETABLE:
return HVAC_MODE_AUTO
return HVAC_MODES_MAPPING.get(self._climate.get_hvac_state()) | [
"def",
"hvac_mode",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_climate",
".",
"get_regulation_state",
"(",
")",
"==",
"RegulationState",
".",
"TIMETABLE",
":",
"return",
"HVAC_MODE_AUTO",
"return",
"HVAC_MODES_MAPPING",
".",
"get",
"(",
"self",
... | [
118,
4
] | [
122,
69
] | python | bg | ['en', 'bg', 'bg'] | True |
SomfyClimate.hvac_modes | (self) | Return the list of available hvac operation modes.
HEAT and COOL mode are exclusive. End user has to enable a mode manually within the Somfy application.
So only one mode can be displayed. Auto mode is a scheduler.
| Return the list of available hvac operation modes. | def hvac_modes(self) -> list[str]:
"""Return the list of available hvac operation modes.
HEAT and COOL mode are exclusive. End user has to enable a mode manually within the Somfy application.
So only one mode can be displayed. Auto mode is a scheduler.
"""
hvac_state = HVAC_MODE... | [
"def",
"hvac_modes",
"(",
"self",
")",
"->",
"list",
"[",
"str",
"]",
":",
"hvac_state",
"=",
"HVAC_MODES_MAPPING",
"[",
"self",
".",
"_climate",
".",
"get_hvac_state",
"(",
")",
"]",
"return",
"[",
"HVAC_MODE_AUTO",
",",
"hvac_state",
"]"
] | [
125,
4
] | [
132,
43
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.set_hvac_mode | (self, hvac_mode: str) | Set new target hvac mode. | Set new target hvac mode. | def set_hvac_mode(self, hvac_mode: str) -> None:
"""Set new target hvac mode."""
if hvac_mode == HVAC_MODE_AUTO:
self._climate.cancel_target()
else:
self._climate.set_target(
TargetMode.MANUAL, self.target_temperature, DurationType.FURTHER_NOTICE
... | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
":",
"str",
")",
"->",
"None",
":",
"if",
"hvac_mode",
"==",
"HVAC_MODE_AUTO",
":",
"self",
".",
"_climate",
".",
"cancel_target",
"(",
")",
"else",
":",
"self",
".",
"_climate",
".",
"set_target",
"... | [
134,
4
] | [
141,
13
] | python | da | ['da', 'su', 'en'] | False |
SomfyClimate.preset_mode | (self) | Return the current preset mode. | Return the current preset mode. | def preset_mode(self) -> str | None:
"""Return the current preset mode."""
mode = self._climate.get_target_mode()
return PRESETS_MAPPING.get(mode) | [
"def",
"preset_mode",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"mode",
"=",
"self",
".",
"_climate",
".",
"get_target_mode",
"(",
")",
"return",
"PRESETS_MAPPING",
".",
"get",
"(",
"mode",
")"
] | [
144,
4
] | [
147,
40
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.preset_modes | (self) | Return a list of available preset modes. | Return a list of available preset modes. | def preset_modes(self) -> list[str] | None:
"""Return a list of available preset modes."""
return list(PRESETS_MAPPING.values()) | [
"def",
"preset_modes",
"(",
"self",
")",
"->",
"list",
"[",
"str",
"]",
"|",
"None",
":",
"return",
"list",
"(",
"PRESETS_MAPPING",
".",
"values",
"(",
")",
")"
] | [
150,
4
] | [
152,
45
] | python | en | ['en', 'en', 'en'] | True |
SomfyClimate.set_preset_mode | (self, preset_mode: str) | Set new preset mode. | Set new preset mode. | def set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
if self.preset_mode == preset_mode:
return
if preset_mode == PRESET_HOME:
temperature = self._climate.get_at_home_temperature()
elif preset_mode == PRESET_AWAY:
temperatur... | [
"def",
"set_preset_mode",
"(",
"self",
",",
"preset_mode",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"preset_mode",
"==",
"preset_mode",
":",
"return",
"if",
"preset_mode",
"==",
"PRESET_HOME",
":",
"temperature",
"=",
"self",
".",
"_climate",
... | [
154,
4
] | [
174,
9
] | python | en | ['en', 'sr', 'en'] | True |
empty_value | (value: Any) | Test if the user has the default config value from adding "zone:". | Test if the user has the default config value from adding "zone:". | def empty_value(value: Any) -> Any:
"""Test if the user has the default config value from adding "zone:"."""
if isinstance(value, dict) and len(value) == 0:
return []
raise vol.Invalid("Not a default value") | [
"def",
"empty_value",
"(",
"value",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
"and",
"len",
"(",
"value",
")",
"==",
"0",
":",
"return",
"[",
"]",
"raise",
"vol",
".",
"Invalid",
"(",
"\"Not a default valu... | [
69,
0
] | [
74,
44
] | python | en | ['en', 'en', 'en'] | True |
async_active_zone | (
hass: HomeAssistant, latitude: float, longitude: float, radius: int = 0
) | Find the active zone for given latitude, longitude.
This method must be run in the event loop.
| Find the active zone for given latitude, longitude. | def async_active_zone(
hass: HomeAssistant, latitude: float, longitude: float, radius: int = 0
) -> State | None:
"""Find the active zone for given latitude, longitude.
This method must be run in the event loop.
"""
# Sort entity IDs so that we are deterministic if equal distance to 2 zones
zon... | [
"def",
"async_active_zone",
"(",
"hass",
":",
"HomeAssistant",
",",
"latitude",
":",
"float",
",",
"longitude",
":",
"float",
",",
"radius",
":",
"int",
"=",
"0",
")",
"->",
"State",
"|",
"None",
":",
"# Sort entity IDs so that we are deterministic if equal distan... | [
93,
0
] | [
135,
18
] | python | en | ['en', 'en', 'en'] | True |
in_zone | (zone: State, latitude: float, longitude: float, radius: float = 0) | Test if given latitude, longitude is in given zone.
Async friendly.
| Test if given latitude, longitude is in given zone. | def in_zone(zone: State, latitude: float, longitude: float, radius: float = 0) -> bool:
"""Test if given latitude, longitude is in given zone.
Async friendly.
"""
if zone.state == STATE_UNAVAILABLE:
return False
zone_dist = distance(
latitude,
longitude,
zone.attrib... | [
"def",
"in_zone",
"(",
"zone",
":",
"State",
",",
"latitude",
":",
"float",
",",
"longitude",
":",
"float",
",",
"radius",
":",
"float",
"=",
"0",
")",
"->",
"bool",
":",
"if",
"zone",
".",
"state",
"==",
"STATE_UNAVAILABLE",
":",
"return",
"False",
... | [
138,
0
] | [
155,
73
] | python | en | ['nl', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: ConfigType) | Set up configured zones as well as Home Assistant zone if necessary. | Set up configured zones as well as Home Assistant zone if necessary. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up configured zones as well as Home Assistant zone if necessary."""
component = entity_component.EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
yaml_collection = collection.IDLessCollection(
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"component",
"=",
"entity_component",
".",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
")",
"id_manager",
"=",
"col... | [
179,
0
] | [
239,
15
] | python | en | ['en', 'en', 'en'] | True |
_home_conf | (hass: HomeAssistant) | Return the home zone config. | Return the home zone config. | def _home_conf(hass: HomeAssistant) -> dict:
"""Return the home zone config."""
return {
CONF_NAME: hass.config.location_name,
CONF_LATITUDE: hass.config.latitude,
CONF_LONGITUDE: hass.config.longitude,
CONF_RADIUS: DEFAULT_RADIUS,
CONF_ICON: ICON_HOME,
CONF_PASSI... | [
"def",
"_home_conf",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"dict",
":",
"return",
"{",
"CONF_NAME",
":",
"hass",
".",
"config",
".",
"location_name",
",",
"CONF_LATITUDE",
":",
"hass",
".",
"config",
".",
"latitude",
",",
"CONF_LONGITUDE",
":",
"ha... | [
243,
0
] | [
252,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, config_entry: config_entries.ConfigEntry
) | Set up zone as config entry. | Set up zone as config entry. | async def async_setup_entry(
hass: HomeAssistant, config_entry: config_entries.ConfigEntry
) -> bool:
"""Set up zone as config entry."""
storage_collection = cast(ZoneStorageCollection, hass.data[DOMAIN])
data = dict(config_entry.data)
data.setdefault(CONF_PASSIVE, DEFAULT_PASSIVE)
data.setdefa... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"bool",
":",
"storage_collection",
"=",
"cast",
"(",
"ZoneStorageCollection",
",",
"hass",
".",
"data",
"[",
"DOMAI... | [
255,
0
] | [
269,
15
] | 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.