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
EsphomeCover.async_open_cover_tilt
(self, **kwargs: Any)
Open the cover tilt.
Open the cover tilt.
async def async_open_cover_tilt(self, **kwargs: Any) -> None: """Open the cover tilt.""" await self._client.cover_command(key=self._static_info.key, tilt=1.0)
[ "async", "def", "async_open_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "_client", ".", "cover_command", "(", "key", "=", "self", ".", "_static_info", ".", "key", ",", "tilt", "=", "1.0",...
[ 116, 4 ]
[ 118, 77 ]
python
en
['en', 'no', 'en']
True
EsphomeCover.async_close_cover_tilt
(self, **kwargs: Any)
Close the cover tilt.
Close the cover tilt.
async def async_close_cover_tilt(self, **kwargs: Any) -> None: """Close the cover tilt.""" await self._client.cover_command(key=self._static_info.key, tilt=0.0)
[ "async", "def", "async_close_cover_tilt", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "await", "self", ".", "_client", ".", "cover_command", "(", "key", "=", "self", ".", "_static_info", ".", "key", ",", "tilt", "=", "0.0"...
[ 120, 4 ]
[ 122, 77 ]
python
en
['en', 'fr', 'en']
True
EsphomeCover.async_set_cover_tilt_position
(self, **kwargs: int)
Move the cover tilt to a specific position.
Move the cover tilt to a specific position.
async def async_set_cover_tilt_position(self, **kwargs: int) -> None: """Move the cover tilt to a specific position.""" await self._client.cover_command( key=self._static_info.key, tilt=kwargs[ATTR_TILT_POSITION] / 100 )
[ "async", "def", "async_set_cover_tilt_position", "(", "self", ",", "*", "*", "kwargs", ":", "int", ")", "->", "None", ":", "await", "self", ".", "_client", ".", "cover_command", "(", "key", "=", "self", ".", "_static_info", ".", "key", ",", "tilt", "=", ...
[ 124, 4 ]
[ 128, 9 ]
python
en
['en', 'en', 'en']
True
mock_http_client
(loop, hass, hass_client)
Set up test fixture.
Set up test fixture.
def mock_http_client(loop, hass, hass_client): """Set up test fixture.""" config = { "rss_feed_template": { "testfeed": { "title": "feed title is {{states.test.test1.state}}", "items": [ { "title": "item title is {{s...
[ "def", "mock_http_client", "(", "loop", ",", "hass", ",", "hass_client", ")", ":", "config", "=", "{", "\"rss_feed_template\"", ":", "{", "\"testfeed\"", ":", "{", "\"title\"", ":", "\"feed title is {{states.test.test1.state}}\"", ",", "\"items\"", ":", "[", "{", ...
[ 9, 0 ]
[ 26, 49 ]
python
en
['en', 'lb', 'en']
True
test_get_nonexistant_feed
(mock_http_client)
Test if we can retrieve the correct rss feed.
Test if we can retrieve the correct rss feed.
async def test_get_nonexistant_feed(mock_http_client): """Test if we can retrieve the correct rss feed.""" resp = await mock_http_client.get("/api/rss_template/otherfeed") assert resp.status == HTTP_NOT_FOUND
[ "async", "def", "test_get_nonexistant_feed", "(", "mock_http_client", ")", ":", "resp", "=", "await", "mock_http_client", ".", "get", "(", "\"/api/rss_template/otherfeed\"", ")", "assert", "resp", ".", "status", "==", "HTTP_NOT_FOUND" ]
[ 29, 0 ]
[ 32, 40 ]
python
en
['en', 'en', 'en']
True
test_get_rss_feed
(mock_http_client, hass)
Test if we can retrieve the correct rss feed.
Test if we can retrieve the correct rss feed.
async def test_get_rss_feed(mock_http_client, hass): """Test if we can retrieve the correct rss feed.""" hass.states.async_set("test.test1", "a_state_1") hass.states.async_set("test.test2", "a_state_2") hass.states.async_set("test.test3", "a_state_3") resp = await mock_http_client.get("/api/rss_tem...
[ "async", "def", "test_get_rss_feed", "(", "mock_http_client", ",", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"test.test1\"", ",", "\"a_state_1\"", ")", "hass", ".", "states", ".", "async_set", "(", "\"test.test2\"", ",", "\"a_state_2\"", ...
[ 35, 0 ]
[ 49, 45 ]
python
en
['en', 'en', 'en']
True
test_state
(hass)
Test Air Quality state.
Test Air Quality state.
async def test_state(hass): """Test Air Quality state.""" config = {"air_quality": {"platform": "demo"}} assert await async_setup_component(hass, "air_quality", config) await hass.async_block_till_done() state = hass.states.get("air_quality.demo_air_quality_home") assert state is not None ...
[ "async", "def", "test_state", "(", "hass", ")", ":", "config", "=", "{", "\"air_quality\"", ":", "{", "\"platform\"", ":", "\"demo\"", "}", "}", "assert", "await", "async_setup_component", "(", "hass", ",", "\"air_quality\"", ",", "config", ")", "await", "ha...
[ 14, 0 ]
[ 24, 30 ]
python
en
['en', 'en', 'en']
True
test_attributes
(hass)
Test Air Quality attributes.
Test Air Quality attributes.
async def test_attributes(hass): """Test Air Quality attributes.""" config = {"air_quality": {"platform": "demo"}} assert await async_setup_component(hass, "air_quality", config) await hass.async_block_till_done() state = hass.states.get("air_quality.demo_air_quality_office") assert state is n...
[ "async", "def", "test_attributes", "(", "hass", ")", ":", "config", "=", "{", "\"air_quality\"", ":", "{", "\"platform\"", ":", "\"demo\"", "}", "}", "assert", "await", "async_setup_component", "(", "hass", ",", "\"air_quality\"", ",", "config", ")", "await", ...
[ 27, 0 ]
[ 44, 5 ]
python
en
['en', 'hmn', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, )
Set up Switcher sensor from config entry.
Set up Switcher sensor from config entry.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up Switcher sensor from config entry.""" @callback def async_add_sensors(wrapper: SwitcherDeviceWrapper) -> None: """Add sensors from Switcher device."...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ",", ")", "->", "None", ":", "@", "callback", "def", "async_add_sensors", "(", "wrapper", ":", ...
[ 69, 0 ]
[ 92, 5 ]
python
en
['en', 'en', 'en']
True
SwitcherSensorEntity.__init__
( self, wrapper: SwitcherDeviceWrapper, attribute: str, description: AttributeDescription, )
Initialize the entity.
Initialize the entity.
def __init__( self, wrapper: SwitcherDeviceWrapper, attribute: str, description: AttributeDescription, ) -> None: """Initialize the entity.""" super().__init__(wrapper) self.wrapper = wrapper self.attribute = attribute # Entity class attribute...
[ "def", "__init__", "(", "self", ",", "wrapper", ":", "SwitcherDeviceWrapper", ",", "attribute", ":", "str", ",", "description", ":", "AttributeDescription", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "wrapper", ")", "self", ".", ...
[ 98, 4 ]
[ 121, 9 ]
python
en
['en', 'en', 'en']
True
SwitcherSensorEntity.native_value
(self)
Return value of sensor.
Return value of sensor.
def native_value(self) -> StateType: """Return value of sensor.""" return getattr(self.wrapper.data, self.attribute)
[ "def", "native_value", "(", "self", ")", "->", "StateType", ":", "return", "getattr", "(", "self", ".", "wrapper", ".", "data", ",", "self", ".", "attribute", ")" ]
[ 124, 4 ]
[ 126, 57 ]
python
en
['en', 'no', 'en']
True
HeaderPreamble
(n)
Returns the preamble for the header file. Args: n: the maximum arity of the predicate macros to be generated.
Returns the preamble for the header file.
def HeaderPreamble(n): """Returns the preamble for the header file. Args: n: the maximum arity of the predicate macros to be generated. """ # A map that defines the values used in the preamble template. DEFS = { 'today' : time.strftime('%m/%d/%Y'), 'year' : time.strftime('%Y'), 'command' : ...
[ "def", "HeaderPreamble", "(", "n", ")", ":", "# A map that defines the values used in the preamble template.", "DEFS", "=", "{", "'today'", ":", "time", ".", "strftime", "(", "'%m/%d/%Y'", ")", ",", "'year'", ":", "time", ".", "strftime", "(", "'%Y'", ")", ",", ...
[ 64, 0 ]
[ 161, 11 ]
python
en
['en', 'en', 'en']
True
Arity
(n)
Returns the English name of the given arity.
Returns the English name of the given arity.
def Arity(n): """Returns the English name of the given arity.""" if n < 0: return None elif n <= 3: return ['nullary', 'unary', 'binary', 'ternary'][n] else: return '%s-ary' % n
[ "def", "Arity", "(", "n", ")", ":", "if", "n", "<", "0", ":", "return", "None", "elif", "n", "<=", "3", ":", "return", "[", "'nullary'", ",", "'unary'", ",", "'binary'", ",", "'ternary'", "]", "[", "n", "]", "else", ":", "return", "'%s-ary'", "%"...
[ 164, 0 ]
[ 172, 23 ]
python
en
['en', 'en', 'en']
True
Title
(word)
Returns the given word in title case. The difference between this and string's title() method is that Title('4-ary') is '4-ary' while '4-ary'.title() is '4-Ary'.
Returns the given word in title case. The difference between this and string's title() method is that Title('4-ary') is '4-ary' while '4-ary'.title() is '4-Ary'.
def Title(word): """Returns the given word in title case. The difference between this and string's title() method is that Title('4-ary') is '4-ary' while '4-ary'.title() is '4-Ary'.""" return word[0].upper() + word[1:]
[ "def", "Title", "(", "word", ")", ":", "return", "word", "[", "0", "]", ".", "upper", "(", ")", "+", "word", "[", "1", ":", "]" ]
[ 175, 0 ]
[ 180, 35 ]
python
en
['en', 'en', 'en']
True
OneTo
(n)
Returns the list [1, 2, 3, ..., n].
Returns the list [1, 2, 3, ..., n].
def OneTo(n): """Returns the list [1, 2, 3, ..., n].""" return range(1, n + 1)
[ "def", "OneTo", "(", "n", ")", ":", "return", "range", "(", "1", ",", "n", "+", "1", ")" ]
[ 183, 0 ]
[ 186, 24 ]
python
en
['en', 'be', 'en']
True
Iter
(n, format, sep='')
Given a positive integer n, a format string that contains 0 or more '%s' format specs, and optionally a separator string, returns the join of n strings, each formatted with the format string on an iterator ranged from 1 to n. Example: Iter(3, 'v%s', sep=', ') returns 'v1, v2, v3'.
Given a positive integer n, a format string that contains 0 or more '%s' format specs, and optionally a separator string, returns the join of n strings, each formatted with the format string on an iterator ranged from 1 to n.
def Iter(n, format, sep=''): """Given a positive integer n, a format string that contains 0 or more '%s' format specs, and optionally a separator string, returns the join of n strings, each formatted with the format string on an iterator ranged from 1 to n. Example: Iter(3, 'v%s', sep=', ') returns 'v1, v...
[ "def", "Iter", "(", "n", ",", "format", ",", "sep", "=", "''", ")", ":", "# How many '%s' specs are in format?", "spec_count", "=", "len", "(", "format", ".", "split", "(", "'%s'", ")", ")", "-", "1", "return", "sep", ".", "join", "(", "[", "format", ...
[ 189, 0 ]
[ 202, 67 ]
python
en
['en', 'en', 'en']
True
ImplementationForArity
(n)
Returns the implementation of n-ary predicate assertions.
Returns the implementation of n-ary predicate assertions.
def ImplementationForArity(n): """Returns the implementation of n-ary predicate assertions.""" # A map the defines the values used in the implementation template. DEFS = { 'n' : str(n), 'vs' : Iter(n, 'v%s', sep=', '), 'vts' : Iter(n, '#v%s', sep=', '), 'arity' : Arity(n), 'Arity' : Title(Ari...
[ "def", "ImplementationForArity", "(", "n", ")", ":", "# A map the defines the values used in the implementation template.", "DEFS", "=", "{", "'n'", ":", "str", "(", "n", ")", ",", "'vs'", ":", "Iter", "(", "n", ",", "'v%s'", ",", "sep", "=", "', '", ")", ",...
[ 205, 0 ]
[ 292, 13 ]
python
en
['en', 'en', 'en']
True
HeaderPostamble
()
Returns the postamble for the header file.
Returns the postamble for the header file.
def HeaderPostamble(): """Returns the postamble for the header file.""" return """ } // namespace testing #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ """
[ "def", "HeaderPostamble", "(", ")", ":", "return", "\"\"\"\n\n} // namespace testing\n\n#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\"\"\"" ]
[ 295, 0 ]
[ 303, 3 ]
python
en
['en', 'en', 'en']
True
GenerateFile
(path, content)
Given a file path and a content string overwrites it with the given content.
Given a file path and a content string overwrites it with the given content.
def GenerateFile(path, content): """Given a file path and a content string overwrites it with the given content. """ print 'Updating file %s . . .' % path f = file(path, 'w+') print >>f, content, f.close() print 'File %s has been updated.' % path
[ "def", "GenerateFile", "(", "path", ",", "content", ")", ":", "print", "'Updating file %s . . .'", "%", "path", "f", "=", "file", "(", "path", ",", "'w+'", ")", "print", ">>", "f", ",", "content", ",", "f", ".", "close", "(", ")", "print", "'File %s ha...
[ 306, 0 ]
[ 315, 42 ]
python
en
['en', 'en', 'en']
True
GenerateHeader
(n)
Given the maximum arity n, updates the header file that implements the predicate assertions.
Given the maximum arity n, updates the header file that implements the predicate assertions.
def GenerateHeader(n): """Given the maximum arity n, updates the header file that implements the predicate assertions. """ GenerateFile(HEADER, HeaderPreamble(n) + ''.join([ImplementationForArity(i) for i in OneTo(n)]) + HeaderPostamble())
[ "def", "GenerateHeader", "(", "n", ")", ":", "GenerateFile", "(", "HEADER", ",", "HeaderPreamble", "(", "n", ")", "+", "''", ".", "join", "(", "[", "ImplementationForArity", "(", "i", ")", "for", "i", "in", "OneTo", "(", "n", ")", "]", ")", "+", "H...
[ 318, 0 ]
[ 325, 35 ]
python
en
['en', 'en', 'en']
True
UnitTestPreamble
()
Returns the preamble for the unit test file.
Returns the preamble for the unit test file.
def UnitTestPreamble(): """Returns the preamble for the unit test file.""" # A map that defines the values used in the preamble template. DEFS = { 'today' : time.strftime('%m/%d/%Y'), 'year' : time.strftime('%Y'), 'command' : '%s %s' % (os.path.basename(sys.argv[0]), sys.argv[1]), } return ( ...
[ "def", "UnitTestPreamble", "(", ")", ":", "# A map that defines the values used in the preamble template.", "DEFS", "=", "{", "'today'", ":", "time", ".", "strftime", "(", "'%m/%d/%Y'", ")", ",", "'year'", ":", "time", ".", "strftime", "(", "'%Y'", ")", ",", "'c...
[ 328, 0 ]
[ 411, 11 ]
python
en
['en', 'en', 'en']
True
TestsForArity
(n)
Returns the tests for n-ary predicate assertions.
Returns the tests for n-ary predicate assertions.
def TestsForArity(n): """Returns the tests for n-ary predicate assertions.""" # A map that defines the values used in the template for the tests. DEFS = { 'n' : n, 'es' : Iter(n, 'e%s', sep=', '), 'vs' : Iter(n, 'v%s', sep=', '), 'vts' : Iter(n, '#v%s', sep=', '), 'tvs' : Iter(n, 'T%s v%s', s...
[ "def", "TestsForArity", "(", "n", ")", ":", "# A map that defines the values used in the template for the tests.", "DEFS", "=", "{", "'n'", ":", "n", ",", "'es'", ":", "Iter", "(", "n", ",", "'e%s'", ",", "sep", "=", "', '", ")", ",", "'vs'", ":", "Iter", ...
[ 414, 0 ]
[ 699, 14 ]
python
en
['en', 'en', 'en']
True
UnitTestPostamble
()
Returns the postamble for the tests.
Returns the postamble for the tests.
def UnitTestPostamble(): """Returns the postamble for the tests.""" return ''
[ "def", "UnitTestPostamble", "(", ")", ":", "return", "''" ]
[ 702, 0 ]
[ 705, 11 ]
python
en
['en', 'en', 'en']
True
GenerateUnitTest
(n)
Returns the tests for up-to n-ary predicate assertions.
Returns the tests for up-to n-ary predicate assertions.
def GenerateUnitTest(n): """Returns the tests for up-to n-ary predicate assertions.""" GenerateFile(UNIT_TEST, UnitTestPreamble() + ''.join([TestsForArity(i) for i in OneTo(n)]) + UnitTestPostamble())
[ "def", "GenerateUnitTest", "(", "n", ")", ":", "GenerateFile", "(", "UNIT_TEST", ",", "UnitTestPreamble", "(", ")", "+", "''", ".", "join", "(", "[", "TestsForArity", "(", "i", ")", "for", "i", "in", "OneTo", "(", "n", ")", "]", ")", "+", "UnitTestPo...
[ 708, 0 ]
[ 714, 37 ]
python
en
['en', 'en', 'en']
True
_Main
()
The entry point of the script. Generates the header file and its unit test.
The entry point of the script. Generates the header file and its unit test.
def _Main(): """The entry point of the script. Generates the header file and its unit test.""" if len(sys.argv) != 2: print __doc__ print 'Author: ' + __author__ sys.exit(1) n = int(sys.argv[1]) GenerateHeader(n) GenerateUnitTest(n)
[ "def", "_Main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "print", "__doc__", "print", "'Author: '", "+", "__author__", "sys", ".", "exit", "(", "1", ")", "n", "=", "int", "(", "sys", ".", "argv", "[", "1", "]", ...
[ 717, 0 ]
[ 728, 21 ]
python
en
['en', 'en', 'en']
True
_convert_to_utc_string
(value: str)
Convert date to UTC iso format.
Convert date to UTC iso format.
def _convert_to_utc_string(value: str) -> str: """Convert date to UTC iso format.""" original_dt = parse_datetime(value) if TYPE_CHECKING: assert original_dt is not None return as_utc(original_dt).isoformat()
[ "def", "_convert_to_utc_string", "(", "value", ":", "str", ")", "->", "str", ":", "original_dt", "=", "parse_datetime", "(", "value", ")", "if", "TYPE_CHECKING", ":", "assert", "original_dt", "is", "not", "None", "return", "as_utc", "(", "original_dt", ")", ...
[ 67, 0 ]
[ 72, 42 ]
python
en
['en', 'en', 'it']
True
RenaultDataEntity.__init__
( self, vehicle: RenaultVehicleProxy, description: RenaultEntityDescription, )
Initialise entity.
Initialise entity.
def __init__( self, vehicle: RenaultVehicleProxy, description: RenaultEntityDescription, ) -> None: """Initialise entity.""" super().__init__(vehicle.coordinators[description.coordinator]) self.vehicle = vehicle self.entity_description = description se...
[ "def", "__init__", "(", "self", ",", "vehicle", ":", "RenaultVehicleProxy", ",", "description", ":", "RenaultEntityDescription", ",", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "vehicle", ".", "coordinators", "[", "description", ".", "c...
[ 36, 4 ]
[ 46, 86 ]
python
et
['et', 'zu', 'it']
False
RenaultDataEntity._get_data_attr
(self, key: str)
Return the attribute value from the coordinator data.
Return the attribute value from the coordinator data.
def _get_data_attr(self, key: str) -> StateType: """Return the attribute value from the coordinator data.""" if self.coordinator.data is None: return None return cast(StateType, getattr(self.coordinator.data, key))
[ "def", "_get_data_attr", "(", "self", ",", "key", ":", "str", ")", "->", "StateType", ":", "if", "self", ".", "coordinator", ".", "data", "is", "None", ":", "return", "None", "return", "cast", "(", "StateType", ",", "getattr", "(", "self", ".", "coordi...
[ 48, 4 ]
[ 52, 67 ]
python
en
['en', 'en', 'en']
True
RenaultDataEntity.extra_state_attributes
(self)
Return the state attributes of this entity.
Return the state attributes of this entity.
def extra_state_attributes(self) -> Mapping[str, Any] | None: """Return the state attributes of this entity.""" last_update: str | None = None if self.entity_description.coordinator == "battery": last_update = cast(str, self._get_data_attr("timestamp")) elif self.entity_descr...
[ "def", "extra_state_attributes", "(", "self", ")", "->", "Mapping", "[", "str", ",", "Any", "]", "|", "None", ":", "last_update", ":", "str", "|", "None", "=", "None", "if", "self", ".", "entity_description", ".", "coordinator", "==", "\"battery\"", ":", ...
[ 55, 4 ]
[ 64, 19 ]
python
en
['en', 'en', 'en']
True
test_support_called
(insights_config, insights_client, insights_support)
InsightsSupport is constructed with InsightsConfig and collect_support_info is called.
InsightsSupport is constructed with InsightsConfig and collect_support_info is called.
def test_support_called(insights_config, insights_client, insights_support): """ InsightsSupport is constructed with InsightsConfig and collect_support_info is called. """ try: pre_update() except SystemExit: pass insights_support.assert_called_once_with(insights_config.return_v...
[ "def", "test_support_called", "(", "insights_config", ",", "insights_client", ",", "insights_support", ")", ":", "try", ":", "pre_update", "(", ")", "except", "SystemExit", ":", "pass", "insights_support", ".", "assert_called_once_with", "(", "insights_config", ".", ...
[ 35, 0 ]
[ 45, 80 ]
python
en
['en', 'error', 'th']
False
test_exit_ok
(insights_config, insights_client, insights_support)
Support collection replaces the normal client run.
Support collection replaces the normal client run.
def test_exit_ok(insights_config, insights_client, insights_support): """ Support collection replaces the normal client run. """ with raises(SystemExit) as exc_info: pre_update() assert exc_info.value.code == InsightsConstants.sig_kill_ok
[ "def", "test_exit_ok", "(", "insights_config", ",", "insights_client", ",", "insights_support", ")", ":", "with", "raises", "(", "SystemExit", ")", "as", "exc_info", ":", "pre_update", "(", ")", "assert", "exc_info", ".", "value", ".", "code", "==", "InsightsC...
[ 52, 0 ]
[ 59, 63 ]
python
en
['en', 'error', 'th']
False
lookupEncoding
(encoding)
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
def lookupEncoding(encoding): """Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.""" if isinstance(encoding, bytes): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return None ...
[ "def", "lookupEncoding", "(", "encoding", ")", ":", "if", "isinstance", "(", "encoding", ",", "bytes", ")", ":", "try", ":", "encoding", "=", "encoding", ".", "decode", "(", "\"ascii\"", ")", "except", "UnicodeDecodeError", ":", "return", "None", "if", "en...
[ 902, 0 ]
[ 917, 19 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.__init__
(self, source)
Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specifie...
Initialises the HTMLInputStream.
def __init__(self, source): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indic...
[ "def", "__init__", "(", "self", ",", "source", ")", ":", "if", "not", "_utils", ".", "supports_lone_surrogates", ":", "# Such platforms will have already checked for such", "# surrogate errors, so no need to do this checking.", "self", ".", "reportCharacterErrors", "=", "None...
[ 157, 4 ]
[ 187, 20 ]
python
en
['en', 'sn', 'en']
True
HTMLUnicodeInputStream.openStream
(self, source)
Produces a file object from source. source can be either a file object, local filename or a string.
Produces a file object from source.
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) ...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "StringIO", "(", "source", ")", "return", "stream" ]
[ 203, 4 ]
[ 215, 21 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.position
(self)
Returns (line, col) of the current position in the stream.
Returns (line, col) of the current position in the stream.
def position(self): """Returns (line, col) of the current position in the stream.""" line, col = self._position(self.chunkOffset) return (line + 1, col)
[ "def", "position", "(", "self", ")", ":", "line", ",", "col", "=", "self", ".", "_position", "(", "self", ".", "chunkOffset", ")", "return", "(", "line", "+", "1", ",", "col", ")" ]
[ 228, 4 ]
[ 231, 30 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.char
(self)
Read one character from the stream or queue if available. Return EOF when EOF is reached.
Read one character from the stream or queue if available. Return EOF when EOF is reached.
def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF ...
[ "def", "char", "(", "self", ")", ":", "# Read a new chunk from the input stream if necessary", "if", "self", ".", "chunkOffset", ">=", "self", ".", "chunkSize", ":", "if", "not", "self", ".", "readChunk", "(", ")", ":", "return", "EOF", "chunkOffset", "=", "se...
[ 233, 4 ]
[ 246, 19 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.charsUntil
(self, characters, opposite=False)
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
def charsUntil(self, characters, opposite=False): """ Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. """ # Use ...
[ "def", "charsUntil", "(", "self", ",", "characters", ",", "opposite", "=", "False", ")", ":", "# Use a cache of regexps to find the required characters", "try", ":", "chars", "=", "charsUntilRegEx", "[", "(", "characters", ",", "opposite", ")", "]", "except", "Key...
[ 313, 4 ]
[ 358, 16 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.__init__
(self, source, override_encoding=None, transport_encoding=None, same_origin_parent_encoding=None, likely_encoding=None, default_encoding="windows-1252", useChardet=True)
Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specifie...
Initialises the HTMLInputStream.
def __init__(self, source, override_encoding=None, transport_encoding=None, same_origin_parent_encoding=None, likely_encoding=None, default_encoding="windows-1252", useChardet=True): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized ...
[ "def", "__init__", "(", "self", ",", "source", ",", "override_encoding", "=", "None", ",", "transport_encoding", "=", "None", ",", "same_origin_parent_encoding", "=", "None", ",", "likely_encoding", "=", "None", ",", "default_encoding", "=", "\"windows-1252\"", ",...
[ 385, 4 ]
[ 425, 20 ]
python
en
['en', 'sn', 'en']
True
HTMLBinaryInputStream.openStream
(self, source)
Produces a file object from source. source can be either a file object, local filename or a string.
Produces a file object from source.
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) t...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "BytesIO", "(", "source", ")", "try", ":", "stream", ".", ...
[ 431, 4 ]
[ 448, 21 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.detectBOM
(self)
Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None
Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None
def detectBOM(self): """Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None""" bomDict = { codecs.BOM_UTF8: 'utf-8', codecs.BOM_UTF16_LE: 'utf-16le', codecs.BOM_U...
[ "def", "detectBOM", "(", "self", ")", ":", "bomDict", "=", "{", "codecs", ".", "BOM_UTF8", ":", "'utf-8'", ",", "codecs", ".", "BOM_UTF16_LE", ":", "'utf-16le'", ",", "codecs", ".", "BOM_UTF16_BE", ":", "'utf-16be'", ",", "codecs", ".", "BOM_UTF32_LE", ":"...
[ 528, 4 ]
[ 560, 23 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.detectEncodingMeta
(self)
Report the encoding declared by the meta element
Report the encoding declared by the meta element
def detectEncodingMeta(self): """Report the encoding declared by the meta element """ buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() i...
[ "def", "detectEncodingMeta", "(", "self", ")", ":", "buffer", "=", "self", ".", "rawStream", ".", "read", "(", "self", ".", "numBytesMeta", ")", "assert", "isinstance", "(", "buffer", ",", "bytes", ")", "parser", "=", "EncodingParser", "(", "buffer", ")", ...
[ 562, 4 ]
[ 574, 23 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.skip
(self, chars=spaceCharactersBytes)
Skip past a list of characters
Skip past a list of characters
def skip(self, chars=spaceCharactersBytes): """Skip past a list of characters""" p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p return c ...
[ "def", "skip", "(", "self", ",", "chars", "=", "spaceCharactersBytes", ")", ":", "p", "=", "self", ".", "position", "# use property for the error-checking", "while", "p", "<", "len", "(", "self", ")", ":", "c", "=", "self", "[", "p", ":", "p", "+", "1"...
[ 633, 4 ]
[ 643, 19 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.matchBytes
(self, bytes)
Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone
Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone
def matchBytes(self, bytes): """Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone""" rv = self.startswith(bytes, self.position) if rv:...
[ "def", "matchBytes", "(", "self", ",", "bytes", ")", ":", "rv", "=", "self", ".", "startswith", "(", "bytes", ",", "self", ".", "position", ")", "if", "rv", ":", "self", ".", "position", "+=", "len", "(", "bytes", ")", "return", "rv" ]
[ 656, 4 ]
[ 663, 17 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.jumpTo
(self, bytes)
Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match
Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match
def jumpTo(self, bytes): """Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match""" try: self._position = self.index(bytes, self.position) + len(bytes) - 1 except ValueError: raise St...
[ "def", "jumpTo", "(", "self", ",", "bytes", ")", ":", "try", ":", "self", ".", "_position", "=", "self", ".", "index", "(", "bytes", ",", "self", ".", "position", ")", "+", "len", "(", "bytes", ")", "-", "1", "except", "ValueError", ":", "raise", ...
[ 665, 4 ]
[ 672, 19 ]
python
en
['en', 'en', 'en']
True
EncodingParser.__init__
(self, data)
string - the data to work on for encoding detection
string - the data to work on for encoding detection
def __init__(self, data): """string - the data to work on for encoding detection""" self.data = EncodingBytes(data) self.encoding = None
[ "def", "__init__", "(", "self", ",", "data", ")", ":", "self", ".", "data", "=", "EncodingBytes", "(", "data", ")", "self", ".", "encoding", "=", "None" ]
[ 678, 4 ]
[ 681, 28 ]
python
en
['en', 'en', 'en']
True
EncodingParser.handleComment
(self)
Skip over comments
Skip over comments
def handleComment(self): """Skip over comments""" return self.data.jumpTo(b"-->")
[ "def", "handleComment", "(", "self", ")", ":", "return", "self", ".", "data", ".", "jumpTo", "(", "b\"-->\"", ")" ]
[ 713, 4 ]
[ 715, 39 ]
python
en
['en', 'en', 'en']
True
EncodingParser.getAttribute
(self)
Return a name,value pair for the next attribute in the stream, if one is found, or None
Return a name,value pair for the next attribute in the stream, if one is found, or None
def getAttribute(self): """Return a name,value pair for the next attribute in the stream, if one is found, or None""" data = self.data # Step 1 (skip chars) c = data.skip(spaceCharactersBytes | frozenset([b"/"])) assert c is None or len(c) == 1 # Step 2 if...
[ "def", "getAttribute", "(", "self", ")", ":", "data", "=", "self", ".", "data", "# Step 1 (skip chars)", "c", "=", "data", ".", "skip", "(", "spaceCharactersBytes", "|", "frozenset", "(", "[", "b\"/\"", "]", ")", ")", "assert", "c", "is", "None", "or", ...
[ 786, 4 ]
[ 860, 35 ]
python
en
['en', 'en', 'en']
True
_transitions_config_parser
(transitions)
Parse transitions config into initialized objects.
Parse transitions config into initialized objects.
def _transitions_config_parser(transitions): """Parse transitions config into initialized objects.""" transition_objects = [] for transition_config in transitions: transition, params = list(transition_config.items())[0] transition_objects.append(getattr(yeelight, transition)(*params)) r...
[ "def", "_transitions_config_parser", "(", "transitions", ")", ":", "transition_objects", "=", "[", "]", "for", "transition_config", "in", "transitions", ":", "transition", ",", "params", "=", "list", "(", "transition_config", ".", "items", "(", ")", ")", "[", ...
[ 210, 0 ]
[ 217, 29 ]
python
en
['en', 'en', 'en']
True
_async_cmd
(func)
Define a wrapper to catch exceptions from the bulb.
Define a wrapper to catch exceptions from the bulb.
def _async_cmd(func): """Define a wrapper to catch exceptions from the bulb.""" async def _async_wrap(self, *args, **kwargs): try: _LOGGER.debug("Calling %s with %s %s", func, args, kwargs) return await func(self, *args, **kwargs) except BULB_EXCEPTIONS as ex: ...
[ "def", "_async_cmd", "(", "func", ")", ":", "async", "def", "_async_wrap", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "_LOGGER", ".", "debug", "(", "\"Calling %s with %s %s\"", ",", "func", ",", "args", ",", "kwargs",...
[ 237, 0 ]
[ 247, 22 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities )
Set up Yeelight from a config entry.
Set up Yeelight from a config entry.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up Yeelight from a config entry.""" custom_effects = _parse_custom_effects(hass.data[DOMAIN][DATA_CUSTOM_EFFECTS]) device = hass.data[DOMAIN][DATA_CONFIG_ENTRIES][config_entry.entry_id][DAT...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "custom_effects", "=", "_parse_custom_effects", "(", "hass", ".", "data", "[", "DOMAIN", "]", "[",...
[ 250, 0 ]
[ 298, 31 ]
python
en
['en', 'en', 'en']
True
_async_setup_services
(hass: HomeAssistant)
Set up custom services.
Set up custom services.
def _async_setup_services(hass: HomeAssistant): """Set up custom services.""" async def _async_start_flow(entity, service_call): params = {**service_call.data} params.pop(ATTR_ENTITY_ID) params[ATTR_TRANSITIONS] = _transitions_config_parser(params[ATTR_TRANSITIONS]) await entity...
[ "def", "_async_setup_services", "(", "hass", ":", "HomeAssistant", ")", ":", "async", "def", "_async_start_flow", "(", "entity", ",", "service_call", ")", ":", "params", "=", "{", "*", "*", "service_call", ".", "data", "}", "params", ".", "pop", "(", "ATTR...
[ 302, 0 ]
[ 378, 5 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.__init__
(self, device, entry, custom_effects=None)
Initialize the Yeelight light.
Initialize the Yeelight light.
def __init__(self, device, entry, custom_effects=None): """Initialize the Yeelight light.""" super().__init__(device, entry) self.config = device.config self._color_temp = None self._effect = None model_specs = self._bulb.get_model_specs() self._min_mireds = ke...
[ "def", "__init__", "(", "self", ",", "device", ",", "entry", ",", "custom_effects", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "entry", ")", "self", ".", "config", "=", "device", ".", "config", "self", ".", "_color...
[ 387, 4 ]
[ 405, 37 ]
python
en
['en', 'xh', 'en']
True
YeelightGenericLight.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" self.async_on_remove( async_dispatcher_connect( self.hass, DATA_UPDATED.format(self._device.host), self.async_write_ha_state, ) ) await su...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "DATA_UPDATED", ".", "format", "(", "self", ".", "_device", ".", "host", ")", ",", "self", ".", "a...
[ 407, 4 ]
[ 416, 43 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_YEELIGHT
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_YEELIGHT" ]
[ 419, 4 ]
[ 421, 31 ]
python
en
['da', 'en', 'en']
True
YeelightGenericLight.effect_list
(self)
Return the list of supported effects.
Return the list of supported effects.
def effect_list(self): """Return the list of supported effects.""" return self._predefined_effects + self.custom_effects_names
[ "def", "effect_list", "(", "self", ")", ":", "return", "self", ".", "_predefined_effects", "+", "self", ".", "custom_effects_names" ]
[ 424, 4 ]
[ 426, 67 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.color_temp
(self)
Return the color temperature.
Return the color temperature.
def color_temp(self) -> int: """Return the color temperature.""" temp_in_k = self._get_property("ct") if temp_in_k: self._color_temp = kelvin_to_mired(int(temp_in_k)) return self._color_temp
[ "def", "color_temp", "(", "self", ")", "->", "int", ":", "temp_in_k", "=", "self", ".", "_get_property", "(", "\"ct\"", ")", "if", "temp_in_k", ":", "self", ".", "_color_temp", "=", "kelvin_to_mired", "(", "int", "(", "temp_in_k", ")", ")", "return", "se...
[ 429, 4 ]
[ 434, 31 ]
python
en
['en', 'la', 'en']
True
YeelightGenericLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self) -> str: """Return the name of the device if any.""" return self.device.name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "device", ".", "name" ]
[ 437, 4 ]
[ 439, 31 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return self._get_property(self._power_property) == "on"
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_get_property", "(", "self", ".", "_power_property", ")", "==", "\"on\"" ]
[ 442, 4 ]
[ 444, 63 ]
python
en
['en', 'fy', 'en']
True
YeelightGenericLight.brightness
(self)
Return the brightness of this light between 1..255.
Return the brightness of this light between 1..255.
def brightness(self) -> int: """Return the brightness of this light between 1..255.""" # Always use "bright" as property name in music mode # Since music mode states are only caches in upstream library # and the cache key is always "bright" for brightness brightness_property = ( ...
[ "def", "brightness", "(", "self", ")", "->", "int", ":", "# Always use \"bright\" as property name in music mode", "# Since music mode states are only caches in upstream library", "# and the cache key is always \"bright\" for brightness", "brightness_property", "=", "(", "\"bright\"", ...
[ 447, 4 ]
[ 456, 51 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.min_mireds
(self)
Return minimum supported color temperature.
Return minimum supported color temperature.
def min_mireds(self): """Return minimum supported color temperature.""" return self._min_mireds
[ "def", "min_mireds", "(", "self", ")", ":", "return", "self", ".", "_min_mireds" ]
[ 459, 4 ]
[ 461, 31 ]
python
en
['ro', 'la', 'en']
False
YeelightGenericLight.max_mireds
(self)
Return maximum supported color temperature.
Return maximum supported color temperature.
def max_mireds(self): """Return maximum supported color temperature.""" return self._max_mireds
[ "def", "max_mireds", "(", "self", ")", ":", "return", "self", ".", "_max_mireds" ]
[ 464, 4 ]
[ 466, 31 ]
python
en
['ro', 'la', 'en']
False
YeelightGenericLight.custom_effects
(self)
Return dict with custom effects.
Return dict with custom effects.
def custom_effects(self): """Return dict with custom effects.""" return self._custom_effects
[ "def", "custom_effects", "(", "self", ")", ":", "return", "self", ".", "_custom_effects" ]
[ 469, 4 ]
[ 471, 35 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.custom_effects_names
(self)
Return list with custom effects names.
Return list with custom effects names.
def custom_effects_names(self): """Return list with custom effects names.""" return list(self.custom_effects)
[ "def", "custom_effects_names", "(", "self", ")", ":", "return", "list", "(", "self", ".", "custom_effects", ")" ]
[ 474, 4 ]
[ 476, 40 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.light_type
(self)
Return light type.
Return light type.
def light_type(self): """Return light type.""" return self._light_type
[ "def", "light_type", "(", "self", ")", ":", "return", "self", ".", "_light_type" ]
[ 479, 4 ]
[ 481, 31 ]
python
en
['es', 'no', 'en']
False
YeelightGenericLight.hs_color
(self)
Return the color property.
Return the color property.
def hs_color(self) -> tuple: """Return the color property.""" hue = self._get_property("hue") sat = self._get_property("sat") if hue is None or sat is None: return None return (int(hue), int(sat))
[ "def", "hs_color", "(", "self", ")", "->", "tuple", ":", "hue", "=", "self", ".", "_get_property", "(", "\"hue\"", ")", "sat", "=", "self", ".", "_get_property", "(", "\"sat\"", ")", "if", "hue", "is", "None", "or", "sat", "is", "None", ":", "return"...
[ 484, 4 ]
[ 491, 35 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.rgb_color
(self)
Return the color property.
Return the color property.
def rgb_color(self) -> tuple: """Return the color property.""" rgb = self._get_property("rgb") if rgb is None: return None rgb = int(rgb) blue = rgb & 0xFF green = (rgb >> 8) & 0xFF red = (rgb >> 16) & 0xFF return (red, green, blue)
[ "def", "rgb_color", "(", "self", ")", "->", "tuple", ":", "rgb", "=", "self", ".", "_get_property", "(", "\"rgb\"", ")", "if", "rgb", "is", "None", ":", "return", "None", "rgb", "=", "int", "(", "rgb", ")", "blue", "=", "rgb", "&", "0xFF", "green",...
[ 494, 4 ]
[ 506, 33 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.effect
(self)
Return the current effect.
Return the current effect.
def effect(self): """Return the current effect.""" if not self.device.is_color_flow_enabled: return None return self._effect
[ "def", "effect", "(", "self", ")", ":", "if", "not", "self", ".", "device", ".", "is_color_flow_enabled", ":", "return", "None", "return", "self", ".", "_effect" ]
[ 509, 4 ]
[ 513, 27 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.extra_state_attributes
(self)
Return the device specific state attributes.
Return the device specific state attributes.
def extra_state_attributes(self): """Return the device specific state attributes.""" attributes = { "flowing": self.device.is_color_flow_enabled, "music_mode": self._bulb.music_mode, } if self.device.is_nightlight_supported: attributes["night_light"] ...
[ "def", "extra_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "\"flowing\"", ":", "self", ".", "device", ".", "is_color_flow_enabled", ",", "\"music_mode\"", ":", "self", ".", "_bulb", ".", "music_mode", ",", "}", "if", "self", ".", "device...
[ 545, 4 ]
[ 555, 25 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.device
(self)
Return yeelight device.
Return yeelight device.
def device(self): """Return yeelight device.""" return self._device
[ "def", "device", "(", "self", ")", ":", "return", "self", ".", "_device" ]
[ 558, 4 ]
[ 560, 27 ]
python
en
['en', 'tr', 'en']
True
YeelightGenericLight.async_update
(self)
Update light properties.
Update light properties.
async def async_update(self): """Update light properties.""" await self.device.async_update()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "device", ".", "async_update", "(", ")" ]
[ 562, 4 ]
[ 564, 40 ]
python
en
['it', 'lb', 'en']
False
YeelightGenericLight.set_music_mode
(self, music_mode)
Set the music mode on or off.
Set the music mode on or off.
def set_music_mode(self, music_mode) -> None: """Set the music mode on or off.""" if music_mode: try: self._bulb.start_music() except AssertionError as ex: _LOGGER.error(ex) else: self._bulb.stop_music()
[ "def", "set_music_mode", "(", "self", ",", "music_mode", ")", "->", "None", ":", "if", "music_mode", ":", "try", ":", "self", ".", "_bulb", ".", "start_music", "(", ")", "except", "AssertionError", "as", "ex", ":", "_LOGGER", ".", "error", "(", "ex", "...
[ 566, 4 ]
[ 574, 35 ]
python
en
['en', 'en', 'en']
True
YeelightGenericLight.async_set_brightness
(self, brightness, duration)
Set bulb brightness.
Set bulb brightness.
async def async_set_brightness(self, brightness, duration) -> None: """Set bulb brightness.""" if brightness: if math.floor(self.brightness) == math.floor(brightness): _LOGGER.debug("brightness already set to: %s", brightness) # Already set, and since we get p...
[ "async", "def", "async_set_brightness", "(", "self", ",", "brightness", ",", "duration", ")", "->", "None", ":", "if", "brightness", ":", "if", "math", ".", "floor", "(", "self", ".", "brightness", ")", "==", "math", ".", "floor", "(", "brightness", ")",...
[ 577, 4 ]
[ 590, 13 ]
python
bg
['nl', 'bg', 'en']
False
YeelightGenericLight.async_set_hs
(self, hs_color, duration)
Set bulb's color.
Set bulb's color.
async def async_set_hs(self, hs_color, duration) -> None: """Set bulb's color.""" if hs_color and COLOR_MODE_HS in self.supported_color_modes: if self.color_mode == COLOR_MODE_HS and self.hs_color == hs_color: _LOGGER.debug("HS already set to: %s", hs_color) #...
[ "async", "def", "async_set_hs", "(", "self", ",", "hs_color", ",", "duration", ")", "->", "None", ":", "if", "hs_color", "and", "COLOR_MODE_HS", "in", "self", ".", "supported_color_modes", ":", "if", "self", ".", "color_mode", "==", "COLOR_MODE_HS", "and", "...
[ 593, 4 ]
[ 606, 13 ]
python
en
['en', 'fr', 'en']
True
YeelightGenericLight.async_set_rgb
(self, rgb, duration)
Set bulb's color.
Set bulb's color.
async def async_set_rgb(self, rgb, duration) -> None: """Set bulb's color.""" if rgb and COLOR_MODE_RGB in self.supported_color_modes: if self.color_mode == COLOR_MODE_RGB and self.rgb_color == rgb: _LOGGER.debug("RGB already set to: %s", rgb) # Already set, a...
[ "async", "def", "async_set_rgb", "(", "self", ",", "rgb", ",", "duration", ")", "->", "None", ":", "if", "rgb", "and", "COLOR_MODE_RGB", "in", "self", ".", "supported_color_modes", ":", "if", "self", ".", "color_mode", "==", "COLOR_MODE_RGB", "and", "self", ...
[ 609, 4 ]
[ 622, 13 ]
python
en
['en', 'fr', 'en']
True
YeelightGenericLight.async_set_colortemp
(self, colortemp, duration)
Set bulb's color temperature.
Set bulb's color temperature.
async def async_set_colortemp(self, colortemp, duration) -> None: """Set bulb's color temperature.""" if colortemp and COLOR_MODE_COLOR_TEMP in self.supported_color_modes: temp_in_k = mired_to_kelvin(colortemp) if ( self.color_mode == COLOR_MODE_COLOR_TEMP ...
[ "async", "def", "async_set_colortemp", "(", "self", ",", "colortemp", ",", "duration", ")", "->", "None", ":", "if", "colortemp", "and", "COLOR_MODE_COLOR_TEMP", "in", "self", ".", "supported_color_modes", ":", "temp_in_k", "=", "mired_to_kelvin", "(", "colortemp"...
[ 625, 4 ]
[ 642, 13 ]
python
en
['en', 'ca', 'en']
True
YeelightGenericLight.async_set_default
(self)
Set current options as default.
Set current options as default.
async def async_set_default(self) -> None: """Set current options as default.""" await self._bulb.async_set_default()
[ "async", "def", "async_set_default", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_bulb", ".", "async_set_default", "(", ")" ]
[ 645, 4 ]
[ 647, 44 ]
python
en
['en', 'da', 'en']
True
YeelightGenericLight.async_set_flash
(self, flash)
Activate flash.
Activate flash.
async def async_set_flash(self, flash) -> None: """Activate flash.""" if flash: if int(self._bulb.last_properties["color_mode"]) != 1: _LOGGER.error("Flash supported currently only in RGB mode") return transition = int(self.config[CONF_TRANSITION]...
[ "async", "def", "async_set_flash", "(", "self", ",", "flash", ")", "->", "None", ":", "if", "flash", ":", "if", "int", "(", "self", ".", "_bulb", ".", "last_properties", "[", "\"color_mode\"", "]", ")", "!=", "1", ":", "_LOGGER", ".", "error", "(", "...
[ 650, 4 ]
[ 682, 60 ]
python
en
['en', 'la', 'en']
False
YeelightGenericLight.async_set_effect
(self, effect)
Activate effect.
Activate effect.
async def async_set_effect(self, effect) -> None: """Activate effect.""" if not effect: return if effect == EFFECT_STOP: await self._bulb.async_stop_flow(light_type=self.light_type) return if effect in self.custom_effects_names: flow = Fl...
[ "async", "def", "async_set_effect", "(", "self", ",", "effect", ")", "->", "None", ":", "if", "not", "effect", ":", "return", "if", "effect", "==", "EFFECT_STOP", ":", "await", "self", ".", "_bulb", ".", "async_stop_flow", "(", "light_type", "=", "self", ...
[ 685, 4 ]
[ 713, 57 ]
python
en
['es', 'en', 'en']
False
YeelightGenericLight.async_turn_on
(self, **kwargs)
Turn the bulb on.
Turn the bulb on.
async def async_turn_on(self, **kwargs) -> None: """Turn the bulb on.""" brightness = kwargs.get(ATTR_BRIGHTNESS) colortemp = kwargs.get(ATTR_COLOR_TEMP) hs_color = kwargs.get(ATTR_HS_COLOR) rgb = kwargs.get(ATTR_RGB_COLOR) flash = kwargs.get(ATTR_FLASH) effect = ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "brightness", "=", "kwargs", ".", "get", "(", "ATTR_BRIGHTNESS", ")", "colortemp", "=", "kwargs", ".", "get", "(", "ATTR_COLOR_TEMP", ")", "hs_color", "=", "kw...
[ 715, 4 ]
[ 767, 48 ]
python
en
['en', 'ga', 'en']
True
YeelightGenericLight.async_set_mode
(self, mode: str)
Set a power mode.
Set a power mode.
async def async_set_mode(self, mode: str): """Set a power mode.""" try: await self._bulb.async_set_power_mode(PowerMode[mode.upper()]) except BULB_EXCEPTIONS as ex: _LOGGER.error("Unable to set the power mode: %s", ex)
[ "async", "def", "async_set_mode", "(", "self", ",", "mode", ":", "str", ")", ":", "try", ":", "await", "self", ".", "_bulb", ".", "async_set_power_mode", "(", "PowerMode", "[", "mode", ".", "upper", "(", ")", "]", ")", "except", "BULB_EXCEPTIONS", "as", ...
[ 783, 4 ]
[ 788, 65 ]
python
en
['en', 'lb', 'en']
True
YeelightGenericLight.async_start_flow
(self, transitions, count=0, action=ACTION_RECOVER)
Start flow.
Start flow.
async def async_start_flow(self, transitions, count=0, action=ACTION_RECOVER): """Start flow.""" try: flow = Flow( count=count, action=Flow.actions[action], transitions=transitions ) await self._bulb.async_start_flow(flow, light_type=self.light_type) ...
[ "async", "def", "async_start_flow", "(", "self", ",", "transitions", ",", "count", "=", "0", ",", "action", "=", "ACTION_RECOVER", ")", ":", "try", ":", "flow", "=", "Flow", "(", "count", "=", "count", ",", "action", "=", "Flow", ".", "actions", "[", ...
[ 790, 4 ]
[ 799, 57 ]
python
en
['en', 'de', 'en']
False
YeelightGenericLight.async_set_scene
(self, scene_class, *args)
Set the light directly to the specified state. If the light is off, it will first be turned on.
Set the light directly to the specified state.
async def async_set_scene(self, scene_class, *args): """ Set the light directly to the specified state. If the light is off, it will first be turned on. """ try: await self._bulb.async_set_scene(scene_class, *args) except BULB_EXCEPTIONS as ex: _L...
[ "async", "def", "async_set_scene", "(", "self", ",", "scene_class", ",", "*", "args", ")", ":", "try", ":", "await", "self", ".", "_bulb", ".", "async_set_scene", "(", "scene_class", ",", "*", "args", ")", "except", "BULB_EXCEPTIONS", "as", "ex", ":", "_...
[ 801, 4 ]
[ 810, 56 ]
python
en
['en', 'error', 'th']
False
YeelightColorLightSupport.color_mode
(self)
Return the color mode.
Return the color mode.
def color_mode(self): """Return the color mode.""" color_mode = int(self._get_property("color_mode")) if color_mode == 1: # RGB return COLOR_MODE_RGB if color_mode == 2: # color temperature return COLOR_MODE_COLOR_TEMP if color_mode == 3: # hsv ...
[ "def", "color_mode", "(", "self", ")", ":", "color_mode", "=", "int", "(", "self", ".", "_get_property", "(", "\"color_mode\"", ")", ")", "if", "color_mode", "==", "1", ":", "# RGB", "return", "COLOR_MODE_RGB", "if", "color_mode", "==", "2", ":", "# color ...
[ 819, 4 ]
[ 829, 33 ]
python
en
['en', 'en', 'en']
True
YeelightColorLightWithNightlightSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return super().is_on and not self.device.is_nightlight_enabled
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "super", "(", ")", ".", "is_on", "and", "not", "self", ".", "device", ".", "is_nightlight_enabled" ]
[ 879, 4 ]
[ 881, 70 ]
python
en
['en', 'fy', 'en']
True
YeelightWithNightLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return super().is_on and not self.device.is_nightlight_enabled
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "super", "(", ")", ".", "is_on", "and", "not", "self", ".", "device", ".", "is_nightlight_enabled" ]
[ 908, 4 ]
[ 910, 70 ]
python
en
['en', 'fy', 'en']
True
YeelightNightLightMode.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" unique = super().unique_id return f"{unique}-nightlight"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "unique", "=", "super", "(", ")", ".", "unique_id", "return", "f\"{unique}-nightlight\"" ]
[ 917, 4 ]
[ 920, 37 ]
python
ca
['fr', 'ca', 'en']
False
YeelightNightLightMode.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self) -> str: """Return the name of the device if any.""" return f"{self.device.name} Nightlight"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self.device.name} Nightlight\"" ]
[ 923, 4 ]
[ 925, 47 ]
python
en
['en', 'en', 'en']
True
YeelightNightLightMode.icon
(self)
Return the icon to use in the frontend, if any.
Return the icon to use in the frontend, if any.
def icon(self): """Return the icon to use in the frontend, if any.""" return "mdi:weather-night"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:weather-night\"" ]
[ 928, 4 ]
[ 930, 34 ]
python
en
['en', 'en', 'en']
True
YeelightNightLightMode.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self) -> bool: """Return true if device is on.""" return super().is_on and self.device.is_nightlight_enabled
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "super", "(", ")", ".", "is_on", "and", "self", ".", "device", ".", "is_nightlight_enabled" ]
[ 933, 4 ]
[ 935, 66 ]
python
en
['en', 'fy', 'en']
True
YeelightNightLightModeWithoutBrightnessControl.supported_features
(self)
Flag no supported features.
Flag no supported features.
def supported_features(self): """Flag no supported features.""" return 0
[ "def", "supported_features", "(", "self", ")", ":", "return", "0" ]
[ 968, 4 ]
[ 970, 16 ]
python
en
['en', 'en', 'en']
True
YeelightAmbientLight.__init__
(self, *args, **kwargs)
Initialize the Yeelight Ambient light.
Initialize the Yeelight Ambient light.
def __init__(self, *args, **kwargs): """Initialize the Yeelight Ambient light.""" super().__init__(*args, **kwargs) self._min_mireds = kelvin_to_mired(6500) self._max_mireds = kelvin_to_mired(1700) self._light_type = LightType.Ambient
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "_min_mireds", "=", "kelvin_to_mired", "(", "6500", ")", "self", ...
[ 1000, 4 ]
[ 1006, 44 ]
python
en
['en', 'en', 'en']
True
YeelightAmbientLight.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" unique = super().unique_id return f"{unique}-ambilight"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "unique", "=", "super", "(", ")", ".", "unique_id", "return", "f\"{unique}-ambilight\"" ]
[ 1009, 4 ]
[ 1012, 36 ]
python
ca
['fr', 'ca', 'en']
False
YeelightAmbientLight.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self) -> str: """Return the name of the device if any.""" return f"{self.device.name} Ambilight"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self.device.name} Ambilight\"" ]
[ 1015, 4 ]
[ 1017, 46 ]
python
en
['en', 'en', 'en']
True
async_get_service
(hass, config, discovery_info=None)
Return the notify service.
Return the notify service.
async def async_get_service(hass, config, discovery_info=None): """Return the notify service.""" client = hass.data[DOMAIN] return KebaNotificationService(client)
[ "async", "def", "async_get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "client", "=", "hass", ".", "data", "[", "DOMAIN", "]", "return", "KebaNotificationService", "(", "client", ")" ]
[ 6, 0 ]
[ 10, 42 ]
python
en
['en', 'en', 'en']
True
KebaNotificationService.__init__
(self, client)
Initialize the service.
Initialize the service.
def __init__(self, client): """Initialize the service.""" self._client = client
[ "def", "__init__", "(", "self", ",", "client", ")", ":", "self", ".", "_client", "=", "client" ]
[ 16, 4 ]
[ 18, 29 ]
python
en
['en', 'en', 'en']
True
KebaNotificationService.async_send_message
(self, message="", **kwargs)
Send the message.
Send the message.
async def async_send_message(self, message="", **kwargs): """Send the message.""" text = message.replace(" ", "$") # Will be translated back by the display data = kwargs[ATTR_DATA] or {} min_time = float(data.get("min_time", 2)) max_time = float(data.get("max_time", 10)) ...
[ "async", "def", "async_send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "text", "=", "message", ".", "replace", "(", "\" \"", ",", "\"$\"", ")", "# Will be translated back by the display", "data", "=", "kwargs", "["...
[ 20, 4 ]
[ 28, 61 ]
python
en
['en', 'en', 'en']
True
TestVultrBinarySensorSetup.add_entities
(self, devices, action)
Mock add devices.
Mock add devices.
def add_entities(self, devices, action): """Mock add devices.""" for device in devices: self.DEVICES.append(device)
[ "def", "add_entities", "(", "self", ",", "devices", ",", "action", ")", ":", "for", "device", "in", "devices", ":", "self", ".", "DEVICES", ".", "append", "(", "device", ")" ]
[ 31, 4 ]
[ 34, 39 ]
python
en
['es', 'en', 'en']
True
TestVultrBinarySensorSetup.setUp
(self)
Init values for this testcase class.
Init values for this testcase class.
def setUp(self): """Init values for this testcase class.""" self.hass = get_test_home_assistant() self.configs = [ {CONF_SUBSCRIPTION: "576965", CONF_NAME: "A Server"}, {CONF_SUBSCRIPTION: "123456", CONF_NAME: "Failed Server"}, {CONF_SUBSCRIPTION: "555555", CO...
[ "def", "setUp", "(", "self", ")", ":", "self", ".", "hass", "=", "get_test_home_assistant", "(", ")", "self", ".", "configs", "=", "[", "{", "CONF_SUBSCRIPTION", ":", "\"576965\"", ",", "CONF_NAME", ":", "\"A Server\"", "}", ",", "{", "CONF_SUBSCRIPTION", ...
[ 36, 4 ]
[ 44, 47 ]
python
en
['en', 'en', 'en']
True
TestVultrBinarySensorSetup.tear_down_cleanup
(self)
Stop our started services.
Stop our started services.
def tear_down_cleanup(self): """Stop our started services.""" self.hass.stop()
[ "def", "tear_down_cleanup", "(", "self", ")", ":", "self", ".", "hass", ".", "stop", "(", ")" ]
[ 46, 4 ]
[ 48, 24 ]
python
en
['de', 'en', 'en']
True
TestVultrBinarySensorSetup.test_binary_sensor
(self, mock)
Test successful instance.
Test successful instance.
def test_binary_sensor(self, mock): """Test successful instance.""" mock.get( "https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567", text=load_fixture("vultr_account_info.json"), ) with patch( "vultr.Vultr.server_list", return_val...
[ "def", "test_binary_sensor", "(", "self", ",", "mock", ")", ":", "mock", ".", "get", "(", "\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"", ",", "text", "=", "load_fixture", "(", "\"vultr_account_info.json\"", ")", ",", ")", "with", "patch", "(", "...
[ 51, 4 ]
[ 103, 69 ]
python
en
['en', 'ro', 'en']
True