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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
delete_user | (username) | Delete user
This can only be done by the logged in user. # noqa: E501
:param username: The name that needs to be deleted
:type username: str
:rtype: None
| Delete user | def delete_user(username): # noqa: E501
"""Delete user
This can only be done by the logged in user. # noqa: E501
:param username: The name that needs to be deleted
:type username: str
:rtype: None
"""
return 'do some magic!' | [
"def",
"delete_user",
"(",
"username",
")",
":",
"# noqa: E501",
"return",
"'do some magic!'"
] | [
52,
0
] | [
62,
27
] | python | en | ['en', 'it', 'sw'] | False |
get_user_by_name | (username) | Get user by user name
# noqa: E501
:param username: The name that needs to be fetched. Use user1 for testing.
:type username: str
:rtype: User
| Get user by user name | def get_user_by_name(username): # noqa: E501
"""Get user by user name
# noqa: E501
:param username: The name that needs to be fetched. Use user1 for testing.
:type username: str
:rtype: User
"""
return 'do some magic!' | [
"def",
"get_user_by_name",
"(",
"username",
")",
":",
"# noqa: E501",
"return",
"'do some magic!'"
] | [
65,
0
] | [
75,
27
] | python | en | ['en', 'en', 'en'] | True |
login_user | (username, password) | Logs user into the system
# noqa: E501
:param username: The user name for login
:type username: str
:param password: The password for login in clear text
:type password: str
:rtype: str
| Logs user into the system | def login_user(username, password): # noqa: E501
"""Logs user into the system
# noqa: E501
:param username: The user name for login
:type username: str
:param password: The password for login in clear text
:type password: str
:rtype: str
"""
return 'do some magic!' | [
"def",
"login_user",
"(",
"username",
",",
"password",
")",
":",
"# noqa: E501",
"return",
"'do some magic!'"
] | [
78,
0
] | [
90,
27
] | python | en | ['en', 'en', 'en'] | True |
logout_user | () | Logs out current logged in user session
# noqa: E501
:rtype: None
| Logs out current logged in user session | def logout_user(): # noqa: E501
"""Logs out current logged in user session
# noqa: E501
:rtype: None
"""
return 'do some magic!' | [
"def",
"logout_user",
"(",
")",
":",
"# noqa: E501",
"return",
"'do some magic!'"
] | [
93,
0
] | [
101,
27
] | python | en | ['en', 'en', 'en'] | True |
update_user | (username, user) | Updated user
This can only be done by the logged in user. # noqa: E501
:param username: name that need to be deleted
:type username: str
:param user: Updated user object
:type user: dict | bytes
:rtype: None
| Updated user | def update_user(username, user): # noqa: E501
"""Updated user
This can only be done by the logged in user. # noqa: E501
:param username: name that need to be deleted
:type username: str
:param user: Updated user object
:type user: dict | bytes
:rtype: None
"""
if connexion.reques... | [
"def",
"update_user",
"(",
"username",
",",
"user",
")",
":",
"# noqa: E501",
"if",
"connexion",
".",
"request",
".",
"is_json",
":",
"user",
"=",
"User",
".",
"from_dict",
"(",
"connexion",
".",
"request",
".",
"get_json",
"(",
")",
")",
"# noqa: E501",
... | [
104,
0
] | [
118,
27
] | python | en | ['en', 'en', 'en'] | False |
test_component_unload_config_entry | (hass, config_entry) | Test that loading and unloading of a config entry works. | Test that loading and unloading of a config entry works. | async def test_component_unload_config_entry(hass, config_entry):
"""Test that loading and unloading of a config entry works."""
config_entry.add_to_hass(hass)
with patch(
"aio_geojson_geonetnz_quakes.GeonetnzQuakesFeedManager.update"
) as mock_feed_manager_update:
# Load config entry.
... | [
"async",
"def",
"test_component_unload_config_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"aio_geojson_geonetnz_quakes.GeonetnzQuakesFeedManager.update\"",
")",
"as",
"mock_feed_manager_up... | [
6,
0
] | [
20,
73
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the RESTful switch. | Set up the RESTful switch. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the RESTful switch."""
body_off = config.get(CONF_BODY_OFF)
body_on = config.get(CONF_BODY_ON)
is_on_template = config.get(CONF_IS_ON_TEMPLATE)
method = config.get(CONF_METHOD)
headers = config.get(C... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"body_off",
"=",
"config",
".",
"get",
"(",
"CONF_BODY_OFF",
")",
"body_on",
"=",
"config",
".",
"get",
"(",
"CONF_BO... | [
61,
0
] | [
115,
68
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.__init__ | (
self,
name,
resource,
state_resource,
method,
headers,
params,
auth,
body_on,
body_off,
is_on_template,
timeout,
verify_ssl,
) | Initialize the REST switch. | Initialize the REST switch. | def __init__(
self,
name,
resource,
state_resource,
method,
headers,
params,
auth,
body_on,
body_off,
is_on_template,
timeout,
verify_ssl,
):
"""Initialize the REST switch."""
self._state = None
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"resource",
",",
"state_resource",
",",
"method",
",",
"headers",
",",
"params",
",",
"auth",
",",
"body_on",
",",
"body_off",
",",
"is_on_template",
",",
"timeout",
",",
"verify_ssl",
",",
")",
":",
"sel... | [
121,
4
] | [
149,
37
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
152,
4
] | [
154,
25
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
157,
4
] | [
159,
26
] | python | en | ['en', 'fy', 'en'] | True |
RestSwitch.async_turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | async def async_turn_on(self, **kwargs):
"""Turn the device on."""
body_on_t = self._body_on.async_render(parse_result=False)
try:
req = await self.set_device_state(body_on_t)
if req.status == HTTP_OK:
self._state = True
else:
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"body_on_t",
"=",
"self",
".",
"_body_on",
".",
"async_render",
"(",
"parse_result",
"=",
"False",
")",
"try",
":",
"req",
"=",
"await",
"self",
".",
"set_device_state",
"("... | [
161,
4
] | [
175,
72
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.async_turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | async def async_turn_off(self, **kwargs):
"""Turn the device off."""
body_off_t = self._body_off.async_render(parse_result=False)
try:
req = await self.set_device_state(body_off_t)
if req.status == HTTP_OK:
self._state = False
else:
... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"body_off_t",
"=",
"self",
".",
"_body_off",
".",
"async_render",
"(",
"parse_result",
"=",
"False",
")",
"try",
":",
"req",
"=",
"await",
"self",
".",
"set_device_state",
... | [
177,
4
] | [
190,
73
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.set_device_state | (self, body) | Send a state update to the device. | Send a state update to the device. | async def set_device_state(self, body):
"""Send a state update to the device."""
websession = async_get_clientsession(self.hass, self._verify_ssl)
with async_timeout.timeout(self._timeout):
req = await getattr(websession, self._method)(
self._resource,
... | [
"async",
"def",
"set_device_state",
"(",
"self",
",",
"body",
")",
":",
"websession",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_verify_ssl",
")",
"with",
"async_timeout",
".",
"timeout",
"(",
"self",
".",
"_timeout",
")",
... | [
192,
4
] | [
204,
22
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.async_update | (self) | Get the current state, catching errors. | Get the current state, catching errors. | async def async_update(self):
"""Get the current state, catching errors."""
try:
await self.get_device_state(self.hass)
except asyncio.TimeoutError:
_LOGGER.exception("Timed out while fetching data")
except aiohttp.ClientError as err:
_LOGGER.exception... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"await",
"self",
".",
"get_device_state",
"(",
"self",
".",
"hass",
")",
"except",
"asyncio",
".",
"TimeoutError",
":",
"_LOGGER",
".",
"exception",
"(",
"\"Timed out while fetching data\"",
")... | [
206,
4
] | [
213,
67
] | python | en | ['en', 'en', 'en'] | True |
RestSwitch.get_device_state | (self, hass) | Get the latest data from REST API and update the state. | Get the latest data from REST API and update the state. | async def get_device_state(self, hass):
"""Get the latest data from REST API and update the state."""
websession = async_get_clientsession(hass, self._verify_ssl)
with async_timeout.timeout(self._timeout):
req = await websession.get(
self._state_resource,
... | [
"async",
"def",
"get_device_state",
"(",
"self",
",",
"hass",
")",
":",
"websession",
"=",
"async_get_clientsession",
"(",
"hass",
",",
"self",
".",
"_verify_ssl",
")",
"with",
"async_timeout",
".",
"timeout",
"(",
"self",
".",
"_timeout",
")",
":",
"req",
... | [
215,
4
] | [
247,
18
] | python | en | ['en', 'en', 'en'] | True |
ModernFormsFlowHandler.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle setup by user for Modern Forms integration. | Handle setup by user for Modern Forms integration. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle setup by user for Modern Forms integration."""
return await self._handle_config_flow(user_input) | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"return",
"await",
"self",
".",
"_handle_config_flow",
"(",
"user_input",
")"
] | [
22,
4
] | [
26,
57
] | python | en | ['en', 'en', 'en'] | True |
ModernFormsFlowHandler.async_step_zeroconf | (
self, discovery_info: DiscoveryInfoType
) | Handle zeroconf discovery. | Handle zeroconf discovery. | async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
) -> FlowResult:
"""Handle zeroconf discovery."""
host = discovery_info["hostname"].rstrip(".")
name, _ = host.rsplit(".")
self.context.update(
{
CONF_HOST: discovery_info["hos... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
":",
"DiscoveryInfoType",
")",
"->",
"FlowResult",
":",
"host",
"=",
"discovery_info",
"[",
"\"hostname\"",
"]",
".",
"rstrip",
"(",
"\".\"",
")",
"name",
",",
"_",
"=",
"host",
".",
... | [
28,
4
] | [
45,
67
] | python | de | ['de', 'sr', 'en'] | False |
ModernFormsFlowHandler.async_step_zeroconf_confirm | (
self, user_input: dict[str, Any] | None = None
) | Handle a flow initiated by zeroconf. | Handle a flow initiated by zeroconf. | async def async_step_zeroconf_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle a flow initiated by zeroconf."""
return await self._handle_config_flow(user_input) | [
"async",
"def",
"async_step_zeroconf_confirm",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"return",
"await",
"self",
".",
"_handle_config_flow",
"(",
"user_input",
")"
] | [
47,
4
] | [
51,
57
] | python | en | ['en', 'en', 'en'] | True |
ModernFormsFlowHandler._handle_config_flow | (
self, user_input: dict[str, Any] | None = None, prepare: bool = False
) | Config flow handler for ModernForms. | Config flow handler for ModernForms. | async def _handle_config_flow(
self, user_input: dict[str, Any] | None = None, prepare: bool = False
) -> FlowResult:
"""Config flow handler for ModernForms."""
source = self.context.get("source")
# Request user input, unless we are preparing discovery flow
if user_input is ... | [
"async",
"def",
"_handle_config_flow",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
",",
"prepare",
":",
"bool",
"=",
"False",
")",
"->",
"FlowResult",
":",
"source",
"=",
"self",
".",
"context",
... | [
53,
4
] | [
97,
9
] | python | da | ['da', 'da', 'en'] | True |
ModernFormsFlowHandler._show_setup_form | (self, errors: dict | None = None) | Show the setup form to the user. | Show the setup form to the user. | def _show_setup_form(self, errors: dict | None = None) -> FlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
data_schema=vol.Schema({vol.Required(CONF_HOST): str}),
errors=errors or {},
) | [
"def",
"_show_setup_form",
"(",
"self",
",",
"errors",
":",
"dict",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{"... | [
99,
4
] | [
105,
9
] | python | en | ['en', 'en', 'en'] | True |
ModernFormsFlowHandler._show_confirm_dialog | (self, errors: dict | None = None) | Show the confirm dialog to the user. | Show the confirm dialog to the user. | def _show_confirm_dialog(self, errors: dict | None = None) -> FlowResult:
"""Show the confirm dialog to the user."""
name = self.context.get(CONF_NAME)
return self.async_show_form(
step_id="zeroconf_confirm",
description_placeholders={"name": name},
errors=err... | [
"def",
"_show_confirm_dialog",
"(",
"self",
",",
"errors",
":",
"dict",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"name",
"=",
"self",
".",
"context",
".",
"get",
"(",
"CONF_NAME",
")",
"return",
"self",
".",
"async_show_form",
"(",
"step_i... | [
107,
4
] | [
114,
9
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_detects_none | (hass, mock_openzwave) | Test device returns none. | Test device returns none. | def test_get_device_detects_none(hass, mock_openzwave):
"""Test device returns none."""
node = MockNode()
value = MockValue(data=0, node=node)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass=hass, node=node, values=values, node_config={})
assert device is None | [
"def",
"test_get_device_detects_none",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"0",
",",
"node",
"=",
"node",
")",
"values",
"=",
"MockEntityValues",
"(",
"primary",
"=",... | [
14,
0
] | [
21,
25
] | python | en | ['fr', 'en', 'en'] | True |
test_get_device_detects_rollershutter | (hass, mock_openzwave) | Test device returns rollershutter. | Test device returns rollershutter. | def test_get_device_detects_rollershutter(hass, mock_openzwave):
"""Test device returns rollershutter."""
hass.data[const.DATA_NETWORK] = MagicMock()
node = MockNode()
value = MockValue(
data=0, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
values = MockEntityValues(pr... | [
"def",
"test_get_device_detects_rollershutter",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"hass",
".",
"data",
"[",
"const",
".",
"DATA_NETWORK",
"]",
"=",
"MagicMock",
"(",
")",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
... | [
24,
0
] | [
34,
55
] | python | en | ['fr', 'en', 'en'] | True |
test_get_device_detects_garagedoor_switch | (hass, mock_openzwave) | Test device returns garage door. | Test device returns garage door. | def test_get_device_detects_garagedoor_switch(hass, mock_openzwave):
"""Test device returns garage door."""
node = MockNode()
value = MockValue(
data=False, node=node, command_class=const.COMMAND_CLASS_SWITCH_BINARY
)
values = MockEntityValues(primary=value, node=node)
device = cover.ge... | [
"def",
"test_get_device_detects_garagedoor_switch",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"False",
",",
"node",
"=",
"node",
",",
"command_class",
"=",
"const",
".",
"COM... | [
37,
0
] | [
48,
68
] | python | nl | ['nl', 'nl', 'en'] | True |
test_get_device_detects_garagedoor_barrier | (hass, mock_openzwave) | Test device returns garage door. | Test device returns garage door. | def test_get_device_detects_garagedoor_barrier(hass, mock_openzwave):
"""Test device returns garage door."""
node = MockNode()
value = MockValue(
data="Closed", node=node, command_class=const.COMMAND_CLASS_BARRIER_OPERATOR
)
values = MockEntityValues(primary=value, node=node)
device = c... | [
"def",
"test_get_device_detects_garagedoor_barrier",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"\"Closed\"",
",",
"node",
"=",
"node",
",",
"command_class",
"=",
"const",
".",
... | [
51,
0
] | [
62,
68
] | python | nl | ['nl', 'nl', 'en'] | True |
test_roller_no_position_workaround | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_roller_no_position_workaround(hass, mock_openzwave):
"""Test position changed."""
hass.data[const.DATA_NETWORK] = MagicMock()
node = MockNode(manufacturer_id="0047", product_type="5a52")
value = MockValue(
data=45, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
... | [
"def",
"test_roller_no_position_workaround",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"hass",
".",
"data",
"[",
"const",
".",
"DATA_NETWORK",
"]",
"=",
"MagicMock",
"(",
")",
"node",
"=",
"MockNode",
"(",
"manufacturer_id",
"=",
"\"0047\"",
",",
"product_... | [
65,
0
] | [
75,
48
] | python | en | ['en', 'en', 'en'] | True |
test_roller_value_changed | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_roller_value_changed(hass, mock_openzwave):
"""Test position changed."""
hass.data[const.DATA_NETWORK] = MagicMock()
node = MockNode()
value = MockValue(
data=None, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
values = MockEntityValues(primary=value, open=Non... | [
"def",
"test_roller_value_changed",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"hass",
".",
"data",
"[",
"const",
".",
"DATA_NETWORK",
"]",
"=",
"MagicMock",
"(",
")",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"No... | [
78,
0
] | [
107,
31
] | python | en | ['en', 'en', 'en'] | True |
test_roller_commands | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_roller_commands(hass, mock_openzwave):
"""Test position changed."""
mock_network = hass.data[const.DATA_NETWORK] = MagicMock()
node = MockNode()
value = MockValue(
data=50, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
open_value = MockValue(data=False, node=n... | [
"def",
"test_roller_commands",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"mock_network",
"=",
"hass",
".",
"data",
"[",
"const",
".",
"DATA_NETWORK",
"]",
"=",
"MagicMock",
"(",
")",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
... | [
110,
0
] | [
143,
42
] | python | en | ['en', 'en', 'en'] | True |
test_roller_invert_percent | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_roller_invert_percent(hass, mock_openzwave):
"""Test position changed."""
mock_network = hass.data[const.DATA_NETWORK] = MagicMock()
node = MockNode()
value = MockValue(
data=50, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
open_value = MockValue(data=False, ... | [
"def",
"test_roller_invert_percent",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"mock_network",
"=",
"hass",
".",
"data",
"[",
"const",
".",
"DATA_NETWORK",
"]",
"=",
"MagicMock",
"(",
")",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"... | [
146,
0
] | [
171,
42
] | python | en | ['en', 'en', 'en'] | True |
test_roller_reverse_open_close | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_roller_reverse_open_close(hass, mock_openzwave):
"""Test position changed."""
mock_network = hass.data[const.DATA_NETWORK] = MagicMock()
node = MockNode()
value = MockValue(
data=50, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL
)
open_value = MockValue(data=Fal... | [
"def",
"test_roller_reverse_open_close",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"mock_network",
"=",
"hass",
".",
"data",
"[",
"const",
".",
"DATA_NETWORK",
"]",
"=",
"MagicMock",
"(",
")",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",... | [
174,
0
] | [
206,
43
] | python | en | ['en', 'en', 'en'] | True |
test_switch_garage_value_changed | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_switch_garage_value_changed(hass, mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(
data=False, node=node, command_class=const.COMMAND_CLASS_SWITCH_BINARY
)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass=hass, ... | [
"def",
"test_switch_garage_value_changed",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"False",
",",
"node",
"=",
"node",
",",
"command_class",
"=",
"const",
".",
"COMMAND_CLAS... | [
209,
0
] | [
222,
31
] | python | en | ['en', 'en', 'en'] | True |
test_switch_garage_commands | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_switch_garage_commands(hass, mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(
data=False, node=node, command_class=const.COMMAND_CLASS_SWITCH_BINARY
)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass=hass, node=... | [
"def",
"test_switch_garage_commands",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"False",
",",
"node",
"=",
"node",
",",
"command_class",
"=",
"const",
".",
"COMMAND_CLASS_SWI... | [
225,
0
] | [
238,
30
] | python | en | ['en', 'en', 'en'] | True |
test_barrier_garage_value_changed | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_barrier_garage_value_changed(hass, mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(
data="Closed", node=node, command_class=const.COMMAND_CLASS_BARRIER_OPERATOR
)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass... | [
"def",
"test_barrier_garage_value_changed",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"\"Closed\"",
",",
"node",
"=",
"node",
",",
"command_class",
"=",
"const",
".",
"COMMAN... | [
241,
0
] | [
270,
28
] | python | en | ['en', 'en', 'en'] | True |
test_barrier_garage_commands | (hass, mock_openzwave) | Test position changed. | Test position changed. | def test_barrier_garage_commands(hass, mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(
data="Closed", node=node, command_class=const.COMMAND_CLASS_BARRIER_OPERATOR
)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass=hass... | [
"def",
"test_barrier_garage_commands",
"(",
"hass",
",",
"mock_openzwave",
")",
":",
"node",
"=",
"MockNode",
"(",
")",
"value",
"=",
"MockValue",
"(",
"data",
"=",
"\"Closed\"",
",",
"node",
"=",
"node",
",",
"command_class",
"=",
"const",
".",
"COMMAND_CLA... | [
273,
0
] | [
286,
33
] | python | en | ['en', 'en', 'en'] | True |
test_entry_setup_unload | (hass, api_factory, gateway_id) | Test config entry setup and unload. | Test config entry setup and unload. | async def test_entry_setup_unload(hass, api_factory, gateway_id):
"""Test config entry setup and unload."""
entry = MockConfigEntry(
domain=tradfri.DOMAIN,
data={
tradfri.CONF_HOST: "mock-host",
tradfri.CONF_IDENTITY: "mock-identity",
tradfri.CONF_KEY: "mock-k... | [
"async",
"def",
"test_entry_setup_unload",
"(",
"hass",
",",
"api_factory",
",",
"gateway_id",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"tradfri",
".",
"DOMAIN",
",",
"data",
"=",
"{",
"tradfri",
".",
"CONF_HOST",
":",
"\"mock-host\"",
... | [
9,
0
] | [
48,
51
] | python | en | ['en', 'en', 'en'] | True |
test_weather | (hass, mock_weather) | Test weather entity. | Test weather entity. | async def test_weather(hass, mock_weather):
"""Test weather entity."""
# Create a mock configuration for testing
mock_data = MockConfigEntry(
domain=DOMAIN,
data={"name": "Somewhere", "latitude": 10, "longitude": 20, "elevation": 0},
)
mock_data.add_to_hass(hass)
await hass.conf... | [
"async",
"def",
"test_weather",
"(",
"hass",
",",
"mock_weather",
")",
":",
"# Create a mock configuration for testing",
"mock_data",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"name\"",
":",
"\"Somewhere\"",
",",
"\"latitude\"",
... | [
7,
0
] | [
30,
60
] | python | en | ['en', 'en', 'en'] | True |
spider_fixture | () | Patch libraries. | Patch libraries. | def spider_fixture() -> Mock:
"""Patch libraries."""
with patch("homeassistant.components.spider.config_flow.SpiderApi") as spider:
yield spider | [
"def",
"spider_fixture",
"(",
")",
"->",
"Mock",
":",
"with",
"patch",
"(",
"\"homeassistant.components.spider.config_flow.SpiderApi\"",
")",
"as",
"spider",
":",
"yield",
"spider"
] | [
21,
0
] | [
24,
20
] | python | en | ['en', 'en', 'en'] | False |
test_user | (hass, spider) | Test user config. | Test user config. | async def test_user(hass, spider):
"""Test user config."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE... | [
"async",
"def",
"test_user",
"(",
"hass",
",",
"spider",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
... | [
27,
0
] | [
54,
48
] | python | en | ['en', 'da', 'en'] | True |
test_import | (hass, spider) | Test import step. | Test import step. | async def test_import(hass, spider):
"""Test import step."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.spider.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.spider.async_setup_e... | [
"async",
"def",
"test_import",
"(",
"hass",
",",
"spider",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.components.spider.async_setup\"",
",",
... | [
57,
0
] | [
81,
48
] | python | de | ['de', 'sd', 'en'] | False |
test_abort_if_already_setup | (hass, spider) | Test we abort if Spider is already setup. | Test we abort if Spider is already setup. | async def test_abort_if_already_setup(hass, spider):
"""Test we abort if Spider is already setup."""
MockConfigEntry(domain=DOMAIN, data=SPIDER_USER_DATA).add_to_hass(hass)
# Should fail, config exist (import)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
",",
"spider",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"SPIDER_USER_DATA",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"# Should fail, config exist (import)",
"result",
... | [
84,
0
] | [
102,
56
] | python | en | ['en', 'de', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Ombi sensor platform. | Set up the Ombi sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Ombi sensor platform."""
if discovery_info is None:
return
ombi = hass.data[DOMAIN]["instance"]
entities = [OmbiSensor(ombi, description) for description in SENSOR_TYPES]
add_entities(entities, True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"ombi",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"instance\"",
"]",
"... | [
15,
0
] | [
24,
32
] | python | en | ['en', 'da', 'en'] | True |
OmbiSensor.__init__ | (self, ombi, description: SensorEntityDescription) | Initialize the sensor. | Initialize the sensor. | def __init__(self, ombi, description: SensorEntityDescription):
"""Initialize the sensor."""
self.entity_description = description
self._ombi = ombi
self._attr_name = f"Ombi {description.name}" | [
"def",
"__init__",
"(",
"self",
",",
"ombi",
",",
"description",
":",
"SensorEntityDescription",
")",
":",
"self",
".",
"entity_description",
"=",
"description",
"self",
".",
"_ombi",
"=",
"ombi",
"self",
".",
"_attr_name",
"=",
"f\"Ombi {description.name}\""
] | [
30,
4
] | [
35,
52
] | python | en | ['en', 'en', 'en'] | True |
OmbiSensor.update | (self) | Update the sensor. | Update the sensor. | def update(self):
"""Update the sensor."""
try:
sensor_type = self.entity_description.key
if sensor_type == "movies":
self._attr_native_value = self._ombi.movie_requests
elif sensor_type == "tv":
self._attr_native_value = self._ombi.tv_... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"sensor_type",
"=",
"self",
".",
"entity_description",
".",
"key",
"if",
"sensor_type",
"==",
"\"movies\"",
":",
"self",
".",
"_attr_native_value",
"=",
"self",
".",
"_ombi",
".",
"movie_requests",
"elif",
... | [
37,
4
] | [
55,
42
] | python | en | ['en', 'nl', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up mysq covers. | Set up mysq covers. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up mysq covers."""
data = hass.data[DOMAIN][config_entry.entry_id]
myq = data[MYQ_GATEWAY]
coordinator = data[MYQ_COORDINATOR]
async_add_entities(
[MyQCover(coordinator, device) for device in myq.covers.values()]
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"myq",
"=",
"data",
"[",
"MYQ_GATEWAY",
"]",
"coord... | [
22,
0
] | [
30,
5
] | python | en | ['en', 'bg', 'en'] | True |
MyQCover.__init__ | (self, coordinator, device) | Initialize with API object, device id. | Initialize with API object, device id. | def __init__(self, coordinator, device):
"""Initialize with API object, device id."""
super().__init__(coordinator, device)
self._device = device
if device.device_type == MYQ_DEVICE_TYPE_GATE:
self._attr_device_class = DEVICE_CLASS_GATE
else:
self._attr_de... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
",",
"device",
")",
"self",
".",
"_device",
"=",
"device",
"if",
"device",
".",
"device_type",
"==",
"MYQ_DEVICE_TYPE_GATE"... | [
38,
4
] | [
46,
47
] | python | en | ['en', 'en', 'en'] | True |
MyQCover.is_closed | (self) | Return true if cover is closed, else False. | Return true if cover is closed, else False. | def is_closed(self):
"""Return true if cover is closed, else False."""
return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSED | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_CLOSED"
] | [
49,
4
] | [
51,
66
] | python | en | ['en', 'en', 'en'] | True |
MyQCover.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not."""
return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSING | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_CLOSING"
] | [
54,
4
] | [
56,
67
] | python | en | ['en', 'en', 'en'] | True |
MyQCover.is_open | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_open(self):
"""Return if the cover is opening or not."""
return MYQ_TO_HASS.get(self._device.state) == STATE_OPEN | [
"def",
"is_open",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_OPEN"
] | [
59,
4
] | [
61,
64
] | python | en | ['en', 'en', 'en'] | True |
MyQCover.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not."""
return MYQ_TO_HASS.get(self._device.state) == STATE_OPENING | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_OPENING"
] | [
64,
4
] | [
66,
67
] | python | en | ['en', 'en', 'en'] | True |
MyQCover.async_close_cover | (self, **kwargs) | Issue close command to cover. | Issue close command to cover. | async def async_close_cover(self, **kwargs):
"""Issue close command to cover."""
if self.is_closing or self.is_closed:
return
try:
wait_task = await self._device.close(wait_for_state=False)
except MyQError as err:
raise HomeAssistantError(
... | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"is_closing",
"or",
"self",
".",
"is_closed",
":",
"return",
"try",
":",
"wait_task",
"=",
"await",
"self",
".",
"_device",
".",
"close",
"(",
"wait... | [
68,
4
] | [
89,
84
] | python | en | ['en', 'en', 'en'] | True |
MyQCover.async_open_cover | (self, **kwargs) | Issue open command to cover. | Issue open command to cover. | async def async_open_cover(self, **kwargs):
"""Issue open command to cover."""
if self.is_opening or self.is_open:
return
try:
wait_task = await self._device.open(wait_for_state=False)
except MyQError as err:
raise HomeAssistantError(
... | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"is_opening",
"or",
"self",
".",
"is_open",
":",
"return",
"try",
":",
"wait_task",
"=",
"await",
"self",
".",
"_device",
".",
"open",
"(",
"wait_for... | [
91,
4
] | [
112,
84
] | python | en | ['en', 'en', 'en'] | True |
merge_setting | (request_setting, session_setting, dict_class=OrderedDict) | Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
"""Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
"""
... | [
"def",
"merge_setting",
"(",
"request_setting",
",",
"session_setting",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_setting",
"is",
"None",
":",
"return",
"request_setting",
"if",
"request_setting",
"is",
"None",
":",
"return",
"session_setting",... | [
49,
0
] | [
77,
25
] | python | en | ['en', 'en', 'en'] | True |
merge_hooks | (request_hooks, session_hooks, dict_class=OrderedDict) | Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
| Properly merges both requests and session hooks. | def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get('response') == []:
... | [
"def",
"merge_hooks",
"(",
"request_hooks",
",",
"session_hooks",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_hooks",
"is",
"None",
"or",
"session_hooks",
".",
"get",
"(",
"'response'",
")",
"==",
"[",
"]",
":",
"return",
"request_hooks",
... | [
80,
0
] | [
92,
66
] | python | en | ['en', 'en', 'en'] | True |
session | () |
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be removed at a future date.... |
Returns a :class:`Session` for context-management. | def session():
"""
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be rem... | [
"def",
"session",
"(",
")",
":",
"return",
"Session",
"(",
")"
] | [
756,
0
] | [
768,
20
] | python | en | ['en', 'error', 'th'] | False |
SessionRedirectMixin.get_redirect_target | (self, resp) | Receives a Response. Returns a redirect URI or ``None`` | Receives a Response. Returns a redirect URI or ``None`` | def get_redirect_target(self, resp):
"""Receives a Response. Returns a redirect URI or ``None``"""
# Due to the nature of how requests processes redirects this method will
# be called at least once upon the original response and at least twice
# on each subsequent redirect response (if a... | [
"def",
"get_redirect_target",
"(",
"self",
",",
"resp",
")",
":",
"# Due to the nature of how requests processes redirects this method will",
"# be called at least once upon the original response and at least twice",
"# on each subsequent redirect response (if any).",
"# If a custom mixin is u... | [
97,
4
] | [
116,
19
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.should_strip_auth | (self, old_url, new_url) | Decide whether Authorization header should be removed when redirecting | Decide whether Authorization header should be removed when redirecting | def should_strip_auth(self, old_url, new_url):
"""Decide whether Authorization header should be removed when redirecting"""
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow h... | [
"def",
"should_strip_auth",
"(",
"self",
",",
"old_url",
",",
"new_url",
")",
":",
"old_parsed",
"=",
"urlparse",
"(",
"old_url",
")",
"new_parsed",
"=",
"urlparse",
"(",
"new_url",
")",
"if",
"old_parsed",
".",
"hostname",
"!=",
"new_parsed",
".",
"hostname... | [
118,
4
] | [
141,
45
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.resolve_redirects | (self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs) | Receives a Response. Returns a generator of Responses or Requests. | Receives a Response. Returns a generator of Responses or Requests. | def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get... | [
"def",
"resolve_redirects",
"(",
"self",
",",
"resp",
",",
"req",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"yield_requests",
"=",
"False",
",",
"... | [
143,
4
] | [
251,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_auth | (self, prepared_request, response) | When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| def rebuild_auth(self, prepared_request, response):
"""When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
"""
headers = pr... | [
"def",
"rebuild_auth",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
".",
"url",
"if",
"'Authorization'",
"in",
"headers",
"and",
"self",
".",
"should_strip_au... | [
253,
4
] | [
269,
51
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_proxies | (self, prepared_request, proxies) | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).
... | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect). | def rebuild_proxies(self, prepared_request, proxies):
"""This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in c... | [
"def",
"rebuild_proxies",
"(",
"self",
",",
"prepared_request",
",",
"proxies",
")",
":",
"proxies",
"=",
"proxies",
"if",
"proxies",
"is",
"not",
"None",
"else",
"{",
"}",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
"... | [
272,
4
] | [
311,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_method | (self, prepared_request, response) | When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| def rebuild_method(self, prepared_request, response):
"""When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
"""
method = prepared_request.method
# https://tools.ietf.org/html/rfc7231#section-6.4.4
if response... | [
"def",
"rebuild_method",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"method",
"=",
"prepared_request",
".",
"method",
"# https://tools.ietf.org/html/rfc7231#section-6.4.4",
"if",
"response",
".",
"status_code",
"==",
"codes",
".",
"see_other",
"a... | [
313,
4
] | [
333,
40
] | python | en | ['en', 'en', 'en'] | True |
Session.prepare_request | (self, request) | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
... | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`. | def prepare_request(self, request):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class... | [
"def",
"prepare_request",
"(",
"self",
",",
"request",
")",
":",
"cookies",
"=",
"request",
".",
"cookies",
"or",
"{",
"}",
"# Bootstrap CookieJar.",
"if",
"not",
"isinstance",
"(",
"cookies",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"cookies",
"=",
"... | [
422,
4
] | [
460,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.request | (self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None) | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the... | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object. | def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
"""Constructs a :class:`Request <Request>`, prepares it and... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"N... | [
462,
4
] | [
531,
19
] | python | en | ['en', 'en', 'en'] | True |
Session.get | (self, url, **kwargs) | r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a GET request. Returns :class:`Response` object. | def get(self, url, **kwargs):
r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects',... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'GET'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
533,
4
] | [
542,
49
] | python | en | ['en', 'lb', 'en'] | True |
Session.options | (self, url, **kwargs) | r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a OPTIONS request. Returns :class:`Response` object. | def options(self, url, **kwargs):
r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_red... | [
"def",
"options",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'OPTIONS'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
544,
4
] | [
553,
53
] | python | en | ['en', 'en', 'en'] | True |
Session.head | (self, url, **kwargs) | r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a HEAD request. Returns :class:`Response` object. | def head(self, url, **kwargs):
r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects... | [
"def",
"head",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"self",
".",
"request",
"(",
"'HEAD'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
555,
4
] | [
564,
50
] | python | en | ['en', 'lb', 'en'] | True |
Session.post | (self, url, data=None, json=None, **kwargs) | r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json to send in the bo... | r"""Sends a POST request. Returns :class:`Response` object. | def post(self, url, data=None, json=None, **kwargs):
r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Req... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'POST'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",... | [
566,
4
] | [
577,
72
] | python | en | ['en', 'lb', 'en'] | True |
Session.put | (self, url, data=None, **kwargs) | r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``re... | r"""Sends a PUT request. Returns :class:`Response` object. | def put(self, url, data=None, **kwargs):
r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PUT'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
579,
4
] | [
589,
60
] | python | en | ['en', 'lb', 'en'] | True |
Session.patch | (self, url, data=None, **kwargs) | r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``... | r"""Sends a PATCH request. Returns :class:`Response` object. | def patch(self, url, data=None, **kwargs):
r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"patch",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PATCH'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
591,
4
] | [
601,
62
] | python | en | ['en', 'en', 'en'] | True |
Session.delete | (self, url, **kwargs) | r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a DELETE request. Returns :class:`Response` object. | def delete(self, url, **kwargs):
r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
return self.request('DELETE', ... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'DELETE'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
603,
4
] | [
611,
52
] | python | en | ['en', 'en', 'en'] | True |
Session.send | (self, request, **kwargs) | Send a given PreparedRequest.
:rtype: requests.Response
| Send a given PreparedRequest. | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults that the hooks can utilize to ensure they always have",
"# the correct parameters to reproduce the previous request.",
"kwargs",
".",
"setdefault",
"(",
"'stream'",
",",
"self",
"... | [
613,
4
] | [
686,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.merge_environment_settings | (self, url, proxies, stream, verify, cert) |
Check the environment and merge it with some settings.
:rtype: dict
|
Check the environment and merge it with some settings. | def merge_environment_settings(self, url, proxies, stream, verify, cert):
"""
Check the environment and merge it with some settings.
:rtype: dict
"""
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
... | [
"def",
"merge_environment_settings",
"(",
"self",
",",
"url",
",",
"proxies",
",",
"stream",
",",
"verify",
",",
"cert",
")",
":",
"# Gather clues from the surrounding environment.",
"if",
"self",
".",
"trust_env",
":",
"# Set environment's proxies.",
"no_proxy",
"=",... | [
688,
4
] | [
715,
29
] | python | en | ['en', 'error', 'th'] | False |
Session.get_adapter | (self, url) |
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
|
Returns the appropriate connection adapter for the given URL. | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
... | [
"def",
"get_adapter",
"(",
"self",
",",
"url",
")",
":",
"for",
"(",
"prefix",
",",
"adapter",
")",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"prefix",
".",
"lower",
"... | [
717,
4
] | [
729,
85
] | python | en | ['en', 'error', 'th'] | False |
Session.close | (self) | Closes all adapters and as such the session | Closes all adapters and as such the session | def close(self):
"""Closes all adapters and as such the session"""
for v in self.adapters.values():
v.close() | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"v",
"in",
"self",
".",
"adapters",
".",
"values",
"(",
")",
":",
"v",
".",
"close",
"(",
")"
] | [
731,
4
] | [
734,
21
] | python | en | ['en', 'en', 'en'] | True |
Session.mount | (self, prefix, adapter) | Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
| Registers a connection adapter to a prefix. | def mount(self, prefix, adapter):
"""Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
"""
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
... | [
"def",
"mount",
"(",
"self",
",",
"prefix",
",",
"adapter",
")",
":",
"self",
".",
"adapters",
"[",
"prefix",
"]",
"=",
"adapter",
"keys_to_move",
"=",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"adapters",
"if",
"len",
"(",
"k",
")",
"<",
"len",
"... | [
736,
4
] | [
745,
55
] | python | en | ['en', 'en', 'en'] | True |
MobileAppFlowHandler.async_step_user | (self, user_input=None) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
placeholders = {
"apps_url": "https://www.home-assistant.io/integrations/mobile_app/#apps"
}
return self.async_abort(
reason="install_app", description_placeholders=pla... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"placeholders",
"=",
"{",
"\"apps_url\"",
":",
"\"https://www.home-assistant.io/integrations/mobile_app/#apps\"",
"}",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
... | [
16,
4
] | [
24,
9
] | python | en | ['en', 'en', 'en'] | True |
MobileAppFlowHandler.async_step_registration | (self, user_input=None) | Handle a flow initialized during registration. | Handle a flow initialized during registration. | async def async_step_registration(self, user_input=None):
"""Handle a flow initialized during registration."""
if ATTR_DEVICE_ID in user_input:
# Unique ID is combi of app + device ID.
await self.async_set_unique_id(
f"{user_input[ATTR_APP_ID]}-{user_input[ATTR_DE... | [
"async",
"def",
"async_step_registration",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"ATTR_DEVICE_ID",
"in",
"user_input",
":",
"# Unique ID is combi of app + device ID.",
"await",
"self",
".",
"async_set_unique_id",
"(",
"f\"{user_input[ATTR_APP_ID]}-{... | [
26,
4
] | [
50,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) | Set up device tracker for Keenetic NDMS2 component. | Set up device tracker for Keenetic NDMS2 component. | async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
):
"""Set up device tracker for Keenetic NDMS2 component."""
router: KeeneticRouter = hass.data[DOMAIN][config_entry.entry_id][ROUTER]
async_add_entities([RouterOnlineBinarySensor(router)]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
":",
"router",
":",
"KeeneticRouter",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entr... | [
17,
0
] | [
23,
58
] | python | en | ['en', 'en', 'en'] | True |
RouterOnlineBinarySensor.__init__ | (self, router: KeeneticRouter) | Initialize the APCUPSd binary device. | Initialize the APCUPSd binary device. | def __init__(self, router: KeeneticRouter) -> None:
"""Initialize the APCUPSd binary device."""
self._router = router | [
"def",
"__init__",
"(",
"self",
",",
"router",
":",
"KeeneticRouter",
")",
"->",
"None",
":",
"self",
".",
"_router",
"=",
"router"
] | [
32,
4
] | [
34,
29
] | python | en | ['en', 'en', 'en'] | True |
RouterOnlineBinarySensor.name | (self) | Return the name of the online status sensor. | Return the name of the online status sensor. | def name(self):
"""Return the name of the online status sensor."""
return f"{self._router.name} Online" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._router.name} Online\""
] | [
37,
4
] | [
39,
44
] | python | en | ['en', 'no', 'en'] | True |
RouterOnlineBinarySensor.unique_id | (self) | Return a unique identifier for this device. | Return a unique identifier for this device. | def unique_id(self) -> str:
"""Return a unique identifier for this device."""
return f"online_{self._router.config_entry.entry_id}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"online_{self._router.config_entry.entry_id}\""
] | [
42,
4
] | [
44,
61
] | python | en | ['en', 'en', 'en'] | True |
RouterOnlineBinarySensor.is_on | (self) | Return true if the UPS is online, else false. | Return true if the UPS is online, else false. | def is_on(self):
"""Return true if the UPS is online, else false."""
return self._router.available | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_router",
".",
"available"
] | [
47,
4
] | [
49,
37
] | python | en | ['en', 'da', 'en'] | True |
RouterOnlineBinarySensor.device_info | (self) | Return a client description for device registry. | Return a client description for device registry. | def device_info(self):
"""Return a client description for device registry."""
return self._router.device_info | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_router",
".",
"device_info"
] | [
52,
4
] | [
54,
39
] | python | ca | ['ca', 'fr', 'en'] | False |
RouterOnlineBinarySensor.async_added_to_hass | (self) | Client entity created. | Client entity created. | async def async_added_to_hass(self):
"""Client entity created."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
self._router.signal_update,
self.async_write_ha_state,
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_router",
".",
"signal_update",
",",
"self",
".",
"async_write_ha_state",
",",
")",
")"
... | [
56,
4
] | [
64,
9
] | python | en | ['en', 'en', 'en'] | True |
rehash | (path, blocksize=1 << 20) | Return (encoded_digest, length) for path using hashlib.sha256() | Return (encoded_digest, length) for path using hashlib.sha256() | def rehash(path, blocksize=1 << 20):
# type: (text_type, int) -> Tuple[str, str]
"""Return (encoded_digest, length) for path using hashlib.sha256()"""
h, length = hash_file(path, blocksize)
digest = 'sha256=' + urlsafe_b64encode(
h.digest()
).decode('latin1').rstrip('=')
# unicode/str py... | [
"def",
"rehash",
"(",
"path",
",",
"blocksize",
"=",
"1",
"<<",
"20",
")",
":",
"# type: (text_type, int) -> Tuple[str, str]",
"h",
",",
"length",
"=",
"hash_file",
"(",
"path",
",",
"blocksize",
")",
"digest",
"=",
"'sha256='",
"+",
"urlsafe_b64encode",
"(",
... | [
103,
0
] | [
111,
32
] | python | cy | ['da', 'cy', 'en'] | False |
csv_io_kwargs | (mode) | Return keyword arguments to properly open a CSV file
in the given mode.
| Return keyword arguments to properly open a CSV file
in the given mode.
| def csv_io_kwargs(mode):
# type: (str) -> Dict[str, Any]
"""Return keyword arguments to properly open a CSV file
in the given mode.
"""
if PY2:
return {'mode': '{}b'.format(mode)}
else:
return {'mode': mode, 'newline': '', 'encoding': 'utf-8'} | [
"def",
"csv_io_kwargs",
"(",
"mode",
")",
":",
"# type: (str) -> Dict[str, Any]",
"if",
"PY2",
":",
"return",
"{",
"'mode'",
":",
"'{}b'",
".",
"format",
"(",
"mode",
")",
"}",
"else",
":",
"return",
"{",
"'mode'",
":",
"mode",
",",
"'newline'",
":",
"''... | [
114,
0
] | [
122,
65
] | python | en | ['en', 'en', 'en'] | True |
fix_script | (path) | Replace #!python with #!/path/to/python
Return True if file was changed.
| Replace #!python with #!/path/to/python
Return True if file was changed.
| def fix_script(path):
# type: (text_type) -> bool
"""Replace #!python with #!/path/to/python
Return True if file was changed.
"""
# XXX RECORD hashes will need to be updated
assert os.path.isfile(path)
with open(path, 'rb') as script:
firstline = script.readline()
if not fir... | [
"def",
"fix_script",
"(",
"path",
")",
":",
"# type: (text_type) -> bool",
"# XXX RECORD hashes will need to be updated",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"script",
":",
"firstline... | [
125,
0
] | [
143,
15
] | python | en | ['en', 'lt', 'en'] | True |
message_about_scripts_not_on_PATH | (scripts) | Determine if any scripts are not on PATH and format a warning.
Returns a warning message if one or more scripts are not on PATH,
otherwise None.
| Determine if any scripts are not on PATH and format a warning.
Returns a warning message if one or more scripts are not on PATH,
otherwise None.
| def message_about_scripts_not_on_PATH(scripts):
# type: (Sequence[str]) -> Optional[str]
"""Determine if any scripts are not on PATH and format a warning.
Returns a warning message if one or more scripts are not on PATH,
otherwise None.
"""
if not scripts:
return None
# Group script... | [
"def",
"message_about_scripts_not_on_PATH",
"(",
"scripts",
")",
":",
"# type: (Sequence[str]) -> Optional[str]",
"if",
"not",
"scripts",
":",
"return",
"None",
"# Group scripts by the path they were installed in",
"grouped_by_dir",
"=",
"collections",
".",
"defaultdict",
"(",
... | [
176,
0
] | [
244,
31
] | python | en | ['en', 'en', 'en'] | True |
_normalized_outrows | (outrows) | Normalize the given rows of a RECORD file.
Items in each row are converted into str. Rows are then sorted to make
the value more predictable for tests.
Each row is a 3-tuple (path, hash, size) and corresponds to a record of
a RECORD file (see PEP 376 and PEP 427 for details). For the rows
passed ... | Normalize the given rows of a RECORD file. | def _normalized_outrows(outrows):
# type: (Iterable[InstalledCSVRow]) -> List[Tuple[str, str, str]]
"""Normalize the given rows of a RECORD file.
Items in each row are converted into str. Rows are then sorted to make
the value more predictable for tests.
Each row is a 3-tuple (path, hash, size) an... | [
"def",
"_normalized_outrows",
"(",
"outrows",
")",
":",
"# type: (Iterable[InstalledCSVRow]) -> List[Tuple[str, str, str]]",
"# Normally, there should only be one row per path, in which case the",
"# second and third elements don't come into play when sorting.",
"# However, in cases in the wild wh... | [
247,
0
] | [
270,
5
] | python | en | ['en', 'en', 'en'] | True |
get_csv_rows_for_installed | (
old_csv_rows, # type: List[List[str]]
installed, # type: Dict[RecordPath, RecordPath]
changed, # type: Set[RecordPath]
generated, # type: List[str]
lib_dir, # type: str
) |
:param installed: A map from archive RECORD path to installation RECORD
path.
|
:param installed: A map from archive RECORD path to installation RECORD
path.
| def get_csv_rows_for_installed(
old_csv_rows, # type: List[List[str]]
installed, # type: Dict[RecordPath, RecordPath]
changed, # type: Set[RecordPath]
generated, # type: List[str]
lib_dir, # type: str
):
# type: (...) -> List[InstalledCSVRow]
"""
:param installed: A map from archive... | [
"def",
"get_csv_rows_for_installed",
"(",
"old_csv_rows",
",",
"# type: List[List[str]]",
"installed",
",",
"# type: Dict[RecordPath, RecordPath]",
"changed",
",",
"# type: Set[RecordPath]",
"generated",
",",
"# type: List[str]",
"lib_dir",
",",
"# type: str",
")",
":",
"# ty... | [
296,
0
] | [
326,
25
] | python | en | ['en', 'error', 'th'] | False |
get_console_script_specs | (console) |
Given the mapping from entrypoint name to callable, return the relevant
console script specs.
|
Given the mapping from entrypoint name to callable, return the relevant
console script specs.
| def get_console_script_specs(console):
# type: (Dict[str, str]) -> List[str]
"""
Given the mapping from entrypoint name to callable, return the relevant
console script specs.
"""
# Don't mutate caller's version
console = console.copy()
scripts_to_generate = []
# Special case pip an... | [
"def",
"get_console_script_specs",
"(",
"console",
")",
":",
"# type: (Dict[str, str]) -> List[str]",
"# Don't mutate caller's version",
"console",
"=",
"console",
".",
"copy",
"(",
")",
"scripts_to_generate",
"=",
"[",
"]",
"# Special case pip and setuptools to generate versio... | [
329,
0
] | [
412,
30
] | python | en | ['en', 'error', 'th'] | False |
_install_wheel | (
name, # type: str
wheel_zip, # type: ZipFile
wheel_path, # type: str
scheme, # type: Scheme
pycompile=True, # type: bool
warn_script_location=True, # type: bool
direct_url=None, # type: Optional[DirectUrl]
requested=False, # type: bool
) | Install a wheel.
:param name: Name of the project to install
:param wheel_zip: open ZipFile for wheel being installed
:param scheme: Distutils scheme dictating the install directories
:param req_description: String used in place of the requirement, for
logging
:param pycompile: Whether to b... | Install a wheel. | def _install_wheel(
name, # type: str
wheel_zip, # type: ZipFile
wheel_path, # type: str
scheme, # type: Scheme
pycompile=True, # type: bool
warn_script_location=True, # type: bool
direct_url=None, # type: Optional[DirectUrl]
requested=False, # type: bool
):
# type: (...) -> ... | [
"def",
"_install_wheel",
"(",
"name",
",",
"# type: str",
"wheel_zip",
",",
"# type: ZipFile",
"wheel_path",
",",
"# type: str",
"scheme",
",",
"# type: Scheme",
"pycompile",
"=",
"True",
",",
"# type: bool",
"warn_script_location",
"=",
"True",
",",
"# type: bool",
... | [
500,
0
] | [
823,
51
] | python | en | ['en', 'cy', 'en'] | True |
parse_bool | (s, default=False) |
Return the boolean value of an English string or default if it can't be
determined.
|
Return the boolean value of an English string or default if it can't be
determined.
| def parse_bool(s, default=False):
"""
Return the boolean value of an English string or default if it can't be
determined.
"""
if s is None:
return default
return TRUTH.get(s.lower(), default) | [
"def",
"parse_bool",
"(",
"s",
",",
"default",
"=",
"False",
")",
":",
"if",
"s",
"is",
"None",
":",
"return",
"default",
"return",
"TRUTH",
".",
"get",
"(",
"s",
".",
"lower",
"(",
")",
",",
"default",
")"
] | [
23,
0
] | [
30,
40
] | python | en | ['en', 'error', 'th'] | False |
defaults | (default=None) |
Catches any exception thrown by the wrapped function and returns `default`
instead.
Parameters
----------
default : object
The default value to return if the wrapped function throws an exception
|
Catches any exception thrown by the wrapped function and returns `default`
instead. | def defaults(default=None):
"""
Catches any exception thrown by the wrapped function and returns `default`
instead.
Parameters
----------
default : object
The default value to return if the wrapped function throws an exception
"""
def _f(func):
@functools.wraps(func)
... | [
"def",
"defaults",
"(",
"default",
"=",
"None",
")",
":",
"def",
"_f",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"__f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return"... | [
92,
0
] | [
111,
13
] | python | en | ['en', 'error', 'th'] | False |
keys_in | (items, *args) |
Use this utility function to ensure multiple keys are in one or more
dicts. Returns `True` if all keys are present in at least one of the
given dicts, otherwise returns `False`.
:Parameters:
- `items`: Iterable of required keys
- Variable number of subsequent arguments, each one being... |
Use this utility function to ensure multiple keys are in one or more
dicts. Returns `True` if all keys are present in at least one of the
given dicts, otherwise returns `False`. | def keys_in(items, *args):
"""
Use this utility function to ensure multiple keys are in one or more
dicts. Returns `True` if all keys are present in at least one of the
given dicts, otherwise returns `False`.
:Parameters:
- `items`: Iterable of required keys
- Variable number of su... | [
"def",
"keys_in",
"(",
"items",
",",
"*",
"args",
")",
":",
"found",
"=",
"dict",
"(",
"(",
"key",
",",
"False",
")",
"for",
"key",
"in",
"items",
")",
"for",
"d",
"in",
"args",
":",
"for",
"item",
"in",
"items",
":",
"if",
"not",
"found",
"[",... | [
114,
0
] | [
130,
30
] | python | en | ['en', 'error', 'th'] | False |
deprecated | (func, solution) |
Mark a parser or combiner as deprecated, and give a message of how to fix
this. This will emit a warning in the logs when the function is used.
When combined with modifications to conftest, this causes deprecations to
become fatal errors when testing, so they get fixed.
Arguments:
func (f... |
Mark a parser or combiner as deprecated, and give a message of how to fix
this. This will emit a warning in the logs when the function is used.
When combined with modifications to conftest, this causes deprecations to
become fatal errors when testing, so they get fixed. | def deprecated(func, solution):
"""
Mark a parser or combiner as deprecated, and give a message of how to fix
this. This will emit a warning in the logs when the function is used.
When combined with modifications to conftest, this causes deprecations to
become fatal errors when testing, so they get... | [
"def",
"deprecated",
"(",
"func",
",",
"solution",
")",
":",
"def",
"get_name_line",
"(",
"src",
")",
":",
"for",
"line",
"in",
"src",
":",
"if",
"\"@\"",
"not",
"in",
"line",
":",
"return",
"line",
".",
"strip",
"(",
")",
"path",
"=",
"inspect",
"... | [
145,
0
] | [
172,
46
] | python | en | ['en', 'error', 'th'] | False |
parse_keypair_lines | (content, delim='|', kv_sep='=') |
Parses a set of entities, where each entity is a set of key-value pairs
contained all on one line. Each entity is parsed into a dictionary and
added to the list returned from this function.
|
Parses a set of entities, where each entity is a set of key-value pairs
contained all on one line. Each entity is parsed into a dictionary and
added to the list returned from this function.
| def parse_keypair_lines(content, delim='|', kv_sep='='):
"""
Parses a set of entities, where each entity is a set of key-value pairs
contained all on one line. Each entity is parsed into a dictionary and
added to the list returned from this function.
"""
r = []
if content:
for row i... | [
"def",
"parse_keypair_lines",
"(",
"content",
",",
"delim",
"=",
"'|'",
",",
"kv_sep",
"=",
"'='",
")",
":",
"r",
"=",
"[",
"]",
"if",
"content",
":",
"for",
"row",
"in",
"[",
"line",
"for",
"line",
"in",
"content",
"if",
"line",
"]",
":",
"item_di... | [
208,
0
] | [
222,
12
] | python | en | ['en', 'error', 'th'] | False |
rsplit | (_str, seps) |
Splits _str by the first sep in seps that is found from the right side.
Returns a tuple without the separator.
|
Splits _str by the first sep in seps that is found from the right side.
Returns a tuple without the separator.
| def rsplit(_str, seps):
"""
Splits _str by the first sep in seps that is found from the right side.
Returns a tuple without the separator.
"""
for idx, ch in enumerate(reversed(_str)):
if ch in seps:
return _str[0:-idx - 1], _str[-idx:] | [
"def",
"rsplit",
"(",
"_str",
",",
"seps",
")",
":",
"for",
"idx",
",",
"ch",
"in",
"enumerate",
"(",
"reversed",
"(",
"_str",
")",
")",
":",
"if",
"ch",
"in",
"seps",
":",
"return",
"_str",
"[",
"0",
":",
"-",
"idx",
"-",
"1",
"]",
",",
"_st... | [
225,
0
] | [
232,
48
] | python | en | ['en', 'error', 'th'] | False |
case_variants | (*elements) |
For configs which take case-insensitive options, it is necessary to extend the list with
various common case variants (all combinations are not practical). In the future, this should
be removed, when parser filters are made case-insensitive.
Args:
*elements (str): list of elements which need c... |
For configs which take case-insensitive options, it is necessary to extend the list with
various common case variants (all combinations are not practical). In the future, this should
be removed, when parser filters are made case-insensitive. | def case_variants(*elements):
"""
For configs which take case-insensitive options, it is necessary to extend the list with
various common case variants (all combinations are not practical). In the future, this should
be removed, when parser filters are made case-insensitive.
Args:
*elements... | [
"def",
"case_variants",
"(",
"*",
"elements",
")",
":",
"expanded_list",
"=",
"[",
"]",
"for",
"element",
"in",
"elements",
":",
"low",
"=",
"element",
".",
"lower",
"(",
")",
"up",
"=",
"element",
".",
"upper",
"(",
")",
"title",
"=",
"element",
"."... | [
264,
0
] | [
299,
24
] | python | en | ['en', 'error', 'th'] | False |
TestKiraSensor.add_entities | (self, devices) | Mock add devices. | Mock add devices. | def add_entities(self, devices):
"""Mock add devices."""
for device in devices:
self.DEVICES.append(device) | [
"def",
"add_entities",
"(",
"self",
",",
"devices",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"DEVICES",
".",
"append",
"(",
"device",
")"
] | [
21,
4
] | [
24,
39
] | python | en | ['es', 'en', 'en'] | True |
TestKiraSensor.setUp | (self) | Initialize values for this testcase class. | Initialize values for this testcase class. | def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.mock_kira = MagicMock()
self.hass.data[kira.DOMAIN] = {kira.CONF_REMOTE: {}}
self.hass.data[kira.DOMAIN][kira.CONF_REMOTE]["kira"] = self.mock_kira
self.addCleanup... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"mock_kira",
"=",
"MagicMock",
"(",
")",
"self",
".",
"hass",
".",
"data",
"[",
"kira",
".",
"DOMAIN",
"]",
"=",
"{",
"kira",
".",
"C... | [
26,
4
] | [
32,
39
] | 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.