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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
VL53L1XSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
80,
4
] | [
82,
25
] | python | en | ['en', 'mi', 'en'] | True |
VL53L1XSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> int:
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_state"
] | [
85,
4
] | [
87,
26
] | python | en | ['en', 'en', 'en'] | True |
VL53L1XSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self) -> str:
"""Return the unit of measurement."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
90,
4
] | [
92,
40
] | python | en | ['en', 'la', 'en'] | True |
VL53L1XSensor.update | (self) | Get the latest measurement and update state. | Get the latest measurement and update state. | def update(self):
"""Get the latest measurement and update state."""
if self.init:
self.vl53l1x_sensor.add_sensor(self.i2c_address, self.i2c_address)
self.init = False
self.vl53l1x_sensor.start_ranging(self.i2c_address, DEFAULT_RANGE)
self.vl53l1x_sensor.update(se... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"init",
":",
"self",
".",
"vl53l1x_sensor",
".",
"add_sensor",
"(",
"self",
".",
"i2c_address",
",",
"self",
".",
"i2c_address",
")",
"self",
".",
"init",
"=",
"False",
"self",
".",
"vl53l1x_se... | [
94,
4
] | [
102,
50
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Fibaro locks. | Set up the Fibaro locks. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Fibaro locks."""
if discovery_info is None:
return
add_entities(
[FibaroLock(device) for device in hass.data[FIBARO_DEVICES]["lock"]], True
) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"add_entities",
"(",
"[",
"FibaroLock",
"(",
"device",
")",
"for",
"device",
"in",
... | [
6,
0
] | [
13,
5
] | python | en | ['en', 'et', 'en'] | True |
FibaroLock.__init__ | (self, fibaro_device) | Initialize the Fibaro device. | Initialize the Fibaro device. | def __init__(self, fibaro_device):
"""Initialize the Fibaro device."""
self._state = False
super().__init__(fibaro_device)
self.entity_id = f"{DOMAIN}.{self.ha_id}" | [
"def",
"__init__",
"(",
"self",
",",
"fibaro_device",
")",
":",
"self",
".",
"_state",
"=",
"False",
"super",
"(",
")",
".",
"__init__",
"(",
"fibaro_device",
")",
"self",
".",
"entity_id",
"=",
"f\"{DOMAIN}.{self.ha_id}\""
] | [
19,
4
] | [
23,
49
] | python | en | ['en', 'en', 'en'] | True |
FibaroLock.lock | (self, **kwargs) | Lock the device. | Lock the device. | def lock(self, **kwargs):
"""Lock the device."""
self.action("secure")
self._state = True | [
"def",
"lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"action",
"(",
"\"secure\"",
")",
"self",
".",
"_state",
"=",
"True"
] | [
25,
4
] | [
28,
26
] | python | en | ['en', 'en', 'en'] | True |
FibaroLock.unlock | (self, **kwargs) | Unlock the device. | Unlock the device. | def unlock(self, **kwargs):
"""Unlock the device."""
self.action("unsecure")
self._state = False | [
"def",
"unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"action",
"(",
"\"unsecure\"",
")",
"self",
".",
"_state",
"=",
"False"
] | [
30,
4
] | [
33,
27
] | python | en | ['en', 'zh', 'en'] | True |
FibaroLock.is_locked | (self) | Return true if device is locked. | Return true if device is locked. | def is_locked(self):
"""Return true if device is locked."""
return self._state | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
36,
4
] | [
38,
26
] | python | en | ['en', 'fy', 'en'] | True |
FibaroLock.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
self._state = self.current_binary_state | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"current_binary_state"
] | [
40,
4
] | [
42,
47
] | python | en | ['fr', 'en', 'en'] | True |
test_server_sends_200_response | () | test home route works | test home route works | def test_server_sends_200_response():
"""test home route works"""
response = requests.get('http://127.0.0.1:3000')
assert response.status_code == 200
assert '<title> cowsay </title>' in response.text | [
"def",
"test_server_sends_200_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000'",
")",
"assert",
"response",
".",
"status_code",
"==",
"200",
"assert",
"'<title> cowsay </title>'",
"in",
"response",
".",
"text"
] | [
3,
0
] | [
7,
53
] | python | en | ['en', 'en', 'en'] | True |
test_server_sends_200_response_header | () | test home route works | test home route works | def test_server_sends_200_response_header():
"""test home route works"""
response = requests.get('http://127.0.0.1:3000')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_sends_200_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
10,
0
] | [
13,
68
] | python | en | ['en', 'en', 'en'] | True |
test_server_cowsay_sends_200_response | () | test cowsay route works | test cowsay route works | def test_server_cowsay_sends_200_response():
"""test cowsay route works"""
response = requests.get('http://127.0.0.1:3000/cowsay')
assert response.status_code == 200
assert 'address bar' in response.text | [
"def",
"test_server_cowsay_sends_200_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cowsay'",
")",
"assert",
"response",
".",
"status_code",
"==",
"200",
"assert",
"'address bar'",
"in",
"response",
".",
"text"
] | [
16,
0
] | [
20,
41
] | python | en | ['en', 'en', 'en'] | True |
test_server_cowsay_sends_200_response_header | () | test cowsay route works | test cowsay route works | def test_server_cowsay_sends_200_response_header():
"""test cowsay route works"""
response = requests.get('http://127.0.0.1:3000/cowsay')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_cowsay_sends_200_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cowsay'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
23,
0
] | [
26,
68
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_sends_200_response | () | test message route works | test message route works | def test_server_cow_sends_200_response():
"""test message route works"""
response = requests.get('http://127.0.0.1:3000/cow?msg="hello world"')
assert response.status_code == 200
assert 'hello world' in response.text | [
"def",
"test_server_cow_sends_200_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cow?msg=\"hello world\"'",
")",
"assert",
"response",
".",
"status_code",
"==",
"200",
"assert",
"'hello world'",
"in",
"response",
".",
"... | [
29,
0
] | [
33,
41
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_sends_200_response_header | () | test message route works | test message route works | def test_server_cow_sends_200_response_header():
"""test message route works"""
response = requests.get('http://127.0.0.1:3000/cow?msg="hello world"')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_cow_sends_200_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cow?msg=\"hello world\"'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
36,
0
] | [
39,
68
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_sends_400_response | () | test cow route sends 400 | test cow route sends 400 | def test_server_cow_sends_400_response():
"""test cow route sends 400"""
response = requests.get('http://127.0.0.1:3000/cow?msg=hello')
assert response.status_code == 400
assert response.text == 'Incorrect format' | [
"def",
"test_server_cow_sends_400_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cow?msg=hello'",
")",
"assert",
"response",
".",
"status_code",
"==",
"400",
"assert",
"response",
".",
"text",
"==",
"'Incorrect format'"... | [
42,
0
] | [
46,
46
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_sends_400_response_header | () | test cow route sends 400 | test cow route sends 400 | def test_server_cow_sends_400_response_header():
"""test cow route sends 400"""
response = requests.get('http://127.0.0.1:3000/cow?msg=hello')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_cow_sends_400_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cow?msg=hello'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
49,
0
] | [
52,
68
] | python | en | ['en', 'en', 'en'] | True |
test_server_sends_404_response | () | test bad route | test bad route | def test_server_sends_404_response():
"""test bad route"""
response = requests.get('http://127.0.0.1:3000/cowsa')
assert response.status_code == 404
assert response.text == 'Not Found' | [
"def",
"test_server_sends_404_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cowsa'",
")",
"assert",
"response",
".",
"status_code",
"==",
"404",
"assert",
"response",
".",
"text",
"==",
"'Not Found'"
] | [
55,
0
] | [
59,
39
] | python | en | ['en', 'en', 'en'] | True |
test_server_sends_404_response_header | () | test bad route | test bad route | def test_server_sends_404_response_header():
"""test bad route"""
response = requests.get('http://127.0.0.1:3000/cowsa')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_sends_404_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://127.0.0.1:3000/cowsa'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
62,
0
] | [
65,
68
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_post_sends_201_response | () | test post route works | test post route works | def test_server_cow_post_sends_201_response():
"""test post route works"""
response = requests.post('http://127.0.0.1:3000/cow', json={'msg': 'test'})
assert response.status_code == 201
assert 'test' in response.text | [
"def",
"test_server_cow_post_sends_201_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'http://127.0.0.1:3000/cow'",
",",
"json",
"=",
"{",
"'msg'",
":",
"'test'",
"}",
")",
"assert",
"response",
".",
"status_code",
"==",
"201",
"assert... | [
68,
0
] | [
72,
34
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_post_sends_201_response_header | () | test post route works | test post route works | def test_server_cow_post_sends_201_response_header():
"""test post route works"""
response = requests.post('http://127.0.0.1:3000/cow', json={'msg': 'test'})
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4'
assert response.headers['Content-Type'] == 'application/json' | [
"def",
"test_server_cow_post_sends_201_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'http://127.0.0.1:3000/cow'",
",",
"json",
"=",
"{",
"'msg'",
":",
"'test'",
"}",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
... | [
75,
0
] | [
79,
65
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_post_sends_400_response | () | test post route 400 works | test post route 400 works | def test_server_cow_post_sends_400_response():
"""test post route 400 works"""
response = requests.post('http://127.0.0.1:3000/cow?"ms4g=hello')
assert response.status_code == 400
assert response.text == 'Incorrect format' | [
"def",
"test_server_cow_post_sends_400_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'http://127.0.0.1:3000/cow?\"ms4g=hello'",
")",
"assert",
"response",
".",
"status_code",
"==",
"400",
"assert",
"response",
".",
"text",
"==",
"'Incorrect... | [
82,
0
] | [
86,
46
] | python | en | ['en', 'en', 'en'] | True |
test_server_cow_post_sends_400_response_header | () | test post route 400 works | test post route 400 works | def test_server_cow_post_sends_400_response_header():
"""test post route 400 works"""
response = requests.post('http://127.0.0.1:3000/cow?"ms4g=hello')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_cow_post_sends_400_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'http://127.0.0.1:3000/cow?\"ms4g=hello'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
89,
0
] | [
92,
68
] | python | en | ['en', 'en', 'en'] | True |
test_server_post_sends_404_response | () | test post route 404 error works | test post route 404 error works | def test_server_post_sends_404_response():
"""test post route 404 error works"""
response = requests.post('http://127.0.0.1:3000/cowsa')
assert response.status_code == 404
assert response.text == 'Not Found' | [
"def",
"test_server_post_sends_404_response",
"(",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'http://127.0.0.1:3000/cowsa'",
")",
"assert",
"response",
".",
"status_code",
"==",
"404",
"assert",
"response",
".",
"text",
"==",
"'Not Found'"
] | [
95,
0
] | [
99,
39
] | python | en | ['en', 'en', 'en'] | True |
test_server_post_sends_404_response_header | () | test post route 404 error works | test post route 404 error works | def test_server_post_sends_404_response_header():
"""test post route 404 error works"""
response = requests.post('http://127.0.0.1:3000/cowsa')
assert response.headers['Server'] == 'BaseHTTP/0.6 Python/3.6.4' | [
"def",
"test_server_post_sends_404_response_header",
"(",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'http://127.0.0.1:3000/cowsa'",
")",
"assert",
"response",
".",
"headers",
"[",
"'Server'",
"]",
"==",
"'BaseHTTP/0.6 Python/3.6.4'"
] | [
102,
0
] | [
105,
68
] | python | en | ['en', 'en', 'en'] | True |
MockDevice.__init__ | (self, udn) | Initialize mock device. | Initialize mock device. | def __init__(self, udn):
"""Initialize mock device."""
igd_device = object()
super().__init__(igd_device)
self._udn = udn
self.added_port_mappings = []
self.removed_port_mappings = [] | [
"def",
"__init__",
"(",
"self",
",",
"udn",
")",
":",
"igd_device",
"=",
"object",
"(",
")",
"super",
"(",
")",
".",
"__init__",
"(",
"igd_device",
")",
"self",
".",
"_udn",
"=",
"udn",
"self",
".",
"added_port_mappings",
"=",
"[",
"]",
"self",
".",
... | [
18,
4
] | [
24,
39
] | python | en | ['es', 'en', 'en'] | True |
MockDevice.async_create_device | (cls, hass, ssdp_location) | Return self. | Return self. | async def async_create_device(cls, hass, ssdp_location):
"""Return self."""
return cls("UDN") | [
"async",
"def",
"async_create_device",
"(",
"cls",
",",
"hass",
",",
"ssdp_location",
")",
":",
"return",
"cls",
"(",
"\"UDN\"",
")"
] | [
27,
4
] | [
29,
25
] | python | en | ['en', 'ig', 'en'] | False |
MockDevice.udn | (self) | Get the UDN. | Get the UDN. | def udn(self) -> str:
"""Get the UDN."""
return self._udn | [
"def",
"udn",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_udn"
] | [
32,
4
] | [
34,
24
] | python | en | ['en', 'en', 'en'] | True |
MockDevice.manufacturer | (self) | Get manufacturer. | Get manufacturer. | def manufacturer(self) -> str:
"""Get manufacturer."""
return "mock-manufacturer" | [
"def",
"manufacturer",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"mock-manufacturer\""
] | [
37,
4
] | [
39,
34
] | python | en | ['en', 'da', 'en'] | False |
MockDevice.model_name | (self) | Get the model name. | Get the model name. | def model_name(self) -> str:
"""Get the model name."""
return "mock-model-name" | [
"def",
"model_name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"mock-model-name\""
] | [
47,
4
] | [
49,
32
] | python | en | ['en', 'en', 'en'] | True |
MockDevice.device_type | (self) | Get the device type. | Get the device type. | def device_type(self) -> str:
"""Get the device type."""
return "urn:schemas-upnp-org:device:InternetGatewayDevice:1" | [
"def",
"device_type",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"urn:schemas-upnp-org:device:InternetGatewayDevice:1\""
] | [
52,
4
] | [
54,
68
] | python | en | ['en', 'en', 'en'] | True |
MockDevice._async_add_port_mapping | (
self, external_port: int, local_ip: str, internal_port: int
) | Add a port mapping. | Add a port mapping. | async def _async_add_port_mapping(
self, external_port: int, local_ip: str, internal_port: int
) -> None:
"""Add a port mapping."""
entry = [external_port, local_ip, internal_port]
self.added_port_mappings.append(entry) | [
"async",
"def",
"_async_add_port_mapping",
"(",
"self",
",",
"external_port",
":",
"int",
",",
"local_ip",
":",
"str",
",",
"internal_port",
":",
"int",
")",
"->",
"None",
":",
"entry",
"=",
"[",
"external_port",
",",
"local_ip",
",",
"internal_port",
"]",
... | [
56,
4
] | [
61,
46
] | python | en | ['en', 'en', 'en'] | True |
MockDevice._async_delete_port_mapping | (self, external_port: int) | Remove a port mapping. | Remove a port mapping. | async def _async_delete_port_mapping(self, external_port: int) -> None:
"""Remove a port mapping."""
entry = external_port
self.removed_port_mappings.append(entry) | [
"async",
"def",
"_async_delete_port_mapping",
"(",
"self",
",",
"external_port",
":",
"int",
")",
"->",
"None",
":",
"entry",
"=",
"external_port",
"self",
".",
"removed_port_mappings",
".",
"append",
"(",
"entry",
")"
] | [
63,
4
] | [
66,
48
] | python | en | ['es', 'en', 'en'] | True |
MockDevice.async_get_traffic_data | (self) | Get traffic data. | Get traffic data. | async def async_get_traffic_data(self) -> Mapping[str, any]:
"""Get traffic data."""
return {
TIMESTAMP: dt_util.utcnow(),
BYTES_RECEIVED: 0,
BYTES_SENT: 0,
PACKETS_RECEIVED: 0,
PACKETS_SENT: 0,
} | [
"async",
"def",
"async_get_traffic_data",
"(",
"self",
")",
"->",
"Mapping",
"[",
"str",
",",
"any",
"]",
":",
"return",
"{",
"TIMESTAMP",
":",
"dt_util",
".",
"utcnow",
"(",
")",
",",
"BYTES_RECEIVED",
":",
"0",
",",
"BYTES_SENT",
":",
"0",
",",
"PACK... | [
68,
4
] | [
76,
9
] | python | en | ['en', 'kk', 'en'] | True |
_format_inputs | (node: Node) |
Format the inputs of a given node
Parameters
----------
node : Node
a graph node, get and format its inputs
Returns
-------
list
the list of input names
list
the list of input values, if an input is simple type, record its value,
otherwise the value is ... |
Format the inputs of a given node | def _format_inputs(node: Node) -> Tuple[List[str], List[Any]]:
"""
Format the inputs of a given node
Parameters
----------
node : Node
a graph node, get and format its inputs
Returns
-------
list
the list of input names
list
the list of input values, if an i... | [
"def",
"_format_inputs",
"(",
"node",
":",
"Node",
")",
"->",
"Tuple",
"[",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"Any",
"]",
"]",
":",
"edges",
"=",
"_sorted_incoming_edges",
"(",
"node",
")",
"inputs",
"=",
"[",
"]",
"inputs_value",
"=",
"[",
... | [
37,
0
] | [
80,
31
] | python | en | ['en', 'error', 'th'] | False |
_remove_prefix | (names, graph_name) |
variables name (full name space) is too long,
shorten the name by removing the prefix ```graph_name```
|
variables name (full name space) is too long,
shorten the name by removing the prefix ```graph_name```
| def _remove_prefix(names, graph_name):
"""
variables name (full name space) is too long,
shorten the name by removing the prefix ```graph_name```
"""
if isinstance(names, list):
converted_names = []
for name in names:
if name.startswith(graph_name):
conver... | [
"def",
"_remove_prefix",
"(",
"names",
",",
"graph_name",
")",
":",
"if",
"isinstance",
"(",
"names",
",",
"list",
")",
":",
"converted_names",
"=",
"[",
"]",
"for",
"name",
"in",
"names",
":",
"if",
"name",
".",
"startswith",
"(",
"graph_name",
")",
"... | [
83,
0
] | [
97,
81
] | python | en | ['en', 'error', 'th'] | False |
UniFiClient.__init__ | (self, client, controller) | Set up client. | Set up client. | def __init__(self, client, controller) -> None:
"""Set up client."""
super().__init__(client, controller)
self._is_wired = client.mac not in controller.wireless_clients | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"controller",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"client",
",",
"controller",
")",
"self",
".",
"_is_wired",
"=",
"client",
".",
"mac",
"not",
"in",
"controller",
".",
... | [
9,
4
] | [
13,
70
] | python | en | ['en', 'fr', 'en'] | True |
UniFiClient.is_wired | (self) | Return if the client is wired.
Allows disabling logic to keep track of clients affected by UniFi wired bug marking wireless devices as wired. This is useful when running a network not only containing UniFi APs.
| Return if the client is wired. | def is_wired(self):
"""Return if the client is wired.
Allows disabling logic to keep track of clients affected by UniFi wired bug marking wireless devices as wired. This is useful when running a network not only containing UniFi APs.
"""
if self._is_wired and self.client.mac in self.con... | [
"def",
"is_wired",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_wired",
"and",
"self",
".",
"client",
".",
"mac",
"in",
"self",
".",
"controller",
".",
"wireless_clients",
":",
"self",
".",
"_is_wired",
"=",
"False",
"if",
"self",
".",
"controller",
... | [
21,
4
] | [
31,
29
] | python | en | ['en', 'en', 'en'] | True |
UniFiClient.unique_id | (self) | Return a unique identifier for this switch. | Return a unique identifier for this switch. | def unique_id(self):
"""Return a unique identifier for this switch."""
return f"{self.TYPE}-{self.client.mac}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self.TYPE}-{self.client.mac}\""
] | [
34,
4
] | [
36,
47
] | python | en | ['en', 'en', 'en'] | True |
UniFiClient.name | (self) | Return the name of the client. | Return the name of the client. | def name(self) -> str:
"""Return the name of the client."""
return self.client.name or self.client.hostname | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"client",
".",
"name",
"or",
"self",
".",
"client",
".",
"hostname"
] | [
39,
4
] | [
41,
55
] | python | en | ['en', 'en', 'en'] | True |
UniFiClient.available | (self) | Return if controller is available. | Return if controller is available. | def available(self) -> bool:
"""Return if controller is available."""
return self.controller.available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"controller",
".",
"available"
] | [
44,
4
] | [
46,
40
] | python | en | ['en', 'en', 'en'] | True |
UniFiClient.device_info | (self) | Return a client description for device registry. | Return a client description for device registry. | def device_info(self) -> dict:
"""Return a client description for device registry."""
return {
"connections": {(CONNECTION_NETWORK_MAC, self.client.mac)},
"default_name": self.name,
"default_manufacturer": self.client.oui,
} | [
"def",
"device_info",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"client",
".",
"mac",
")",
"}",
",",
"\"default_name\"",
":",
"self",
".",
"name",
",",
"\"default_manuf... | [
49,
4
] | [
55,
9
] | python | ca | ['ca', 'fr', 'en'] | False |
test_sensors | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the creation and values of the IPP sensors. | Test the creation and values of the IPP sensors. | async def test_sensors(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the creation and values of the IPP sensors."""
mock_connection(aioclient_mock)
entry = await init_integration(hass, aioclient_mock, skip_setup=True)
registry = await hass.helpers.entity_registry.asyn... | [
"async",
"def",
"test_sensors",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"mock_connection",
"(",
"aioclient_mock",
")",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_moc... | [
14,
0
] | [
80,
75
] | python | en | ['en', 'en', 'en'] | True |
test_disabled_by_default_sensors | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the disabled by default IPP sensors. | Test the disabled by default IPP sensors. | async def test_disabled_by_default_sensors(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the disabled by default IPP sensors."""
await init_integration(hass, aioclient_mock)
registry = await hass.helpers.entity_registry.async_get_registry()
state = hass.states.get("se... | [
"async",
"def",
"test_disabled_by_default_sensors",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"registry",
"=",
"await",
"hass",
... | [
83,
0
] | [
96,
45
] | python | en | ['en', 'en', 'en'] | True |
test_missing_entry_unique_id | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the unique_id of IPP sensor when printer is missing identifiers. | Test the unique_id of IPP sensor when printer is missing identifiers. | async def test_missing_entry_unique_id(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the unique_id of IPP sensor when printer is missing identifiers."""
entry = await init_integration(hass, aioclient_mock, uuid=None, unique_id=None)
registry = await hass.helpers.entity_reg... | [
"async",
"def",
"test_missing_entry_unique_id",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"uuid",
"=",
"None",
... | [
99,
0
] | [
108,
58
] | python | en | ['en', 'en', 'en'] | True |
discover_sensors | (topic, payload) | Given a topic, dynamically create the right sensor type.
Async friendly.
| Given a topic, dynamically create the right sensor type. | def discover_sensors(topic, payload):
"""Given a topic, dynamically create the right sensor type.
Async friendly.
"""
parts = topic.split("/")
unit = payload.get("units", "")
domain = parts[1]
if domain == "temperature":
name = parts[2]
if unit == "F":
unit = TEM... | [
"def",
"discover_sensors",
"(",
"topic",
",",
"payload",
")",
":",
"parts",
"=",
"topic",
".",
"split",
"(",
"\"/\"",
")",
"unit",
"=",
"payload",
".",
"get",
"(",
"\"units\"",
",",
"\"\"",
")",
"domain",
"=",
"parts",
"[",
"1",
"]",
"if",
"domain",
... | [
18,
0
] | [
56,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the ARWN platform. | Set up the ARWN platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the ARWN platform."""
@callback
def async_sensor_event_received(msg):
"""Process events as sensors.
When a new event on our topic (arwn/#) is received we map it
into a known kind of sen... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"@",
"callback",
"def",
"async_sensor_event_received",
"(",
"msg",
")",
":",
"\"\"\"Process events as sensors.\n\n When a ... | [
63,
0
] | [
113,
15
] | python | en | ['en', 'da', 'en'] | True |
ArwnSensor.__init__ | (self, topic, name, state_key, units, icon=None) | Initialize the sensor. | Initialize the sensor. | def __init__(self, topic, name, state_key, units, icon=None):
"""Initialize the sensor."""
self.hass = None
self.entity_id = _slug(name)
self._name = name
# This mqtt topic for the sensor which is its uid
self._uid = topic
self._state_key = state_key
self.... | [
"def",
"__init__",
"(",
"self",
",",
"topic",
",",
"name",
",",
"state_key",
",",
"units",
",",
"icon",
"=",
"None",
")",
":",
"self",
".",
"hass",
"=",
"None",
"self",
".",
"entity_id",
"=",
"_slug",
"(",
"name",
")",
"self",
".",
"_name",
"=",
... | [
119,
4
] | [
129,
25
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.set_event | (self, event) | Update the sensor with the most recent event. | Update the sensor with the most recent event. | def set_event(self, event):
"""Update the sensor with the most recent event."""
self.event = {}
self.event.update(event)
self.async_write_ha_state() | [
"def",
"set_event",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"event",
"=",
"{",
"}",
"self",
".",
"event",
".",
"update",
"(",
"event",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
131,
4
] | [
135,
35
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self.event.get(self._state_key, None) | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"event",
".",
"get",
"(",
"self",
".",
"_state_key",
",",
"None",
")"
] | [
138,
4
] | [
140,
52
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.name | (self) | Get the name of the sensor. | Get the name of the sensor. | def name(self):
"""Get the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
143,
4
] | [
145,
25
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.unique_id | (self) | Return a unique ID.
This is based on the topic that comes from mqtt
| Return a unique ID. | def unique_id(self):
"""Return a unique ID.
This is based on the topic that comes from mqtt
"""
return self._uid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_uid"
] | [
148,
4
] | [
153,
24
] | python | ca | ['fr', 'ca', 'en'] | False |
ArwnSensor.state_attributes | (self) | Return all the state attributes. | Return all the state attributes. | def state_attributes(self):
"""Return all the state attributes."""
return self.event | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"event"
] | [
156,
4
] | [
158,
25
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.unit_of_measurement | (self) | Return the unit of measurement the state is expressed in. | Return the unit of measurement the state is expressed in. | def unit_of_measurement(self):
"""Return the unit of measurement the state is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
161,
4
] | [
163,
40
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
166,
4
] | [
168,
20
] | python | en | ['en', 'en', 'en'] | True |
ArwnSensor.icon | (self) | Return the icon of device based on its type. | Return the icon of device based on its type. | def icon(self):
"""Return the icon of device based on its type."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
171,
4
] | [
173,
25
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.create | (create_deployment: dict) | Create MARO Cluster with create_deployment.
Args:
create_deployment (dict): create_deployment of k8s/aks. See lib/deployments/internal for reference.
Returns:
None.
| Create MARO Cluster with create_deployment. | def create(create_deployment: dict) -> None:
"""Create MARO Cluster with create_deployment.
Args:
create_deployment (dict): create_deployment of k8s/aks. See lib/deployments/internal for reference.
Returns:
None.
"""
logger.info("Creating cluster")
... | [
"def",
"create",
"(",
"create_deployment",
":",
"dict",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"\"Creating cluster\"",
")",
"# Get standardized cluster_details",
"cluster_details",
"=",
"K8sAksExecutor",
".",
"_standardize_cluster_details",
"(",
"create_dep... | [
48,
4
] | [
83,
65
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._standardize_cluster_details | (create_deployment: dict) | Standardize cluster_details from create_deployment.
We use create_deployment to build cluster_details (they share the same keys structure).
Args:
create_deployment (dict): create_deployment of k8s/aks. See lib/deployments/internal for reference.
Returns:
dict: standard... | Standardize cluster_details from create_deployment. | def _standardize_cluster_details(create_deployment: dict) -> dict:
"""Standardize cluster_details from create_deployment.
We use create_deployment to build cluster_details (they share the same keys structure).
Args:
create_deployment (dict): create_deployment of k8s/aks. See lib/de... | [
"def",
"_standardize_cluster_details",
"(",
"create_deployment",
":",
"dict",
")",
"->",
"dict",
":",
"optional_key_to_value",
"=",
"{",
"\"root['master']['redis']\"",
":",
"{",
"\"port\"",
":",
"GlobalParams",
".",
"DEFAULT_REDIS_PORT",
"}",
",",
"\"root['master']['red... | [
86,
4
] | [
114,
32
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._create_resource_group | (cluster_details: dict) | Create the resource group if it does not exist.
Args:
cluster_details (dict): details of the cluster.
Returns:
None.
| Create the resource group if it does not exist. | def _create_resource_group(cluster_details: dict) -> None:
"""Create the resource group if it does not exist.
Args:
cluster_details (dict): details of the cluster.
Returns:
None.
"""
# Get params
subscription = cluster_details["cloud"]["subscrip... | [
"def",
"_create_resource_group",
"(",
"cluster_details",
":",
"dict",
")",
"->",
"None",
":",
"# Get params",
"subscription",
"=",
"cluster_details",
"[",
"\"cloud\"",
"]",
"[",
"\"subscription\"",
"]",
"resource_group",
"=",
"cluster_details",
"[",
"\"cloud\"",
"]"... | [
117,
4
] | [
148,
78
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._create_k8s_cluster | (cluster_details: dict) | Create k8s cluster for the MARO Cluster.
Args:
cluster_details (dict): details of the MARO Cluster.
Returns:
None.
| Create k8s cluster for the MARO Cluster. | def _create_k8s_cluster(cluster_details: dict) -> None:
"""Create k8s cluster for the MARO Cluster.
Args:
cluster_details (dict): details of the MARO Cluster.
Returns:
None.
"""
logger.info("Creating k8s cluster")
# Create ARM parameters and sta... | [
"def",
"_create_k8s_cluster",
"(",
"cluster_details",
":",
"dict",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"\"Creating k8s cluster\"",
")",
"# Create ARM parameters and start deployment",
"template_file_path",
"=",
"f\"{K8sPaths.ABS_MARO_K8S_LIB}/modes/aks/create_ak... | [
151,
4
] | [
185,
51
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._init_nvidia_plugin | () | Setup nvidia plugin for the MARO Cluster.
Returns:
None.
| Setup nvidia plugin for the MARO Cluster. | def _init_nvidia_plugin() -> None:
"""Setup nvidia plugin for the MARO Cluster.
Returns:
None.
"""
client.CoreV1Api().create_namespace(body=client.V1Namespace(metadata=client.V1ObjectMeta(name="gpu-resources")))
with open(
f"{K8sPaths.ABS_MARO_K8S_LIB}/m... | [
"def",
"_init_nvidia_plugin",
"(",
")",
"->",
"None",
":",
"client",
".",
"CoreV1Api",
"(",
")",
".",
"create_namespace",
"(",
"body",
"=",
"client",
".",
"V1Namespace",
"(",
"metadata",
"=",
"client",
".",
"V1ObjectMeta",
"(",
"name",
"=",
"\"gpu-resources\... | [
188,
4
] | [
200,
105
] | python | en | ['en', 'sm', 'en'] | True |
K8sAksExecutor._create_storage_account_secret | (cluster_details: dict) | Setup storage_account_secret for the MARO Cluster.
The secret is used in Azure File Service.
Returns:
None.
| Setup storage_account_secret for the MARO Cluster. | def _create_storage_account_secret(cluster_details: dict) -> None:
"""Setup storage_account_secret for the MARO Cluster.
The secret is used in Azure File Service.
Returns:
None.
"""
# Build params
storage_account_name = f"{cluster_details['id']}st"
... | [
"def",
"_create_storage_account_secret",
"(",
"cluster_details",
":",
"dict",
")",
"->",
"None",
":",
"# Build params",
"storage_account_name",
"=",
"f\"{cluster_details['id']}st\"",
"# Get storage account key",
"storage_account_keys",
"=",
"AzureController",
".",
"get_storage_... | [
203,
4
] | [
231,
9
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.delete | (self) | Delete the MARO Cluster.
Returns:
None.
| Delete the MARO Cluster. | def delete(self) -> None:
"""Delete the MARO Cluster.
Returns:
None.
"""
logger.info(f"Deleting cluster '{self.cluster_name}'")
# Get resource list
resource_list = AzureController.list_resources(resource_group=self.resource_group)
# Filter resources... | [
"def",
"delete",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"f\"Deleting cluster '{self.cluster_name}'\"",
")",
"# Get resource list",
"resource_list",
"=",
"AzureController",
".",
"list_resources",
"(",
"resource_group",
"=",
"self",
".",
"res... | [
235,
4
] | [
259,
70
] | python | en | ['en', 'it', 'en'] | True |
K8sAksExecutor.scale_node | (self, replicas: int, node_size: str) | Scale up/down MARO Node.
Args:
replicas (int): desired number of MARO Node in specific node_size.
node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes
for reference.
Returns:
None.
| Scale up/down MARO Node. | def scale_node(self, replicas: int, node_size: str) -> None:
"""Scale up/down MARO Node.
Args:
replicas (int): desired number of MARO Node in specific node_size.
node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes
... | [
"def",
"scale_node",
"(",
"self",
",",
"replicas",
":",
"int",
",",
"node_size",
":",
"str",
")",
"->",
"None",
":",
"# Get node_size_to_info",
"node_size_to_info",
"=",
"self",
".",
"_get_node_size_to_info",
"(",
")",
"# Get node_size_to_spec, and check if node_size ... | [
263,
4
] | [
295,
74
] | python | en | ['en', 'en', 'pt'] | True |
K8sAksExecutor._get_node_size_to_info | (self) | Get node_size to info mapping of the K8s Cluster.
Returns:
dict: node_size to info mapping.
| Get node_size to info mapping of the K8s Cluster. | def _get_node_size_to_info(self) -> dict:
"""Get node_size to info mapping of the K8s Cluster.
Returns:
dict: node_size to info mapping.
"""
# List nodepool
nodepools = AzureController.list_nodepool(
resource_group=self.resource_group,
aks_nam... | [
"def",
"_get_node_size_to_info",
"(",
"self",
")",
"->",
"dict",
":",
"# List nodepool",
"nodepools",
"=",
"AzureController",
".",
"list_nodepool",
"(",
"resource_group",
"=",
"self",
".",
"resource_group",
",",
"aks_name",
"=",
"f\"{self.cluster_id}-aks\"",
")",
"#... | [
297,
4
] | [
314,
33
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._get_node_size_to_spec | (self) | Get node_size to spec mapping of Azure VM.
Returns:
dict: node_size to spec mapping.
| Get node_size to spec mapping of Azure VM. | def _get_node_size_to_spec(self) -> dict:
"""Get node_size to spec mapping of Azure VM.
Returns:
dict: node_size to spec mapping.
"""
# List available sizes for VM
specs = AzureController.list_vm_sizes(location=self.location)
# Build node_size_to_spec
... | [
"def",
"_get_node_size_to_spec",
"(",
"self",
")",
"->",
"dict",
":",
"# List available sizes for VM",
"specs",
"=",
"AzureController",
".",
"list_vm_sizes",
"(",
"location",
"=",
"self",
".",
"location",
")",
"# Build node_size_to_spec",
"node_size_to_spec",
"=",
"{"... | [
316,
4
] | [
330,
32
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._build_node_pool | (self, replicas: int, node_size: str) | Build node pool for the specific node_size.
Args:
replicas (int): number of MARO Node in specific node_size to stop.
node_size (str): size of the MARO Node VM,
see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes for reference.
Returns:
... | Build node pool for the specific node_size. | def _build_node_pool(self, replicas: int, node_size: str) -> None:
"""Build node pool for the specific node_size.
Args:
replicas (int): number of MARO Node in specific node_size to stop.
node_size (str): size of the MARO Node VM,
see https://docs.microsoft.com/en... | [
"def",
"_build_node_pool",
"(",
"self",
",",
"replicas",
":",
"int",
",",
"node_size",
":",
"str",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"f\"Building '{node_size}' nodepool\"",
")",
"# Build nodepool",
"AzureController",
".",
"add_nodepool",
"(",
"... | [
332,
4
] | [
354,
61
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._scale_node_pool | (self, replicas: int, node_size: str, node_size_to_info: dict) | Scale node pool of the specific node_size.
Args:
replicas (int): number of MARO Node in specific node_size to stop.
node_size (str): size of the MARO Node VM,
see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes for reference.
node_size_to_info (... | Scale node pool of the specific node_size. | def _scale_node_pool(self, replicas: int, node_size: str, node_size_to_info: dict):
"""Scale node pool of the specific node_size.
Args:
replicas (int): number of MARO Node in specific node_size to stop.
node_size (str): size of the MARO Node VM,
see https://docs.... | [
"def",
"_scale_node_pool",
"(",
"self",
",",
"replicas",
":",
"int",
",",
"node_size",
":",
"str",
",",
"node_size_to_info",
":",
"dict",
")",
":",
"logger",
".",
"info",
"(",
"f\"Scaling '{node_size}' nodepool\"",
")",
"# Scale node pool",
"AzureController",
".",... | [
356,
4
] | [
378,
62
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._generate_nodepool_name | (node_size: str) | Generate name of the nodepool.
Args:
node_size (str): size of the MARO Node VM.
Returns:
None.
| Generate name of the nodepool. | def _generate_nodepool_name(node_size: str) -> str:
"""Generate name of the nodepool.
Args:
node_size (str): size of the MARO Node VM.
Returns:
None.
"""
return NameCreator.create_name_with_md5(prefix="pool", key=node_size, md5_len=8) | [
"def",
"_generate_nodepool_name",
"(",
"node_size",
":",
"str",
")",
"->",
"str",
":",
"return",
"NameCreator",
".",
"create_name_with_md5",
"(",
"prefix",
"=",
"\"pool\"",
",",
"key",
"=",
"node_size",
",",
"md5_len",
"=",
"8",
")"
] | [
381,
4
] | [
390,
88
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.list_node | (self) | Print node details to the command line.
Returns:
None.
| Print node details to the command line. | def list_node(self) -> None:
"""Print node details to the command line.
Returns:
None.
"""
# Get aks details
aks_details = AzureController.get_aks(
resource_group=self.resource_group,
aks_name=f"{self.cluster_id}-aks"
)
agent_p... | [
"def",
"list_node",
"(",
"self",
")",
"->",
"None",
":",
"# Get aks details",
"aks_details",
"=",
"AzureController",
".",
"get_aks",
"(",
"resource_group",
"=",
"self",
".",
"resource_group",
",",
"aks_name",
"=",
"f\"{self.cluster_id}-aks\"",
")",
"agent_pools_deta... | [
392,
4
] | [
414,
9
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.push_image | (self, image_name: str) | Push local image to the MARO Cluster.
Args:
image_name (str): name of the local image that loaded in the docker.
Returns:
None.
| Push local image to the MARO Cluster. | def push_image(self, image_name: str) -> None:
"""Push local image to the MARO Cluster.
Args:
image_name (str): name of the local image that loaded in the docker.
Returns:
None.
"""
remote_image_name = f"{self.cluster_id}acr.azurecr.io/{image_name}"
... | [
"def",
"push_image",
"(",
"self",
",",
"image_name",
":",
"str",
")",
"->",
"None",
":",
"remote_image_name",
"=",
"f\"{self.cluster_id}acr.azurecr.io/{image_name}\"",
"# ACR login",
"AzureController",
".",
"login_acr",
"(",
"acr_name",
"=",
"f\"{self.cluster_id}acr\"",
... | [
418,
4
] | [
438,
43
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.list_image | (self) | Print image details to the command line.
Returns:
None.
| Print image details to the command line. | def list_image(self):
"""Print image details to the command line.
Returns:
None.
"""
# List acr repository
acr_repositories = AzureController.list_acr_repositories(acr_name=f"{self.cluster_id}acr")
logger.info(acr_repositories) | [
"def",
"list_image",
"(",
"self",
")",
":",
"# List acr repository",
"acr_repositories",
"=",
"AzureController",
".",
"list_acr_repositories",
"(",
"acr_name",
"=",
"f\"{self.cluster_id}acr\"",
")",
"logger",
".",
"info",
"(",
"acr_repositories",
")"
] | [
440,
4
] | [
448,
37
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.push_data | (self, local_path: str, remote_dir: str) | Push local data to the remote AFS service via azcopy.
Args:
local_path (str): path of the local data.
remote_dir (str): path of the remote folder.
Returns:
None.
| Push local data to the remote AFS service via azcopy. | def push_data(self, local_path: str, remote_dir: str) -> None:
"""Push local data to the remote AFS service via azcopy.
Args:
local_path (str): path of the local data.
remote_dir (str): path of the remote folder.
Returns:
None.
"""
# Get sas
... | [
"def",
"push_data",
"(",
"self",
",",
"local_path",
":",
"str",
",",
"remote_dir",
":",
"str",
")",
"->",
"None",
":",
"# Get sas",
"sas",
"=",
"self",
".",
"_check_and_get_account_sas",
"(",
")",
"# Push data",
"abs_local_path",
"=",
"os",
".",
"path",
".... | [
452,
4
] | [
477,
48
] | python | en | ['en', 'it', 'en'] | True |
K8sAksExecutor.pull_data | (self, local_dir: str, remote_path: str) | Pull remote AFS service data to local folder via azcopy.
Args:
local_dir (str): path of the local folder.
remote_path (str): path of the remote data.
Returns:
None.
| Pull remote AFS service data to local folder via azcopy. | def pull_data(self, local_dir: str, remote_path: str) -> None:
"""Pull remote AFS service data to local folder via azcopy.
Args:
local_dir (str): path of the local folder.
remote_path (str): path of the remote data.
Returns:
None.
"""
# Get s... | [
"def",
"pull_data",
"(",
"self",
",",
"local_dir",
":",
"str",
",",
"remote_path",
":",
"str",
")",
"->",
"None",
":",
"# Get sas",
"sas",
"=",
"self",
".",
"_check_and_get_account_sas",
"(",
")",
"# Push data",
"abs_local_dir",
"=",
"os",
".",
"path",
"."... | [
479,
4
] | [
505,
48
] | python | en | ['en', 'it', 'en'] | True |
K8sAksExecutor.remove_data | (self, remote_path: str) | Remote data at the remote AFS service.
Args:
remote_path (str): path of the remote data.
Returns:
None.
| Remote data at the remote AFS service. | def remove_data(self, remote_path: str) -> None:
"""Remote data at the remote AFS service.
Args:
remote_path (str): path of the remote data.
Returns:
None.
"""
# FIXME: Remove failed, The specified resource may be in use by an SMB client
# Get s... | [
"def",
"remove_data",
"(",
"self",
",",
"remote_path",
":",
"str",
")",
"->",
"None",
":",
"# FIXME: Remove failed, The specified resource may be in use by an SMB client",
"# Get sas",
"sas",
"=",
"self",
".",
"_check_and_get_account_sas",
"(",
")",
"# Remove data",
"copy... | [
507,
4
] | [
527,
48
] | python | en | ['en', 'it', 'en'] | True |
K8sAksExecutor._check_and_get_account_sas | (self) | Check and get account sas token, also update it to the cluster_details.
Ref: https://msdn.microsoft.com/library/azure/mt584140.aspx
Returns:
str: account sas token.
| Check and get account sas token, also update it to the cluster_details. | def _check_and_get_account_sas(self) -> str:
"""Check and get account sas token, also update it to the cluster_details.
Ref: https://msdn.microsoft.com/library/azure/mt584140.aspx
Returns:
str: account sas token.
"""
# Load details
cloud_details = self.clus... | [
"def",
"_check_and_get_account_sas",
"(",
"self",
")",
"->",
"str",
":",
"# Load details",
"cloud_details",
"=",
"self",
".",
"cluster_details",
"[",
"\"cloud\"",
"]",
"# Regenerate sas if the key is None or expired TODO:",
"if",
"\"account_sas\"",
"not",
"in",
"cloud_det... | [
529,
4
] | [
550,
43
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._create_k8s_job | (self, job_details: dict) | Create k8s job object with job_details.
Args:
job_details (dict): details of the MARO Job.
Returns:
dict: k8s job object.
| Create k8s job object with job_details. | def _create_k8s_job(self, job_details: dict) -> dict:
"""Create k8s job object with job_details.
Args:
job_details (dict): details of the MARO Job.
Returns:
dict: k8s job object.
"""
# Get config template
with open(f"{K8sPaths.ABS_MARO_K8S_LIB}/m... | [
"def",
"_create_k8s_job",
"(",
"self",
",",
"job_details",
":",
"dict",
")",
"->",
"dict",
":",
"# Get config template",
"with",
"open",
"(",
"f\"{K8sPaths.ABS_MARO_K8S_LIB}/modes/aks/create_job/job.yml\"",
")",
"as",
"fr",
":",
"k8s_job_config",
"=",
"yaml",
".",
"... | [
554,
4
] | [
587,
29
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._create_k8s_container_config | (
self, job_details: dict, k8s_container_config_template: dict,
component_type: str, component_index: int
) | Create the container config in the k8s job object.
Args:
job_details (dict): details of the MARO Job.
k8s_container_config_template (dict): template of the k8s_container_config.
component_type (str): type of the component.
component_index (int): index of the comp... | Create the container config in the k8s job object. | def _create_k8s_container_config(
self, job_details: dict, k8s_container_config_template: dict,
component_type: str, component_index: int
) -> dict:
"""Create the container config in the k8s job object.
Args:
job_details (dict): details of the MARO Job.
k8s_c... | [
"def",
"_create_k8s_container_config",
"(",
"self",
",",
"job_details",
":",
"dict",
",",
"k8s_container_config_template",
":",
"dict",
",",
"component_type",
":",
"str",
",",
"component_index",
":",
"int",
")",
"->",
"dict",
":",
"# Copy config.",
"k8s_container_co... | [
589,
4
] | [
663,
35
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._build_image_address | (self, image_name: str) | Build image address name for image that stored at Azure Container Registry.
Args:
image_name (str): name of the image.
Returns:
str: image address name.
| Build image address name for image that stored at Azure Container Registry. | def _build_image_address(self, image_name: str) -> str:
"""Build image address name for image that stored at Azure Container Registry.
Args:
image_name (str): name of the image.
Returns:
str: image address name.
"""
# Get repositories
acr_reposit... | [
"def",
"_build_image_address",
"(",
"self",
",",
"image_name",
":",
"str",
")",
"->",
"str",
":",
"# Get repositories",
"acr_repositories",
"=",
"AzureController",
".",
"list_acr_repositories",
"(",
"acr_name",
"=",
"f\"{self.cluster_id}acr\"",
")",
"# Build address",
... | [
665,
4
] | [
681,
29
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor._export_log | (pod_id: str, container_name: str, export_dir: str) | Export k8s job logs to the specific folder.
Args:
pod_id (str): id of the k8s pod.
container_name (str): name of the container.
export_dir (str): path of the exported folder.
Returns:
None.
| Export k8s job logs to the specific folder. | def _export_log(pod_id: str, container_name: str, export_dir: str) -> None:
"""Export k8s job logs to the specific folder.
Args:
pod_id (str): id of the k8s pod.
container_name (str): name of the container.
export_dir (str): path of the exported folder.
Retu... | [
"def",
"_export_log",
"(",
"pod_id",
":",
"str",
",",
"container_name",
":",
"str",
",",
"export_dir",
":",
"str",
")",
"->",
"None",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"export_dir",
"+",
"f\"/{pod_id}\"",
")",
... | [
684,
4
] | [
698,
32
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.status | (self) | Print details of specific MARO Resources (redis only at this time).
Returns:
None.
| Print details of specific MARO Resources (redis only at this time). | def status(self) -> None:
"""Print details of specific MARO Resources (redis only at this time).
Returns:
None.
"""
return_status = {}
# Get pods details
pod_list = client.CoreV1Api().list_pod_for_all_namespaces(watch=False).to_dict()["items"]
for p... | [
"def",
"status",
"(",
"self",
")",
"->",
"None",
":",
"return_status",
"=",
"{",
"}",
"# Get pods details",
"pod_list",
"=",
"client",
".",
"CoreV1Api",
"(",
")",
".",
"list_pod_for_all_namespaces",
"(",
"watch",
"=",
"False",
")",
".",
"to_dict",
"(",
")"... | [
702,
4
] | [
726,
9
] | python | en | ['en', 'en', 'en'] | True |
K8sAksExecutor.load_k8s_context | (self) | Activate load k8s context operation.
Returns:
None.
| Activate load k8s context operation. | def load_k8s_context(self) -> None:
"""Activate load k8s context operation.
Returns:
None.
"""
self._load_k8s_context(
cluster_id=self.cluster_id,
resource_group=self.resource_group
) | [
"def",
"load_k8s_context",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_load_k8s_context",
"(",
"cluster_id",
"=",
"self",
".",
"cluster_id",
",",
"resource_group",
"=",
"self",
".",
"resource_group",
")"
] | [
730,
4
] | [
739,
9
] | python | en | ['nl', 'en', 'en'] | True |
K8sAksExecutor._load_k8s_context | (cluster_id: int, resource_group: str) | Load the k8s context.
Set current k8s context (only in the CLI runtime) to the k8s cluster that related to the MARO Cluster.
Args:
cluster_id (str): id of the MARO Cluster.
resource_group (str): name of the resource group.
Returns:
None.
| Load the k8s context. | def _load_k8s_context(cluster_id: int, resource_group: str) -> None:
"""Load the k8s context.
Set current k8s context (only in the CLI runtime) to the k8s cluster that related to the MARO Cluster.
Args:
cluster_id (str): id of the MARO Cluster.
resource_group (str): nam... | [
"def",
"_load_k8s_context",
"(",
"cluster_id",
":",
"int",
",",
"resource_group",
":",
"str",
")",
"->",
"None",
":",
"AzureController",
".",
"load_aks_context",
"(",
"resource_group",
"=",
"resource_group",
",",
"aks_name",
"=",
"f\"{cluster_id}-aks\"",
")",
"con... | [
742,
4
] | [
758,
60
] | python | en | ['en', 'en', 'en'] | True |
ArmTemplateParameterBuilder.create_aks_cluster | (cluster_details: dict, export_path: str) | Create parameters file for AKS cluster.
Args:
cluster_details (dict): details of the MARO Cluster.
export_path (str): path to export the parameter file.
Returns:
dict: parameter dict, should be exported to json.
| Create parameters file for AKS cluster. | def create_aks_cluster(cluster_details: dict, export_path: str) -> dict:
"""Create parameters file for AKS cluster.
Args:
cluster_details (dict): details of the MARO Cluster.
export_path (str): path to export the parameter file.
Returns:
dict: parameter dict... | [
"def",
"create_aks_cluster",
"(",
"cluster_details",
":",
"dict",
",",
"export_path",
":",
"str",
")",
"->",
"dict",
":",
"# Get params",
"cluster_id",
"=",
"cluster_details",
"[",
"'id'",
"]",
"with",
"open",
"(",
"f\"{K8sPaths.ABS_MARO_K8S_LIB}/modes/aks/create_aks_... | [
763,
4
] | [
798,
25
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Use config values to set up a function enabling status retrieval. | Use config values to set up a function enabling status retrieval. | def setup(hass, config):
"""Use config values to set up a function enabling status retrieval."""
conf = config[DOMAIN]
host = conf[CONF_HOST]
port = conf[CONF_PORT]
apcups_data = APCUPSdData(host, port)
hass.data[DOMAIN] = apcups_data
# It doesn't really matter why we're not able to get th... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"host",
"=",
"conf",
"[",
"CONF_HOST",
"]",
"port",
"=",
"conf",
"[",
"CONF_PORT",
"]",
"apcups_data",
"=",
"APCUPSdData",
"(",
"host",
",",
"port",
")",... | [
36,
0
] | [
52,
15
] | python | en | ['en', 'en', 'en'] | True |
APCUPSdData.__init__ | (self, host, port) | Initialize the data object. | Initialize the data object. | def __init__(self, host, port):
"""Initialize the data object."""
self._host = host
self._port = port
self._status = None
self._get = status.get
self._parse = status.parse | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_port",
"=",
"port",
"self",
".",
"_status",
"=",
"None",
"self",
".",
"_get",
"=",
"status",
".",
"get",
"self",
".",
"_parse",
... | [
62,
4
] | [
69,
34
] | python | en | ['en', 'en', 'en'] | True |
APCUPSdData.status | (self) | Get latest update if throttle allows. Return status. | Get latest update if throttle allows. Return status. | def status(self):
"""Get latest update if throttle allows. Return status."""
self.update()
return self._status | [
"def",
"status",
"(",
"self",
")",
":",
"self",
".",
"update",
"(",
")",
"return",
"self",
".",
"_status"
] | [
72,
4
] | [
75,
27
] | python | en | ['en', 'en', 'en'] | True |
APCUPSdData._get_status | (self) | Get the status from APCUPSd and parse it into a dict. | Get the status from APCUPSd and parse it into a dict. | def _get_status(self):
"""Get the status from APCUPSd and parse it into a dict."""
return self._parse(self._get(host=self._host, port=self._port)) | [
"def",
"_get_status",
"(",
"self",
")",
":",
"return",
"self",
".",
"_parse",
"(",
"self",
".",
"_get",
"(",
"host",
"=",
"self",
".",
"_host",
",",
"port",
"=",
"self",
".",
"_port",
")",
")"
] | [
77,
4
] | [
79,
71
] | python | en | ['en', 'en', 'en'] | True |
APCUPSdData.update | (self, **kwargs) | Fetch the latest status from APCUPSd. | Fetch the latest status from APCUPSd. | def update(self, **kwargs):
"""Fetch the latest status from APCUPSd."""
self._status = self._get_status() | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_status",
"=",
"self",
".",
"_get_status",
"(",
")"
] | [
82,
4
] | [
84,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config, retry_delay=FIRST_RETRY_TIME) | Set up the asuswrt component. | Set up the asuswrt component. | async def async_setup(hass, config, retry_delay=FIRST_RETRY_TIME):
"""Set up the asuswrt component."""
conf = config[DOMAIN]
api = AsusWrt(
conf[CONF_HOST],
conf[CONF_PORT],
conf[CONF_PROTOCOL] == "telnet",
conf[CONF_USERNAME],
conf.get(CONF_PASSWORD, ""),
c... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
",",
"retry_delay",
"=",
"FIRST_RETRY_TIME",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"api",
"=",
"AsusWrt",
"(",
"conf",
"[",
"CONF_HOST",
"]",
",",
"conf",
"[",
"CONF_PORT",
"]",
... | [
65,
0
] | [
119,
15
] | python | en | ['en', 'en', 'en'] | True |
mock_config_flow_login | () | Mock a successful login. | Mock a successful login. | def mock_config_flow_login():
"""Mock a successful login."""
with patch("homeassistant.components.neato.config_flow.Account", return_value=True):
yield | [
"def",
"mock_config_flow_login",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.neato.config_flow.Account\"",
",",
"return_value",
"=",
"True",
")",
":",
"yield"
] | [
37,
0
] | [
40,
13
] | python | en | ['en', 'co', 'en'] | True |
mock_controller_login | () | Mock a successful login. | Mock a successful login. | def mock_controller_login():
"""Mock a successful login."""
with patch("homeassistant.components.neato.Account", return_value=True):
yield | [
"def",
"mock_controller_login",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.neato.Account\"",
",",
"return_value",
"=",
"True",
")",
":",
"yield"
] | [
44,
0
] | [
47,
13
] | python | en | ['en', 'co', 'en'] | True |
test_no_config_entry | (hass) | There is nothing in configuration.yaml. | There is nothing in configuration.yaml. | async def test_no_config_entry(hass):
"""There is nothing in configuration.yaml."""
res = await async_setup_component(hass, NEATO_DOMAIN, {})
assert res is True | [
"async",
"def",
"test_no_config_entry",
"(",
"hass",
")",
":",
"res",
"=",
"await",
"async_setup_component",
"(",
"hass",
",",
"NEATO_DOMAIN",
",",
"{",
"}",
")",
"assert",
"res",
"is",
"True"
] | [
50,
0
] | [
53,
22
] | python | en | ['en', 'en', 'en'] | True |
test_create_valid_config_entry | (hass, config_flow, hub) | There is something in configuration.yaml. | There is something in configuration.yaml. | async def test_create_valid_config_entry(hass, config_flow, hub):
"""There is something in configuration.yaml."""
assert hass.config_entries.async_entries(NEATO_DOMAIN) == []
assert await async_setup_component(hass, NEATO_DOMAIN, {NEATO_DOMAIN: VALID_CONFIG})
await hass.async_block_till_done()
entr... | [
"async",
"def",
"test_create_valid_config_entry",
"(",
"hass",
",",
"config_flow",
",",
"hub",
")",
":",
"assert",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"NEATO_DOMAIN",
")",
"==",
"[",
"]",
"assert",
"await",
"async_setup_component",
"(",
"ha... | [
56,
0
] | [
66,
55
] | python | en | ['en', 'en', 'en'] | True |
test_config_entries_in_sync | (hass, hub) | The config entry and configuration.yaml are in sync. | The config entry and configuration.yaml are in sync. | async def test_config_entries_in_sync(hass, hub):
"""The config entry and configuration.yaml are in sync."""
MockConfigEntry(domain=NEATO_DOMAIN, data=VALID_CONFIG).add_to_hass(hass)
assert hass.config_entries.async_entries(NEATO_DOMAIN)
assert await async_setup_component(hass, NEATO_DOMAIN, {NEATO_DOM... | [
"async",
"def",
"test_config_entries_in_sync",
"(",
"hass",
",",
"hub",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"NEATO_DOMAIN",
",",
"data",
"=",
"VALID_CONFIG",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"hass",
".",
"config_entries",
".",
... | [
69,
0
] | [
81,
55
] | python | en | ['en', 'en', 'en'] | True |
test_config_entries_not_in_sync | (hass, config_flow, hub) | The config entry and configuration.yaml are not in sync. | The config entry and configuration.yaml are not in sync. | async def test_config_entries_not_in_sync(hass, config_flow, hub):
"""The config entry and configuration.yaml are not in sync."""
MockConfigEntry(domain=NEATO_DOMAIN, data=DIFFERENT_CONFIG).add_to_hass(hass)
assert hass.config_entries.async_entries(NEATO_DOMAIN)
assert await async_setup_component(hass,... | [
"async",
"def",
"test_config_entries_not_in_sync",
"(",
"hass",
",",
"config_flow",
",",
"hub",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"NEATO_DOMAIN",
",",
"data",
"=",
"DIFFERENT_CONFIG",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"hass",
... | [
84,
0
] | [
96,
55
] | python | en | ['en', 'en', 'en'] | True |
test_config_entries_not_in_sync_error | (hass) | The config entry and configuration.yaml are not in sync, the new configuration is wrong. | The config entry and configuration.yaml are not in sync, the new configuration is wrong. | async def test_config_entries_not_in_sync_error(hass):
"""The config entry and configuration.yaml are not in sync, the new configuration is wrong."""
MockConfigEntry(domain=NEATO_DOMAIN, data=VALID_CONFIG).add_to_hass(hass)
assert hass.config_entries.async_entries(NEATO_DOMAIN)
with patch(
"hom... | [
"async",
"def",
"test_config_entries_not_in_sync_error",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"NEATO_DOMAIN",
",",
"data",
"=",
"VALID_CONFIG",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"hass",
".",
"config_entries",
".",
"asy... | [
99,
0
] | [
117,
55
] | python | en | ['en', 'en', 'en'] | True |
find_box | (segment: io.BytesIO, target_type: bytes, box_start: int = 0) | Find location of first box (or sub_box if box_start provided) of given type. | Find location of first box (or sub_box if box_start provided) of given type. | def find_box(segment: io.BytesIO, target_type: bytes, box_start: int = 0) -> int:
"""Find location of first box (or sub_box if box_start provided) of given type."""
if box_start == 0:
box_end = segment.seek(0, io.SEEK_END)
segment.seek(0)
index = 0
else:
segment.seek(box_star... | [
"def",
"find_box",
"(",
"segment",
":",
"io",
".",
"BytesIO",
",",
"target_type",
":",
"bytes",
",",
"box_start",
":",
"int",
"=",
"0",
")",
"->",
"int",
":",
"if",
"box_start",
"==",
"0",
":",
"box_end",
"=",
"segment",
".",
"seek",
"(",
"0",
",",... | [
4,
0
] | [
22,
65
] | python | en | ['en', 'en', 'en'] | True |
get_init | (segment: io.BytesIO) | Get init section from fragmented mp4. | Get init section from fragmented mp4. | def get_init(segment: io.BytesIO) -> bytes:
"""Get init section from fragmented mp4."""
moof_location = next(find_box(segment, b"moof"))
segment.seek(0)
return segment.read(moof_location) | [
"def",
"get_init",
"(",
"segment",
":",
"io",
".",
"BytesIO",
")",
"->",
"bytes",
":",
"moof_location",
"=",
"next",
"(",
"find_box",
"(",
"segment",
",",
"b\"moof\"",
")",
")",
"segment",
".",
"seek",
"(",
"0",
")",
"return",
"segment",
".",
"read",
... | [
25,
0
] | [
29,
38
] | 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.