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
IPWebcamSensor.name
(self)
Return the name of the sensor, if any.
Return the name of the sensor, if any.
def name(self): """Return the name of the sensor, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 46, 4 ]
[ 48, 25 ]
python
en
['en', 'en', 'en']
True
IPWebcamSensor.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 51, 4 ]
[ 53, 25 ]
python
en
['en', 'en', 'en']
True
IPWebcamSensor.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" ]
[ 56, 4 ]
[ 58, 26 ]
python
en
['en', 'en', 'en']
True
IPWebcamSensor.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self): """Retrieve latest state.""" if self._sensor in ("audio_connections", "video_connections"): if not self._ipcam.status_data: return self._state = self._ipcam.status_data.get(self._sensor) self._unit = "Connections" ...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "self", ".", "_sensor", "in", "(", "\"audio_connections\"", ",", "\"video_connections\"", ")", ":", "if", "not", "self", ".", "_ipcam", ".", "status_data", ":", "return", "self", ".", "_state", "...
[ 60, 4 ]
[ 68, 77 ]
python
en
['es', 'sk', 'en']
False
IPWebcamSensor.icon
(self)
Return the icon for the sensor.
Return the icon for the sensor.
def icon(self): """Return the icon for the sensor.""" if self._sensor == "battery_level" and self._state is not None: return icon_for_battery_level(int(self._state)) return ICON_MAP.get(self._sensor, "mdi:eye")
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_sensor", "==", "\"battery_level\"", "and", "self", ".", "_state", "is", "not", "None", ":", "return", "icon_for_battery_level", "(", "int", "(", "self", ".", "_state", ")", ")", "return", "ICON_M...
[ 71, 4 ]
[ 75, 52 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up cover controlled by shell commands.
Set up cover controlled by shell commands.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up cover controlled by shell commands.""" setup_reload_service(hass, DOMAIN, PLATFORMS) devices = config.get(CONF_COVERS, {}) covers = [] for device_name, device_config in devices.items(): value_template = device_...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "setup_reload_service", "(", "hass", ",", "DOMAIN", ",", "PLATFORMS", ")", "devices", "=", "config", ".", "get", "(", "CONF_COVERS", ",", ...
[ 40, 0 ]
[ 70, 24 ]
python
en
['en', 'en', 'en']
True
CommandCover.__init__
( self, hass, name, command_open, command_close, command_stop, command_state, value_template, timeout, )
Initialize the cover.
Initialize the cover.
def __init__( self, hass, name, command_open, command_close, command_stop, command_state, value_template, timeout, ): """Initialize the cover.""" self._hass = hass self._name = name self._state = None sel...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ",", "command_open", ",", "command_close", ",", "command_stop", ",", "command_state", ",", "value_template", ",", "timeout", ",", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_name", ...
[ 76, 4 ]
[ 96, 31 ]
python
en
['en', 'en', 'en']
True
CommandCover._move_cover
(self, command)
Execute the actual commands.
Execute the actual commands.
def _move_cover(self, command): """Execute the actual commands.""" _LOGGER.info("Running command: %s", command) success = call_shell_with_timeout(command, self._timeout) == 0 if not success: _LOGGER.error("Command failed: %s", command) return success
[ "def", "_move_cover", "(", "self", ",", "command", ")", ":", "_LOGGER", ".", "info", "(", "\"Running command: %s\"", ",", "command", ")", "success", "=", "call_shell_with_timeout", "(", "command", ",", "self", ".", "_timeout", ")", "==", "0", "if", "not", ...
[ 98, 4 ]
[ 107, 22 ]
python
en
['en', 'en', 'en']
True
CommandCover._query_state_value
(self, command)
Execute state command for return value.
Execute state command for return value.
def _query_state_value(self, command): """Execute state command for return value.""" _LOGGER.info("Running state value command: %s", command) return check_output_or_log(command, self._timeout)
[ "def", "_query_state_value", "(", "self", ",", "command", ")", ":", "_LOGGER", ".", "info", "(", "\"Running state value command: %s\"", ",", "command", ")", "return", "check_output_or_log", "(", "command", ",", "self", ".", "_timeout", ")" ]
[ 109, 4 ]
[ 112, 58 ]
python
en
['en', 'en', 'en']
True
CommandCover.should_poll
(self)
Only poll if we have state command.
Only poll if we have state command.
def should_poll(self): """Only poll if we have state command.""" return self._command_state is not None
[ "def", "should_poll", "(", "self", ")", ":", "return", "self", ".", "_command_state", "is", "not", "None" ]
[ 115, 4 ]
[ 117, 46 ]
python
en
['en', 'en', 'en']
True
CommandCover.name
(self)
Return the name of the cover.
Return the name of the cover.
def name(self): """Return the name of the cover.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 120, 4 ]
[ 122, 25 ]
python
en
['en', 'en', 'en']
True
CommandCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self): """Return if the cover is closed.""" if self.current_cover_position is not None: return self.current_cover_position == 0
[ "def", "is_closed", "(", "self", ")", ":", "if", "self", ".", "current_cover_position", "is", "not", "None", ":", "return", "self", ".", "current_cover_position", "==", "0" ]
[ 125, 4 ]
[ 128, 51 ]
python
en
['en', 'en', 'en']
True
CommandCover.current_cover_position
(self)
Return current position of cover. None is unknown, 0 is closed, 100 is fully open.
Return current position of cover.
def current_cover_position(self): """Return current position of cover. None is unknown, 0 is closed, 100 is fully open. """ return self._state
[ "def", "current_cover_position", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 131, 4 ]
[ 136, 26 ]
python
en
['en', 'en', 'en']
True
CommandCover._query_state
(self)
Query for the state.
Query for the state.
def _query_state(self): """Query for the state.""" if not self._command_state: _LOGGER.error("No state command specified") return return self._query_state_value(self._command_state)
[ "def", "_query_state", "(", "self", ")", ":", "if", "not", "self", ".", "_command_state", ":", "_LOGGER", ".", "error", "(", "\"No state command specified\"", ")", "return", "return", "self", ".", "_query_state_value", "(", "self", ".", "_command_state", ")" ]
[ 138, 4 ]
[ 143, 59 ]
python
en
['en', 'en', 'en']
True
CommandCover.update
(self)
Update device state.
Update device state.
def update(self): """Update device state.""" if self._command_state: payload = str(self._query_state()) if self._value_template: payload = self._value_template.render_with_possible_json_value(payload) self._state = int(payload)
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "_command_state", ":", "payload", "=", "str", "(", "self", ".", "_query_state", "(", ")", ")", "if", "self", ".", "_value_template", ":", "payload", "=", "self", ".", "_value_template", ".", "r...
[ 145, 4 ]
[ 151, 38 ]
python
en
['fr', 'en', 'en']
True
CommandCover.open_cover
(self, **kwargs)
Open the cover.
Open the cover.
def open_cover(self, **kwargs): """Open the cover.""" self._move_cover(self._command_open)
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_move_cover", "(", "self", ".", "_command_open", ")" ]
[ 153, 4 ]
[ 155, 44 ]
python
en
['en', 'en', 'en']
True
CommandCover.close_cover
(self, **kwargs)
Close the cover.
Close the cover.
def close_cover(self, **kwargs): """Close the cover.""" self._move_cover(self._command_close)
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_move_cover", "(", "self", ".", "_command_close", ")" ]
[ 157, 4 ]
[ 159, 45 ]
python
en
['en', 'en', 'en']
True
CommandCover.stop_cover
(self, **kwargs)
Stop the cover.
Stop the cover.
def stop_cover(self, **kwargs): """Stop the cover.""" self._move_cover(self._command_stop)
[ "def", "stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_move_cover", "(", "self", ".", "_command_stop", ")" ]
[ 161, 4 ]
[ 163, 44 ]
python
en
['en', 'en', 'en']
True
copyHdfsDirectoryToLocal
(hdfsDirectory, localDirectory, hdfsClient)
Copy directory from HDFS to local
Copy directory from HDFS to local
def copyHdfsDirectoryToLocal(hdfsDirectory, localDirectory, hdfsClient): '''Copy directory from HDFS to local''' if not os.path.exists(localDirectory): os.makedirs(localDirectory) try: listing = hdfsClient.list_status(hdfsDirectory) except Exception as exception: nni_log(LogType....
[ "def", "copyHdfsDirectoryToLocal", "(", "hdfsDirectory", ",", "localDirectory", ",", "hdfsClient", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "localDirectory", ")", ":", "os", ".", "makedirs", "(", "localDirectory", ")", "try", ":", "listi...
[ 7, 0 ]
[ 27, 69 ]
python
en
['en', 'en', 'en']
True
copyHdfsFileToLocal
(hdfsFilePath, localFilePath, hdfsClient, override=True)
Copy file from HDFS to local
Copy file from HDFS to local
def copyHdfsFileToLocal(hdfsFilePath, localFilePath, hdfsClient, override=True): '''Copy file from HDFS to local''' if not hdfsClient.exists(hdfsFilePath): raise Exception('HDFS file {} does not exist!'.format(hdfsFilePath)) try: file_status = hdfsClient.get_file_status(hdfsFilePath) ...
[ "def", "copyHdfsFileToLocal", "(", "hdfsFilePath", ",", "localFilePath", ",", "hdfsClient", ",", "override", "=", "True", ")", ":", "if", "not", "hdfsClient", ".", "exists", "(", "hdfsFilePath", ")", ":", "raise", "Exception", "(", "'HDFS file {} does not exist!'"...
[ 29, 0 ]
[ 48, 136 ]
python
en
['en', 'en', 'en']
True
copyDirectoryToHdfs
(localDirectory, hdfsDirectory, hdfsClient)
Copy directory from local to HDFS
Copy directory from local to HDFS
def copyDirectoryToHdfs(localDirectory, hdfsDirectory, hdfsClient): '''Copy directory from local to HDFS''' if not os.path.exists(localDirectory): raise Exception('Local Directory does not exist!') hdfsClient.mkdirs(hdfsDirectory) result = True for file in os.listdir(localDirectory): ...
[ "def", "copyDirectoryToHdfs", "(", "localDirectory", ",", "hdfsDirectory", ",", "hdfsClient", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "localDirectory", ")", ":", "raise", "Exception", "(", "'Local Directory does not exist!'", ")", "hdfsClient...
[ 50, 0 ]
[ 73, 17 ]
python
en
['en', 'en', 'en']
True
copyFileToHdfs
(localFilePath, hdfsFilePath, hdfsClient, override=True)
Copy a local file to HDFS directory
Copy a local file to HDFS directory
def copyFileToHdfs(localFilePath, hdfsFilePath, hdfsClient, override=True): '''Copy a local file to HDFS directory''' if not os.path.exists(localFilePath): raise Exception('Local file Path does not exist!') if os.path.isdir(localFilePath): raise Exception('localFile should not a directory!')...
[ "def", "copyFileToHdfs", "(", "localFilePath", ",", "hdfsFilePath", ",", "hdfsClient", ",", "override", "=", "True", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "localFilePath", ")", ":", "raise", "Exception", "(", "'Local file Path does not ...
[ 75, 0 ]
[ 91, 20 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up AdGuard Home sensor based on a config entry.
Set up AdGuard Home sensor based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up AdGuard Home sensor based on a config entry.""" adguard = hass.data[DOMAIN][DATA_ADGUARD_CLIENT] try: version = await adguard.version() except AdGuardHomeConnectionError as exce...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "adguard", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_ADGUARD_CLIENT", "]", "try", ...
[ 20, 0 ]
[ 44, 37 ]
python
en
['en', 'da', 'en']
True
AdGuardHomeSensor.__init__
( self, adguard, name: str, icon: str, measurement: str, unit_of_measurement: str, enabled_default: bool = True, )
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__( self, adguard, name: str, icon: str, measurement: str, unit_of_measurement: str, enabled_default: bool = True, ) -> None: """Initialize AdGuard Home sensor.""" self._state = None self._unit_of_measurement = unit_of_measure...
[ "def", "__init__", "(", "self", ",", "adguard", ",", "name", ":", "str", ",", "icon", ":", "str", ",", "measurement", ":", "str", ",", "unit_of_measurement", ":", "str", ",", "enabled_default", ":", "bool", "=", "True", ",", ")", "->", "None", ":", "...
[ 50, 4 ]
[ 64, 62 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeSensor.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" return "_".join( [ DOMAIN, self.adguard.host, str(self.adguard.port), "sensor", self.measurement, ] )
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "\"_\"", ".", "join", "(", "[", "DOMAIN", ",", "self", ".", "adguard", ".", "host", ",", "str", "(", "self", ".", "adguard", ".", "port", ")", ",", "\"sensor\"", ",", "self", ".", ...
[ 67, 4 ]
[ 77, 9 ]
python
en
['en', 'la', 'en']
True
AdGuardHomeSensor.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" ]
[ 80, 4 ]
[ 82, 26 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeSensor.unit_of_measurement
(self)
Return the unit this state is expressed in.
Return the unit this state is expressed in.
def unit_of_measurement(self) -> str: """Return the unit this state is expressed in.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 85, 4 ]
[ 87, 40 ]
python
en
['en', 'en', 'en']
True
AdGuardHomeDNSQueriesSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard DNS Queries", "mdi:magnify", "dns_queries", "queries" )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard DNS Queries\"", ",", "\"mdi:magnify\"", ",", "\"dns_queries\"", ",", "\"queries\"", ")" ]
[ 93, 4 ]
[ 97, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeDNSQueriesSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" self._state = await self.adguard.stats.dns_queries()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "await", "self", ".", "adguard", ".", "stats", ".", "dns_queries", "(", ")" ]
[ 99, 4 ]
[ 101, 60 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeBlockedFilteringSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard DNS Queries Blocked", "mdi:magnify-close", "blocked_filtering", "queries", enabled_default=False, )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard DNS Queries Blocked\"", ",", "\"mdi:magnify-close\"", ",", "\"blocked_filtering\"", ",", "\"queries\"", ",", "enabled_default", "=", "Fals...
[ 107, 4 ]
[ 116, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeBlockedFilteringSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" self._state = await self.adguard.stats.blocked_filtering()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "await", "self", ".", "adguard", ".", "stats", ".", "blocked_filtering", "(", ")" ]
[ 118, 4 ]
[ 120, 66 ]
python
en
['es', 'en', 'en']
True
AdGuardHomePercentageBlockedSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard DNS Queries Blocked Ratio", "mdi:magnify-close", "blocked_percentage", PERCENTAGE, )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard DNS Queries Blocked Ratio\"", ",", "\"mdi:magnify-close\"", ",", "\"blocked_percentage\"", ",", "PERCENTAGE", ",", ")" ]
[ 126, 4 ]
[ 134, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomePercentageBlockedSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" percentage = await self.adguard.stats.blocked_percentage() self._state = f"{percentage:.2f}"
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "percentage", "=", "await", "self", ".", "adguard", ".", "stats", ".", "blocked_percentage", "(", ")", "self", ".", "_state", "=", "f\"{percentage:.2f}\"" ]
[ 136, 4 ]
[ 139, 41 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeReplacedParentalSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard Parental Control Blocked", "mdi:human-male-girl", "blocked_parental", "requests", )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard Parental Control Blocked\"", ",", "\"mdi:human-male-girl\"", ",", "\"blocked_parental\"", ",", "\"requests\"", ",", ")" ]
[ 145, 4 ]
[ 153, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeReplacedParentalSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" self._state = await self.adguard.stats.replaced_parental()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "await", "self", ".", "adguard", ".", "stats", ".", "replaced_parental", "(", ")" ]
[ 155, 4 ]
[ 157, 66 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeReplacedSafeBrowsingSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard Safe Browsing Blocked", "mdi:shield-half-full", "blocked_safebrowsing", "requests", )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard Safe Browsing Blocked\"", ",", "\"mdi:shield-half-full\"", ",", "\"blocked_safebrowsing\"", ",", "\"requests\"", ",", ")" ]
[ 163, 4 ]
[ 171, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeReplacedSafeBrowsingSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" self._state = await self.adguard.stats.replaced_safebrowsing()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "await", "self", ".", "adguard", ".", "stats", ".", "replaced_safebrowsing", "(", ")" ]
[ 173, 4 ]
[ 175, 70 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeReplacedSafeSearchSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard Safe Searches Enforced", "mdi:shield-search", "enforced_safesearch", "requests", )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard Safe Searches Enforced\"", ",", "\"mdi:shield-search\"", ",", "\"enforced_safesearch\"", ",", "\"requests\"", ",", ")" ]
[ 181, 4 ]
[ 189, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeReplacedSafeSearchSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" self._state = await self.adguard.stats.replaced_safesearch()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "await", "self", ".", "adguard", ".", "stats", ".", "replaced_safesearch", "(", ")" ]
[ 191, 4 ]
[ 193, 68 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeAverageProcessingTimeSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard Average Processing Speed", "mdi:speedometer", "average_speed", TIME_MILLISECONDS, )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard Average Processing Speed\"", ",", "\"mdi:speedometer\"", ",", "\"average_speed\"", ",", "TIME_MILLISECONDS", ",", ")" ]
[ 199, 4 ]
[ 207, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeAverageProcessingTimeSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" average = await self.adguard.stats.avg_processing_time() self._state = f"{average:.2f}"
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "average", "=", "await", "self", ".", "adguard", ".", "stats", ".", "avg_processing_time", "(", ")", "self", ".", "_state", "=", "f\"{average:.2f}\"" ]
[ 209, 4 ]
[ 212, 38 ]
python
en
['es', 'en', 'en']
True
AdGuardHomeRulesCountSensor.__init__
(self, adguard)
Initialize AdGuard Home sensor.
Initialize AdGuard Home sensor.
def __init__(self, adguard): """Initialize AdGuard Home sensor.""" super().__init__( adguard, "AdGuard Rules Count", "mdi:counter", "rules_count", "rules", enabled_default=False, )
[ "def", "__init__", "(", "self", ",", "adguard", ")", ":", "super", "(", ")", ".", "__init__", "(", "adguard", ",", "\"AdGuard Rules Count\"", ",", "\"mdi:counter\"", ",", "\"rules_count\"", ",", "\"rules\"", ",", "enabled_default", "=", "False", ",", ")" ]
[ 218, 4 ]
[ 227, 9 ]
python
en
['en', 'pt', 'en']
True
AdGuardHomeRulesCountSensor._adguard_update
(self)
Update AdGuard Home entity.
Update AdGuard Home entity.
async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" self._state = await self.adguard.filtering.rules_count()
[ "async", "def", "_adguard_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "await", "self", ".", "adguard", ".", "filtering", ".", "rules_count", "(", ")" ]
[ 229, 4 ]
[ 231, 64 ]
python
en
['es', 'en', 'en']
True
get_scanner
(hass, config)
Validate the configuration and return a THOMSON scanner.
Validate the configuration and return a THOMSON scanner.
def get_scanner(hass, config): """Validate the configuration and return a THOMSON scanner.""" scanner = ThomsonDeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "ThomsonDeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 36, 0 ]
[ 40, 52 ]
python
en
['en', 'en', 'en']
True
ThomsonDeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] self.last_results = {} # Test the router is accessible. data = self.get_thomson_data() self...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "password", "=", "config", "[", "CONF_PASSWORD", "]", "s...
[ 46, 4 ]
[ 55, 44 ]
python
en
['en', 'en', 'en']
True
ThomsonDeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [client["mac"] for client in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "client", "[", "\"mac\"", "]", "for", "client", "in", "self", ".", "last_results", "]" ]
[ 57, 4 ]
[ 60, 62 ]
python
en
['en', 'en', 'en']
True
ThomsonDeviceScanner.get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
def get_device_name(self, device): """Return the name of the given device or None if we don't know.""" if not self.last_results: return None for client in self.last_results: if client["mac"] == device: return client["host"] return None
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "if", "not", "self", ".", "last_results", ":", "return", "None", "for", "client", "in", "self", ".", "last_results", ":", "if", "client", "[", "\"mac\"", "]", "==", "device", ":", "return", ...
[ 62, 4 ]
[ 69, 19 ]
python
en
['en', 'en', 'en']
True
ThomsonDeviceScanner._update_info
(self)
Ensure the information from the THOMSON router is up to date. Return boolean if scanning successful.
Ensure the information from the THOMSON router is up to date.
def _update_info(self): """Ensure the information from the THOMSON router is up to date. Return boolean if scanning successful. """ if not self.success_init: return False _LOGGER.info("Checking ARP") data = self.get_thomson_data() if not data: ...
[ "def", "_update_info", "(", "self", ")", ":", "if", "not", "self", ".", "success_init", ":", "return", "False", "_LOGGER", ".", "info", "(", "\"Checking ARP\"", ")", "data", "=", "self", ".", "get_thomson_data", "(", ")", "if", "not", "data", ":", "retur...
[ 71, 4 ]
[ 89, 19 ]
python
en
['en', 'en', 'en']
True
ThomsonDeviceScanner.get_thomson_data
(self)
Retrieve data from THOMSON and return parsed result.
Retrieve data from THOMSON and return parsed result.
def get_thomson_data(self): """Retrieve data from THOMSON and return parsed result.""" try: telnet = telnetlib.Telnet(self.host) telnet.read_until(b"Username : ") telnet.write((self.username + "\r\n").encode("ascii")) telnet.read_until(b"Password : ") ...
[ "def", "get_thomson_data", "(", "self", ")", ":", "try", ":", "telnet", "=", "telnetlib", ".", "Telnet", "(", "self", ".", "host", ")", "telnet", ".", "read_until", "(", "b\"Username : \"", ")", "telnet", ".", "write", "(", "(", "self", ".", "username", ...
[ 91, 4 ]
[ 120, 22 ]
python
en
['en', 'en', 'en']
True
KeyphraseExtractor.normalize
(self, sent)
Removes punctuation from a tokenized/tagged sentence and lowercases words.
Removes punctuation from a tokenized/tagged sentence and lowercases words.
def normalize(self, sent): """ Removes punctuation from a tokenized/tagged sentence and lowercases words. """ is_punct = lambda word: all(unicat(char).startswith('P') for char in word) sent = filter(lambda t: not is_punct(t[0]), sent) sent = map(lambda t: (t[0].lo...
[ "def", "normalize", "(", "self", ",", "sent", ")", ":", "is_punct", "=", "lambda", "word", ":", "all", "(", "unicat", "(", "char", ")", ".", "startswith", "(", "'P'", ")", "for", "char", "in", "word", ")", "sent", "=", "filter", "(", "lambda", "t",...
[ 24, 4 ]
[ 32, 25 ]
python
en
['en', 'error', 'th']
False
KeyphraseExtractor.extract_keyphrases
(self, document)
For a document, parse sentences using our chunker created by our grammar, converting the parse tree into a tagged sequence. Yields extracted phrases.
For a document, parse sentences using our chunker created by our grammar, converting the parse tree into a tagged sequence. Yields extracted phrases.
def extract_keyphrases(self, document): """ For a document, parse sentences using our chunker created by our grammar, converting the parse tree into a tagged sequence. Yields extracted phrases. """ for sents in document: for sent in sents: sent...
[ "def", "extract_keyphrases", "(", "self", ",", "document", ")", ":", "for", "sents", "in", "document", ":", "for", "sent", "in", "sents", ":", "sent", "=", "self", ".", "normalize", "(", "sent", ")", "if", "not", "sent", ":", "continue", "chunks", "=",...
[ 34, 4 ]
[ 52, 32 ]
python
en
['en', 'error', 'th']
False
deps_dir
()
Return path to deps directory.
Return path to deps directory.
def deps_dir(): """Return path to deps directory.""" return os.path.abspath("/deps_dir")
[ "def", "deps_dir", "(", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "\"/deps_dir\"", ")" ]
[ 34, 0 ]
[ 36, 39 ]
python
en
['en', 'en', 'en']
True
lib_dir
(deps_dir)
Return path to lib directory.
Return path to lib directory.
def lib_dir(deps_dir): """Return path to lib directory.""" return os.path.join(deps_dir, "lib_dir")
[ "def", "lib_dir", "(", "deps_dir", ")", ":", "return", "os", ".", "path", ".", "join", "(", "deps_dir", ",", "\"lib_dir\"", ")" ]
[ 40, 0 ]
[ 42, 44 ]
python
en
['en', 'cy', 'en']
True
mock_popen
(lib_dir)
Return a Popen mock.
Return a Popen mock.
def mock_popen(lib_dir): """Return a Popen mock.""" with patch("homeassistant.util.package.Popen") as popen_mock: popen_mock.return_value.communicate.return_value = ( bytes(lib_dir, "utf-8"), b"error", ) popen_mock.return_value.returncode = 0 yield popen_m...
[ "def", "mock_popen", "(", "lib_dir", ")", ":", "with", "patch", "(", "\"homeassistant.util.package.Popen\"", ")", "as", "popen_mock", ":", "popen_mock", ".", "return_value", ".", "communicate", ".", "return_value", "=", "(", "bytes", "(", "lib_dir", ",", "\"utf-...
[ 46, 0 ]
[ 54, 24 ]
python
en
['en', 'fy', 'en']
True
mock_env_copy
()
Mock os.environ.copy.
Mock os.environ.copy.
def mock_env_copy(): """Mock os.environ.copy.""" with patch("homeassistant.util.package.os.environ.copy") as env_copy: env_copy.return_value = {} yield env_copy
[ "def", "mock_env_copy", "(", ")", ":", "with", "patch", "(", "\"homeassistant.util.package.os.environ.copy\"", ")", "as", "env_copy", ":", "env_copy", ".", "return_value", "=", "{", "}", "yield", "env_copy" ]
[ 58, 0 ]
[ 62, 22 ]
python
gl
['gl', 'gl', 'pt']
False
mock_venv
()
Mock homeassistant.util.package.is_virtual_env.
Mock homeassistant.util.package.is_virtual_env.
def mock_venv(): """Mock homeassistant.util.package.is_virtual_env.""" with patch("homeassistant.util.package.is_virtual_env") as mock: mock.return_value = True yield mock
[ "def", "mock_venv", "(", ")", ":", "with", "patch", "(", "\"homeassistant.util.package.is_virtual_env\"", ")", "as", "mock", ":", "mock", ".", "return_value", "=", "True", "yield", "mock" ]
[ 66, 0 ]
[ 70, 18 ]
python
af
['en', 'af', 'it']
False
mock_async_subprocess
()
Return an async Popen mock.
Return an async Popen mock.
def mock_async_subprocess(): """Return an async Popen mock.""" async_popen = MagicMock() async def communicate(input=None): """Communicate mock.""" stdout = bytes("/deps_dir/lib_dir", "utf-8") return (stdout, None) async_popen.communicate = communicate return async_popen
[ "def", "mock_async_subprocess", "(", ")", ":", "async_popen", "=", "MagicMock", "(", ")", "async", "def", "communicate", "(", "input", "=", "None", ")", ":", "\"\"\"Communicate mock.\"\"\"", "stdout", "=", "bytes", "(", "\"/deps_dir/lib_dir\"", ",", "\"utf-8\"", ...
[ 73, 0 ]
[ 83, 22 ]
python
en
['en', 'fy', 'en']
True
test_install
(mock_sys, mock_popen, mock_env_copy, mock_venv)
Test an install attempt on a package that doesn't exist.
Test an install attempt on a package that doesn't exist.
def test_install(mock_sys, mock_popen, mock_env_copy, mock_venv): """Test an install attempt on a package that doesn't exist.""" env = mock_env_copy() assert package.install_package(TEST_NEW_REQ, False) assert mock_popen.call_count == 1 assert mock_popen.call_args == call( [mock_sys.executab...
[ "def", "test_install", "(", "mock_sys", ",", "mock_popen", ",", "mock_env_copy", ",", "mock_venv", ")", ":", "env", "=", "mock_env_copy", "(", ")", "assert", "package", ".", "install_package", "(", "TEST_NEW_REQ", ",", "False", ")", "assert", "mock_popen", "."...
[ 86, 0 ]
[ 98, 62 ]
python
en
['en', 'en', 'en']
True
test_install_upgrade
(mock_sys, mock_popen, mock_env_copy, mock_venv)
Test an upgrade attempt on a package.
Test an upgrade attempt on a package.
def test_install_upgrade(mock_sys, mock_popen, mock_env_copy, mock_venv): """Test an upgrade attempt on a package.""" env = mock_env_copy() assert package.install_package(TEST_NEW_REQ) assert mock_popen.call_count == 1 assert mock_popen.call_args == call( [ mock_sys.executable, ...
[ "def", "test_install_upgrade", "(", "mock_sys", ",", "mock_popen", ",", "mock_env_copy", ",", "mock_venv", ")", ":", "env", "=", "mock_env_copy", "(", ")", "assert", "package", ".", "install_package", "(", "TEST_NEW_REQ", ")", "assert", "mock_popen", ".", "call_...
[ 101, 0 ]
[ 121, 62 ]
python
en
['en', 'en', 'en']
True
test_install_target
(mock_sys, mock_popen, mock_env_copy, mock_venv)
Test an install with a target.
Test an install with a target.
def test_install_target(mock_sys, mock_popen, mock_env_copy, mock_venv): """Test an install with a target.""" target = "target_folder" env = mock_env_copy() env["PYTHONUSERBASE"] = os.path.abspath(target) mock_venv.return_value = False mock_sys.platform = "linux" args = [ mock_sys.ex...
[ "def", "test_install_target", "(", "mock_sys", ",", "mock_popen", ",", "mock_env_copy", ",", "mock_venv", ")", ":", "target", "=", "\"target_folder\"", "env", "=", "mock_env_copy", "(", ")", "env", "[", "\"PYTHONUSERBASE\"", "]", "=", "os", ".", "path", ".", ...
[ 124, 0 ]
[ 147, 62 ]
python
en
['en', 'en', 'en']
True
test_install_target_venv
(mock_sys, mock_popen, mock_env_copy, mock_venv)
Test an install with a target in a virtual environment.
Test an install with a target in a virtual environment.
def test_install_target_venv(mock_sys, mock_popen, mock_env_copy, mock_venv): """Test an install with a target in a virtual environment.""" target = "target_folder" with pytest.raises(AssertionError): package.install_package(TEST_NEW_REQ, False, target=target)
[ "def", "test_install_target_venv", "(", "mock_sys", ",", "mock_popen", ",", "mock_env_copy", ",", "mock_venv", ")", ":", "target", "=", "\"target_folder\"", "with", "pytest", ".", "raises", "(", "AssertionError", ")", ":", "package", ".", "install_package", "(", ...
[ 150, 0 ]
[ 154, 67 ]
python
en
['en', 'en', 'en']
True
test_install_error
(caplog, mock_sys, mock_popen, mock_venv)
Test an install with a target.
Test an install with a target.
def test_install_error(caplog, mock_sys, mock_popen, mock_venv): """Test an install with a target.""" caplog.set_level(logging.WARNING) mock_popen.return_value.returncode = 1 assert not package.install_package(TEST_NEW_REQ) assert len(caplog.records) == 1 for record in caplog.records: as...
[ "def", "test_install_error", "(", "caplog", ",", "mock_sys", ",", "mock_popen", ",", "mock_venv", ")", ":", "caplog", ".", "set_level", "(", "logging", ".", "WARNING", ")", "mock_popen", ".", "return_value", ".", "returncode", "=", "1", "assert", "not", "pac...
[ 157, 0 ]
[ 164, 42 ]
python
en
['en', 'en', 'en']
True
test_install_constraint
(mock_sys, mock_popen, mock_env_copy, mock_venv)
Test install with constraint file on not installed package.
Test install with constraint file on not installed package.
def test_install_constraint(mock_sys, mock_popen, mock_env_copy, mock_venv): """Test install with constraint file on not installed package.""" env = mock_env_copy() constraints = "constraints_file.txt" assert package.install_package(TEST_NEW_REQ, False, constraints=constraints) assert mock_popen.cal...
[ "def", "test_install_constraint", "(", "mock_sys", ",", "mock_popen", ",", "mock_env_copy", ",", "mock_venv", ")", ":", "env", "=", "mock_env_copy", "(", ")", "constraints", "=", "\"constraints_file.txt\"", "assert", "package", ".", "install_package", "(", "TEST_NEW...
[ 167, 0 ]
[ 189, 62 ]
python
en
['en', 'en', 'en']
True
test_install_find_links
(mock_sys, mock_popen, mock_env_copy, mock_venv)
Test install with find-links on not installed package.
Test install with find-links on not installed package.
def test_install_find_links(mock_sys, mock_popen, mock_env_copy, mock_venv): """Test install with find-links on not installed package.""" env = mock_env_copy() link = "https://wheels-repository" assert package.install_package(TEST_NEW_REQ, False, find_links=link) assert mock_popen.call_count == 1 ...
[ "def", "test_install_find_links", "(", "mock_sys", ",", "mock_popen", ",", "mock_env_copy", ",", "mock_venv", ")", ":", "env", "=", "mock_env_copy", "(", ")", "link", "=", "\"https://wheels-repository\"", "assert", "package", ".", "install_package", "(", "TEST_NEW_R...
[ 192, 0 ]
[ 215, 62 ]
python
en
['en', 'en', 'en']
True
test_async_get_user_site
(mock_env_copy)
Test async get user site directory.
Test async get user site directory.
async def test_async_get_user_site(mock_env_copy): """Test async get user site directory.""" deps_dir = "/deps_dir" env = mock_env_copy() env["PYTHONUSERBASE"] = os.path.abspath(deps_dir) args = [sys.executable, "-m", "site", "--user-site"] with patch( "homeassistant.util.package.asyncio...
[ "async", "def", "test_async_get_user_site", "(", "mock_env_copy", ")", ":", "deps_dir", "=", "\"/deps_dir\"", "env", "=", "mock_env_copy", "(", ")", "env", "[", "\"PYTHONUSERBASE\"", "]", "=", "os", ".", "path", ".", "abspath", "(", "deps_dir", ")", "args", ...
[ 218, 0 ]
[ 237, 51 ]
python
en
['fr', 'en', 'en']
True
test_check_package_global
()
Test for an installed package.
Test for an installed package.
def test_check_package_global(): """Test for an installed package.""" installed_package = list(pkg_resources.working_set)[0].project_name assert package.is_installed(installed_package)
[ "def", "test_check_package_global", "(", ")", ":", "installed_package", "=", "list", "(", "pkg_resources", ".", "working_set", ")", "[", "0", "]", ".", "project_name", "assert", "package", ".", "is_installed", "(", "installed_package", ")" ]
[ 240, 0 ]
[ 243, 50 ]
python
en
['en', 'en', 'en']
True
test_check_package_zip
()
Test for an installed zip package.
Test for an installed zip package.
def test_check_package_zip(): """Test for an installed zip package.""" assert not package.is_installed(TEST_ZIP_REQ)
[ "def", "test_check_package_zip", "(", ")", ":", "assert", "not", "package", ".", "is_installed", "(", "TEST_ZIP_REQ", ")" ]
[ 246, 0 ]
[ 248, 49 ]
python
en
['en', 'en', 'en']
True
ZWaveBaseEntity.__init__
(self)
Initialize the base Z-Wave class.
Initialize the base Z-Wave class.
def __init__(self): """Initialize the base Z-Wave class.""" self._update_scheduled = False
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_update_scheduled", "=", "False" ]
[ 65, 4 ]
[ 67, 38 ]
python
en
['en', 'en', 'en']
True
ZWaveBaseEntity.maybe_schedule_update
(self)
Maybe schedule state update. If value changed after device was created but before setup_platform was called - skip updating state.
Maybe schedule state update.
def maybe_schedule_update(self): """Maybe schedule state update. If value changed after device was created but before setup_platform was called - skip updating state. """ if self.hass and not self._update_scheduled: self.hass.add_job(self._schedule_update)
[ "def", "maybe_schedule_update", "(", "self", ")", ":", "if", "self", ".", "hass", "and", "not", "self", ".", "_update_scheduled", ":", "self", ".", "hass", ".", "add_job", "(", "self", ".", "_schedule_update", ")" ]
[ 69, 4 ]
[ 76, 52 ]
python
en
['de', 'en', 'en']
True
ZWaveBaseEntity._schedule_update
(self)
Schedule delayed update.
Schedule delayed update.
def _schedule_update(self): """Schedule delayed update.""" if self._update_scheduled: return @callback def do_update(): """Really update.""" self.async_write_ha_state() self._update_scheduled = False self._update_scheduled = True ...
[ "def", "_schedule_update", "(", "self", ")", ":", "if", "self", ".", "_update_scheduled", ":", "return", "@", "callback", "def", "do_update", "(", ")", ":", "\"\"\"Really update.\"\"\"", "self", ".", "async_write_ha_state", "(", ")", "self", ".", "_update_schedu...
[ 79, 4 ]
[ 91, 49 ]
python
de
['it', 'de', 'en']
False
ZWaveBaseEntity.try_remove_and_add
(self)
Remove this entity and add it back.
Remove this entity and add it back.
def try_remove_and_add(self): """Remove this entity and add it back.""" async def _async_remove_and_add(): await self.async_remove() self.entity_id = None await self.platform.async_add_entities([self]) if self.hass and self.platform: self.hass.ad...
[ "def", "try_remove_and_add", "(", "self", ")", ":", "async", "def", "_async_remove_and_add", "(", ")", ":", "await", "self", ".", "async_remove", "(", ")", "self", ".", "entity_id", "=", "None", "await", "self", ".", "platform", ".", "async_add_entities", "(...
[ 93, 4 ]
[ 102, 52 ]
python
en
['en', 'en', 'en']
True
ZWaveBaseEntity.node_removed
(self)
Call when a node is removed from the Z-Wave network.
Call when a node is removed from the Z-Wave network.
async def node_removed(self): """Call when a node is removed from the Z-Wave network.""" await self.async_remove() registry = await async_get_registry(self.hass) if self.entity_id not in registry.entities: return registry.async_remove(self.entity_id)
[ "async", "def", "node_removed", "(", "self", ")", ":", "await", "self", ".", "async_remove", "(", ")", "registry", "=", "await", "async_get_registry", "(", "self", ".", "hass", ")", "if", "self", ".", "entity_id", "not", "in", "registry", ".", "entities", ...
[ 104, 4 ]
[ 112, 45 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.__init__
(self, node, network)
Initialize node.
Initialize node.
def __init__(self, node, network): """Initialize node.""" # pylint: disable=import-error super().__init__() from openzwave.network import ZWaveNetwork from pydispatch import dispatcher self._network = network self.node = node self.node_id = self.node.node...
[ "def", "__init__", "(", "self", ",", "node", ",", "network", ")", ":", "# pylint: disable=import-error", "super", "(", ")", ".", "__init__", "(", ")", "from", "openzwave", ".", "network", "import", "ZWaveNetwork", "from", "pydispatch", "import", "dispatcher", ...
[ 118, 4 ]
[ 146, 9 ]
python
en
['en', 'en', 'it']
False
ZWaveNodeEntity.unique_id
(self)
Return unique ID of Z-wave node.
Return unique ID of Z-wave node.
def unique_id(self): """Return unique ID of Z-wave node.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 149, 4 ]
[ 151, 30 ]
python
en
['en', 'fr', 'en']
True
ZWaveNodeEntity.device_info
(self)
Return device information.
Return device information.
def device_info(self): """Return device information.""" identifier, name = node_device_id_and_name(self.node) info = { "identifiers": {identifier}, "manufacturer": self.node.manufacturer_name, "model": self.node.product_name, "name": name, ...
[ "def", "device_info", "(", "self", ")", ":", "identifier", ",", "name", "=", "node_device_id_and_name", "(", "self", ".", "node", ")", "info", "=", "{", "\"identifiers\"", ":", "{", "identifier", "}", ",", "\"manufacturer\"", ":", "self", ".", "node", ".",...
[ 154, 4 ]
[ 165, 19 ]
python
da
['es', 'da', 'en']
False
ZWaveNodeEntity.maybe_update_application_version
(self, value)
Update application version if value is a Command Class Version, Application Value.
Update application version if value is a Command Class Version, Application Value.
def maybe_update_application_version(self, value): """Update application version if value is a Command Class Version, Application Value.""" if ( value and value.command_class == COMMAND_CLASS_VERSION and value.label == "Application Version" ): self...
[ "def", "maybe_update_application_version", "(", "self", ",", "value", ")", ":", "if", "(", "value", "and", "value", ".", "command_class", "==", "COMMAND_CLASS_VERSION", "and", "value", ".", "label", "==", "\"Application Version\"", ")", ":", "self", ".", "_appli...
[ 167, 4 ]
[ 174, 50 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.network_node_value_added
(self, node=None, value=None, args=None)
Handle a added value to a none on the network.
Handle a added value to a none on the network.
def network_node_value_added(self, node=None, value=None, args=None): """Handle a added value to a none on the network.""" if node and node.node_id != self.node_id: return if args is not None and "nodeId" in args and args["nodeId"] != self.node_id: return self.ma...
[ "def", "network_node_value_added", "(", "self", ",", "node", "=", "None", ",", "value", "=", "None", ",", "args", "=", "None", ")", ":", "if", "node", "and", "node", ".", "node_id", "!=", "self", ".", "node_id", ":", "return", "if", "args", "is", "no...
[ 176, 4 ]
[ 183, 52 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.network_node_changed
(self, node=None, value=None, args=None)
Handle a changed node on the network.
Handle a changed node on the network.
def network_node_changed(self, node=None, value=None, args=None): """Handle a changed node on the network.""" if node and node.node_id != self.node_id: return if args is not None and "nodeId" in args and args["nodeId"] != self.node_id: return # Process central sc...
[ "def", "network_node_changed", "(", "self", ",", "node", "=", "None", ",", "value", "=", "None", ",", "args", "=", "None", ")", ":", "if", "node", "and", "node", ".", "node_id", "!=", "self", ".", "node_id", ":", "return", "if", "args", "is", "not", ...
[ 185, 4 ]
[ 198, 27 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.get_node_statistics
(self)
Retrieve statistics from the node.
Retrieve statistics from the node.
def get_node_statistics(self): """Retrieve statistics from the node.""" return self._network.manager.getNodeStatistics( self._network.home_id, self.node_id )
[ "def", "get_node_statistics", "(", "self", ")", ":", "return", "self", ".", "_network", ".", "manager", ".", "getNodeStatistics", "(", "self", ".", "_network", ".", "home_id", ",", "self", ".", "node_id", ")" ]
[ 200, 4 ]
[ 204, 9 ]
python
en
['en', 'pt', 'en']
True
ZWaveNodeEntity.node_changed
(self)
Update node properties.
Update node properties.
def node_changed(self): """Update node properties.""" attributes = {} stats = self.get_node_statistics() for attr in ATTRIBUTES: value = getattr(self.node, attr) if attr in _REQUIRED_ATTRIBUTES or value: attributes[attr] = value for attr i...
[ "def", "node_changed", "(", "self", ")", ":", "attributes", "=", "{", "}", "stats", "=", "self", ".", "get_node_statistics", "(", ")", "for", "attr", "in", "ATTRIBUTES", ":", "value", "=", "getattr", "(", "self", ".", "node", ",", "attr", ")", "if", ...
[ 206, 4 ]
[ 240, 36 ]
python
en
['en', 'nl', 'en']
True
ZWaveNodeEntity.node_renamed
(self, update_ids=False)
Rename the node and update any IDs.
Rename the node and update any IDs.
async def node_renamed(self, update_ids=False): """Rename the node and update any IDs.""" identifier, self._name = node_device_id_and_name(self.node) # Set the name in the devices. If they're customised # the customisation will not be stored as name and will stick. dev_reg = awai...
[ "async", "def", "node_renamed", "(", "self", ",", "update_ids", "=", "False", ")", ":", "identifier", ",", "self", ".", "_name", "=", "node_device_id_and_name", "(", "self", ".", "node", ")", "# Set the name in the devices. If they're customised", "# the customisation...
[ 242, 4 ]
[ 273, 35 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.network_node_event
(self, node, value)
Handle a node activated event on the network.
Handle a node activated event on the network.
def network_node_event(self, node, value): """Handle a node activated event on the network.""" if node.node_id == self.node.node_id: self.node_event(value)
[ "def", "network_node_event", "(", "self", ",", "node", ",", "value", ")", ":", "if", "node", ".", "node_id", "==", "self", ".", "node", ".", "node_id", ":", "self", ".", "node_event", "(", "value", ")" ]
[ 275, 4 ]
[ 278, 34 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.node_event
(self, value)
Handle a node activated event for this node.
Handle a node activated event for this node.
def node_event(self, value): """Handle a node activated event for this node.""" if self.hass is None: return self.hass.bus.fire( EVENT_NODE_EVENT, { ATTR_ENTITY_ID: self.entity_id, ATTR_NODE_ID: self.node.node_id, ...
[ "def", "node_event", "(", "self", ",", "value", ")", ":", "if", "self", ".", "hass", "is", "None", ":", "return", "self", ".", "hass", ".", "bus", ".", "fire", "(", "EVENT_NODE_EVENT", ",", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_id", ",", "...
[ 280, 4 ]
[ 292, 9 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.network_scene_activated
(self, node, scene_id)
Handle a scene activated event on the network.
Handle a scene activated event on the network.
def network_scene_activated(self, node, scene_id): """Handle a scene activated event on the network.""" if node.node_id == self.node.node_id: self.scene_activated(scene_id)
[ "def", "network_scene_activated", "(", "self", ",", "node", ",", "scene_id", ")", ":", "if", "node", ".", "node_id", "==", "self", ".", "node", ".", "node_id", ":", "self", ".", "scene_activated", "(", "scene_id", ")" ]
[ 294, 4 ]
[ 297, 42 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.scene_activated
(self, scene_id)
Handle an activated scene for this node.
Handle an activated scene for this node.
def scene_activated(self, scene_id): """Handle an activated scene for this node.""" if self.hass is None: return self.hass.bus.fire( EVENT_SCENE_ACTIVATED, { ATTR_ENTITY_ID: self.entity_id, ATTR_NODE_ID: self.node.node_id, ...
[ "def", "scene_activated", "(", "self", ",", "scene_id", ")", ":", "if", "self", ".", "hass", "is", "None", ":", "return", "self", ".", "hass", ".", "bus", ".", "fire", "(", "EVENT_SCENE_ACTIVATED", ",", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_id...
[ 299, 4 ]
[ 311, 9 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.central_scene_activated
(self, scene_id, scene_data)
Handle an activated central scene for this node.
Handle an activated central scene for this node.
def central_scene_activated(self, scene_id, scene_data): """Handle an activated central scene for this node.""" if self.hass is None: return self.hass.bus.fire( EVENT_SCENE_ACTIVATED, { ATTR_ENTITY_ID: self.entity_id, ATTR_NODE...
[ "def", "central_scene_activated", "(", "self", ",", "scene_id", ",", "scene_data", ")", ":", "if", "self", ".", "hass", "is", "None", ":", "return", "self", ".", "hass", ".", "bus", ".", "fire", "(", "EVENT_SCENE_ACTIVATED", ",", "{", "ATTR_ENTITY_ID", ":"...
[ 313, 4 ]
[ 326, 9 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.state
(self)
Return the state.
Return the state.
def state(self): """Return the state.""" if ATTR_READY not in self._attributes: return None if self._attributes[ATTR_FAILED]: return "dead" if self._attributes[ATTR_QUERY_STAGE] != "Complete": return "initializing" if not self._attributes[ATTR...
[ "def", "state", "(", "self", ")", ":", "if", "ATTR_READY", "not", "in", "self", ".", "_attributes", ":", "return", "None", "if", "self", ".", "_attributes", "[", "ATTR_FAILED", "]", ":", "return", "\"dead\"", "if", "self", ".", "_attributes", "[", "ATTR_...
[ 329, 4 ]
[ 343, 19 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 346, 4 ]
[ 348, 20 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.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" ]
[ 351, 4 ]
[ 353, 25 ]
python
en
['en', 'en', 'en']
True
ZWaveNodeEntity.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.""" attrs = { ATTR_NODE_ID: self.node_id, ATTR_NODE_NAME: self._name, ATTR_MANUFACTURER_NAME: self._manufacturer_name, ATTR_PRODUCT_NAME: self._product_name, } ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attrs", "=", "{", "ATTR_NODE_ID", ":", "self", ".", "node_id", ",", "ATTR_NODE_NAME", ":", "self", ".", "_name", ",", "ATTR_MANUFACTURER_NAME", ":", "self", ".", "_manufacturer_name", ",", "ATTR_PRODUCT_N...
[ 356, 4 ]
[ 372, 20 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up the Avri Waste platform.
Set up the Avri Waste platform.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up the Avri Waste platform.""" client = hass.data[DOMAIN][entry.entry_id] integration_id = entry.data[CONF_ID] try: each_upcoming = await hass.async_add_executor_job(client.upcomin...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "client", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "in...
[ 16, 0 ]
[ 32, 42 ]
python
en
['en', 'hr', 'en']
True
AvriWasteUpcoming.__init__
(self, client: Avri, waste_type: str, integration_id: str)
Initialize the sensor.
Initialize the sensor.
def __init__(self, client: Avri, waste_type: str, integration_id: str): """Initialize the sensor.""" self._waste_type = waste_type self._name = f"{self._waste_type}".title() self._state = None self._client = client self._state_available = False self._integration_i...
[ "def", "__init__", "(", "self", ",", "client", ":", "Avri", ",", "waste_type", ":", "str", ",", "integration_id", ":", "str", ")", ":", "self", ".", "_waste_type", "=", "waste_type", "self", ".", "_name", "=", "f\"{self._waste_type}\"", ".", "title", "(", ...
[ 38, 4 ]
[ 45, 45 ]
python
en
['en', 'en', 'en']
True
AvriWasteUpcoming.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" ]
[ 48, 4 ]
[ 50, 25 ]
python
en
['en', 'mi', 'en']
True
AvriWasteUpcoming.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self) -> str: """Return a unique ID.""" return (f"{self._integration_id}" f"-{self._waste_type}").replace(" ", "")
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "(", "f\"{self._integration_id}\"", "f\"-{self._waste_type}\"", ")", ".", "replace", "(", "\" \"", ",", "\"\"", ")" ]
[ 53, 4 ]
[ 55, 82 ]
python
ca
['fr', 'ca', 'en']
False
AvriWasteUpcoming.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" ]
[ 58, 4 ]
[ 60, 26 ]
python
en
['en', 'en', 'en']
True
AvriWasteUpcoming.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._state_available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_state_available" ]
[ 63, 4 ]
[ 65, 36 ]
python
en
['en', 'en', 'en']
True
AvriWasteUpcoming.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self): """Return the device class of the sensor.""" return DEVICE_CLASS_TIMESTAMP
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_TIMESTAMP" ]
[ 68, 4 ]
[ 70, 37 ]
python
en
['en', 'en', 'en']
True
AvriWasteUpcoming.icon
(self)
Icon to use in the frontend.
Icon to use in the frontend.
def icon(self): """Icon to use in the frontend.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 73, 4 ]
[ 75, 19 ]
python
en
['en', 'en', 'en']
True
AvriWasteUpcoming.async_update
(self)
Update the data.
Update the data.
async def async_update(self): """Update the data.""" if not self.enabled: return try: pickup_events = self._client.upcoming_of_each() except AvriException as ex: _LOGGER.error( "There was an error retrieving upcoming garbage pickups: %...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "try", ":", "pickup_events", "=", "self", ".", "_client", ".", "upcoming_of_each", "(", ")", "except", "AvriException", "as", "ex", ":", "_LOGGER", ...
[ 77, 4 ]
[ 98, 58 ]
python
en
['en', 'sn', 'en']
True
train
(args, train_dataset, model, tokenizer, teacher=None)
Train the model
Train the model
def train(args, train_dataset, model, tokenizer, teacher=None): """ Train the model """ if args.local_rank in [-1, 0]: tb_writer = SummaryWriter(log_dir=args.output_dir) args.train_batch_size = args.per_gpu_train_batch_size * max(1, args.n_gpu) train_sampler = RandomSampler(train_dataset) if ar...
[ "def", "train", "(", "args", ",", "train_dataset", ",", "model", ",", "tokenizer", ",", "teacher", "=", "None", ")", ":", "if", "args", ".", "local_rank", "in", "[", "-", "1", ",", "0", "]", ":", "tb_writer", "=", "SummaryWriter", "(", "log_dir", "="...
[ 106, 0 ]
[ 417, 45 ]
python
en
['en', 'it', 'en']
True