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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ParserElement.ignore | ( self, other ) |
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj /* comment */ lskjd')... |
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj /* comment */ lskjd')... | def ignore( self, other ):
"""
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.p... | [
"def",
"ignore",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"Suppress",
"(",
"other",
")",
"if",
"isinstance",
"(",
"other",
",",
"Suppress",
")",
":",
"if",
"other",
"not",
"in",... | [
2078,
4
] | [
2099,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.setDebugActions | ( self, startAction, successAction, exceptionAction ) |
Enable display of debugging messages while doing pattern matching.
|
Enable display of debugging messages while doing pattern matching.
| def setDebugActions( self, startAction, successAction, exceptionAction ):
"""
Enable display of debugging messages while doing pattern matching.
"""
self.debugActions = (startAction or _defaultStartDebugAction,
successAction or _defaultSuccessDebugAction... | [
"def",
"setDebugActions",
"(",
"self",
",",
"startAction",
",",
"successAction",
",",
"exceptionAction",
")",
":",
"self",
".",
"debugActions",
"=",
"(",
"startAction",
"or",
"_defaultStartDebugAction",
",",
"successAction",
"or",
"_defaultSuccessDebugAction",
",",
... | [
2101,
4
] | [
2109,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.setDebug | ( self, flag=True ) |
Enable display of debugging messages while doing pattern matching.
Set C{flag} to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd | integer
... |
Enable display of debugging messages while doing pattern matching.
Set C{flag} to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd | integer
... | def setDebug( self, flag=True ):
"""
Enable display of debugging messages while doing pattern matching.
Set C{flag} to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
t... | [
"def",
"setDebug",
"(",
"self",
",",
"flag",
"=",
"True",
")",
":",
"if",
"flag",
":",
"self",
".",
"setDebugActions",
"(",
"_defaultStartDebugAction",
",",
"_defaultSuccessDebugAction",
",",
"_defaultExceptionDebugAction",
")",
"else",
":",
"self",
".",
"debug"... | [
2111,
4
] | [
2150,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.validate | ( self, validateTrace=[] ) |
Check defined expressions for valid structure, check for infinite recursive definitions.
|
Check defined expressions for valid structure, check for infinite recursive definitions.
| def validate( self, validateTrace=[] ):
"""
Check defined expressions for valid structure, check for infinite recursive definitions.
"""
self.checkRecursion( [] ) | [
"def",
"validate",
"(",
"self",
",",
"validateTrace",
"=",
"[",
"]",
")",
":",
"self",
".",
"checkRecursion",
"(",
"[",
"]",
")"
] | [
2166,
4
] | [
2170,
33
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.parseFile | ( self, file_or_filename, parseAll=False ) |
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
|
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
| def parseFile( self, file_or_filename, parseAll=False ):
"""
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
"""
try:
file_con... | [
"def",
"parseFile",
"(",
"self",
",",
"file_or_filename",
",",
"parseAll",
"=",
"False",
")",
":",
"try",
":",
"file_contents",
"=",
"file_or_filename",
".",
"read",
"(",
")",
"except",
"AttributeError",
":",
"with",
"open",
"(",
"file_or_filename",
",",
"\"... | [
2172,
4
] | [
2190,
25
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.matches | (self, testString, parseAll=True) |
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.
Parameters:
- testString - to test against this expression for a match
- parseAll - (default=C{True}) - flag to ... |
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.
Parameters:
- testString - to test against this expression for a match
- parseAll - (default=C{True}) - flag to ... | def matches(self, testString, parseAll=True):
"""
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.
Parameters:
- testString - to test against this expression for a... | [
"def",
"matches",
"(",
"self",
",",
"testString",
",",
"parseAll",
"=",
"True",
")",
":",
"try",
":",
"self",
".",
"parseString",
"(",
"_ustr",
"(",
"testString",
")",
",",
"parseAll",
"=",
"parseAll",
")",
"return",
"True",
"except",
"ParseBaseException",... | [
2212,
4
] | [
2229,
24
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.runTests | (self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False) |
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression against a list of sample strings.
Parameters:
- tests - a list of separate test strings, or ... |
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression against a list of sample strings.
Parameters:
- tests - a list of separate test strings, or ... | def runTests(self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False):
"""
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression aga... | [
"def",
"runTests",
"(",
"self",
",",
"tests",
",",
"parseAll",
"=",
"True",
",",
"comment",
"=",
"'#'",
",",
"fullDump",
"=",
"True",
",",
"printResults",
"=",
"True",
",",
"failureTests",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"tests",
",",
... | [
2231,
4
] | [
2360,
34
] | python | en | ['en', 'ja', 'th'] | False |
test_component_unload_config_entry | (hass, config_entry) | Test that loading and unloading of a config entry works. | Test that loading and unloading of a config entry works. | async def test_component_unload_config_entry(hass, config_entry):
"""Test that loading and unloading of a config entry works."""
config_entry.add_to_hass(hass)
with patch("aio_georss_gdacs.GdacsFeedManager.update") as mock_feed_manager_update:
# Load config entry.
assert await hass.config_en... | [
"async",
"def",
"test_component_unload_config_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"aio_georss_gdacs.GdacsFeedManager.update\"",
")",
"as",
"mock_feed_manager_update",
":",
"# L... | [
6,
0
] | [
18,
73
] | python | en | ['en', 'en', 'en'] | True |
call | (cmd,
timeout=None,
signum=signal.SIGKILL,
keep_rc=False,
encoding="utf-8",
env=os.environ) |
Execute a cmd or list of commands with an optional timeout in seconds.
If `timeout` is supplied and expires, the process is killed with
SIGKILL (kill -9) and an exception is raised. Otherwise, the command
output is returned.
Parameters
----------
cmd: str or [[str]]
The command(s)... |
Execute a cmd or list of commands with an optional timeout in seconds. | def call(cmd,
timeout=None,
signum=signal.SIGKILL,
keep_rc=False,
encoding="utf-8",
env=os.environ):
"""
Execute a cmd or list of commands with an optional timeout in seconds.
If `timeout` is supplied and expires, the process is killed with
SIGKILL (kill -9)... | [
"def",
"call",
"(",
"cmd",
",",
"timeout",
"=",
"None",
",",
"signum",
"=",
"signal",
".",
"SIGKILL",
",",
"keep_rc",
"=",
"False",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"env",
"=",
"os",
".",
"environ",
")",
":",
"if",
"not",
"isinstance",
"(",
... | [
164,
0
] | [
215,
41
] | python | en | ['en', 'error', 'th'] | False |
Pipeline.__init__ | (self, *cmds, **kwargs) |
cmds (list): one or more commands. Each command will be shlex.split if
it isn't already split.
bufsize (int): size of the I/O buffers to use between processes running
the commands. -1 means to use system defaults. 0 means no buffering.
Defaults to -1.
env (di... |
cmds (list): one or more commands. Each command will be shlex.split if
it isn't already split.
bufsize (int): size of the I/O buffers to use between processes running
the commands. -1 means to use system defaults. 0 means no buffering.
Defaults to -1.
env (di... | def __init__(self, *cmds, **kwargs):
"""
cmds (list): one or more commands. Each command will be shlex.split if
it isn't already split.
bufsize (int): size of the I/O buffers to use between processes running
the commands. -1 means to use system defaults. 0 means no buffer... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"cmds",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"bufsize",
"=",
"kwargs",
".",
"get",
"(",
"\"bufsize\"",
",",
"-",
"1",
")",
"self",
".",
"env",
"=",
"kwargs",
".",
"get",
"(",
"\"env\"",
",",
... | [
58,
4
] | [
88,
24
] | python | en | ['en', 'error', 'th'] | False |
Pipeline.__call__ | (self, keep_rc=False) |
Executes the pipeline.
Returns:
The final output of the pipeline if keep_rc is False;
an (exit code, output) tuple if keep_rc is True.
Raises:
CalledProcessError if any return code in the pipeline is nonzero
and keep_rc is False.
|
Executes the pipeline. | def __call__(self, keep_rc=False):
"""
Executes the pipeline.
Returns:
The final output of the pipeline if keep_rc is False;
an (exit code, output) tuple if keep_rc is True.
Raises:
CalledProcessError if any return code in the pipeline is nonzero
... | [
"def",
"__call__",
"(",
"self",
",",
"keep_rc",
"=",
"False",
")",
":",
"p",
"=",
"self",
".",
"_build_pipes",
"(",
")",
"output",
"=",
"p",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
"rc",
"=",
"p",
".",
"poll",
"(",
")",
"if",
"keep_rc",
":... | [
103,
4
] | [
121,
21
] | python | en | ['en', 'error', 'th'] | False |
Pipeline.write | (self, output, mode="w", keep_rc=False) |
Executes the pipeline and writes the results to the supplied output.
If output is a filename and the file didn't already exist before trying
to write, the file will be removed if an exception is raised.
Args:
output (str or file like object): will create a new file of this
... |
Executes the pipeline and writes the results to the supplied output.
If output is a filename and the file didn't already exist before trying
to write, the file will be removed if an exception is raised. | def write(self, output, mode="w", keep_rc=False):
"""
Executes the pipeline and writes the results to the supplied output.
If output is a filename and the file didn't already exist before trying
to write, the file will be removed if an exception is raised.
Args:
outp... | [
"def",
"write",
"(",
"self",
",",
"output",
",",
"mode",
"=",
"\"w\"",
",",
"keep_rc",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"output",
",",
"six",
".",
"string_types",
")",
":",
"already_exists",
"=",
"os",
".",
"path",
".",
"exists",
"(",... | [
123,
4
] | [
161,
62
] | python | en | ['en', 'error', 'th'] | False |
test_boolean | () | Test boolean validation. | Test boolean validation. | def test_boolean():
"""Test boolean validation."""
schema = vol.Schema(cv.boolean)
for value in (
None,
"T",
"negative",
"lock",
"tr ue",
[],
[1, 2],
{"one": "two"},
test_boolean,
):
with pytest.raises(vol.MultipleInvalid)... | [
"def",
"test_boolean",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"boolean",
")",
"for",
"value",
"in",
"(",
"None",
",",
"\"T\"",
",",
"\"negative\"",
",",
"\"lock\"",
",",
"\"tr ue\"",
",",
"[",
"]",
",",
"[",
"1",
",",
... | [
16,
0
] | [
38,
32
] | python | en | ['en', 'et', 'it'] | False |
test_latitude | () | Test latitude validation. | Test latitude validation. | def test_latitude():
"""Test latitude validation."""
schema = vol.Schema(cv.latitude)
for value in ("invalid", None, -91, 91, "-91", "91", "123.01A"):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ("-89", 89, "12.34"):
schema(value) | [
"def",
"test_latitude",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"latitude",
")",
"for",
"value",
"in",
"(",
"\"invalid\"",
",",
"None",
",",
"-",
"91",
",",
"91",
",",
"\"-91\"",
",",
"\"91\"",
",",
"\"123.01A\"",
")",
"... | [
41,
0
] | [
50,
21
] | python | et | ['et', 'et', 'en'] | True |
test_longitude | () | Test longitude validation. | Test longitude validation. | def test_longitude():
"""Test longitude validation."""
schema = vol.Schema(cv.longitude)
for value in ("invalid", None, -181, 181, "-181", "181", "123.01A"):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ("-179", 179, "12.34"):
schema(value) | [
"def",
"test_longitude",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"longitude",
")",
"for",
"value",
"in",
"(",
"\"invalid\"",
",",
"None",
",",
"-",
"181",
",",
"181",
",",
"\"-181\"",
",",
"\"181\"",
",",
"\"123.01A\"",
")... | [
53,
0
] | [
62,
21
] | python | et | ['et', 'et', 'it'] | True |
test_port | () | Test TCP/UDP network port. | Test TCP/UDP network port. | def test_port():
"""Test TCP/UDP network port."""
schema = vol.Schema(cv.port)
for value in ("invalid", None, -1, 0, 80000, "81000"):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ("1000", 21, 24574):
schema(value) | [
"def",
"test_port",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"port",
")",
"for",
"value",
"in",
"(",
"\"invalid\"",
",",
"None",
",",
"-",
"1",
",",
"0",
",",
"80000",
",",
"\"81000\"",
")",
":",
"with",
"pytest",
".",
... | [
65,
0
] | [
74,
21
] | python | da | ['es', 'da', 'en'] | False |
test_isfile | () | Validate that the value is an existing file. | Validate that the value is an existing file. | def test_isfile():
"""Validate that the value is an existing file."""
schema = vol.Schema(cv.isfile)
fake_file = "this-file-does-not.exist"
assert not os.path.isfile(fake_file)
for value in ("invalid", None, -1, 0, 80000, fake_file):
with pytest.raises(vol.Invalid):
schema(valu... | [
"def",
"test_isfile",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"isfile",
")",
"fake_file",
"=",
"\"this-file-does-not.exist\"",
"assert",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fake_file",
")",
"for",
"value",
"in",
"("... | [
77,
0
] | [
93,
26
] | python | en | ['en', 'en', 'en'] | True |
test_platform_config | () | Test platform config validation. | Test platform config validation. | def test_platform_config():
"""Test platform config validation."""
options = ({}, {"hello": "world"})
for value in options:
with pytest.raises(vol.MultipleInvalid):
cv.PLATFORM_SCHEMA(value)
options = ({"platform": "mqtt"}, {"platform": "mqtt", "beer": "yes"})
for value in optio... | [
"def",
"test_platform_config",
"(",
")",
":",
"options",
"=",
"(",
"{",
"}",
",",
"{",
"\"hello\"",
":",
"\"world\"",
"}",
")",
"for",
"value",
"in",
"options",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
"cv",
... | [
141,
0
] | [
150,
38
] | python | da | ['nl', 'da', 'en'] | False |
test_ensure_list | () | Test ensure_list. | Test ensure_list. | def test_ensure_list():
"""Test ensure_list."""
schema = vol.Schema(cv.ensure_list)
assert [] == schema(None)
assert [1] == schema(1)
assert [1] == schema([1])
assert ["1"] == schema("1")
assert ["1"] == schema(["1"])
assert [{"1": "2"}] == schema({"1": "2"}) | [
"def",
"test_ensure_list",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"ensure_list",
")",
"assert",
"[",
"]",
"==",
"schema",
"(",
"None",
")",
"assert",
"[",
"1",
"]",
"==",
"schema",
"(",
"1",
")",
"assert",
"[",
"1",
"... | [
153,
0
] | [
161,
45
] | python | en | ['fr', 'et', 'en'] | False |
test_entity_id | () | Test entity ID validation. | Test entity ID validation. | def test_entity_id():
"""Test entity ID validation."""
schema = vol.Schema(cv.entity_id)
with pytest.raises(vol.MultipleInvalid):
schema("invalid_entity")
assert schema("sensor.LIGHT") == "sensor.light" | [
"def",
"test_entity_id",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"entity_id",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
"schema",
"(",
"\"invalid_entity\"",
")",
"assert",
"schema",
"(... | [
164,
0
] | [
171,
51
] | python | en | ['en', 'et', 'en'] | True |
test_entity_ids | () | Test entity ID validation. | Test entity ID validation. | def test_entity_ids():
"""Test entity ID validation."""
schema = vol.Schema(cv.entity_ids)
options = (
"invalid_entity",
"sensor.light,sensor_invalid",
["invalid_entity"],
["sensor.light", "sensor_invalid"],
["sensor.light,sensor_invalid"],
)
for value in opt... | [
"def",
"test_entity_ids",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"entity_ids",
")",
"options",
"=",
"(",
"\"invalid_entity\"",
",",
"\"sensor.light,sensor_invalid\"",
",",
"[",
"\"invalid_entity\"",
"]",
",",
"[",
"\"sensor.light\"",... | [
174,
0
] | [
193,
86
] | python | en | ['en', 'et', 'en'] | True |
test_entity_domain | () | Test entity domain validation. | Test entity domain validation. | def test_entity_domain():
"""Test entity domain validation."""
schema = vol.Schema(cv.entity_domain("sensor"))
for value in (
"invalid_entity",
"cover.demo",
"cover.demo,sensor.another_entity",
"",
):
with pytest.raises(vol.MultipleInvalid):
schema(va... | [
"def",
"test_entity_domain",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"entity_domain",
"(",
"\"sensor\"",
")",
")",
"for",
"value",
"in",
"(",
"\"invalid_entity\"",
",",
"\"cover.demo\"",
",",
"\"cover.demo,sensor.another_entity\"",
",... | [
196,
0
] | [
218,
65
] | python | en | ['en', 'zu', 'en'] | True |
test_entities_domain | () | Test entities domain validation. | Test entities domain validation. | def test_entities_domain():
"""Test entities domain validation."""
schema = vol.Schema(cv.entities_domain("sensor"))
options = (
None,
"",
"invalid_entity",
["sensor.light", "cover.demo"],
["sensor.light", "sensor_invalid"],
)
for value in options:
w... | [
"def",
"test_entities_domain",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"entities_domain",
"(",
"\"sensor\"",
")",
")",
"options",
"=",
"(",
"None",
",",
"\"\"",
",",
"\"invalid_entity\"",
",",
"[",
"\"sensor.light\"",
",",
"\"co... | [
221,
0
] | [
242,
85
] | python | en | ['fr', 'en', 'en'] | True |
test_ensure_list_csv | () | Test ensure_list_csv. | Test ensure_list_csv. | def test_ensure_list_csv():
"""Test ensure_list_csv."""
schema = vol.Schema(cv.ensure_list_csv)
options = (None, 12, [], ["string"], "string1,string2")
for value in options:
schema(value)
assert schema("string1, string2 ") == ["string1", "string2"] | [
"def",
"test_ensure_list_csv",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"ensure_list_csv",
")",
"options",
"=",
"(",
"None",
",",
"12",
",",
"[",
"]",
",",
"[",
"\"string\"",
"]",
",",
"\"string1,string2\"",
")",
"for",
"valu... | [
245,
0
] | [
253,
64
] | python | be | ['fr', 'be', 'en'] | False |
test_event_schema | () | Test event_schema validation. | Test event_schema validation. | def test_event_schema():
"""Test event_schema validation."""
options = (
{},
None,
{"event_data": {}},
{"event": "state_changed", "event_data": 1},
)
for value in options:
with pytest.raises(vol.MultipleInvalid):
cv.EVENT_SCHEMA(value)
options = (... | [
"def",
"test_event_schema",
"(",
")",
":",
"options",
"=",
"(",
"{",
"}",
",",
"None",
",",
"{",
"\"event_data\"",
":",
"{",
"}",
"}",
",",
"{",
"\"event\"",
":",
"\"state_changed\"",
",",
"\"event_data\"",
":",
"1",
"}",
",",
")",
"for",
"value",
"i... | [
256,
0
] | [
273,
30
] | python | de | ['de', 'de', 'it'] | True |
test_icon | () | Test icon validation. | Test icon validation. | def test_icon():
"""Test icon validation."""
schema = vol.Schema(cv.icon)
for value in (False, "work"):
with pytest.raises(vol.MultipleInvalid):
schema(value)
schema("mdi:work")
schema("custom:prefix") | [
"def",
"test_icon",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"icon",
")",
"for",
"value",
"in",
"(",
"False",
",",
"\"work\"",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
"sche... | [
276,
0
] | [
285,
27
] | python | en | ['es', 'ja', 'en'] | False |
test_time_period | () | Test time_period validation. | Test time_period validation. | def test_time_period():
"""Test time_period validation."""
schema = vol.Schema(cv.time_period)
options = (
None,
"",
"hello:world",
"12:",
"12:34:56:78",
{},
{"wrong_key": -10},
"12.5:30",
"12:30.5",
"12.5:30:30",
"12:3... | [
"def",
"test_time_period",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"time_period",
")",
"options",
"=",
"(",
"None",
",",
"\"\"",
",",
"\"hello:world\"",
",",
"\"12:\"",
",",
"\"12:34:56:78\"",
",",
"{",
"}",
",",
"{",
"\"wro... | [
288,
0
] | [
334,
38
] | python | en | ['da', 'en', 'en'] | True |
test_remove_falsy | () | Test remove falsy. | Test remove falsy. | def test_remove_falsy():
"""Test remove falsy."""
assert cv.remove_falsy([0, None, 1, "1", {}, [], ""]) == [1, "1"] | [
"def",
"test_remove_falsy",
"(",
")",
":",
"assert",
"cv",
".",
"remove_falsy",
"(",
"[",
"0",
",",
"None",
",",
"1",
",",
"\"1\"",
",",
"{",
"}",
",",
"[",
"]",
",",
"\"\"",
"]",
")",
"==",
"[",
"1",
",",
"\"1\"",
"]"
] | [
337,
0
] | [
339,
69
] | python | en | ['en', 'en', 'en'] | True |
test_service | () | Test service validation. | Test service validation. | def test_service():
"""Test service validation."""
schema = vol.Schema(cv.service)
with pytest.raises(vol.MultipleInvalid):
schema("invalid_turn_on")
schema("homeassistant.turn_on") | [
"def",
"test_service",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"service",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
"schema",
"(",
"\"invalid_turn_on\"",
")",
"schema",
"(",
"\"homeass... | [
342,
0
] | [
349,
35
] | python | en | ['en', 'ky', 'en'] | True |
test_service_schema | () | Test service_schema validation. | Test service_schema validation. | def test_service_schema():
"""Test service_schema validation."""
options = (
{},
None,
{
"service": "homeassistant.turn_on",
"service_template": "homeassistant.turn_on",
},
{"data": {"entity_id": "light.kitchen"}},
{"service": "homeassistan... | [
"def",
"test_service_schema",
"(",
")",
":",
"options",
"=",
"(",
"{",
"}",
",",
"None",
",",
"{",
"\"service\"",
":",
"\"homeassistant.turn_on\"",
",",
"\"service_template\"",
":",
"\"homeassistant.turn_on\"",
",",
"}",
",",
"{",
"\"data\"",
":",
"{",
"\"enti... | [
352,
0
] | [
387,
32
] | python | de | ['de', 'de', 'en'] | True |
test_entity_service_schema | () | Test make_entity_service_schema validation. | Test make_entity_service_schema validation. | def test_entity_service_schema():
"""Test make_entity_service_schema validation."""
schema = cv.make_entity_service_schema(
{vol.Required("required"): cv.positive_int, vol.Optional("optional"): cv.string}
)
options = (
{},
None,
{"entity_id": "light.kitchen"},
{"... | [
"def",
"test_entity_service_schema",
"(",
")",
":",
"schema",
"=",
"cv",
".",
"make_entity_service_schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"\"required\"",
")",
":",
"cv",
".",
"positive_int",
",",
"vol",
".",
"Optional",
"(",
"\"optional\"",
")",
":"... | [
390,
0
] | [
415,
21
] | python | de | ['de', 'de', 'en'] | True |
test_slug | () | Test slug validation. | Test slug validation. | def test_slug():
"""Test slug validation."""
schema = vol.Schema(cv.slug)
for value in (None, "hello world"):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in (12345, "hello"):
schema(value) | [
"def",
"test_slug",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"slug",
")",
"for",
"value",
"in",
"(",
"None",
",",
"\"hello world\"",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
... | [
418,
0
] | [
427,
21
] | python | et | ['nl', 'et', 'it'] | False |
test_string | (hass) | Test string validation. | Test string validation. | def test_string(hass):
"""Test string validation."""
schema = vol.Schema(cv.string)
with pytest.raises(vol.Invalid):
schema(None)
with pytest.raises(vol.Invalid):
schema([])
with pytest.raises(vol.Invalid):
schema({})
for value in (True, 1, "hello"):
schema(va... | [
"def",
"test_string",
"(",
"hass",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"string",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"None",
")",
"with",
"pytest",
".",
"raises",
"("... | [
430,
0
] | [
457,
37
] | python | en | ['nl', 'sv', 'en'] | False |
test_string_with_no_html | () | Test string with no html validation. | Test string with no html validation. | def test_string_with_no_html():
"""Test string with no html validation."""
schema = vol.Schema(cv.string_with_no_html)
with pytest.raises(vol.Invalid):
schema("This has HTML in it <a>Link</a>")
with pytest.raises(vol.Invalid):
schema("<b>Bold</b>")
for value in (
True,
... | [
"def",
"test_string_with_no_html",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"string_with_no_html",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"\"This has HTML in it <a>Link</a>\"",
")",... | [
460,
0
] | [
477,
21
] | python | en | ['en', 'en', 'en'] | True |
test_temperature_unit | () | Test temperature unit validation. | Test temperature unit validation. | def test_temperature_unit():
"""Test temperature unit validation."""
schema = vol.Schema(cv.temperature_unit)
with pytest.raises(vol.MultipleInvalid):
schema("K")
schema("C")
schema("F") | [
"def",
"test_temperature_unit",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"temperature_unit",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
"schema",
"(",
"\"K\"",
")",
"schema",
"(",
"\"C\"... | [
480,
0
] | [
488,
15
] | python | en | ['nl', 'la', 'en'] | False |
test_x10_address | () | Test x10 addr validator. | Test x10 addr validator. | def test_x10_address():
"""Test x10 addr validator."""
schema = vol.Schema(cv.x10_address)
with pytest.raises(vol.Invalid):
schema("Q1")
schema("q55")
schema("garbage_addr")
schema("a1")
schema("C11") | [
"def",
"test_x10_address",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"x10_address",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"\"Q1\"",
")",
"schema",
"(",
"\"q55\"",
")",
"sc... | [
491,
0
] | [
500,
17
] | python | ar | ['en', 'ar', 'hi'] | False |
test_template | () | Test template validator. | Test template validator. | def test_template():
"""Test template validator."""
schema = vol.Schema(cv.template)
for value in (None, "{{ partial_print }", "{% if True %}Hello", ["test"]):
with pytest.raises(vol.Invalid):
schema(value)
options = (
1,
"Hello",
"{{ beer }}",
"{% i... | [
"def",
"test_template",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"template",
")",
"for",
"value",
"in",
"(",
"None",
",",
"\"{{ partial_print }\"",
",",
"\"{% if True %}Hello\"",
",",
"[",
"\"test\"",
"]",
")",
":",
"with",
"py... | [
503,
0
] | [
518,
21
] | python | en | ['en', 'et', 'en'] | True |
test_dynamic_template | () | Test dynamic template validator. | Test dynamic template validator. | def test_dynamic_template():
"""Test dynamic template validator."""
schema = vol.Schema(cv.dynamic_template)
for value in (
None,
1,
"{{ partial_print }",
"{% if True %}Hello",
["test"],
"just a string",
):
with pytest.raises(vol.Invalid):
... | [
"def",
"test_dynamic_template",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"dynamic_template",
")",
"for",
"value",
"in",
"(",
"None",
",",
"1",
",",
"\"{{ partial_print }\"",
",",
"\"{% if True %}Hello\"",
",",
"[",
"\"test\"",
"]",... | [
521,
0
] | [
541,
21
] | python | en | ['en', 'en', 'en'] | True |
test_template_complex | () | Test template_complex validator. | Test template_complex validator. | def test_template_complex():
"""Test template_complex validator."""
schema = vol.Schema(cv.template_complex)
for value in ("{{ partial_print }", "{% if True %}Hello"):
with pytest.raises(vol.MultipleInvalid):
schema(value)
options = (
1,
"Hello",
"{{ beer }}... | [
"def",
"test_template_complex",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"template_complex",
")",
"for",
"value",
"in",
"(",
"\"{{ partial_print }\"",
",",
"\"{% if True %}Hello\"",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"... | [
544,
0
] | [
575,
37
] | python | en | ['en', 'et', 'en'] | True |
test_time_zone | () | Test time zone validation. | Test time zone validation. | def test_time_zone():
"""Test time zone validation."""
schema = vol.Schema(cv.time_zone)
with pytest.raises(vol.MultipleInvalid):
schema("America/Do_Not_Exist")
schema("America/Los_Angeles")
schema("UTC") | [
"def",
"test_time_zone",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"time_zone",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
":",
"schema",
"(",
"\"America/Do_Not_Exist\"",
")",
"schema",
"(",
"... | [
578,
0
] | [
586,
17
] | python | en | ['nl', 'en', 'en'] | True |
test_date | () | Test date validation. | Test date validation. | def test_date():
"""Test date validation."""
schema = vol.Schema(cv.date)
for value in ["Not a date", "23:42", "2016-11-23T18:59:08"]:
with pytest.raises(vol.Invalid):
schema(value)
schema(datetime.now().date())
schema("2016-11-23") | [
"def",
"test_date",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"date",
")",
"for",
"value",
"in",
"[",
"\"Not a date\"",
",",
"\"23:42\"",
",",
"\"2016-11-23T18:59:08\"",
"]",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
"... | [
589,
0
] | [
598,
24
] | python | de | ['fr', 'de', 'en'] | False |
test_time | () | Test date validation. | Test date validation. | def test_time():
"""Test date validation."""
schema = vol.Schema(cv.time)
for value in ["Not a time", "2016-11-23", "2016-11-23T18:59:08"]:
with pytest.raises(vol.Invalid):
schema(value)
schema(datetime.now().time())
schema("23:42:00")
schema("23:42") | [
"def",
"test_time",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"time",
")",
"for",
"value",
"in",
"[",
"\"Not a time\"",
",",
"\"2016-11-23\"",
",",
"\"2016-11-23T18:59:08\"",
"]",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol"... | [
601,
0
] | [
611,
19
] | python | de | ['fr', 'de', 'en'] | False |
test_datetime | () | Test date time validation. | Test date time validation. | def test_datetime():
"""Test date time validation."""
schema = vol.Schema(cv.datetime)
for value in [date.today(), "Wrong DateTime"]:
with pytest.raises(vol.MultipleInvalid):
schema(value)
schema(datetime.now())
schema("2016-11-23T18:59:08") | [
"def",
"test_datetime",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"datetime",
")",
"for",
"value",
"in",
"[",
"date",
".",
"today",
"(",
")",
",",
"\"Wrong DateTime\"",
"]",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
... | [
614,
0
] | [
622,
33
] | python | en | ['fr', 'en', 'en'] | True |
test_multi_select | () | Test multi select validation.
Expected behavior:
- Will not accept any input but a list
- Will not accept selections outside of configured scope
| Test multi select validation. | def test_multi_select():
"""Test multi select validation.
Expected behavior:
- Will not accept any input but a list
- Will not accept selections outside of configured scope
"""
schema = vol.Schema(cv.multi_select({"paulus": "Paulus", "robban": "Robban"}))
with pytest.raises(vol.Inv... | [
"def",
"test_multi_select",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"multi_select",
"(",
"{",
"\"paulus\"",
":",
"\"Paulus\"",
",",
"\"robban\"",
":",
"\"Robban\"",
"}",
")",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
... | [
625,
0
] | [
638,
32
] | python | en | ['nl', 'et', 'en'] | False |
test_multi_select_in_serializer | () | Test multi_select with custom_serializer. | Test multi_select with custom_serializer. | def test_multi_select_in_serializer():
"""Test multi_select with custom_serializer."""
assert cv.custom_serializer(cv.multi_select({"paulus": "Paulus"})) == {
"type": "multi_select",
"options": {"paulus": "Paulus"},
} | [
"def",
"test_multi_select_in_serializer",
"(",
")",
":",
"assert",
"cv",
".",
"custom_serializer",
"(",
"cv",
".",
"multi_select",
"(",
"{",
"\"paulus\"",
":",
"\"Paulus\"",
"}",
")",
")",
"==",
"{",
"\"type\"",
":",
"\"multi_select\"",
",",
"\"options\"",
":"... | [
641,
0
] | [
646,
5
] | python | en | ['en', 'en', 'en'] | True |
test_boolean_in_serializer | () | Test boolean with custom_serializer. | Test boolean with custom_serializer. | def test_boolean_in_serializer():
"""Test boolean with custom_serializer."""
assert cv.custom_serializer(cv.boolean) == {
"type": "boolean",
} | [
"def",
"test_boolean_in_serializer",
"(",
")",
":",
"assert",
"cv",
".",
"custom_serializer",
"(",
"cv",
".",
"boolean",
")",
"==",
"{",
"\"type\"",
":",
"\"boolean\"",
",",
"}"
] | [
649,
0
] | [
653,
5
] | python | en | ['en', 'en', 'en'] | True |
test_string_in_serializer | () | Test string with custom_serializer. | Test string with custom_serializer. | def test_string_in_serializer():
"""Test string with custom_serializer."""
assert cv.custom_serializer(cv.string) == {
"type": "string",
} | [
"def",
"test_string_in_serializer",
"(",
")",
":",
"assert",
"cv",
".",
"custom_serializer",
"(",
"cv",
".",
"string",
")",
"==",
"{",
"\"type\"",
":",
"\"string\"",
",",
"}"
] | [
656,
0
] | [
660,
5
] | python | en | ['en', 'en', 'en'] | True |
test_positive_time_period_dict_in_serializer | () | Test positive_time_period_dict with custom_serializer. | Test positive_time_period_dict with custom_serializer. | def test_positive_time_period_dict_in_serializer():
"""Test positive_time_period_dict with custom_serializer."""
assert cv.custom_serializer(cv.positive_time_period_dict) == {
"type": "positive_time_period_dict",
} | [
"def",
"test_positive_time_period_dict_in_serializer",
"(",
")",
":",
"assert",
"cv",
".",
"custom_serializer",
"(",
"cv",
".",
"positive_time_period_dict",
")",
"==",
"{",
"\"type\"",
":",
"\"positive_time_period_dict\"",
",",
"}"
] | [
663,
0
] | [
667,
5
] | python | en | ['en', 'en', 'en'] | True |
schema | () | Create a schema used for testing deprecation. | Create a schema used for testing deprecation. | def schema():
"""Create a schema used for testing deprecation."""
return vol.Schema({"venus": cv.boolean, "mars": cv.boolean, "jupiter": cv.boolean}) | [
"def",
"schema",
"(",
")",
":",
"return",
"vol",
".",
"Schema",
"(",
"{",
"\"venus\"",
":",
"cv",
".",
"boolean",
",",
"\"mars\"",
":",
"cv",
".",
"boolean",
",",
"\"jupiter\"",
":",
"cv",
".",
"boolean",
"}",
")"
] | [
671,
0
] | [
673,
87
] | python | en | ['en', 'en', 'en'] | True |
version | (monkeypatch) | Patch the version used for testing to 0.5.0. | Patch the version used for testing to 0.5.0. | def version(monkeypatch):
"""Patch the version used for testing to 0.5.0."""
monkeypatch.setattr(homeassistant.const, "__version__", "0.5.0") | [
"def",
"version",
"(",
"monkeypatch",
")",
":",
"monkeypatch",
".",
"setattr",
"(",
"homeassistant",
".",
"const",
",",
"\"__version__\"",
",",
"\"0.5.0\"",
")"
] | [
677,
0
] | [
679,
68
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_with_no_optionals | (caplog, schema) |
Test deprecation behaves correctly when optional params are None.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
- Processes schema without changing any values
- No warning or difference in output if key is not provided
|
Test deprecation behaves correctly when optional params are None. | def test_deprecated_with_no_optionals(caplog, schema):
"""
Test deprecation behaves correctly when optional params are None.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
- Processes schema without changing any values
- No warning or difference ... | [
"def",
"test_deprecated_with_no_optionals",
"(",
"caplog",
",",
"schema",
")",
":",
"deprecated_schema",
"=",
"vol",
".",
"All",
"(",
"cv",
".",
"deprecated",
"(",
"\"mars\"",
")",
",",
"schema",
")",
"test_data",
"=",
"{",
"\"mars\"",
":",
"True",
"}",
"o... | [
682,
0
] | [
711,
30
] | python | en | ['en', 'error', 'th'] | False |
test_deprecated_with_replacement_key | (caplog, schema) |
Test deprecation behaves correctly when only a replacement key is provided.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
- Processes schema moving the value from key to replacement_key
- Processes schema changing nothing if only replacement_key pr... |
Test deprecation behaves correctly when only a replacement key is provided. | def test_deprecated_with_replacement_key(caplog, schema):
"""
Test deprecation behaves correctly when only a replacement key is provided.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
- Processes schema moving the value from key to replacement_key
... | [
"def",
"test_deprecated_with_replacement_key",
"(",
"caplog",
",",
"schema",
")",
":",
"deprecated_schema",
"=",
"vol",
".",
"All",
"(",
"cv",
".",
"deprecated",
"(",
"\"mars\"",
",",
"replacement_key",
"=",
"\"jupiter\"",
")",
",",
"schema",
")",
"test_data",
... | [
714,
0
] | [
749,
30
] | python | en | ['en', 'error', 'th'] | False |
test_deprecated_with_default | (caplog, schema) |
Test deprecation behaves correctly with a default value.
This is likely a scenario that would never occur.
Expected behavior:
- Behaves identically as when the default value was not present
|
Test deprecation behaves correctly with a default value. | def test_deprecated_with_default(caplog, schema):
"""
Test deprecation behaves correctly with a default value.
This is likely a scenario that would never occur.
Expected behavior:
- Behaves identically as when the default value was not present
"""
deprecated_schema = vol.All(cv.depreca... | [
"def",
"test_deprecated_with_default",
"(",
"caplog",
",",
"schema",
")",
":",
"deprecated_schema",
"=",
"vol",
".",
"All",
"(",
"cv",
".",
"deprecated",
"(",
"\"mars\"",
",",
"default",
"=",
"False",
")",
",",
"schema",
")",
"test_data",
"=",
"{",
"\"mars... | [
752,
0
] | [
778,
30
] | python | en | ['en', 'error', 'th'] | False |
test_deprecated_with_replacement_key_and_default | (caplog, schema) |
Test deprecation with a replacement key and default.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
- Processes schema moving the value from key to replacement_key
- Processes schema changing nothing if only replacement_key provided
- No war... |
Test deprecation with a replacement key and default. | def test_deprecated_with_replacement_key_and_default(caplog, schema):
"""
Test deprecation with a replacement key and default.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
- Processes schema moving the value from key to replacement_key
- Proces... | [
"def",
"test_deprecated_with_replacement_key_and_default",
"(",
"caplog",
",",
"schema",
")",
":",
"deprecated_schema",
"=",
"vol",
".",
"All",
"(",
"cv",
".",
"deprecated",
"(",
"\"mars\"",
",",
"replacement_key",
"=",
"\"jupiter\"",
",",
"default",
"=",
"False",... | [
781,
0
] | [
835,
38
] | python | en | ['en', 'error', 'th'] | False |
test_deprecated_cant_find_module | () | Test if the current module cannot be inspected. | Test if the current module cannot be inspected. | def test_deprecated_cant_find_module():
"""Test if the current module cannot be inspected."""
with patch("inspect.getmodule", return_value=None):
# This used to raise.
cv.deprecated(
"mars",
replacement_key="jupiter",
default=False,
) | [
"def",
"test_deprecated_cant_find_module",
"(",
")",
":",
"with",
"patch",
"(",
"\"inspect.getmodule\"",
",",
"return_value",
"=",
"None",
")",
":",
"# This used to raise.",
"cv",
".",
"deprecated",
"(",
"\"mars\"",
",",
"replacement_key",
"=",
"\"jupiter\"",
",",
... | [
838,
0
] | [
846,
9
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_logger_with_config_attributes | (caplog) | Test if the logger outputs the correct message if the line and file attribute is available in config. | Test if the logger outputs the correct message if the line and file attribute is available in config. | def test_deprecated_logger_with_config_attributes(caplog):
"""Test if the logger outputs the correct message if the line and file attribute is available in config."""
file: str = "configuration.yaml"
line: int = 54
replacement = f"'mars' option near {file}:{line} is deprecated"
config = OrderedDict(... | [
"def",
"test_deprecated_logger_with_config_attributes",
"(",
"caplog",
")",
":",
"file",
":",
"str",
"=",
"\"configuration.yaml\"",
"line",
":",
"int",
"=",
"54",
"replacement",
"=",
"f\"'mars' option near {file}:{line} is deprecated\"",
"config",
"=",
"OrderedDict",
"(",... | [
849,
0
] | [
864,
35
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_logger_with_one_config_attribute | (caplog) | Test if the logger outputs the correct message if only one of line and file attribute is available in config. | Test if the logger outputs the correct message if only one of line and file attribute is available in config. | def test_deprecated_logger_with_one_config_attribute(caplog):
"""Test if the logger outputs the correct message if only one of line and file attribute is available in config."""
file: str = "configuration.yaml"
line: int = 54
replacement = f"'mars' option near {file}:{line} is deprecated"
config = O... | [
"def",
"test_deprecated_logger_with_one_config_attribute",
"(",
"caplog",
")",
":",
"file",
":",
"str",
"=",
"\"configuration.yaml\"",
"line",
":",
"int",
"=",
"54",
"replacement",
"=",
"f\"'mars' option near {file}:{line} is deprecated\"",
"config",
"=",
"OrderedDict",
"... | [
867,
0
] | [
898,
35
] | python | en | ['en', 'en', 'en'] | True |
test_deprecated_logger_without_config_attributes | (caplog) | Test if the logger outputs the correct message if the line and file attribute is not available in config. | Test if the logger outputs the correct message if the line and file attribute is not available in config. | def test_deprecated_logger_without_config_attributes(caplog):
"""Test if the logger outputs the correct message if the line and file attribute is not available in config."""
file: str = "configuration.yaml"
line: int = 54
replacement = f"'mars' option near {file}:{line} is deprecated"
config = Order... | [
"def",
"test_deprecated_logger_without_config_attributes",
"(",
"caplog",
")",
":",
"file",
":",
"str",
"=",
"\"configuration.yaml\"",
"line",
":",
"int",
"=",
"54",
"replacement",
"=",
"f\"'mars' option near {file}:{line} is deprecated\"",
"config",
"=",
"OrderedDict",
"... | [
901,
0
] | [
917,
35
] | python | en | ['en', 'en', 'en'] | True |
test_key_dependency | () | Test key_dependency validator. | Test key_dependency validator. | def test_key_dependency():
"""Test key_dependency validator."""
schema = vol.Schema(cv.key_dependency("beer", "soda"))
options = {"beer": None}
for value in options:
with pytest.raises(vol.MultipleInvalid):
schema(value)
options = ({"beer": None, "soda": None}, {"soda": None}, ... | [
"def",
"test_key_dependency",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"key_dependency",
"(",
"\"beer\"",
",",
"\"soda\"",
")",
")",
"options",
"=",
"{",
"\"beer\"",
":",
"None",
"}",
"for",
"value",
"in",
"options",
":",
"wi... | [
920,
0
] | [
931,
21
] | python | af | ['hu', 'af', 'en'] | False |
test_has_at_most_one_key | () | Test has_at_most_one_key validator. | Test has_at_most_one_key validator. | def test_has_at_most_one_key():
"""Test has_at_most_one_key validator."""
schema = vol.Schema(cv.has_at_most_one_key("beer", "soda"))
for value in (None, [], {"beer": None, "soda": None}):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ({}, {"beer": None}, {"so... | [
"def",
"test_has_at_most_one_key",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"has_at_most_one_key",
"(",
"\"beer\"",
",",
"\"soda\"",
")",
")",
"for",
"value",
"in",
"(",
"None",
",",
"[",
"]",
",",
"{",
"\"beer\"",
":",
"None... | [
934,
0
] | [
943,
21
] | python | en | ['en', 'en', 'it'] | True |
test_has_at_least_one_key | () | Test has_at_least_one_key validator. | Test has_at_least_one_key validator. | def test_has_at_least_one_key():
"""Test has_at_least_one_key validator."""
schema = vol.Schema(cv.has_at_least_one_key("beer", "soda"))
for value in (None, [], {}, {"wine": None}):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ({"beer": None}, {"soda": None},... | [
"def",
"test_has_at_least_one_key",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"has_at_least_one_key",
"(",
"\"beer\"",
",",
"\"soda\"",
")",
")",
"for",
"value",
"in",
"(",
"None",
",",
"[",
"]",
",",
"{",
"}",
",",
"{",
"\"... | [
946,
0
] | [
955,
21
] | python | en | ['en', 'et', 'it'] | False |
test_enum | () | Test enum validator. | Test enum validator. | def test_enum():
"""Test enum validator."""
class TestEnum(enum.Enum):
"""Test enum."""
value1 = "Value 1"
value2 = "Value 2"
schema = vol.Schema(cv.enum(TestEnum))
with pytest.raises(vol.Invalid):
schema("value3") | [
"def",
"test_enum",
"(",
")",
":",
"class",
"TestEnum",
"(",
"enum",
".",
"Enum",
")",
":",
"\"\"\"Test enum.\"\"\"",
"value1",
"=",
"\"Value 1\"",
"value2",
"=",
"\"Value 2\"",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"enum",
"(",
"TestEnum",
... | [
958,
0
] | [
970,
24
] | python | de | ['de', 'et', 'it'] | False |
test_socket_timeout | () | Test socket timeout validator. | Test socket timeout validator. | def test_socket_timeout(): # pylint: disable=invalid-name
"""Test socket timeout validator."""
schema = vol.Schema(cv.socket_timeout)
with pytest.raises(vol.Invalid):
schema(0.0)
with pytest.raises(vol.Invalid):
schema(-1)
assert schema(None) == _GLOBAL_DEFAULT_TIMEOUT
asser... | [
"def",
"test_socket_timeout",
"(",
")",
":",
"# pylint: disable=invalid-name",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"socket_timeout",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"0.0",
")",
"wi... | [
973,
0
] | [
985,
27
] | python | en | ['en', 'et', 'en'] | True |
test_matches_regex | () | Test matches_regex validator. | Test matches_regex validator. | def test_matches_regex():
"""Test matches_regex validator."""
schema = vol.Schema(cv.matches_regex(".*uiae.*"))
with pytest.raises(vol.Invalid):
schema(1.0)
with pytest.raises(vol.Invalid):
schema(" nrtd ")
test_str = "This is a test including uiae."
assert schema(test_str)... | [
"def",
"test_matches_regex",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"matches_regex",
"(",
"\".*uiae.*\"",
")",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"1.0",
")",
"with",
... | [
988,
0
] | [
999,
39
] | python | de | ['nl', 'de', 'it'] | False |
test_is_regex | () | Test the is_regex validator. | Test the is_regex validator. | def test_is_regex():
"""Test the is_regex validator."""
schema = vol.Schema(cv.is_regex)
with pytest.raises(vol.Invalid):
schema("(")
with pytest.raises(vol.Invalid):
schema({"a dict": "is not a regex"})
valid_re = ".*"
schema(valid_re) | [
"def",
"test_is_regex",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"is_regex",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"schema",
"(",
"\"(\"",
")",
"with",
"pytest",
".",
"raises",
"(",
"... | [
1002,
0
] | [
1013,
20
] | python | en | ['en', 'et', 'en'] | True |
test_comp_entity_ids | () | Test config validation for component entity IDs. | Test config validation for component entity IDs. | def test_comp_entity_ids():
"""Test config validation for component entity IDs."""
schema = vol.Schema(cv.comp_entity_ids)
for valid in (
"ALL",
"all",
"AlL",
"light.kitchen",
["light.kitchen"],
["light.kitchen", "light.ceiling"],
[],
):
s... | [
"def",
"test_comp_entity_ids",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"comp_entity_ids",
")",
"for",
"valid",
"in",
"(",
"\"ALL\"",
",",
"\"all\"",
",",
"\"AlL\"",
",",
"\"light.kitchen\"",
",",
"[",
"\"light.kitchen\"",
"]",
"... | [
1016,
0
] | [
1033,
27
] | python | en | ['nb', 'en', 'en'] | True |
test_uuid4_hex | (caplog) | Test uuid validation. | Test uuid validation. | def test_uuid4_hex(caplog):
"""Test uuid validation."""
schema = vol.Schema(cv.uuid4_hex)
for value in ["Not a hex string", "0", 0]:
with pytest.raises(vol.Invalid):
schema(value)
with pytest.raises(vol.Invalid):
# the 13th char should be 4
schema("a03d31b22eee1acc9... | [
"def",
"test_uuid4_hex",
"(",
"caplog",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"uuid4_hex",
")",
"for",
"value",
"in",
"[",
"\"Not a hex string\"",
",",
"\"0\"",
",",
"0",
"]",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
... | [
1036,
0
] | [
1054,
39
] | python | et | ['fi', 'et', 'ur'] | False |
test_key_value_schemas | () | Test key value schemas. | Test key value schemas. | def test_key_value_schemas():
"""Test key value schemas."""
schema = vol.Schema(
cv.key_value_schemas(
"mode",
{
"number": vol.Schema({"mode": "number", "data": int}),
"string": vol.Schema({"mode": "string", "data": str}),
},
)
... | [
"def",
"test_key_value_schemas",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"key_value_schemas",
"(",
"\"mode\"",
",",
"{",
"\"number\"",
":",
"vol",
".",
"Schema",
"(",
"{",
"\"mode\"",
":",
"\"number\"",
",",
"\"data\"",
":",
"... | [
1057,
0
] | [
1090,
44
] | python | de | ['de', 'de', 'en'] | True |
test_script | (caplog) | Test script validation is user friendly. | Test script validation is user friendly. | def test_script(caplog):
"""Test script validation is user friendly."""
for data, msg in (
({"delay": "{{ invalid"}, "should be format 'HH:MM'"),
({"wait_template": "{{ invalid"}, "invalid template"),
({"condition": "invalid"}, "Unexpected value for condition: 'invalid'"),
({"eve... | [
"def",
"test_script",
"(",
"caplog",
")",
":",
"for",
"data",
",",
"msg",
"in",
"(",
"(",
"{",
"\"delay\"",
":",
"\"{{ invalid\"",
"}",
",",
"\"should be format 'HH:MM'\"",
")",
",",
"(",
"{",
"\"wait_template\"",
":",
"\"{{ invalid\"",
"}",
",",
"\"invalid ... | [
1093,
0
] | [
1112,
40
] | python | en | ['en', 'en', 'en'] | True |
test_whitespace | () | Test whitespace validation. | Test whitespace validation. | def test_whitespace():
"""Test whitespace validation."""
schema = vol.Schema(cv.whitespace)
for value in (
None,
"" "T",
"negative",
"lock",
"tr ue",
[],
[1, 2],
{"one": "two"},
):
with pytest.raises(vol.MultipleInvalid):
... | [
"def",
"test_whitespace",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"whitespace",
")",
"for",
"value",
"in",
"(",
"None",
",",
"\"\"",
"\"T\"",
",",
"\"negative\"",
",",
"\"lock\"",
",",
"\"tr ue\"",
",",
"[",
"]",
",",
"["... | [
1115,
0
] | [
1133,
28
] | python | en | ['en', 'zu', 'en'] | True |
test_currency | () | Test currency validator. | Test currency validator. | def test_currency():
"""Test currency validator."""
schema = vol.Schema(cv.currency)
for value in (
None,
"BTC",
):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ("EUR", "USD"):
assert schema(value) | [
"def",
"test_currency",
"(",
")",
":",
"schema",
"=",
"vol",
".",
"Schema",
"(",
"cv",
".",
"currency",
")",
"for",
"value",
"in",
"(",
"None",
",",
"\"BTC\"",
",",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"MultipleInvalid",
")",
... | [
1136,
0
] | [
1148,
28
] | python | en | ['en', 'en', 'en'] | True |
validate_input | (hass: HomeAssistant, data: dict[str, Any]) | Validate the user input allows us to connect. | Validate the user input allows us to connect. | async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
"""Validate the user input allows us to connect."""
account_id = data[ACCOUNT_ID]
password = data[CONF_PASSWORD].replace(" ", "")
token = await adax.get_adax_token(
async_get_clientsession(hass), account_id, password
... | [
"async",
"def",
"validate_input",
"(",
"hass",
":",
"HomeAssistant",
",",
"data",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"account_id",
"=",
"data",
"[",
"ACCOUNT_ID",
"]",
"password",
"=",
"data",
"[",
"CONF_PASSWORD",
"]",
"... | [
25,
0
] | [
35,
27
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle the initial step. | Handle the initial step. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the initial step."""
if user_input is None:
return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA
)
errors = {}
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"... | [
43,
4
] | [
68,
9
] | python | en | ['en', 'en', 'en'] | True |
test_refresh_library | (
hass,
mock_plex_server,
setup_plex_server,
requests_mock,
empty_payload,
plex_server_accounts,
plex_server_base,
) | Test refresh_library service call. | Test refresh_library service call. | async def test_refresh_library(
hass,
mock_plex_server,
setup_plex_server,
requests_mock,
empty_payload,
plex_server_accounts,
plex_server_base,
):
"""Test refresh_library service call."""
url = mock_plex_server.url_in_use
refresh = requests_mock.get(f"{url}/library/sections/1/re... | [
"async",
"def",
"test_refresh_library",
"(",
"hass",
",",
"mock_plex_server",
",",
"setup_plex_server",
",",
"requests_mock",
",",
"empty_payload",
",",
"plex_server_accounts",
",",
"plex_server_base",
",",
")",
":",
"url",
"=",
"mock_plex_server",
".",
"url_in_use",
... | [
24,
0
] | [
97,
34
] | python | en | ['en', 'en', 'en'] | True |
test_scan_clients | (hass, mock_plex_server) | Test scan_for_clients service call. | Test scan_for_clients service call. | async def test_scan_clients(hass, mock_plex_server):
"""Test scan_for_clients service call."""
assert await hass.services.async_call(
DOMAIN,
SERVICE_SCAN_CLIENTS,
blocking=True,
) | [
"async",
"def",
"test_scan_clients",
"(",
"hass",
",",
"mock_plex_server",
")",
":",
"assert",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SCAN_CLIENTS",
",",
"blocking",
"=",
"True",
",",
")"
] | [
100,
0
] | [
106,
5
] | python | en | ['en', 'en', 'en'] | True |
test_sonos_play_media | (
hass,
entry,
setup_plex_server,
requests_mock,
empty_payload,
playqueue_1234,
playqueue_created,
plextv_account,
sonos_resources,
) | Test playback from a Sonos media_player.play_media call. | Test playback from a Sonos media_player.play_media call. | async def test_sonos_play_media(
hass,
entry,
setup_plex_server,
requests_mock,
empty_payload,
playqueue_1234,
playqueue_created,
plextv_account,
sonos_resources,
):
"""Test playback from a Sonos media_player.play_media call."""
media_content_id = (
'{"library_name": ... | [
"async",
"def",
"test_sonos_play_media",
"(",
"hass",
",",
"entry",
",",
"setup_plex_server",
",",
"requests_mock",
",",
"empty_payload",
",",
"playqueue_1234",
",",
"playqueue_created",
",",
"plextv_account",
",",
"sonos_resources",
",",
")",
":",
"media_content_id",... | [
109,
0
] | [
196,
40
] | python | en | ['en', 'en', 'en'] | True |
test_show_config_form | (hass) | Test show configuration form. | Test show configuration form. | async def test_show_config_form(hass):
"""Test show configuration form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["step_id"] == "user" | [
"async",
"def",
"test_show_config_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",... | [
12,
0
] | [
19,
38
] | python | en | ['en', 'fr', 'en'] | True |
test_create_entry | (hass, mock_litejet) | Test create entry from user input. | Test create entry from user input. | async def test_create_entry(hass, mock_litejet):
"""Test create entry from user input."""
test_data = {CONF_PORT: "/dev/test"}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
)
assert result["type"] == "create_entry... | [
"async",
"def",
"test_create_entry",
"(",
"hass",
",",
"mock_litejet",
")",
":",
"test_data",
"=",
"{",
"CONF_PORT",
":",
"\"/dev/test\"",
"}",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"contex... | [
22,
0
] | [
32,
38
] | python | en | ['en', 'en', 'en'] | True |
test_flow_entry_already_exists | (hass) | Test user input when a config entry already exists. | Test user input when a config entry already exists. | async def test_flow_entry_already_exists(hass):
"""Test user input when a config entry already exists."""
first_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_PORT: "/dev/first"},
)
first_entry.add_to_hass(hass)
test_data = {CONF_PORT: "/dev/test"}
result = await hass.confi... | [
"async",
"def",
"test_flow_entry_already_exists",
"(",
"hass",
")",
":",
"first_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_PORT",
":",
"\"/dev/first\"",
"}",
",",
")",
"first_entry",
".",
"add_to_hass",
"(",
"has... | [
35,
0
] | [
50,
56
] | python | en | ['en', 'en', 'en'] | True |
test_flow_open_failed | (hass) | Test user input when serial port open fails. | Test user input when serial port open fails. | async def test_flow_open_failed(hass):
"""Test user input when serial port open fails."""
test_data = {CONF_PORT: "/dev/test"}
with patch("pylitejet.LiteJet") as mock_pylitejet:
mock_pylitejet.side_effect = SerialException
result = await hass.config_entries.flow.async_init(
DOM... | [
"async",
"def",
"test_flow_open_failed",
"(",
"hass",
")",
":",
"test_data",
"=",
"{",
"CONF_PORT",
":",
"\"/dev/test\"",
"}",
"with",
"patch",
"(",
"\"pylitejet.LiteJet\"",
")",
"as",
"mock_pylitejet",
":",
"mock_pylitejet",
".",
"side_effect",
"=",
"SerialExcept... | [
53,
0
] | [
65,
55
] | python | en | ['en', 'lb', 'en'] | True |
test_import_step | (hass) | Test initializing via import step. | Test initializing via import step. | async def test_import_step(hass):
"""Test initializing via import step."""
test_data = {CONF_PORT: "/dev/imported"}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=test_data
)
assert result["type"] == "create_entry"
asse... | [
"async",
"def",
"test_import_step",
"(",
"hass",
")",
":",
"test_data",
"=",
"{",
"CONF_PORT",
":",
"\"/dev/imported\"",
"}",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\... | [
68,
0
] | [
77,
38
] | python | en | ['nl', 'zu', 'en'] | False |
test_options | (hass) | Test updating options. | Test updating options. | async def test_options(hass):
"""Test updating options."""
entry = MockConfigEntry(domain=DOMAIN, data={CONF_PORT: "/dev/test"})
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result... | [
"async",
"def",
"test_options",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_PORT",
":",
"\"/dev/test\"",
"}",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",
"await... | [
80,
0
] | [
96,
58
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the SleepIQ sensors. | Set up the SleepIQ sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the SleepIQ sensors."""
if discovery_info is None:
return
data = hass.data[DOMAIN]
data.update()
dev = []
for bed_id, bed in data.beds.items():
for side in SIDES:
if getattr(bed, side) is... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"data",
".",
"update",
"(",... | [
10,
0
] | [
23,
21
] | python | en | ['en', 'bg', 'en'] | True |
IsInBedBinarySensor.__init__ | (self, sleepiq_data, bed_id, side) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sleepiq_data, bed_id, side):
"""Initialize the sensor."""
super().__init__(sleepiq_data, bed_id, side)
self._state = None
self._name = SENSOR_TYPES[IS_IN_BED]
self.update() | [
"def",
"__init__",
"(",
"self",
",",
"sleepiq_data",
",",
"bed_id",
",",
"side",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"sleepiq_data",
",",
"bed_id",
",",
"side",
")",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_name",
"=",
"SENSO... | [
29,
4
] | [
34,
21
] | python | en | ['en', 'en', 'en'] | True |
IsInBedBinarySensor.is_on | (self) | Return the status of the sensor. | Return the status of the sensor. | def is_on(self):
"""Return the status of the sensor."""
return self._state is True | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"is",
"True"
] | [
37,
4
] | [
39,
34
] | python | en | ['en', 'id', 'en'] | True |
IsInBedBinarySensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
return DEVICE_CLASS_OCCUPANCY | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_OCCUPANCY"
] | [
42,
4
] | [
44,
37
] | python | en | ['en', 'en', 'en'] | True |
IsInBedBinarySensor.update | (self) | Get the latest data from SleepIQ and updates the states. | Get the latest data from SleepIQ and updates the states. | def update(self):
"""Get the latest data from SleepIQ and updates the states."""
super().update()
self._state = self.side.is_in_bed | [
"def",
"update",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"side",
".",
"is_in_bed"
] | [
46,
4
] | [
49,
41
] | python | en | ['en', 'en', 'en'] | True |
async_register | (hass: HomeAssistant, handler: IntentHandler) | Register an intent with Home Assistant. | Register an intent with Home Assistant. | def async_register(hass: HomeAssistant, handler: IntentHandler) -> None:
"""Register an intent with Home Assistant."""
intents = hass.data.get(DATA_KEY)
if intents is None:
intents = hass.data[DATA_KEY] = {}
assert handler.intent_type is not None, "intent_type cannot be None"
if handler.in... | [
"def",
"async_register",
"(",
"hass",
":",
"HomeAssistant",
",",
"handler",
":",
"IntentHandler",
")",
"->",
"None",
":",
"intents",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_KEY",
")",
"if",
"intents",
"is",
"None",
":",
"intents",
"=",
"hass",
... | [
33,
0
] | [
46,
42
] | python | en | ['en', 'en', 'en'] | True |
async_handle | (
hass: HomeAssistant,
platform: str,
intent_type: str,
slots: _SlotsType | None = None,
text_input: str | None = None,
context: Context | None = None,
) | Handle an intent. | Handle an intent. | async def async_handle(
hass: HomeAssistant,
platform: str,
intent_type: str,
slots: _SlotsType | None = None,
text_input: str | None = None,
context: Context | None = None,
) -> IntentResponse:
"""Handle an intent."""
handler: IntentHandler = hass.data.get(DATA_KEY, {}).get(intent_type)... | [
"async",
"def",
"async_handle",
"(",
"hass",
":",
"HomeAssistant",
",",
"platform",
":",
"str",
",",
"intent_type",
":",
"str",
",",
"slots",
":",
"_SlotsType",
"|",
"None",
"=",
"None",
",",
"text_input",
":",
"str",
"|",
"None",
"=",
"None",
",",
"co... | [
50,
0
] | [
79,
77
] | python | en | ['en', 'en', 'en'] | True |
async_match_state | (
hass: HomeAssistant, name: str, states: Iterable[State] | None = None
) | Find a state that matches the name. | Find a state that matches the name. | def async_match_state(
hass: HomeAssistant, name: str, states: Iterable[State] | None = None
) -> State:
"""Find a state that matches the name."""
if states is None:
states = hass.states.async_all()
state = _fuzzymatch(name, states, lambda state: state.name)
if state is None:
raise... | [
"def",
"async_match_state",
"(",
"hass",
":",
"HomeAssistant",
",",
"name",
":",
"str",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"State",
":",
"if",
"states",
"is",
"None",
":",
"states",
"=",
"hass",
".... | [
104,
0
] | [
116,
16
] | python | en | ['en', 'en', 'en'] | True |
async_test_feature | (state: State, feature: int, feature_name: str) | Test if state supports a feature. | Test if state supports a feature. | def async_test_feature(state: State, feature: int, feature_name: str) -> None:
"""Test if state supports a feature."""
if state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) & feature == 0:
raise IntentHandleError(f"Entity {state.name} does not support {feature_name}") | [
"def",
"async_test_feature",
"(",
"state",
":",
"State",
",",
"feature",
":",
"int",
",",
"feature_name",
":",
"str",
")",
"->",
"None",
":",
"if",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_SUPPORTED_FEATURES",
",",
"0",
")",
"&",
"feature",
"==... | [
120,
0
] | [
123,
87
] | python | en | ['en', 'en', 'en'] | True |
_fuzzymatch | (name: str, items: Iterable[T], key: Callable[[T], str]) | Fuzzy matching function. | Fuzzy matching function. | def _fuzzymatch(name: str, items: Iterable[T], key: Callable[[T], str]) -> T | None:
"""Fuzzy matching function."""
matches = []
pattern = ".*?".join(name)
regex = re.compile(pattern, re.IGNORECASE)
for idx, item in enumerate(items):
match = regex.search(key(item))
if match:
... | [
"def",
"_fuzzymatch",
"(",
"name",
":",
"str",
",",
"items",
":",
"Iterable",
"[",
"T",
"]",
",",
"key",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"str",
"]",
")",
"->",
"T",
"|",
"None",
":",
"matches",
"=",
"[",
"]",
"pattern",
"=",
"\".*?\""... | [
165,
0
] | [
179,
53
] | python | en | ['en', 'en', 'en'] | True |
IntentHandler.async_can_handle | (self, intent_obj: Intent) | Test if an intent can be handled. | Test if an intent can be handled. | def async_can_handle(self, intent_obj: Intent) -> bool:
"""Test if an intent can be handled."""
return self.platforms is None or intent_obj.platform in self.platforms | [
"def",
"async_can_handle",
"(",
"self",
",",
"intent_obj",
":",
"Intent",
")",
"->",
"bool",
":",
"return",
"self",
".",
"platforms",
"is",
"None",
"or",
"intent_obj",
".",
"platform",
"in",
"self",
".",
"platforms"
] | [
135,
4
] | [
137,
78
] | python | en | ['en', 'en', 'en'] | True |
IntentHandler.async_validate_slots | (self, slots: _SlotsType) | Validate slot information. | Validate slot information. | def async_validate_slots(self, slots: _SlotsType) -> _SlotsType:
"""Validate slot information."""
if self.slot_schema is None:
return slots
if self._slot_schema is None:
self._slot_schema = vol.Schema(
{
key: SLOT_SCHEMA.extend({"value... | [
"def",
"async_validate_slots",
"(",
"self",
",",
"slots",
":",
"_SlotsType",
")",
"->",
"_SlotsType",
":",
"if",
"self",
".",
"slot_schema",
"is",
"None",
":",
"return",
"slots",
"if",
"self",
".",
"_slot_schema",
"is",
"None",
":",
"self",
".",
"_slot_sch... | [
140,
4
] | [
154,
39
] | python | en | ['en', 'da', 'en'] | True |
IntentHandler.async_handle | (self, intent_obj: Intent) | Handle the intent. | Handle the intent. | async def async_handle(self, intent_obj: Intent) -> IntentResponse:
"""Handle the intent."""
raise NotImplementedError() | [
"async",
"def",
"async_handle",
"(",
"self",
",",
"intent_obj",
":",
"Intent",
")",
"->",
"IntentResponse",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
156,
4
] | [
158,
35
] | python | en | ['en', 'en', 'en'] | True |
IntentHandler.__repr__ | (self) | Represent a string of an intent handler. | Represent a string of an intent handler. | def __repr__(self) -> str:
"""Represent a string of an intent handler."""
return f"<{self.__class__.__name__} - {self.intent_type}>" | [
"def",
"__repr__",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"<{self.__class__.__name__} - {self.intent_type}>\""
] | [
160,
4
] | [
162,
66
] | python | en | ['en', 'lb', 'en'] | True |
ServiceIntentHandler.__init__ | (
self, intent_type: str, domain: str, service: str, speech: str
) | Create Service Intent Handler. | Create Service Intent Handler. | def __init__(
self, intent_type: str, domain: str, service: str, speech: str
) -> None:
"""Create Service Intent Handler."""
self.intent_type = intent_type
self.domain = domain
self.service = service
self.speech = speech | [
"def",
"__init__",
"(",
"self",
",",
"intent_type",
":",
"str",
",",
"domain",
":",
"str",
",",
"service",
":",
"str",
",",
"speech",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"intent_type",
"=",
"intent_type",
"self",
".",
"domain",
"=",
"dom... | [
190,
4
] | [
197,
28
] | python | en | ['en', 'nl', 'en'] | True |
ServiceIntentHandler.async_handle | (self, intent_obj: Intent) | Handle the hass intent. | Handle the hass intent. | async def async_handle(self, intent_obj: Intent) -> IntentResponse:
"""Handle the hass intent."""
hass = intent_obj.hass
slots = self.async_validate_slots(intent_obj.slots)
state = async_match_state(hass, slots["name"]["value"])
await hass.services.async_call(
self.d... | [
"async",
"def",
"async_handle",
"(",
"self",
",",
"intent_obj",
":",
"Intent",
")",
"->",
"IntentResponse",
":",
"hass",
"=",
"intent_obj",
".",
"hass",
"slots",
"=",
"self",
".",
"async_validate_slots",
"(",
"intent_obj",
".",
"slots",
")",
"state",
"=",
... | [
199,
4
] | [
214,
23
] | python | en | ['en', 'en', 'en'] | True |
Intent.__init__ | (
self,
hass: HomeAssistant,
platform: str,
intent_type: str,
slots: _SlotsType,
text_input: str | None,
context: Context,
) | Initialize an intent. | Initialize an intent. | def __init__(
self,
hass: HomeAssistant,
platform: str,
intent_type: str,
slots: _SlotsType,
text_input: str | None,
context: Context,
) -> None:
"""Initialize an intent."""
self.hass = hass
self.platform = platform
self.intent_... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"platform",
":",
"str",
",",
"intent_type",
":",
"str",
",",
"slots",
":",
"_SlotsType",
",",
"text_input",
":",
"str",
"|",
"None",
",",
"context",
":",
"Context",
",",
")",
"->",... | [
222,
4
] | [
237,
30
] | python | en | ['en', 'en', 'en'] | True |
Intent.create_response | (self) | Create a response. | Create a response. | def create_response(self) -> IntentResponse:
"""Create a response."""
return IntentResponse(self) | [
"def",
"create_response",
"(",
"self",
")",
"->",
"IntentResponse",
":",
"return",
"IntentResponse",
"(",
"self",
")"
] | [
240,
4
] | [
242,
35
] | python | en | ['en', 'gl', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.