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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_setup_hls | (hass) | Set up api endpoints. | Set up api endpoints. | def async_setup_hls(hass):
"""Set up api endpoints."""
hass.http.register_view(HlsPlaylistView())
hass.http.register_view(HlsSegmentView())
hass.http.register_view(HlsInitView())
hass.http.register_view(HlsMasterPlaylistView())
return "/api/hls/{}/master_playlist.m3u8" | [
"def",
"async_setup_hls",
"(",
"hass",
")",
":",
"hass",
".",
"http",
".",
"register_view",
"(",
"HlsPlaylistView",
"(",
")",
")",
"hass",
".",
"http",
".",
"register_view",
"(",
"HlsSegmentView",
"(",
")",
")",
"hass",
".",
"http",
".",
"register_view",
... | [
14,
0
] | [
20,
45
] | python | en | ['en', 'da', 'en'] | True |
HlsMasterPlaylistView.render | (track) | Render M3U8 file. | Render M3U8 file. | def render(track):
"""Render M3U8 file."""
# Need to calculate max bandwidth as input_container.bit_rate doesn't seem to work
# Calculate file size / duration and use a small multiplier to account for variation
# hls spec already allows for 25% variation
segment = track.get_segme... | [
"def",
"render",
"(",
"track",
")",
":",
"# Need to calculate max bandwidth as input_container.bit_rate doesn't seem to work",
"# Calculate file size / duration and use a small multiplier to account for variation",
"# hls spec already allows for 25% variation",
"segment",
"=",
"track",
".",
... | [
31,
4
] | [
46,
38
] | python | af | ['de', 'af', 'hi'] | False |
HlsMasterPlaylistView.handle | (self, request, stream, sequence) | Return m3u8 playlist. | Return m3u8 playlist. | async def handle(self, request, stream, sequence):
"""Return m3u8 playlist."""
track = stream.add_provider("hls")
stream.start()
# Wait for a segment to be ready
if not track.segments:
await track.recv()
headers = {"Content-Type": FORMAT_CONTENT_TYPE["hls"]}
... | [
"async",
"def",
"handle",
"(",
"self",
",",
"request",
",",
"stream",
",",
"sequence",
")",
":",
"track",
"=",
"stream",
".",
"add_provider",
"(",
"\"hls\"",
")",
"stream",
".",
"start",
"(",
")",
"# Wait for a segment to be ready",
"if",
"not",
"track",
"... | [
48,
4
] | [
56,
85
] | python | en | ['en', 'mt', 'en'] | True |
HlsPlaylistView.render_preamble | (track) | Render preamble. | Render preamble. | def render_preamble(track):
"""Render preamble."""
return [
"#EXT-X-VERSION:7",
f"#EXT-X-TARGETDURATION:{track.target_duration}",
'#EXT-X-MAP:URI="init.mp4"',
] | [
"def",
"render_preamble",
"(",
"track",
")",
":",
"return",
"[",
"\"#EXT-X-VERSION:7\"",
",",
"f\"#EXT-X-TARGETDURATION:{track.target_duration}\"",
",",
"'#EXT-X-MAP:URI=\"init.mp4\"'",
",",
"]"
] | [
67,
4
] | [
73,
9
] | python | da | ['da', 'ht', 'en'] | False |
HlsPlaylistView.render_playlist | (track) | Render playlist. | Render playlist. | def render_playlist(track):
"""Render playlist."""
segments = track.segments
if not segments:
return []
playlist = ["#EXT-X-MEDIA-SEQUENCE:{}".format(segments[0])]
for sequence in segments:
segment = track.get_segment(sequence)
playlist.exte... | [
"def",
"render_playlist",
"(",
"track",
")",
":",
"segments",
"=",
"track",
".",
"segments",
"if",
"not",
"segments",
":",
"return",
"[",
"]",
"playlist",
"=",
"[",
"\"#EXT-X-MEDIA-SEQUENCE:{}\"",
".",
"format",
"(",
"segments",
"[",
"0",
"]",
")",
"]",
... | [
76,
4
] | [
94,
23
] | python | da | ['da', 'de', 'en'] | False |
HlsPlaylistView.render | (self, track) | Render M3U8 file. | Render M3U8 file. | def render(self, track):
"""Render M3U8 file."""
lines = ["#EXTM3U"] + self.render_preamble(track) + self.render_playlist(track)
return "\n".join(lines) + "\n" | [
"def",
"render",
"(",
"self",
",",
"track",
")",
":",
"lines",
"=",
"[",
"\"#EXTM3U\"",
"]",
"+",
"self",
".",
"render_preamble",
"(",
"track",
")",
"+",
"self",
".",
"render_playlist",
"(",
"track",
")",
"return",
"\"\\n\"",
".",
"join",
"(",
"lines",... | [
96,
4
] | [
99,
38
] | python | af | ['de', 'af', 'hi'] | False |
HlsPlaylistView.handle | (self, request, stream, sequence) | Return m3u8 playlist. | Return m3u8 playlist. | async def handle(self, request, stream, sequence):
"""Return m3u8 playlist."""
track = stream.add_provider("hls")
stream.start()
# Wait for a segment to be ready
if not track.segments:
await track.recv()
headers = {"Content-Type": FORMAT_CONTENT_TYPE["hls"]}
... | [
"async",
"def",
"handle",
"(",
"self",
",",
"request",
",",
"stream",
",",
"sequence",
")",
":",
"track",
"=",
"stream",
".",
"add_provider",
"(",
"\"hls\"",
")",
"stream",
".",
"start",
"(",
")",
"# Wait for a segment to be ready",
"if",
"not",
"track",
"... | [
101,
4
] | [
109,
85
] | python | en | ['en', 'mt', 'en'] | True |
HlsInitView.handle | (self, request, stream, sequence) | Return init.mp4. | Return init.mp4. | async def handle(self, request, stream, sequence):
"""Return init.mp4."""
track = stream.add_provider("hls")
segments = track.get_segment()
if not segments:
return web.HTTPNotFound()
headers = {"Content-Type": "video/mp4"}
return web.Response(body=get_init(seg... | [
"async",
"def",
"handle",
"(",
"self",
",",
"request",
",",
"stream",
",",
"sequence",
")",
":",
"track",
"=",
"stream",
".",
"add_provider",
"(",
"\"hls\"",
")",
"segments",
"=",
"track",
".",
"get_segment",
"(",
")",
"if",
"not",
"segments",
":",
"re... | [
119,
4
] | [
126,
80
] | python | en | ['en', 'mt', 'en'] | False |
HlsSegmentView.handle | (self, request, stream, sequence) | Return fmp4 segment. | Return fmp4 segment. | async def handle(self, request, stream, sequence):
"""Return fmp4 segment."""
track = stream.add_provider("hls")
segment = track.get_segment(int(sequence))
if not segment:
return web.HTTPNotFound()
headers = {"Content-Type": "video/iso.segment"}
return web.Res... | [
"async",
"def",
"handle",
"(",
"self",
",",
"request",
",",
"stream",
",",
"sequence",
")",
":",
"track",
"=",
"stream",
".",
"add_provider",
"(",
"\"hls\"",
")",
"segment",
"=",
"track",
".",
"get_segment",
"(",
"int",
"(",
"sequence",
")",
")",
"if",... | [
136,
4
] | [
146,
9
] | python | bg-Latn | ['it', 'bg-Latn', 'en'] | False |
test_form | (hass) | Test user form showing. | Test user form showing. | async def test_form(hass):
"""Test user form showing."""
flow = config_flow.SomaFlowHandler()
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",
"\"type\"",
"]"... | [
14,
0
] | [
19,
61
] | python | en | ['en', 'da', 'en'] | True |
test_import_abort | (hass) | Test configuration from YAML aborting with existing entity. | Test configuration from YAML aborting with existing entity. | async def test_import_abort(hass):
"""Test configuration from YAML aborting with existing entity."""
flow = config_flow.SomaFlowHandler()
flow.hass = hass
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
result = await flow.async_step_import()
assert result["type"] == data_entry_flow.RESULT_TYPE... | [
"async",
"def",
"test_import_abort",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"result"... | [
22,
0
] | [
29,
46
] | python | en | ['en', 'en', 'en'] | True |
test_import_create | (hass) | Test configuration from YAML. | Test configuration from YAML. | async def test_import_create(hass):
"""Test configuration from YAML."""
flow = config_flow.SomaFlowHandler()
flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={"result": "success"}):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
assert r... | [
"async",
"def",
"test_import_create",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"with",
"patch",
".",
"object",
"(",
"SomaApi",
",",
"\"list_devices\"",
",",
"return_value",
"=",
... | [
32,
0
] | [
38,
69
] | python | en | ['en', 'en', 'en'] | True |
test_error_status | (hass) | Test Connect successfully returning error status. | Test Connect successfully returning error status. | async def test_error_status(hass):
"""Test Connect successfully returning error status."""
flow = config_flow.SomaFlowHandler()
flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={"result": "error"}):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PO... | [
"async",
"def",
"test_error_status",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"with",
"patch",
".",
"object",
"(",
"SomaApi",
",",
"\"list_devices\"",
",",
"return_value",
"=",
"... | [
41,
0
] | [
48,
45
] | python | en | ['en', 'la', 'en'] | True |
test_key_error | (hass) | Test Connect returning empty string. | Test Connect returning empty string. | async def test_key_error(hass):
"""Test Connect returning empty string."""
flow = config_flow.SomaFlowHandler()
flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={}):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
assert result["type"] ==... | [
"async",
"def",
"test_key_error",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"with",
"patch",
".",
"object",
"(",
"SomaApi",
",",
"\"list_devices\"",
",",
"return_value",
"=",
"{",... | [
51,
0
] | [
58,
49
] | python | en | ['en', 'en', 'en'] | True |
test_exception | (hass) | Test if RequestException fires when no connection can be made. | Test if RequestException fires when no connection can be made. | async def test_exception(hass):
"""Test if RequestException fires when no connection can be made."""
flow = config_flow.SomaFlowHandler()
flow.hass = hass
with patch.object(SomaApi, "list_devices", side_effect=RequestException()):
result = await flow.async_step_import({"host": MOCK_HOST, "port":... | [
"async",
"def",
"test_exception",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"with",
"patch",
".",
"object",
"(",
"SomaApi",
",",
"\"list_devices\"",
",",
"side_effect",
"=",
"Requ... | [
61,
0
] | [
68,
49
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow | (hass) | Check classic use case. | Check classic use case. | async def test_full_flow(hass):
"""Check classic use case."""
hass.data[DOMAIN] = {}
flow = config_flow.SomaFlowHandler()
flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={"result": "success"}):
result = await flow.async_step_user({"host": MOCK_HOST, "port": MOCK_PORT... | [
"async",
"def",
"test_full_flow",
"(",
"hass",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"flow",
"=",
"config_flow",
".",
"SomaFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"with",
"patch",
".",
"object",
"(",
"Som... | [
71,
0
] | [
78,
69
] | python | en | ['en', 'it', 'en'] | True |
test_config_required_fields | (hass) | Test that configuration is successful with required fields. | Test that configuration is successful with required fields. | async def test_config_required_fields(hass):
"""Test that configuration is successful with required fields."""
with patch.object(emulated_roku, "configured_servers", return_value=[]), patch(
"homeassistant.components.emulated_roku.binding.EmulatedRokuServer",
return_value=Mock(start=AsyncMock(),... | [
"async",
"def",
"test_config_required_fields",
"(",
"hass",
")",
":",
"with",
"patch",
".",
"object",
"(",
"emulated_roku",
",",
"\"configured_servers\"",
",",
"return_value",
"=",
"[",
"]",
")",
",",
"patch",
"(",
"\"homeassistant.components.emulated_roku.binding.Emu... | [
7,
0
] | [
29,
9
] | python | en | ['en', 'en', 'en'] | True |
test_config_already_registered_not_configured | (hass) | Test that an already registered name causes the entry to be ignored. | Test that an already registered name causes the entry to be ignored. | async def test_config_already_registered_not_configured(hass):
"""Test that an already registered name causes the entry to be ignored."""
with patch(
"homeassistant.components.emulated_roku.binding.EmulatedRokuServer",
return_value=Mock(start=AsyncMock(), close=AsyncMock()),
) as instantiate... | [
"async",
"def",
"test_config_already_registered_not_configured",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.emulated_roku.binding.EmulatedRokuServer\"",
",",
"return_value",
"=",
"Mock",
"(",
"start",
"=",
"AsyncMock",
"(",
")",
",",
"close",... | [
32,
0
] | [
58,
43
] | python | en | ['en', 'en', 'en'] | True |
test_setup_entry_successful | (hass) | Test setup entry is successful. | Test setup entry is successful. | async def test_setup_entry_successful(hass):
"""Test setup entry is successful."""
entry = Mock()
entry.data = {
emulated_roku.CONF_NAME: "Emulated Roku Test",
emulated_roku.CONF_LISTEN_PORT: 8060,
emulated_roku.CONF_HOST_IP: "1.2.3.5",
emulated_roku.CONF_ADVERTISE_IP: "1.2.3... | [
"async",
"def",
"test_setup_entry_successful",
"(",
"hass",
")",
":",
"entry",
"=",
"Mock",
"(",
")",
"entry",
".",
"data",
"=",
"{",
"emulated_roku",
".",
"CONF_NAME",
":",
"\"Emulated Roku Test\"",
",",
"emulated_roku",
".",
"CONF_LISTEN_PORT",
":",
"8060",
... | [
61,
0
] | [
89,
48
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass) | Test being able to unload an entry. | Test being able to unload an entry. | async def test_unload_entry(hass):
"""Test being able to unload an entry."""
entry = Mock()
entry.data = {"name": "Emulated Roku Test", "listen_port": 8060}
with patch(
"homeassistant.components.emulated_roku.binding.EmulatedRokuServer",
return_value=Mock(start=AsyncMock(), close=AsyncM... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
")",
":",
"entry",
"=",
"Mock",
"(",
")",
"entry",
".",
"data",
"=",
"{",
"\"name\"",
":",
"\"Emulated Roku Test\"",
",",
"\"listen_port\"",
":",
"8060",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.e... | [
92,
0
] | [
109,
52
] | python | en | ['en', 'en', 'en'] | True |
TFEmbeddings.call | (self, input_ids=None, position_ids=None, inputs_embeds=None, training=False) |
Applies embedding based on inputs tensor.
Returns:
final_embeddings (:obj:`tf.Tensor`): output embedding tensor.
|
Applies embedding based on inputs tensor. | def call(self, input_ids=None, position_ids=None, inputs_embeds=None, training=False):
"""
Applies embedding based on inputs tensor.
Returns:
final_embeddings (:obj:`tf.Tensor`): output embedding tensor.
"""
assert not (input_ids is None and inputs_embeds is None)
... | [
"def",
"call",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"position_ids",
"=",
"None",
",",
"inputs_embeds",
"=",
"None",
",",
"training",
"=",
"False",
")",
":",
"assert",
"not",
"(",
"input_ids",
"is",
"None",
"and",
"inputs_embeds",
"is",
"None"... | [
101,
4
] | [
124,
31
] | python | en | ['en', 'error', 'th'] | False |
TFMultiHeadSelfAttention.call | (self, query, key, value, mask, head_mask, output_attentions, training=False) |
Parameters:
query: tf.Tensor(bs, seq_length, dim)
key: tf.Tensor(bs, seq_length, dim)
value: tf.Tensor(bs, seq_length, dim)
mask: tf.Tensor(bs, seq_length)
Returns:
weights: tf.Tensor(bs, n_heads, seq_length, seq_length) Attention weights con... |
Parameters:
query: tf.Tensor(bs, seq_length, dim)
key: tf.Tensor(bs, seq_length, dim)
value: tf.Tensor(bs, seq_length, dim)
mask: tf.Tensor(bs, seq_length) | def call(self, query, key, value, mask, head_mask, output_attentions, training=False):
"""
Parameters:
query: tf.Tensor(bs, seq_length, dim)
key: tf.Tensor(bs, seq_length, dim)
value: tf.Tensor(bs, seq_length, dim)
mask: tf.Tensor(bs, seq_length)
... | [
"def",
"call",
"(",
"self",
",",
"query",
",",
"key",
",",
"value",
",",
"mask",
",",
"head_mask",
",",
"output_attentions",
",",
"training",
"=",
"False",
")",
":",
"bs",
",",
"q_length",
",",
"dim",
"=",
"shape_list",
"(",
"query",
")",
"k_length",
... | [
156,
4
] | [
210,
29
] | python | en | ['en', 'error', 'th'] | False |
TFTransformerBlock.call | (self, x, attn_mask, head_mask, output_attentions, training=False) |
Parameters:
x: tf.Tensor(bs, seq_length, dim)
attn_mask: tf.Tensor(bs, seq_length)
Outputs: sa_weights: tf.Tensor(bs, n_heads, seq_length, seq_length) The attention weights ffn_output:
tf.Tensor(bs, seq_length, dim) The output of the transformer block contextualization.... |
Parameters:
x: tf.Tensor(bs, seq_length, dim)
attn_mask: tf.Tensor(bs, seq_length) | def call(self, x, attn_mask, head_mask, output_attentions, training=False): # removed: src_enc=None, src_len=None
"""
Parameters:
x: tf.Tensor(bs, seq_length, dim)
attn_mask: tf.Tensor(bs, seq_length)
Outputs: sa_weights: tf.Tensor(bs, n_heads, seq_length, seq_length) T... | [
"def",
"call",
"(",
"self",
",",
"x",
",",
"attn_mask",
",",
"head_mask",
",",
"output_attentions",
",",
"training",
"=",
"False",
")",
":",
"# removed: src_enc=None, src_len=None",
"# Self-Attention",
"sa_output",
"=",
"self",
".",
"attention",
"(",
"x",
",",
... | [
257,
4
] | [
282,
21
] | python | en | ['en', 'error', 'th'] | False |
TFTransformer.call | (self, x, attn_mask, head_mask, output_attentions, output_hidden_states, return_dict, training=False) |
Parameters:
x: tf.Tensor(bs, seq_length, dim) Input sequence embedded.
attn_mask: tf.Tensor(bs, seq_length) Attention mask on the sequence.
Returns:
hidden_state: tf.Tensor(bs, seq_length, dim)
Sequence of hidden states in the last (top) layer
... |
Parameters:
x: tf.Tensor(bs, seq_length, dim) Input sequence embedded.
attn_mask: tf.Tensor(bs, seq_length) Attention mask on the sequence. | def call(self, x, attn_mask, head_mask, output_attentions, output_hidden_states, return_dict, training=False):
# docstyle-ignore
"""
Parameters:
x: tf.Tensor(bs, seq_length, dim) Input sequence embedded.
attn_mask: tf.Tensor(bs, seq_length) Attention mask on the sequence.... | [
"def",
"call",
"(",
"self",
",",
"x",
",",
"attn_mask",
",",
"head_mask",
",",
"output_attentions",
",",
"output_hidden_states",
",",
"return_dict",
",",
"training",
"=",
"False",
")",
":",
"# docstyle-ignore",
"all_hidden_states",
"=",
"(",
")",
"if",
"output... | [
294,
4
] | [
337,
9
] | python | en | ['en', 'error', 'th'] | False |
_gelu | (x) |
Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when
initially created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results):
0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)... |
Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when
initially created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results):
0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3)... | def _gelu(x):
"""
Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when
initially created. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results):
0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044... | [
"def",
"_gelu",
"(",
"x",
")",
":",
"x",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"x",
")",
"cdf",
"=",
"0.5",
"*",
"(",
"1.0",
"+",
"tf",
".",
"math",
".",
"erf",
"(",
"x",
"/",
"tf",
".",
"cast",
"(",
"tf",
".",
"sqrt",
"(",
"2.0",
")",
... | [
20,
0
] | [
30,
18
] | python | en | ['en', 'error', 'th'] | False |
_gelu_new | (x) |
Gaussian Error Linear Unit. This is a smoother version of the GELU. Original paper: https://arxiv.org/abs/1606.0841
Args:
x: float Tensor to perform activation
Returns:
`x` with the GELU activation applied.
|
Gaussian Error Linear Unit. This is a smoother version of the GELU. Original paper: https://arxiv.org/abs/1606.0841 | def _gelu_new(x):
"""
Gaussian Error Linear Unit. This is a smoother version of the GELU. Original paper: https://arxiv.org/abs/1606.0841
Args:
x: float Tensor to perform activation
Returns:
`x` with the GELU activation applied.
"""
x = tf.convert_to_tensor(x)
pi = tf.cast(... | [
"def",
"_gelu_new",
"(",
"x",
")",
":",
"x",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"x",
")",
"pi",
"=",
"tf",
".",
"cast",
"(",
"math",
".",
"pi",
",",
"x",
".",
"dtype",
")",
"coeff",
"=",
"tf",
".",
"cast",
"(",
"0.044715",
",",
"x",
".... | [
33,
0
] | [
48,
18
] | python | en | ['en', 'error', 'th'] | False |
test_format_default | (value, expected) | Test that default formatter copes with expected values. | Test that default formatter copes with expected values. | def test_format_default(value, expected):
"""Test that default formatter copes with expected values."""
assert sensor.format_default(value) == expected | [
"def",
"test_format_default",
"(",
"value",
",",
"expected",
")",
":",
"assert",
"sensor",
".",
"format_default",
"(",
"value",
")",
"==",
"expected"
] | [
19,
0
] | [
21,
51
] | python | en | ['en', 'en', 'en'] | True |
AsyncMock.__call__ | (self, *args, **kwargs) | Hack for async support for Mock. | Hack for async support for Mock. | async def __call__(self, *args, **kwargs):
"""Hack for async support for Mock."""
return super().__call__(*args, **kwargs) | [
"async",
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"__call__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
8,
4
] | [
10,
48
] | python | en | ['en', 'en', 'en'] | True |
get_calendar_info | (calendar) | Convert data from Google into DEVICE_SCHEMA. | Convert data from Google into DEVICE_SCHEMA. | def get_calendar_info(calendar):
"""Convert data from Google into DEVICE_SCHEMA."""
calendar_info = DEVICE_SCHEMA(
{
CONF_CAL_ID: calendar["id"],
CONF_ENTITIES: [
{
CONF_TRACK: calendar["track"],
CONF_NAME: calendar["summary... | [
"def",
"get_calendar_info",
"(",
"calendar",
")",
":",
"calendar_info",
"=",
"DEVICE_SCHEMA",
"(",
"{",
"CONF_CAL_ID",
":",
"calendar",
"[",
"\"id\"",
"]",
",",
"CONF_ENTITIES",
":",
"[",
"{",
"CONF_TRACK",
":",
"calendar",
"[",
"\"track\"",
"]",
",",
"CONF_... | [
61,
0
] | [
75,
24
] | python | en | ['en', 'en', 'en'] | True |
mock_google_setup | (hass, test_calendar) | Mock the google set up functions. | Mock the google set up functions. | def mock_google_setup(hass, test_calendar):
"""Mock the google set up functions."""
hass.loop.run_until_complete(async_setup_component(hass, "group", {"group": {}}))
calendar = get_calendar_info(test_calendar)
calendars = {calendar[CONF_CAL_ID]: calendar}
patch_google_auth = patch(
"homeassi... | [
"def",
"mock_google_setup",
"(",
"hass",
",",
"test_calendar",
")",
":",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"async_setup_component",
"(",
"hass",
",",
"\"group\"",
",",
"{",
"\"group\"",
":",
"{",
"}",
"}",
")",
")",
"calendar",
"=",
"get... | [
79,
0
] | [
94,
13
] | python | en | ['en', 'en', 'en'] | True |
mock_http | (hass) | Mock the http component. | Mock the http component. | def mock_http(hass):
"""Mock the http component."""
hass.http = Mock() | [
"def",
"mock_http",
"(",
"hass",
")",
":",
"hass",
".",
"http",
"=",
"Mock",
"(",
")"
] | [
98,
0
] | [
100,
22
] | python | en | ['en', 'en', 'en'] | True |
set_time_zone | () | Set the time zone for the tests. | Set the time zone for the tests. | def set_time_zone():
"""Set the time zone for the tests."""
# Set our timezone to CST/Regina so we can check calculations
# This keeps UTC-6 all year round
dt_util.set_default_time_zone(dt_util.get_time_zone("America/Regina"))
yield
dt_util.set_default_time_zone(dt_util.get_time_zone("UTC")) | [
"def",
"set_time_zone",
"(",
")",
":",
"# Set our timezone to CST/Regina so we can check calculations",
"# This keeps UTC-6 all year round",
"dt_util",
".",
"set_default_time_zone",
"(",
"dt_util",
".",
"get_time_zone",
"(",
"\"America/Regina\"",
")",
")",
"yield",
"dt_util",
... | [
104,
0
] | [
110,
63
] | python | en | ['en', 'en', 'en'] | True |
mock_google_service | () | Mock google service. | Mock google service. | def mock_google_service():
"""Mock google service."""
patch_google_service = patch(
"homeassistant.components.google.calendar.GoogleCalendarService"
)
with patch_google_service as mock_service:
yield mock_service | [
"def",
"mock_google_service",
"(",
")",
":",
"patch_google_service",
"=",
"patch",
"(",
"\"homeassistant.components.google.calendar.GoogleCalendarService\"",
")",
"with",
"patch_google_service",
"as",
"mock_service",
":",
"yield",
"mock_service"
] | [
114,
0
] | [
120,
26
] | python | en | ['en', 'cs', 'en'] | True |
test_all_day_event | (hass, mock_next_event) | Test that we can create an event trigger on device. | Test that we can create an event trigger on device. | async def test_all_day_event(hass, mock_next_event):
"""Test that we can create an event trigger on device."""
week_from_today = dt_util.dt.date.today() + dt_util.dt.timedelta(days=7)
end_event = week_from_today + dt_util.dt.timedelta(days=1)
event = copy.deepcopy(TEST_EVENT)
start = week_from_today... | [
"async",
"def",
"test_all_day_event",
"(",
"hass",
",",
"mock_next_event",
")",
":",
"week_from_today",
"=",
"dt_util",
".",
"dt",
".",
"date",
".",
"today",
"(",
")",
"+",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"days",
"=",
"7",
")",
"end_event",
... | [
123,
0
] | [
149,
5
] | python | en | ['en', 'en', 'en'] | True |
test_future_event | (hass, mock_next_event) | Test that we can create an event trigger on device. | Test that we can create an event trigger on device. | async def test_future_event(hass, mock_next_event):
"""Test that we can create an event trigger on device."""
one_hour_from_now = dt_util.now() + dt_util.dt.timedelta(minutes=30)
end_event = one_hour_from_now + dt_util.dt.timedelta(minutes=60)
start = one_hour_from_now.isoformat()
end = end_event.is... | [
"async",
"def",
"test_future_event",
"(",
"hass",
",",
"mock_next_event",
")",
":",
"one_hour_from_now",
"=",
"dt_util",
".",
"now",
"(",
")",
"+",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"minutes",
"=",
"30",
")",
"end_event",
"=",
"one_hour_from_now",... | [
152,
0
] | [
178,
5
] | python | en | ['en', 'en', 'en'] | True |
test_in_progress_event | (hass, mock_next_event) | Test that we can create an event trigger on device. | Test that we can create an event trigger on device. | async def test_in_progress_event(hass, mock_next_event):
"""Test that we can create an event trigger on device."""
middle_of_event = dt_util.now() - dt_util.dt.timedelta(minutes=30)
end_event = middle_of_event + dt_util.dt.timedelta(minutes=60)
start = middle_of_event.isoformat()
end = end_event.iso... | [
"async",
"def",
"test_in_progress_event",
"(",
"hass",
",",
"mock_next_event",
")",
":",
"middle_of_event",
"=",
"dt_util",
".",
"now",
"(",
")",
"-",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"minutes",
"=",
"30",
")",
"end_event",
"=",
"middle_of_event"... | [
181,
0
] | [
207,
5
] | python | en | ['en', 'en', 'en'] | True |
test_offset_in_progress_event | (hass, mock_next_event) | Test that we can create an event trigger on device. | Test that we can create an event trigger on device. | async def test_offset_in_progress_event(hass, mock_next_event):
"""Test that we can create an event trigger on device."""
middle_of_event = dt_util.now() + dt_util.dt.timedelta(minutes=14)
end_event = middle_of_event + dt_util.dt.timedelta(minutes=60)
start = middle_of_event.isoformat()
end = end_ev... | [
"async",
"def",
"test_offset_in_progress_event",
"(",
"hass",
",",
"mock_next_event",
")",
":",
"middle_of_event",
"=",
"dt_util",
".",
"now",
"(",
")",
"+",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"minutes",
"=",
"14",
")",
"end_event",
"=",
"middle_of... | [
210,
0
] | [
238,
5
] | python | en | ['en', 'en', 'en'] | True |
test_all_day_offset_in_progress_event | (hass, mock_next_event) | Test that we can create an event trigger on device. | Test that we can create an event trigger on device. | async def test_all_day_offset_in_progress_event(hass, mock_next_event):
"""Test that we can create an event trigger on device."""
tomorrow = dt_util.dt.date.today() + dt_util.dt.timedelta(days=1)
end_event = tomorrow + dt_util.dt.timedelta(days=1)
start = tomorrow.isoformat()
end = end_event.isoform... | [
"async",
"def",
"test_all_day_offset_in_progress_event",
"(",
"hass",
",",
"mock_next_event",
")",
":",
"tomorrow",
"=",
"dt_util",
".",
"dt",
".",
"date",
".",
"today",
"(",
")",
"+",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"... | [
242,
0
] | [
270,
5
] | python | en | ['en', 'en', 'en'] | True |
test_all_day_offset_event | (hass, mock_next_event) | Test that we can create an event trigger on device. | Test that we can create an event trigger on device. | async def test_all_day_offset_event(hass, mock_next_event):
"""Test that we can create an event trigger on device."""
tomorrow = dt_util.dt.date.today() + dt_util.dt.timedelta(days=2)
end_event = tomorrow + dt_util.dt.timedelta(days=1)
start = tomorrow.isoformat()
end = end_event.isoformat()
off... | [
"async",
"def",
"test_all_day_offset_event",
"(",
"hass",
",",
"mock_next_event",
")",
":",
"tomorrow",
"=",
"dt_util",
".",
"dt",
".",
"date",
".",
"today",
"(",
")",
"+",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"days",
"=",
"2",
")",
"end_event",
... | [
273,
0
] | [
302,
5
] | python | en | ['en', 'en', 'en'] | True |
test_update_error | (hass, google_service) | Test that the calendar handles a server error. | Test that the calendar handles a server error. | async def test_update_error(hass, google_service):
"""Test that the calendar handles a server error."""
google_service.return_value.get = Mock(
side_effect=httplib2.ServerNotFoundError("unit test")
)
assert await async_setup_component(hass, "google", {"google": GOOGLE_CONFIG})
await hass.asy... | [
"async",
"def",
"test_update_error",
"(",
"hass",
",",
"google_service",
")",
":",
"google_service",
".",
"return_value",
".",
"get",
"=",
"Mock",
"(",
"side_effect",
"=",
"httplib2",
".",
"ServerNotFoundError",
"(",
"\"unit test\"",
")",
")",
"assert",
"await",... | [
305,
0
] | [
315,
31
] | python | en | ['en', 'lb', 'en'] | True |
add_mock_config | (hass) | Create a fake Advantage Air Config Entry. | Create a fake Advantage Air Config Entry. | async def add_mock_config(hass):
"""Create a fake Advantage Air Config Entry."""
entry = MockConfigEntry(
domain=DOMAIN,
title="test entry",
unique_id="0123456",
data=USER_INPUT,
)
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await... | [
"async",
"def",
"add_mock_config",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"test entry\"",
",",
"unique_id",
"=",
"\"0123456\"",
",",
"data",
"=",
"USER_INPUT",
",",
")",
"entry",
".",
"add... | [
21,
0
] | [
32,
16
] | python | en | ['en', 'gd', 'en'] | True |
test_alarm_control_panel | (hass, canary) | Test the creation and values of the alarm_control_panel for Canary. | Test the creation and values of the alarm_control_panel for Canary. | async def test_alarm_control_panel(hass, canary) -> None:
"""Test the creation and values of the alarm_control_panel for Canary."""
await async_setup_component(hass, "persistent_notification", {})
registry = mock_registry(hass)
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Pro")
... | [
"async",
"def",
"test_alarm_control_panel",
"(",
"hass",
",",
"canary",
")",
"->",
"None",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"registry",
"=",
"mock_registry",
"(",
"hass",
")",
"online_dev... | [
24,
0
] | [
105,
49
] | python | en | ['en', 'en', 'en'] | True |
test_alarm_control_panel_services | (hass, canary) | Test the services of the alarm_control_panel for Canary. | Test the services of the alarm_control_panel for Canary. | async def test_alarm_control_panel_services(hass, canary) -> None:
"""Test the services of the alarm_control_panel for Canary."""
await async_setup_component(hass, "persistent_notification", {})
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Pro")
mocked_location = mock_location(... | [
"async",
"def",
"test_alarm_control_panel_services",
"(",
"hass",
",",
"canary",
")",
"->",
"None",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"online_device_at_home",
"=",
"mock_device",
"(",
"20",
... | [
108,
0
] | [
166,
72
] | python | en | ['en', 'en', 'en'] | True |
get_args | () | get args from command line
| get args from command line
| def get_args():
""" get args from command line
"""
parser = argparse.ArgumentParser("FashionMNIST")
parser.add_argument("--batch_size", type=int, default=128, help="batch size")
parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer")
parser.add_argument("--epochs", type=int... | [
"def",
"get_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"\"FashionMNIST\"",
")",
"parser",
".",
"add_argument",
"(",
"\"--batch_size\"",
",",
"type",
"=",
"int",
",",
"default",
"=",
"128",
",",
"help",
"=",
"\"batch size\"",... | [
46,
0
] | [
61,
30
] | python | en | ['en', 'en', 'en'] | True |
build_graph_from_json | (ir_model_json) | build model from json representation
| build model from json representation
| def build_graph_from_json(ir_model_json):
"""build model from json representation
"""
graph = json_to_graph(ir_model_json)
logging.debug(graph.operation_history)
model = graph.produce_torch_model()
return model | [
"def",
"build_graph_from_json",
"(",
"ir_model_json",
")",
":",
"graph",
"=",
"json_to_graph",
"(",
"ir_model_json",
")",
"logging",
".",
"debug",
"(",
"graph",
".",
"operation_history",
")",
"model",
"=",
"graph",
".",
"produce_torch_model",
"(",
")",
"return",... | [
74,
0
] | [
80,
16
] | python | en | ['en', 'en', 'en'] | True |
parse_rev_args | (receive_msg) | parse reveive msgs to global variable
| parse reveive msgs to global variable
| def parse_rev_args(receive_msg):
""" parse reveive msgs to global variable
"""
global trainloader
global testloader
global net
global criterion
global optimizer
# Loading Data
logger.debug("Preparing data..")
raw_train_data = torchvision.datasets.FashionMNIST(
root="./d... | [
"def",
"parse_rev_args",
"(",
"receive_msg",
")",
":",
"global",
"trainloader",
"global",
"testloader",
"global",
"net",
"global",
"criterion",
"global",
"optimizer",
"# Loading Data",
"logger",
".",
"debug",
"(",
"\"Preparing data..\"",
")",
"raw_train_data",
"=",
... | [
83,
0
] | [
144,
12
] | python | en | ['en', 'en', 'en'] | True |
train | (epoch) | train model on each epoch in trainset
| train model on each epoch in trainset
| def train(epoch):
""" train model on each epoch in trainset
"""
global trainloader
global testloader
global net
global criterion
global optimizer
logger.debug("Epoch: %d", epoch)
net.train()
train_loss = 0
correct = 0
total = 0
for batch_idx, (inputs, targets) in e... | [
"def",
"train",
"(",
"epoch",
")",
":",
"global",
"trainloader",
"global",
"testloader",
"global",
"net",
"global",
"criterion",
"global",
"optimizer",
"logger",
".",
"debug",
"(",
"\"Epoch: %d\"",
",",
"epoch",
")",
"net",
".",
"train",
"(",
")",
"train_los... | [
148,
0
] | [
187,
14
] | python | en | ['en', 'fy', 'en'] | True |
test | (epoch) | eval model on each epoch in testset
| eval model on each epoch in testset
| def test(epoch):
""" eval model on each epoch in testset
"""
global best_acc
global trainloader
global testloader
global net
global criterion
global optimizer
logger.debug("Eval on epoch: %d", epoch)
net.eval()
test_loss = 0
correct = 0
total = 0
with torch.no_gr... | [
"def",
"test",
"(",
"epoch",
")",
":",
"global",
"best_acc",
"global",
"trainloader",
"global",
"testloader",
"global",
"net",
"global",
"criterion",
"global",
"optimizer",
"logger",
".",
"debug",
"(",
"\"Eval on epoch: %d\"",
",",
"epoch",
")",
"net",
".",
"e... | [
190,
0
] | [
229,
24
] | python | da | ['en', 'da', 'it'] | False |
test_migration_creates_new_flow | (hass, smartthings_mock, config_entry) | Test migration deletes app and creates new flow. | Test migration deletes app and creates new flow. | async def test_migration_creates_new_flow(hass, smartthings_mock, config_entry):
"""Test migration deletes app and creates new flow."""
assert await async_setup_component(hass, "persistent_notification", {})
config_entry.version = 1
config_entry.add_to_hass(hass)
await smartthings.async_migrate_ent... | [
"async",
"def",
"test_migration_creates_new_flow",
"(",
"hass",
",",
"smartthings_mock",
",",
"config_entry",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
".",
"version",
"... | [
28,
0
] | [
43,
54
] | python | en | ['en', 'en', 'en'] | True |
test_unrecoverable_api_errors_create_new_flow | (
hass, config_entry, smartthings_mock
) |
Test a new config flow is initiated when there are API errors.
401 (unauthorized): Occurs when the access token is no longer valid.
403 (forbidden/not found): Occurs when the app or installed app could
not be retrieved/found (likely deleted?)
|
Test a new config flow is initiated when there are API errors. | async def test_unrecoverable_api_errors_create_new_flow(
hass, config_entry, smartthings_mock
):
"""
Test a new config flow is initiated when there are API errors.
401 (unauthorized): Occurs when the access token is no longer valid.
403 (forbidden/not found): Occurs when the app or installed app co... | [
"async",
"def",
"test_unrecoverable_api_errors_create_new_flow",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"config_entry",
".",
... | [
46,
0
] | [
74,
61
] | python | en | ['en', 'error', 'th'] | False |
test_recoverable_api_errors_raise_not_ready | (
hass, config_entry, smartthings_mock
) | Test config entry not ready raised for recoverable API errors. | Test config entry not ready raised for recoverable API errors. | async def test_recoverable_api_errors_raise_not_ready(
hass, config_entry, smartthings_mock
):
"""Test config entry not ready raised for recoverable API errors."""
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://example.com")
smartthings_mock.app.side_effect = ClientResponseError... | [
"async",
"def",
"test_recoverable_api_errors_raise_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
... | [
77,
0
] | [
88,
63
] | python | en | ['en', 'en', 'en'] | True |
test_scenes_api_errors_raise_not_ready | (
hass, config_entry, app, installed_app, smartthings_mock
) | Test if scenes are unauthorized we continue to load platforms. | Test if scenes are unauthorized we continue to load platforms. | async def test_scenes_api_errors_raise_not_ready(
hass, config_entry, app, installed_app, smartthings_mock
):
"""Test if scenes are unauthorized we continue to load platforms."""
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://example.com")
smartthings_mock.app.return_value = app... | [
"async",
"def",
"test_scenes_api_errors_raise_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"request_info",
"=",
"Mock",
"(",
"real_url",
"="... | [
91,
0
] | [
103,
63
] | python | en | ['en', 'en', 'en'] | True |
test_connection_errors_raise_not_ready | (hass, config_entry, smartthings_mock) | Test config entry not ready raised for connection errors. | Test config entry not ready raised for connection errors. | async def test_connection_errors_raise_not_ready(hass, config_entry, smartthings_mock):
"""Test config entry not ready raised for connection errors."""
config_entry.add_to_hass(hass)
smartthings_mock.app.side_effect = ClientConnectionError()
with pytest.raises(ConfigEntryNotReady):
await smartt... | [
"async",
"def",
"test_connection_errors_raise_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"smartthings_mock",
".",
"app",
".",
"side_effect",
"=",
"ClientConnectionError",
"(",
... | [
106,
0
] | [
112,
63
] | python | en | ['en', 'en', 'en'] | True |
test_base_url_no_longer_https_does_not_load | (
hass, config_entry, app, smartthings_mock
) | Test base_url no longer valid creates a new flow. | Test base_url no longer valid creates a new flow. | async def test_base_url_no_longer_https_does_not_load(
hass, config_entry, app, smartthings_mock
):
"""Test base_url no longer valid creates a new flow."""
await async_process_ha_core_config(
hass,
{"external_url": "http://example.local:8123"},
)
config_entry.add_to_hass(hass)
sm... | [
"async",
"def",
"test_base_url_no_longer_https_does_not_load",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"smartthings_mock",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"http://example.local:8123\"",
"}",
... | [
115,
0
] | [
128,
21
] | python | en | ['en', 'fr', 'en'] | True |
test_unauthorized_installed_app_raises_not_ready | (
hass, config_entry, app, installed_app, smartthings_mock
) | Test config entry not ready raised when the app isn't authorized. | Test config entry not ready raised when the app isn't authorized. | async def test_unauthorized_installed_app_raises_not_ready(
hass, config_entry, app, installed_app, smartthings_mock
):
"""Test config entry not ready raised when the app isn't authorized."""
config_entry.add_to_hass(hass)
installed_app.installed_app_status = InstalledAppStatus.PENDING
smartthings_... | [
"async",
"def",
"test_unauthorized_installed_app_raises_not_ready",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"smartthings_mock",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"installed_app",
".",
"installed_app_status",... | [
131,
0
] | [
142,
63
] | python | en | ['en', 'en', 'en'] | True |
test_scenes_unauthorized_loads_platforms | (
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
) | Test if scenes are unauthorized we continue to load platforms. | Test if scenes are unauthorized we continue to load platforms. | async def test_scenes_unauthorized_loads_platforms(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
):
"""Test if scenes are unauthorized we continue to load platforms."""
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://... | [
"async",
"def",
"test_scenes_unauthorized_loads_platforms",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"device",
",",
"smartthings_mock",
",",
"subscription_factory",
",",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
145,
0
] | [
176,
66
] | python | en | ['en', 'en', 'en'] | True |
test_config_entry_loads_platforms | (
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
) | Test config entry loads properly and proxies to platforms. | Test config entry loads properly and proxies to platforms. | async def test_config_entry_loads_platforms(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
):
"""Test config entry loads properly and proxies to platforms."""
config_entry.add_to_hass(hass)
smartthings_mock.app.return_value = a... | [
"async",
"def",
"test_config_entry_loads_platforms",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"device",
",",
"smartthings_mock",
",",
"subscription_factory",
",",
"scene",
",",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"has... | [
179,
0
] | [
208,
66
] | python | en | ['en', 'en', 'en'] | True |
test_config_entry_loads_unconnected_cloud | (
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
) | Test entry loads during startup when cloud isn't connected. | Test entry loads during startup when cloud isn't connected. | async def test_config_entry_loads_unconnected_cloud(
hass,
config_entry,
app,
installed_app,
device,
smartthings_mock,
subscription_factory,
scene,
):
"""Test entry loads during startup when cloud isn't connected."""
config_entry.add_to_hass(hass)
hass.data[DOMAIN][CONF_CLOUD... | [
"async",
"def",
"test_config_entry_loads_unconnected_cloud",
"(",
"hass",
",",
"config_entry",
",",
"app",
",",
"installed_app",
",",
"device",
",",
"smartthings_mock",
",",
"subscription_factory",
",",
"scene",
",",
")",
":",
"config_entry",
".",
"add_to_hass",
"("... | [
211,
0
] | [
239,
66
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass, config_entry) | Test entries are unloaded correctly. | Test entries are unloaded correctly. | async def test_unload_entry(hass, config_entry):
"""Test entries are unloaded correctly."""
connect_disconnect = Mock()
smart_app = Mock()
smart_app.connect_event.return_value = connect_disconnect
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), smart_app, [], [])
broker.connect()
... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"connect_disconnect",
"=",
"Mock",
"(",
")",
"smart_app",
"=",
"Mock",
"(",
")",
"smart_app",
".",
"connect_event",
".",
"return_value",
"=",
"connect_disconnect",
"broker",
"=",
... | [
242,
0
] | [
260,
66
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry | (hass, config_entry, smartthings_mock) | Test that the installed app and app are removed up. | Test that the installed app and app are removed up. | async def test_remove_entry(hass, config_entry, smartthings_mock):
"""Test that the installed app and app are removed up."""
# Act
await smartthings.async_remove_entry(hass, config_entry)
# Assert
assert smartthings_mock.delete_installed_app.call_count == 1
assert smartthings_mock.delete_app.cal... | [
"async",
"def",
"test_remove_entry",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Act",
"await",
"smartthings",
".",
"async_remove_entry",
"(",
"hass",
",",
"config_entry",
")",
"# Assert",
"assert",
"smartthings_mock",
".",
"delete_instal... | [
263,
0
] | [
269,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_cloudhook | (hass, config_entry, smartthings_mock) | Test that the installed app, app, and cloudhook are removed up. | Test that the installed app, app, and cloudhook are removed up. | async def test_remove_entry_cloudhook(hass, config_entry, smartthings_mock):
"""Test that the installed app, app, and cloudhook are removed up."""
hass.config.components.add("cloud")
# Arrange
config_entry.add_to_hass(hass)
hass.data[DOMAIN][CONF_CLOUDHOOK_URL] = "https://test.cloud"
# Act
w... | [
"async",
"def",
"test_remove_entry_cloudhook",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"hass",
".",
"config",
".",
"components",
".",
"add",
"(",
"\"cloud\"",
")",
"# Arrange",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
272,
0
] | [
289,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_app_in_use | (hass, config_entry, smartthings_mock) | Test app is not removed if in use by another config entry. | Test app is not removed if in use by another config entry. | async def test_remove_entry_app_in_use(hass, config_entry, smartthings_mock):
"""Test app is not removed if in use by another config entry."""
# Arrange
config_entry.add_to_hass(hass)
data = config_entry.data.copy()
data[CONF_INSTALLED_APP_ID] = str(uuid4())
entry2 = MockConfigEntry(version=2, d... | [
"async",
"def",
"test_remove_entry_app_in_use",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"data",
"=",
"config_entry",
".",
"data",
".",
"copy",
"(",
")",
"data",
"["... | [
292,
0
] | [
304,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_already_deleted | (hass, config_entry, smartthings_mock) | Test handles when the apps have already been removed. | Test handles when the apps have already been removed. | async def test_remove_entry_already_deleted(hass, config_entry, smartthings_mock):
"""Test handles when the apps have already been removed."""
request_info = Mock(real_url="http://example.com")
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
request_info=reques... | [
"async",
"def",
"test_remove_entry_already_deleted",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"# Arrange",
"smartthings_mock",
".",
"delete_installed_app",
".",... | [
307,
0
] | [
321,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_installedapp_api_error | (
hass, config_entry, smartthings_mock
) | Test raises exceptions removing the installed app. | Test raises exceptions removing the installed app. | async def test_remove_entry_installedapp_api_error(
hass, config_entry, smartthings_mock
):
"""Test raises exceptions removing the installed app."""
request_info = Mock(real_url="http://example.com")
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
request_i... | [
"async",
"def",
"test_remove_entry_installedapp_api_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"# Arrange",
"smartthings_mock",
".",
"delete_installed_app",... | [
324,
0
] | [
338,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_installedapp_unknown_error | (
hass, config_entry, smartthings_mock
) | Test raises exceptions removing the installed app. | Test raises exceptions removing the installed app. | async def test_remove_entry_installedapp_unknown_error(
hass, config_entry, smartthings_mock
):
"""Test raises exceptions removing the installed app."""
# Arrange
smartthings_mock.delete_installed_app.side_effect = Exception
# Act
with pytest.raises(Exception):
await smartthings.async_re... | [
"async",
"def",
"test_remove_entry_installedapp_unknown_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"smartthings_mock",
".",
"delete_installed_app",
".",
"side_effect",
"=",
"Exception",
"# Act",
"with",
"pytest",
".",
"rais... | [
341,
0
] | [
352,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_app_api_error | (hass, config_entry, smartthings_mock) | Test raises exceptions removing the app. | Test raises exceptions removing the app. | async def test_remove_entry_app_api_error(hass, config_entry, smartthings_mock):
"""Test raises exceptions removing the app."""
# Arrange
request_info = Mock(real_url="http://example.com")
smartthings_mock.delete_app.side_effect = ClientResponseError(
request_info=request_info, history=None, sta... | [
"async",
"def",
"test_remove_entry_app_api_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"request_info",
"=",
"Mock",
"(",
"real_url",
"=",
"\"http://example.com\"",
")",
"smartthings_mock",
".",
"delete_app",
".",
"side_eff... | [
355,
0
] | [
367,
54
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_app_unknown_error | (hass, config_entry, smartthings_mock) | Test raises exceptions removing the app. | Test raises exceptions removing the app. | async def test_remove_entry_app_unknown_error(hass, config_entry, smartthings_mock):
"""Test raises exceptions removing the app."""
# Arrange
smartthings_mock.delete_app.side_effect = Exception
# Act
with pytest.raises(Exception):
await smartthings.async_remove_entry(hass, config_entry)
... | [
"async",
"def",
"test_remove_entry_app_unknown_error",
"(",
"hass",
",",
"config_entry",
",",
"smartthings_mock",
")",
":",
"# Arrange",
"smartthings_mock",
".",
"delete_app",
".",
"side_effect",
"=",
"Exception",
"# Act",
"with",
"pytest",
".",
"raises",
"(",
"Exce... | [
370,
0
] | [
379,
54
] | python | en | ['en', 'en', 'en'] | True |
test_broker_regenerates_token | (hass, config_entry) | Test the device broker regenerates the refresh token. | Test the device broker regenerates the refresh token. | async def test_broker_regenerates_token(hass, config_entry):
"""Test the device broker regenerates the refresh token."""
token = Mock(OAuthToken)
token.refresh_token = str(uuid4())
stored_action = None
def async_track_time_interval(hass, action, interval):
nonlocal stored_action
sto... | [
"async",
"def",
"test_broker_regenerates_token",
"(",
"hass",
",",
"config_entry",
")",
":",
"token",
"=",
"Mock",
"(",
"OAuthToken",
")",
"token",
".",
"refresh_token",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"stored_action",
"=",
"None",
"def",
"async_tra... | [
382,
0
] | [
402,
71
] | python | en | ['en', 'en', 'en'] | True |
test_event_handler_dispatches_updated_devices | (
hass, config_entry, device_factory, event_request_factory, event_factory
) | Test the event handler dispatches updated devices. | Test the event handler dispatches updated devices. | async def test_event_handler_dispatches_updated_devices(
hass, config_entry, device_factory, event_request_factory, event_factory
):
"""Test the event handler dispatches updated devices."""
devices = [
device_factory("Bedroom 1 Switch", ["switch"]),
device_factory("Bathroom 1", ["switch"]),
... | [
"async",
"def",
"test_event_handler_dispatches_updated_devices",
"(",
"hass",
",",
"config_entry",
",",
"device_factory",
",",
"event_request_factory",
",",
"event_factory",
")",
":",
"devices",
"=",
"[",
"device_factory",
"(",
"\"Bedroom 1 Switch\"",
",",
"[",
"\"switc... | [
405,
0
] | [
453,
71
] | python | en | ['en', 'en', 'en'] | True |
test_event_handler_ignores_other_installed_app | (
hass, config_entry, device_factory, event_request_factory
) | Test the event handler dispatches updated devices. | Test the event handler dispatches updated devices. | async def test_event_handler_ignores_other_installed_app(
hass, config_entry, device_factory, event_request_factory
):
"""Test the event handler dispatches updated devices."""
device = device_factory("Bedroom 1 Switch", ["switch"])
request = event_request_factory([device.device_id])
called = False
... | [
"async",
"def",
"test_event_handler_ignores_other_installed_app",
"(",
"hass",
",",
"config_entry",
",",
"device_factory",
",",
"event_request_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Bedroom 1 Switch\"",
",",
"[",
"\"switch\"",
"]",
")",
"request",
... | [
456,
0
] | [
476,
21
] | python | en | ['en', 'en', 'en'] | True |
test_event_handler_fires_button_events | (
hass, config_entry, device_factory, event_factory, event_request_factory
) | Test the event handler fires button events. | Test the event handler fires button events. | async def test_event_handler_fires_button_events(
hass, config_entry, device_factory, event_factory, event_request_factory
):
"""Test the event handler fires button events."""
device = device_factory("Button 1", ["button"])
event = event_factory(
device.device_id, capability="button", attribute=... | [
"async",
"def",
"test_event_handler_fires_button_events",
"(",
"hass",
",",
"config_entry",
",",
"device_factory",
",",
"event_factory",
",",
"event_request_factory",
")",
":",
"device",
"=",
"device_factory",
"(",
"\"Button 1\"",
",",
"[",
"\"button\"",
"]",
")",
"... | [
479,
0
] | [
514,
17
] | python | en | ['en', 'en', 'en'] | True |
get_departures_mock | () | Mock rmvtransport departures loading. | Mock rmvtransport departures loading. | def get_departures_mock():
"""Mock rmvtransport departures loading."""
return {
"station": "Frankfurt (Main) Hauptbahnhof",
"stationId": "3000010",
"filter": "11111111111",
"journeys": [
{
"product": "Tram",
"number": 12,
... | [
"def",
"get_departures_mock",
"(",
")",
":",
"return",
"{",
"\"station\"",
":",
"\"Frankfurt (Main) Hauptbahnhof\"",
",",
"\"stationId\"",
":",
"\"3000010\"",
",",
"\"filter\"",
":",
"\"11111111111\"",
",",
"\"journeys\"",
":",
"[",
"{",
"\"product\"",
":",
"\"Tram\... | [
48,
0
] | [
146,
5
] | python | da | ['fr', 'da', 'pt'] | False |
get_no_departures_mock | () | Mock no departures in results. | Mock no departures in results. | def get_no_departures_mock():
"""Mock no departures in results."""
return {
"station": "Frankfurt (Main) Hauptbahnhof",
"stationId": "3000010",
"filter": "11111111111",
"journeys": [],
} | [
"def",
"get_no_departures_mock",
"(",
")",
":",
"return",
"{",
"\"station\"",
":",
"\"Frankfurt (Main) Hauptbahnhof\"",
",",
"\"stationId\"",
":",
"\"3000010\"",
",",
"\"filter\"",
":",
"\"11111111111\"",
",",
"\"journeys\"",
":",
"[",
"]",
",",
"}"
] | [
149,
0
] | [
156,
5
] | python | en | ['pt', 'en', 'en'] | True |
test_rmvtransport_min_config | (hass) | Test minimal rmvtransport configuration. | Test minimal rmvtransport configuration. | async def test_rmvtransport_min_config(hass):
"""Test minimal rmvtransport configuration."""
with patch(
"RMVtransport.RMVtransport.get_departures",
return_value=get_departures_mock(),
):
assert await async_setup_component(hass, "sensor", VALID_CONFIG_MINIMAL) is True
await h... | [
"async",
"def",
"test_rmvtransport_min_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"RMVtransport.RMVtransport.get_departures\"",
",",
"return_value",
"=",
"get_departures_mock",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"has... | [
159,
0
] | [
177,
79
] | python | de | ['de', 'et', 'it'] | False |
test_rmvtransport_name_config | (hass) | Test custom name configuration. | Test custom name configuration. | async def test_rmvtransport_name_config(hass):
"""Test custom name configuration."""
with patch(
"RMVtransport.RMVtransport.get_departures",
return_value=get_departures_mock(),
):
assert await async_setup_component(hass, "sensor", VALID_CONFIG_NAME)
await hass.async_block_til... | [
"async",
"def",
"test_rmvtransport_name_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"RMVtransport.RMVtransport.get_departures\"",
",",
"return_value",
"=",
"get_departures_mock",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"ha... | [
180,
0
] | [
190,
60
] | python | en | ['en', 'sm', 'en'] | True |
test_rmvtransport_misc_config | (hass) | Test misc configuration. | Test misc configuration. | async def test_rmvtransport_misc_config(hass):
"""Test misc configuration."""
with patch(
"RMVtransport.RMVtransport.get_departures",
return_value=get_departures_mock(),
):
assert await async_setup_component(hass, "sensor", VALID_CONFIG_MISC)
await hass.async_block_till_done(... | [
"async",
"def",
"test_rmvtransport_misc_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"RMVtransport.RMVtransport.get_departures\"",
",",
"return_value",
"=",
"get_departures_mock",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"ha... | [
193,
0
] | [
204,
41
] | python | en | ['en', 'fr', 'en'] | True |
test_rmvtransport_dest_config | (hass) | Test destination configuration. | Test destination configuration. | async def test_rmvtransport_dest_config(hass):
"""Test destination configuration."""
with patch(
"RMVtransport.RMVtransport.get_departures",
return_value=get_departures_mock(),
):
assert await async_setup_component(hass, "sensor", VALID_CONFIG_DEST)
await hass.async_block_til... | [
"async",
"def",
"test_rmvtransport_dest_config",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"RMVtransport.RMVtransport.get_departures\"",
",",
"return_value",
"=",
"get_departures_mock",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"ha... | [
207,
0
] | [
223,
86
] | python | fr | ['fr', 'fr', 'en'] | True |
test_rmvtransport_no_departures | (hass) | Test for no departures. | Test for no departures. | async def test_rmvtransport_no_departures(hass):
"""Test for no departures."""
with patch(
"RMVtransport.RMVtransport.get_departures",
return_value=get_no_departures_mock(),
):
assert await async_setup_component(hass, "sensor", VALID_CONFIG_MINIMAL)
await hass.async_block_til... | [
"async",
"def",
"test_rmvtransport_no_departures",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"RMVtransport.RMVtransport.get_departures\"",
",",
"return_value",
"=",
"get_no_departures_mock",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
... | [
226,
0
] | [
236,
39
] | python | pt | ['pt', 'en', 'pt'] | True |
RuleBasedAlgorithm.allocate_vm | (self, decision_event: DecisionPayload, env: Env) | This method will determine allocate which PM to the current VM.
| This method will determine allocate which PM to the current VM.
| def allocate_vm(self, decision_event: DecisionPayload, env: Env) -> AllocateAction:
"""This method will determine allocate which PM to the current VM.
"""
pass | [
"def",
"allocate_vm",
"(",
"self",
",",
"decision_event",
":",
"DecisionPayload",
",",
"env",
":",
"Env",
")",
"->",
"AllocateAction",
":",
"pass"
] | [
10,
4
] | [
13,
12
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Magicseaweed sensor. | Set up the Magicseaweed sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Magicseaweed sensor."""
name = config.get(CONF_NAME)
spot_id = config[CONF_SPOT_ID]
api_key = config[CONF_API_KEY]
hours = config.get(CONF_HOURS)
if CONF_UNITS in config:
units = config.get(CONF_UNITS)
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"spot_id",
"=",
"config",
"[",
"CONF_SPOT_ID",
"]",
"api_key",
"=",
"config",
... | [
60,
0
] | [
89,
31
] | python | en | ['en', 'xh', 'en'] | True |
MagicSeaweedSensor.__init__ | (self, forecast_data, sensor_type, name, unit_system, hour=None) | Initialize the sensor. | Initialize the sensor. | def __init__(self, forecast_data, sensor_type, name, unit_system, hour=None):
"""Initialize the sensor."""
self.client_name = name
self.data = forecast_data
self.hour = hour
self.type = sensor_type
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
self._name =... | [
"def",
"__init__",
"(",
"self",
",",
"forecast_data",
",",
"sensor_type",
",",
"name",
",",
"unit_system",
",",
"hour",
"=",
"None",
")",
":",
"self",
".",
"client_name",
"=",
"name",
"self",
".",
"data",
"=",
"forecast_data",
"self",
".",
"hour",
"=",
... | [
95,
4
] | [
106,
40
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
if self.hour is None and "forecast" in self.type:
return f"{self.client_name} {self._name}"
if self.hour is None:
return f"Current {self.client_name} {self._name}"
return f"{self.hour} {self.client_name} {self._... | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"hour",
"is",
"None",
"and",
"\"forecast\"",
"in",
"self",
".",
"type",
":",
"return",
"f\"{self.client_name} {self._name}\"",
"if",
"self",
".",
"hour",
"is",
"None",
":",
"return",
"f\"Current {self.... | [
109,
4
] | [
115,
61
] | python | en | ['en', 'mi', 'en'] | True |
MagicSeaweedSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
118,
4
] | [
120,
26
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedSensor.unit_system | (self) | Return the unit system of this entity. | Return the unit system of this entity. | def unit_system(self):
"""Return the unit system of this entity."""
return self._unit_system | [
"def",
"unit_system",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_system"
] | [
123,
4
] | [
125,
32
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
128,
4
] | [
130,
40
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedSensor.icon | (self) | Return the entity weather icon, if any. | Return the entity weather icon, if any. | def icon(self):
"""Return the entity weather icon, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
133,
4
] | [
135,
19
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attrs"
] | [
138,
4
] | [
140,
26
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedSensor.update | (self) | Get the latest data from Magicseaweed and updates the states. | Get the latest data from Magicseaweed and updates the states. | def update(self):
"""Get the latest data from Magicseaweed and updates the states."""
self.data.update()
if self.hour is None:
forecast = self.data.currently
else:
forecast = self.data.hourly[self.hour]
self._unit_of_measurement = forecast.swell_unit
... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"data",
".",
"update",
"(",
")",
"if",
"self",
".",
"hour",
"is",
"None",
":",
"forecast",
"=",
"self",
".",
"data",
".",
"currently",
"else",
":",
"forecast",
"=",
"self",
".",
"data",
".",
"h... | [
142,
4
] | [
165,
46
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedData.__init__ | (self, api_key, spot_id, units) | Initialize the data object. | Initialize the data object. | def __init__(self, api_key, spot_id, units):
"""Initialize the data object."""
self._msw = magicseaweed.MSW_Forecast(api_key, spot_id, None, units)
self.currently = None
self.hourly = {}
# Apply throttling to methods using configured interval
self.update = Throttle(MIN_T... | [
"def",
"__init__",
"(",
"self",
",",
"api_key",
",",
"spot_id",
",",
"units",
")",
":",
"self",
".",
"_msw",
"=",
"magicseaweed",
".",
"MSW_Forecast",
"(",
"api_key",
",",
"spot_id",
",",
"None",
",",
"units",
")",
"self",
".",
"currently",
"=",
"None"... | [
171,
4
] | [
178,
70
] | python | en | ['en', 'en', 'en'] | True |
MagicSeaweedData._update | (self) | Get the latest data from MagicSeaweed. | Get the latest data from MagicSeaweed. | def _update(self):
"""Get the latest data from MagicSeaweed."""
try:
forecasts = self._msw.get_future()
self.currently = forecasts.data[0]
for forecast in forecasts.data[:8]:
hour = dt_util.utc_from_timestamp(forecast.localTimestamp).strftime(
... | [
"def",
"_update",
"(",
"self",
")",
":",
"try",
":",
"forecasts",
"=",
"self",
".",
"_msw",
".",
"get_future",
"(",
")",
"self",
".",
"currently",
"=",
"forecasts",
".",
"data",
"[",
"0",
"]",
"for",
"forecast",
"in",
"forecasts",
".",
"data",
"[",
... | [
180,
4
] | [
191,
70
] | python | en | ['en', 'en', 'en'] | True |
async_get_scanner | (hass, config, discovery_info=None) | Configure the OPNSense device_tracker. | Configure the OPNSense device_tracker. | async def async_get_scanner(hass, config, discovery_info=None):
"""Configure the OPNSense device_tracker."""
interface_client = hass.data[OPNSENSE_DATA]["interfaces"]
scanner = OPNSenseDeviceScanner(
interface_client, hass.data[OPNSENSE_DATA][CONF_TRACKER_INTERFACE]
)
return scanner | [
"async",
"def",
"async_get_scanner",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"interface_client",
"=",
"hass",
".",
"data",
"[",
"OPNSENSE_DATA",
"]",
"[",
"\"interfaces\"",
"]",
"scanner",
"=",
"OPNSenseDeviceScanner",
"(",
"i... | [
5,
0
] | [
11,
18
] | python | en | ['en', 'en', 'en'] | True |
OPNSenseDeviceScanner.__init__ | (self, client, interfaces) | Initialize the scanner. | Initialize the scanner. | def __init__(self, client, interfaces):
"""Initialize the scanner."""
self.last_results = {}
self.client = client
self.interfaces = interfaces | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"interfaces",
")",
":",
"self",
".",
"last_results",
"=",
"{",
"}",
"self",
".",
"client",
"=",
"client",
"self",
".",
"interfaces",
"=",
"interfaces"
] | [
17,
4
] | [
21,
36
] | python | en | ['en', 'en', 'en'] | True |
OPNSenseDeviceScanner._get_mac_addrs | (self, devices) | Create dict with mac address keys from list of devices. | Create dict with mac address keys from list of devices. | def _get_mac_addrs(self, devices):
"""Create dict with mac address keys from list of devices."""
out_devices = {}
for device in devices:
if not self.interfaces:
out_devices[device["mac"]] = device
elif device["intf_description"] in self.interfaces:
... | [
"def",
"_get_mac_addrs",
"(",
"self",
",",
"devices",
")",
":",
"out_devices",
"=",
"{",
"}",
"for",
"device",
"in",
"devices",
":",
"if",
"not",
"self",
".",
"interfaces",
":",
"out_devices",
"[",
"device",
"[",
"\"mac\"",
"]",
"]",
"=",
"device",
"el... | [
23,
4
] | [
31,
26
] | python | en | ['en', 'en', 'en'] | True |
OPNSenseDeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self.update_info()
return list(self.last_results) | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"update_info",
"(",
")",
"return",
"list",
"(",
"self",
".",
"last_results",
")"
] | [
33,
4
] | [
36,
38
] | python | en | ['en', 'en', 'en'] | True |
OPNSenseDeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
if device not in self.last_results:
return None
hostname = self.last_results[device].get("hostname") or None
return hostname | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"if",
"device",
"not",
"in",
"self",
".",
"last_results",
":",
"return",
"None",
"hostname",
"=",
"self",
".",
"last_results",
"[",
"device",
"]",
".",
"get",
"(",
"\"hostname\"",
")",
"or",... | [
38,
4
] | [
43,
23
] | python | en | ['en', 'en', 'en'] | True |
OPNSenseDeviceScanner.update_info | (self) | Ensure the information from the OPNSense router is up to date.
Return boolean if scanning successful.
| Ensure the information from the OPNSense router is up to date. | def update_info(self):
"""Ensure the information from the OPNSense router is up to date.
Return boolean if scanning successful.
"""
devices = self.client.get_arp()
self.last_results = self._get_mac_addrs(devices) | [
"def",
"update_info",
"(",
"self",
")",
":",
"devices",
"=",
"self",
".",
"client",
".",
"get_arp",
"(",
")",
"self",
".",
"last_results",
"=",
"self",
".",
"_get_mac_addrs",
"(",
"devices",
")"
] | [
45,
4
] | [
52,
56
] | python | en | ['en', 'en', 'en'] | True |
OPNSenseDeviceScanner.get_extra_attributes | (self, device) | Return the extra attrs of the given device. | Return the extra attrs of the given device. | def get_extra_attributes(self, device):
"""Return the extra attrs of the given device."""
if device not in self.last_results:
return None
mfg = self.last_results[device].get("manufacturer")
if not mfg:
return {}
return {"manufacturer": mfg} | [
"def",
"get_extra_attributes",
"(",
"self",
",",
"device",
")",
":",
"if",
"device",
"not",
"in",
"self",
".",
"last_results",
":",
"return",
"None",
"mfg",
"=",
"self",
".",
"last_results",
"[",
"device",
"]",
".",
"get",
"(",
"\"manufacturer\"",
")",
"... | [
54,
4
] | [
61,
36
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Decora WiFi platform. | Set up the Decora WiFi platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Decora WiFi platform."""
email = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
session = DecoraWiFiSession()
try:
success = session.login(email, password)
# If login failed, notify user.
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"email",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"config",
"[",
"CONF_PASSWORD",
"]",
"session",
"=",
"DecoraWiFiSession"... | [
33,
0
] | [
79,
53
] | python | en | ['en', 'lv', 'en'] | True |
DecoraWifiLight.__init__ | (self, switch) | Initialize the switch. | Initialize the switch. | def __init__(self, switch):
"""Initialize the switch."""
self._switch = switch | [
"def",
"__init__",
"(",
"self",
",",
"switch",
")",
":",
"self",
".",
"_switch",
"=",
"switch"
] | [
85,
4
] | [
87,
29
] | python | en | ['en', 'en', 'en'] | True |
DecoraWifiLight.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self):
"""Return supported features."""
if self._switch.canSetLevel:
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
return 0 | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_switch",
".",
"canSetLevel",
":",
"return",
"SUPPORT_BRIGHTNESS",
"|",
"SUPPORT_TRANSITION",
"return",
"0"
] | [
90,
4
] | [
94,
16
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.