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
write_to_version_file
(filename, versions)
Write the given version number to the given _version.py file.
Write the given version number to the given _version.py file.
def write_to_version_file(filename, versions): """Write the given version number to the given _version.py file.""" os.unlink(filename) contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) with open(filename, "w") as f: f.write(SHORT_VERSION_...
[ "def", "write_to_version_file", "(", "filename", ",", "versions", ")", ":", "os", ".", "unlink", "(", "filename", ")", "contents", "=", "json", ".", "dumps", "(", "versions", ",", "sort_keys", "=", "True", ",", "indent", "=", "1", ",", "separators", "=",...
[ 1217, 0 ]
[ 1225, 61 ]
python
en
['en', 'en', 'en']
True
plus_or_dot
(pieces)
Return a + if we don't already have one, else return a .
Return a + if we don't already have one, else return a .
def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+"
[ "def", "plus_or_dot", "(", "pieces", ")", ":", "if", "\"+\"", "in", "pieces", ".", "get", "(", "\"closest-tag\"", ",", "\"\"", ")", ":", "return", "\".\"", "return", "\"+\"" ]
[ 1228, 0 ]
[ 1232, 14 ]
python
en
['en', 'en', 'en']
True
render_pep440
(pieces)
Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty Exceptions: 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
Build up version string, with post-release "local version identifier".
def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty Exceptions: 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHE...
[ "def", "render_pep440", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", "or", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=...
[ 1235, 0 ]
[ 1257, 19 ]
python
en
['en', 'en', 'en']
True
render_pep440_pre
(pieces)
TAG[.post.devDISTANCE] -- No -dirty. Exceptions: 1: no tags. 0.post.devDISTANCE
TAG[.post.devDISTANCE] -- No -dirty.
def render_pep440_pre(pieces): """TAG[.post.devDISTANCE] -- No -dirty. Exceptions: 1: no tags. 0.post.devDISTANCE """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered += ".post.dev%d" % pieces["distance"] else: # exce...
[ "def", "render_pep440_pre", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", ":", "rendered", "+=", "\".post.dev%d\"", "%", "pieces", ...
[ 1260, 0 ]
[ 1273, 19 ]
python
en
['en', 'en', 'pt']
True
render_pep440_post
(pieces)
TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards (a dirty tree will appear "older" than the corresponding clean one), but you shouldn't be releasing software with -dirty anyways. Exceptions: 1: no tags. 0.postDISTANCE[.dev0]
TAG[.postDISTANCE[.dev0]+gHEX] .
def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards (a dirty tree will appear "older" than the corresponding clean one), but you shouldn't be releasing software with -dirty anyways. Exceptions: 1: no tags. 0.postDISTANCE[...
[ "def", "render_pep440_post", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", "or", "pieces", "[", "\"dirty\"", "]", ":", "rendered", ...
[ 1276, 0 ]
[ 1300, 19 ]
python
cy
['en', 'cy', 'hi']
False
render_pep440_old
(pieces)
TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. Eexceptions: 1: no tags. 0.postDISTANCE[.dev0]
TAG[.postDISTANCE[.dev0]] .
def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. Eexceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % pie...
[ "def", "render_pep440_old", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", "or", "pieces", "[", "\"dirty\"", "]", ":", "rendered", ...
[ 1303, 0 ]
[ 1322, 19 ]
python
en
['en', 'mt', 'hi']
False
render_git_describe
(pieces)
TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix)
TAG[-DISTANCE-gHEX][-dirty].
def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered +=...
[ "def", "render_git_describe", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", ":", "rendered", "+=", "\"-%d-g%s\"", "%", "(", "pieces...
[ 1325, 0 ]
[ 1342, 19 ]
python
en
['en', 'en', 'en']
False
render_git_describe_long
(pieces)
TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix)
TAG-DISTANCE-gHEX[-dirty].
def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] ...
[ "def", "render_git_describe_long", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "rendered", "+=", "\"-%d-g%s\"", "%", "(", "pieces", "[", "\"distance\"", "]", ",", "pieces", ...
[ 1345, 0 ]
[ 1362, 19 ]
python
en
['en', 'en', 'pt']
False
render
(pieces, style)
Render the given version pieces into the requested style.
Render the given version pieces into the requested style.
def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", "full-revisionid": pieces.get("long"), "dirty": None, "error": pieces["error"], "date": None} ...
[ "def", "render", "(", "pieces", ",", "style", ")", ":", "if", "pieces", "[", "\"error\"", "]", ":", "return", "{", "\"version\"", ":", "\"unknown\"", ",", "\"full-revisionid\"", ":", "pieces", ".", "get", "(", "\"long\"", ")", ",", "\"dirty\"", ":", "Non...
[ 1365, 0 ]
[ 1394, 39 ]
python
en
['en', 'en', 'en']
True
get_versions
(verbose=False)
Get the project version from whatever source is available. Returns dict with two keys: 'version' and 'full'.
Get the project version from whatever source is available.
def get_versions(verbose=False): """Get the project version from whatever source is available. Returns dict with two keys: 'version' and 'full'. """ if "versioneer" in sys.modules: # see the discussion in cmdclass.py:get_cmdclass() del sys.modules["versioneer"] root = get_root() ...
[ "def", "get_versions", "(", "verbose", "=", "False", ")", ":", "if", "\"versioneer\"", "in", "sys", ".", "modules", ":", "# see the discussion in cmdclass.py:get_cmdclass()", "del", "sys", ".", "modules", "[", "\"versioneer\"", "]", "root", "=", "get_root", "(", ...
[ 1401, 0 ]
[ 1474, 25 ]
python
en
['en', 'en', 'en']
True
get_version
()
Get the short version string for this project.
Get the short version string for this project.
def get_version(): """Get the short version string for this project.""" return get_versions()["version"]
[ "def", "get_version", "(", ")", ":", "return", "get_versions", "(", ")", "[", "\"version\"", "]" ]
[ 1477, 0 ]
[ 1479, 36 ]
python
en
['en', 'en', 'en']
True
get_cmdclass
()
Get the custom setuptools/distutils subclasses used by Versioneer.
Get the custom setuptools/distutils subclasses used by Versioneer.
def get_cmdclass(): """Get the custom setuptools/distutils subclasses used by Versioneer.""" if "versioneer" in sys.modules: del sys.modules["versioneer"] # this fixes the "python setup.py develop" case (also 'install' and # 'easy_install .'), in which subdependencies of the main project...
[ "def", "get_cmdclass", "(", ")", ":", "if", "\"versioneer\"", "in", "sys", ".", "modules", ":", "del", "sys", ".", "modules", "[", "\"versioneer\"", "]", "# this fixes the \"python setup.py develop\" case (also 'install' and", "# 'easy_install .'), in which subdependencies of...
[ 1482, 0 ]
[ 1649, 15 ]
python
en
['en', 'et', 'en']
True
do_setup
()
Main VCS-independent setup function for installing Versioneer.
Main VCS-independent setup function for installing Versioneer.
def do_setup(): """Main VCS-independent setup function for installing Versioneer.""" root = get_root() try: cfg = get_config_from_root(root) except (EnvironmentError, configparser.NoSectionError, configparser.NoOptionError) as e: if isinstance(e, (EnvironmentError, configpars...
[ "def", "do_setup", "(", ")", ":", "root", "=", "get_root", "(", ")", "try", ":", "cfg", "=", "get_config_from_root", "(", "root", ")", "except", "(", "EnvironmentError", ",", "configparser", ".", "NoSectionError", ",", "configparser", ".", "NoOptionError", "...
[ 1696, 0 ]
[ 1775, 12 ]
python
en
['en', 'en', 'en']
True
scan_setup_py
()
Validate the contents of setup.py against Versioneer's expectations.
Validate the contents of setup.py against Versioneer's expectations.
def scan_setup_py(): """Validate the contents of setup.py against Versioneer's expectations.""" found = set() setters = False errors = 0 with open("setup.py", "r") as f: for line in f.readlines(): if "import versioneer" in line: found.add("import") if ...
[ "def", "scan_setup_py", "(", ")", ":", "found", "=", "set", "(", ")", "setters", "=", "False", "errors", "=", "0", "with", "open", "(", "\"setup.py\"", ",", "\"r\"", ")", "as", "f", ":", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", ...
[ 1778, 0 ]
[ 1812, 17 ]
python
en
['en', 'en', 'en']
True
test_entity_registry
(hass)
Tests that the devices are registered in the entity registry.
Tests that the devices are registered in the entity registry.
async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, LIGHT_DOMAIN) entity_registry = await hass.helpers.entity_registry.async_get_registry() entry = entity_registry.async_get(DEVICE_ID) assert entry.unique_id == "741385...
[ "async", "def", "test_entity_registry", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "entity_registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "entry", "=", ...
[ 24, 0 ]
[ 30, 64 ]
python
en
['en', 'en', 'en']
True
test_attributes
(hass)
Test the light attributes are correct.
Test the light attributes are correct.
async def test_attributes(hass): """Test the light attributes are correct.""" await setup_platform(hass, LIGHT_DOMAIN) state = hass.states.get(DEVICE_ID) assert state.state == STATE_ON assert state.attributes.get(ATTR_BRIGHTNESS) == 204 assert state.attributes.get(ATTR_RGB_COLOR) == (0, 63, 255...
[ "async", "def", "test_attributes", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "DEVICE_ID", ")", "assert", "state", ".", "state", "==", "STATE_ON", "assert",...
[ 33, 0 ]
[ 47, 62 ]
python
en
['en', 'en', 'en']
True
test_switch_off
(hass)
Test the light can be turned off.
Test the light can be turned off.
async def test_switch_off(hass): """Test the light can be turned off.""" await setup_platform(hass, LIGHT_DOMAIN) with patch("abodepy.AbodeLight.switch_off") as mock_switch_off: assert await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DEVICE_ID}, blocking=...
[ "async", "def", "test_switch_off", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeLight.switch_off\"", ")", "as", "mock_switch_off", ":", "assert", "await", "hass", ".", "services", ...
[ 50, 0 ]
[ 59, 44 ]
python
en
['en', 'en', 'en']
True
test_switch_on
(hass)
Test the light can be turned on.
Test the light can be turned on.
async def test_switch_on(hass): """Test the light can be turned on.""" await setup_platform(hass, LIGHT_DOMAIN) with patch("abodepy.AbodeLight.switch_on") as mock_switch_on: await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DEVICE_ID}, blocking=True ...
[ "async", "def", "test_switch_on", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeLight.switch_on\"", ")", "as", "mock_switch_on", ":", "await", "hass", ".", "services", ".", "async_c...
[ 62, 0 ]
[ 71, 43 ]
python
en
['en', 'en', 'en']
True
test_set_brightness
(hass)
Test the brightness can be set.
Test the brightness can be set.
async def test_set_brightness(hass): """Test the brightness can be set.""" await setup_platform(hass, LIGHT_DOMAIN) with patch("abodepy.AbodeLight.set_level") as mock_set_level: await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DEVIC...
[ "async", "def", "test_set_brightness", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeLight.set_level\"", ")", "as", "mock_set_level", ":", "await", "hass", ".", "services", ".", "as...
[ 74, 0 ]
[ 87, 50 ]
python
en
['en', 'en', 'en']
True
test_set_color
(hass)
Test the color can be set.
Test the color can be set.
async def test_set_color(hass): """Test the color can be set.""" await setup_platform(hass, LIGHT_DOMAIN) with patch("abodepy.AbodeLight.set_color") as mock_set_color: await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DEVICE_ID, "hs_...
[ "async", "def", "test_set_color", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeLight.set_color\"", ")", "as", "mock_set_color", ":", "await", "hass", ".", "services", ".", "async_c...
[ 90, 0 ]
[ 102, 62 ]
python
en
['en', 'en', 'en']
True
test_set_color_temp
(hass)
Test the color temp can be set.
Test the color temp can be set.
async def test_set_color_temp(hass): """Test the color temp can be set.""" await setup_platform(hass, LIGHT_DOMAIN) with patch("abodepy.AbodeLight.set_color_temp") as mock_set_color_temp: await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY...
[ "async", "def", "test_set_color_temp", "(", "hass", ")", ":", "await", "setup_platform", "(", "hass", ",", "LIGHT_DOMAIN", ")", "with", "patch", "(", "\"abodepy.AbodeLight.set_color_temp\"", ")", "as", "mock_set_color_temp", ":", "await", "hass", ".", "services", ...
[ 105, 0 ]
[ 118, 57 ]
python
en
['en', 'en', 'en']
True
CanaryDataUpdateCoordinator.__init__
(self, hass: HomeAssistantType, *, api: Api)
Initialize global Canary data updater.
Initialize global Canary data updater.
def __init__(self, hass: HomeAssistantType, *, api: Api): """Initialize global Canary data updater.""" self.canary = api update_interval = timedelta(seconds=30) super().__init__( hass, _LOGGER, name=DOMAIN, update_interval=update_interval,...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ",", "*", ",", "api", ":", "Api", ")", ":", "self", ".", "canary", "=", "api", "update_interval", "=", "timedelta", "(", "seconds", "=", "30", ")", "super", "(", ")", ".", "__init...
[ 19, 4 ]
[ 29, 9 ]
python
en
['en', 'en', 'en']
True
CanaryDataUpdateCoordinator._update_data
(self)
Fetch data from Canary via sync functions.
Fetch data from Canary via sync functions.
def _update_data(self) -> dict: """Fetch data from Canary via sync functions.""" locations_by_id = {} readings_by_device_id = {} for location in self.canary.get_locations(): location_id = location.location_id locations_by_id[location_id] = location f...
[ "def", "_update_data", "(", "self", ")", "->", "dict", ":", "locations_by_id", "=", "{", "}", "readings_by_device_id", "=", "{", "}", "for", "location", "in", "self", ".", "canary", ".", "get_locations", "(", ")", ":", "location_id", "=", "location", ".", ...
[ 31, 4 ]
[ 49, 9 ]
python
en
['en', 'en', 'en']
True
CanaryDataUpdateCoordinator._async_update_data
(self)
Fetch data from Canary.
Fetch data from Canary.
async def _async_update_data(self) -> dict: """Fetch data from Canary.""" try: async with timeout(15): return await self.hass.async_add_executor_job(self._update_data) except (ConnectTimeout, HTTPError) as error: raise UpdateFailed(f"Invalid response from...
[ "async", "def", "_async_update_data", "(", "self", ")", "->", "dict", ":", "try", ":", "async", "with", "timeout", "(", "15", ")", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_update_data", ")", "except", ...
[ 51, 4 ]
[ 58, 80 ]
python
en
['en', 'en', 'en']
True
valid_topic
(value: Any)
Validate that this is a valid topic name/filter.
Validate that this is a valid topic name/filter.
def valid_topic(value: Any) -> str: """Validate that this is a valid topic name/filter.""" value = cv.string(value) try: raw_value = value.encode("utf-8") except UnicodeError as err: raise vol.Invalid("MQTT topic name/filter must be valid UTF-8 string.") from err if not raw_value: ...
[ "def", "valid_topic", "(", "value", ":", "Any", ")", "->", "str", ":", "value", "=", "cv", ".", "string", "(", "value", ")", "try", ":", "raw_value", "=", "value", ".", "encode", "(", "\"utf-8\"", ")", "except", "UnicodeError", "as", "err", ":", "rai...
[ 18, 0 ]
[ 33, 16 ]
python
en
['en', 'en', 'en']
True
valid_subscribe_topic
(value: Any)
Validate that we can subscribe using this MQTT topic.
Validate that we can subscribe using this MQTT topic.
def valid_subscribe_topic(value: Any) -> str: """Validate that we can subscribe using this MQTT topic.""" value = valid_topic(value) for i in (i for i, c in enumerate(value) if c == "+"): if (i > 0 and value[i - 1] != "/") or ( i < len(value) - 1 and value[i + 1] != "/" ): ...
[ "def", "valid_subscribe_topic", "(", "value", ":", "Any", ")", "->", "str", ":", "value", "=", "valid_topic", "(", "value", ")", "for", "i", "in", "(", "i", "for", "i", ",", "c", "in", "enumerate", "(", "value", ")", "if", "c", "==", "\"+\"", ")", ...
[ 36, 0 ]
[ 60, 16 ]
python
en
['en', 'en', 'en']
True
valid_publish_topic
(value: Any)
Validate that we can publish using this MQTT topic.
Validate that we can publish using this MQTT topic.
def valid_publish_topic(value: Any) -> str: """Validate that we can publish using this MQTT topic.""" value = valid_topic(value) if "+" in value or "#" in value: raise vol.Invalid("Wildcards can not be used in topic names") return value
[ "def", "valid_publish_topic", "(", "value", ":", "Any", ")", "->", "str", ":", "value", "=", "valid_topic", "(", "value", ")", "if", "\"+\"", "in", "value", "or", "\"#\"", "in", "value", ":", "raise", "vol", ".", "Invalid", "(", "\"Wildcards can not be use...
[ 63, 0 ]
[ 68, 16 ]
python
en
['en', 'en', 'en']
True
test_entity_and_device_attributes
(hass, device_factory)
Test the attributes of the entity are correct.
Test the attributes of the entity are correct.
async def test_entity_and_device_attributes(hass, device_factory): """Test the attributes of the entity are correct.""" # Arrange device = device_factory("Lock_1", [Capability.lock], {Attribute.lock: "unlocked"}) entity_registry = await hass.helpers.entity_registry.async_get_registry() device_regist...
[ "async", "def", "test_entity_and_device_attributes", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Lock_1\"", ",", "[", "Capability", ".", "lock", "]", ",", "{", "Attribute", ".", "lock", ":", "\"unlocked\"",...
[ 16, 0 ]
[ 33, 46 ]
python
en
['en', 'en', 'en']
True
test_lock
(hass, device_factory)
Test the lock locks successfully.
Test the lock locks successfully.
async def test_lock(hass, device_factory): """Test the lock locks successfully.""" # Arrange device = device_factory("Lock_1", [Capability.lock]) device.status.attributes[Attribute.lock] = Status( "unlocked", None, { "method": "Manual", "codeId": None, ...
[ "async", "def", "test_lock", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Lock_1\"", ",", "[", "Capability", ".", "lock", "]", ")", "device", ".", "status", ".", "attributes", "[", "Attribute", ".", "l...
[ 36, 0 ]
[ 65, 44 ]
python
en
['en', 'zh', 'en']
True
test_unlock
(hass, device_factory)
Test the lock unlocks successfully.
Test the lock unlocks successfully.
async def test_unlock(hass, device_factory): """Test the lock unlocks successfully.""" # Arrange device = device_factory("Lock_1", [Capability.lock], {Attribute.lock: "locked"}) await setup_platform(hass, LOCK_DOMAIN, devices=[device]) # Act await hass.services.async_call( LOCK_DOMAIN, "...
[ "async", "def", "test_unlock", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Lock_1\"", ",", "[", "Capability", ".", "lock", "]", ",", "{", "Attribute", ".", "lock", ":", "\"locked\"", "}", ")", "await"...
[ 68, 0 ]
[ 80, 36 ]
python
en
['en', 'zh', 'en']
True
test_update_from_signal
(hass, device_factory)
Test the lock updates when receiving a signal.
Test the lock updates when receiving a signal.
async def test_update_from_signal(hass, device_factory): """Test the lock updates when receiving a signal.""" # Arrange device = device_factory("Lock_1", [Capability.lock], {Attribute.lock: "unlocked"}) await setup_platform(hass, LOCK_DOMAIN, devices=[device]) await device.lock(True) # Act a...
[ "async", "def", "test_update_from_signal", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Lock_1\"", ",", "[", "Capability", ".", "lock", "]", ",", "{", "Attribute", ".", "lock", ":", "\"unlocked\"", "}", ...
[ 83, 0 ]
[ 95, 34 ]
python
en
['en', 'en', 'en']
True
test_unload_config_entry
(hass, device_factory)
Test the lock is removed when the config entry is unloaded.
Test the lock is removed when the config entry is unloaded.
async def test_unload_config_entry(hass, device_factory): """Test the lock is removed when the config entry is unloaded.""" # Arrange device = device_factory("Lock_1", [Capability.lock], {Attribute.lock: "locked"}) config_entry = await setup_platform(hass, LOCK_DOMAIN, devices=[device]) # Act aw...
[ "async", "def", "test_unload_config_entry", "(", "hass", ",", "device_factory", ")", ":", "# Arrange", "device", "=", "device_factory", "(", "\"Lock_1\"", ",", "[", "Capability", ".", "lock", "]", ",", "{", "Attribute", ".", "lock", ":", "\"locked\"", "}", "...
[ 98, 0 ]
[ 106, 45 ]
python
en
['en', 'en', 'en']
True
init
(empty=False)
Initialize the platform with entities.
Initialize the platform with entities.
def init(empty=False): """Initialize the platform with entities.""" global ENTITIES ENTITIES = ( {} if empty else { "arm_code": MockAlarm( name="Alarm arm code", code_arm_required=True, unique_id="unique_arm_code", ...
[ "def", "init", "(", "empty", "=", "False", ")", ":", "global", "ENTITIES", "ENTITIES", "=", "(", "{", "}", "if", "empty", "else", "{", "\"arm_code\"", ":", "MockAlarm", "(", "name", "=", "\"Alarm arm code\"", ",", "code_arm_required", "=", "True", ",", "...
[ 25, 0 ]
[ 44, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, config, async_add_entities_callback, discovery_info=None )
Return mock entities.
Return mock entities.
async def async_setup_platform( hass, config, async_add_entities_callback, discovery_info=None ): """Return mock entities.""" async_add_entities_callback(list(ENTITIES.values()))
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities_callback", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities_callback", "(", "list", "(", "ENTITIES", ".", "values", "(", ")", ")", ")" ]
[ 47, 0 ]
[ 51, 56 ]
python
af
['nl', 'af', 'en']
False
MockAlarm.__init__
(self, **values)
Init the Mock Alarm Control Panel.
Init the Mock Alarm Control Panel.
def __init__(self, **values): """Init the Mock Alarm Control Panel.""" self._state = None MockEntity.__init__(self, **values)
[ "def", "__init__", "(", "self", ",", "*", "*", "values", ")", ":", "self", ".", "_state", "=", "None", "MockEntity", ".", "__init__", "(", "self", ",", "*", "*", "values", ")" ]
[ 57, 4 ]
[ 61, 43 ]
python
en
['en', 'ja', 'en']
True
MockAlarm.code_arm_required
(self)
Whether the code is required for arm actions.
Whether the code is required for arm actions.
def code_arm_required(self): """Whether the code is required for arm actions.""" return self._handle("code_arm_required")
[ "def", "code_arm_required", "(", "self", ")", ":", "return", "self", ".", "_handle", "(", "\"code_arm_required\"", ")" ]
[ 64, 4 ]
[ 66, 48 ]
python
en
['en', 'en', 'en']
True
MockAlarm.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 69, 4 ]
[ 71, 26 ]
python
en
['en', 'en', 'en']
True
MockAlarm.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self) -> int: """Return the list of supported features.""" return ( SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_TRIGGER )
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "(", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY", "|", "SUPPORT_ALARM_ARM_NIGHT", "|", "SUPPORT_ALARM_TRIGGER", ")" ]
[ 74, 4 ]
[ 81, 9 ]
python
en
['en', 'en', 'en']
True
MockAlarm.alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
def alarm_arm_away(self, code=None): """Send arm away command.""" self._state = STATE_ALARM_ARMED_AWAY self.async_write_ha_state()
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_AWAY", "self", ".", "async_write_ha_state", "(", ")" ]
[ 83, 4 ]
[ 86, 35 ]
python
en
['en', 'en', 'en']
True
MockAlarm.alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
def alarm_arm_home(self, code=None): """Send arm home command.""" self._state = STATE_ALARM_ARMED_HOME self.async_write_ha_state()
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_HOME", "self", ".", "async_write_ha_state", "(", ")" ]
[ 88, 4 ]
[ 91, 35 ]
python
en
['en', 'pt', 'en']
True
MockAlarm.alarm_arm_night
(self, code=None)
Send arm night command.
Send arm night command.
def alarm_arm_night(self, code=None): """Send arm night command.""" self._state = STATE_ALARM_ARMED_NIGHT self.async_write_ha_state()
[ "def", "alarm_arm_night", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_ARMED_NIGHT", "self", ".", "async_write_ha_state", "(", ")" ]
[ 93, 4 ]
[ 96, 35 ]
python
en
['en', 'zh', 'en']
True
MockAlarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" if code == "1234": self._state = STATE_ALARM_DISARMED self.async_write_ha_state()
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "if", "code", "==", "\"1234\"", ":", "self", ".", "_state", "=", "STATE_ALARM_DISARMED", "self", ".", "async_write_ha_state", "(", ")" ]
[ 98, 4 ]
[ 102, 39 ]
python
en
['en', 'pt', 'en']
True
MockAlarm.alarm_trigger
(self, code=None)
Send alarm trigger command.
Send alarm trigger command.
def alarm_trigger(self, code=None): """Send alarm trigger command.""" self._state = STATE_ALARM_TRIGGERED self.async_write_ha_state()
[ "def", "alarm_trigger", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_state", "=", "STATE_ALARM_TRIGGERED", "self", ".", "async_write_ha_state", "(", ")" ]
[ 104, 4 ]
[ 107, 35 ]
python
en
['en', 'ca', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the pyLoad sensors.
Set up the pyLoad sensors.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the pyLoad sensors.""" host = config.get(CONF_HOST) port = config.get(CONF_PORT) protocol = "https" if config[CONF_SSL] else "http" name = config.get(CONF_NAME) username = config.get(CONF_USERNAME) password = conf...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "port", "=", "config", ".", "get", "(", "CONF_PORT", ")", "protocol", "=", ...
[ 49, 0 ]
[ 76, 31 ]
python
en
['en', 'bg', 'en']
True
PyLoadSensor.__init__
(self, api, sensor_type, client_name)
Initialize a new pyLoad sensor.
Initialize a new pyLoad sensor.
def __init__(self, api, sensor_type, client_name): """Initialize a new pyLoad sensor.""" self._name = f"{client_name} {sensor_type[1]}" self.type = sensor_type[0] self.api = api self._state = None self._unit_of_measurement = sensor_type[2]
[ "def", "__init__", "(", "self", ",", "api", ",", "sensor_type", ",", "client_name", ")", ":", "self", ".", "_name", "=", "f\"{client_name} {sensor_type[1]}\"", "self", ".", "type", "=", "sensor_type", "[", "0", "]", "self", ".", "api", "=", "api", "self", ...
[ 82, 4 ]
[ 88, 50 ]
python
en
['en', 'ca', 'en']
True
PyLoadSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 91, 4 ]
[ 93, 25 ]
python
en
['en', 'mi', 'en']
True
PyLoadSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 96, 4 ]
[ 98, 26 ]
python
en
['en', 'en', 'en']
True
PyLoadSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 101, 4 ]
[ 103, 40 ]
python
en
['en', 'en', 'en']
True
PyLoadSensor.update
(self)
Update state of sensor.
Update state of sensor.
def update(self): """Update state of sensor.""" try: self.api.update() except requests.exceptions.ConnectionError: # Error calling the API, already logged in api.update() return if self.api.status is None: _LOGGER.debug( "U...
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "api", ".", "update", "(", ")", "except", "requests", ".", "exceptions", ".", "ConnectionError", ":", "# Error calling the API, already logged in api.update()", "return", "if", "self", ".", "api", ...
[ 105, 4 ]
[ 128, 31 ]
python
en
['en', 'co', 'en']
True
PyLoadAPI.__init__
(self, api_url, username=None, password=None)
Initialize pyLoad API and set headers needed later.
Initialize pyLoad API and set headers needed later.
def __init__(self, api_url, username=None, password=None): """Initialize pyLoad API and set headers needed later.""" self.api_url = api_url self.status = None self.headers = {CONTENT_TYPE: CONTENT_TYPE_JSON} if username is not None and password is not None: self.payl...
[ "def", "__init__", "(", "self", ",", "api_url", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "self", ".", "api_url", "=", "api_url", "self", ".", "status", "=", "None", "self", ".", "headers", "=", "{", "CONTENT_TYPE", ":", "...
[ 134, 4 ]
[ 143, 21 ]
python
en
['en', 'en', 'en']
True
PyLoadAPI.post
(self)
Send a POST request and return the response as a dict.
Send a POST request and return the response as a dict.
def post(self): """Send a POST request and return the response as a dict.""" try: response = requests.post( f"{self.api_url}statusServer", cookies=self.login.cookies, headers=self.headers, timeout=5, ) re...
[ "def", "post", "(", "self", ")", ":", "try", ":", "response", "=", "requests", ".", "post", "(", "f\"{self.api_url}statusServer\"", ",", "cookies", "=", "self", ".", "login", ".", "cookies", ",", "headers", "=", "self", ".", "headers", ",", "timeout", "=...
[ 145, 4 ]
[ 160, 17 ]
python
en
['en', 'en', 'en']
True
PyLoadAPI.update
(self)
Update cached response.
Update cached response.
def update(self): """Update cached response.""" self.status = self.post()
[ "def", "update", "(", "self", ")", ":", "self", ".", "status", "=", "self", ".", "post", "(", ")" ]
[ 163, 4 ]
[ 165, 33 ]
python
en
['en', 'en', 'en']
True
default_logdir
()
Same default as PyTorch
Same default as PyTorch
def default_logdir() -> str: """ Same default as PyTorch """ import socket from datetime import datetime current_time = datetime.now().strftime("%b%d_%H-%M-%S") return os.path.join("runs", current_time + "_" + socket.gethostname())
[ "def", "default_logdir", "(", ")", "->", "str", ":", "import", "socket", "from", "datetime", "import", "datetime", "current_time", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%b%d_%H-%M-%S\"", ")", "return", "os", ".", "path", ".", "joi...
[ 45, 0 ]
[ 53, 74 ]
python
en
['en', 'error', 'th']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Air Quality.
Set up the Air Quality.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Air Quality.""" async_add_entities( [DemoAirQuality("Home", 14, 23, 100), DemoAirQuality("Office", 4, 16, None)] )
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities", "(", "[", "DemoAirQuality", "(", "\"Home\"", ",", "14", ",", "23", ",", "100", ")", ",", "DemoA...
[ 4, 0 ]
[ 8, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Demo config entry.
Set up the Demo config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Demo config entry.""" await async_setup_platform(hass, {}, async_add_entities)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "await", "async_setup_platform", "(", "hass", ",", "{", "}", ",", "async_add_entities", ")" ]
[ 11, 0 ]
[ 13, 60 ]
python
en
['en', 'en', 'en']
True
DemoAirQuality.__init__
(self, name, pm_2_5, pm_10, n2o)
Initialize the Demo Air Quality.
Initialize the Demo Air Quality.
def __init__(self, name, pm_2_5, pm_10, n2o): """Initialize the Demo Air Quality.""" self._name = name self._pm_2_5 = pm_2_5 self._pm_10 = pm_10 self._n2o = n2o
[ "def", "__init__", "(", "self", ",", "name", ",", "pm_2_5", ",", "pm_10", ",", "n2o", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_pm_2_5", "=", "pm_2_5", "self", ".", "_pm_10", "=", "pm_10", "self", ".", "_n2o", "=", "n2o" ]
[ 19, 4 ]
[ 24, 23 ]
python
en
['en', 'en', 'en']
True
DemoAirQuality.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"Demo Air Quality {self._name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"Demo Air Quality {self._name}\"" ]
[ 27, 4 ]
[ 29, 47 ]
python
en
['en', 'mi', 'en']
True
DemoAirQuality.should_poll
(self)
No polling needed for Demo Air Quality.
No polling needed for Demo Air Quality.
def should_poll(self): """No polling needed for Demo Air Quality.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 32, 4 ]
[ 34, 20 ]
python
en
['en', 'en', 'en']
True
DemoAirQuality.particulate_matter_2_5
(self)
Return the particulate matter 2.5 level.
Return the particulate matter 2.5 level.
def particulate_matter_2_5(self): """Return the particulate matter 2.5 level.""" return self._pm_2_5
[ "def", "particulate_matter_2_5", "(", "self", ")", ":", "return", "self", ".", "_pm_2_5" ]
[ 37, 4 ]
[ 39, 27 ]
python
en
['en', 'en', 'en']
True
DemoAirQuality.particulate_matter_10
(self)
Return the particulate matter 10 level.
Return the particulate matter 10 level.
def particulate_matter_10(self): """Return the particulate matter 10 level.""" return self._pm_10
[ "def", "particulate_matter_10", "(", "self", ")", ":", "return", "self", ".", "_pm_10" ]
[ 42, 4 ]
[ 44, 26 ]
python
en
['en', 'en', 'en']
True
DemoAirQuality.nitrogen_oxide
(self)
Return the nitrogen oxide (N2O) level.
Return the nitrogen oxide (N2O) level.
def nitrogen_oxide(self): """Return the nitrogen oxide (N2O) level.""" return self._n2o
[ "def", "nitrogen_oxide", "(", "self", ")", ":", "return", "self", ".", "_n2o" ]
[ 47, 4 ]
[ 49, 24 ]
python
en
['en', 'no', 'en']
True
DemoAirQuality.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return "Powered by Home Assistant"
[ "def", "attribution", "(", "self", ")", ":", "return", "\"Powered by Home Assistant\"" ]
[ 52, 4 ]
[ 54, 42 ]
python
en
['en', 'ja', 'en']
True
AdamW.step
(self, closure=None)
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss.
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss.
def step(self, closure=None): """Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for ...
[ "def", "step", "(", "self", ",", "closure", "=", "None", ")", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_groups", ":", "for", "p", "in", "group", ...
[ 128, 4 ]
[ 186, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the MiFlora sensor.
Set up the MiFlora sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the MiFlora sensor.""" backend = BACKEND _LOGGER.debug("Miflora is using %s backend", backend.__name__) cache = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL).total_seconds() poller = miflora_poller.MiFl...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "backend", "=", "BACKEND", "_LOGGER", ".", "debug", "(", "\"Miflora is using %s backend\"", ",", "backend", ".", "__name__"...
[ 82, 0 ]
[ 129, 28 ]
python
en
['en', 'su', 'en']
True
MiFloraSensor.__init__
( self, poller, parameter, name, unit, icon, device_class, force_update, median, go_unavailable_timeout, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, poller, parameter, name, unit, icon, device_class, force_update, median, go_unavailable_timeout, ): """Initialize the sensor.""" self.poller = poller self.parameter = parameter self._u...
[ "def", "__init__", "(", "self", ",", "poller", ",", "parameter", ",", "name", ",", "unit", ",", "icon", ",", "device_class", ",", "force_update", ",", "median", ",", "go_unavailable_timeout", ",", ")", ":", "self", ".", "poller", "=", "poller", "self", "...
[ 135, 4 ]
[ 162, 34 ]
python
en
['en', 'en', 'en']
True
MiFloraSensor.async_added_to_hass
(self)
Set initial state.
Set initial state.
async def async_added_to_hass(self): """Set initial state.""" @callback def on_startup(_): self.async_schedule_update_ha_state(True) self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, on_startup)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "@", "callback", "def", "on_startup", "(", "_", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")", "self", ".", "hass", ".", "bus", ".", "async_listen_once", "(", "EVENT_HO...
[ 164, 4 ]
[ 171, 78 ]
python
en
['da', 'en', 'en']
True
MiFloraSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 174, 4 ]
[ 176, 25 ]
python
en
['en', 'mi', 'en']
True
MiFloraSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 179, 4 ]
[ 181, 26 ]
python
en
['en', 'en', 'en']
True
MiFloraSensor.available
(self)
Return True if did update since 2h.
Return True if did update since 2h.
def available(self): """Return True if did update since 2h.""" return self.last_successful_update > ( dt_util.utcnow() - self.go_unavailable_timeout )
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "last_successful_update", ">", "(", "dt_util", ".", "utcnow", "(", ")", "-", "self", ".", "go_unavailable_timeout", ")" ]
[ 184, 4 ]
[ 188, 9 ]
python
en
['en', 'co', 'en']
True
MiFloraSensor.device_state_attributes
(self)
Return the state attributes of the device.
Return the state attributes of the device.
def device_state_attributes(self): """Return the state attributes of the device.""" return {ATTR_LAST_SUCCESSFUL_UPDATE: self.last_successful_update}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_LAST_SUCCESSFUL_UPDATE", ":", "self", ".", "last_successful_update", "}" ]
[ 191, 4 ]
[ 193, 73 ]
python
en
['en', 'en', 'en']
True
MiFloraSensor.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 196, 4 ]
[ 198, 33 ]
python
en
['en', 'en', 'en']
True
MiFloraSensor.unit_of_measurement
(self)
Return the units of measurement.
Return the units of measurement.
def unit_of_measurement(self): """Return the units of measurement.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 201, 4 ]
[ 203, 25 ]
python
en
['en', 'bg', 'en']
True
MiFloraSensor.icon
(self)
Return the icon of the sensor.
Return the icon of the sensor.
def icon(self): """Return the icon of the sensor.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 206, 4 ]
[ 208, 25 ]
python
en
['en', 'en', 'en']
True
MiFloraSensor.force_update
(self)
Force update.
Force update.
def force_update(self): """Force update.""" return self._force_update
[ "def", "force_update", "(", "self", ")", ":", "return", "self", ".", "_force_update" ]
[ 211, 4 ]
[ 213, 33 ]
python
en
['en', 'en', 'en']
False
MiFloraSensor.update
(self)
Update current conditions. This uses a rolling median over 3 values to filter out outliers.
Update current conditions.
def update(self): """ Update current conditions. This uses a rolling median over 3 values to filter out outliers. """ try: _LOGGER.debug("Polling data for %s", self.name) data = self.poller.parameter_value(self.parameter) except (OSError, Bluetoot...
[ "def", "update", "(", "self", ")", ":", "try", ":", "_LOGGER", ".", "debug", "(", "\"Polling data for %s\"", ",", "self", ".", "name", ")", "data", "=", "self", ".", "poller", ".", "parameter_value", "(", "self", ".", "parameter", ")", "except", "(", "...
[ 215, 4 ]
[ 256, 71 ]
python
en
['en', 'error', 'th']
False
_get_entities_matching_domains
(hass, domains)
List entities in the given domains.
List entities in the given domains.
def _get_entities_matching_domains(hass, domains): """List entities in the given domains.""" included_domains = set(domains) entity_ids = [ state.entity_id for state in hass.states.all() if (split_entity_id(state.entity_id))[0] in included_domains ] entity_ids.sort() retu...
[ "def", "_get_entities_matching_domains", "(", "hass", ",", "domains", ")", ":", "included_domains", "=", "set", "(", "domains", ")", "entity_ids", "=", "[", "state", ".", "entity_id", "for", "state", "in", "hass", ".", "states", ".", "all", "(", ")", "if",...
[ 401, 0 ]
[ 410, 21 ]
python
en
['en', 'en', 'en']
True
_domains_set_from_entities
(entity_ids)
Build a set of domains for the given entity ids.
Build a set of domains for the given entity ids.
def _domains_set_from_entities(entity_ids): """Build a set of domains for the given entity ids.""" domains = set() for entity_id in entity_ids: domains.add(split_entity_id(entity_id)[0]) return domains
[ "def", "_domains_set_from_entities", "(", "entity_ids", ")", ":", "domains", "=", "set", "(", ")", "for", "entity_id", "in", "entity_ids", ":", "domains", ".", "add", "(", "split_entity_id", "(", "entity_id", ")", "[", "0", "]", ")", "return", "domains" ]
[ 413, 0 ]
[ 418, 18 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.__init__
(self)
Initialize config flow.
Initialize config flow.
def __init__(self): """Initialize config flow.""" self.homekit_data = {} self.entry_title = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "homekit_data", "=", "{", "}", "self", ".", "entry_title", "=", "None" ]
[ 91, 4 ]
[ 94, 31 ]
python
en
['de', 'en', 'en']
True
ConfigFlow.async_step_pairing
(self, user_input=None)
Pairing instructions.
Pairing instructions.
async def async_step_pairing(self, user_input=None): """Pairing instructions.""" if user_input is not None: return self.async_create_entry( title=self.entry_title, data=self.homekit_data ) return self.async_show_form( step_id="pairing", ...
[ "async", "def", "async_step_pairing", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "self", ".", "entry_title", ",", "data", "=", "self",...
[ 96, 4 ]
[ 105, 9 ]
python
en
['en', 'en', 'en']
False
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: port = await self._async_available_port() name = self._async_available_name() title = f"{name}:{port}" self.homekit_data = user_...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "port", "=", "await", "self", ".", "_async_available_port", "(", ")", "name", "=", "self", ...
[ 107, 4 ]
[ 139, 9 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_import
(self, user_input=None)
Handle import from yaml.
Handle import from yaml.
async def async_step_import(self, user_input=None): """Handle import from yaml.""" if not self._async_is_unique_name_port(user_input): return self.async_abort(reason="port_name_in_use") return self.async_create_entry( title=f"{user_input[CONF_NAME]}:{user_input[CONF_PORT]...
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "not", "self", ".", "_async_is_unique_name_port", "(", "user_input", ")", ":", "return", "self", ".", "async_abort", "(", "reason", "=", "\"port_name_in_use\"", "...
[ 141, 4 ]
[ 147, 9 ]
python
en
['en', 'en', 'en']
True
ConfigFlow._async_available_port
(self)
Return an available port the bridge.
Return an available port the bridge.
async def _async_available_port(self): """Return an available port the bridge.""" return await self.hass.async_add_executor_job( find_next_available_port, DEFAULT_CONFIG_FLOW_PORT )
[ "async", "def", "_async_available_port", "(", "self", ")", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "find_next_available_port", ",", "DEFAULT_CONFIG_FLOW_PORT", ")" ]
[ 149, 4 ]
[ 153, 9 ]
python
en
['en', 'ga', 'en']
True
ConfigFlow._async_current_names
(self)
Return a set of bridge names.
Return a set of bridge names.
def _async_current_names(self): """Return a set of bridge names.""" current_entries = self._async_current_entries() return { entry.data[CONF_NAME] for entry in current_entries if CONF_NAME in entry.data }
[ "def", "_async_current_names", "(", "self", ")", ":", "current_entries", "=", "self", ".", "_async_current_entries", "(", ")", "return", "{", "entry", ".", "data", "[", "CONF_NAME", "]", "for", "entry", "in", "current_entries", "if", "CONF_NAME", "in", "entry"...
[ 156, 4 ]
[ 164, 9 ]
python
en
['en', 'ca', 'en']
True
ConfigFlow._async_available_name
(self)
Return an available for the bridge.
Return an available for the bridge.
def _async_available_name(self): """Return an available for the bridge.""" # We always pick a RANDOM name to avoid Zeroconf # name collisions. If the name has been seen before # pairing will probably fail. acceptable_chars = string.ascii_uppercase + string.digits traile...
[ "def", "_async_available_name", "(", "self", ")", ":", "# We always pick a RANDOM name to avoid Zeroconf", "# name collisions. If the name has been seen before", "# pairing will probably fail.", "acceptable_chars", "=", "string", ".", "ascii_uppercase", "+", "string", ".", "digits...
[ 167, 4 ]
[ 181, 29 ]
python
en
['en', 'en', 'en']
True
ConfigFlow._async_is_unique_name_port
(self, user_input)
Determine is a name or port is already used.
Determine is a name or port is already used.
def _async_is_unique_name_port(self, user_input): """Determine is a name or port is already used.""" name = user_input[CONF_NAME] port = user_input[CONF_PORT] for entry in self._async_current_entries(): if entry.data[CONF_NAME] == name or entry.data[CONF_PORT] == port: ...
[ "def", "_async_is_unique_name_port", "(", "self", ",", "user_input", ")", ":", "name", "=", "user_input", "[", "CONF_NAME", "]", "port", "=", "user_input", "[", "CONF_PORT", "]", "for", "entry", "in", "self", ".", "_async_current_entries", "(", ")", ":", "if...
[ 184, 4 ]
[ 191, 19 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 195, 4 ]
[ 197, 47 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.__init__
(self, config_entry: config_entries.ConfigEntry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry: config_entries.ConfigEntry): """Initialize options flow.""" self.config_entry = config_entry self.homekit_options = {} self.included_cameras = set()
[ "def", "__init__", "(", "self", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "homekit_options", "=", "{", "}", "self", ".", "included_cameras", "=", "set", "(", ")" ]
[ 203, 4 ]
[ 207, 37 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_yaml
(self, user_input=None)
No options for yaml managed entries.
No options for yaml managed entries.
async def async_step_yaml(self, user_input=None): """No options for yaml managed entries.""" if user_input is not None: # Apparently not possible to abort an options flow # at the moment return self.async_create_entry(title="", data=self.config_entry.options) ...
[ "async", "def", "async_step_yaml", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "# Apparently not possible to abort an options flow", "# at the moment", "return", "self", ".", "async_create_entry", "(", "title", ...
[ 209, 4 ]
[ 216, 51 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_advanced
(self, user_input=None)
Choose advanced options.
Choose advanced options.
async def async_step_advanced(self, user_input=None): """Choose advanced options.""" if user_input is not None: self.homekit_options.update(user_input) for key in (CONF_DOMAINS, CONF_ENTITIES): if key in self.homekit_options: del self.homekit_o...
[ "async", "def", "async_step_advanced", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "homekit_options", ".", "update", "(", "user_input", ")", "for", "key", "in", "(", "CONF_DOMAINS", ",",...
[ 218, 4 ]
[ 254, 9 ]
python
en
['en', 'bg', 'en']
True
OptionsFlowHandler.async_step_cameras
(self, user_input=None)
Choose camera config.
Choose camera config.
async def async_step_cameras(self, user_input=None): """Choose camera config.""" if user_input is not None: entity_config = self.homekit_options[CONF_ENTITY_CONFIG] for entity_id in self.included_cameras: if entity_id in user_input[CONF_CAMERA_COPY]: ...
[ "async", "def", "async_step_cameras", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "entity_config", "=", "self", ".", "homekit_options", "[", "CONF_ENTITY_CONFIG", "]", "for", "entity_id", "in", "self", ...
[ 256, 4 ]
[ 287, 79 ]
python
es
['es', 'es', 'en']
True
OptionsFlowHandler.async_step_include_exclude
(self, user_input=None)
Choose entities to include or exclude from the domain.
Choose entities to include or exclude from the domain.
async def async_step_include_exclude(self, user_input=None): """Choose entities to include or exclude from the domain.""" if user_input is not None: entity_filter = { CONF_INCLUDE_DOMAINS: [], CONF_EXCLUDE_DOMAINS: [], CONF_INCLUDE_ENTITIES: []...
[ "async", "def", "async_step_include_exclude", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "entity_filter", "=", "{", "CONF_INCLUDE_DOMAINS", ":", "[", "]", ",", "CONF_EXCLUDE_DOMAINS", ":", "[", "]", "...
[ 289, 4 ]
[ 367, 9 ]
python
en
['en', 'en', 'en']
True
OptionsFlowHandler.async_step_init
(self, user_input=None)
Handle options flow.
Handle options flow.
async def async_step_init(self, user_input=None): """Handle options flow.""" if self.config_entry.source == SOURCE_IMPORT: return await self.async_step_yaml(user_input) if user_input is not None: self.homekit_options.update(user_input) return await self.async...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "self", ".", "config_entry", ".", "source", "==", "SOURCE_IMPORT", ":", "return", "await", "self", ".", "async_step_yaml", "(", "user_input", ")", "if", "user_inp...
[ 369, 4 ]
[ 398, 76 ]
python
en
['en', 'nl', 'en']
True
Embeddings.forward
(self, input_ids)
Parameters: input_ids: torch.tensor(bs, max_seq_length) The token ids to embed. Returns: torch.tensor(bs, max_seq_length, dim) The embedded tokens (plus position embeddings, no token_type embeddings)
Parameters: input_ids: torch.tensor(bs, max_seq_length) The token ids to embed.
def forward(self, input_ids): """ Parameters: input_ids: torch.tensor(bs, max_seq_length) The token ids to embed. Returns: torch.tensor(bs, max_seq_length, dim) The embedded tokens (plus position embeddings, no token_type embeddings) """ seq_length = input_id...
[ "def", "forward", "(", "self", ",", "input_ids", ")", ":", "seq_length", "=", "input_ids", ".", "size", "(", "1", ")", "position_ids", "=", "torch", ".", "arange", "(", "seq_length", ",", "dtype", "=", "torch", ".", "long", ",", "device", "=", "input_i...
[ 94, 4 ]
[ 112, 25 ]
python
en
['en', 'error', 'th']
False
MultiHeadSelfAttention.forward
(self, query, key, value, mask, head_mask=None, output_attentions=False)
Parameters: query: torch.tensor(bs, seq_length, dim) key: torch.tensor(bs, seq_length, dim) value: torch.tensor(bs, seq_length, dim) mask: torch.tensor(bs, seq_length) Returns: weights: torch.tensor(bs, n_heads, seq_length, seq_length) Attent...
Parameters: query: torch.tensor(bs, seq_length, dim) key: torch.tensor(bs, seq_length, dim) value: torch.tensor(bs, seq_length, dim) mask: torch.tensor(bs, seq_length)
def forward(self, query, key, value, mask, head_mask=None, output_attentions=False): """ Parameters: query: torch.tensor(bs, seq_length, dim) key: torch.tensor(bs, seq_length, dim) value: torch.tensor(bs, seq_length, dim) mask: torch.tensor(bs, seq_length)...
[ "def", "forward", "(", "self", ",", "query", ",", "key", ",", "value", ",", "mask", ",", "head_mask", "=", "None", ",", "output_attentions", "=", "False", ")", ":", "bs", ",", "q_length", ",", "dim", "=", "query", ".", "size", "(", ")", "k_length", ...
[ 147, 4 ]
[ 199, 29 ]
python
en
['en', 'error', 'th']
False
TransformerBlock.forward
(self, x, attn_mask=None, head_mask=None, output_attentions=False)
Parameters: x: torch.tensor(bs, seq_length, dim) attn_mask: torch.tensor(bs, seq_length) Returns: sa_weights: torch.tensor(bs, n_heads, seq_length, seq_length) The attention weights ffn_output: torch.tensor(bs, seq_length, dim) The output of the transfor...
Parameters: x: torch.tensor(bs, seq_length, dim) attn_mask: torch.tensor(bs, seq_length)
def forward(self, x, attn_mask=None, head_mask=None, output_attentions=False): """ Parameters: x: torch.tensor(bs, seq_length, dim) attn_mask: torch.tensor(bs, seq_length) Returns: sa_weights: torch.tensor(bs, n_heads, seq_length, seq_length) The attention we...
[ "def", "forward", "(", "self", ",", "x", ",", "attn_mask", "=", "None", ",", "head_mask", "=", "None", ",", "output_attentions", "=", "False", ")", ":", "# Self-Attention", "sa_output", "=", "self", ".", "attention", "(", "query", "=", "x", ",", "key", ...
[ 238, 4 ]
[ 271, 21 ]
python
en
['en', 'error', 'th']
False
Transformer.forward
( self, x, attn_mask=None, head_mask=None, output_attentions=False, output_hidden_states=False, return_dict=None )
Parameters: x: torch.tensor(bs, seq_length, dim) Input sequence embedded. attn_mask: torch.tensor(bs, seq_length) Attention mask on the sequence. Returns: hidden_state: torch.tensor(bs, seq_length, dim) Sequence of hidden states in the last (top) layer a...
Parameters: x: torch.tensor(bs, seq_length, dim) Input sequence embedded. attn_mask: torch.tensor(bs, seq_length) Attention mask on the sequence.
def forward( self, x, attn_mask=None, head_mask=None, output_attentions=False, output_hidden_states=False, return_dict=None ): # docstyle-ignore """ Parameters: x: torch.tensor(bs, seq_length, dim) Input sequence embedded. attn_mask: torch.tensor(bs, seq_length) Atte...
[ "def", "forward", "(", "self", ",", "x", ",", "attn_mask", "=", "None", ",", "head_mask", "=", "None", ",", "output_attentions", "=", "False", ",", "output_hidden_states", "=", "False", ",", "return_dict", "=", "None", ")", ":", "# docstyle-ignore", "all_hid...
[ 282, 4 ]
[ 327, 9 ]
python
en
['en', 'error', 'th']
False
DistilBertPreTrainedModel._init_weights
(self, module)
Initialize the weights.
Initialize the weights.
def _init_weights(self, module): """Initialize the weights.""" if isinstance(module, nn.Linear): # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 module.weight.data.normal_(mean=0...
[ "def", "_init_weights", "(", "self", ",", "module", ")", ":", "if", "isinstance", "(", "module", ",", "nn", ".", "Linear", ")", ":", "# Slightly different from the TF version which uses truncated_normal for initialization", "# cf https://github.com/pytorch/pytorch/pull/5617", ...
[ 341, 4 ]
[ 355, 41 ]
python
en
['en', 'en', 'en']
True
GenerateConfig
(context)
Generate configuration.
Generate configuration.
def GenerateConfig(context): """Generate configuration.""" backend = context.env['deployment'] + '-backend' frontend = context.env['deployment'] + '-frontend' firewall = context.env['deployment'] + '-application-fw' application_port = 8080 mysql_port = 8080 resources = [{ 'name': backend, 'ty...
[ "def", "GenerateConfig", "(", "context", ")", ":", "backend", "=", "context", ".", "env", "[", "'deployment'", "]", "+", "'-backend'", "frontend", "=", "context", ".", "env", "[", "'deployment'", "]", "+", "'-frontend'", "firewall", "=", "context", ".", "e...
[ 17, 0 ]
[ 63, 33 ]
python
en
['en', 'la', 'en']
False
async_api_discovery
(hass, config, directive, context)
Create a API formatted discovery response. Async friendly.
Create a API formatted discovery response.
async def async_api_discovery(hass, config, directive, context): """Create a API formatted discovery response. Async friendly. """ discovery_endpoints = [ alexa_entity.serialize_discovery() for alexa_entity in async_get_entities(hass, config) if config.should_expose(alexa_entity...
[ "async", "def", "async_api_discovery", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "discovery_endpoints", "=", "[", "alexa_entity", ".", "serialize_discovery", "(", ")", "for", "alexa_entity", "in", "async_get_entities", "(", "hass", ...
[ 77, 0 ]
[ 92, 5 ]
python
en
['en', 'en', 'en']
True
async_api_accept_grant
(hass, config, directive, context)
Create a API formatted AcceptGrant response. Async friendly.
Create a API formatted AcceptGrant response.
async def async_api_accept_grant(hass, config, directive, context): """Create a API formatted AcceptGrant response. Async friendly. """ auth_code = directive.payload["grant"]["code"] _LOGGER.debug("AcceptGrant code: %s", auth_code) if config.supports_auth: await config.async_accept_gra...
[ "async", "def", "async_api_accept_grant", "(", "hass", ",", "config", ",", "directive", ",", "context", ")", ":", "auth_code", "=", "directive", ".", "payload", "[", "\"grant\"", "]", "[", "\"code\"", "]", "_LOGGER", ".", "debug", "(", "\"AcceptGrant code: %s\...
[ 96, 0 ]
[ 112, 5 ]
python
en
['en', 'en', 'en']
True