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
_iter_decode_generator
(input, decoder)
Return a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings.
Return a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings.
def _iter_decode_generator(input, decoder): """Return a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings. """ decode = decoder.decode input = iter(input) for chunck in input: output = decode(chunck) if output: assert decod...
[ "def", "_iter_decode_generator", "(", "input", ",", "decoder", ")", ":", "decode", "=", "decoder", ".", "decode", "input", "=", "iter", "(", "input", ")", "for", "chunck", "in", "input", ":", "output", "=", "decode", "(", "chunck", ")", "if", "output", ...
[ 213, 0 ]
[ 242, 20 ]
python
en
['en', 'en', 'en']
True
iter_encode
(input, encoding=UTF8, errors='strict')
“Pull”-based encoder. :param input: An iterable of Unicode strings. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :returns: An iterable o...
“Pull”-based encoder.
def iter_encode(input, encoding=UTF8, errors='strict'): """ “Pull”-based encoder. :param input: An iterable of Unicode strings. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupEr...
[ "def", "iter_encode", "(", "input", ",", "encoding", "=", "UTF8", ",", "errors", "=", "'strict'", ")", ":", "# Fail early if `encoding` is an invalid label.", "encode", "=", "IncrementalEncoder", "(", "encoding", ",", "errors", ")", ".", "encode", "return", "_iter...
[ 245, 0 ]
[ 258, 48 ]
python
en
['en', 'error', 'th']
False
IncrementalDecoder.decode
(self, input, final=False)
Decode one chunk of the input. :param input: A byte string. :param final: Indicate that no more input is available. Must be :obj:`True` if this is the last call. :returns: An Unicode string.
Decode one chunk of the input.
def decode(self, input, final=False): """Decode one chunk of the input. :param input: A byte string. :param final: Indicate that no more input is available. Must be :obj:`True` if this is the last call. :returns: An Unicode string. """ decoder = ...
[ "def", "decode", "(", "self", ",", "input", ",", "final", "=", "False", ")", ":", "decoder", "=", "self", ".", "_decoder", "if", "decoder", "is", "not", "None", ":", "return", "decoder", "(", "input", ",", "final", ")", "input", "=", "self", ".", "...
[ 294, 4 ]
[ 319, 36 ]
python
en
['en', 'en', 'en']
True
TestMedian.test_docstring_examples
(self)
test the examples given in the docstring of ma.median
test the examples given in the docstring of ma.median
def test_docstring_examples(self): "test the examples given in the docstring of ma.median" x = array(np.arange(8), mask=[0]*4 + [1]*4) assert_equal(np.ma.median(x), 1.5) assert_equal(np.ma.median(x).shape, (), "shape mismatch") assert_(type(np.ma.median(x)) is not MaskedArray) ...
[ "def", "test_docstring_examples", "(", "self", ")", ":", "x", "=", "array", "(", "np", ".", "arange", "(", "8", ")", ",", "mask", "=", "[", "0", "]", "*", "4", "+", "[", "1", "]", "*", "4", ")", "assert_equal", "(", "np", ".", "ma", ".", "med...
[ 753, 4 ]
[ 766, 42 ]
python
en
['en', 'en', 'en']
True
test_serialize_text
()
Test serializing a text response.
Test serializing a text response.
def test_serialize_text(): """Test serializing a text response.""" response = web.Response(status=201, text="Hello") assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": "Hello", "headers": {"Content-Type": "text/plain; charset=utf-8"}, }
[ "def", "test_serialize_text", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "text", "=", "\"Hello\"", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":", "...
[ 6, 0 ]
[ 13, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_body_str
()
Test serializing a response with a str as body.
Test serializing a response with a str as body.
def test_serialize_body_str(): """Test serializing a response with a str as body.""" response = web.Response(status=201, body="Hello") assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": "Hello", "headers": {"Content-Length": "5", "Content-Type": "text/plain...
[ "def", "test_serialize_body_str", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "body", "=", "\"Hello\"", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":",...
[ 16, 0 ]
[ 23, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_body_None
()
Test serializing a response with a str as body.
Test serializing a response with a str as body.
def test_serialize_body_None(): """Test serializing a response with a str as body.""" response = web.Response(status=201, body=None) assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": None, "headers": {}, }
[ "def", "test_serialize_body_None", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "body", "=", "None", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":", "...
[ 26, 0 ]
[ 33, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_body_bytes
()
Test serializing a response with a str as body.
Test serializing a response with a str as body.
def test_serialize_body_bytes(): """Test serializing a response with a str as body.""" response = web.Response(status=201, body=b"Hello") assert utils.aiohttp_serialize_response(response) == { "status": 201, "body": "Hello", "headers": {}, }
[ "def", "test_serialize_body_bytes", "(", ")", ":", "response", "=", "web", ".", "Response", "(", "status", "=", "201", ",", "body", "=", "b\"Hello\"", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", "...
[ 36, 0 ]
[ 43, 5 ]
python
en
['en', 'en', 'en']
True
test_serialize_json
()
Test serializing a JSON response.
Test serializing a JSON response.
def test_serialize_json(): """Test serializing a JSON response.""" response = web.json_response({"how": "what"}) assert utils.aiohttp_serialize_response(response) == { "status": 200, "body": '{"how": "what"}', "headers": {"Content-Type": "application/json; charset=utf-8"}, }
[ "def", "test_serialize_json", "(", ")", ":", "response", "=", "web", ".", "json_response", "(", "{", "\"how\"", ":", "\"what\"", "}", ")", "assert", "utils", ".", "aiohttp_serialize_response", "(", "response", ")", "==", "{", "\"status\"", ":", "200", ",", ...
[ 46, 0 ]
[ 53, 5 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up X10 switches over a mochad controller.
Set up X10 switches over a mochad controller.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up X10 switches over a mochad controller.""" mochad_controller = hass.data[DOMAIN] devs = config.get(CONF_DEVICES) add_entities([MochadSwitch(hass, mochad_controller.ctrl, dev) for dev in devs]) return True
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "mochad_controller", "=", "hass", ".", "data", "[", "DOMAIN", "]", "devs", "=", "config", ".", "get", "(", "CONF_DEVICES", ")", "add_ent...
[ 30, 0 ]
[ 35, 15 ]
python
en
['en', 'en', 'en']
True
MochadSwitch.__init__
(self, hass, ctrl, dev)
Initialize a Mochad Switch Device.
Initialize a Mochad Switch Device.
def __init__(self, hass, ctrl, dev): """Initialize a Mochad Switch Device.""" self._controller = ctrl self._address = dev[CONF_ADDRESS] self._name = dev.get(CONF_NAME, f"x10_switch_dev_{self._address}") self._comm_type = dev.get(CONF_COMM_TYPE, "pl") self.switch = device...
[ "def", "__init__", "(", "self", ",", "hass", ",", "ctrl", ",", "dev", ")", ":", "self", ".", "_controller", "=", "ctrl", "self", ".", "_address", "=", "dev", "[", "CONF_ADDRESS", "]", "self", ".", "_name", "=", "dev", ".", "get", "(", "CONF_NAME", ...
[ 41, 4 ]
[ 54, 31 ]
python
en
['en', 'pl', 'pt']
False
MochadSwitch.name
(self)
Get the name of the switch.
Get the name of the switch.
def name(self): """Get the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 57, 4 ]
[ 59, 25 ]
python
en
['en', 'en', 'en']
True
MochadSwitch.turn_on
(self, **kwargs)
Turn the switch on.
Turn the switch on.
def turn_on(self, **kwargs): """Turn the switch on.""" _LOGGER.debug("Reconnect %s:%s", self._controller.server, self._controller.port) with REQ_LOCK: try: # Recycle socket on new command to recover mochad connection self._controller.reconnect() ...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Reconnect %s:%s\"", ",", "self", ".", "_controller", ".", "server", ",", "self", ".", "_controller", ".", "port", ")", "with", "REQ_LOCK", ":", "try", ":...
[ 61, 4 ]
[ 75, 73 ]
python
en
['en', 'en', 'en']
True
MochadSwitch.turn_off
(self, **kwargs)
Turn the switch off.
Turn the switch off.
def turn_off(self, **kwargs): """Turn the switch off.""" _LOGGER.debug("Reconnect %s:%s", self._controller.server, self._controller.port) with REQ_LOCK: try: # Recycle socket on new command to recover mochad connection self._controller.reconnect() ...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Reconnect %s:%s\"", ",", "self", ".", "_controller", ".", "server", ",", "self", ".", "_controller", ".", "port", ")", "with", "REQ_LOCK", ":", "try", "...
[ 77, 4 ]
[ 91, 73 ]
python
en
['en', 'en', 'en']
True
MochadSwitch._get_device_status
(self)
Get the status of the switch from mochad.
Get the status of the switch from mochad.
def _get_device_status(self): """Get the status of the switch from mochad.""" with REQ_LOCK: status = self.switch.get_status().rstrip() return status == "on"
[ "def", "_get_device_status", "(", "self", ")", ":", "with", "REQ_LOCK", ":", "status", "=", "self", ".", "switch", ".", "get_status", "(", ")", ".", "rstrip", "(", ")", "return", "status", "==", "\"on\"" ]
[ 93, 4 ]
[ 97, 29 ]
python
en
['en', 'en', 'en']
True
MochadSwitch.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 100, 4 ]
[ 102, 26 ]
python
en
['en', 'fy', 'en']
True
mock_handlers
()
Mock config flows.
Mock config flows.
def mock_handlers(): """Mock config flows.""" class MockFlowHandler(config_entries.ConfigFlow): """Define a mock flow handler.""" VERSION = 1 with patch.dict(config_entries.HANDLERS, {"comp": MockFlowHandler}): yield
[ "def", "mock_handlers", "(", ")", ":", "class", "MockFlowHandler", "(", "config_entries", ".", "ConfigFlow", ")", ":", "\"\"\"Define a mock flow handler.\"\"\"", "VERSION", "=", "1", "with", "patch", ".", "dict", "(", "config_entries", ".", "HANDLERS", ",", "{", ...
[ 38, 0 ]
[ 47, 13 ]
python
da
['de', 'da', 'en']
False
test_component_warn_slow_setup
(hass)
Warn we log when a component setup takes a long time.
Warn we log when a component setup takes a long time.
async def test_component_warn_slow_setup(hass): """Warn we log when a component setup takes a long time.""" mock_integration(hass, MockModule("test_component1")) with patch.object(hass.loop, "call_later") as mock_call: result = await setup.async_setup_component(hass, "test_component1", {}) a...
[ "async", "def", "test_component_warn_slow_setup", "(", "hass", ")", ":", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"test_component1\"", ")", ")", "with", "patch", ".", "object", "(", "hass", ".", "loop", ",", "\"call_later\"", ")", "as", "mock...
[ 484, 0 ]
[ 498, 40 ]
python
en
['en', 'en', 'en']
True
test_platform_no_warn_slow
(hass)
Do not warn for long entity setup time.
Do not warn for long entity setup time.
async def test_platform_no_warn_slow(hass): """Do not warn for long entity setup time.""" mock_integration( hass, MockModule("test_component1", platform_schema=PLATFORM_SCHEMA) ) with patch.object(hass.loop, "call_later") as mock_call: result = await setup.async_setup_component(hass, "te...
[ "async", "def", "test_platform_no_warn_slow", "(", "hass", ")", ":", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"test_component1\"", ",", "platform_schema", "=", "PLATFORM_SCHEMA", ")", ")", "with", "patch", ".", "object", "(", "hass", ".", "loop...
[ 501, 0 ]
[ 509, 45 ]
python
en
['en', 'en', 'en']
True
test_platform_error_slow_setup
(hass, caplog)
Don't block startup more than SLOW_SETUP_MAX_WAIT.
Don't block startup more than SLOW_SETUP_MAX_WAIT.
async def test_platform_error_slow_setup(hass, caplog): """Don't block startup more than SLOW_SETUP_MAX_WAIT.""" with patch.object(setup, "SLOW_SETUP_MAX_WAIT", 1): called = [] async def async_setup(*args): """Tracking Setup.""" called.append(1) await asynci...
[ "async", "def", "test_platform_error_slow_setup", "(", "hass", ",", "caplog", ")", ":", "with", "patch", ".", "object", "(", "setup", ",", "\"SLOW_SETUP_MAX_WAIT\"", ",", "1", ")", ":", "called", "=", "[", "]", "async", "def", "async_setup", "(", "*", "arg...
[ 512, 0 ]
[ 527, 79 ]
python
en
['en', 'jv', 'en']
True
test_when_setup_already_loaded
(hass)
Test when setup.
Test when setup.
async def test_when_setup_already_loaded(hass): """Test when setup.""" calls = [] async def mock_callback(hass, component): """Mock callback.""" calls.append(component) setup.async_when_setup(hass, "test", mock_callback) await hass.async_block_till_done() assert calls == [] ...
[ "async", "def", "test_when_setup_already_loaded", "(", "hass", ")", ":", "calls", "=", "[", "]", "async", "def", "mock_callback", "(", "hass", ",", "component", ")", ":", "\"\"\"Mock callback.\"\"\"", "calls", ".", "append", "(", "component", ")", "setup", "."...
[ 530, 0 ]
[ 555, 36 ]
python
en
['en', 'ht', 'en']
True
test_async_when_setup_or_start_already_loaded
(hass)
Test when setup or start.
Test when setup or start.
async def test_async_when_setup_or_start_already_loaded(hass): """Test when setup or start.""" calls = [] async def mock_callback(hass, component): """Mock callback.""" calls.append(component) setup.async_when_setup_or_start(hass, "test", mock_callback) await hass.async_block_till_...
[ "async", "def", "test_async_when_setup_or_start_already_loaded", "(", "hass", ")", ":", "calls", "=", "[", "]", "async", "def", "mock_callback", "(", "hass", ",", "component", ")", ":", "\"\"\"Mock callback.\"\"\"", "calls", ".", "append", "(", "component", ")", ...
[ 558, 0 ]
[ 590, 50 ]
python
en
['en', 'no', 'en']
True
test_setup_import_blows_up
(hass)
Test that we handle it correctly when importing integration blows up.
Test that we handle it correctly when importing integration blows up.
async def test_setup_import_blows_up(hass): """Test that we handle it correctly when importing integration blows up.""" with patch( "homeassistant.loader.Integration.get_component", side_effect=ValueError ): assert not await setup.async_setup_component(hass, "sun", {})
[ "async", "def", "test_setup_import_blows_up", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.loader.Integration.get_component\"", ",", "side_effect", "=", "ValueError", ")", ":", "assert", "not", "await", "setup", ".", "async_setup_component", "(", "has...
[ 593, 0 ]
[ 598, 69 ]
python
en
['en', 'en', 'en']
True
test_parallel_entry_setup
(hass)
Test config entries are set up in parallel.
Test config entries are set up in parallel.
async def test_parallel_entry_setup(hass): """Test config entries are set up in parallel.""" MockConfigEntry(domain="comp", data={"value": 1}).add_to_hass(hass) MockConfigEntry(domain="comp", data={"value": 2}).add_to_hass(hass) calls = [] async def mock_async_setup_entry(hass, entry): """...
[ "async", "def", "test_parallel_entry_setup", "(", "hass", ")", ":", "MockConfigEntry", "(", "domain", "=", "\"comp\"", ",", "data", "=", "{", "\"value\"", ":", "1", "}", ")", ".", "add_to_hass", "(", "hass", ")", "MockConfigEntry", "(", "domain", "=", "\"c...
[ 601, 0 ]
[ 625, 32 ]
python
en
['en', 'en', 'en']
True
test_integration_disabled
(hass, caplog)
Test we can disable an integration.
Test we can disable an integration.
async def test_integration_disabled(hass, caplog): """Test we can disable an integration.""" disabled_reason = "Dependency contains code that breaks Home Assistant" mock_integration( hass, MockModule("test_component1", partial_manifest={"disabled": disabled_reason}), ) result = await...
[ "async", "def", "test_integration_disabled", "(", "hass", ",", "caplog", ")", ":", "disabled_reason", "=", "\"Dependency contains code that breaks Home Assistant\"", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"test_component1\"", ",", "partial_manifest", "="...
[ 628, 0 ]
[ 637, 41 ]
python
en
['br', 'en', 'en']
True
test_async_get_loaded_integrations
(hass)
Test we can enumerate loaded integations.
Test we can enumerate loaded integations.
async def test_async_get_loaded_integrations(hass): """Test we can enumerate loaded integations.""" hass.config.components.add("notbase") hass.config.components.add("switch") hass.config.components.add("notbase.switch") hass.config.components.add("myintegration") hass.config.components.add("devi...
[ "async", "def", "test_async_get_loaded_integrations", "(", "hass", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"notbase\"", ")", "hass", ".", "config", ".", "components", ".", "add", "(", "\"switch\"", ")", "hass", ".", "config", ...
[ 640, 0 ]
[ 655, 5 ]
python
en
['en', 'en', 'en']
True
test_integration_no_setup
(hass, caplog)
Test we fail integration setup without setup functions.
Test we fail integration setup without setup functions.
async def test_integration_no_setup(hass, caplog): """Test we fail integration setup without setup functions.""" mock_integration( hass, MockModule("test_integration_without_setup", setup=False), ) result = await setup.async_setup_component( hass, "test_integration_without_setup"...
[ "async", "def", "test_integration_no_setup", "(", "hass", ",", "caplog", ")", ":", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"test_integration_without_setup\"", ",", "setup", "=", "False", ")", ",", ")", "result", "=", "await", "setup", ".", "...
[ 658, 0 ]
[ 668, 75 ]
python
en
['en', 'en', 'en']
True
test_integration_only_setup_entry
(hass)
Test we have an integration with only a setup entry method.
Test we have an integration with only a setup entry method.
async def test_integration_only_setup_entry(hass): """Test we have an integration with only a setup entry method.""" mock_integration( hass, MockModule( "test_integration_only_entry", setup=False, async_setup_entry=AsyncMock(return_value=True), ), ...
[ "async", "def", "test_integration_only_setup_entry", "(", "hass", ")", ":", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"test_integration_only_entry\"", ",", "setup", "=", "False", ",", "async_setup_entry", "=", "AsyncMock", "(", "return_value", "=", ...
[ 671, 0 ]
[ 681, 85 ]
python
en
['en', 'en', 'en']
True
test_async_start_setup
(hass)
Test setup started context manager keeps track of setup times.
Test setup started context manager keeps track of setup times.
async def test_async_start_setup(hass): """Test setup started context manager keeps track of setup times.""" with setup.async_start_setup(hass, ["august"]): assert isinstance( hass.data[setup.DATA_SETUP_STARTED]["august"], datetime.datetime ) with setup.async_start_setup(hass...
[ "async", "def", "test_async_start_setup", "(", "hass", ")", ":", "with", "setup", ".", "async_start_setup", "(", "hass", ",", "[", "\"august\"", "]", ")", ":", "assert", "isinstance", "(", "hass", ".", "data", "[", "setup", ".", "DATA_SETUP_STARTED", "]", ...
[ 684, 0 ]
[ 697, 61 ]
python
en
['en', 'da', 'en']
True
test_async_start_setup_platforms
(hass)
Test setup started context manager keeps track of setup times for platforms.
Test setup started context manager keeps track of setup times for platforms.
async def test_async_start_setup_platforms(hass): """Test setup started context manager keeps track of setup times for platforms.""" with setup.async_start_setup(hass, ["sensor.august"]): assert isinstance( hass.data[setup.DATA_SETUP_STARTED]["sensor.august"], datetime.datetime ) ...
[ "async", "def", "test_async_start_setup_platforms", "(", "hass", ")", ":", "with", "setup", ".", "async_start_setup", "(", "hass", ",", "[", "\"sensor.august\"", "]", ")", ":", "assert", "isinstance", "(", "hass", ".", "data", "[", "setup", ".", "DATA_SETUP_ST...
[ 700, 0 ]
[ 709, 59 ]
python
en
['en', 'da', 'en']
True
TestSetup.setup_method
(self, method)
Set up the test.
Set up the test.
def setup_method(self, method): """Set up the test.""" self.hass = get_test_home_assistant()
[ "def", "setup_method", "(", "self", ",", "method", ")", ":", "self", ".", "hass", "=", "get_test_home_assistant", "(", ")" ]
[ 57, 4 ]
[ 59, 45 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_validate_component_config
(self)
Test validating component configuration.
Test validating component configuration.
def test_validate_component_config(self): """Test validating component configuration.""" config_schema = vol.Schema({"comp_conf": {"hello": str}}, required=True) mock_integration( self.hass, MockModule("comp_conf", config_schema=config_schema) ) with assert_setup_com...
[ "def", "test_validate_component_config", "(", "self", ")", ":", "config_schema", "=", "vol", ".", "Schema", "(", "{", "\"comp_conf\"", ":", "{", "\"hello\"", ":", "str", "}", "}", ",", "required", "=", "True", ")", "mock_integration", "(", "self", ".", "ha...
[ 65, 4 ]
[ 101, 13 ]
python
en
['nl', 'en', 'en']
True
TestSetup.test_validate_platform_config
(self, caplog)
Test validating platform configuration.
Test validating platform configuration.
def test_validate_platform_config(self, caplog): """Test validating platform configuration.""" platform_schema = PLATFORM_SCHEMA.extend({"hello": str}) platform_schema_base = PLATFORM_SCHEMA_BASE.extend({}) mock_integration( self.hass, MockModule("platform_conf", ...
[ "def", "test_validate_platform_config", "(", "self", ",", "caplog", ")", ":", "platform_schema", "=", "PLATFORM_SCHEMA", ".", "extend", "(", "{", "\"hello\"", ":", "str", "}", ")", "platform_schema_base", "=", "PLATFORM_SCHEMA_BASE", ".", "extend", "(", "{", "}"...
[ 103, 4 ]
[ 159, 46 ]
python
en
['en', 'da', 'en']
True
TestSetup.test_validate_platform_config_2
(self, caplog)
Test component PLATFORM_SCHEMA_BASE prio over PLATFORM_SCHEMA.
Test component PLATFORM_SCHEMA_BASE prio over PLATFORM_SCHEMA.
def test_validate_platform_config_2(self, caplog): """Test component PLATFORM_SCHEMA_BASE prio over PLATFORM_SCHEMA.""" platform_schema = PLATFORM_SCHEMA.extend({"hello": str}) platform_schema_base = PLATFORM_SCHEMA_BASE.extend({"hello": "world"}) mock_integration( self.hass,...
[ "def", "test_validate_platform_config_2", "(", "self", ",", "caplog", ")", ":", "platform_schema", "=", "PLATFORM_SCHEMA", ".", "extend", "(", "{", "\"hello\"", ":", "str", "}", ")", "platform_schema_base", "=", "PLATFORM_SCHEMA_BASE", ".", "extend", "(", "{", "...
[ 161, 4 ]
[ 190, 13 ]
python
de
['es', 'de', 'nl']
False
TestSetup.test_validate_platform_config_3
(self, caplog)
Test fallback to component PLATFORM_SCHEMA.
Test fallback to component PLATFORM_SCHEMA.
def test_validate_platform_config_3(self, caplog): """Test fallback to component PLATFORM_SCHEMA.""" component_schema = PLATFORM_SCHEMA_BASE.extend({"hello": str}) platform_schema = PLATFORM_SCHEMA.extend({"cheers": str, "hello": "world"}) mock_integration( self.hass, MockMod...
[ "def", "test_validate_platform_config_3", "(", "self", ",", "caplog", ")", ":", "component_schema", "=", "PLATFORM_SCHEMA_BASE", ".", "extend", "(", "{", "\"hello\"", ":", "str", "}", ")", "platform_schema", "=", "PLATFORM_SCHEMA", ".", "extend", "(", "{", "\"ch...
[ 192, 4 ]
[ 216, 13 ]
python
en
['en', 'de', 'en']
True
TestSetup.test_validate_platform_config_4
(self)
Test entity_namespace in PLATFORM_SCHEMA.
Test entity_namespace in PLATFORM_SCHEMA.
def test_validate_platform_config_4(self): """Test entity_namespace in PLATFORM_SCHEMA.""" component_schema = PLATFORM_SCHEMA_BASE platform_schema = PLATFORM_SCHEMA mock_integration( self.hass, MockModule("platform_conf", platform_schema_base=component_schema), ...
[ "def", "test_validate_platform_config_4", "(", "self", ")", ":", "component_schema", "=", "PLATFORM_SCHEMA_BASE", "platform_schema", "=", "PLATFORM_SCHEMA", "mock_integration", "(", "self", ".", "hass", ",", "MockModule", "(", "\"platform_conf\"", ",", "platform_schema_ba...
[ 218, 4 ]
[ 247, 59 ]
python
de
['nl', 'de', 'it']
False
TestSetup.test_component_not_found
(self)
setup_component should not crash if component doesn't exist.
setup_component should not crash if component doesn't exist.
def test_component_not_found(self): """setup_component should not crash if component doesn't exist.""" assert setup.setup_component(self.hass, "non_existing", {}) is False
[ "def", "test_component_not_found", "(", "self", ")", ":", "assert", "setup", ".", "setup_component", "(", "self", ".", "hass", ",", "\"non_existing\"", ",", "{", "}", ")", "is", "False" ]
[ 249, 4 ]
[ 251, 76 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_component_not_double_initialized
(self)
Test we do not set up a component twice.
Test we do not set up a component twice.
def test_component_not_double_initialized(self): """Test we do not set up a component twice.""" mock_setup = Mock(return_value=True) mock_integration(self.hass, MockModule("comp", setup=mock_setup)) assert setup.setup_component(self.hass, "comp", {}) assert mock_setup.called ...
[ "def", "test_component_not_double_initialized", "(", "self", ")", ":", "mock_setup", "=", "Mock", "(", "return_value", "=", "True", ")", "mock_integration", "(", "self", ".", "hass", ",", "MockModule", "(", "\"comp\"", ",", "setup", "=", "mock_setup", ")", ")"...
[ 253, 4 ]
[ 265, 36 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_component_not_installed_if_requirement_fails
(self, mock_install)
Component setup should fail if requirement can't install.
Component setup should fail if requirement can't install.
def test_component_not_installed_if_requirement_fails(self, mock_install): """Component setup should fail if requirement can't install.""" self.hass.config.skip_pip = False mock_integration(self.hass, MockModule("comp", requirements=["package==0.0.1"])) assert not setup.setup_component(...
[ "def", "test_component_not_installed_if_requirement_fails", "(", "self", ",", "mock_install", ")", ":", "self", ".", "hass", ".", "config", ".", "skip_pip", "=", "False", "mock_integration", "(", "self", ".", "hass", ",", "MockModule", "(", "\"comp\"", ",", "req...
[ 268, 4 ]
[ 274, 56 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_component_not_setup_twice_if_loaded_during_other_setup
(self)
Test component setup while waiting for lock is not set up twice.
Test component setup while waiting for lock is not set up twice.
def test_component_not_setup_twice_if_loaded_during_other_setup(self): """Test component setup while waiting for lock is not set up twice.""" result = [] async def async_setup(hass, config): """Tracking Setup.""" result.append(1) mock_integration(self.hass, Mock...
[ "def", "test_component_not_setup_twice_if_loaded_during_other_setup", "(", "self", ")", ":", "result", "=", "[", "]", "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "\"\"\"Tracking Setup.\"\"\"", "result", ".", "append", "(", "1", ")", "mock_...
[ 276, 4 ]
[ 296, 31 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_component_not_setup_missing_dependencies
(self)
Test we do not set up a component if not all dependencies loaded.
Test we do not set up a component if not all dependencies loaded.
def test_component_not_setup_missing_dependencies(self): """Test we do not set up a component if not all dependencies loaded.""" deps = ["maybe_existing"] mock_integration(self.hass, MockModule("comp", dependencies=deps)) assert not setup.setup_component(self.hass, "comp", {}) a...
[ "def", "test_component_not_setup_missing_dependencies", "(", "self", ")", ":", "deps", "=", "[", "\"maybe_existing\"", "]", "mock_integration", "(", "self", ".", "hass", ",", "MockModule", "(", "\"comp\"", ",", "dependencies", "=", "deps", ")", ")", "assert", "n...
[ 298, 4 ]
[ 311, 60 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_component_failing_setup
(self)
Test component that fails setup.
Test component that fails setup.
def test_component_failing_setup(self): """Test component that fails setup.""" mock_integration( self.hass, MockModule("comp", setup=lambda hass, config: False) ) assert not setup.setup_component(self.hass, "comp", {}) assert "comp" not in self.hass.config.components
[ "def", "test_component_failing_setup", "(", "self", ")", ":", "mock_integration", "(", "self", ".", "hass", ",", "MockModule", "(", "\"comp\"", ",", "setup", "=", "lambda", "hass", ",", "config", ":", "False", ")", ")", "assert", "not", "setup", ".", "setu...
[ 313, 4 ]
[ 320, 56 ]
python
en
['en', 'fr', 'en']
True
TestSetup.test_component_exception_setup
(self)
Test component that raises exception during setup.
Test component that raises exception during setup.
def test_component_exception_setup(self): """Test component that raises exception during setup.""" def exception_setup(hass, config): """Raise exception.""" raise Exception("fail!") mock_integration(self.hass, MockModule("comp", setup=exception_setup)) assert n...
[ "def", "test_component_exception_setup", "(", "self", ")", ":", "def", "exception_setup", "(", "hass", ",", "config", ")", ":", "\"\"\"Raise exception.\"\"\"", "raise", "Exception", "(", "\"fail!\"", ")", "mock_integration", "(", "self", ".", "hass", ",", "MockMod...
[ 322, 4 ]
[ 332, 56 ]
python
en
['en', 'fr', 'en']
True
TestSetup.test_component_setup_with_validation_and_dependency
(self)
Test all config is passed to dependencies.
Test all config is passed to dependencies.
def test_component_setup_with_validation_and_dependency(self): """Test all config is passed to dependencies.""" def config_check_setup(hass, config): """Test that config is passed in.""" if config.get("comp_a", {}).get("valid", False): return True rai...
[ "def", "test_component_setup_with_validation_and_dependency", "(", "self", ")", ":", "def", "config_check_setup", "(", "hass", ",", "config", ")", ":", "\"\"\"Test that config is passed in.\"\"\"", "if", "config", ".", "get", "(", "\"comp_a\"", ",", "{", "}", ")", "...
[ 334, 4 ]
[ 359, 54 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_platform_specific_config_validation
(self)
Test platform that specifies config.
Test platform that specifies config.
def test_platform_specific_config_validation(self): """Test platform that specifies config.""" platform_schema = PLATFORM_SCHEMA.extend( {"valid": True}, extra=vol.PREVENT_EXTRA ) mock_setup = Mock(spec_set=True) mock_entity_platform( self.hass, ...
[ "def", "test_platform_specific_config_validation", "(", "self", ")", ":", "platform_schema", "=", "PLATFORM_SCHEMA", ".", "extend", "(", "{", "\"valid\"", ":", "True", "}", ",", "extra", "=", "vol", ".", "PREVENT_EXTRA", ")", "mock_setup", "=", "Mock", "(", "s...
[ 361, 4 ]
[ 412, 45 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_disable_component_if_invalid_return
(self)
Test disabling component if invalid return.
Test disabling component if invalid return.
def test_disable_component_if_invalid_return(self): """Test disabling component if invalid return.""" mock_integration( self.hass, MockModule("disabled_component", setup=lambda hass, config: None) ) assert not setup.setup_component(self.hass, "disabled_component", {}) ...
[ "def", "test_disable_component_if_invalid_return", "(", "self", ")", ":", "mock_integration", "(", "self", ".", "hass", ",", "MockModule", "(", "\"disabled_component\"", ",", "setup", "=", "lambda", "hass", ",", "config", ":", "None", ")", ")", "assert", "not", ...
[ 414, 4 ]
[ 438, 66 ]
python
en
['en', 'en', 'en']
True
TestSetup.test_all_work_done_before_start
(self)
Test all init work done till start.
Test all init work done till start.
def test_all_work_done_before_start(self): """Test all init work done till start.""" call_order = [] async def component1_setup(hass, config): """Set up mock component.""" await discovery.async_discover( hass, "test_component2", {}, "test_component2", {} ...
[ "def", "test_all_work_done_before_start", "(", "self", ")", ":", "call_order", "=", "[", "]", "async", "def", "component1_setup", "(", "hass", ",", "config", ")", ":", "\"\"\"Set up mock component.\"\"\"", "await", "discovery", ".", "async_discover", "(", "hass", ...
[ 440, 4 ]
[ 481, 38 ]
python
en
['en', 'en', 'en']
True
HangoutsCredentials.__init__
(self, email, password, pin=None, auth_code=None)
Google account credentials. :param email: Google account email address. :param password: Google account password. :param pin: Google account verification code.
Google account credentials.
def __init__(self, email, password, pin=None, auth_code=None): """Google account credentials. :param email: Google account email address. :param password: Google account password. :param pin: Google account verification code. """ self._email = email self._passwor...
[ "def", "__init__", "(", "self", ",", "email", ",", "password", ",", "pin", "=", "None", ",", "auth_code", "=", "None", ")", ":", "self", ".", "_email", "=", "email", "self", ".", "_password", "=", "password", "self", ".", "_pin", "=", "pin", "self", ...
[ 15, 4 ]
[ 25, 35 ]
python
en
['en', 'ca', 'en']
True
HangoutsCredentials.get_email
(self)
Return email. :return: Google account email address.
Return email.
def get_email(self): """Return email. :return: Google account email address. """ return self._email
[ "def", "get_email", "(", "self", ")", ":", "return", "self", ".", "_email" ]
[ 27, 4 ]
[ 32, 26 ]
python
en
['es', 'en', 'en']
False
HangoutsCredentials.get_password
(self)
Return password. :return: Google account password.
Return password.
def get_password(self): """Return password. :return: Google account password. """ return self._password
[ "def", "get_password", "(", "self", ")", ":", "return", "self", ".", "_password" ]
[ 34, 4 ]
[ 39, 29 ]
python
en
['fr', 'la', 'en']
False
HangoutsCredentials.get_verification_code
(self)
Return the verification code. :return: Google account verification code.
Return the verification code.
def get_verification_code(self): """Return the verification code. :return: Google account verification code. """ if self._pin is None: raise Google2FAError() return self._pin
[ "def", "get_verification_code", "(", "self", ")", ":", "if", "self", ".", "_pin", "is", "None", ":", "raise", "Google2FAError", "(", ")", "return", "self", ".", "_pin" ]
[ 41, 4 ]
[ 48, 24 ]
python
en
['en', 'sn', 'en']
True
HangoutsCredentials.set_verification_code
(self, pin)
Set the verification code. :param pin: Google account verification code.
Set the verification code.
def set_verification_code(self, pin): """Set the verification code. :param pin: Google account verification code. """ self._pin = pin
[ "def", "set_verification_code", "(", "self", ",", "pin", ")", ":", "self", ".", "_pin", "=", "pin" ]
[ 50, 4 ]
[ 55, 23 ]
python
en
['en', 'fr', 'en']
True
HangoutsCredentials.get_authorization_code
(self)
Return the oauth authorization code. :return: Google oauth code.
Return the oauth authorization code.
def get_authorization_code(self): """Return the oauth authorization code. :return: Google oauth code. """ return self._auth_code
[ "def", "get_authorization_code", "(", "self", ")", ":", "return", "self", ".", "_auth_code" ]
[ 57, 4 ]
[ 62, 30 ]
python
en
['en', 'sn', 'en']
True
HangoutsCredentials.set_authorization_code
(self, code)
Set the google oauth authorization code. :param code: Oauth code returned after authentication with google.
Set the google oauth authorization code.
def set_authorization_code(self, code): """Set the google oauth authorization code. :param code: Oauth code returned after authentication with google. """ self._auth_code = code
[ "def", "set_authorization_code", "(", "self", ",", "code", ")", ":", "self", ".", "_auth_code", "=", "code" ]
[ 64, 4 ]
[ 69, 30 ]
python
en
['en', 'en', 'en']
True
HangoutsRefreshToken.__init__
(self, token)
Memory-based cache for refresh token. :param token: Initial refresh token.
Memory-based cache for refresh token.
def __init__(self, token): """Memory-based cache for refresh token. :param token: Initial refresh token. """ super().__init__("") self._token = token
[ "def", "__init__", "(", "self", ",", "token", ")", ":", "super", "(", ")", ".", "__init__", "(", "\"\"", ")", "self", ".", "_token", "=", "token" ]
[ 75, 4 ]
[ 81, 27 ]
python
en
['en', 'no', 'en']
True
HangoutsRefreshToken.get
(self)
Get cached refresh token. :return: Cached refresh token.
Get cached refresh token.
def get(self): """Get cached refresh token. :return: Cached refresh token. """ return self._token
[ "def", "get", "(", "self", ")", ":", "return", "self", ".", "_token" ]
[ 83, 4 ]
[ 88, 26 ]
python
en
['en', 'en', 'en']
True
HangoutsRefreshToken.set
(self, refresh_token)
Cache a refresh token. :param refresh_token: Refresh token to cache.
Cache a refresh token.
def set(self, refresh_token): """Cache a refresh token. :param refresh_token: Refresh token to cache. """ self._token = refresh_token
[ "def", "set", "(", "self", ",", "refresh_token", ")", ":", "self", ".", "_token", "=", "refresh_token" ]
[ 90, 4 ]
[ 95, 35 ]
python
en
['en', 'gl', 'en']
True
session
(hass)
Return aioclient session.
Return aioclient session.
async def session(hass): """Return aioclient session.""" return hass.helpers.aiohttp_client.async_get_clientsession()
[ "async", "def", "session", "(", "hass", ")", ":", "return", "hass", ".", "helpers", ".", "aiohttp_client", ".", "async_get_clientsession", "(", ")" ]
[ 27, 0 ]
[ 29, 64 ]
python
en
['en', 'fr', 'en']
True
raising_session
(loop)
Return an aioclient session that only fails.
Return an aioclient session that only fails.
async def raising_session(loop): """Return an aioclient session that only fails.""" return Mock(get=Mock(side_effect=aiohttp.ClientError))
[ "async", "def", "raising_session", "(", "loop", ")", ":", "return", "Mock", "(", "get", "=", "Mock", "(", "side_effect", "=", "aiohttp", ".", "ClientError", ")", ")" ]
[ 33, 0 ]
[ 35, 58 ]
python
en
['en', 'en', 'en']
True
test_get_distance_to_same_place
()
Test getting the distance.
Test getting the distance.
def test_get_distance_to_same_place(): """Test getting the distance.""" meters = location_util.distance( COORDINATES_PARIS[0], COORDINATES_PARIS[1], COORDINATES_PARIS[0], COORDINATES_PARIS[1], ) assert meters == 0
[ "def", "test_get_distance_to_same_place", "(", ")", ":", "meters", "=", "location_util", ".", "distance", "(", "COORDINATES_PARIS", "[", "0", "]", ",", "COORDINATES_PARIS", "[", "1", "]", ",", "COORDINATES_PARIS", "[", "0", "]", ",", "COORDINATES_PARIS", "[", ...
[ 38, 0 ]
[ 47, 22 ]
python
en
['en', 'en', 'en']
True
test_get_distance
()
Test getting the distance.
Test getting the distance.
def test_get_distance(): """Test getting the distance.""" meters = location_util.distance( COORDINATES_PARIS[0], COORDINATES_PARIS[1], COORDINATES_NEW_YORK[0], COORDINATES_NEW_YORK[1], ) assert meters / 1000 - DISTANCE_KM < 0.01
[ "def", "test_get_distance", "(", ")", ":", "meters", "=", "location_util", ".", "distance", "(", "COORDINATES_PARIS", "[", "0", "]", ",", "COORDINATES_PARIS", "[", "1", "]", ",", "COORDINATES_NEW_YORK", "[", "0", "]", ",", "COORDINATES_NEW_YORK", "[", "1", "...
[ 50, 0 ]
[ 59, 45 ]
python
en
['en', 'en', 'en']
True
test_get_kilometers
()
Test getting the distance between given coordinates in km.
Test getting the distance between given coordinates in km.
def test_get_kilometers(): """Test getting the distance between given coordinates in km.""" kilometers = location_util.vincenty(COORDINATES_PARIS, COORDINATES_NEW_YORK) assert round(kilometers, 2) == DISTANCE_KM
[ "def", "test_get_kilometers", "(", ")", ":", "kilometers", "=", "location_util", ".", "vincenty", "(", "COORDINATES_PARIS", ",", "COORDINATES_NEW_YORK", ")", "assert", "round", "(", "kilometers", ",", "2", ")", "==", "DISTANCE_KM" ]
[ 62, 0 ]
[ 65, 46 ]
python
en
['en', 'en', 'en']
True
test_get_miles
()
Test getting the distance between given coordinates in miles.
Test getting the distance between given coordinates in miles.
def test_get_miles(): """Test getting the distance between given coordinates in miles.""" miles = location_util.vincenty(COORDINATES_PARIS, COORDINATES_NEW_YORK, miles=True) assert round(miles, 2) == DISTANCE_MILES
[ "def", "test_get_miles", "(", ")", ":", "miles", "=", "location_util", ".", "vincenty", "(", "COORDINATES_PARIS", ",", "COORDINATES_NEW_YORK", ",", "miles", "=", "True", ")", "assert", "round", "(", "miles", ",", "2", ")", "==", "DISTANCE_MILES" ]
[ 68, 0 ]
[ 71, 44 ]
python
en
['en', 'en', 'en']
True
test_detect_location_info_whoami
(aioclient_mock, session)
Test detect location info using whoami.home-assistant.io.
Test detect location info using whoami.home-assistant.io.
async def test_detect_location_info_whoami(aioclient_mock, session): """Test detect location info using whoami.home-assistant.io.""" aioclient_mock.get(location_util.WHOAMI_URL, text=load_fixture("whoami.json")) with patch("homeassistant.util.location.HA_VERSION", "1.0"): info = await location_util...
[ "async", "def", "test_detect_location_info_whoami", "(", "aioclient_mock", ",", "session", ")", ":", "aioclient_mock", ".", "get", "(", "location_util", ".", "WHOAMI_URL", ",", "text", "=", "load_fixture", "(", "\"whoami.json\"", ")", ")", "with", "patch", "(", ...
[ 74, 0 ]
[ 93, 26 ]
python
en
['en', 'en', 'en']
True
test_dev_url
(aioclient_mock, session)
Test usage of dev URL.
Test usage of dev URL.
async def test_dev_url(aioclient_mock, session): """Test usage of dev URL.""" aioclient_mock.get(location_util.WHOAMI_URL_DEV, text=load_fixture("whoami.json")) with patch("homeassistant.util.location.HA_VERSION", "1.0.dev0"): info = await location_util.async_detect_location_info(session, _test_real...
[ "async", "def", "test_dev_url", "(", "aioclient_mock", ",", "session", ")", ":", "aioclient_mock", ".", "get", "(", "location_util", ".", "WHOAMI_URL_DEV", ",", "text", "=", "load_fixture", "(", "\"whoami.json\"", ")", ")", "with", "patch", "(", "\"homeassistant...
[ 96, 0 ]
[ 104, 33 ]
python
en
['en', 'cy', 'en']
True
test_whoami_query_raises
(raising_session)
Test whoami query when the request to API fails.
Test whoami query when the request to API fails.
async def test_whoami_query_raises(raising_session): """Test whoami query when the request to API fails.""" info = await location_util._get_whoami(raising_session) assert info is None
[ "async", "def", "test_whoami_query_raises", "(", "raising_session", ")", ":", "info", "=", "await", "location_util", ".", "_get_whoami", "(", "raising_session", ")", "assert", "info", "is", "None" ]
[ 107, 0 ]
[ 110, 23 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up a sensor for a raincloud device.
Set up a sensor for a raincloud device.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up a sensor for a raincloud device.""" raincloud = hass.data[DATA_RAINCLOUD].data sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): if sensor_type == "status": sensors.append(RainCloudBi...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "raincloud", "=", "hass", ".", "data", "[", "DATA_RAINCLOUD", "]", ".", "data", "sensors", "=", "[", "]", "for", "sensor_type", "in", ...
[ 22, 0 ]
[ 40, 15 ]
python
en
['en', 'ca', 'en']
True
RainCloudBinarySensor.is_on
(self)
Return true if the binary sensor is on.
Return true if the binary sensor is on.
def is_on(self): """Return true if the binary sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 47, 4 ]
[ 49, 26 ]
python
en
['en', 'fy', 'en']
True
RainCloudBinarySensor.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" _LOGGER.debug("Updating RainCloud sensor: %s", self._name) self._state = getattr(self.data, self._sensor_type) if self._sensor_type == "status": self._state = self._state == "Online"
[ "def", "update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating RainCloud sensor: %s\"", ",", "self", ".", "_name", ")", "self", ".", "_state", "=", "getattr", "(", "self", ".", "data", ",", "self", ".", "_sensor_type", ")", "if", "self...
[ 51, 4 ]
[ 56, 49 ]
python
en
['en', 'en', 'en']
True
RainCloudBinarySensor.icon
(self)
Return the icon of this device.
Return the icon of this device.
def icon(self): """Return the icon of this device.""" if self._sensor_type == "is_watering": return "mdi:water" if self.is_on else "mdi:water-off" if self._sensor_type == "status": return "mdi:pipe" if self.is_on else "mdi:pipe-disconnected" return ICON_MAP.get(se...
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_sensor_type", "==", "\"is_watering\"", ":", "return", "\"mdi:water\"", "if", "self", ".", "is_on", "else", "\"mdi:water-off\"", "if", "self", ".", "_sensor_type", "==", "\"status\"", ":", "return", "...
[ 59, 4 ]
[ 65, 46 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.__init__
(self, file=None, files=None, local_vars_configuration=None)
FileSchemaTestClass - a model defined in OpenAPI
FileSchemaTestClass - a model defined in OpenAPI
def __init__(self, file=None, files=None, local_vars_configuration=None): # noqa: E501 """FileSchemaTestClass - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() self.local_vars_configuration ...
[ "def", "__init__", "(", "self", ",", "file", "=", "None", ",", "files", "=", "None", ",", "local_vars_configuration", "=", "None", ")", ":", "# noqa: E501", "# noqa: E501", "if", "local_vars_configuration", "is", "None", ":", "local_vars_configuration", "=", "Co...
[ 44, 4 ]
[ 57, 30 ]
python
en
['en', 'fy', 'en']
True
FileSchemaTestClass.file
(self)
Gets the file of this FileSchemaTestClass. # noqa: E501 :return: The file of this FileSchemaTestClass. # noqa: E501 :rtype: File
Gets the file of this FileSchemaTestClass. # noqa: E501
def file(self): """Gets the file of this FileSchemaTestClass. # noqa: E501 :return: The file of this FileSchemaTestClass. # noqa: E501 :rtype: File """ return self._file
[ "def", "file", "(", "self", ")", ":", "return", "self", ".", "_file" ]
[ 60, 4 ]
[ 67, 25 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.file
(self, file)
Sets the file of this FileSchemaTestClass. :param file: The file of this FileSchemaTestClass. # noqa: E501 :type file: File
Sets the file of this FileSchemaTestClass.
def file(self, file): """Sets the file of this FileSchemaTestClass. :param file: The file of this FileSchemaTestClass. # noqa: E501 :type file: File """ self._file = file
[ "def", "file", "(", "self", ",", "file", ")", ":", "self", ".", "_file", "=", "file" ]
[ 70, 4 ]
[ 78, 25 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.files
(self)
Gets the files of this FileSchemaTestClass. # noqa: E501 :return: The files of this FileSchemaTestClass. # noqa: E501 :rtype: list[File]
Gets the files of this FileSchemaTestClass. # noqa: E501
def files(self): """Gets the files of this FileSchemaTestClass. # noqa: E501 :return: The files of this FileSchemaTestClass. # noqa: E501 :rtype: list[File] """ return self._files
[ "def", "files", "(", "self", ")", ":", "return", "self", ".", "_files" ]
[ 81, 4 ]
[ 88, 26 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.files
(self, files)
Sets the files of this FileSchemaTestClass. :param files: The files of this FileSchemaTestClass. # noqa: E501 :type files: list[File]
Sets the files of this FileSchemaTestClass.
def files(self, files): """Sets the files of this FileSchemaTestClass. :param files: The files of this FileSchemaTestClass. # noqa: E501 :type files: list[File] """ self._files = files
[ "def", "files", "(", "self", ",", "files", ")", ":", "self", ".", "_files", "=", "files" ]
[ 91, 4 ]
[ 99, 27 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.to_dict
(self, serialize=False)
Returns the model properties as a dict
Returns the model properties as a dict
def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} def convert(x): if hasattr(x, "to_dict"): args = inspect.getargspec(x.to_dict).args if len(args) == 1: return x.to_dict() ...
[ "def", "to_dict", "(", "self", ",", "serialize", "=", "False", ")", ":", "result", "=", "{", "}", "def", "convert", "(", "x", ")", ":", "if", "hasattr", "(", "x", ",", "\"to_dict\"", ")", ":", "args", "=", "inspect", ".", "getargspec", "(", "x", ...
[ 101, 4 ]
[ 131, 21 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.to_str
(self)
Returns the string representation of the model
Returns the string representation of the model
def to_str(self): """Returns the string representation of the model""" return pprint.pformat(self.to_dict())
[ "def", "to_str", "(", "self", ")", ":", "return", "pprint", ".", "pformat", "(", "self", ".", "to_dict", "(", ")", ")" ]
[ 133, 4 ]
[ 135, 45 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.__repr__
(self)
For `print` and `pprint`
For `print` and `pprint`
def __repr__(self): """For `print` and `pprint`""" return self.to_str()
[ "def", "__repr__", "(", "self", ")", ":", "return", "self", ".", "to_str", "(", ")" ]
[ 137, 4 ]
[ 139, 28 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.__eq__
(self, other)
Returns true if both objects are equal
Returns true if both objects are equal
def __eq__(self, other): """Returns true if both objects are equal""" if not isinstance(other, FileSchemaTestClass): return False return self.to_dict() == other.to_dict()
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "FileSchemaTestClass", ")", ":", "return", "False", "return", "self", ".", "to_dict", "(", ")", "==", "other", ".", "to_dict", "(", ")" ]
[ 141, 4 ]
[ 146, 48 ]
python
en
['en', 'en', 'en']
True
FileSchemaTestClass.__ne__
(self, other)
Returns true if both objects are not equal
Returns true if both objects are not equal
def __ne__(self, other): """Returns true if both objects are not equal""" if not isinstance(other, FileSchemaTestClass): return True return self.to_dict() != other.to_dict()
[ "def", "__ne__", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "FileSchemaTestClass", ")", ":", "return", "True", "return", "self", ".", "to_dict", "(", ")", "!=", "other", ".", "to_dict", "(", ")" ]
[ 148, 4 ]
[ 153, 48 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, disc_info=None)
Set up the WebDav Calendar platform.
Set up the WebDav Calendar platform.
def setup_platform(hass, config, add_entities, disc_info=None): """Set up the WebDav Calendar platform.""" url = config[CONF_URL] username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) days = config[CONF_DAYS] client = caldav.DAVClient( url, None, username, password, ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "disc_info", "=", "None", ")", ":", "url", "=", "config", "[", "CONF_URL", "]", "username", "=", "config", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", "config", "....
[ 65, 0 ]
[ 110, 40 ]
python
en
['en', 'pt', 'en']
True
WebDavCalendarEventDevice.__init__
(self, name, calendar, entity_id, days, all_day=False, search=None)
Create the WebDav Calendar Event Device.
Create the WebDav Calendar Event Device.
def __init__(self, name, calendar, entity_id, days, all_day=False, search=None): """Create the WebDav Calendar Event Device.""" self.data = WebDavCalendarData(calendar, days, all_day, search) self.entity_id = entity_id self._event = None self._attr_name = name
[ "def", "__init__", "(", "self", ",", "name", ",", "calendar", ",", "entity_id", ",", "days", ",", "all_day", "=", "False", ",", "search", "=", "None", ")", ":", "self", ".", "data", "=", "WebDavCalendarData", "(", "calendar", ",", "days", ",", "all_day...
[ 116, 4 ]
[ 121, 30 ]
python
en
['en', 'pt', 'en']
True
WebDavCalendarEventDevice.event
(self)
Return the next upcoming event.
Return the next upcoming event.
def event(self): """Return the next upcoming event.""" return self._event
[ "def", "event", "(", "self", ")", ":", "return", "self", ".", "_event" ]
[ 124, 4 ]
[ 126, 26 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarEventDevice.async_get_events
(self, hass, start_date, end_date)
Get all events in a specific time frame.
Get all events in a specific time frame.
async def async_get_events(self, hass, start_date, end_date): """Get all events in a specific time frame.""" return await self.data.async_get_events(hass, start_date, end_date)
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "return", "await", "self", ".", "data", ".", "async_get_events", "(", "hass", ",", "start_date", ",", "end_date", ")" ]
[ 128, 4 ]
[ 130, 75 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarEventDevice.update
(self)
Update event data.
Update event data.
def update(self): """Update event data.""" self.data.update() event = copy.deepcopy(self.data.event) if event is None: self._event = event return event = calculate_offset(event, OFFSET) self._event = event self._attr_extra_state_attributes ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "event", "=", "copy", ".", "deepcopy", "(", "self", ".", "data", ".", "event", ")", "if", "event", "is", "None", ":", "self", ".", "_event", "=", "event", "retu...
[ 132, 4 ]
[ 141, 88 ]
python
co
['fr', 'co', 'en']
False
WebDavCalendarData.__init__
(self, calendar, days, include_all_day, search)
Set up how we are going to search the WebDav calendar.
Set up how we are going to search the WebDav calendar.
def __init__(self, calendar, days, include_all_day, search): """Set up how we are going to search the WebDav calendar.""" self.calendar = calendar self.days = days self.include_all_day = include_all_day self.search = search self.event = None
[ "def", "__init__", "(", "self", ",", "calendar", ",", "days", ",", "include_all_day", ",", "search", ")", ":", "self", ".", "calendar", "=", "calendar", "self", ".", "days", "=", "days", "self", ".", "include_all_day", "=", "include_all_day", "self", ".", ...
[ 147, 4 ]
[ 153, 25 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.async_get_events
(self, hass, start_date, end_date)
Get all events in a specific time frame.
Get all events in a specific time frame.
async def async_get_events(self, hass, start_date, end_date): """Get all events in a specific time frame.""" # Get event list from the current calendar vevent_list = await hass.async_add_executor_job( self.calendar.date_search, start_date, end_date ) event_list = [] ...
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "# Get event list from the current calendar", "vevent_list", "=", "await", "hass", ".", "async_add_executor_job", "(", "self", ".", "calendar", ".", "date_sea...
[ 155, 4 ]
[ 183, 25 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.update
(self)
Get the latest data.
Get the latest data.
def update(self): """Get the latest data.""" start_of_today = dt.start_of_local_day() start_of_tomorrow = dt.start_of_local_day() + timedelta(days=self.days) # We have to retrieve the results for the whole day as the server # won't return events that have already started ...
[ "def", "update", "(", "self", ")", ":", "start_of_today", "=", "dt", ".", "start_of_local_day", "(", ")", "start_of_tomorrow", "=", "dt", ".", "start_of_local_day", "(", ")", "+", "timedelta", "(", "days", "=", "self", ".", "days", ")", "# We have to retriev...
[ 186, 4 ]
[ 254, 9 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.is_matching
(vevent, search)
Return if the event matches the filter criteria.
Return if the event matches the filter criteria.
def is_matching(vevent, search): """Return if the event matches the filter criteria.""" if search is None: return True pattern = re.compile(search) return ( hasattr(vevent, "summary") and pattern.match(vevent.summary.value) or hasattr(veve...
[ "def", "is_matching", "(", "vevent", ",", "search", ")", ":", "if", "search", "is", "None", ":", "return", "True", "pattern", "=", "re", ".", "compile", "(", "search", ")", "return", "(", "hasattr", "(", "vevent", ",", "\"summary\"", ")", "and", "patte...
[ 257, 4 ]
[ 270, 9 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.is_all_day
(vevent)
Return if the event last the whole day.
Return if the event last the whole day.
def is_all_day(vevent): """Return if the event last the whole day.""" return not isinstance(vevent.dtstart.value, datetime)
[ "def", "is_all_day", "(", "vevent", ")", ":", "return", "not", "isinstance", "(", "vevent", ".", "dtstart", ".", "value", ",", "datetime", ")" ]
[ 273, 4 ]
[ 275, 61 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.is_over
(vevent)
Return if the event is over.
Return if the event is over.
def is_over(vevent): """Return if the event is over.""" return dt.now() >= WebDavCalendarData.to_datetime( WebDavCalendarData.get_end_date(vevent) )
[ "def", "is_over", "(", "vevent", ")", ":", "return", "dt", ".", "now", "(", ")", ">=", "WebDavCalendarData", ".", "to_datetime", "(", "WebDavCalendarData", ".", "get_end_date", "(", "vevent", ")", ")" ]
[ 278, 4 ]
[ 282, 9 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.get_hass_date
(obj)
Return if the event matches.
Return if the event matches.
def get_hass_date(obj): """Return if the event matches.""" if isinstance(obj, datetime): return {"dateTime": obj.isoformat()} return {"date": obj.isoformat()}
[ "def", "get_hass_date", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "return", "{", "\"dateTime\"", ":", "obj", ".", "isoformat", "(", ")", "}", "return", "{", "\"date\"", ":", "obj", ".", "isoformat", "(", ")", "}...
[ 285, 4 ]
[ 290, 40 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.to_datetime
(obj)
Return a datetime.
Return a datetime.
def to_datetime(obj): """Return a datetime.""" if isinstance(obj, datetime): if obj.tzinfo is None: # floating value, not bound to any time zone in particular # represent same time regardless of which time zone is currently being observed retur...
[ "def", "to_datetime", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "if", "obj", ".", "tzinfo", "is", "None", ":", "# floating value, not bound to any time zone in particular", "# represent same time regardless of which time zone is curr...
[ 293, 4 ]
[ 303, 9 ]
python
en
['en', 'ro', 'en']
True
WebDavCalendarData.get_attr_value
(obj, attribute)
Return the value of the attribute if defined.
Return the value of the attribute if defined.
def get_attr_value(obj, attribute): """Return the value of the attribute if defined.""" if hasattr(obj, attribute): return getattr(obj, attribute).value return None
[ "def", "get_attr_value", "(", "obj", ",", "attribute", ")", ":", "if", "hasattr", "(", "obj", ",", "attribute", ")", ":", "return", "getattr", "(", "obj", ",", "attribute", ")", ".", "value", "return", "None" ]
[ 306, 4 ]
[ 310, 19 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.get_end_date
(obj)
Return the end datetime as determined by dtend or duration.
Return the end datetime as determined by dtend or duration.
def get_end_date(obj): """Return the end datetime as determined by dtend or duration.""" if hasattr(obj, "dtend"): enddate = obj.dtend.value elif hasattr(obj, "duration"): enddate = obj.dtstart.value + obj.duration.value else: enddate = obj.dtstart.v...
[ "def", "get_end_date", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "\"dtend\"", ")", ":", "enddate", "=", "obj", ".", "dtend", ".", "value", "elif", "hasattr", "(", "obj", ",", "\"duration\"", ")", ":", "enddate", "=", "obj", ".", "dtstar...
[ 313, 4 ]
[ 324, 22 ]
python
en
['en', 'en', 'en']
True
create_checker
( hass: HomeAssistant, _domain: str, extra_significant_check: ExtraCheckTypeFunc | None = None, )
Create a significantly changed checker for a domain.
Create a significantly changed checker for a domain.
async def create_checker( hass: HomeAssistant, _domain: str, extra_significant_check: ExtraCheckTypeFunc | None = None, ) -> SignificantlyChangedChecker: """Create a significantly changed checker for a domain.""" await _initialize(hass) return SignificantlyChangedChecker(hass, extra_significant_...
[ "async", "def", "create_checker", "(", "hass", ":", "HomeAssistant", ",", "_domain", ":", "str", ",", "extra_significant_check", ":", "ExtraCheckTypeFunc", "|", "None", "=", "None", ",", ")", "->", "SignificantlyChangedChecker", ":", "await", "_initialize", "(", ...
[ 65, 0 ]
[ 72, 69 ]
python
en
['en', 'en', 'en']
True
_initialize
(hass: HomeAssistant)
Initialize the functions.
Initialize the functions.
async def _initialize(hass: HomeAssistant) -> None: """Initialize the functions.""" if DATA_FUNCTIONS in hass.data: return functions = hass.data[DATA_FUNCTIONS] = {} async def process_platform( hass: HomeAssistant, component_name: str, platform: Any ) -> None: """Process a ...
[ "async", "def", "_initialize", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "if", "DATA_FUNCTIONS", "in", "hass", ".", "data", ":", "return", "functions", "=", "hass", ".", "data", "[", "DATA_FUNCTIONS", "]", "=", "{", "}", "async", "def", ...
[ 76, 0 ]
[ 89, 79 ]
python
en
['en', 'en', 'en']
True
either_one_none
(val1: Any | None, val2: Any | None)
Test if exactly one value is None.
Test if exactly one value is None.
def either_one_none(val1: Any | None, val2: Any | None) -> bool: """Test if exactly one value is None.""" return (val1 is None and val2 is not None) or (val1 is not None and val2 is None)
[ "def", "either_one_none", "(", "val1", ":", "Any", "|", "None", ",", "val2", ":", "Any", "|", "None", ")", "->", "bool", ":", "return", "(", "val1", "is", "None", "and", "val2", "is", "not", "None", ")", "or", "(", "val1", "is", "not", "None", "a...
[ 92, 0 ]
[ 94, 85 ]
python
en
['en', 'en', 'en']
True
_check_numeric_change
( old_state: int | float | None, new_state: int | float | None, change: int | float, metric: Callable[[int | float, int | float], int | float], )
Check if two numeric values have changed.
Check if two numeric values have changed.
def _check_numeric_change( old_state: int | float | None, new_state: int | float | None, change: int | float, metric: Callable[[int | float, int | float], int | float], ) -> bool: """Check if two numeric values have changed.""" if old_state is None and new_state is None: return False ...
[ "def", "_check_numeric_change", "(", "old_state", ":", "int", "|", "float", "|", "None", ",", "new_state", ":", "int", "|", "float", "|", "None", ",", "change", ":", "int", "|", "float", ",", "metric", ":", "Callable", "[", "[", "int", "|", "float", ...
[ 97, 0 ]
[ 116, 16 ]
python
en
['en', 'en', 'en']
True
check_absolute_change
( val1: int | float | None, val2: int | float | None, change: int | float, )
Check if two numeric values have changed.
Check if two numeric values have changed.
def check_absolute_change( val1: int | float | None, val2: int | float | None, change: int | float, ) -> bool: """Check if two numeric values have changed.""" return _check_numeric_change( val1, val2, change, lambda val1, val2: abs(val1 - val2) )
[ "def", "check_absolute_change", "(", "val1", ":", "int", "|", "float", "|", "None", ",", "val2", ":", "int", "|", "float", "|", "None", ",", "change", ":", "int", "|", "float", ",", ")", "->", "bool", ":", "return", "_check_numeric_change", "(", "val1"...
[ 119, 0 ]
[ 127, 5 ]
python
en
['en', 'en', 'en']
True