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
TotalConnectAlarm.__init__
(self, name, location_id, client)
Initialize the TotalConnect status.
Initialize the TotalConnect status.
def __init__(self, name, location_id, client): """Initialize the TotalConnect status.""" self._name = name self._location_id = location_id self._client = client self._state = None self._device_state_attributes = {}
[ "def", "__init__", "(", "self", ",", "name", ",", "location_id", ",", "client", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_location_id", "=", "location_id", "self", ".", "_client", "=", "client", "self", ".", "_state", "=", "None", "se...
[ 42, 4 ]
[ 48, 42 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 51, 4 ]
[ 53, 25 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.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" ]
[ 56, 4 ]
[ 58, 26 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.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
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY", "|", "SUPPORT_ALARM_ARM_NIGHT" ]
[ 61, 4 ]
[ 63, 88 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.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 self._device_state_attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "self", ".", "_device_state_attributes" ]
[ 66, 4 ]
[ 68, 44 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.update
(self)
Return the state of the device.
Return the state of the device.
def update(self): """Return the state of the device.""" self._client.get_armed_status(self._location_id) attr = { "location_name": self._name, "location_id": self._location_id, "ac_loss": self._client.locations[self._location_id].ac_loss, "low_batt...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_client", ".", "get_armed_status", "(", "self", ".", "_location_id", ")", "attr", "=", "{", "\"location_name\"", ":", "self", ".", "_name", ",", "\"location_id\"", ":", "self", ".", "_location_id", ",",...
[ 70, 4 ]
[ 113, 44 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" if self._client.disarm(self._location_id) is not True: raise HomeAssistantError(f"TotalConnect failed to disarm {self._name}.")
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "if", "self", ".", "_client", ".", "disarm", "(", "self", ".", "_location_id", ")", "is", "not", "True", ":", "raise", "HomeAssistantError", "(", "f\"TotalConnect failed to disarm {self._n...
[ 115, 4 ]
[ 118, 84 ]
python
en
['en', 'pt', 'en']
True
TotalConnectAlarm.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.""" if self._client.arm_stay(self._location_id) is not True: raise HomeAssistantError(f"TotalConnect failed to arm home {self._name}.")
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "if", "self", ".", "_client", ".", "arm_stay", "(", "self", ".", "_location_id", ")", "is", "not", "True", ":", "raise", "HomeAssistantError", "(", "f\"TotalConnect failed to arm home {s...
[ 120, 4 ]
[ 123, 86 ]
python
en
['en', 'pt', 'en']
True
TotalConnectAlarm.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.""" if self._client.arm_away(self._location_id) is not True: raise HomeAssistantError(f"TotalConnect failed to arm away {self._name}.")
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "if", "self", ".", "_client", ".", "arm_away", "(", "self", ".", "_location_id", ")", "is", "not", "True", ":", "raise", "HomeAssistantError", "(", "f\"TotalConnect failed to arm away {s...
[ 125, 4 ]
[ 128, 86 ]
python
en
['en', 'en', 'en']
True
TotalConnectAlarm.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.""" if self._client.arm_stay_night(self._location_id) is not True: raise HomeAssistantError(f"TotalConnect failed to arm night {self._name}.")
[ "def", "alarm_arm_night", "(", "self", ",", "code", "=", "None", ")", ":", "if", "self", ".", "_client", ".", "arm_stay_night", "(", "self", ".", "_location_id", ")", "is", "not", "True", ":", "raise", "HomeAssistantError", "(", "f\"TotalConnect failed to arm ...
[ 130, 4 ]
[ 133, 87 ]
python
en
['en', 'zh', 'en']
True
archive_paths_to
(obj, paths, mtime)
Writes the given store paths as a tar file to the given stream. obj: Stream to write to. Should have a 'write' method. paths: List of store paths.
Writes the given store paths as a tar file to the given stream.
def archive_paths_to(obj, paths, mtime): """ Writes the given store paths as a tar file to the given stream. obj: Stream to write to. Should have a 'write' method. paths: List of store paths. """ # gettarinfo makes the paths relative, this makes them # absolute again def append_root(ti...
[ "def", "archive_paths_to", "(", "obj", ",", "paths", ",", "mtime", ")", ":", "# gettarinfo makes the paths relative, this makes them", "# absolute again", "def", "append_root", "(", "ti", ")", ":", "ti", ".", "name", "=", "\"/\"", "+", "ti", ".", "name", "return...
[ 47, 0 ]
[ 105, 35 ]
python
en
['en', 'error', 'th']
False
load_from_image
(from_image_str)
Loads the given base image, if any. from_image_str: Path to the base image archive. Returns: A 'FromImage' object with references to the loaded base image, or 'None' if no base image was provided.
Loads the given base image, if any.
def load_from_image(from_image_str): """ Loads the given base image, if any. from_image_str: Path to the base image archive. Returns: A 'FromImage' object with references to the loaded base image, or 'None' if no base image was provided. """ if from_image_str is None: retu...
[ "def", "load_from_image", "(", "from_image_str", ")", ":", "if", "from_image_str", "is", "None", ":", "return", "None", "base_tar", "=", "tarfile", ".", "open", "(", "from_image_str", ")", "manifest_json_tarinfo", "=", "base_tar", ".", "getmember", "(", "\"manif...
[ 134, 0 ]
[ 156, 57 ]
python
en
['en', 'error', 'th']
False
add_base_layers
(tar, from_image)
Adds the layers from the given base image to the final image. tar: 'tarfile.TarFile' object for new layers to be added to. from_image: 'FromImage' object with references to the loaded base image.
Adds the layers from the given base image to the final image.
def add_base_layers(tar, from_image): """ Adds the layers from the given base image to the final image. tar: 'tarfile.TarFile' object for new layers to be added to. from_image: 'FromImage' object with references to the loaded base image. """ if from_image is None: print("No 'fromImage' ...
[ "def", "add_base_layers", "(", "tar", ",", "from_image", ")", ":", "if", "from_image", "is", "None", ":", "print", "(", "\"No 'fromImage' provided\"", ",", "file", "=", "sys", ".", "stderr", ")", "return", "[", "]", "layers", "=", "from_image", ".", "manif...
[ 159, 0 ]
[ 185, 26 ]
python
en
['en', 'error', 'th']
False
overlay_base_config
(from_image, final_config)
Overlays the final image 'config' JSON on top of selected defaults from the base image 'config' JSON. from_image: 'FromImage' object with references to the loaded base image. final_config: 'dict' object of the final image 'config' JSON.
Overlays the final image 'config' JSON on top of selected defaults from the base image 'config' JSON.
def overlay_base_config(from_image, final_config): """ Overlays the final image 'config' JSON on top of selected defaults from the base image 'config' JSON. from_image: 'FromImage' object with references to the loaded base image. final_config: 'dict' object of the final image 'config' JSON. """...
[ "def", "overlay_base_config", "(", "from_image", ",", "final_config", ")", ":", "if", "from_image", "is", "None", ":", "return", "final_config", "base_config", "=", "from_image", ".", "image_json", "[", "\"config\"", "]", "# Preserve environment from base image", "fin...
[ 188, 0 ]
[ 207, 23 ]
python
en
['en', 'error', 'th']
False
add_layer_dir
(tar, paths, store_dir, mtime)
Appends given store paths to a TarFile object as a new layer. tar: 'tarfile.TarFile' object for the new layer to be added to. paths: List of store paths. store_dir: the root directory of the nix store mtime: 'mtime' of the added files and the layer tarball. Should be an integer represen...
Appends given store paths to a TarFile object as a new layer.
def add_layer_dir(tar, paths, store_dir, mtime): """ Appends given store paths to a TarFile object as a new layer. tar: 'tarfile.TarFile' object for the new layer to be added to. paths: List of store paths. store_dir: the root directory of the nix store mtime: 'mtime' of the added files and the...
[ "def", "add_layer_dir", "(", "tar", ",", "paths", ",", "store_dir", ",", "mtime", ")", ":", "invalid_paths", "=", "[", "i", "for", "i", "in", "paths", "if", "not", "i", ".", "startswith", "(", "store_dir", ")", "]", "assert", "len", "(", "invalid_paths...
[ 210, 0 ]
[ 262, 74 ]
python
en
['en', 'error', 'th']
False
add_customisation_layer
(target_tar, customisation_layer, mtime)
Adds the customisation layer as a new layer. This is layer is structured differently; given store path has the 'layer.tar' and corresponding sha256sum ready. tar: 'tarfile.TarFile' object for the new layer to be added to. customisation_layer: Path containing the layer archive. mtime: 'mtime' o...
Adds the customisation layer as a new layer. This is layer is structured differently; given store path has the 'layer.tar' and corresponding sha256sum ready.
def add_customisation_layer(target_tar, customisation_layer, mtime): """ Adds the customisation layer as a new layer. This is layer is structured differently; given store path has the 'layer.tar' and corresponding sha256sum ready. tar: 'tarfile.TarFile' object for the new layer to be added to. ...
[ "def", "add_customisation_layer", "(", "target_tar", ",", "customisation_layer", ",", "mtime", ")", ":", "checksum_path", "=", "os", ".", "path", ".", "join", "(", "customisation_layer", ",", "\"checksum\"", ")", "with", "open", "(", "checksum_path", ")", "as", ...
[ 265, 0 ]
[ 296, 5 ]
python
en
['en', 'error', 'th']
False
add_bytes
(tar, path, content, mtime)
Adds a file to the tarball with given path and contents. tar: 'tarfile.TarFile' object. path: Path of the file as a string. content: Contents of the file. mtime: 'mtime' of the file. Should be an integer representing a POSIX time.
Adds a file to the tarball with given path and contents.
def add_bytes(tar, path, content, mtime): """ Adds a file to the tarball with given path and contents. tar: 'tarfile.TarFile' object. path: Path of the file as a string. content: Contents of the file. mtime: 'mtime' of the file. Should be an integer representing a POSIX time. """ assert...
[ "def", "add_bytes", "(", "tar", ",", "path", ",", "content", ",", "mtime", ")", ":", "assert", "type", "(", "content", ")", "is", "bytes", "ti", "=", "tarfile", ".", "TarInfo", "(", "path", ")", "ti", ".", "size", "=", "len", "(", "content", ")", ...
[ 299, 0 ]
[ 313, 40 ]
python
en
['en', 'error', 'th']
False
ExtractChecksum.extract
(self)
Returns: Hex-encoded sha256sum and size as a tuple.
Returns: Hex-encoded sha256sum and size as a tuple.
def extract(self): """ Returns: Hex-encoded sha256sum and size as a tuple. """ return (self._digest.hexdigest(), self._size)
[ "def", "extract", "(", "self", ")", ":", "return", "(", "self", ".", "_digest", ".", "hexdigest", "(", ")", ",", "self", ".", "_size", ")" ]
[ 122, 4 ]
[ 126, 53 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass, config)
Set up the MQTT state feed.
Set up the MQTT state feed.
async def async_setup(hass, config): """Set up the MQTT state feed.""" conf = config.get(DOMAIN) publish_filter = convert_include_exclude_filter(conf) base_topic = conf.get(CONF_BASE_TOPIC) publish_attributes = conf.get(CONF_PUBLISH_ATTRIBUTES) publish_timestamps = conf.get(CONF_PUBLISH_TIMESTAM...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "publish_filter", "=", "convert_include_exclude_filter", "(", "conf", ")", "base_topic", "=", "conf", ".", "get", "(", "CONF_BASE_TOPI...
[ 36, 0 ]
[ 75, 15 ]
python
en
['en', 'en', 'en']
True
test_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", ...
[ 27, 0 ]
[ 34, 43 ]
python
en
['en', 'en', 'en']
True
test_invalid_api_key
(hass)
Test that errors are shown when API key is invalid.
Test that errors are shown when API key is invalid.
async def test_invalid_api_key(hass): """Test that errors are shown when API key is invalid.""" with patch( "airly._private._RequestsHandler.get", side_effect=AirlyError( HTTP_FORBIDDEN, {"message": "Invalid authentication credentials"} ), ): result = await hass....
[ "async", "def", "test_invalid_api_key", "(", "hass", ")", ":", "with", "patch", "(", "\"airly._private._RequestsHandler.get\"", ",", "side_effect", "=", "AirlyError", "(", "HTTP_FORBIDDEN", ",", "{", "\"message\"", ":", "\"Invalid authentication credentials\"", "}", ")"...
[ 37, 0 ]
[ 50, 62 ]
python
en
['en', 'en', 'en']
True
test_invalid_location
(hass)
Test that errors are shown when location is invalid.
Test that errors are shown when location is invalid.
async def test_invalid_location(hass): """Test that errors are shown when location is invalid.""" with patch( "airly._private._RequestsHandler.get", return_value=json.loads(load_fixture("airly_no_station.json")), ): result = await hass.config_entries.flow.async_init( DOM...
[ "async", "def", "test_invalid_location", "(", "hass", ")", ":", "with", "patch", "(", "\"airly._private._RequestsHandler.get\"", ",", "return_value", "=", "json", ".", "loads", "(", "load_fixture", "(", "\"airly_no_station.json\"", ")", ")", ",", ")", ":", "result...
[ 53, 0 ]
[ 64, 61 ]
python
en
['en', 'en', 'en']
True
test_duplicate_error
(hass)
Test that errors are shown when duplicates are added.
Test that errors are shown when duplicates are added.
async def test_duplicate_error(hass): """Test that errors are shown when duplicates are added.""" with patch( "airly._private._RequestsHandler.get", return_value=json.loads(load_fixture("airly_valid_station.json")), ): MockConfigEntry(domain=DOMAIN, unique_id="123-456", data=CONFIG)...
[ "async", "def", "test_duplicate_error", "(", "hass", ")", ":", "with", "patch", "(", "\"airly._private._RequestsHandler.get\"", ",", "return_value", "=", "json", ".", "loads", "(", "load_fixture", "(", "\"airly_valid_station.json\"", ")", ")", ",", ")", ":", "Mock...
[ 67, 0 ]
[ 83, 55 ]
python
en
['en', 'en', 'en']
True
test_create_entry
(hass)
Test that the user step works.
Test that the user step works.
async def test_create_entry(hass): """Test that the user step works.""" with patch( "airly._private._RequestsHandler.get", return_value=json.loads(load_fixture("airly_valid_station.json")), ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source"...
[ "async", "def", "test_create_entry", "(", "hass", ")", ":", "with", "patch", "(", "\"airly._private._RequestsHandler.get\"", ",", "return_value", "=", "json", ".", "loads", "(", "load_fixture", "(", "\"airly_valid_station.json\"", ")", ")", ",", ")", ":", "result"...
[ 86, 0 ]
[ 102, 67 ]
python
en
['en', 'en', 'en']
True
resnext50
(baseWidth=32, cardinality=4, num_classes=1000)
Construct ResNeXt-50.
Construct ResNeXt-50.
def resnext50(baseWidth=32, cardinality=4, num_classes=1000): """ Construct ResNeXt-50. """ model = ResNeXt(baseWidth, cardinality, [3, 4, 6, 3], num_classes) return model
[ "def", "resnext50", "(", "baseWidth", "=", "32", ",", "cardinality", "=", "4", ",", "num_classes", "=", "1000", ")", ":", "model", "=", "ResNeXt", "(", "baseWidth", ",", "cardinality", ",", "[", "3", ",", "4", ",", "6", ",", "3", "]", ",", "num_cla...
[ 151, 0 ]
[ 156, 16 ]
python
en
['en', 'error', 'th']
False
resnext101
(baseWidth, cardinality)
Construct ResNeXt-101.
Construct ResNeXt-101.
def resnext101(baseWidth, cardinality): """ Construct ResNeXt-101. """ model = ResNeXt(baseWidth, cardinality, [3, 4, 23, 3], 1000) return model
[ "def", "resnext101", "(", "baseWidth", ",", "cardinality", ")", ":", "model", "=", "ResNeXt", "(", "baseWidth", ",", "cardinality", ",", "[", "3", ",", "4", ",", "23", ",", "3", "]", ",", "1000", ")", "return", "model" ]
[ 159, 0 ]
[ 164, 16 ]
python
en
['en', 'error', 'th']
False
resnext152
(baseWidth, cardinality)
Construct ResNeXt-152.
Construct ResNeXt-152.
def resnext152(baseWidth, cardinality): """ Construct ResNeXt-152. """ model = ResNeXt(baseWidth, cardinality, [3, 8, 36, 3], 1000) return model
[ "def", "resnext152", "(", "baseWidth", ",", "cardinality", ")", ":", "model", "=", "ResNeXt", "(", "baseWidth", ",", "cardinality", ",", "[", "3", ",", "8", ",", "36", ",", "3", "]", ",", "1000", ")", "return", "model" ]
[ 167, 0 ]
[ 172, 16 ]
python
en
['en', 'error', 'th']
False
Bottleneck.__init__
(self, inplanes, planes, baseWidth, cardinality, stride=1, downsample=None)
Constructor Args: inplanes: input channel dimensionality planes: output channel dimensionality baseWidth: base width. cardinality: num of convolution groups. stride: conv stride. Replaces pooling layer.
Constructor Args: inplanes: input channel dimensionality planes: output channel dimensionality baseWidth: base width. cardinality: num of convolution groups. stride: conv stride. Replaces pooling layer.
def __init__(self, inplanes, planes, baseWidth, cardinality, stride=1, downsample=None): """ Constructor Args: inplanes: input channel dimensionality planes: output channel dimensionality baseWidth: base width. cardinality: num of convolution groups. ...
[ "def", "__init__", "(", "self", ",", "inplanes", ",", "planes", ",", "baseWidth", ",", "cardinality", ",", "stride", "=", "1", ",", "downsample", "=", "None", ")", ":", "super", "(", "Bottleneck", ",", "self", ")", ".", "__init__", "(", ")", "D", "="...
[ 22, 4 ]
[ 44, 36 ]
python
en
['en', 'en', 'pt']
False
ResNeXt.__init__
(self, baseWidth, cardinality, layers, num_classes)
Constructor Args: baseWidth: baseWidth for ResNeXt. cardinality: number of convolution groups. layers: config of layers, e.g., [3, 4, 6, 3] num_classes: number of classes
Constructor Args: baseWidth: baseWidth for ResNeXt. cardinality: number of convolution groups. layers: config of layers, e.g., [3, 4, 6, 3] num_classes: number of classes
def __init__(self, baseWidth, cardinality, layers, num_classes): """ Constructor Args: baseWidth: baseWidth for ResNeXt. cardinality: number of convolution groups. layers: config of layers, e.g., [3, 4, 6, 3] num_classes: number of classes """ ...
[ "def", "__init__", "(", "self", ",", "baseWidth", ",", "cardinality", ",", "layers", ",", "num_classes", ")", ":", "super", "(", "ResNeXt", ",", "self", ")", ".", "__init__", "(", ")", "block", "=", "Bottleneck", "self", ".", "cardinality", "=", "cardina...
[ 74, 4 ]
[ 108, 35 ]
python
en
['en', 'en', 'pt']
False
ResNeXt._make_layer
(self, block, planes, blocks, stride=1)
Stack n bottleneck modules where n is inferred from the depth of the network. Args: block: block type used to construct ResNext planes: number of output channels (need to multiply by block.expansion) blocks: number of blocks to be built stride: factor to reduce t...
Stack n bottleneck modules where n is inferred from the depth of the network. Args: block: block type used to construct ResNext planes: number of output channels (need to multiply by block.expansion) blocks: number of blocks to be built stride: factor to reduce t...
def _make_layer(self, block, planes, blocks, stride=1): """ Stack n bottleneck modules where n is inferred from the depth of the network. Args: block: block type used to construct ResNext planes: number of output channels (need to multiply by block.expansion) blocks: ...
[ "def", "_make_layer", "(", "self", ",", "block", ",", "planes", ",", "blocks", ",", "stride", "=", "1", ")", ":", "downsample", "=", "None", "if", "stride", "!=", "1", "or", "self", ".", "inplanes", "!=", "planes", "*", "block", ".", "expansion", ":"...
[ 110, 4 ]
[ 133, 37 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Import the Islamic Prayer component from config.
Import the Islamic Prayer component from config.
async def async_setup(hass, config): """Import the Islamic Prayer component from config.""" if DOMAIN in config: hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=config[DOMAIN] ) ) return Tru...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "in", "config", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"so...
[ 37, 0 ]
[ 46, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set up the Islamic Prayer Component.
Set up the Islamic Prayer Component.
async def async_setup_entry(hass, config_entry): """Set up the Islamic Prayer Component.""" client = IslamicPrayerClient(hass, config_entry) if not await client.async_setup(): return False hass.data.setdefault(DOMAIN, client) return True
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "client", "=", "IslamicPrayerClient", "(", "hass", ",", "config_entry", ")", "if", "not", "await", "client", ".", "async_setup", "(", ")", ":", "return", "False", "hass", ".", ...
[ 49, 0 ]
[ 57, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, config_entry)
Unload Islamic Prayer entry from config_entry.
Unload Islamic Prayer entry from config_entry.
async def async_unload_entry(hass, config_entry): """Unload Islamic Prayer entry from config_entry.""" if hass.data[DOMAIN].event_unsub: hass.data[DOMAIN].event_unsub() hass.data.pop(DOMAIN) await hass.config_entries.async_forward_entry_unload(config_entry, "sensor") return True
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "if", "hass", ".", "data", "[", "DOMAIN", "]", ".", "event_unsub", ":", "hass", ".", "data", "[", "DOMAIN", "]", ".", "event_unsub", "(", ")", "hass", ".", "data", ".", ...
[ 60, 0 ]
[ 67, 15 ]
python
en
['en', 'en', 'en']
True
IslamicPrayerClient.__init__
(self, hass, config_entry)
Initialize the Islamic Prayer client.
Initialize the Islamic Prayer client.
def __init__(self, hass, config_entry): """Initialize the Islamic Prayer client.""" self.hass = hass self.config_entry = config_entry self.prayer_times_info = {} self.available = True self.event_unsub = None
[ "def", "__init__", "(", "self", ",", "hass", ",", "config_entry", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "config_entry", "=", "config_entry", "self", ".", "prayer_times_info", "=", "{", "}", "self", ".", "available", "=", "True", "self"...
[ 73, 4 ]
[ 79, 31 ]
python
en
['en', 'en', 'en']
True
IslamicPrayerClient.calc_method
(self)
Return the calculation method.
Return the calculation method.
def calc_method(self): """Return the calculation method.""" return self.config_entry.options[CONF_CALC_METHOD]
[ "def", "calc_method", "(", "self", ")", ":", "return", "self", ".", "config_entry", ".", "options", "[", "CONF_CALC_METHOD", "]" ]
[ 82, 4 ]
[ 84, 58 ]
python
en
['en', 'ja', 'en']
True
IslamicPrayerClient.get_new_prayer_times
(self)
Fetch prayer times for today.
Fetch prayer times for today.
def get_new_prayer_times(self): """Fetch prayer times for today.""" calc = PrayerTimesCalculator( latitude=self.hass.config.latitude, longitude=self.hass.config.longitude, calculation_method=self.calc_method, date=str(dt_util.now().date()), ) ...
[ "def", "get_new_prayer_times", "(", "self", ")", ":", "calc", "=", "PrayerTimesCalculator", "(", "latitude", "=", "self", ".", "hass", ".", "config", ".", "latitude", ",", "longitude", "=", "self", ".", "hass", ".", "config", ".", "longitude", ",", "calcul...
[ 86, 4 ]
[ 94, 40 ]
python
en
['en', 'en', 'en']
True
IslamicPrayerClient.async_schedule_future_update
(self)
Schedule future update for sensors. Midnight is a calculated time. The specifics of the calculation depends on the method of the prayer time calculation. This calculated midnight is the time at which the time to pray the Isha prayers have expired. Calculated Midnight: The Isl...
Schedule future update for sensors.
async def async_schedule_future_update(self): """Schedule future update for sensors. Midnight is a calculated time. The specifics of the calculation depends on the method of the prayer time calculation. This calculated midnight is the time at which the time to pray the Isha prayers ha...
[ "async", "def", "async_schedule_future_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Scheduling next update for Islamic prayer times\"", ")", "now", "=", "dt_util", ".", "utcnow", "(", ")", "midnight_dt", "=", "self", ".", "prayer_times_info", "["...
[ 96, 4 ]
[ 146, 9 ]
python
en
['en', 'co', 'en']
True
IslamicPrayerClient.async_update
(self, *_)
Update sensors with new prayer times.
Update sensors with new prayer times.
async def async_update(self, *_): """Update sensors with new prayer times.""" try: prayer_times = await self.hass.async_add_executor_job( self.get_new_prayer_times ) self.available = True except (exceptions.InvalidResponseError, ConnError): ...
[ "async", "def", "async_update", "(", "self", ",", "*", "_", ")", ":", "try", ":", "prayer_times", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "get_new_prayer_times", ")", "self", ".", "available", "=", "True", "excep...
[ 148, 4 ]
[ 168, 54 ]
python
en
['en', 'en', 'en']
True
IslamicPrayerClient.async_setup
(self)
Set up the Islamic prayer client.
Set up the Islamic prayer client.
async def async_setup(self): """Set up the Islamic prayer client.""" await self.async_add_options() try: await self.hass.async_add_executor_job(self.get_new_prayer_times) except (exceptions.InvalidResponseError, ConnError) as err: raise ConfigEntryNotReady from e...
[ "async", "def", "async_setup", "(", "self", ")", ":", "await", "self", ".", "async_add_options", "(", ")", "try", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "get_new_prayer_times", ")", "except", "(", "exceptions", "....
[ 170, 4 ]
[ 188, 19 ]
python
en
['en', 'en', 'en']
True
IslamicPrayerClient.async_add_options
(self)
Add options for entry.
Add options for entry.
async def async_add_options(self): """Add options for entry.""" if not self.config_entry.options: data = dict(self.config_entry.data) calc_method = data.pop(CONF_CALC_METHOD, DEFAULT_CALC_METHOD) self.hass.config_entries.async_update_entry( self.confi...
[ "async", "def", "async_add_options", "(", "self", ")", ":", "if", "not", "self", ".", "config_entry", ".", "options", ":", "data", "=", "dict", "(", "self", ".", "config_entry", ".", "data", ")", "calc_method", "=", "data", ".", "pop", "(", "CONF_CALC_ME...
[ 190, 4 ]
[ 198, 13 ]
python
en
['en', 'en', 'en']
True
IslamicPrayerClient.async_options_updated
(hass, entry)
Triggered by config entry options updates.
Triggered by config entry options updates.
async def async_options_updated(hass, entry): """Triggered by config entry options updates.""" if hass.data[DOMAIN].event_unsub: hass.data[DOMAIN].event_unsub() await hass.data[DOMAIN].async_update()
[ "async", "def", "async_options_updated", "(", "hass", ",", "entry", ")", ":", "if", "hass", ".", "data", "[", "DOMAIN", "]", ".", "event_unsub", ":", "hass", ".", "data", "[", "DOMAIN", "]", ".", "event_unsub", "(", ")", "await", "hass", ".", "data", ...
[ 201, 4 ]
[ 205, 46 ]
python
en
['en', 'en', 'en']
True
classic_mode
( mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size)
Execute the chosen function and inputs directly. In this mode, the trial code is only running the chosen subgraph (i.e., the chosen ops and inputs), without touching the full model graph.
Execute the chosen function and inputs directly. In this mode, the trial code is only running the chosen subgraph (i.e., the chosen ops and inputs), without touching the full model graph.
def classic_mode( mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size): '''Execute the chosen function and inputs directly. In this mode, the trial code is only running the chosen subgraph (i.e., the chosen o...
[ "def", "classic_mode", "(", "mutable_id", ",", "mutable_layer_id", ",", "funcs", ",", "funcs_args", ",", "fixed_inputs", ",", "optional_inputs", ",", "optional_input_size", ")", ":", "if", "trial", ".", "get_current_parameter", "(", ")", "is", "None", ":", "tria...
[ 18, 0 ]
[ 37, 20 ]
python
en
['en', 'en', 'en']
True
enas_mode
( mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size, tf)
For enas mode, we build the full model graph in trial but only run a subgraph。 This is implemented by masking inputs and branching ops. Specifically, based on the received subgraph (through nni.get_next_parameter), it can be known which inputs should be masked and which op should be executed.
For enas mode, we build the full model graph in trial but only run a subgraph。 This is implemented by masking inputs and branching ops. Specifically, based on the received subgraph (through nni.get_next_parameter), it can be known which inputs should be masked and which op should be executed.
def enas_mode( mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size, tf): '''For enas mode, we build the full model graph in trial but only run a subgraph。 This is implemented by masking inputs and bra...
[ "def", "enas_mode", "(", "mutable_id", ",", "mutable_layer_id", ",", "funcs", ",", "funcs_args", ",", "fixed_inputs", ",", "optional_inputs", ",", "optional_input_size", ",", "tf", ")", ":", "name_prefix", "=", "\"{}_{}\"", ".", "format", "(", "mutable_id", ",",...
[ 40, 0 ]
[ 90, 20 ]
python
en
['en', 'en', 'en']
True
oneshot_mode
( mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size, tf)
Similar to enas mode, oneshot mode also builds the full model graph. The difference is that oneshot mode does not receive subgraph. Instead, it uses dropout to randomly dropout inputs and ops.
Similar to enas mode, oneshot mode also builds the full model graph. The difference is that oneshot mode does not receive subgraph. Instead, it uses dropout to randomly dropout inputs and ops.
def oneshot_mode( mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size, tf): '''Similar to enas mode, oneshot mode also builds the full model graph. The difference is that oneshot mode does not receive...
[ "def", "oneshot_mode", "(", "mutable_id", ",", "mutable_layer_id", ",", "funcs", ",", "funcs_args", ",", "fixed_inputs", ",", "optional_inputs", ",", "optional_input_size", ",", "tf", ")", ":", "# NNI requires to get_next_parameter before report a result. But the parameter wi...
[ 93, 0 ]
[ 125, 20 ]
python
en
['en', 'en', 'en']
True
reload_tensorflow_variables
(tf, session)
In Enas mode, this function reload every signal varaible created in `enas_mode` function so the whole tensorflow graph will be changed into certain subgraph recerived from Tuner. --------------- session: the tensorflow session created by users tf: tensorflow module
In Enas mode, this function reload every signal varaible created in `enas_mode` function so the whole tensorflow graph will be changed into certain subgraph recerived from Tuner. --------------- session: the tensorflow session created by users tf: tensorflow module
def reload_tensorflow_variables(tf, session): '''In Enas mode, this function reload every signal varaible created in `enas_mode` function so the whole tensorflow graph will be changed into certain subgraph recerived from Tuner. --------------- session: the tensorflow session created by users tf: ten...
[ "def", "reload_tensorflow_variables", "(", "tf", ",", "session", ")", ":", "subgraph_from_tuner", "=", "trial", ".", "get_next_parameter", "(", ")", "mutable_layers", "=", "set", "(", ")", "for", "subgraph_key", "in", "subgraph_from_tuner", ":", "if", "\"/\"", "...
[ 150, 0 ]
[ 180, 35 ]
python
en
['en', 'en', 'en']
True
convert_nas_search_space
(search_space)
Args: param search_space: raw search space return: the new search space, mutable_layers will be converted into choice
Args: param search_space: raw search space return: the new search space, mutable_layers will be converted into choice
def convert_nas_search_space(search_space): """ Args: param search_space: raw search space return: the new search space, mutable_layers will be converted into choice """ if not isinstance(search_space, dict): return search_space ret = dict() for k, v in search_space.items...
[ "def", "convert_nas_search_space", "(", "search_space", ")", ":", "if", "not", "isinstance", "(", "search_space", ",", "dict", ")", ":", "return", "search_space", "ret", "=", "dict", "(", ")", "for", "k", ",", "v", "in", "search_space", ".", "items", "(", ...
[ 245, 0 ]
[ 308, 14 ]
python
en
['en', 'error', 'th']
False
UpCloudConfigFlow.async_step_user
(self, user_input=None)
Handle user initiated flow.
Handle user initiated flow.
async def async_step_user(self, user_input=None): """Handle user initiated flow.""" if user_input is None: return self._async_show_form(step_id="user") await self.async_set_unique_id(user_input[CONF_USERNAME]) manager = upcloud_api.CloudManager( user_input[CONF_...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "_async_show_form", "(", "step_id", "=", "\"user\"", ")", "await", "self", ".", "async_set_unique_id", "("...
[ 27, 4 ]
[ 53, 88 ]
python
en
['en', 'nl', 'en']
True
UpCloudConfigFlow.async_step_import
(self, user_input=None)
Handle import initiated flow.
Handle import initiated flow.
async def async_step_import(self, user_input=None): """Handle import initiated flow.""" await self.async_set_unique_id(user_input[CONF_USERNAME]) self._abort_if_unique_id_configured() return await self.async_step_user(user_input=user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", "=", "None", ")", ":", "await", "self", ".", "async_set_unique_id", "(", "user_input", "[", "CONF_USERNAME", "]", ")", "self", ".", "_abort_if_unique_id_configured", "(", ")", "return", "await"...
[ 55, 4 ]
[ 60, 64 ]
python
en
['en', 'en', 'en']
True
UpCloudConfigFlow._async_show_form
(self, step_id, user_input=None, errors=None)
Show our form.
Show our form.
def _async_show_form(self, step_id, user_input=None, errors=None): """Show our form.""" if user_input is None: user_input = {} return self.async_show_form( step_id=step_id, data_schema=vol.Schema( { vol.Required( ...
[ "def", "_async_show_form", "(", "self", ",", "step_id", ",", "user_input", "=", "None", ",", "errors", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "user_input", "=", "{", "}", "return", "self", ".", "async_show_form", "(", "step_id", "=...
[ 63, 4 ]
[ 80, 9 ]
python
en
['en', 'en', 'en']
True
UpCloudConfigFlow.async_get_options_flow
(config_entry)
Get options flow.
Get options flow.
def async_get_options_flow(config_entry): """Get options flow.""" return UpCloudOptionsFlow(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "UpCloudOptionsFlow", "(", "config_entry", ")" ]
[ 84, 4 ]
[ 86, 47 ]
python
en
['en', 'nl', 'en']
True
UpCloudOptionsFlow.__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
[ "def", "__init__", "(", "self", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 92, 4 ]
[ 94, 40 ]
python
en
['en', 'en', 'en']
True
UpCloudOptionsFlow.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 user_input is not None: return self.async_create_entry(title="", data=user_input) data_schema = vol.Schema( { vol.Optional( CONF_SCAN_INTERVAL, ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "data_schem...
[ 96, 4 ]
[ 111, 76 ]
python
en
['en', 'nl', 'en']
True
test_unload_entry
(hass)
Test successful unload of entry.
Test successful unload of entry.
async def test_unload_entry(hass): """Test successful unload of entry.""" entry = await init_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state == ENTRY_STATE_LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_bloc...
[ "async", "def", "test_unload_entry", "(", "hass", ")", ":", "entry", "=", "await", "init_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ")", "==", "1", "assert", "entry", ".", ...
[ 16, 0 ]
[ 27, 36 ]
python
en
['en', 'en', 'en']
True
test_async_setup_raises_entry_not_ready
(hass)
Test that it throws ConfigEntryNotReady when exception occurs during setup.
Test that it throws ConfigEntryNotReady when exception occurs during setup.
async def test_async_setup_raises_entry_not_ready(hass): """Test that it throws ConfigEntryNotReady when exception occurs during setup.""" config_entry = MockConfigEntry( domain=DOMAIN, data={CONF_URL: "https://some.url:1234"}, ) config_entry.add_to_hass(hass) with patch( "h...
[ "async", "def", "test_async_setup_raises_entry_not_ready", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "CONF_URL", ":", "\"https://some.url:1234\"", "}", ",", ")", "config_entry", ".", "add_to...
[ 30, 0 ]
[ 43, 56 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a Point's binary sensors based on a config entry.
Set up a Point's binary sensors based on a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a Point's binary sensors based on a config entry.""" async def async_discover_sensor(device_id): """Discover and add a discovered sensor.""" client = hass.data[POINT_DOMAIN][config_entry.entry_id] async_add_e...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "async", "def", "async_discover_sensor", "(", "device_id", ")", ":", "\"\"\"Discover and add a discovered sensor.\"\"\"", "client", "=", "hass", ".", "data", "[...
[ 50, 0 ]
[ 66, 5 ]
python
en
['en', 'en', 'en']
True
MinutPointBinarySensor.__init__
(self, point_client, device_id, device_class)
Initialize the binary sensor.
Initialize the binary sensor.
def __init__(self, point_client, device_id, device_class): """Initialize the binary sensor.""" super().__init__(point_client, device_id, device_class) self._async_unsub_hook_dispatcher_connect = None self._events = EVENTS[device_class] self._is_on = None
[ "def", "__init__", "(", "self", ",", "point_client", ",", "device_id", ",", "device_class", ")", ":", "super", "(", ")", ".", "__init__", "(", "point_client", ",", "device_id", ",", "device_class", ")", "self", ".", "_async_unsub_hook_dispatcher_connect", "=", ...
[ 72, 4 ]
[ 78, 26 ]
python
en
['en', 'haw', 'en']
True
MinutPointBinarySensor.async_added_to_hass
(self)
Call when entity is added to HOme Assistant.
Call when entity is added to HOme Assistant.
async def async_added_to_hass(self): """Call when entity is added to HOme Assistant.""" await super().async_added_to_hass() self._async_unsub_hook_dispatcher_connect = async_dispatcher_connect( self.hass, SIGNAL_WEBHOOK, self._webhook_event )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "_async_unsub_hook_dispatcher_connect", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "SIGNAL_WEBHOOK", "...
[ 80, 4 ]
[ 85, 9 ]
python
en
['en', 'en', 'en']
True
MinutPointBinarySensor.async_will_remove_from_hass
(self)
Disconnect dispatcher listener when removed.
Disconnect dispatcher listener when removed.
async def async_will_remove_from_hass(self): """Disconnect dispatcher listener when removed.""" await super().async_will_remove_from_hass() if self._async_unsub_hook_dispatcher_connect: self._async_unsub_hook_dispatcher_connect()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_will_remove_from_hass", "(", ")", "if", "self", ".", "_async_unsub_hook_dispatcher_connect", ":", "self", ".", "_async_unsub_hook_dispatcher_connect", "(", ")...
[ 87, 4 ]
[ 91, 55 ]
python
en
['en', 'en', 'en']
True
MinutPointBinarySensor._update_callback
(self)
Update the value of the sensor.
Update the value of the sensor.
async def _update_callback(self): """Update the value of the sensor.""" if not self.is_updated: return if self._events[0] in self.device.ongoing_events: self._is_on = True else: self._is_on = None self.async_write_ha_state()
[ "async", "def", "_update_callback", "(", "self", ")", ":", "if", "not", "self", ".", "is_updated", ":", "return", "if", "self", ".", "_events", "[", "0", "]", "in", "self", ".", "device", ".", "ongoing_events", ":", "self", ".", "_is_on", "=", "True", ...
[ 93, 4 ]
[ 101, 35 ]
python
en
['en', 'en', 'en']
True
MinutPointBinarySensor._webhook_event
(self, data, webhook)
Process new event from the webhook.
Process new event from the webhook.
def _webhook_event(self, data, webhook): """Process new event from the webhook.""" if self.device.webhook != webhook: return _type = data.get("event", {}).get("type") _device_id = data.get("event", {}).get("device_id") if _type not in self._events or _device_id != sel...
[ "def", "_webhook_event", "(", "self", ",", "data", ",", "webhook", ")", ":", "if", "self", ".", "device", ".", "webhook", "!=", "webhook", ":", "return", "_type", "=", "data", ".", "get", "(", "\"event\"", ",", "{", "}", ")", ".", "get", "(", "\"ty...
[ 104, 4 ]
[ 117, 35 ]
python
en
['en', 'en', 'en']
True
MinutPointBinarySensor.is_on
(self)
Return the state of the binary sensor.
Return the state of the binary sensor.
def is_on(self): """Return the state of the binary sensor.""" if self.device_class == DEVICE_CLASS_CONNECTIVITY: # connectivity is the other way around. return not self._is_on return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "if", "self", ".", "device_class", "==", "DEVICE_CLASS_CONNECTIVITY", ":", "# connectivity is the other way around.", "return", "not", "self", ".", "_is_on", "return", "self", ".", "_is_on" ]
[ 120, 4 ]
[ 125, 26 ]
python
en
['en', 'ig', 'en']
True
rank_quadgrams
(corpus, metric, path=None)
Find and rank quadgrams from the supplied corpus using the given association metric. Write the quadgrams out to the given path if supplied otherwise return the list in memory.
Find and rank quadgrams from the supplied corpus using the given association metric. Write the quadgrams out to the given path if supplied otherwise return the list in memory.
def rank_quadgrams(corpus, metric, path=None): """ Find and rank quadgrams from the supplied corpus using the given association metric. Write the quadgrams out to the given path if supplied otherwise return the list in memory. """ # Create a collocation ranking utility from corpus words. ng...
[ "def", "rank_quadgrams", "(", "corpus", ",", "metric", ",", "path", "=", "None", ")", ":", "# Create a collocation ranking utility from corpus words.", "ngrams", "=", "QuadgramCollocationFinder", ".", "from_words", "(", "corpus", ".", "words", "(", ")", ")", "# Rank...
[ 9, 0 ]
[ 28, 21 ]
python
en
['en', 'error', 'th']
False
parse_args
()
Helper function parsing the command line options @retval ArgumentParser
Helper function parsing the command line options
def parse_args(): """ Helper function parsing the command line options @retval ArgumentParser """ parser = ArgumentParser( description=( "PyTorch TPU distributed training launch " "helper utility that will spawn up " "multiple distributed processes" ...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "ArgumentParser", "(", "description", "=", "(", "\"PyTorch TPU distributed training launch \"", "\"helper utility that will spawn up \"", "\"multiple distributed processes\"", ")", ")", "# Optional arguments for the launch helper",...
[ 34, 0 ]
[ 65, 30 ]
python
en
['en', 'error', 'th']
False
async_setup_services
(hass: HomeAssistantType)
Set up the HomematicIP Cloud services.
Set up the HomematicIP Cloud services.
async def async_setup_services(hass: HomeAssistantType) -> None: """Set up the HomematicIP Cloud services.""" if hass.services.async_services().get(HMIPC_DOMAIN): return @verify_domain_control(hass, HMIPC_DOMAIN) async def async_call_hmipc_service(service: ServiceCallType): """Call cor...
[ "async", "def", "async_setup_services", "(", "hass", ":", "HomeAssistantType", ")", "->", "None", ":", "if", "hass", ".", "services", ".", "async_services", "(", ")", ".", "get", "(", "HMIPC_DOMAIN", ")", ":", "return", "@", "verify_domain_control", "(", "ha...
[ 109, 0 ]
[ 193, 5 ]
python
en
['en', 'en', 'en']
True
async_unload_services
(hass: HomeAssistantType)
Unload HomematicIP Cloud services.
Unload HomematicIP Cloud services.
async def async_unload_services(hass: HomeAssistantType): """Unload HomematicIP Cloud services.""" if hass.data[HMIPC_DOMAIN]: return for hmipc_service in HMIPC_SERVICES: hass.services.async_remove(domain=HMIPC_DOMAIN, service=hmipc_service)
[ "async", "def", "async_unload_services", "(", "hass", ":", "HomeAssistantType", ")", ":", "if", "hass", ".", "data", "[", "HMIPC_DOMAIN", "]", ":", "return", "for", "hmipc_service", "in", "HMIPC_SERVICES", ":", "hass", ".", "services", ".", "async_remove", "("...
[ 196, 0 ]
[ 202, 78 ]
python
ca
['nl', 'ca', 'en']
False
_async_activate_eco_mode_with_duration
( hass: HomeAssistantType, service: ServiceCallType )
Service to activate eco mode with duration.
Service to activate eco mode with duration.
async def _async_activate_eco_mode_with_duration( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to activate eco mode with duration.""" duration = service.data[ATTR_DURATION] hapid = service.data.get(ATTR_ACCESSPOINT_ID) if hapid: home = _get_home(hass, hapid) ...
[ "async", "def", "_async_activate_eco_mode_with_duration", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "duration", "=", "service", ".", "data", "[", "ATTR_DURATION", "]", "hapid", "=", "service", ".", "da...
[ 205, 0 ]
[ 218, 67 ]
python
en
['en', 'en', 'en']
True
_async_activate_eco_mode_with_period
( hass: HomeAssistantType, service: ServiceCallType )
Service to activate eco mode with period.
Service to activate eco mode with period.
async def _async_activate_eco_mode_with_period( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to activate eco mode with period.""" endtime = service.data[ATTR_ENDTIME] hapid = service.data.get(ATTR_ACCESSPOINT_ID) if hapid: home = _get_home(hass, hapid) if ...
[ "async", "def", "_async_activate_eco_mode_with_period", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "endtime", "=", "service", ".", "data", "[", "ATTR_ENDTIME", "]", "hapid", "=", "service", ".", "data",...
[ 221, 0 ]
[ 234, 64 ]
python
en
['en', 'en', 'en']
True
_async_activate_vacation
( hass: HomeAssistantType, service: ServiceCallType )
Service to activate vacation.
Service to activate vacation.
async def _async_activate_vacation( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to activate vacation.""" endtime = service.data[ATTR_ENDTIME] temperature = service.data[ATTR_TEMPERATURE] hapid = service.data.get(ATTR_ACCESSPOINT_ID) if hapid: home = _get_home...
[ "async", "def", "_async_activate_vacation", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "endtime", "=", "service", ".", "data", "[", "ATTR_ENDTIME", "]", "temperature", "=", "service", ".", "data", "["...
[ 237, 0 ]
[ 251, 66 ]
python
en
['en', 'en', 'en']
True
_async_deactivate_eco_mode
( hass: HomeAssistantType, service: ServiceCallType )
Service to deactivate eco mode.
Service to deactivate eco mode.
async def _async_deactivate_eco_mode( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to deactivate eco mode.""" hapid = service.data.get(ATTR_ACCESSPOINT_ID) if hapid: home = _get_home(hass, hapid) if home: await home.deactivate_absence() else: ...
[ "async", "def", "_async_deactivate_eco_mode", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "hapid", "=", "service", ".", "data", ".", "get", "(", "ATTR_ACCESSPOINT_ID", ")", "if", "hapid", ":", "home", ...
[ 254, 0 ]
[ 266, 47 ]
python
it
['it', 'en', 'it']
True
_async_deactivate_vacation
( hass: HomeAssistantType, service: ServiceCallType )
Service to deactivate vacation.
Service to deactivate vacation.
async def _async_deactivate_vacation( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to deactivate vacation.""" hapid = service.data.get(ATTR_ACCESSPOINT_ID) if hapid: home = _get_home(hass, hapid) if home: await home.deactivate_vacation() else: ...
[ "async", "def", "_async_deactivate_vacation", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "hapid", "=", "service", ".", "data", ".", "get", "(", "ATTR_ACCESSPOINT_ID", ")", "if", "hapid", ":", "home", ...
[ 269, 0 ]
[ 281, 48 ]
python
en
['it', 'en', 'en']
True
_set_active_climate_profile
( hass: HomeAssistantType, service: ServiceCallType )
Service to set the active climate profile.
Service to set the active climate profile.
async def _set_active_climate_profile( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to set the active climate profile.""" entity_id_list = service.data[ATTR_ENTITY_ID] climate_profile_index = service.data[ATTR_CLIMATE_PROFILE_INDEX] - 1 for hap in hass.data[HMIPC_DOMAIN]....
[ "async", "def", "_set_active_climate_profile", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "entity_id_list", "=", "service", ".", "data", "[", "ATTR_ENTITY_ID", "]", "climate_profile_index", "=", "service", ...
[ 284, 0 ]
[ 300, 73 ]
python
en
['en', 'en', 'en']
True
_async_dump_hap_config
( hass: HomeAssistantType, service: ServiceCallType )
Service to dump the configuration of a Homematic IP Access Point.
Service to dump the configuration of a Homematic IP Access Point.
async def _async_dump_hap_config( hass: HomeAssistantType, service: ServiceCallType ) -> None: """Service to dump the configuration of a Homematic IP Access Point.""" config_path = service.data.get(ATTR_CONFIG_OUTPUT_PATH) or hass.config.config_dir config_file_prefix = service.data[ATTR_CONFIG_OUTPUT_FI...
[ "async", "def", "_async_dump_hap_config", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", "->", "None", ":", "config_path", "=", "service", ".", "data", ".", "get", "(", "ATTR_CONFIG_OUTPUT_PATH", ")", "or", "hass", ".", "co...
[ 303, 0 ]
[ 324, 59 ]
python
en
['en', 'en', 'en']
True
_async_reset_energy_counter
( hass: HomeAssistantType, service: ServiceCallType )
Service to reset the energy counter.
Service to reset the energy counter.
async def _async_reset_energy_counter( hass: HomeAssistantType, service: ServiceCallType ): """Service to reset the energy counter.""" entity_id_list = service.data[ATTR_ENTITY_ID] for hap in hass.data[HMIPC_DOMAIN].values(): if entity_id_list != "all": for entity_id in entity_id_li...
[ "async", "def", "_async_reset_energy_counter", "(", "hass", ":", "HomeAssistantType", ",", "service", ":", "ServiceCallType", ")", ":", "entity_id_list", "=", "service", ".", "data", "[", "ATTR_ENTITY_ID", "]", "for", "hap", "in", "hass", ".", "data", "[", "HM...
[ 327, 0 ]
[ 342, 55 ]
python
en
['en', 'en', 'en']
True
_get_home
(hass: HomeAssistantType, hapid: str)
Return a HmIP home.
Return a HmIP home.
def _get_home(hass: HomeAssistantType, hapid: str) -> Optional[AsyncHome]: """Return a HmIP home.""" hap = hass.data[HMIPC_DOMAIN].get(hapid) if hap: return hap.home _LOGGER.info("No matching access point found for access point id %s", hapid) return None
[ "def", "_get_home", "(", "hass", ":", "HomeAssistantType", ",", "hapid", ":", "str", ")", "->", "Optional", "[", "AsyncHome", "]", ":", "hap", "=", "hass", ".", "data", "[", "HMIPC_DOMAIN", "]", ".", "get", "(", "hapid", ")", "if", "hap", ":", "retur...
[ 345, 0 ]
[ 352, 15 ]
python
en
['en', 'gd', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Nuki lock platform.
Set up the Nuki lock platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Nuki lock platform.""" bridge = NukiBridge( config[CONF_HOST], config[CONF_TOKEN], config[CONF_PORT], True, DEFAULT_TIMEOUT, ) devices = [NukiLockEntity(lock) for lock in bridge.lo...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "bridge", "=", "NukiBridge", "(", "config", "[", "CONF_HOST", "]", ",", "config", "[", "CONF_TOKEN", "]", ",", "config", "[", "CONF_PORT...
[ 50, 0 ]
[ 81, 25 ]
python
en
['en', 'lv', 'en']
True
NukiDeviceEntity.__init__
(self, nuki_device)
Initialize the lock.
Initialize the lock.
def __init__(self, nuki_device): """Initialize the lock.""" self._nuki_device = nuki_device self._available = nuki_device.state not in ERROR_STATES
[ "def", "__init__", "(", "self", ",", "nuki_device", ")", ":", "self", ".", "_nuki_device", "=", "nuki_device", "self", ".", "_available", "=", "nuki_device", ".", "state", "not", "in", "ERROR_STATES" ]
[ 87, 4 ]
[ 90, 63 ]
python
en
['en', 'en', 'en']
True
NukiDeviceEntity.name
(self)
Return the name of the lock.
Return the name of the lock.
def name(self): """Return the name of the lock.""" return self._nuki_device.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_nuki_device", ".", "name" ]
[ 93, 4 ]
[ 95, 37 ]
python
en
['en', 'en', 'en']
True
NukiDeviceEntity.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return self._nuki_device.nuki_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_nuki_device", ".", "nuki_id" ]
[ 98, 4 ]
[ 100, 40 ]
python
ca
['fr', 'ca', 'en']
False
NukiDeviceEntity.is_locked
(self)
Return true if lock is locked.
Return true if lock is locked.
def is_locked(self): """Return true if lock is locked."""
[ "def", "is_locked", "(", "self", ")", ":" ]
[ 104, 4 ]
[ 105, 44 ]
python
en
['en', 'mt', 'en']
True
NukiDeviceEntity.device_state_attributes
(self)
Return the device specific state attributes.
Return the device specific state attributes.
def device_state_attributes(self): """Return the device specific state attributes.""" data = { ATTR_BATTERY_CRITICAL: self._nuki_device.battery_critical, ATTR_NUKI_ID: self._nuki_device.nuki_id, } return data
[ "def", "device_state_attributes", "(", "self", ")", ":", "data", "=", "{", "ATTR_BATTERY_CRITICAL", ":", "self", ".", "_nuki_device", ".", "battery_critical", ",", "ATTR_NUKI_ID", ":", "self", ".", "_nuki_device", ".", "nuki_id", ",", "}", "return", "data" ]
[ 108, 4 ]
[ 114, 19 ]
python
en
['en', 'en', 'en']
True
NukiDeviceEntity.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_OPEN
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_OPEN" ]
[ 117, 4 ]
[ 119, 27 ]
python
en
['da', 'en', 'en']
True
NukiDeviceEntity.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 122, 4 ]
[ 124, 30 ]
python
en
['en', 'en', 'en']
True
NukiDeviceEntity.update
(self)
Update the nuki lock properties.
Update the nuki lock properties.
def update(self): """Update the nuki lock properties.""" for level in (False, True): try: self._nuki_device.update(aggressive=level) except RequestException: _LOGGER.warning("Network issues detect with %s", self.name) self._availabl...
[ "def", "update", "(", "self", ")", ":", "for", "level", "in", "(", "False", ",", "True", ")", ":", "try", ":", "self", ".", "_nuki_device", ".", "update", "(", "aggressive", "=", "level", ")", "except", "RequestException", ":", "_LOGGER", ".", "warning...
[ 126, 4 ]
[ 139, 21 ]
python
en
['en', 'af', 'en']
True
NukiDeviceEntity.lock
(self, **kwargs)
Lock the device.
Lock the device.
def lock(self, **kwargs): """Lock the device."""
[ "def", "lock", "(", "self", ",", "*", "*", "kwargs", ")", ":" ]
[ 142, 4 ]
[ 143, 30 ]
python
en
['en', 'en', 'en']
True
NukiDeviceEntity.unlock
(self, **kwargs)
Unlock the device.
Unlock the device.
def unlock(self, **kwargs): """Unlock the device."""
[ "def", "unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":" ]
[ 146, 4 ]
[ 147, 32 ]
python
en
['en', 'zh', 'en']
True
NukiDeviceEntity.open
(self, **kwargs)
Open the door latch.
Open the door latch.
def open(self, **kwargs): """Open the door latch."""
[ "def", "open", "(", "self", ",", "*", "*", "kwargs", ")", ":" ]
[ 150, 4 ]
[ 151, 34 ]
python
en
['en', 'nl', 'en']
True
NukiLockEntity.is_locked
(self)
Return true if lock is locked.
Return true if lock is locked.
def is_locked(self): """Return true if lock is locked.""" return self._nuki_device.is_locked
[ "def", "is_locked", "(", "self", ")", ":", "return", "self", ".", "_nuki_device", ".", "is_locked" ]
[ 158, 4 ]
[ 160, 42 ]
python
en
['en', 'mt', 'en']
True
NukiLockEntity.lock
(self, **kwargs)
Lock the device.
Lock the device.
def lock(self, **kwargs): """Lock the device.""" self._nuki_device.lock()
[ "def", "lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "lock", "(", ")" ]
[ 162, 4 ]
[ 164, 32 ]
python
en
['en', 'en', 'en']
True
NukiLockEntity.unlock
(self, **kwargs)
Unlock the device.
Unlock the device.
def unlock(self, **kwargs): """Unlock the device.""" self._nuki_device.unlock()
[ "def", "unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "unlock", "(", ")" ]
[ 166, 4 ]
[ 168, 34 ]
python
en
['en', 'zh', 'en']
True
NukiLockEntity.open
(self, **kwargs)
Open the door latch.
Open the door latch.
def open(self, **kwargs): """Open the door latch.""" self._nuki_device.unlatch()
[ "def", "open", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "unlatch", "(", ")" ]
[ 170, 4 ]
[ 172, 35 ]
python
en
['en', 'nl', 'en']
True
NukiLockEntity.lock_n_go
(self, unlatch=False, **kwargs)
Lock and go. This will first unlock the door, then wait for 20 seconds (or another amount of time depending on the lock settings) and relock.
Lock and go.
def lock_n_go(self, unlatch=False, **kwargs): """Lock and go. This will first unlock the door, then wait for 20 seconds (or another amount of time depending on the lock settings) and relock. """ self._nuki_device.lock_n_go(unlatch, kwargs)
[ "def", "lock_n_go", "(", "self", ",", "unlatch", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "lock_n_go", "(", "unlatch", ",", "kwargs", ")" ]
[ 174, 4 ]
[ 180, 52 ]
python
en
['en', 'en', 'en']
True
NukiOpenerEntity.is_locked
(self)
Return true if ring-to-open is enabled.
Return true if ring-to-open is enabled.
def is_locked(self): """Return true if ring-to-open is enabled.""" return not self._nuki_device.is_rto_activated
[ "def", "is_locked", "(", "self", ")", ":", "return", "not", "self", ".", "_nuki_device", ".", "is_rto_activated" ]
[ 187, 4 ]
[ 189, 53 ]
python
en
['en', 'en', 'en']
True
NukiOpenerEntity.lock
(self, **kwargs)
Disable ring-to-open.
Disable ring-to-open.
def lock(self, **kwargs): """Disable ring-to-open.""" self._nuki_device.deactivate_rto()
[ "def", "lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "deactivate_rto", "(", ")" ]
[ 191, 4 ]
[ 193, 42 ]
python
en
['en', 'en', 'en']
False
NukiOpenerEntity.unlock
(self, **kwargs)
Enable ring-to-open.
Enable ring-to-open.
def unlock(self, **kwargs): """Enable ring-to-open.""" self._nuki_device.activate_rto()
[ "def", "unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "activate_rto", "(", ")" ]
[ 195, 4 ]
[ 197, 40 ]
python
en
['en', 'en', 'en']
False
NukiOpenerEntity.open
(self, **kwargs)
Buzz open the door.
Buzz open the door.
def open(self, **kwargs): """Buzz open the door.""" self._nuki_device.electric_strike_actuation()
[ "def", "open", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_nuki_device", ".", "electric_strike_actuation", "(", ")" ]
[ 199, 4 ]
[ 201, 53 ]
python
en
['en', 'nl', 'en']
True
host_valid
(host)
Return True if hostname or IP address is valid.
Return True if hostname or IP address is valid.
def host_valid(host): """Return True if hostname or IP address is valid.""" try: if ipaddress.ip_address(host).version == (4 or 6): return True except ValueError: disallowed = re.compile(r"[^a-zA-Z\d\-]") return all(x and not disallowed.search(x) for x in host.split("."))
[ "def", "host_valid", "(", "host", ")", ":", "try", ":", "if", "ipaddress", ".", "ip_address", "(", "host", ")", ".", "version", "==", "(", "4", "or", "6", ")", ":", "return", "True", "except", "ValueError", ":", "disallowed", "=", "re", ".", "compile...
[ 28, 0 ]
[ 35, 75 ]
python
en
['en', 'af', 'en']
True
BraviaTVConfigFlow.__init__
(self)
Initialize.
Initialize.
def __init__(self): """Initialize.""" self.braviarc = None self.host = None self.title = None self.mac = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "braviarc", "=", "None", "self", ".", "host", "=", "None", "self", ".", "title", "=", "None", "self", ".", "mac", "=", "None" ]
[ 44, 4 ]
[ 49, 23 ]
python
en
['en', 'en', 'it']
False
BraviaTVConfigFlow.init_device
(self, pin)
Initialize Bravia TV device.
Initialize Bravia TV device.
async def init_device(self, pin): """Initialize Bravia TV device.""" await self.hass.async_add_executor_job( self.braviarc.connect, pin, CLIENTID_PREFIX, NICKNAME ) connected = await self.hass.async_add_executor_job(self.braviarc.is_connected) if not connected: ...
[ "async", "def", "init_device", "(", "self", ",", "pin", ")", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "braviarc", ".", "connect", ",", "pin", ",", "CLIENTID_PREFIX", ",", "NICKNAME", ")", "connected", "=", "await"...
[ 51, 4 ]
[ 71, 40 ]
python
es
['es', 'hr', 'it']
False
BraviaTVConfigFlow.async_get_options_flow
(config_entry)
Bravia TV options callback.
Bravia TV options callback.
def async_get_options_flow(config_entry): """Bravia TV options callback.""" return BraviaTVOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "BraviaTVOptionsFlowHandler", "(", "config_entry", ")" ]
[ 75, 4 ]
[ 77, 55 ]
python
en
['fr', 'hr', 'en']
False
BraviaTVConfigFlow.async_step_import
(self, user_input=None)
Handle configuration by yaml file.
Handle configuration by yaml file.
async def async_step_import(self, user_input=None): """Handle configuration by yaml file.""" self.host = user_input[CONF_HOST] self.braviarc = BraviaRC(self.host) try: await self.init_device(user_input[CONF_PIN]) except CannotConnect: _LOGGER.error("Impor...
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", "=", "None", ")", ":", "self", ".", "host", "=", "user_input", "[", "CONF_HOST", "]", "self", ".", "braviarc", "=", "BraviaRC", "(", "self", ".", "host", ")", "try", ":", "await", "se...
[ 79, 4 ]
[ 98, 73 ]
python
en
['en', 'en', 'en']
True