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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
isnumberlike | (text) | Returns true if `text` can be interpreted as a floating point number. | Returns true if `text` can be interpreted as a floating point number. | def isnumberlike(text):
""" Returns true if `text` can be interpreted as a floating point number. """
try:
float(text)
return True
except ValueError:
return False | [
"def",
"isnumberlike",
"(",
"text",
")",
":",
"try",
":",
"float",
"(",
"text",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False"
] | [
847,
0
] | [
853,
20
] | python | en | ['en', 'en', 'en'] | True |
get_index | (seq, value) |
Find the first location in *seq* which contains a case-insensitive,
whitespace-insensitive match for *value*. Returns *None* if no match is
found.
|
Find the first location in *seq* which contains a case-insensitive,
whitespace-insensitive match for *value*. Returns *None* if no match is
found.
| def get_index(seq, value):
"""
Find the first location in *seq* which contains a case-insensitive,
whitespace-insensitive match for *value*. Returns *None* if no match is
found.
"""
if isinstance(seq, string_types):
seq = seq.split()
value = value.lower().strip()
for i,item in en... | [
"def",
"get_index",
"(",
"seq",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"seq",
",",
"string_types",
")",
":",
"seq",
"=",
"seq",
".",
"split",
"(",
")",
"value",
"=",
"value",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"for",
"i",
... | [
855,
0
] | [
867,
15
] | python | en | ['en', 'error', 'th'] | False |
main | (options) |
import getopt
longOptions = ['input=', 'thermo=', 'transport=', 'id=', 'output=',
'permissive', 'help', 'debug']
try:
optlist, args = getopt.getopt(argv, 'dh', longOptions)
options = dict()
for o,a in optlist:
options[o] = a
if args:
... |
import getopt | def main(options):
"""
import getopt
longOptions = ['input=', 'thermo=', 'transport=', 'id=', 'output=',
'permissive', 'help', 'debug']
try:
optlist, args = getopt.getopt(argv, 'dh', longOptions)
options = dict()
for o,a in optlist:
options[o] = a... | [
"def",
"main",
"(",
"options",
")",
":",
"parser",
"=",
"Parser",
"(",
")",
"if",
"not",
"options",
"or",
"'-h'",
"in",
"options",
"or",
"'--help'",
"in",
"options",
":",
"parser",
".",
"showHelp",
"(",
")",
"sys",
".",
"exit",
"(",
"0",
")",
"if",... | [
1940,
0
] | [
2013,
19
] | python | en | ['en', 'error', 'th'] | False |
Reaction.__str__ | (self) |
Return a string representation of the reaction, in the form 'A + B <=> C + D'.
|
Return a string representation of the reaction, in the form 'A + B <=> C + D'.
| def __str__(self):
"""
Return a string representation of the reaction, in the form 'A + B <=> C + D'.
"""
arrow = ' <=> ' if self.reversible else ' -> '
return arrow.join([self.reactantString, self.productString]) | [
"def",
"__str__",
"(",
"self",
")",
":",
"arrow",
"=",
"' <=> '",
"if",
"self",
".",
"reversible",
"else",
"' -> '",
"return",
"arrow",
".",
"join",
"(",
"[",
"self",
".",
"reactantString",
",",
"self",
".",
"productString",
"]",
")"
] | [
284,
4
] | [
289,
68
] | python | en | ['en', 'error', 'th'] | False |
KineticsModel.isPressureDependent | (self) |
Return ``True`` if the kinetics are pressure-dependent or ``False`` if
they are pressure-independent. This method must be overloaded in the
derived class.
|
Return ``True`` if the kinetics are pressure-dependent or ``False`` if
they are pressure-independent. This method must be overloaded in the
derived class.
| def isPressureDependent(self):
"""
Return ``True`` if the kinetics are pressure-dependent or ``False`` if
they are pressure-independent. This method must be overloaded in the
derived class.
"""
raise InputParseError('Unexpected call to KineticsModel.isPressureDependent();... | [
"def",
"isPressureDependent",
"(",
"self",
")",
":",
"raise",
"InputParseError",
"(",
"'Unexpected call to KineticsModel.isPressureDependent();'",
"' you should be using a class derived from KineticsModel.'",
")"
] | [
345,
4
] | [
352,
89
] | python | en | ['en', 'error', 'th'] | False |
KineticsData.isPressureDependent | (self) |
Returns ``False`` since KineticsData kinetics are not
pressure-dependent.
|
Returns ``False`` since KineticsData kinetics are not
pressure-dependent.
| def isPressureDependent(self):
"""
Returns ``False`` since KineticsData kinetics are not
pressure-dependent.
"""
return False | [
"def",
"isPressureDependent",
"(",
"self",
")",
":",
"return",
"False"
] | [
384,
4
] | [
389,
20
] | python | en | ['en', 'error', 'th'] | False |
Arrhenius.isPressureDependent | (self) |
Returns ``False`` since Arrhenius kinetics are not pressure-dependent.
|
Returns ``False`` since Arrhenius kinetics are not pressure-dependent.
| def isPressureDependent(self):
"""
Returns ``False`` since Arrhenius kinetics are not pressure-dependent.
"""
return False | [
"def",
"isPressureDependent",
"(",
"self",
")",
":",
"return",
"False"
] | [
421,
4
] | [
425,
20
] | python | en | ['en', 'error', 'th'] | False |
PDepArrhenius.isPressureDependent | (self) |
Returns ``True`` since PDepArrhenius kinetics are pressure-dependent.
|
Returns ``True`` since PDepArrhenius kinetics are pressure-dependent.
| def isPressureDependent(self):
"""
Returns ``True`` since PDepArrhenius kinetics are pressure-dependent.
"""
return True | [
"def",
"isPressureDependent",
"(",
"self",
")",
":",
"return",
"True"
] | [
478,
4
] | [
482,
19
] | python | en | ['en', 'error', 'th'] | False |
Chebyshev.isPressureDependent | (self) |
Returns ``True`` since Chebyshev polynomial kinetics are
pressure-dependent.
|
Returns ``True`` since Chebyshev polynomial kinetics are
pressure-dependent.
| def isPressureDependent(self):
"""
Returns ``True`` since Chebyshev polynomial kinetics are
pressure-dependent.
"""
return True | [
"def",
"isPressureDependent",
"(",
"self",
")",
":",
"return",
"True"
] | [
539,
4
] | [
544,
19
] | python | en | ['en', 'error', 'th'] | False |
ThirdBody.isPressureDependent | (self) |
Returns ``True`` since third-body kinetics are pressure-dependent.
|
Returns ``True`` since third-body kinetics are pressure-dependent.
| def isPressureDependent(self):
"""
Returns ``True`` since third-body kinetics are pressure-dependent.
"""
return True | [
"def",
"isPressureDependent",
"(",
"self",
")",
":",
"return",
"True"
] | [
594,
4
] | [
598,
19
] | python | en | ['en', 'error', 'th'] | False |
Parser.parseComposition | (self, elements, nElements, width) |
Parse the elemental composition from a 7 or 9 coefficient NASA polynomial
entry.
|
Parse the elemental composition from a 7 or 9 coefficient NASA polynomial
entry.
| def parseComposition(self, elements, nElements, width):
"""
Parse the elemental composition from a 7 or 9 coefficient NASA polynomial
entry.
"""
composition = {}
for i in range(nElements):
symbol = elements[width*i:width*i+2].strip()
count = elemen... | [
"def",
"parseComposition",
"(",
"self",
",",
"elements",
",",
"nElements",
",",
"width",
")",
":",
"composition",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"nElements",
")",
":",
"symbol",
"=",
"elements",
"[",
"width",
"*",
"i",
":",
"width",
"... | [
896,
4
] | [
913,
26
] | python | en | ['en', 'error', 'th'] | False |
Parser.readThermoEntry | (self, lines, TintDefault) |
Read a thermodynamics entry for one species in a Chemkin-format file
(consisting of two 7-coefficient NASA polynomials). Returns the label of
the species, the thermodynamics model as a :class:`MultiNASA` object, the
elemental composition of the species, and the comment/note associated w... |
Read a thermodynamics entry for one species in a Chemkin-format file
(consisting of two 7-coefficient NASA polynomials). Returns the label of
the species, the thermodynamics model as a :class:`MultiNASA` object, the
elemental composition of the species, and the comment/note associated w... | def readThermoEntry(self, lines, TintDefault):
"""
Read a thermodynamics entry for one species in a Chemkin-format file
(consisting of two 7-coefficient NASA polynomials). Returns the label of
the species, the thermodynamics model as a :class:`MultiNASA` object, the
elemental com... | [
"def",
"readThermoEntry",
"(",
"self",
",",
"lines",
",",
"TintDefault",
")",
":",
"identifier",
"=",
"lines",
"[",
"0",
"]",
"[",
"0",
":",
"24",
"]",
".",
"split",
"(",
")",
"species",
"=",
"identifier",
"[",
"0",
"]",
".",
"strip",
"(",
")",
"... | [
935,
4
] | [
995,
49
] | python | en | ['en', 'error', 'th'] | False |
Parser.readNasa9Entry | (self, entry) |
Read a thermodynamics `entry` for one species given as one or more
9-coefficient NASA polynomials, written in the format described in
Appendix A of NASA Reference Publication 1311 (McBride and Gordon, 1996).
Returns the label of the species, the thermodynamics model as a
:class:... |
Read a thermodynamics `entry` for one species given as one or more
9-coefficient NASA polynomials, written in the format described in
Appendix A of NASA Reference Publication 1311 (McBride and Gordon, 1996).
Returns the label of the species, the thermodynamics model as a
:class:... | def readNasa9Entry(self, entry):
"""
Read a thermodynamics `entry` for one species given as one or more
9-coefficient NASA polynomials, written in the format described in
Appendix A of NASA Reference Publication 1311 (McBride and Gordon, 1996).
Returns the label of the species, t... | [
"def",
"readNasa9Entry",
"(",
"self",
",",
"entry",
")",
":",
"tokens",
"=",
"entry",
"[",
"0",
"]",
".",
"split",
"(",
")",
"species",
"=",
"tokens",
"[",
"0",
"]",
"note",
"=",
"' '",
".",
"join",
"(",
"tokens",
"[",
"1",
":",
"]",
")",
"N",
... | [
997,
4
] | [
1041,
49
] | python | en | ['en', 'error', 'th'] | False |
Parser.readKineticsEntry | (self, entry) |
Read a kinetics `entry` for a single reaction as loaded from a
Chemkin-format file. Returns a :class:`Reaction` object with the
reaction and its associated kinetics.
|
Read a kinetics `entry` for a single reaction as loaded from a
Chemkin-format file. Returns a :class:`Reaction` object with the
reaction and its associated kinetics.
| def readKineticsEntry(self, entry):
"""
Read a kinetics `entry` for a single reaction as loaded from a
Chemkin-format file. Returns a :class:`Reaction` object with the
reaction and its associated kinetics.
"""
# Handle non-default units which apply to this entry
... | [
"def",
"readKineticsEntry",
"(",
"self",
",",
"entry",
")",
":",
"# Handle non-default units which apply to this entry",
"energy_units",
"=",
"self",
".",
"energy_units",
"quantity_units",
"=",
"self",
".",
"quantity_units",
"if",
"'units'",
"in",
"entry",
".",
"lower... | [
1057,
4
] | [
1387,
36
] | python | en | ['en', 'error', 'th'] | False |
Parser.loadChemkinFile | (self, path, skipUndeclaredSpecies=True) |
Load a Chemkin-format input file to `path` on disk.
|
Load a Chemkin-format input file to `path` on disk.
| def loadChemkinFile(self, path, skipUndeclaredSpecies=True):
"""
Load a Chemkin-format input file to `path` on disk.
"""
transportLines = []
self.line_number = 0
with open(path, 'rU') as ck_file:
def readline():
self.line_number += 1
... | [
"def",
"loadChemkinFile",
"(",
"self",
",",
"path",
",",
"skipUndeclaredSpecies",
"=",
"True",
")",
":",
"transportLines",
"=",
"[",
"]",
"self",
".",
"line_number",
"=",
"0",
"with",
"open",
"(",
"path",
",",
"'rU'",
")",
"as",
"ck_file",
":",
"def",
... | [
1389,
4
] | [
1697,
79
] | python | en | ['en', 'error', 'th'] | False |
Parser.checkDuplicateReactions | (self) |
Check for marked (and unmarked!) duplicate reactions. Raise exception
for unmarked duplicate reactions.
Pressure-independent and pressure-dependent reactions are treated as
different, so they don't need to be marked as duplicate.
|
Check for marked (and unmarked!) duplicate reactions. Raise exception
for unmarked duplicate reactions. | def checkDuplicateReactions(self):
"""
Check for marked (and unmarked!) duplicate reactions. Raise exception
for unmarked duplicate reactions.
Pressure-independent and pressure-dependent reactions are treated as
different, so they don't need to be marked as duplicate.
""... | [
"def",
"checkDuplicateReactions",
"(",
"self",
")",
":",
"message",
"=",
"(",
"'Encountered unmarked duplicate reaction {0} '",
"'(See lines {1} and {2} of the input file.).'",
")",
"possible_duplicates",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"r",
"in",
"self",
"."... | [
1699,
4
] | [
1728,
93
] | python | en | ['en', 'error', 'th'] | False |
Parser.parseTransportData | (self, lines, filename, line_offset) |
Parse the Chemkin-format transport data in ``lines`` (a list of strings)
and add that transport data to the previously-loaded species.
|
Parse the Chemkin-format transport data in ``lines`` (a list of strings)
and add that transport data to the previously-loaded species.
| def parseTransportData(self, lines, filename, line_offset):
"""
Parse the Chemkin-format transport data in ``lines`` (a list of strings)
and add that transport data to the previously-loaded species.
"""
for i,line in enumerate(lines):
line = line.strip()
... | [
"def",
"parseTransportData",
"(",
"self",
",",
"lines",
",",
"filename",
",",
"line_offset",
")",
":",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"lines",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"not",
"line",
"or",
"line",... | [
1730,
4
] | [
1760,
68
] | python | en | ['en', 'error', 'th'] | False |
get_cipher | () | Return decryption function and length of key.
Async friendly.
| Return decryption function and length of key. | def get_cipher():
"""Return decryption function and length of key.
Async friendly.
"""
def decrypt(ciphertext, key):
"""Decrypt ciphertext using key."""
return SecretBox(key).decrypt(ciphertext, encoder=Base64Encoder)
return (SecretBox.KEY_SIZE, decrypt) | [
"def",
"get_cipher",
"(",
")",
":",
"def",
"decrypt",
"(",
"ciphertext",
",",
"key",
")",
":",
"\"\"\"Decrypt ciphertext using key.\"\"\"",
"return",
"SecretBox",
"(",
"key",
")",
".",
"decrypt",
"(",
"ciphertext",
",",
"encoder",
"=",
"Base64Encoder",
")",
"r... | [
22,
0
] | [
32,
40
] | python | en | ['en', 'en', 'en'] | True |
_parse_topic | (topic, subscribe_topic) | Parse an MQTT topic {sub_topic}/user/dev, return (user, dev) tuple.
Async friendly.
| Parse an MQTT topic {sub_topic}/user/dev, return (user, dev) tuple. | def _parse_topic(topic, subscribe_topic):
"""Parse an MQTT topic {sub_topic}/user/dev, return (user, dev) tuple.
Async friendly.
"""
subscription = subscribe_topic.split("/")
try:
user_index = subscription.index("#")
except ValueError:
_LOGGER.error("Can't parse subscription top... | [
"def",
"_parse_topic",
"(",
"topic",
",",
"subscribe_topic",
")",
":",
"subscription",
"=",
"subscribe_topic",
".",
"split",
"(",
"\"/\"",
")",
"try",
":",
"user_index",
"=",
"subscription",
".",
"index",
"(",
"\"#\"",
")",
"except",
"ValueError",
":",
"_LOG... | [
35,
0
] | [
54,
23
] | python | en | ['en', 'mt', 'en'] | True |
_parse_see_args | (message, subscribe_topic) | Parse the OwnTracks location parameters, into the format see expects.
Async friendly.
| Parse the OwnTracks location parameters, into the format see expects. | def _parse_see_args(message, subscribe_topic):
"""Parse the OwnTracks location parameters, into the format see expects.
Async friendly.
"""
user, device = _parse_topic(message["topic"], subscribe_topic)
dev_id = slugify(f"{user}_{device}")
kwargs = {"dev_id": dev_id, "host_name": user, "attribu... | [
"def",
"_parse_see_args",
"(",
"message",
",",
"subscribe_topic",
")",
":",
"user",
",",
"device",
"=",
"_parse_topic",
"(",
"message",
"[",
"\"topic\"",
"]",
",",
"subscribe_topic",
")",
"dev_id",
"=",
"slugify",
"(",
"f\"{user}_{device}\"",
")",
"kwargs",
"=... | [
57,
0
] | [
90,
25
] | python | en | ['en', 'en', 'en'] | True |
_set_gps_from_zone | (kwargs, location, zone) | Set the see parameters from the zone parameters.
Async friendly.
| Set the see parameters from the zone parameters. | def _set_gps_from_zone(kwargs, location, zone):
"""Set the see parameters from the zone parameters.
Async friendly.
"""
if zone is not None:
kwargs["gps"] = (
zone.attributes[ATTR_LATITUDE],
zone.attributes[ATTR_LONGITUDE],
)
kwargs["gps_accuracy"] = zone... | [
"def",
"_set_gps_from_zone",
"(",
"kwargs",
",",
"location",
",",
"zone",
")",
":",
"if",
"zone",
"is",
"not",
"None",
":",
"kwargs",
"[",
"\"gps\"",
"]",
"=",
"(",
"zone",
".",
"attributes",
"[",
"ATTR_LATITUDE",
"]",
",",
"zone",
".",
"attributes",
"... | [
93,
0
] | [
105,
17
] | python | en | ['en', 'en', 'en'] | True |
_decrypt_payload | (secret, topic, ciphertext) | Decrypt encrypted payload. | Decrypt encrypted payload. | def _decrypt_payload(secret, topic, ciphertext):
"""Decrypt encrypted payload."""
try:
if supports_encryption():
keylen, decrypt = get_cipher()
else:
_LOGGER.warning("Ignoring encrypted payload because nacl not installed")
return None
except OSError:
... | [
"def",
"_decrypt_payload",
"(",
"secret",
",",
"topic",
",",
"ciphertext",
")",
":",
"try",
":",
"if",
"supports_encryption",
"(",
")",
":",
"keylen",
",",
"decrypt",
"=",
"get_cipher",
"(",
")",
"else",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Ignoring enc... | [
108,
0
] | [
146,
19
] | python | en | ['fr', 'en', 'en'] | True |
encrypt_message | (secret, topic, message) | Encrypt message. | Encrypt message. | def encrypt_message(secret, topic, message):
"""Encrypt message."""
keylen = SecretBox.KEY_SIZE
if isinstance(secret, dict):
key = secret.get(topic)
else:
key = secret
if key is None:
_LOGGER.warning(
"Unable to encrypt payload because no decryption key known "... | [
"def",
"encrypt_message",
"(",
"secret",
",",
"topic",
",",
"message",
")",
":",
"keylen",
"=",
"SecretBox",
".",
"KEY_SIZE",
"if",
"isinstance",
"(",
"secret",
",",
"dict",
")",
":",
"key",
"=",
"secret",
".",
"get",
"(",
"topic",
")",
"else",
":",
... | [
149,
0
] | [
177,
19
] | python | en | ['en', 'el-Latn', 'en'] | False |
async_handle_location_message | (hass, context, message) | Handle a location message. | Handle a location message. | async def async_handle_location_message(hass, context, message):
"""Handle a location message."""
if not context.async_valid_accuracy(message):
return
if context.events_only:
_LOGGER.debug("Location update ignored due to events_only setting")
return
dev_id, kwargs = _parse_see_... | [
"async",
"def",
"async_handle_location_message",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"if",
"not",
"context",
".",
"async_valid_accuracy",
"(",
"message",
")",
":",
"return",
"if",
"context",
".",
"events_only",
":",
"_LOGGER",
".",
"debug",
... | [
181,
0
] | [
199,
51
] | python | en | ['es', 'en', 'en'] | True |
_async_transition_message_enter | (hass, context, message, location) | Execute enter event. | Execute enter event. | async def _async_transition_message_enter(hass, context, message, location):
"""Execute enter event."""
zone = hass.states.get(f"zone.{slugify(location)}")
dev_id, kwargs = _parse_see_args(message, context.mqtt_topic)
if zone is None and message.get("t") == "b":
# Not a HA zone, and a beacon so... | [
"async",
"def",
"_async_transition_message_enter",
"(",
"hass",
",",
"context",
",",
"message",
",",
"location",
")",
":",
"zone",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"f\"zone.{slugify(location)}\"",
")",
"dev_id",
",",
"kwargs",
"=",
"_parse_see_args",... | [
202,
0
] | [
225,
55
] | python | en | ['fr', 'gl', 'en'] | False |
_async_transition_message_leave | (hass, context, message, location) | Execute leave event. | Execute leave event. | async def _async_transition_message_leave(hass, context, message, location):
"""Execute leave event."""
dev_id, kwargs = _parse_see_args(message, context.mqtt_topic)
regions = context.regions_entered[dev_id]
if location in regions:
regions.remove(location)
beacons = context.mobile_beacons_... | [
"async",
"def",
"_async_transition_message_leave",
"(",
"hass",
",",
"context",
",",
"message",
",",
"location",
")",
":",
"dev_id",
",",
"kwargs",
"=",
"_parse_see_args",
"(",
"message",
",",
"context",
".",
"mqtt_topic",
")",
"regions",
"=",
"context",
".",
... | [
228,
0
] | [
257,
59
] | python | en | ['en', 'en', 'en'] | True |
async_handle_transition_message | (hass, context, message) | Handle a transition message. | Handle a transition message. | async def async_handle_transition_message(hass, context, message):
"""Handle a transition message."""
if message.get("desc") is None:
_LOGGER.error(
"Location missing from `Entering/Leaving` message - "
"please turn `Share` on in OwnTracks app"
)
return
# OwnT... | [
"async",
"def",
"async_handle_transition_message",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"if",
"message",
".",
"get",
"(",
"\"desc\"",
")",
"is",
"None",
":",
"_LOGGER",
".",
"error",
"(",
"\"Location missing from `Entering/Leaving` message - \"",
... | [
261,
0
] | [
288,
9
] | python | en | ['en', 'en', 'en'] | True |
async_handle_waypoint | (hass, name_base, waypoint) | Handle a waypoint. | Handle a waypoint. | async def async_handle_waypoint(hass, name_base, waypoint):
"""Handle a waypoint."""
name = waypoint["desc"]
pretty_name = f"{name_base} - {name}"
lat = waypoint["lat"]
lon = waypoint["lon"]
rad = waypoint["rad"]
# check zone exists
entity_id = zone_comp.ENTITY_ID_FORMAT.format(slugify(... | [
"async",
"def",
"async_handle_waypoint",
"(",
"hass",
",",
"name_base",
",",
"waypoint",
")",
":",
"name",
"=",
"waypoint",
"[",
"\"desc\"",
"]",
"pretty_name",
"=",
"f\"{name_base} - {name}\"",
"lat",
"=",
"waypoint",
"[",
"\"lat\"",
"]",
"lon",
"=",
"waypoin... | [
291,
0
] | [
319,
31
] | python | en | ['en', 'en', 'en'] | True |
async_handle_waypoints_message | (hass, context, message) | Handle a waypoints message. | Handle a waypoints message. | async def async_handle_waypoints_message(hass, context, message):
"""Handle a waypoints message."""
if not context.import_waypoints:
return
if context.waypoint_whitelist is not None:
user = _parse_topic(message["topic"], context.mqtt_topic)[0]
if user not in context.waypoint_whitel... | [
"async",
"def",
"async_handle_waypoints_message",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"if",
"not",
"context",
".",
"import_waypoints",
":",
"return",
"if",
"context",
".",
"waypoint_whitelist",
"is",
"not",
"None",
":",
"user",
"=",
"_parse_... | [
324,
0
] | [
345,
58
] | python | en | ['en', 'en', 'en'] | True |
async_handle_encrypted_message | (hass, context, message) | Handle an encrypted message. | Handle an encrypted message. | async def async_handle_encrypted_message(hass, context, message):
"""Handle an encrypted message."""
if "topic" not in message and isinstance(context.secret, dict):
_LOGGER.error("You cannot set per topic secrets when using HTTP")
return
plaintext_payload = _decrypt_payload(
context... | [
"async",
"def",
"async_handle_encrypted_message",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"if",
"\"topic\"",
"not",
"in",
"message",
"and",
"isinstance",
"(",
"context",
".",
"secret",
",",
"dict",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"... | [
349,
0
] | [
366,
56
] | python | en | ['br', 'en', 'en'] | True |
async_handle_not_impl_msg | (hass, context, message) | Handle valid but not implemented message types. | Handle valid but not implemented message types. | async def async_handle_not_impl_msg(hass, context, message):
"""Handle valid but not implemented message types."""
_LOGGER.debug("Not handling %s message: %s", message.get("_type"), message) | [
"async",
"def",
"async_handle_not_impl_msg",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Not handling %s message: %s\"",
",",
"message",
".",
"get",
"(",
"\"_type\"",
")",
",",
"message",
")"
] | [
375,
0
] | [
377,
79
] | python | en | ['en', 'en', 'en'] | True |
async_handle_unsupported_msg | (hass, context, message) | Handle an unsupported or invalid message type. | Handle an unsupported or invalid message type. | async def async_handle_unsupported_msg(hass, context, message):
"""Handle an unsupported or invalid message type."""
_LOGGER.warning("Received unsupported message type: %s", message.get("_type")) | [
"async",
"def",
"async_handle_unsupported_msg",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Received unsupported message type: %s\"",
",",
"message",
".",
"get",
"(",
"\"_type\"",
")",
")"
] | [
380,
0
] | [
382,
82
] | python | en | ['en', 'en', 'en'] | True |
async_handle_message | (hass, context, message) | Handle an OwnTracks message. | Handle an OwnTracks message. | async def async_handle_message(hass, context, message):
"""Handle an OwnTracks message."""
msgtype = message.get("_type")
_LOGGER.debug("Received %s", message)
handler = HANDLERS.get(msgtype, async_handle_unsupported_msg)
await handler(hass, context, message) | [
"async",
"def",
"async_handle_message",
"(",
"hass",
",",
"context",
",",
"message",
")",
":",
"msgtype",
"=",
"message",
".",
"get",
"(",
"\"_type\"",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Received %s\"",
",",
"message",
")",
"handler",
"=",
"HANDLERS",
"... | [
385,
0
] | [
393,
41
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry | (hass) | Test the sensor. | Test the sensor. | async def test_async_setup_entry(hass):
"""Test the sensor."""
fake_async_add_entities = MagicMock()
fake_srp_energy_client = MagicMock()
fake_srp_energy_client.usage.return_value = [{1, 2, 3, 1.999, 4}]
fake_config = MagicMock(
data={
"name": "SRP Energy",
"is_tou": ... | [
"async",
"def",
"test_async_setup_entry",
"(",
"hass",
")",
":",
"fake_async_add_entities",
"=",
"MagicMock",
"(",
")",
"fake_srp_energy_client",
"=",
"MagicMock",
"(",
")",
"fake_srp_energy_client",
".",
"usage",
".",
"return_value",
"=",
"[",
"{",
"1",
",",
"2... | [
15,
0
] | [
31,
71
] | python | en | ['en', 'sq', 'en'] | True |
test_async_setup_entry_timeout_error | (hass) | Test fetching usage data. Failed the first time because was too get response. | Test fetching usage data. Failed the first time because was too get response. | async def test_async_setup_entry_timeout_error(hass):
"""Test fetching usage data. Failed the first time because was too get response."""
fake_async_add_entities = MagicMock()
fake_srp_energy_client = MagicMock()
fake_srp_energy_client.usage.return_value = [{1, 2, 3, 1.999, 4}]
fake_config = MagicMo... | [
"async",
"def",
"test_async_setup_entry_timeout_error",
"(",
"hass",
")",
":",
"fake_async_add_entities",
"=",
"MagicMock",
"(",
")",
"fake_srp_energy_client",
"=",
"MagicMock",
"(",
")",
"fake_srp_energy_client",
".",
"usage",
".",
"return_value",
"=",
"[",
"{",
"1... | [
34,
0
] | [
54,
37
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry_connect_error | (hass) | Test fetching usage data. Failed the first time because was too get response. | Test fetching usage data. Failed the first time because was too get response. | async def test_async_setup_entry_connect_error(hass):
"""Test fetching usage data. Failed the first time because was too get response."""
fake_async_add_entities = MagicMock()
fake_srp_energy_client = MagicMock()
fake_srp_energy_client.usage.return_value = [{1, 2, 3, 1.999, 4}]
fake_config = MagicMo... | [
"async",
"def",
"test_async_setup_entry_connect_error",
"(",
"hass",
")",
":",
"fake_async_add_entities",
"=",
"MagicMock",
"(",
")",
"fake_srp_energy_client",
"=",
"MagicMock",
"(",
")",
"fake_srp_energy_client",
".",
"usage",
".",
"return_value",
"=",
"[",
"{",
"1... | [
57,
0
] | [
77,
37
] | python | en | ['en', 'en', 'en'] | True |
test_srp_entity | (hass) | Test the SrpEntity. | Test the SrpEntity. | async def test_srp_entity(hass):
"""Test the SrpEntity."""
fake_coordinator = MagicMock(data=1.99999999999)
srp_entity = SrpEntity(fake_coordinator)
assert srp_entity is not None
assert srp_entity.name == f"{DEFAULT_NAME} {SENSOR_NAME}"
assert srp_entity.unique_id == SENSOR_TYPE
assert srp_... | [
"async",
"def",
"test_srp_entity",
"(",
"hass",
")",
":",
"fake_coordinator",
"=",
"MagicMock",
"(",
"data",
"=",
"1.99999999999",
")",
"srp_entity",
"=",
"SrpEntity",
"(",
"fake_coordinator",
")",
"assert",
"srp_entity",
"is",
"not",
"None",
"assert",
"srp_enti... | [
80,
0
] | [
99,
62
] | python | en | ['en', 'en', 'en'] | True |
test_srp_entity_no_data | (hass) | Test the SrpEntity. | Test the SrpEntity. | async def test_srp_entity_no_data(hass):
"""Test the SrpEntity."""
fake_coordinator = MagicMock(data=False)
srp_entity = SrpEntity(fake_coordinator)
assert srp_entity.device_state_attributes is None | [
"async",
"def",
"test_srp_entity_no_data",
"(",
"hass",
")",
":",
"fake_coordinator",
"=",
"MagicMock",
"(",
"data",
"=",
"False",
")",
"srp_entity",
"=",
"SrpEntity",
"(",
"fake_coordinator",
")",
"assert",
"srp_entity",
".",
"device_state_attributes",
"is",
"Non... | [
102,
0
] | [
106,
53
] | python | en | ['en', 'en', 'en'] | True |
test_srp_entity_no_coord_data | (hass) | Test the SrpEntity. | Test the SrpEntity. | async def test_srp_entity_no_coord_data(hass):
"""Test the SrpEntity."""
fake_coordinator = MagicMock(data=False)
srp_entity = SrpEntity(fake_coordinator)
assert srp_entity.usage is None | [
"async",
"def",
"test_srp_entity_no_coord_data",
"(",
"hass",
")",
":",
"fake_coordinator",
"=",
"MagicMock",
"(",
"data",
"=",
"False",
")",
"srp_entity",
"=",
"SrpEntity",
"(",
"fake_coordinator",
")",
"assert",
"srp_entity",
".",
"usage",
"is",
"None"
] | [
109,
0
] | [
114,
35
] | python | en | ['en', 'en', 'en'] | True |
test_srp_entity_async_update | (hass) | Test the SrpEntity. | Test the SrpEntity. | async def test_srp_entity_async_update(hass):
"""Test the SrpEntity."""
async def async_magic():
pass
MagicMock.__await__ = lambda x: async_magic().__await__()
fake_coordinator = MagicMock(data=False)
srp_entity = SrpEntity(fake_coordinator)
await srp_entity.async_update()
assert ... | [
"async",
"def",
"test_srp_entity_async_update",
"(",
"hass",
")",
":",
"async",
"def",
"async_magic",
"(",
")",
":",
"pass",
"MagicMock",
".",
"__await__",
"=",
"lambda",
"x",
":",
"async_magic",
"(",
")",
".",
"__await__",
"(",
")",
"fake_coordinator",
"=",... | [
117,
0
] | [
128,
56
] | python | en | ['en', 'en', 'en'] | True |
build_nn | () |
Create a function that returns a compiled neural network
:return: compiled Keras neural network model
|
Create a function that returns a compiled neural network
:return: compiled Keras neural network model
| def build_nn():
"""
Create a function that returns a compiled neural network
:return: compiled Keras neural network model
"""
nn = Sequential()
nn.add(Dense(500, activation='relu', input_shape=(N_FEATURES,)))
nn.add(Dense(150, activation='relu'))
nn.add(Dense(N_CLASSES, activation='softm... | [
"def",
"build_nn",
"(",
")",
":",
"nn",
"=",
"Sequential",
"(",
")",
"nn",
".",
"add",
"(",
"Dense",
"(",
"500",
",",
"activation",
"=",
"'relu'",
",",
"input_shape",
"=",
"(",
"N_FEATURES",
",",
")",
")",
")",
"nn",
".",
"add",
"(",
"Dense",
"("... | [
40,
0
] | [
54,
13
] | python | en | ['en', 'error', 'th'] | False |
train_model | (path, model, saveto=None, cv=12, **kwargs) |
Trains model from corpus at specified path;
fitting the model on the full data and
writing it to disk at the saveto directory if specified.
Returns the scores.
|
Trains model from corpus at specified path;
fitting the model on the full data and
writing it to disk at the saveto directory if specified.
Returns the scores.
| def train_model(path, model, saveto=None, cv=12, **kwargs):
"""
Trains model from corpus at specified path;
fitting the model on the full data and
writing it to disk at the saveto directory if specified.
Returns the scores.
"""
# Load the corpus data and labels for classification
# corpu... | [
"def",
"train_model",
"(",
"path",
",",
"model",
",",
"saveto",
"=",
"None",
",",
"cv",
"=",
"12",
",",
"*",
"*",
"kwargs",
")",
":",
"# Load the corpus data and labels for classification",
"# corpus = PickledReviewsReader(path) # for Pitchfork",
"corpus",
"=",
"Pickl... | [
71,
0
] | [
101,
17
] | python | en | ['en', 'error', 'th'] | False |
gen_cim_frame | (port_num: int, vessel_num: int, stop_nums: tuple, snapshots_num: int) | Define and generate cim frame.
Args:
port_num (int): Number of ports.
vessel_num (int): Number of vessels.
stop_nums (tuple): Past stops number and future stop number.
| Define and generate cim frame. | def gen_cim_frame(port_num: int, vessel_num: int, stop_nums: tuple, snapshots_num: int):
"""Define and generate cim frame.
Args:
port_num (int): Number of ports.
vessel_num (int): Number of vessels.
stop_nums (tuple): Past stops number and future stop number.
"""
vessel_cls = ge... | [
"def",
"gen_cim_frame",
"(",
"port_num",
":",
"int",
",",
"vessel_num",
":",
"int",
",",
"stop_nums",
":",
"tuple",
",",
"snapshots_num",
":",
"int",
")",
":",
"vessel_cls",
"=",
"gen_vessel_definition",
"(",
"stop_nums",
")",
"matrix_cls",
"=",
"gen_matrix",
... | [
10,
0
] | [
30,
21
] | python | en | ['en', 'co', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
17,
0
] | [
43,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_invalid_auth | (hass) | Test we handle invalid auth. | Test we handle invalid auth. | async def test_form_invalid_auth(hass):
"""Test we handle invalid auth."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.juicenet.config_flow.Api.get_devices",
side_effect=TokenE... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
46,
0
] | [
61,
56
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.juicenet.config_flow.Api.get_devices",
side_eff... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
64,
0
] | [
79,
58
] | python | en | ['en', 'en', 'en'] | True |
test_form_catch_unknown_errors | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_catch_unknown_errors(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.juicenet.config_flow.Api.get_devices",
si... | [
"async",
"def",
"test_form_catch_unknown_errors",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}... | [
82,
0
] | [
97,
51
] | python | en | ['en', 'en', 'en'] | True |
test_import | (hass) | Test that import works as expected. | Test that import works as expected. | async def test_import(hass):
"""Test that import works as expected."""
with patch(
"homeassistant.components.juicenet.config_flow.Api.get_devices",
return_value=MagicMock(),
), patch(
"homeassistant.components.juicenet.async_setup", return_value=True
) as mock_setup, patch(
... | [
"async",
"def",
"test_import",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.juicenet.config_flow.Api.get_devices\"",
",",
"return_value",
"=",
"MagicMock",
"(",
")",
",",
")",
",",
"patch",
"(",
"\"homeassistant.components.juicenet.async_setup\... | [
100,
0
] | [
122,
48
] | python | en | ['en', 'en', 'en'] | True |
AugustSubscriberMixin.__init__ | (self, hass, update_interval) | Initialize an subscriber. | Initialize an subscriber. | def __init__(self, hass, update_interval):
"""Initialize an subscriber."""
super().__init__()
self._hass = hass
self._update_interval = update_interval
self._subscriptions = {}
self._unsub_interval = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"update_interval",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_update_interval",
"=",
"update_interval",
"self",
".",
"_subscriptions",
"=",
"... | [
10,
4
] | [
16,
35
] | python | en | ['en', 'en', 'en'] | True |
AugustSubscriberMixin.async_subscribe_device_id | (self, device_id, update_callback) | Add an callback subscriber.
Returns a callable that can be used to unsubscribe.
| Add an callback subscriber. | def async_subscribe_device_id(self, device_id, update_callback):
"""Add an callback subscriber.
Returns a callable that can be used to unsubscribe.
"""
if not self._subscriptions:
self._unsub_interval = async_track_time_interval(
self._hass, self._async_refre... | [
"def",
"async_subscribe_device_id",
"(",
"self",
",",
"device_id",
",",
"update_callback",
")",
":",
"if",
"not",
"self",
".",
"_subscriptions",
":",
"self",
".",
"_unsub_interval",
"=",
"async_track_time_interval",
"(",
"self",
".",
"_hass",
",",
"self",
".",
... | [
19,
4
] | [
33,
27
] | python | en | ['en', 'en', 'en'] | True |
AugustSubscriberMixin.async_unsubscribe_device_id | (self, device_id, update_callback) | Remove a callback subscriber. | Remove a callback subscriber. | def async_unsubscribe_device_id(self, device_id, update_callback):
"""Remove a callback subscriber."""
self._subscriptions[device_id].remove(update_callback)
if not self._subscriptions[device_id]:
del self._subscriptions[device_id]
if not self._subscriptions:
self... | [
"def",
"async_unsubscribe_device_id",
"(",
"self",
",",
"device_id",
",",
"update_callback",
")",
":",
"self",
".",
"_subscriptions",
"[",
"device_id",
"]",
".",
"remove",
"(",
"update_callback",
")",
"if",
"not",
"self",
".",
"_subscriptions",
"[",
"device_id",... | [
36,
4
] | [
43,
39
] | python | en | ['es', 'it', 'en'] | False |
AugustSubscriberMixin.async_signal_device_id_update | (self, device_id) | Call the callbacks for a device_id. | Call the callbacks for a device_id. | def async_signal_device_id_update(self, device_id):
"""Call the callbacks for a device_id."""
if not self._subscriptions.get(device_id):
return
for update_callback in self._subscriptions[device_id]:
update_callback() | [
"def",
"async_signal_device_id_update",
"(",
"self",
",",
"device_id",
")",
":",
"if",
"not",
"self",
".",
"_subscriptions",
".",
"get",
"(",
"device_id",
")",
":",
"return",
"for",
"update_callback",
"in",
"self",
".",
"_subscriptions",
"[",
"device_id",
"]",... | [
46,
4
] | [
52,
29
] | python | en | ['en', 'en', 'en'] | True |
mock_controller_client_single | () | Mock a successful client. | Mock a successful client. | def mock_controller_client_single():
"""Mock a successful client."""
with patch(
"homeassistant.components.meteo_france.config_flow.MeteoFranceClient",
update=False,
) as service_mock:
service_mock.return_value.search_places.return_value = [CITY_1]
yield service_mock | [
"def",
"mock_controller_client_single",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteo_france.config_flow.MeteoFranceClient\"",
",",
"update",
"=",
"False",
",",
")",
"as",
"service_mock",
":",
"service_mock",
".",
"return_value",
".",
"search_plac... | [
72,
0
] | [
79,
26
] | python | en | ['en', 'en', 'en'] | True |
mock_setup | () | Prevent setup. | Prevent setup. | def mock_setup():
"""Prevent setup."""
with patch(
"homeassistant.components.meteo_france.async_setup",
return_value=True,
), patch(
"homeassistant.components.meteo_france.async_setup_entry",
return_value=True,
):
yield | [
"def",
"mock_setup",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteo_france.async_setup\"",
",",
"return_value",
"=",
"True",
",",
")",
",",
"patch",
"(",
"\"homeassistant.components.meteo_france.async_setup_entry\"",
",",
"return_value",
"=",
"True... | [
83,
0
] | [
92,
13
] | python | en | ['en', 'pt', 'en'] | False |
mock_controller_client_multiple | () | Mock a successful client. | Mock a successful client. | def mock_controller_client_multiple():
"""Mock a successful client."""
with patch(
"homeassistant.components.meteo_france.config_flow.MeteoFranceClient",
update=False,
) as service_mock:
service_mock.return_value.search_places.return_value = [CITY_2, CITY_3]
yield service_moc... | [
"def",
"mock_controller_client_multiple",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteo_france.config_flow.MeteoFranceClient\"",
",",
"update",
"=",
"False",
",",
")",
"as",
"service_mock",
":",
"service_mock",
".",
"return_value",
".",
"search_pl... | [
96,
0
] | [
103,
26
] | python | en | ['en', 'en', 'en'] | True |
mock_controller_client_empty | () | Mock a successful client. | Mock a successful client. | def mock_controller_client_empty():
"""Mock a successful client."""
with patch(
"homeassistant.components.meteo_france.config_flow.MeteoFranceClient",
update=False,
) as service_mock:
service_mock.return_value.search_places.return_value = []
yield service_mock | [
"def",
"mock_controller_client_empty",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.meteo_france.config_flow.MeteoFranceClient\"",
",",
"update",
"=",
"False",
",",
")",
"as",
"service_mock",
":",
"service_mock",
".",
"return_value",
".",
"search_place... | [
107,
0
] | [
114,
26
] | python | en | ['en', 'en', 'en'] | True |
test_user | (hass, client_single) | Test user config. | Test user config. | async def test_user(hass, client_single):
"""Test user config."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
# test with all provided with sear... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"client_single",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
")",
"assert",
... | [
117,
0
] | [
135,
60
] | python | en | ['en', 'da', 'en'] | True |
test_user_list | (hass, client_multiple) | Test user config. | Test user config. | async def test_user_list(hass, client_multiple):
"""Test user config."""
# test with all provided with search returning more than 1 place
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_CITY: CITY_2_NAME},
)
assert resu... | [
"async",
"def",
"test_user_list",
"(",
"hass",
",",
"client_multiple",
")",
":",
"# test with all provided with search returning more than 1 place",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"... | [
138,
0
] | [
158,
60
] | python | en | ['en', 'da', 'en'] | True |
test_import | (hass, client_multiple) | Test import step. | Test import step. | async def test_import(hass, client_multiple):
"""Test import step."""
# import with all
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={CONF_CITY: CITY_2_NAME},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_... | [
"async",
"def",
"test_import",
"(",
"hass",
",",
"client_multiple",
")",
":",
"# import with all",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_IMPORT... | [
161,
0
] | [
173,
60
] | python | de | ['de', 'sd', 'en'] | False |
test_search_failed | (hass, client_empty) | Test error displayed if no result in search. | Test error displayed if no result in search. | async def test_search_failed(hass, client_empty):
"""Test error displayed if no result in search."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_CITY: CITY_1_POSTAL},
)
assert result["type"] == data_entry_flow.RESULT_TY... | [
"async",
"def",
"test_search_failed",
"(",
"hass",
",",
"client_empty",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"SOURCE_USER",
"}",
",",
"d... | [
176,
0
] | [
185,
51
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_already_setup | (hass, client_single) | Test we abort if already setup. | Test we abort if already setup. | async def test_abort_if_already_setup(hass, client_single):
"""Test we abort if already setup."""
MockConfigEntry(
domain=DOMAIN,
data={CONF_LATITUDE: CITY_1_LAT, CONF_LONGITUDE: CITY_1_LON},
unique_id=f"{CITY_1_LAT}, {CITY_1_LON}",
).add_to_hass(hass)
# Should fail, same CITY s... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
",",
"client_single",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_LATITUDE",
":",
"CITY_1_LAT",
",",
"CONF_LONGITUDE",
":",
"CITY_1_LON",
"}",
",",
"unique_id... | [
188,
0
] | [
212,
51
] | python | en | ['en', 'zu', 'en'] | True |
test_options_flow | (hass: HomeAssistantType) | Test config flow options. | Test config flow options. | async def test_options_flow(hass: HomeAssistantType):
"""Test config flow options."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_LATITUDE: CITY_1_LAT, CONF_LONGITUDE: CITY_1_LON},
unique_id=f"{CITY_1_LAT}, {CITY_1_LON}",
)
config_entry.add_to_hass(hass)
assert... | [
"async",
"def",
"test_options_flow",
"(",
"hass",
":",
"HomeAssistantType",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_LATITUDE",
":",
"CITY_1_LAT",
",",
"CONF_LONGITUDE",
":",
"CITY_1_LON",
"}",
... | [
215,
0
] | [
245,
66
] | python | en | ['en', 'fr', 'en'] | True |
async_setup | (hass, config) | Initialize the Mythic Beasts component. | Initialize the Mythic Beasts component. | async def async_setup(hass, config):
"""Initialize the Mythic Beasts component."""
domain = config[DOMAIN][CONF_DOMAIN]
password = config[DOMAIN][CONF_PASSWORD]
host = config[DOMAIN][CONF_HOST]
update_interval = config[DOMAIN][CONF_SCAN_INTERVAL]
session = async_get_clientsession(hass)
res... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"domain",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_DOMAIN",
"]",
"password",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_PASSWORD",
"]",
"host",
"=",
"config",
"[",
"DOMAIN",
"... | [
37,
0
] | [
57,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass, config, async_add_entities_callback, discovery_info=None
) | Find and return test switches. | Find and return test switches. | async def async_setup_platform(
hass, config, async_add_entities_callback, discovery_info=None
):
"""Find and return test switches."""
pass | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"pass"
] | [
3,
0
] | [
7,
8
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler._set_headers | (self) | Setting up the header response upon connection establishment.
| Setting up the header response upon connection establishment.
| def _set_headers(self):
'''Setting up the header response upon connection establishment.
'''
self.send_response(200)
self.send_header('Content-type','text/json')
# reads the length of the Headers
length = int(self.headers['Content-Length'])
# reads ... | [
"def",
"_set_headers",
"(",
"self",
")",
":",
"self",
".",
"send_response",
"(",
"200",
")",
"self",
".",
"send_header",
"(",
"'Content-type'",
",",
"'text/json'",
")",
"# reads the length of the Headers",
"length",
"=",
"int",
"(",
"self",
".",
"headers",
"["... | [
19,
4
] | [
32,
24
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_VIEW | (self) | Uses VIEW Method to show the value for a given Key from the cb-exporter's targets.json file.
Sample Curl Query: curl -X VIEW --data "tild23.pld.ai" server-url:port-no
| Uses VIEW Method to show the value for a given Key from the cb-exporter's targets.json file.
Sample Curl Query: curl -X VIEW --data "tild23.pld.ai" server-url:port-no
| def do_VIEW(self):
'''Uses VIEW Method to show the value for a given Key from the cb-exporter's targets.json file.
Sample Curl Query: curl -X VIEW --data "tild23.pld.ai" server-url:port-no
'''
# defining all the headers.
display = {}
data_strm = self._set_headers... | [
"def",
"do_VIEW",
"(",
"self",
")",
":",
"# defining all the headers.",
"display",
"=",
"{",
"}",
"data_strm",
"=",
"self",
".",
"_set_headers",
"(",
")",
"display",
"[",
"data_strm",
"]",
"=",
"get_util",
"(",
"data_strm",
")",
"self",
".",
"send_response",... | [
35,
4
] | [
48,
54
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_GET | (self) | Uses GET Method to show all the keys and their respective values from the cb-exporter's targets.json file.
Sample Curl Query: curl -X GET server-url:port-no
| Uses GET Method to show all the keys and their respective values from the cb-exporter's targets.json file.
Sample Curl Query: curl -X GET server-url:port-no
| def do_GET(self):
'''Uses GET Method to show all the keys and their respective values from the cb-exporter's targets.json file.
Sample Curl Query: curl -X GET server-url:port-no
'''
# defining all the headers.
self.send_response(200)
self.send_header('Cont... | [
"def",
"do_GET",
"(",
"self",
")",
":",
"# defining all the headers.",
"self",
".",
"send_response",
"(",
"200",
")",
"self",
".",
"send_header",
"(",
"'Content-type'",
",",
"'text/json'",
")",
"self",
".",
"end_headers",
"(",
")",
"# prints all the keys and value... | [
51,
4
] | [
62,
57
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_POST | (self) | Uses POST Method to get empty port-no to start cb-exporter process & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X POST --data "Hostname,UserName,Password" server-url:port-no
| Uses POST Method to get empty port-no to start cb-exporter process & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X POST --data "Hostname,UserName,Password" server-url:port-no
| def do_POST(self):
'''Uses POST Method to get empty port-no to start cb-exporter process & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X POST --data "Hostname,UserName,Password" server-url:port-no
'''
data_strm = self._set_heade... | [
"def",
"do_POST",
"(",
"self",
")",
":",
"data_strm",
"=",
"self",
".",
"_set_headers",
"(",
")",
"data_strm_list",
"=",
"data_strm",
".",
"split",
"(",
"','",
")",
"# get free port number",
"port_no",
"=",
"get_empty_port",
"(",
")",
"# store key, values in ref... | [
65,
4
] | [
86,
49
] | python | en | ['en', 'en', 'en'] | True |
ServiceHandler.do_DELETE | (self) | Uses DELETE Method to kill a cb-exporter process baed on port-no & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X DELETE --data "Hostname" server-url:port-no
| Uses DELETE Method to kill a cb-exporter process baed on port-no & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X DELETE --data "Hostname" server-url:port-no
| def do_DELETE(self):
'''Uses DELETE Method to kill a cb-exporter process baed on port-no & update targets.json for both our HTTP server and Prometheus.
Sample Curl Query: curl -X DELETE --data "Hostname" server-url:port-no
'''
# receive hostname value as key
data_st... | [
"def",
"do_DELETE",
"(",
"self",
")",
":",
"# receive hostname value as key",
"data_strm",
"=",
"self",
".",
"_set_headers",
"(",
")",
"# delete value from cb-exporter's reference file.",
"str_val",
",",
"port_no",
"=",
"del_util",
"(",
"data_strm",
")",
"eff_mssg",
"... | [
89,
4
] | [
107,
49
] | python | en | ['en', 'en', 'en'] | True |
get_mock_remote | (device_info=MOCK_DEVICE_INFO) | Return a mock remote. | Return a mock remote. | def get_mock_remote(device_info=MOCK_DEVICE_INFO):
"""Return a mock remote."""
mock_remote = Mock()
async def async_create_remote_control(during_setup=False):
return
mock_remote.async_create_remote_control = async_create_remote_control
async def async_get_device_info():
return dev... | [
"def",
"get_mock_remote",
"(",
"device_info",
"=",
"MOCK_DEVICE_INFO",
")",
":",
"mock_remote",
"=",
"Mock",
"(",
")",
"async",
"def",
"async_create_remote_control",
"(",
"during_setup",
"=",
"False",
")",
":",
"return",
"mock_remote",
".",
"async_create_remote_cont... | [
43,
0
] | [
57,
22
] | python | en | ['en', 'co', 'en'] | True |
test_setup_entry_encrypted | (hass) | Test setup with encrypted config entry. | Test setup with encrypted config entry. | async def test_setup_entry_encrypted(hass):
"""Test setup with encrypted config entry."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=MOCK_DEVICE_INFO[ATTR_UDN],
data={**MOCK_CONFIG_DATA, **MOCK_ENCRYPTION_DATA, **MOCK_DEVICE_INFO},
)
mock_entry.add_to_hass(hass)
... | [
"async",
"def",
"test_setup_entry_encrypted",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_DEVICE_INFO",
"[",
"ATTR_UDN",
"]",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_CONFIG_DATA",
",",
... | [
60,
0
] | [
82,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_encrypted_missing_device_info | (hass) | Test setup with encrypted config entry and missing device info. | Test setup with encrypted config entry and missing device info. | async def test_setup_entry_encrypted_missing_device_info(hass):
"""Test setup with encrypted config entry and missing device info."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=MOCK_CONFIG_DATA[CONF_HOST],
data={**MOCK_CONFIG_DATA, **MOCK_ENCRYPTION_DATA},
)
mock_ent... | [
"async",
"def",
"test_setup_entry_encrypted_missing_device_info",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_CONFIG_DATA",
"[",
"CONF_HOST",
"]",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_... | [
85,
0
] | [
110,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_encrypted_missing_device_info_none | (hass) | Test setup with encrypted config entry and device info set to None. | Test setup with encrypted config entry and device info set to None. | async def test_setup_entry_encrypted_missing_device_info_none(hass):
"""Test setup with encrypted config entry and device info set to None."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=MOCK_CONFIG_DATA[CONF_HOST],
data={**MOCK_CONFIG_DATA, **MOCK_ENCRYPTION_DATA},
)
... | [
"async",
"def",
"test_setup_entry_encrypted_missing_device_info_none",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_CONFIG_DATA",
"[",
"CONF_HOST",
"]",
",",
"data",
"=",
"{",
"*",
"*",
"... | [
113,
0
] | [
138,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_unencrypted | (hass) | Test setup with unencrypted config entry. | Test setup with unencrypted config entry. | async def test_setup_entry_unencrypted(hass):
"""Test setup with unencrypted config entry."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=MOCK_DEVICE_INFO[ATTR_UDN],
data={**MOCK_CONFIG_DATA, **MOCK_DEVICE_INFO},
)
mock_entry.add_to_hass(hass)
mock_remote = get_m... | [
"async",
"def",
"test_setup_entry_unencrypted",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_DEVICE_INFO",
"[",
"ATTR_UDN",
"]",
",",
"data",
"=",
"{",
"*",
"*",
"MOCK_CONFIG_DATA",
","... | [
141,
0
] | [
163,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_unencrypted_missing_device_info | (hass) | Test setup with unencrypted config entry and missing device info. | Test setup with unencrypted config entry and missing device info. | async def test_setup_entry_unencrypted_missing_device_info(hass):
"""Test setup with unencrypted config entry and missing device info."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=MOCK_CONFIG_DATA[CONF_HOST],
data=MOCK_CONFIG_DATA,
)
mock_entry.add_to_hass(hass)
... | [
"async",
"def",
"test_setup_entry_unencrypted_missing_device_info",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_CONFIG_DATA",
"[",
"CONF_HOST",
"]",
",",
"data",
"=",
"MOCK_CONFIG_DATA",
","... | [
166,
0
] | [
191,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_unencrypted_missing_device_info_none | (hass) | Test setup with unencrypted config entry and device info set to None. | Test setup with unencrypted config entry and device info set to None. | async def test_setup_entry_unencrypted_missing_device_info_none(hass):
"""Test setup with unencrypted config entry and device info set to None."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=MOCK_CONFIG_DATA[CONF_HOST],
data=MOCK_CONFIG_DATA,
)
mock_entry.add_to_hass(... | [
"async",
"def",
"test_setup_entry_unencrypted_missing_device_info_none",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_CONFIG_DATA",
"[",
"CONF_HOST",
"]",
",",
"data",
"=",
"MOCK_CONFIG_DATA",
... | [
194,
0
] | [
219,
41
] | python | en | ['en', 'en', 'en'] | True |
test_setup_config_flow_initiated | (hass) | Test if config flow is initiated in setup. | Test if config flow is initiated in setup. | async def test_setup_config_flow_initiated(hass):
"""Test if config flow is initiated in setup."""
assert (
await async_setup_component(
hass,
DOMAIN,
{DOMAIN: {CONF_HOST: "0.0.0.0"}},
)
is True
)
assert len(hass.config_entries.flow.async_prog... | [
"async",
"def",
"test_setup_config_flow_initiated",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"CONF_HOST",
":",
"\"0.0.0.0\"",
"}",
"}",
",",
")",
"is",
"True",
")",
"a... | [
222,
0
] | [
233,
62
] | python | en | ['en', 'en', 'en'] | True |
test_setup_unload_entry | (hass) | Test if config entry is unloaded. | Test if config entry is unloaded. | async def test_setup_unload_entry(hass):
"""Test if config entry is unloaded."""
mock_entry = MockConfigEntry(
domain=DOMAIN, unique_id=MOCK_DEVICE_INFO[ATTR_UDN], data=MOCK_CONFIG_DATA
)
mock_entry.add_to_hass(hass)
mock_remote = get_mock_remote()
with patch(
"homeassistant.c... | [
"async",
"def",
"test_setup_unload_entry",
"(",
"hass",
")",
":",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"MOCK_DEVICE_INFO",
"[",
"ATTR_UDN",
"]",
",",
"data",
"=",
"MOCK_CONFIG_DATA",
")",
"mock_entry",
".",
... | [
236,
0
] | [
259,
24
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_devices, discovery_info=None) | Set up the Essent platform. | Set up the Essent platform. | def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Essent platform."""
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
essent = EssentBase(username, password)
meters = []
for meter in essent.retrieve_meters():
data = essent.retrieve_meter... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_devices",
",",
"discovery_info",
"=",
"None",
")",
":",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"config",
"[",
"CONF_PASSWORD",
"]",
"essent",
"=",
"EssentBase",
"(... | [
20,
0
] | [
50,
29
] | python | en | ['en', 'lv', 'en'] | True |
EssentBase.__init__ | (self, username, password) | Initialize the Essent API. | Initialize the Essent API. | def __init__(self, username, password):
"""Initialize the Essent API."""
self._username = username
self._password = password
self._meter_data = {}
self.update() | [
"def",
"__init__",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"_username",
"=",
"username",
"self",
".",
"_password",
"=",
"password",
"self",
".",
"_meter_data",
"=",
"{",
"}",
"self",
".",
"update",
"(",
")"
] | [
56,
4
] | [
62,
21
] | python | en | ['en', 'pt', 'en'] | True |
EssentBase.retrieve_meters | (self) | Retrieve the list of meters. | Retrieve the list of meters. | def retrieve_meters(self):
"""Retrieve the list of meters."""
return self._meter_data.keys() | [
"def",
"retrieve_meters",
"(",
"self",
")",
":",
"return",
"self",
".",
"_meter_data",
".",
"keys",
"(",
")"
] | [
64,
4
] | [
66,
38
] | python | en | ['en', 'af', 'en'] | True |
EssentBase.retrieve_meter_data | (self, meter) | Retrieve the data for this meter. | Retrieve the data for this meter. | def retrieve_meter_data(self, meter):
"""Retrieve the data for this meter."""
return self._meter_data[meter] | [
"def",
"retrieve_meter_data",
"(",
"self",
",",
"meter",
")",
":",
"return",
"self",
".",
"_meter_data",
"[",
"meter",
"]"
] | [
68,
4
] | [
70,
38
] | python | en | ['en', 'en', 'en'] | True |
EssentBase.update | (self) | Retrieve the latest meter data from Essent. | Retrieve the latest meter data from Essent. | def update(self):
"""Retrieve the latest meter data from Essent."""
essent = PyEssent(self._username, self._password)
eans = set(essent.get_EANs())
for possible_meter in eans:
meter_data = essent.read_meter(possible_meter, only_last_meter_reading=True)
if meter_da... | [
"def",
"update",
"(",
"self",
")",
":",
"essent",
"=",
"PyEssent",
"(",
"self",
".",
"_username",
",",
"self",
".",
"_password",
")",
"eans",
"=",
"set",
"(",
"essent",
".",
"get_EANs",
"(",
")",
")",
"for",
"possible_meter",
"in",
"eans",
":",
"mete... | [
73,
4
] | [
80,
61
] | python | en | ['en', 'en', 'en'] | True |
EssentMeter.__init__ | (self, essent_base, meter, meter_type, tariff, unit) | Initialize the sensor. | Initialize the sensor. | def __init__(self, essent_base, meter, meter_type, tariff, unit):
"""Initialize the sensor."""
self._state = None
self._essent_base = essent_base
self._meter = meter
self._type = meter_type
self._tariff = tariff
self._unit = unit | [
"def",
"__init__",
"(",
"self",
",",
"essent_base",
",",
"meter",
",",
"meter_type",
",",
"tariff",
",",
"unit",
")",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_essent_base",
"=",
"essent_base",
"self",
".",
"_meter",
"=",
"meter",
"self",
... | [
86,
4
] | [
93,
25
] | python | en | ['en', 'en', 'en'] | True |
EssentMeter.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> Optional[str]:
"""Return a unique ID."""
return f"{self._meter}-{self._type}-{self._tariff}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"f\"{self._meter}-{self._type}-{self._tariff}\""
] | [
96,
4
] | [
98,
59
] | python | ca | ['fr', 'ca', 'en'] | False |
EssentMeter.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"Essent {self._type} ({self._tariff})" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"Essent {self._type} ({self._tariff})\""
] | [
101,
4
] | [
103,
54
] | python | en | ['en', 'mi', 'en'] | True |
EssentMeter.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"
] | [
106,
4
] | [
108,
26
] | python | en | ['en', 'en', 'en'] | True |
EssentMeter.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
if self._unit.lower() == "kwh":
return ENERGY_KILO_WATT_HOUR
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unit",
".",
"lower",
"(",
")",
"==",
"\"kwh\"",
":",
"return",
"ENERGY_KILO_WATT_HOUR",
"return",
"self",
".",
"_unit"
] | [
111,
4
] | [
116,
25
] | python | en | ['en', 'la', 'en'] | True |
EssentMeter.update | (self) | Fetch the energy usage. | Fetch the energy usage. | def update(self):
"""Fetch the energy usage."""
# Ensure our data isn't too old
self._essent_base.update()
# Retrieve our meter
data = self._essent_base.retrieve_meter_data(self._meter)
# Set our value
self._state = next(
iter(data["values"]["LVR"][s... | [
"def",
"update",
"(",
"self",
")",
":",
"# Ensure our data isn't too old",
"self",
".",
"_essent_base",
".",
"update",
"(",
")",
"# Retrieve our meter",
"data",
"=",
"self",
".",
"_essent_base",
".",
"retrieve_meter_data",
"(",
"self",
".",
"_meter",
")",
"# Set... | [
118,
4
] | [
129,
9
] | python | en | ['en', 'en', 'en'] | True |
turn_on | (hass, entity_id=None, **service_data) | Turn specified entity on if possible.
This is a legacy helper method. Do not use it for new tests.
| Turn specified entity on if possible. | def turn_on(hass, entity_id=None, **service_data):
"""Turn specified entity on if possible.
This is a legacy helper method. Do not use it for new tests.
"""
if entity_id is not None:
service_data[ATTR_ENTITY_ID] = entity_id
hass.services.call(ha.DOMAIN, SERVICE_TURN_ON, service_data) | [
"def",
"turn_on",
"(",
"hass",
",",
"entity_id",
"=",
"None",
",",
"*",
"*",
"service_data",
")",
":",
"if",
"entity_id",
"is",
"not",
"None",
":",
"service_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
"hass",
".",
"services",
".",
"call",
"(",
... | [
44,
0
] | [
52,
64
] | python | en | ['en', 'en', 'en'] | True |
turn_off | (hass, entity_id=None, **service_data) | Turn specified entity off.
This is a legacy helper method. Do not use it for new tests.
| Turn specified entity off. | def turn_off(hass, entity_id=None, **service_data):
"""Turn specified entity off.
This is a legacy helper method. Do not use it for new tests.
"""
if entity_id is not None:
service_data[ATTR_ENTITY_ID] = entity_id
hass.services.call(ha.DOMAIN, SERVICE_TURN_OFF, service_data) | [
"def",
"turn_off",
"(",
"hass",
",",
"entity_id",
"=",
"None",
",",
"*",
"*",
"service_data",
")",
":",
"if",
"entity_id",
"is",
"not",
"None",
":",
"service_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
"hass",
".",
"services",
".",
"call",
"(",
... | [
55,
0
] | [
63,
65
] | python | en | ['en', 'en', 'en'] | True |
toggle | (hass, entity_id=None, **service_data) | Toggle specified entity.
This is a legacy helper method. Do not use it for new tests.
| Toggle specified entity. | def toggle(hass, entity_id=None, **service_data):
"""Toggle specified entity.
This is a legacy helper method. Do not use it for new tests.
"""
if entity_id is not None:
service_data[ATTR_ENTITY_ID] = entity_id
hass.services.call(ha.DOMAIN, SERVICE_TOGGLE, service_data) | [
"def",
"toggle",
"(",
"hass",
",",
"entity_id",
"=",
"None",
",",
"*",
"*",
"service_data",
")",
":",
"if",
"entity_id",
"is",
"not",
"None",
":",
"service_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
"hass",
".",
"services",
".",
"call",
"(",
... | [
66,
0
] | [
74,
63
] | python | en | ['en', 'en', 'en'] | True |
stop | (hass) | Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
| Stop Home Assistant. | def stop(hass):
"""Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP) | [
"def",
"stop",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_HOMEASSISTANT_STOP",
")"
] | [
77,
0
] | [
82,
61
] | python | en | ['en', 'en', 'en'] | True |
restart | (hass) | Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
| Stop Home Assistant. | def restart(hass):
"""Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_HOMEASSISTANT_RESTART) | [
"def",
"restart",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_HOMEASSISTANT_RESTART",
")"
] | [
85,
0
] | [
90,
64
] | python | en | ['en', 'en', 'en'] | True |
check_config | (hass) | Check the config files.
This is a legacy helper method. Do not use it for new tests.
| Check the config files. | def check_config(hass):
"""Check the config files.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_CHECK_CONFIG) | [
"def",
"check_config",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_CHECK_CONFIG",
")"
] | [
93,
0
] | [
98,
55
] | python | en | ['en', 'en', 'en'] | True |
reload_core_config | (hass) | Reload the core config.
This is a legacy helper method. Do not use it for new tests.
| Reload the core config. | def reload_core_config(hass):
"""Reload the core config.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG) | [
"def",
"reload_core_config",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_RELOAD_CORE_CONFIG",
")"
] | [
101,
0
] | [
106,
61
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_to_not_block_for_domains_without_service | (hass) | Test if turn_on is blocking domain with no service. | Test if turn_on is blocking domain with no service. | async def test_turn_on_to_not_block_for_domains_without_service(hass):
"""Test if turn_on is blocking domain with no service."""
await async_setup_component(hass, "homeassistant", {})
async_mock_service(hass, "light", SERVICE_TURN_ON)
hass.states.async_set("light.Bowl", STATE_ON)
hass.states.async_s... | [
"async",
"def",
"test_turn_on_to_not_block_for_domains_without_service",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"async_mock_service",
"(",
"hass",
",",
"\"light\"",
",",
"SERVICE_TURN_ON",
")... | [
250,
0
] | [
285,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entity_update | (hass) | Test being able to call entity update. | Test being able to call entity update. | async def test_entity_update(hass):
"""Test being able to call entity update."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.helpers.entity_component.async_update_entity",
return_value=None,
) as mock_update:
await hass.services.async_call(
... | [
"async",
"def",
"test_entity_update",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.entity_component.async_update_entity\"",
",",
"return_value",
"=",
... | [
288,
0
] | [
304,
61
] | python | en | ['en', 'en', 'en'] | True |
test_setting_location | (hass) | Test setting the location. | Test setting the location. | async def test_setting_location(hass):
"""Test setting the location."""
await async_setup_component(hass, "homeassistant", {})
events = async_capture_events(hass, EVENT_CORE_CONFIG_UPDATE)
# Just to make sure that we are updating values.
assert hass.config.latitude != 30
assert hass.config.longi... | [
"async",
"def",
"test_setting_location",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"EVENT_CORE_CONFIG_UPDATE",
")",
"# Just to make sur... | [
307,
0
] | [
322,
38
] | python | en | ['en', 'en', 'en'] | True |
test_require_admin | (hass, hass_read_only_user) | Test services requiring admin. | Test services requiring admin. | async def test_require_admin(hass, hass_read_only_user):
"""Test services requiring admin."""
await async_setup_component(hass, "homeassistant", {})
for service in (
SERVICE_HOMEASSISTANT_RESTART,
SERVICE_HOMEASSISTANT_STOP,
SERVICE_CHECK_CONFIG,
SERVICE_RELOAD_CORE_CONFIG,
... | [
"async",
"def",
"test_require_admin",
"(",
"hass",
",",
"hass_read_only_user",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"for",
"service",
"in",
"(",
"SERVICE_HOMEASSISTANT_RESTART",
",",
"SERVICE_HOMEASSI... | [
325,
0
] | [
352,
9
] | 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.