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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_track_template_unavailable_sates_has_default_rate_limit | (hass) | Test template watching for unavailable states has a rate limit by default. | Test template watching for unavailable states has a rate limit by default. | async def test_track_template_unavailable_sates_has_default_rate_limit(hass):
"""Test template watching for unavailable states has a rate limit by default."""
hass.states.async_set("sensor.zero", "unknown")
template_refresh = Template(
"{{ states | selectattr('state', 'in', ['unavailable', 'unknown'... | [
"async",
"def",
"test_track_template_unavailable_sates_has_default_rate_limit",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.zero\"",
",",
"\"unknown\"",
")",
"template_refresh",
"=",
"Template",
"(",
"\"{{ states | selectattr('state', 'in'... | [
1751,
0
] | [
1789,
23
] | python | en | ['en', 'en', 'en'] | True |
test_specifically_referenced_entity_is_not_rate_limited | (hass) | Test template rate limit of 5 seconds. | Test template rate limit of 5 seconds. | async def test_specifically_referenced_entity_is_not_rate_limited(hass):
"""Test template rate limit of 5 seconds."""
hass.states.async_set("sensor.one", "none")
template_refresh = Template('{{ states | count }}_{{ states("sensor.one") }}', hass)
refresh_runs = []
@ha.callback
def refresh_lis... | [
"async",
"def",
"test_specifically_referenced_entity_is_not_rate_limited",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.one\"",
",",
"\"none\"",
")",
"template_refresh",
"=",
"Template",
"(",
"'{{ states | count }}_{{ states(\"sensor.one\")... | [
1792,
0
] | [
1828,
23
] | python | en | ['en', 'en', 'en'] | True |
test_track_two_templates_with_different_rate_limits | (hass) | Test two templates with different rate limits. | Test two templates with different rate limits. | async def test_track_two_templates_with_different_rate_limits(hass):
"""Test two templates with different rate limits."""
template_one = Template("{{ (states | count) + 0 }}", hass)
template_five = Template("{{ states | count }}", hass)
refresh_runs = {
template_one: [],
template_five: ... | [
"async",
"def",
"test_track_two_templates_with_different_rate_limits",
"(",
"hass",
")",
":",
"template_one",
"=",
"Template",
"(",
"\"{{ (states | count) + 0 }}\"",
",",
"hass",
")",
"template_five",
"=",
"Template",
"(",
"\"{{ states | count }}\"",
",",
"hass",
")",
"... | [
1831,
0
] | [
1893,
23
] | python | en | ['en', 'en', 'en'] | True |
test_string | (hass) | Test a string. | Test a string. | async def test_string(hass):
"""Test a string."""
template_refresh = Template("no_template", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
refresh_runs.append(updates.pop().result)
info = async_track_template_result(
hass, [TrackTemplate(template_r... | [
"async",
"def",
"test_string",
"(",
"hass",
")",
":",
"template_refresh",
"=",
"Template",
"(",
"\"no_template\"",
",",
"hass",
")",
"refresh_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"refresh_listener",
"(",
"event",
",",
"updates",
")",
":... | [
1896,
0
] | [
1913,
42
] | python | en | ['en', 'cy', 'en'] | True |
test_track_template_result_refresh_cancel | (hass) | Test cancelling and refreshing result. | Test cancelling and refreshing result. | async def test_track_template_result_refresh_cancel(hass):
"""Test cancelling and refreshing result."""
template_refresh = Template("{{states.switch.test.state == 'on' and now() }}", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
refresh_runs.append(updates.pop(... | [
"async",
"def",
"test_track_template_result_refresh_cancel",
"(",
"hass",
")",
":",
"template_refresh",
"=",
"Template",
"(",
"\"{{states.switch.test.state == 'on' and now() }}\"",
",",
"hass",
")",
"refresh_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"re... | [
1916,
0
] | [
1967,
35
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_template_result_multiple_templates | (hass) | Test tracking multiple templates. | Test tracking multiple templates. | async def test_async_track_template_result_multiple_templates(hass):
"""Test tracking multiple templates."""
template_1 = Template("{{ states.switch.test.state == 'on' }}")
template_2 = Template("{{ states.switch.test.state == 'on' }}")
template_3 = Template("{{ states.switch.test.state == 'off' }}")
... | [
"async",
"def",
"test_async_track_template_result_multiple_templates",
"(",
"hass",
")",
":",
"template_1",
"=",
"Template",
"(",
"\"{{ states.switch.test.state == 'on' }}\"",
")",
"template_2",
"=",
"Template",
"(",
"\"{{ states.switch.test.state == 'on' }}\"",
")",
"template_... | [
1970,
0
] | [
2026,
5
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_template_result_multiple_templates_mixing_domain | (hass) | Test tracking multiple templates when tracking entities and an entire domain. | Test tracking multiple templates when tracking entities and an entire domain. | async def test_async_track_template_result_multiple_templates_mixing_domain(hass):
"""Test tracking multiple templates when tracking entities and an entire domain."""
template_1 = Template("{{ states.switch.test.state == 'on' }}")
template_2 = Template("{{ states.switch.test.state == 'on' }}")
template... | [
"async",
"def",
"test_async_track_template_result_multiple_templates_mixing_domain",
"(",
"hass",
")",
":",
"template_1",
"=",
"Template",
"(",
"\"{{ states.switch.test.state == 'on' }}\"",
")",
"template_2",
"=",
"Template",
"(",
"\"{{ states.switch.test.state == 'on' }}\"",
")"... | [
2029,
0
] | [
2094,
5
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_template_result_raise_on_template_error | (hass) | Test that we raise as soon as we encounter a failed template. | Test that we raise as soon as we encounter a failed template. | async def test_async_track_template_result_raise_on_template_error(hass):
"""Test that we raise as soon as we encounter a failed template."""
with pytest.raises(TemplateError):
async_track_template_result(
hass,
[
TrackTemplate(
Template(
... | [
"async",
"def",
"test_async_track_template_result_raise_on_template_error",
"(",
"hass",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"TemplateError",
")",
":",
"async_track_template_result",
"(",
"hass",
",",
"[",
"TrackTemplate",
"(",
"Template",
"(",
"\"{{ state... | [
2097,
0
] | [
2113,
9
] | python | en | ['en', 'gd', 'en'] | True |
test_track_template_with_time | (hass) | Test tracking template with time. | Test tracking template with time. | async def test_track_template_with_time(hass):
"""Test tracking template with time."""
hass.states.async_set("switch.test", "on")
specific_runs = []
template_complex = Template("{{ states.switch.test.state and now() }}", hass)
def specific_run_callback(event, updates):
specific_runs.append... | [
"async",
"def",
"test_track_template_with_time",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"switch.test\"",
",",
"\"on\"",
")",
"specific_runs",
"=",
"[",
"]",
"template_complex",
"=",
"Template",
"(",
"\"{{ states.switch.test.state and ... | [
2116,
0
] | [
2144,
23
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_with_time_default | (hass) | Test tracking template with time. | Test tracking template with time. | async def test_track_template_with_time_default(hass):
"""Test tracking template with time."""
specific_runs = []
template_complex = Template("{{ now() }}", hass)
def specific_run_callback(event, updates):
specific_runs.append(updates.pop().result)
info = async_track_template_result(
... | [
"async",
"def",
"test_track_template_with_time_default",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"template_complex",
"=",
"Template",
"(",
"\"{{ now() }}\"",
",",
"hass",
")",
"def",
"specific_run_callback",
"(",
"event",
",",
"updates",
")",
":",
... | [
2147,
0
] | [
2180,
23
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_with_time_that_leaves_scope | (hass) | Test tracking template with time. | Test tracking template with time. | async def test_track_template_with_time_that_leaves_scope(hass):
"""Test tracking template with time."""
now = dt_util.utcnow()
test_time = datetime(now.year + 1, 5, 24, 11, 59, 1, 500000, tzinfo=dt_util.UTC)
with patch("homeassistant.util.dt.utcnow", return_value=test_time):
hass.states.async_... | [
"async",
"def",
"test_track_template_with_time_that_leaves_scope",
"(",
"hass",
")",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"test_time",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"5",
",",
"24",
",",
"11",
",",
"59",
",",
"... | [
2183,
0
] | [
2253,
23
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_template_result_multiple_templates_mixing_listeners | (hass) | Test tracking multiple templates with mixing listener types. | Test tracking multiple templates with mixing listener types. | async def test_async_track_template_result_multiple_templates_mixing_listeners(hass):
"""Test tracking multiple templates with mixing listener types."""
template_1 = Template("{{ states.switch.test.state == 'on' }}")
template_2 = Template("{{ now() and True }}")
refresh_runs = []
@ha.callback
... | [
"async",
"def",
"test_async_track_template_result_multiple_templates_mixing_listeners",
"(",
"hass",
")",
":",
"template_1",
"=",
"Template",
"(",
"\"{{ states.switch.test.state == 'on' }}\"",
")",
"template_2",
"=",
"Template",
"(",
"\"{{ now() and True }}\"",
")",
"refresh_ru... | [
2256,
0
] | [
2321,
5
] | python | en | ['en', 'en', 'en'] | True |
test_track_same_state_simple_no_trigger | (hass) | Test track_same_change with no trigger. | Test track_same_change with no trigger. | async def test_track_same_state_simple_no_trigger(hass):
"""Test track_same_change with no trigger."""
callback_runs = []
period = timedelta(minutes=1)
@ha.callback
def callback_run_callback():
callback_runs.append(1)
async_track_same_state(
hass,
period,
callba... | [
"async",
"def",
"test_track_same_state_simple_no_trigger",
"(",
"hass",
")",
":",
"callback_runs",
"=",
"[",
"]",
"period",
"=",
"timedelta",
"(",
"minutes",
"=",
"1",
")",
"@",
"ha",
".",
"callback",
"def",
"callback_run_callback",
"(",
")",
":",
"callback_ru... | [
2324,
0
] | [
2355,
34
] | python | en | ['en', 'en', 'en'] | True |
test_track_same_state_simple_trigger_check_funct | (hass) | Test track_same_change with trigger and check funct. | Test track_same_change with trigger and check funct. | async def test_track_same_state_simple_trigger_check_funct(hass):
"""Test track_same_change with trigger and check funct."""
callback_runs = []
check_func = []
period = timedelta(minutes=1)
@ha.callback
def callback_run_callback():
callback_runs.append(1)
@ha.callback
def async... | [
"async",
"def",
"test_track_same_state_simple_trigger_check_funct",
"(",
"hass",
")",
":",
"callback_runs",
"=",
"[",
"]",
"check_func",
"=",
"[",
"]",
"period",
"=",
"timedelta",
"(",
"minutes",
"=",
"1",
")",
"@",
"ha",
".",
"callback",
"def",
"callback_run_... | [
2358,
0
] | [
2393,
34
] | python | en | ['en', 'en', 'en'] | True |
test_track_time_interval | (hass) | Test tracking time interval. | Test tracking time interval. | async def test_track_time_interval(hass):
"""Test tracking time interval."""
specific_runs = []
utc_now = dt_util.utcnow()
unsub = async_track_time_interval(
hass, callback(lambda x: specific_runs.append(x)), timedelta(seconds=10)
)
async_fire_time_changed(hass, utc_now + timedelta(sec... | [
"async",
"def",
"test_track_time_interval",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"utc_now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"unsub",
"=",
"async_track_time_interval",
"(",
"hass",
",",
"callback",
"(",
"lambda",
"x",
":",
"specific... | [
2396,
0
] | [
2421,
34
] | python | en | ['vi', 'en', 'en'] | True |
test_track_sunrise | (hass, legacy_patchable_time) | Test track the sunrise. | Test track the sunrise. | async def test_track_sunrise(hass, legacy_patchable_time):
"""Test track the sunrise."""
latitude = 32.87336
longitude = 117.22743
# Setup sun component
hass.config.latitude = latitude
hass.config.longitude = longitude
assert await async_setup_component(
hass, sun.DOMAIN, {sun.DOMAI... | [
"async",
"def",
"test_track_sunrise",
"(",
"hass",
",",
"legacy_patchable_time",
")",
":",
"latitude",
"=",
"32.87336",
"longitude",
"=",
"117.22743",
"# Setup sun component",
"hass",
".",
"config",
".",
"latitude",
"=",
"latitude",
"hass",
".",
"config",
".",
"... | [
2424,
0
] | [
2487,
32
] | python | en | ['en', 'zu', 'en'] | True |
test_track_sunrise_update_location | (hass, legacy_patchable_time) | Test track the sunrise. | Test track the sunrise. | async def test_track_sunrise_update_location(hass, legacy_patchable_time):
"""Test track the sunrise."""
# Setup sun component
hass.config.latitude = 32.87336
hass.config.longitude = 117.22743
assert await async_setup_component(
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
)
... | [
"async",
"def",
"test_track_sunrise_update_location",
"(",
"hass",
",",
"legacy_patchable_time",
")",
":",
"# Setup sun component",
"hass",
".",
"config",
".",
"latitude",
"=",
"32.87336",
"hass",
".",
"config",
".",
"longitude",
"=",
"117.22743",
"assert",
"await",... | [
2490,
0
] | [
2555,
25
] | python | en | ['en', 'zu', 'en'] | True |
test_track_sunset | (hass, legacy_patchable_time) | Test track the sunset. | Test track the sunset. | async def test_track_sunset(hass, legacy_patchable_time):
"""Test track the sunset."""
latitude = 32.87336
longitude = 117.22743
location = LocationInfo(latitude=latitude, longitude=longitude)
# Setup sun component
hass.config.latitude = latitude
hass.config.longitude = longitude
asser... | [
"async",
"def",
"test_track_sunset",
"(",
"hass",
",",
"legacy_patchable_time",
")",
":",
"latitude",
"=",
"32.87336",
"longitude",
"=",
"117.22743",
"location",
"=",
"LocationInfo",
"(",
"latitude",
"=",
"latitude",
",",
"longitude",
"=",
"longitude",
")",
"# S... | [
2558,
0
] | [
2619,
32
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_time_change | (hass) | Test tracking time change. | Test tracking time change. | async def test_async_track_time_change(hass):
"""Test tracking time change."""
wildcard_runs = []
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.year + 1, 5, 24, 11, 59, 55, tzinfo=dt_util.UTC
)
with patch(
"homeassistant.util... | [
"async",
"def",
"test_async_track_time_change",
"(",
"hass",
")",
":",
"wildcard_runs",
"=",
"[",
"]",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"datetime",
"(",
"now",
".",
"yea... | [
2622,
0
] | [
2672,
34
] | python | en | ['vi', 'en', 'en'] | True |
test_periodic_task_minute | (hass) | Test periodic tasks per minute. | Test periodic tasks per minute. | async def test_periodic_task_minute(hass):
"""Test periodic tasks per minute."""
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.year + 1, 5, 24, 11, 59, 55, tzinfo=dt_util.UTC
)
with patch(
"homeassistant.util.dt.utcnow", return_v... | [
"async",
"def",
"test_periodic_task_minute",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"5",
",",
"2... | [
2675,
0
] | [
2716,
34
] | python | ca | ['ca', 'la', 'it'] | False |
test_periodic_task_hour | (hass) | Test periodic tasks per hour. | Test periodic tasks per hour. | async def test_periodic_task_hour(hass):
"""Test periodic tasks per hour."""
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.year + 1, 5, 24, 21, 59, 55, tzinfo=dt_util.UTC
)
with patch(
"homeassistant.util.dt.utcnow", return_value... | [
"async",
"def",
"test_periodic_task_hour",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"5",
",",
"24"... | [
2719,
0
] | [
2776,
34
] | python | en | ['en', 'la', 'it'] | False |
test_periodic_task_wrong_input | (hass) | Test periodic tasks with wrong input. | Test periodic tasks with wrong input. | async def test_periodic_task_wrong_input(hass):
"""Test periodic tasks with wrong input."""
specific_runs = []
now = dt_util.utcnow()
with pytest.raises(ValueError):
async_track_utc_time_change(
hass, callback(lambda x: specific_runs.append(x)), hour="/two"
)
async_fir... | [
"async",
"def",
"test_periodic_task_wrong_input",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
":",
"async_track_utc_time_change",
"(",
"hass",
... | [
2779,
0
] | [
2794,
34
] | python | en | ['en', 'en', 'en'] | True |
test_periodic_task_clock_rollback | (hass) | Test periodic tasks with the time rolling backwards. | Test periodic tasks with the time rolling backwards. | async def test_periodic_task_clock_rollback(hass):
"""Test periodic tasks with the time rolling backwards."""
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.year + 1, 5, 24, 21, 59, 55, tzinfo=dt_util.UTC
)
with patch(
"homeassist... | [
"async",
"def",
"test_periodic_task_clock_rollback",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"5",
"... | [
2797,
0
] | [
2858,
34
] | python | en | ['en', 'en', 'en'] | True |
test_periodic_task_duplicate_time | (hass) | Test periodic tasks not triggering on duplicate time. | Test periodic tasks not triggering on duplicate time. | async def test_periodic_task_duplicate_time(hass):
"""Test periodic tasks not triggering on duplicate time."""
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.year + 1, 5, 24, 21, 59, 55, tzinfo=dt_util.UTC
)
with patch(
"homeassis... | [
"async",
"def",
"test_periodic_task_duplicate_time",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"5",
"... | [
2861,
0
] | [
2900,
11
] | python | en | ['en', 'en', 'en'] | True |
test_periodic_task_entering_dst | (hass) | Test periodic task behavior when entering dst. | Test periodic task behavior when entering dst. | async def test_periodic_task_entering_dst(hass):
"""Test periodic task behavior when entering dst."""
timezone = dt_util.get_time_zone("Europe/Vienna")
dt_util.set_default_time_zone(timezone)
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.y... | [
"async",
"def",
"test_periodic_task_entering_dst",
"(",
"hass",
")",
":",
"timezone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"\"Europe/Vienna\"",
")",
"dt_util",
".",
"set_default_time_zone",
"(",
"timezone",
")",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
... | [
2903,
0
] | [
2949,
11
] | python | en | ['en', 'en', 'en'] | True |
test_periodic_task_leaving_dst | (hass) | Test periodic task behavior when leaving dst. | Test periodic task behavior when leaving dst. | async def test_periodic_task_leaving_dst(hass):
"""Test periodic task behavior when leaving dst."""
timezone = dt_util.get_time_zone("Europe/Vienna")
dt_util.set_default_time_zone(timezone)
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.ye... | [
"async",
"def",
"test_periodic_task_leaving_dst",
"(",
"hass",
")",
":",
"timezone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"\"Europe/Vienna\"",
")",
"dt_util",
".",
"set_default_time_zone",
"(",
"timezone",
")",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"... | [
2952,
0
] | [
3007,
11
] | python | en | ['en', 'en', 'en'] | True |
test_call_later | (hass) | Test calling an action later. | Test calling an action later. | async def test_call_later(hass):
"""Test calling an action later."""
def action():
pass
now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC)
with patch(
"homeassistant.helpers.event.async_track_point_in_utc_time"
) as mock, patch("homeassistant.util.dt.utcnow", return_value... | [
"async",
"def",
"test_call_later",
"(",
"hass",
")",
":",
"def",
"action",
"(",
")",
":",
"pass",
"now",
"=",
"datetime",
"(",
"2017",
",",
"12",
",",
"19",
",",
"15",
",",
"40",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"with",
... | [
3010,
0
] | [
3027,
48
] | python | en | ['en', 'en', 'en'] | True |
test_async_call_later | (hass) | Test calling an action later. | Test calling an action later. | async def test_async_call_later(hass):
"""Test calling an action later."""
def action():
pass
now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC)
with patch(
"homeassistant.helpers.event.async_track_point_in_utc_time"
) as mock, patch("homeassistant.util.dt.utcnow", return... | [
"async",
"def",
"test_async_call_later",
"(",
"hass",
")",
":",
"def",
"action",
"(",
")",
":",
"pass",
"now",
"=",
"datetime",
"(",
"2017",
",",
"12",
",",
"19",
",",
"15",
",",
"40",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"wi... | [
3030,
0
] | [
3048,
27
] | python | en | ['en', 'en', 'en'] | True |
test_async_call_later_timedelta | (hass) | Test calling an action later with a timedelta. | Test calling an action later with a timedelta. | async def test_async_call_later_timedelta(hass):
"""Test calling an action later with a timedelta."""
def action():
pass
now = datetime(2017, 12, 19, 15, 40, 0, tzinfo=dt_util.UTC)
with patch(
"homeassistant.helpers.event.async_track_point_in_utc_time"
) as mock, patch("homeassist... | [
"async",
"def",
"test_async_call_later_timedelta",
"(",
"hass",
")",
":",
"def",
"action",
"(",
")",
":",
"pass",
"now",
"=",
"datetime",
"(",
"2017",
",",
"12",
",",
"19",
",",
"15",
",",
"40",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
... | [
3051,
0
] | [
3069,
27
] | python | en | ['en', 'en', 'en'] | True |
test_track_state_change_event_chain_multple_entity | (hass) | Test that adding a new state tracker inside a tracker does not fire right away. | Test that adding a new state tracker inside a tracker does not fire right away. | async def test_track_state_change_event_chain_multple_entity(hass):
"""Test that adding a new state tracker inside a tracker does not fire right away."""
tracker_called = []
chained_tracker_called = []
chained_tracker_unsub = []
tracker_unsub = []
@ha.callback
def chained_single_run_callba... | [
"async",
"def",
"test_track_state_change_event_chain_multple_entity",
"(",
"hass",
")",
":",
"tracker_called",
"=",
"[",
"]",
"chained_tracker_called",
"=",
"[",
"]",
"chained_tracker_unsub",
"=",
"[",
"]",
"tracker_unsub",
"=",
"[",
"]",
"@",
"ha",
".",
"callback... | [
3072,
0
] | [
3121,
42
] | python | en | ['en', 'en', 'en'] | True |
test_track_state_change_event_chain_single_entity | (hass) | Test that adding a new state tracker inside a tracker does not fire right away. | Test that adding a new state tracker inside a tracker does not fire right away. | async def test_track_state_change_event_chain_single_entity(hass):
"""Test that adding a new state tracker inside a tracker does not fire right away."""
tracker_called = []
chained_tracker_called = []
chained_tracker_unsub = []
tracker_unsub = []
@ha.callback
def chained_single_run_callbac... | [
"async",
"def",
"test_track_state_change_event_chain_single_entity",
"(",
"hass",
")",
":",
"tracker_called",
"=",
"[",
"]",
"chained_tracker_called",
"=",
"[",
"]",
"chained_tracker_unsub",
"=",
"[",
"]",
"tracker_unsub",
"=",
"[",
"]",
"@",
"ha",
".",
"callback"... | [
3124,
0
] | [
3170,
42
] | python | en | ['en', 'en', 'en'] | True |
test_track_point_in_utc_time_cancel | (hass) | Test cancel of async track point in time. | Test cancel of async track point in time. | async def test_track_point_in_utc_time_cancel(hass):
"""Test cancel of async track point in time."""
times = []
@ha.callback
def run_callback(utc_time):
nonlocal times
times.append(utc_time)
def _setup_listeners():
"""Ensure we test the non-async version."""
utc_no... | [
"async",
"def",
"test_track_point_in_utc_time_cancel",
"(",
"hass",
")",
":",
"times",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"run_callback",
"(",
"utc_time",
")",
":",
"nonlocal",
"times",
"times",
".",
"append",
"(",
"utc_time",
")",
"def",
"_... | [
3173,
0
] | [
3204,
41
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_point_in_time_cancel | (hass) | Test cancel of async track point in time. | Test cancel of async track point in time. | async def test_async_track_point_in_time_cancel(hass):
"""Test cancel of async track point in time."""
times = []
hst_tz = dt_util.get_time_zone("US/Hawaii")
dt_util.set_default_time_zone(hst_tz)
@ha.callback
def run_callback(local_time):
nonlocal times
times.append(local_time)... | [
"async",
"def",
"test_async_track_point_in_time_cancel",
"(",
"hass",
")",
":",
"times",
"=",
"[",
"]",
"hst_tz",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"\"US/Hawaii\"",
")",
"dt_util",
".",
"set_default_time_zone",
"(",
"hst_tz",
")",
"@",
"ha",
".",
"cal... | [
3207,
0
] | [
3233,
21
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) | Set up Guardian switches based on a config entry. | Set up Guardian switches based on a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up Guardian switches based on a config entry."""
@callback
def add_new_paired_sensor(uid: str) -> None:
"""Add a new paired sensor."""
coordinator = hass.data[... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
")",
"->",
"None",
":",
"@",
"callback",
"def",
"add_new_paired_sensor",
"(",
"uid",
":",
"str",
")",... | [
61,
0
] | [
108,
31
] | python | en | ['en', 'en', 'en'] | True |
PairedSensorSensor._async_update_from_latest_data | (self) | Update the entity. | Update the entity. | def _async_update_from_latest_data(self) -> None:
"""Update the entity."""
if self.entity_description.key == SENSOR_KIND_BATTERY:
self._attr_native_value = self.coordinator.data["battery"]
elif self.entity_description.key == SENSOR_KIND_TEMPERATURE:
self._attr_native_valu... | [
"def",
"_async_update_from_latest_data",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"entity_description",
".",
"key",
"==",
"SENSOR_KIND_BATTERY",
":",
"self",
".",
"_attr_native_value",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"\"battery\... | [
115,
4
] | [
120,
74
] | python | en | ['en', 'en', 'en'] | True |
ValveControllerSensor._async_continue_entity_setup | (self) | Register API interest (and related tasks) when the entity is added. | Register API interest (and related tasks) when the entity is added. | async def _async_continue_entity_setup(self) -> None:
"""Register API interest (and related tasks) when the entity is added."""
if self.entity_description.key == SENSOR_KIND_TEMPERATURE:
self.async_add_coordinator_update_listener(API_SYSTEM_ONBOARD_SENSOR_STATUS) | [
"async",
"def",
"_async_continue_entity_setup",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"entity_description",
".",
"key",
"==",
"SENSOR_KIND_TEMPERATURE",
":",
"self",
".",
"async_add_coordinator_update_listener",
"(",
"API_SYSTEM_ONBOARD_SENSOR_STATUS",
... | [
126,
4
] | [
129,
88
] | python | en | ['en', 'en', 'en'] | True |
ValveControllerSensor._async_update_from_latest_data | (self) | Update the entity. | Update the entity. | def _async_update_from_latest_data(self) -> None:
"""Update the entity."""
if self.entity_description.key == SENSOR_KIND_TEMPERATURE:
self._attr_available = self.coordinators[
API_SYSTEM_ONBOARD_SENSOR_STATUS
].last_update_success
self._attr_native_val... | [
"def",
"_async_update_from_latest_data",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"entity_description",
".",
"key",
"==",
"SENSOR_KIND_TEMPERATURE",
":",
"self",
".",
"_attr_available",
"=",
"self",
".",
"coordinators",
"[",
"API_SYSTEM_ONBOARD_SENSOR... | [
132,
4
] | [
147,
13
] | python | en | ['en', 'en', 'en'] | True |
test_reload_notify | (hass) | Verify we can reload the notify service. | Verify we can reload the notify service. | async def test_reload_notify(hass):
"""Verify we can reload the notify service."""
respx.get("http://localhost") % 200
assert await async_setup_component(
hass,
notify.DOMAIN,
{
notify.DOMAIN: [
{
"name": DOMAIN,
"p... | [
"async",
"def",
"test_reload_notify",
"(",
"hass",
")",
":",
"respx",
".",
"get",
"(",
"\"http://localhost\"",
")",
"%",
"200",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"notify",
".",
"DOMAIN",
",",
"{",
"notify",
".",
"DOMAIN",
":",
"... | [
14,
0
] | [
50,
68
] | python | en | ['en', 'en', 'en'] | True |
_add_keepdims | (func) | hack in keepdims behavior into a function taking an axis | hack in keepdims behavior into a function taking an axis | def _add_keepdims(func):
""" hack in keepdims behavior into a function taking an axis """
@functools.wraps(func)
def wrapped(a, axis, **kwargs):
res = func(a, axis=axis, **kwargs)
if axis is None:
axis = 0 # res is now a scalar, so we can insert this anywhere
return np.e... | [
"def",
"_add_keepdims",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"a",
",",
"axis",
",",
"*",
"*",
"kwargs",
")",
":",
"res",
"=",
"func",
"(",
"a",
",",
"axis",
"=",
"axis",
",",
"*",
"*",
... | [
18,
0
] | [
26,
18
] | python | en | ['en', 'en', 'en'] | True |
TestTakeAlongAxis.test_argequivalent | (self) | Test it translates from arg<func> to <func> | Test it translates from arg<func> to <func> | def test_argequivalent(self):
""" Test it translates from arg<func> to <func> """
from numpy.random import rand
a = rand(3, 4, 5)
funcs = [
(np.sort, np.argsort, dict()),
(_add_keepdims(np.min), _add_keepdims(np.argmin), dict()),
(_add_keepdims(np.max... | [
"def",
"test_argequivalent",
"(",
"self",
")",
":",
"from",
"numpy",
".",
"random",
"import",
"rand",
"a",
"=",
"rand",
"(",
"3",
",",
"4",
",",
"5",
")",
"funcs",
"=",
"[",
"(",
"np",
".",
"sort",
",",
"np",
".",
"argsort",
",",
"dict",
"(",
"... | [
30,
4
] | [
46,
76
] | python | en | ['en', 'en', 'en'] | True |
TestTakeAlongAxis.test_invalid | (self) | Test it errors when indices has too few dimensions | Test it errors when indices has too few dimensions | def test_invalid(self):
""" Test it errors when indices has too few dimensions """
a = np.ones((10, 10))
ai = np.ones((10, 2), dtype=np.intp)
# sanity check
take_along_axis(a, ai, axis=1)
# not enough indices
assert_raises(ValueError, take_along_axis, a, np.arra... | [
"def",
"test_invalid",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"ones",
"(",
"(",
"10",
",",
"10",
")",
")",
"ai",
"=",
"np",
".",
"ones",
"(",
"(",
"10",
",",
"2",
")",
",",
"dtype",
"=",
"np",
".",
"intp",
")",
"# sanity check",
"take_al... | [
48,
4
] | [
63,
68
] | python | en | ['en', 'en', 'en'] | True |
TestTakeAlongAxis.test_empty | (self) | Test everything is ok with empty results, even with inserted dims | Test everything is ok with empty results, even with inserted dims | def test_empty(self):
""" Test everything is ok with empty results, even with inserted dims """
a = np.ones((3, 4, 5))
ai = np.ones((3, 0, 5), dtype=np.intp)
actual = take_along_axis(a, ai, axis=1)
assert_equal(actual.shape, ai.shape) | [
"def",
"test_empty",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"ones",
"(",
"(",
"3",
",",
"4",
",",
"5",
")",
")",
"ai",
"=",
"np",
".",
"ones",
"(",
"(",
"3",
",",
"0",
",",
"5",
")",
",",
"dtype",
"=",
"np",
".",
"intp",
")",
"actu... | [
65,
4
] | [
71,
44
] | python | en | ['en', 'en', 'en'] | True |
TestTakeAlongAxis.test_broadcast | (self) | Test that non-indexing dimensions are broadcast in both directions | Test that non-indexing dimensions are broadcast in both directions | def test_broadcast(self):
""" Test that non-indexing dimensions are broadcast in both directions """
a = np.ones((3, 4, 1))
ai = np.ones((1, 2, 5), dtype=np.intp)
actual = take_along_axis(a, ai, axis=1)
assert_equal(actual.shape, (3, 2, 5)) | [
"def",
"test_broadcast",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"ones",
"(",
"(",
"3",
",",
"4",
",",
"1",
")",
")",
"ai",
"=",
"np",
".",
"ones",
"(",
"(",
"1",
",",
"2",
",",
"5",
")",
",",
"dtype",
"=",
"np",
".",
"intp",
")",
"... | [
73,
4
] | [
78,
45
] | python | en | ['en', 'en', 'en'] | True |
TestPutAlongAxis.test_broadcast | (self) | Test that non-indexing dimensions are broadcast in both directions | Test that non-indexing dimensions are broadcast in both directions | def test_broadcast(self):
""" Test that non-indexing dimensions are broadcast in both directions """
a = np.ones((3, 4, 1))
ai = np.arange(10, dtype=np.intp).reshape((1, 2, 5)) % 4
put_along_axis(a, ai, 20, axis=1)
assert_equal(take_along_axis(a, ai, axis=1), 20) | [
"def",
"test_broadcast",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"ones",
"(",
"(",
"3",
",",
"4",
",",
"1",
")",
")",
"ai",
"=",
"np",
".",
"arange",
"(",
"10",
",",
"dtype",
"=",
"np",
".",
"intp",
")",
".",
"reshape",
"(",
"(",
"1",
... | [
98,
4
] | [
103,
56
] | python | en | ['en', 'en', 'en'] | True |
TestArraySplit.test_integer_split_2D_default | (self) | This will fail if we change default axis
| This will fail if we change default axis
| def test_integer_split_2D_default(self):
""" This will fail if we change default axis
"""
a = np.array([np.arange(10), np.arange(10)])
res = array_split(a, 3)
tgt = [np.array([np.arange(10)]), np.array([np.arange(10)]),
np.zeros((0, 10))]
compare_result... | [
"def",
"test_integer_split_2D_default",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"array",
"(",
"[",
"np",
".",
"arange",
"(",
"10",
")",
",",
"np",
".",
"arange",
"(",
"10",
")",
"]",
")",
"res",
"=",
"array_split",
"(",
"a",
",",
"3",
")",
... | [
408,
4
] | [
416,
51
] | python | en | ['en', 'en', 'en'] | True |
check_dir | (module, module_name=None) | Returns a mapping of all objects with the wrong __module__ attribute. | Returns a mapping of all objects with the wrong __module__ attribute. | def check_dir(module, module_name=None):
"""Returns a mapping of all objects with the wrong __module__ attribute."""
if module_name is None:
module_name = module.__name__
results = {}
for name in dir(module):
item = getattr(module, name)
if (hasattr(item, '__module__') and hasatt... | [
"def",
"check_dir",
"(",
"module",
",",
"module_name",
"=",
"None",
")",
":",
"if",
"module_name",
"is",
"None",
":",
"module_name",
"=",
"module",
".",
"__name__",
"results",
"=",
"{",
"}",
"for",
"name",
"in",
"dir",
"(",
"module",
")",
":",
"item",
... | [
17,
0
] | [
27,
18
] | python | en | ['en', 'en', 'en'] | True |
test_import_lazy_import | (name) | Make sure we can actually use the modules we lazy load.
While not exported as part of the public API, it was accessible. With the
use of __getattr__ and __dir__, this isn't always true It can happen that
an infinite recursion may happen.
This is the only way I found that would force the failure to ap... | Make sure we can actually use the modules we lazy load. | def test_import_lazy_import(name):
"""Make sure we can actually use the modules we lazy load.
While not exported as part of the public API, it was accessible. With the
use of __getattr__ and __dir__, this isn't always true It can happen that
an infinite recursion may happen.
This is the only way ... | [
"def",
"test_import_lazy_import",
"(",
"name",
")",
":",
"exe",
"=",
"(",
"sys",
".",
"executable",
",",
"'-c'",
",",
"\"import numpy; numpy.\"",
"+",
"name",
")",
"result",
"=",
"subprocess",
".",
"check_output",
"(",
"exe",
")",
"assert",
"not",
"result",
... | [
75,
0
] | [
93,
26
] | python | en | ['en', 'en', 'en'] | True |
test_dir_testing | () | Assert that output of dir has only one "testing/tester"
attribute without duplicate | Assert that output of dir has only one "testing/tester"
attribute without duplicate | def test_dir_testing():
"""Assert that output of dir has only one "testing/tester"
attribute without duplicate"""
assert len(dir(np)) == len(set(dir(np))) | [
"def",
"test_dir_testing",
"(",
")",
":",
"assert",
"len",
"(",
"dir",
"(",
"np",
")",
")",
"==",
"len",
"(",
"set",
"(",
"dir",
"(",
"np",
")",
")",
")"
] | [
96,
0
] | [
99,
44
] | python | en | ['en', 'en', 'en'] | True |
is_unexpected | (name) | Check if this needs to be considered. | Check if this needs to be considered. | def is_unexpected(name):
"""Check if this needs to be considered."""
if '._' in name or '.tests' in name or '.setup' in name:
return False
if name in PUBLIC_MODULES:
return False
if name in PUBLIC_ALIASED_MODULES:
return False
if name in PRIVATE_BUT_PRESENT_MODULES:
... | [
"def",
"is_unexpected",
"(",
"name",
")",
":",
"if",
"'._'",
"in",
"name",
"or",
"'.tests'",
"in",
"name",
"or",
"'.setup'",
"in",
"name",
":",
"return",
"False",
"if",
"name",
"in",
"PUBLIC_MODULES",
":",
"return",
"False",
"if",
"name",
"in",
"PUBLIC_A... | [
306,
0
] | [
320,
15
] | python | en | ['en', 'en', 'en'] | True |
test_all_modules_are_expected | () |
Test that we don't add anything that looks like a new public module by
accident. Check is based on filenames.
|
Test that we don't add anything that looks like a new public module by
accident. Check is based on filenames.
| def test_all_modules_are_expected():
"""
Test that we don't add anything that looks like a new public module by
accident. Check is based on filenames.
"""
modnames = []
for _, modname, ispkg in pkgutil.walk_packages(path=np.__path__,
prefix=np... | [
"def",
"test_all_modules_are_expected",
"(",
")",
":",
"modnames",
"=",
"[",
"]",
"for",
"_",
",",
"modname",
",",
"ispkg",
"in",
"pkgutil",
".",
"walk_packages",
"(",
"path",
"=",
"np",
".",
"__path__",
",",
"prefix",
"=",
"np",
".",
"__name__",
"+",
... | [
339,
0
] | [
356,
77
] | python | en | ['en', 'error', 'th'] | False |
test_all_modules_are_expected_2 | () |
Method checking all objects. The pkgutil-based method in
`test_all_modules_are_expected` does not catch imports into a namespace,
only filenames. So this test is more thorough, and checks this like:
import .lib.scimath as emath
To check if something in a module is (effectively) public, one c... |
Method checking all objects. The pkgutil-based method in
`test_all_modules_are_expected` does not catch imports into a namespace,
only filenames. So this test is more thorough, and checks this like: | def test_all_modules_are_expected_2():
"""
Method checking all objects. The pkgutil-based method in
`test_all_modules_are_expected` does not catch imports into a namespace,
only filenames. So this test is more thorough, and checks this like:
import .lib.scimath as emath
To check if someth... | [
"def",
"test_all_modules_are_expected_2",
"(",
")",
":",
"def",
"find_unexpected_members",
"(",
"mod_name",
")",
":",
"members",
"=",
"[",
"]",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"mod_name",
")",
"if",
"hasattr",
"(",
"module",
",",
"'__all... | [
392,
0
] | [
441,
70
] | python | en | ['en', 'error', 'th'] | False |
test_api_importable | () |
Check that all submodules listed higher up in this file can be imported
Note that if a PRIVATE_BUT_PRESENT_MODULES entry goes missing, it may
simply need to be removed from the list (deprecation may or may not be
needed - apply common sense).
|
Check that all submodules listed higher up in this file can be imported | def test_api_importable():
"""
Check that all submodules listed higher up in this file can be imported
Note that if a PRIVATE_BUT_PRESENT_MODULES entry goes missing, it may
simply need to be removed from the list (deprecation may or may not be
needed - apply common sense).
"""
def check_imp... | [
"def",
"test_api_importable",
"(",
")",
":",
"def",
"check_importable",
"(",
"module_name",
")",
":",
"try",
":",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"except",
"(",
"ImportError",
",",
"AttributeError",
")",
":",
"return",
"False",
"ret... | [
444,
0
] | [
489,
55
] | python | en | ['en', 'error', 'th'] | False |
test_setup_component | (hass) | Test setup and teardown of the netatmo component. | Test setup and teardown of the netatmo component. | async def test_setup_component(hass):
"""Test setup and teardown of the netatmo component."""
config_entry = MockConfigEntry(
domain="netatmo",
data={
"auth_implementation": "cloud",
"token": {
"refresh_token": "mock-refresh-token",
"access... | [
"async",
"def",
"test_setup_component",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"netatmo\"",
",",
"data",
"=",
"{",
"\"auth_implementation\"",
":",
"\"cloud\"",
",",
"\"token\"",
":",
"{",
"\"refresh_token\"",
":",
"\... | [
51,
0
] | [
96,
56
] | python | en | ['en', 'haw', 'en'] | True |
test_setup_component_with_config | (hass, config_entry) | Test setup of the netatmo component with dev account. | Test setup of the netatmo component with dev account. | async def test_setup_component_with_config(hass, config_entry):
"""Test setup of the netatmo component with dev account."""
fake_post_hits = 0
async def fake_post(*args, **kwargs):
"""Fake error during requesting backend data."""
nonlocal fake_post_hits
fake_post_hits += 1
r... | [
"async",
"def",
"test_setup_component_with_config",
"(",
"hass",
",",
"config_entry",
")",
":",
"fake_post_hits",
"=",
"0",
"async",
"def",
"fake_post",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Fake error during requesting backend data.\"\"\"",
"n... | [
99,
0
] | [
133,
43
] | python | en | ['en', 'en', 'en'] | True |
test_setup_component_with_webhook | (hass, config_entry, netatmo_auth) | Test setup and teardown of the netatmo component with webhook registration. | Test setup and teardown of the netatmo component with webhook registration. | async def test_setup_component_with_webhook(hass, config_entry, netatmo_auth):
"""Test setup and teardown of the netatmo component with webhook registration."""
with selected_platforms(["camera", "climate", "light", "sensor"]):
await hass.config_entries.async_setup(config_entry.entry_id)
await ... | [
"async",
"def",
"test_setup_component_with_webhook",
"(",
"hass",
",",
"config_entry",
",",
"netatmo_auth",
")",
":",
"with",
"selected_platforms",
"(",
"[",
"\"camera\"",
",",
"\"climate\"",
",",
"\"light\"",
",",
"\"sensor\"",
"]",
")",
":",
"await",
"hass",
"... | [
136,
0
] | [
162,
62
] | python | en | ['en', 'haw', 'en'] | True |
test_setup_without_https | (hass, config_entry, caplog) | Test if set up with cloud link and without https. | Test if set up with cloud link and without https. | async def test_setup_without_https(hass, config_entry, caplog):
"""Test if set up with cloud link and without https."""
hass.config.components.add("cloud")
with patch(
"homeassistant.helpers.network.get_url",
return_value="http://example.nabu.casa",
), patch(
"homeassistant.compo... | [
"async",
"def",
"test_setup_without_https",
"(",
"hass",
",",
"config_entry",
",",
"caplog",
")",
":",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"cloud\"",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.network.get_url\"",
",",
"return_valu... | [
165,
0
] | [
188,
82
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_cloud | (hass, config_entry) | Test if set up with active cloud subscription. | Test if set up with active cloud subscription. | async def test_setup_with_cloud(hass, config_entry):
"""Test if set up with active cloud subscription."""
await mock_cloud(hass)
await hass.async_block_till_done()
with patch(
"homeassistant.components.cloud.async_is_logged_in", return_value=True
), patch(
"homeassistant.components.... | [
"async",
"def",
"test_setup_with_cloud",
"(",
"hass",
",",
"config_entry",
")",
":",
"await",
"mock_cloud",
"(",
"hass",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.cloud.async_is_logged_in\"",
",",
... | [
191,
0
] | [
234,
60
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_cloudhook | (hass) | Test if set up with active cloud subscription and cloud hook. | Test if set up with active cloud subscription and cloud hook. | async def test_setup_with_cloudhook(hass):
"""Test if set up with active cloud subscription and cloud hook."""
config_entry = MockConfigEntry(
domain="netatmo",
data={
"auth_implementation": "cloud",
"cloudhook_url": "https://hooks.nabu.casa/ABCD",
"token": {
... | [
"async",
"def",
"test_setup_with_cloudhook",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"netatmo\"",
",",
"data",
"=",
"{",
"\"auth_implementation\"",
":",
"\"cloud\"",
",",
"\"cloudhook_url\"",
":",
"\"https://hooks.nabu.casa... | [
237,
0
] | [
297,
60
] | python | en | ['en', 'en', 'en'] | True |
test_setup_component_api_error | (hass) | Test error on setup of the netatmo component. | Test error on setup of the netatmo component. | async def test_setup_component_api_error(hass):
"""Test error on setup of the netatmo component."""
config_entry = MockConfigEntry(
domain="netatmo",
data={
"auth_implementation": "cloud",
"token": {
"refresh_token": "mock-refresh-token",
"... | [
"async",
"def",
"test_setup_component_api_error",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"netatmo\"",
",",
"data",
"=",
"{",
"\"auth_implementation\"",
":",
"\"cloud\"",
",",
"\"token\"",
":",
"{",
"\"refresh_token\"",
... | [
300,
0
] | [
336,
34
] | python | en | ['en', 'et', 'en'] | True |
test_setup_component_api_timeout | (hass) | Test timeout on setup of the netatmo component. | Test timeout on setup of the netatmo component. | async def test_setup_component_api_timeout(hass):
"""Test timeout on setup of the netatmo component."""
config_entry = MockConfigEntry(
domain="netatmo",
data={
"auth_implementation": "cloud",
"token": {
"refresh_token": "mock-refresh-token",
... | [
"async",
"def",
"test_setup_component_api_timeout",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"netatmo\"",
",",
"data",
"=",
"{",
"\"auth_implementation\"",
":",
"\"cloud\"",
",",
"\"token\"",
":",
"{",
"\"refresh_token\"",... | [
339,
0
] | [
375,
34
] | python | en | ['en', 'en', 'en'] | True |
test_setup_component_with_delay | (hass, config_entry) | Test setup of the netatmo component with delayed startup. | Test setup of the netatmo component with delayed startup. | async def test_setup_component_with_delay(hass, config_entry):
"""Test setup of the netatmo component with delayed startup."""
hass.state = CoreState.not_running
with patch(
"pyatmo.AbstractAsyncAuth.async_addwebhook", side_effect=AsyncMock()
) as mock_addwebhook, patch(
"pyatmo.Abstrac... | [
"async",
"def",
"test_setup_component_with_delay",
"(",
"hass",
",",
"config_entry",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"with",
"patch",
"(",
"\"pyatmo.AbstractAsyncAuth.async_addwebhook\"",
",",
"side_effect",
"=",
"AsyncMock",
"(",... | [
378,
0
] | [
430,
45
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the kaiterra temperature and humidity sensor. | Set up the kaiterra temperature and humidity sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the kaiterra temperature and humidity sensor."""
if discovery_info is None:
return
api = hass.data[DOMAIN]
name = discovery_info[CONF_NAME]
device_id = discovery_info[CONF_DEVICE_ID]
async_... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"api",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"name",
"... | [
20,
0
] | [
31,
5
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.__init__ | (self, api, name, device_id, sensor) | Initialize the sensor. | Initialize the sensor. | def __init__(self, api, name, device_id, sensor):
"""Initialize the sensor."""
self._api = api
self._name = f'{name} {sensor["name"]}'
self._device_id = device_id
self._kind = sensor["name"].lower()
self._property = sensor["prop"]
self._device_class = sensor["devi... | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"name",
",",
"device_id",
",",
"sensor",
")",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_name",
"=",
"f'{name} {sensor[\"name\"]}'",
"self",
".",
"_device_id",
"=",
"device_id",
"self",
".",
"_ki... | [
37,
4
] | [
44,
51
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor._sensor | (self) | Return the sensor data. | Return the sensor data. | def _sensor(self):
"""Return the sensor data."""
return self._api.data.get(self._device_id, {}).get(self._property, {}) | [
"def",
"_sensor",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"self",
".",
"_device_id",
",",
"{",
"}",
")",
".",
"get",
"(",
"self",
".",
"_property",
",",
"{",
"}",
")"
] | [
47,
4
] | [
49,
78
] | python | en | ['en', 'no', 'en'] | True |
KaiterraSensor.should_poll | (self) | Return that the sensor should not be polled. | Return that the sensor should not be polled. | def should_poll(self):
"""Return that the sensor should not be polled."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
52,
4
] | [
54,
20
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.available | (self) | Return the availability of the sensor. | Return the availability of the sensor. | def available(self):
"""Return the availability of the sensor."""
return self._api.data.get(self._device_id) is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"self",
".",
"_device_id",
")",
"is",
"not",
"None"
] | [
57,
4
] | [
59,
62
] | python | en | ['en', 'ga', 'en'] | True |
KaiterraSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
62,
4
] | [
64,
33
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
67,
4
] | [
69,
25
] | python | en | ['en', 'ig', 'en'] | True |
KaiterraSensor.native_value | (self) | Return the state. | Return the state. | def native_value(self):
"""Return the state."""
return self._sensor.get("value") | [
"def",
"native_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor",
".",
"get",
"(",
"\"value\"",
")"
] | [
72,
4
] | [
74,
40
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.unique_id | (self) | Return the sensor's unique id. | Return the sensor's unique id. | def unique_id(self):
"""Return the sensor's unique id."""
return f"{self._device_id}_{self._kind}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._device_id}_{self._kind}\""
] | [
77,
4
] | [
79,
48
] | python | en | ['en', 'ca', 'en'] | True |
KaiterraSensor.native_unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
if not self._sensor.get("units"):
return None
value = self._sensor["units"].value
if value == "F":
return TEMP_FAHRENHEIT
if value == "C":
return TEMP_CELS... | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_sensor",
".",
"get",
"(",
"\"units\"",
")",
":",
"return",
"None",
"value",
"=",
"self",
".",
"_sensor",
"[",
"\"units\"",
"]",
".",
"value",
"if",
"value",
"==",
"... | [
82,
4
] | [
93,
20
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.async_added_to_hass | (self) | Register callback. | Register callback. | async def async_added_to_hass(self):
"""Register callback."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, DISPATCHER_KAITERRA, self.async_write_ha_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DISPATCHER_KAITERRA",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
95,
4
] | [
101,
9
] | python | en | ['en', 'no', 'en'] | False |
async_setup | (hass, config) | Initialize the namecheap DNS component. | Initialize the namecheap DNS component. | async def async_setup(hass, config):
"""Initialize the namecheap DNS component."""
host = config[DOMAIN][CONF_HOST]
domain = config[DOMAIN][CONF_DOMAIN]
password = config[DOMAIN][CONF_PASSWORD]
session = async_get_clientsession(hass)
result = await _update_namecheapdns(session, host, domain, p... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"host",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_HOST",
"]",
"domain",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_DOMAIN",
"]",
"password",
"=",
"config",
"[",
"DOMAIN",
"]",
... | [
34,
0
] | [
53,
17
] | python | en | ['en', 'en', 'en'] | True |
_update_namecheapdns | (session, host, domain, password) | Update namecheap DNS entry. | Update namecheap DNS entry. | async def _update_namecheapdns(session, host, domain, password):
"""Update namecheap DNS entry."""
params = {"host": host, "domain": domain, "password": password}
resp = await session.get(UPDATE_URL, params=params)
xml_string = await resp.text()
root = ET.fromstring(xml_string)
err_count = root... | [
"async",
"def",
"_update_namecheapdns",
"(",
"session",
",",
"host",
",",
"domain",
",",
"password",
")",
":",
"params",
"=",
"{",
"\"host\"",
":",
"host",
",",
"\"domain\"",
":",
"domain",
",",
"\"password\"",
":",
"password",
"}",
"resp",
"=",
"await",
... | [
56,
0
] | [
69,
15
] | python | en | ['en', 'lb', 'en'] | True |
_make_str | (s) |
Inspired by six.ensure_str in six version 1.15. See the six module for
copyright notice.
|
Inspired by six.ensure_str in six version 1.15. See the six module for
copyright notice.
| def _make_str(s):
"""
Inspired by six.ensure_str in six version 1.15. See the six module for
copyright notice.
"""
if six.PY2 and isinstance(s, six.text_type):
return s.encode("utf-8", "strict")
if six.PY3 and isinstance(s, six.binary_type):
return s.decode("utf-8", "strict")
... | [
"def",
"_make_str",
"(",
"s",
")",
":",
"if",
"six",
".",
"PY2",
"and",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"return",
"s",
".",
"encode",
"(",
"\"utf-8\"",
",",
"\"strict\"",
")",
"if",
"six",
".",
"PY3",
"and",
"isinsta... | [
37,
0
] | [
46,
12
] | python | en | ['en', 'error', 'th'] | False |
all_ | (expr) |
Use to express that ``expr`` must succeed on all attributes for the query
to be successful. Only works against :py:class:`Entry` attributes.
|
Use to express that ``expr`` must succeed on all attributes for the query
to be successful. Only works against :py:class:`Entry` attributes.
| def all_(expr):
"""
Use to express that ``expr`` must succeed on all attributes for the query
to be successful. Only works against :py:class:`Entry` attributes.
"""
return _AllAttrQuery(_desugar_attr(expr)) | [
"def",
"all_",
"(",
"expr",
")",
":",
"return",
"_AllAttrQuery",
"(",
"_desugar_attr",
"(",
"expr",
")",
")"
] | [
771,
0
] | [
776,
45
] | python | en | ['en', 'error', 'th'] | False |
any_ | (expr) |
Use to express that ``expr`` can succeed on any attribute for the query to be
successful. Only works against :py:class:`Entry` attributes.
|
Use to express that ``expr`` can succeed on any attribute for the query to be
successful. Only works against :py:class:`Entry` attributes.
| def any_(expr):
"""
Use to express that ``expr`` can succeed on any attribute for the query to be
successful. Only works against :py:class:`Entry` attributes.
"""
return _AnyAttrQuery(_desugar_attr(expr)) | [
"def",
"any_",
"(",
"expr",
")",
":",
"return",
"_AnyAttrQuery",
"(",
"_desugar_attr",
"(",
"expr",
")",
")"
] | [
779,
0
] | [
784,
45
] | python | en | ['en', 'error', 'th'] | False |
child_query | (name, value=None) |
Converts a query into a ChildQuery that works on all child entries at once
to determine if the current entry is accepted.
|
Converts a query into a ChildQuery that works on all child entries at once
to determine if the current entry is accepted.
| def child_query(name, value=None):
"""
Converts a query into a ChildQuery that works on all child entries at once
to determine if the current entry is accepted.
"""
q = _desugar((name, value) if value is not None else name)
return ChildQuery(q) | [
"def",
"child_query",
"(",
"name",
",",
"value",
"=",
"None",
")",
":",
"q",
"=",
"_desugar",
"(",
"(",
"name",
",",
"value",
")",
"if",
"value",
"is",
"not",
"None",
"else",
"name",
")",
"return",
"ChildQuery",
"(",
"q",
")"
] | [
798,
0
] | [
804,
24
] | python | en | ['en', 'error', 'th'] | False |
_flatten | (nodes) |
Flatten the config tree into a list of nodes.
|
Flatten the config tree into a list of nodes.
| def _flatten(nodes):
"""
Flatten the config tree into a list of nodes.
"""
def inner(n):
yield n
for i in chain.from_iterable(inner(c) for c in n.children):
yield i
return list(chain.from_iterable(inner(n) for n in nodes)) | [
"def",
"_flatten",
"(",
"nodes",
")",
":",
"def",
"inner",
"(",
"n",
")",
":",
"yield",
"n",
"for",
"i",
"in",
"chain",
".",
"from_iterable",
"(",
"inner",
"(",
"c",
")",
"for",
"c",
"in",
"n",
".",
"children",
")",
":",
"yield",
"i",
"return",
... | [
866,
0
] | [
874,
61
] | python | en | ['en', 'error', 'th'] | False |
compile_queries | (*queries) |
compile_queries returns a function that will execute a list of query
expressions against an :py:class:`Entry`. The first query is run against
the current entry's children, the second query is run against the children
of the children remaining from the first query, and so on.
If a query is a single... |
compile_queries returns a function that will execute a list of query
expressions against an :py:class:`Entry`. The first query is run against
the current entry's children, the second query is run against the children
of the children remaining from the first query, and so on. | def compile_queries(*queries):
"""
compile_queries returns a function that will execute a list of query
expressions against an :py:class:`Entry`. The first query is run against
the current entry's children, the second query is run against the children
of the children remaining from the first query, ... | [
"def",
"compile_queries",
"(",
"*",
"queries",
")",
":",
"queries",
"=",
"[",
"_desugar",
"(",
"q",
")",
"for",
"q",
"in",
"queries",
"]",
"def",
"match",
"(",
"qs",
",",
"nodes",
")",
":",
"q",
"=",
"qs",
"[",
"0",
"]",
"qs",
"=",
"qs",
"[",
... | [
877,
0
] | [
903,
16
] | python | en | ['en', 'error', 'th'] | False |
select | (query, nodes, deep=False, roots=False) |
select runs query, a function returned by :py:func:`compile_queries`,
against a list of :py:class:`Entry` instances. If you pass ``deep=True``,
select recursively walks each entry in the list and accumulates the
results of running the query against it. If you pass ``roots=True``,
select returns the... |
select runs query, a function returned by :py:func:`compile_queries`,
against a list of :py:class:`Entry` instances. If you pass ``deep=True``,
select recursively walks each entry in the list and accumulates the
results of running the query against it. If you pass ``roots=True``,
select returns the... | def select(query, nodes, deep=False, roots=False):
"""
select runs query, a function returned by :py:func:`compile_queries`,
against a list of :py:class:`Entry` instances. If you pass ``deep=True``,
select recursively walks each entry in the list and accumulates the
results of running the query agai... | [
"def",
"select",
"(",
"query",
",",
"nodes",
",",
"deep",
"=",
"False",
",",
"roots",
"=",
"False",
")",
":",
"results",
"=",
"query",
"(",
"_flatten",
"(",
"nodes",
")",
")",
"if",
"deep",
"else",
"query",
"(",
"nodes",
")",
"if",
"not",
"roots",
... | [
906,
0
] | [
927,
31
] | python | en | ['en', 'error', 'th'] | False |
from_dict | (orig, src=None) |
from_dict is a helper function that does its best to convert a python dict
into a tree of :py:class:`Entry` instances that can be queried.
|
from_dict is a helper function that does its best to convert a python dict
into a tree of :py:class:`Entry` instances that can be queried.
| def from_dict(orig, src=None):
"""
from_dict is a helper function that does its best to convert a python dict
into a tree of :py:class:`Entry` instances that can be queried.
"""
def inner(d):
result = []
for k, v in d.items():
if isinstance(v, dict):
resul... | [
"def",
"from_dict",
"(",
"orig",
",",
"src",
"=",
"None",
")",
":",
"def",
"inner",
"(",
"d",
")",
":",
"result",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
"... | [
930,
0
] | [
952,
47
] | python | en | ['en', 'error', 'th'] | False |
pretty_format | (root, indent=4) |
pretty_format generates a text representation of a model as a list of
lines.
|
pretty_format generates a text representation of a model as a list of
lines.
| def pretty_format(root, indent=4):
"""
pretty_format generates a text representation of a model as a list of
lines.
"""
results = []
def sep():
if results and results[-1] != "":
results.append("")
def inner(d, prefix=""):
if isinstance(d, Result):
fo... | [
"def",
"pretty_format",
"(",
"root",
",",
"indent",
"=",
"4",
")",
":",
"results",
"=",
"[",
"]",
"def",
"sep",
"(",
")",
":",
"if",
"results",
"and",
"results",
"[",
"-",
"1",
"]",
"!=",
"\"\"",
":",
"results",
".",
"append",
"(",
"\"\"",
")",
... | [
955,
0
] | [
985,
18
] | python | en | ['en', 'error', 'th'] | False |
Entry.__getattr__ | (self, name) |
Allows queries based on attribute access so long as they don't conflict
with members of the Entry class itself.
|
Allows queries based on attribute access so long as they don't conflict
with members of the Entry class itself.
| def __getattr__(self, name):
"""
Allows queries based on attribute access so long as they don't conflict
with members of the Entry class itself.
"""
if name == "name" and self._name is not None:
return self._name
res = self[name]
if res:
r... | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"==",
"\"name\"",
"and",
"self",
".",
"_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_name",
"res",
"=",
"self",
"[",
"name",
"]",
"if",
"res",
":",
"return",
"res"... | [
102,
4
] | [
118,
18
] | python | en | ['en', 'error', 'th'] | False |
Entry.get_keys | (self) |
Returns the unique names of all the children as a list.
|
Returns the unique names of all the children as a list.
| def get_keys(self):
"""
Returns the unique names of all the children as a list.
"""
return sorted(set(c._name for c in self.children if c._name)) | [
"def",
"get_keys",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"set",
"(",
"c",
".",
"_name",
"for",
"c",
"in",
"self",
".",
"children",
"if",
"c",
".",
"_name",
")",
")"
] | [
120,
4
] | [
124,
69
] | python | en | ['en', 'error', 'th'] | False |
Entry.__dir__ | (self) |
Exists for ipython autocompletion.
|
Exists for ipython autocompletion.
| def __dir__(self):
"""
Exists for ipython autocompletion.
"""
return self.get_keys() + object.__dir__(self) | [
"def",
"__dir__",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_keys",
"(",
")",
"+",
"object",
".",
"__dir__",
"(",
"self",
")"
] | [
128,
4
] | [
132,
53
] | python | en | ['en', 'error', 'th'] | False |
Entry.get_crumbs | (self, down=False) |
Get the unique paths from the current entry up to the root or down
to all of the leaves.
|
Get the unique paths from the current entry up to the root or down
to all of the leaves.
| def get_crumbs(self, down=False):
"""
Get the unique paths from the current entry up to the root or down
to all of the leaves.
"""
return self._crumbs_up() if not down else self._crumbs_down() | [
"def",
"get_crumbs",
"(",
"self",
",",
"down",
"=",
"False",
")",
":",
"return",
"self",
".",
"_crumbs_up",
"(",
")",
"if",
"not",
"down",
"else",
"self",
".",
"_crumbs_down",
"(",
")"
] | [
192,
4
] | [
197,
69
] | python | en | ['en', 'error', 'th'] | False |
Entry.line | (self) |
Returns the original first line of text that generated the ``Entry``.
``None`` if the model wasn't generated by an insights parser.
|
Returns the original first line of text that generated the ``Entry``.
``None`` if the model wasn't generated by an insights parser.
| def line(self):
"""
Returns the original first line of text that generated the ``Entry``.
``None`` if the model wasn't generated by an insights parser.
"""
if self.src is not None and self.lineno is not None:
return self.src.content[self.lineno - 1] | [
"def",
"line",
"(",
"self",
")",
":",
"if",
"self",
".",
"src",
"is",
"not",
"None",
"and",
"self",
".",
"lineno",
"is",
"not",
"None",
":",
"return",
"self",
".",
"src",
".",
"content",
"[",
"self",
".",
"lineno",
"-",
"1",
"]"
] | [
202,
4
] | [
208,
52
] | python | en | ['en', 'error', 'th'] | False |
Entry.string_value | (self) |
Returns the string representation of all attributes separated by a
single whilespace.
|
Returns the string representation of all attributes separated by a
single whilespace.
| def string_value(self):
"""
Returns the string representation of all attributes separated by a
single whilespace.
"""
t = " ".join(["%s"] * len(self.attrs))
return t % tuple(self.attrs) | [
"def",
"string_value",
"(",
"self",
")",
":",
"t",
"=",
"\" \"",
".",
"join",
"(",
"[",
"\"%s\"",
"]",
"*",
"len",
"(",
"self",
".",
"attrs",
")",
")",
"return",
"t",
"%",
"tuple",
"(",
"self",
".",
"attrs",
")"
] | [
211,
4
] | [
217,
36
] | python | en | ['en', 'error', 'th'] | False |
Entry.value | (self) |
Returns ``None`` if no attributes exist, the first attribute if only
one exists, or the ``string_value`` if more than one exists.
|
Returns ``None`` if no attributes exist, the first attribute if only
one exists, or the ``string_value`` if more than one exists.
| def value(self):
"""
Returns ``None`` if no attributes exist, the first attribute if only
one exists, or the ``string_value`` if more than one exists.
"""
if len(self.attrs) == 1:
return self.attrs[0]
return self.string_value if len(self.attrs) > 1 else None | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"attrs",
")",
"==",
"1",
":",
"return",
"self",
".",
"attrs",
"[",
"0",
"]",
"return",
"self",
".",
"string_value",
"if",
"len",
"(",
"self",
".",
"attrs",
")",
">",
"1",
"el... | [
220,
4
] | [
227,
65
] | python | en | ['en', 'error', 'th'] | False |
Entry.root | (self) |
Returns the furthest ancestor ``Entry``. If the node is already the
furthest ancestor, ``None`` is returned.
|
Returns the furthest ancestor ``Entry``. If the node is already the
furthest ancestor, ``None`` is returned.
| def root(self):
"""
Returns the furthest ancestor ``Entry``. If the node is already the
furthest ancestor, ``None`` is returned.
"""
p = self.parent
while p is not None and p.parent is not None:
p = p.parent
return p | [
"def",
"root",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"parent",
"while",
"p",
"is",
"not",
"None",
"and",
"p",
".",
"parent",
"is",
"not",
"None",
":",
"p",
"=",
"p",
".",
"parent",
"return",
"p"
] | [
230,
4
] | [
238,
16
] | python | en | ['en', 'error', 'th'] | False |
Entry.grandchildren | (self) |
Returns a flattened list of all grandchildren.
|
Returns a flattened list of all grandchildren.
| def grandchildren(self):
"""
Returns a flattened list of all grandchildren.
"""
return list(chain.from_iterable(c.children for c in self.children)) | [
"def",
"grandchildren",
"(",
"self",
")",
":",
"return",
"list",
"(",
"chain",
".",
"from_iterable",
"(",
"c",
".",
"children",
"for",
"c",
"in",
"self",
".",
"children",
")",
")"
] | [
241,
4
] | [
245,
75
] | python | en | ['en', 'error', 'th'] | False |
Entry.upto | (self, query) |
Go up from the current node to the first node that matches query.
|
Go up from the current node to the first node that matches query.
| def upto(self, query):
"""
Go up from the current node to the first node that matches query.
"""
predicate = _desugar(query)
parent = self.parent
while parent is not None:
if predicate(parent):
return parent
parent = parent.parent | [
"def",
"upto",
"(",
"self",
",",
"query",
")",
":",
"predicate",
"=",
"_desugar",
"(",
"query",
")",
"parent",
"=",
"self",
".",
"parent",
"while",
"parent",
"is",
"not",
"None",
":",
"if",
"predicate",
"(",
"parent",
")",
":",
"return",
"parent",
"p... | [
247,
4
] | [
256,
34
] | python | en | ['en', 'error', 'th'] | False |
Entry.select | (self, *queries, **kwargs) |
select uses :py:func:`compile_queries` to compile ``queries`` into a
query function and then passes the function, the current ``Entry``
instances children, and ``kwargs`` on to :py:func:`select`.
|
select uses :py:func:`compile_queries` to compile ``queries`` into a
query function and then passes the function, the current ``Entry``
instances children, and ``kwargs`` on to :py:func:`select`.
| def select(self, *queries, **kwargs):
"""
select uses :py:func:`compile_queries` to compile ``queries`` into a
query function and then passes the function, the current ``Entry``
instances children, and ``kwargs`` on to :py:func:`select`.
"""
query = compile_queries(*queri... | [
"def",
"select",
"(",
"self",
",",
"*",
"queries",
",",
"*",
"*",
"kwargs",
")",
":",
"query",
"=",
"compile_queries",
"(",
"*",
"queries",
")",
"return",
"select",
"(",
"query",
",",
"self",
".",
"children",
",",
"*",
"*",
"kwargs",
")"
] | [
258,
4
] | [
265,
53
] | python | en | ['en', 'error', 'th'] | False |
Entry.find | (self, *queries, **kwargs) |
Finds matching results anywhere in the configuration. The arguments are
the same as those accepted by :py:func:`compile_queries`, and it
accepts a keyword called ``roots`` that will return the ultimate root
nodes of any results.
|
Finds matching results anywhere in the configuration. The arguments are
the same as those accepted by :py:func:`compile_queries`, and it
accepts a keyword called ``roots`` that will return the ultimate root
nodes of any results.
| def find(self, *queries, **kwargs):
"""
Finds matching results anywhere in the configuration. The arguments are
the same as those accepted by :py:func:`compile_queries`, and it
accepts a keyword called ``roots`` that will return the ultimate root
nodes of any results.
"""... | [
"def",
"find",
"(",
"self",
",",
"*",
"queries",
",",
"*",
"*",
"kwargs",
")",
":",
"roots",
"=",
"kwargs",
".",
"get",
"(",
"\"roots\"",
",",
"False",
")",
"return",
"self",
".",
"select",
"(",
"*",
"queries",
",",
"deep",
"=",
"True",
",",
"roo... | [
267,
4
] | [
275,
60
] | python | en | ['en', 'error', 'th'] | False |
Entry.where | (self, name, value=None) |
Selects current nodes based on name and value queries of child nodes.
If any immediate children match the queries, the parent is included in
the results. The :py:func:``make_child_query`` function can be used to
construct queries that act on the children as a whole instead of one
... |
Selects current nodes based on name and value queries of child nodes.
If any immediate children match the queries, the parent is included in
the results. The :py:func:``make_child_query`` function can be used to
construct queries that act on the children as a whole instead of one
... | def where(self, name, value=None):
"""
Selects current nodes based on name and value queries of child nodes.
If any immediate children match the queries, the parent is included in
the results. The :py:func:``make_child_query`` function can be used to
construct queries that act on... | [
"def",
"where",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"_EntryQuery",
")",
":",
"query",
"=",
"name",
".",
"to_pyfunc",
"(",
")",
"elif",
"isinstance",
"(",
"name",
",",
"Boolean",
")",
... | [
277,
4
] | [
309,
68
] | python | en | ['en', 'error', 'th'] | False |
Entry.choose | (self, chooser) |
Run a selector function on each node. It should return a tuple, each
element of which is some query using the node. This lets you select
parts of each tree in a result.
If you want to rename a field, make the element a dictionary whose
key is the name you want and whose value i... |
Run a selector function on each node. It should return a tuple, each
element of which is some query using the node. This lets you select
parts of each tree in a result. | def choose(self, chooser):
"""
Run a selector function on each node. It should return a tuple, each
element of which is some query using the node. This lets you select
parts of each tree in a result.
If you want to rename a field, make the element a dictionary whose
key ... | [
"def",
"choose",
"(",
"self",
",",
"chooser",
")",
":",
"results",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"children",
":",
"res",
"=",
"chooser",
"(",
"c",
")",
"res",
"=",
"res",
"if",
"isinstance",
"(",
"res",
",",
"(",
"list",
",",
"t... | [
311,
4
] | [
368,
31
] | python | en | ['en', 'error', 'th'] | False |
Entry.sections | (self) |
Returns all immediate children that are instances of
:py:class:`Section`.
|
Returns all immediate children that are instances of
:py:class:`Section`.
| def sections(self):
"""
Returns all immediate children that are instances of
:py:class:`Section`.
"""
return Result(children=[c for c in self.children if isinstance(c, Section)]) | [
"def",
"sections",
"(",
"self",
")",
":",
"return",
"Result",
"(",
"children",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"children",
"if",
"isinstance",
"(",
"c",
",",
"Section",
")",
"]",
")"
] | [
379,
4
] | [
384,
84
] | python | en | ['en', 'error', 'th'] | False |
Entry.directives | (self) |
Returns all immediate children that are instances of
:py:class:`Directive`.
|
Returns all immediate children that are instances of
:py:class:`Directive`.
| def directives(self):
"""
Returns all immediate children that are instances of
:py:class:`Directive`.
"""
return Result(children=[c for c in self.children if isinstance(c, Directive)]) | [
"def",
"directives",
"(",
"self",
")",
":",
"return",
"Result",
"(",
"children",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"children",
"if",
"isinstance",
"(",
"c",
",",
"Directive",
")",
"]",
")"
] | [
387,
4
] | [
392,
86
] | python | en | ['en', 'error', 'th'] | False |
Section.section | (self) |
Returns the name of the section.
|
Returns the name of the section.
| def section(self):
"""
Returns the name of the section.
"""
return self.name | [
"def",
"section",
"(",
"self",
")",
":",
"return",
"self",
".",
"name"
] | [
421,
4
] | [
425,
24
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.