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
UpbLight.__init__
(self, element, unique_id, upb)
Initialize an UpbLight.
Initialize an UpbLight.
def __init__(self, element, unique_id, upb): """Initialize an UpbLight.""" super().__init__(element, unique_id, upb) self._brightness = self._element.status
[ "def", "__init__", "(", "self", ",", "element", ",", "unique_id", ",", "upb", ")", ":", "super", "(", ")", ".", "__init__", "(", "element", ",", "unique_id", ",", "upb", ")", "self", ".", "_brightness", "=", "self", ".", "_element", ".", "status" ]
[ 45, 4 ]
[ 48, 47 ]
python
en
['en', 'en', 'nl']
True
UpbLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" if self._element.dimmable: return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_FLASH return SUPPORT_FLASH
[ "def", "supported_features", "(", "self", ")", ":", "if", "self", ".", "_element", ".", "dimmable", ":", "return", "SUPPORT_BRIGHTNESS", "|", "SUPPORT_TRANSITION", "|", "SUPPORT_FLASH", "return", "SUPPORT_FLASH" ]
[ 51, 4 ]
[ 55, 28 ]
python
en
['da', 'en', 'en']
True
UpbLight.brightness
(self)
Get the brightness.
Get the brightness.
def brightness(self): """Get the brightness.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 58, 4 ]
[ 60, 31 ]
python
en
['en', 'ko', 'en']
True
UpbLight.is_on
(self)
Get the current brightness.
Get the current brightness.
def is_on(self) -> bool: """Get the current brightness.""" return self._brightness != 0
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_brightness", "!=", "0" ]
[ 63, 4 ]
[ 65, 36 ]
python
en
['en', 'en', 'en']
True
UpbLight.async_turn_on
(self, **kwargs)
Turn on the light.
Turn on the light.
async def async_turn_on(self, **kwargs): """Turn on the light.""" flash = kwargs.get(ATTR_FLASH) if flash: await self.async_light_blink(0.5 if flash == "short" else 1.5) else: rate = kwargs.get(ATTR_TRANSITION, -1) brightness = round(kwargs.get(ATTR_BR...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "flash", "=", "kwargs", ".", "get", "(", "ATTR_FLASH", ")", "if", "flash", ":", "await", "self", ".", "async_light_blink", "(", "0.5", "if", "flash", "==", "\"short\"", "e...
[ 67, 4 ]
[ 75, 51 ]
python
en
['en', 'et', 'en']
True
UpbLight.async_turn_off
(self, **kwargs)
Turn off the device.
Turn off the device.
async def async_turn_off(self, **kwargs): """Turn off the device.""" rate = kwargs.get(ATTR_TRANSITION, -1) self._element.turn_off(rate)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rate", "=", "kwargs", ".", "get", "(", "ATTR_TRANSITION", ",", "-", "1", ")", "self", ".", "_element", ".", "turn_off", "(", "rate", ")" ]
[ 77, 4 ]
[ 80, 36 ]
python
en
['en', 'en', 'en']
True
UpbLight.async_light_fade_start
(self, rate, brightness=None, brightness_pct=None)
Start dimming of device.
Start dimming of device.
async def async_light_fade_start(self, rate, brightness=None, brightness_pct=None): """Start dimming of device.""" if brightness is not None: brightness_pct = round(brightness / 2.55) self._element.fade_start(brightness_pct, rate)
[ "async", "def", "async_light_fade_start", "(", "self", ",", "rate", ",", "brightness", "=", "None", ",", "brightness_pct", "=", "None", ")", ":", "if", "brightness", "is", "not", "None", ":", "brightness_pct", "=", "round", "(", "brightness", "/", "2.55", ...
[ 82, 4 ]
[ 86, 54 ]
python
en
['en', 'en', 'en']
True
UpbLight.async_light_fade_stop
(self)
Stop dimming of device.
Stop dimming of device.
async def async_light_fade_stop(self): """Stop dimming of device.""" self._element.fade_stop()
[ "async", "def", "async_light_fade_stop", "(", "self", ")", ":", "self", ".", "_element", ".", "fade_stop", "(", ")" ]
[ 88, 4 ]
[ 90, 33 ]
python
en
['en', 'en', 'en']
True
UpbLight.async_light_blink
(self, blink_rate)
Request device to blink.
Request device to blink.
async def async_light_blink(self, blink_rate): """Request device to blink.""" blink_rate = int(blink_rate * 60) # Convert seconds to 60 hz pulses self._element.blink(blink_rate)
[ "async", "def", "async_light_blink", "(", "self", ",", "blink_rate", ")", ":", "blink_rate", "=", "int", "(", "blink_rate", "*", "60", ")", "# Convert seconds to 60 hz pulses", "self", ".", "_element", ".", "blink", "(", "blink_rate", ")" ]
[ 92, 4 ]
[ 95, 39 ]
python
en
['en', 'en', 'en']
True
UpbLight.async_update
(self)
Request the device to update its status.
Request the device to update its status.
async def async_update(self): """Request the device to update its status.""" self._element.update_status()
[ "async", "def", "async_update", "(", "self", ")", ":", "self", ".", "_element", ".", "update_status", "(", ")" ]
[ 97, 4 ]
[ 99, 37 ]
python
en
['en', 'en', 'en']
True
test_loading_no_group_data_format
(hass, hass_storage)
Test we correctly load old data without any groups.
Test we correctly load old data without any groups.
async def test_loading_no_group_data_format(hass, hass_storage): """Test we correctly load old data without any groups.""" hass_storage[auth_store.STORAGE_KEY] = { "version": 1, "data": { "credentials": [], "users": [ { "id": "user-id",...
[ "async", "def", "test_loading_no_group_data_format", "(", "hass", ",", "hass_storage", ")", ":", "hass_storage", "[", "auth_store", ".", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"credentials\"", ":", "[", "]", ",", ...
[ 8, 0 ]
[ 95, 47 ]
python
en
['en', 'en', 'en']
True
test_loading_all_access_group_data_format
(hass, hass_storage)
Test we correctly load old data with single group.
Test we correctly load old data with single group.
async def test_loading_all_access_group_data_format(hass, hass_storage): """Test we correctly load old data with single group.""" hass_storage[auth_store.STORAGE_KEY] = { "version": 1, "data": { "credentials": [], "users": [ { "id": "us...
[ "async", "def", "test_loading_all_access_group_data_format", "(", "hass", ",", "hass_storage", ")", ":", "hass_storage", "[", "auth_store", ".", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":", "1", ",", "\"data\"", ":", "{", "\"credentials\"", ":", "[", "]", ...
[ 98, 0 ]
[ 187, 47 ]
python
en
['en', 'en', 'en']
True
test_loading_empty_data
(hass, hass_storage)
Test we correctly load with no existing data.
Test we correctly load with no existing data.
async def test_loading_empty_data(hass, hass_storage): """Test we correctly load with no existing data.""" store = auth_store.AuthStore(hass) groups = await store.async_get_groups() assert len(groups) == 3 admin_group = groups[0] assert admin_group.name == auth_store.GROUP_NAME_ADMIN assert ...
[ "async", "def", "test_loading_empty_data", "(", "hass", ",", "hass_storage", ")", ":", "store", "=", "auth_store", ".", "AuthStore", "(", "hass", ")", "groups", "=", "await", "store", ".", "async_get_groups", "(", ")", "assert", "len", "(", "groups", ")", ...
[ 190, 0 ]
[ 209, 26 ]
python
en
['en', 'en', 'en']
True
test_system_groups_store_id_and_name
(hass, hass_storage)
Test that for system groups we store the ID and name. Name is stored so that we remain backwards compat with < 0.82.
Test that for system groups we store the ID and name.
async def test_system_groups_store_id_and_name(hass, hass_storage): """Test that for system groups we store the ID and name. Name is stored so that we remain backwards compat with < 0.82. """ store = auth_store.AuthStore(hass) await store._async_load() data = store._data_to_save() assert le...
[ "async", "def", "test_system_groups_store_id_and_name", "(", "hass", ",", "hass_storage", ")", ":", "store", "=", "auth_store", ".", "AuthStore", "(", "hass", ")", "await", "store", ".", "_async_load", "(", ")", "data", "=", "store", ".", "_data_to_save", "(",...
[ 212, 0 ]
[ 225, 5 ]
python
en
['en', 'en', 'en']
True
test_loading_race_condition
(hass)
Test only one storage load called when concurrent loading occurred .
Test only one storage load called when concurrent loading occurred .
async def test_loading_race_condition(hass): """Test only one storage load called when concurrent loading occurred .""" store = auth_store.AuthStore(hass) with patch( "homeassistant.helpers.entity_registry.async_get_registry" ) as mock_ent_registry, patch( "homeassistant.helpers.device_r...
[ "async", "def", "test_loading_race_condition", "(", "hass", ")", ":", "store", "=", "auth_store", ".", "AuthStore", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.helpers.entity_registry.async_get_registry\"", ")", "as", "mock_ent_registry", ",", "patch", "(...
[ 228, 0 ]
[ 243, 39 ]
python
en
['en', 'en', 'en']
True
get_config
()
Get config from arument parser.
Get config from arument parser.
def get_config(): ''' Get config from arument parser. ''' parser = argparse.ArgumentParser( description='This program is using genetic algorithm to search architecture for SQuAD.') parser.add_argument('--input_file', type=str, default='./train-v1.1.json', help='input ...
[ "def", "get_config", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'This program is using genetic algorithm to search architecture for SQuAD.'", ")", "parser", ".", "add_argument", "(", "'--input_file'", ",", "type", "=", "st...
[ 45, 0 ]
[ 73, 15 ]
python
en
['en', 'error', 'th']
False
get_id
(word_dict, word)
Return word id.
Return word id.
def get_id(word_dict, word): ''' Return word id. ''' if word in word_dict.keys(): return word_dict[word] return word_dict['<unk>']
[ "def", "get_id", "(", "word_dict", ",", "word", ")", ":", "if", "word", "in", "word_dict", ".", "keys", "(", ")", ":", "return", "word_dict", "[", "word", "]", "return", "word_dict", "[", "'<unk>'", "]" ]
[ 76, 0 ]
[ 82, 29 ]
python
en
['en', 'error', 'th']
False
load_embedding
(path)
return embedding for a specif file by given file path.
return embedding for a specif file by given file path.
def load_embedding(path): ''' return embedding for a specif file by given file path. ''' EMBEDDING_DIM = 300 embedding_dict = {} with open(path, 'r', encoding='utf-8') as file: pairs = [line.strip('\r\n').split() for line in file.readlines()] for pair in pairs: if len...
[ "def", "load_embedding", "(", "path", ")", ":", "EMBEDDING_DIM", "=", "300", "embedding_dict", "=", "{", "}", "with", "open", "(", "path", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "pairs", "=", "[", "line", ".", "strip", "...
[ 85, 0 ]
[ 97, 25 ]
python
en
['en', 'error', 'th']
False
generate_predict_json
(position1_result, position2_result, ids, passage_tokens)
Generate json by prediction.
Generate json by prediction.
def generate_predict_json(position1_result, position2_result, ids, passage_tokens): ''' Generate json by prediction. ''' predict_len = len(position1_result) logger.debug('total prediction num is %s', str(predict_len)) answers = {} for i in range(predict_len): sample_id = ids[i] ...
[ "def", "generate_predict_json", "(", "position1_result", ",", "position2_result", ",", "ids", ",", "passage_tokens", ")", ":", "predict_len", "=", "len", "(", "position1_result", ")", "logger", ".", "debug", "(", "'total prediction num is %s'", ",", "str", "(", "p...
[ 248, 0 ]
[ 265, 18 ]
python
en
['en', 'error', 'th']
False
generate_data
(path, tokenizer, char_vcb, word_vcb, is_training=False)
Generate data
Generate data
def generate_data(path, tokenizer, char_vcb, word_vcb, is_training=False): ''' Generate data ''' global root_path qp_pairs = data.load_from_file(path=path, is_training=is_training) tokenized_sent = 0 # qp_pairs = qp_pairs[:1000]1 for qp_pair in qp_pairs: tokenized_sent += 1 ...
[ "def", "generate_data", "(", "path", ",", "tokenizer", ",", "char_vcb", ",", "word_vcb", ",", "is_training", "=", "False", ")", ":", "global", "root_path", "qp_pairs", "=", "data", ".", "load_from_file", "(", "path", "=", "path", ",", "is_training", "=", "...
[ 268, 0 ]
[ 295, 19 ]
python
en
['en', 'error', 'th']
False
train_with_graph
(p_graph, qp_pairs, dev_qp_pairs)
Train a network from a specific graph.
Train a network from a specific graph.
def train_with_graph(p_graph, qp_pairs, dev_qp_pairs): ''' Train a network from a specific graph. ''' global sess with tf.Graph().as_default(): train_model = GAG(cfg, embed, p_graph) train_model.build_net(is_training=True) tf.get_variable_scope().reuse_variables() dev...
[ "def", "train_with_graph", "(", "p_graph", ",", "qp_pairs", ",", "dev_qp_pairs", ")", ":", "global", "sess", "with", "tf", ".", "Graph", "(", ")", ".", "as_default", "(", ")", ":", "train_model", "=", "GAG", "(", "cfg", ",", "embed", ",", "p_graph", ")...
[ 298, 0 ]
[ 373, 30 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Find and return switches controlled by a generic RF device via GPIO.
Find and return switches controlled by a generic RF device via GPIO.
def setup_platform(hass, config, add_entities, discovery_info=None): """Find and return switches controlled by a generic RF device via GPIO.""" rpi_rf = importlib.import_module("rpi_rf") gpio = config.get(CONF_GPIO) rfdevice = rpi_rf.RFDevice(gpio) rfdevice_lock = RLock() switches = config.get(...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "rpi_rf", "=", "importlib", ".", "import_module", "(", "\"rpi_rf\"", ")", "gpio", "=", "config", ".", "get", "(", "CONF_GPIO", ")", "rfd...
[ 44, 0 ]
[ 72, 84 ]
python
en
['en', 'en', 'en']
True
RPiRFSwitch.__init__
( self, name, rfdevice, lock, protocol, pulselength, signal_repetitions, code_on, code_off, )
Initialize the switch.
Initialize the switch.
def __init__( self, name, rfdevice, lock, protocol, pulselength, signal_repetitions, code_on, code_off, ): """Initialize the switch.""" self._name = name self._state = False self._rfdevice = rfdevice self...
[ "def", "__init__", "(", "self", ",", "name", ",", "rfdevice", ",", "lock", ",", "protocol", ",", "pulselength", ",", "signal_repetitions", ",", "code_on", ",", "code_off", ",", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "F...
[ 78, 4 ]
[ 98, 53 ]
python
en
['en', 'en', 'en']
True
RPiRFSwitch.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 101, 4 ]
[ 103, 20 ]
python
en
['en', 'en', 'en']
True
RPiRFSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 106, 4 ]
[ 108, 25 ]
python
en
['en', 'en', 'en']
True
RPiRFSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 111, 4 ]
[ 113, 26 ]
python
en
['en', 'fy', 'en']
True
RPiRFSwitch._send_code
(self, code_list, protocol, pulselength)
Send the code(s) with a specified pulselength.
Send the code(s) with a specified pulselength.
def _send_code(self, code_list, protocol, pulselength): """Send the code(s) with a specified pulselength.""" with self._lock: _LOGGER.info("Sending code(s): %s", code_list) for code in code_list: self._rfdevice.tx_code(code, protocol, pulselength) return T...
[ "def", "_send_code", "(", "self", ",", "code_list", ",", "protocol", ",", "pulselength", ")", ":", "with", "self", ".", "_lock", ":", "_LOGGER", ".", "info", "(", "\"Sending code(s): %s\"", ",", "code_list", ")", "for", "code", "in", "code_list", ":", "sel...
[ 115, 4 ]
[ 121, 19 ]
python
en
['en', 'en', 'en']
True
RPiRFSwitch.turn_on
(self, **kwargs)
Turn the switch on.
Turn the switch on.
def turn_on(self, **kwargs): """Turn the switch on.""" if self._send_code(self._code_on, self._protocol, self._pulselength): self._state = True self.schedule_update_ha_state()
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_send_code", "(", "self", ".", "_code_on", ",", "self", ".", "_protocol", ",", "self", ".", "_pulselength", ")", ":", "self", ".", "_state", "=", "True", "self", ...
[ 123, 4 ]
[ 127, 43 ]
python
en
['en', 'en', 'en']
True
RPiRFSwitch.turn_off
(self, **kwargs)
Turn the switch off.
Turn the switch off.
def turn_off(self, **kwargs): """Turn the switch off.""" if self._send_code(self._code_off, self._protocol, self._pulselength): self._state = False self.schedule_update_ha_state()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_send_code", "(", "self", ".", "_code_off", ",", "self", ".", "_protocol", ",", "self", ".", "_pulselength", ")", ":", "self", ".", "_state", "=", "False", "self",...
[ 129, 4 ]
[ 133, 43 ]
python
en
['en', 'en', 'en']
True
ResNetVLBERTForPretraining._collect_obj_reps
(self, span_tags, object_reps)
Collect span-level object representations :param span_tags: [batch_size, ..leading_dims.., L] :param object_reps: [batch_size, max_num_objs_per_batch, obj_dim] :return:
Collect span-level object representations :param span_tags: [batch_size, ..leading_dims.., L] :param object_reps: [batch_size, max_num_objs_per_batch, obj_dim] :return:
def _collect_obj_reps(self, span_tags, object_reps): """ Collect span-level object representations :param span_tags: [batch_size, ..leading_dims.., L] :param object_reps: [batch_size, max_num_objs_per_batch, obj_dim] :return: """ span_tags_fixed = torch.clamp(spa...
[ "def", "_collect_obj_reps", "(", "self", ",", "span_tags", ",", "object_reps", ")", ":", "span_tags_fixed", "=", "torch", ".", "clamp", "(", "span_tags", ",", "min", "=", "0", ")", "# In case there were masked values here", "row_id", "=", "span_tags_fixed", ".", ...
[ 73, 4 ]
[ 90, 102 ]
python
en
['en', 'error', 'th']
False
ProcessXMLAnnotation
(xml_file)
Process a single XML file containing a bounding box.
Process a single XML file containing a bounding box.
def ProcessXMLAnnotation(xml_file): """Process a single XML file containing a bounding box.""" # pylint: disable=broad-except try: tree = ET.parse(xml_file) except Exception: print('Failed to parse: ' + xml_file, file=sys.stderr) return None # pylint: enable=broad-except root = tree.getroot() ...
[ "def", "ProcessXMLAnnotation", "(", "xml_file", ")", ":", "# pylint: disable=broad-except", "try", ":", "tree", "=", "ET", ".", "parse", "(", "xml_file", ")", "except", "Exception", ":", "print", "(", "'Failed to parse: '", "+", "xml_file", ",", "file", "=", "...
[ 117, 0 ]
[ 166, 14 ]
python
en
['en', 'mk', 'en']
True
RMMResourceAnalyzer.enable_logging
(self)
Enable RMM logging. RMM creates a CSV output file derived from provided file name that looks like: log_file_prefix + ".devX", where X is the GPU number.
Enable RMM logging. RMM creates a CSV output file derived from provided file name that looks like: log_file_prefix + ".devX", where X is the GPU number.
def enable_logging(self): """ Enable RMM logging. RMM creates a CSV output file derived from provided file name that looks like: log_file_prefix + ".devX", where X is the GPU number. """ rmm.enable_logging(log_file_name=self._log_file_prefix)
[ "def", "enable_logging", "(", "self", ")", ":", "rmm", ".", "enable_logging", "(", "log_file_name", "=", "self", ".", "_log_file_prefix", ")" ]
[ 19, 4 ]
[ 25, 63 ]
python
en
['en', 'error', 'th']
False
RMMResourceAnalyzer.disable_logging
(self)
Disable RMM logging
Disable RMM logging
def disable_logging(self): """ Disable RMM logging """ log_output_files = rmm.get_log_filenames() rmm.mr._flush_logs() rmm.disable_logging() # FIXME: potential improvement here would be to only parse the log files for # the gpu ID that's passed in via --be...
[ "def", "disable_logging", "(", "self", ")", ":", "log_output_files", "=", "rmm", ".", "get_log_filenames", "(", ")", "rmm", ".", "mr", ".", "_flush_logs", "(", ")", "rmm", ".", "disable_logging", "(", ")", "# FIXME: potential improvement here would be to only parse ...
[ 27, 4 ]
[ 38, 31 ]
python
en
['en', 'error', 'th']
False
RMMResourceAnalyzer._parse_results
(self, log_files)
Parse CSV results. CSV file has columns: Thread,Time,Action,Pointer,Size,Stream
Parse CSV results. CSV file has columns: Thread,Time,Action,Pointer,Size,Stream
def _parse_results(self, log_files): """ Parse CSV results. CSV file has columns: Thread,Time,Action,Pointer,Size,Stream """ current_mem_usage = 0 for _, log_file in log_files.items(): with open(log_file, mode="r") as csv_file: csv_reader = csv...
[ "def", "_parse_results", "(", "self", ",", "log_files", ")", ":", "current_mem_usage", "=", "0", "for", "_", ",", "log_file", "in", "log_files", ".", "items", "(", ")", ":", "with", "open", "(", "log_file", ",", "mode", "=", "\"r\"", ")", "as", "csv_fi...
[ 40, 4 ]
[ 60, 46 ]
python
en
['en', 'error', 'th']
False
async_get_service
(hass, config, discovery_info=None)
Get the Jabber (XMPP) notification service.
Get the Jabber (XMPP) notification service.
async def async_get_service(hass, config, discovery_info=None): """Get the Jabber (XMPP) notification service.""" return XmppNotificationService( config.get(CONF_SENDER), config.get(CONF_RESOURCE), config.get(CONF_PASSWORD), config.get(CONF_RECIPIENT), config.get(CONF_TLS...
[ "async", "def", "async_get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "XmppNotificationService", "(", "config", ".", "get", "(", "CONF_SENDER", ")", ",", "config", ".", "get", "(", "CONF_RESOURCE", ")", ",",...
[ 66, 0 ]
[ 77, 5 ]
python
en
['en', 'lb', 'en']
True
async_send_message
( sender, password, recipient, use_tls, verify_certificate, room, hass, message, timeout=None, data=None, )
Send a message over XMPP.
Send a message over XMPP.
async def async_send_message( sender, password, recipient, use_tls, verify_certificate, room, hass, message, timeout=None, data=None, ): """Send a message over XMPP.""" class SendNotificationBot(slixmpp.ClientXMPP): """Service for sending Jabber (XMPP) messages."...
[ "async", "def", "async_send_message", "(", "sender", ",", "password", ",", "recipient", ",", "use_tls", ",", "verify_certificate", ",", "room", ",", "hass", ",", "message", ",", "timeout", "=", "None", ",", "data", "=", "None", ",", ")", ":", "class", "S...
[ 115, 0 ]
[ 369, 25 ]
python
en
['en', 'lb', 'en']
True
XmppNotificationService.__init__
(self, sender, resource, password, recipient, tls, verify, room, hass)
Initialize the service.
Initialize the service.
def __init__(self, sender, resource, password, recipient, tls, verify, room, hass): """Initialize the service.""" self._hass = hass self._sender = sender self._resource = resource self._password = password self._recipient = recipient self._tls = tls self._...
[ "def", "__init__", "(", "self", ",", "sender", ",", "resource", ",", "password", ",", "recipient", ",", "tls", ",", "verify", ",", "room", ",", "hass", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_sender", "=", "sender", "self", ".", ...
[ 83, 4 ]
[ 92, 25 ]
python
en
['en', 'en', 'en']
True
XmppNotificationService.async_send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
async def async_send_message(self, message="", **kwargs): """Send a message to a user.""" title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) text = f"{title}: {message}" if title else message data = kwargs.get(ATTR_DATA) timeout = data.get(ATTR_TIMEOUT, XEP_0363_TIMEOUT) if data ...
[ "async", "def", "async_send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "title", "=", "kwargs", ".", "get", "(", "ATTR_TITLE", ",", "ATTR_TITLE_DEFAULT", ")", "text", "=", "f\"{title}: {message}\"", "if", "title", ...
[ 94, 4 ]
[ 112, 9 ]
python
en
['en', 'en', 'en']
True
do_authentication
(hass, hass_config, config)
Notify user of actions and authenticate. Notify user of user_code and verification_url then poll until we have an access token.
Notify user of actions and authenticate.
def do_authentication(hass, hass_config, config): """Notify user of actions and authenticate. Notify user of user_code and verification_url then poll until we have an access token. """ oauth = OAuth2WebServerFlow( client_id=config[CONF_CLIENT_ID], client_secret=config[CONF_CLIENT_SE...
[ "def", "do_authentication", "(", "hass", ",", "hass_config", ",", "config", ")", ":", "oauth", "=", "OAuth2WebServerFlow", "(", "client_id", "=", "config", "[", "CONF_CLIENT_ID", "]", ",", "client_secret", "=", "config", "[", "CONF_CLIENT_SECRET", "]", ",", "s...
[ 129, 0 ]
[ 195, 15 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the Google platform.
Set up the Google platform.
def setup(hass, config): """Set up the Google platform.""" if DATA_INDEX not in hass.data: hass.data[DATA_INDEX] = {} conf = config.get(DOMAIN, {}) if not conf: # component is set up by tts platform return True token_file = hass.config.path(TOKEN_FILE) if not os.path.is...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "if", "DATA_INDEX", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "DATA_INDEX", "]", "=", "{", "}", "conf", "=", "config", ".", "get", "(", "DOMAIN", ",", "{", "}", ")", "...
[ 198, 0 ]
[ 217, 15 ]
python
en
['en', 'da', 'en']
True
check_correct_scopes
(token_file)
Check for the correct scopes in file.
Check for the correct scopes in file.
def check_correct_scopes(token_file): """Check for the correct scopes in file.""" tokenfile = open(token_file).read() if "readonly" in tokenfile: _LOGGER.warning("Please re-authenticate with Google") return False return True
[ "def", "check_correct_scopes", "(", "token_file", ")", ":", "tokenfile", "=", "open", "(", "token_file", ")", ".", "read", "(", ")", "if", "\"readonly\"", "in", "tokenfile", ":", "_LOGGER", ".", "warning", "(", "\"Please re-authenticate with Google\"", ")", "ret...
[ 220, 0 ]
[ 226, 15 ]
python
en
['en', 'en', 'en']
True
setup_services
(hass, hass_config, track_new_found_calendars, calendar_service)
Set up the service listeners.
Set up the service listeners.
def setup_services(hass, hass_config, track_new_found_calendars, calendar_service): """Set up the service listeners.""" def _found_calendar(call): """Check if we know about a calendar and generate PLATFORM_DISCOVER.""" calendar = get_calendar_info(hass, call.data) if hass.data[DATA_INDE...
[ "def", "setup_services", "(", "hass", ",", "hass_config", ",", "track_new_found_calendars", ",", "calendar_service", ")", ":", "def", "_found_calendar", "(", "call", ")", ":", "\"\"\"Check if we know about a calendar and generate PLATFORM_DISCOVER.\"\"\"", "calendar", "=", ...
[ 229, 0 ]
[ 314, 15 ]
python
en
['en', 'en', 'en']
True
do_setup
(hass, hass_config, config)
Run the setup after we have everything configured.
Run the setup after we have everything configured.
def do_setup(hass, hass_config, config): """Run the setup after we have everything configured.""" # Load calendars the user has configured hass.data[DATA_INDEX] = load_config(hass.config.path(YAML_DEVICES)) calendar_service = GoogleCalendarService(hass.config.path(TOKEN_FILE)) track_new_found_calen...
[ "def", "do_setup", "(", "hass", ",", "hass_config", ",", "config", ")", ":", "# Load calendars the user has configured", "hass", ".", "data", "[", "DATA_INDEX", "]", "=", "load_config", "(", "hass", ".", "config", ".", "path", "(", "YAML_DEVICES", ")", ")", ...
[ 317, 0 ]
[ 333, 15 ]
python
en
['en', 'en', 'en']
True
get_calendar_info
(hass, calendar)
Convert data from Google into DEVICE_SCHEMA.
Convert data from Google into DEVICE_SCHEMA.
def get_calendar_info(hass, calendar): """Convert data from Google into DEVICE_SCHEMA.""" calendar_info = DEVICE_SCHEMA( { CONF_CAL_ID: calendar["id"], CONF_ENTITIES: [ { CONF_TRACK: calendar["track"], CONF_NAME: calendar["s...
[ "def", "get_calendar_info", "(", "hass", ",", "calendar", ")", ":", "calendar_info", "=", "DEVICE_SCHEMA", "(", "{", "CONF_CAL_ID", ":", "calendar", "[", "\"id\"", "]", ",", "CONF_ENTITIES", ":", "[", "{", "CONF_TRACK", ":", "calendar", "[", "\"track\"", "]"...
[ 353, 0 ]
[ 369, 24 ]
python
en
['en', 'en', 'en']
True
load_config
(path)
Load the google_calendar_devices.yaml.
Load the google_calendar_devices.yaml.
def load_config(path): """Load the google_calendar_devices.yaml.""" calendars = {} try: with open(path) as file: data = yaml.safe_load(file) for calendar in data: try: calendars.update({calendar[CONF_CAL_ID]: DEVICE_SCHEMA(calendar)}) ...
[ "def", "load_config", "(", "path", ")", ":", "calendars", "=", "{", "}", "try", ":", "with", "open", "(", "path", ")", "as", "file", ":", "data", "=", "yaml", ".", "safe_load", "(", "file", ")", "for", "calendar", "in", "data", ":", "try", ":", "...
[ 372, 0 ]
[ 388, 20 ]
python
en
['en', 'en', 'en']
True
update_config
(path, calendar)
Write the google_calendar_devices.yaml.
Write the google_calendar_devices.yaml.
def update_config(path, calendar): """Write the google_calendar_devices.yaml.""" with open(path, "a") as out: out.write("\n") yaml.dump([calendar], out, default_flow_style=False)
[ "def", "update_config", "(", "path", ",", "calendar", ")", ":", "with", "open", "(", "path", ",", "\"a\"", ")", "as", "out", ":", "out", ".", "write", "(", "\"\\n\"", ")", "yaml", ".", "dump", "(", "[", "calendar", "]", ",", "out", ",", "default_fl...
[ 391, 0 ]
[ 395, 60 ]
python
en
['en', 'zh', 'en']
True
GoogleCalendarService.__init__
(self, token_file)
Init the Google Calendar service.
Init the Google Calendar service.
def __init__(self, token_file): """Init the Google Calendar service.""" self.token_file = token_file
[ "def", "__init__", "(", "self", ",", "token_file", ")", ":", "self", ".", "token_file", "=", "token_file" ]
[ 339, 4 ]
[ 341, 36 ]
python
en
['en', 'ro', 'en']
True
GoogleCalendarService.get
(self)
Get the calendar service from the storage file token.
Get the calendar service from the storage file token.
def get(self): """Get the calendar service from the storage file token.""" credentials = Storage(self.token_file).get() http = credentials.authorize(httplib2.Http()) service = google_discovery.build( "calendar", "v3", http=http, cache_discovery=False ) return ...
[ "def", "get", "(", "self", ")", ":", "credentials", "=", "Storage", "(", "self", ".", "token_file", ")", ".", "get", "(", ")", "http", "=", "credentials", ".", "authorize", "(", "httplib2", ".", "Http", "(", ")", ")", "service", "=", "google_discovery"...
[ 343, 4 ]
[ 350, 22 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up actuator platform.
Set up actuator platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up actuator platform.""" if discovery_info is None: return None consumer = hass.data[DOMAIN][KEY_CONSUMER] actuator_list = [] for entity_info in discovery_info: peripheral = hass.data[DOM...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "None", "consumer", "=", "hass", ".", "data", "[", "DOMAIN", "]"...
[ 20, 0 ]
[ 41, 37 ]
python
en
['en', 'su', 'en']
True
VActuator.__init__
(self, peripheral, parent_name, unit, measurement, consumer)
Initialize the sensor.
Initialize the sensor.
def __init__(self, peripheral, parent_name, unit, measurement, consumer): """Initialize the sensor.""" self._is_on = False self._available = True self._name = f"{parent_name} {measurement}" self._parent_mac = peripheral.parentMac self._identifier = peripheral.identifier ...
[ "def", "__init__", "(", "self", ",", "peripheral", ",", "parent_name", ",", "unit", ",", "measurement", ",", "consumer", ")", ":", "self", ".", "_is_on", "=", "False", "self", ".", "_available", "=", "True", "self", ".", "_name", "=", "f\"{parent_name} {me...
[ 47, 4 ]
[ 56, 32 ]
python
en
['en', 'en', 'en']
True
VActuator.unique_id
(self)
Return the unique id of the actuator.
Return the unique id of the actuator.
def unique_id(self): """Return the unique id of the actuator.""" return f"{self._parent_mac}/{self._identifier}/{self._measurement}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._parent_mac}/{self._identifier}/{self._measurement}\"" ]
[ 59, 4 ]
[ 61, 75 ]
python
en
['en', 'la', 'en']
True
VActuator.name
(self)
Return the name of the actuator.
Return the name of the actuator.
def name(self): """Return the name of the actuator.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 64, 4 ]
[ 66, 25 ]
python
en
['en', 'en', 'en']
True
VActuator.is_on
(self)
Return the state of the actuator.
Return the state of the actuator.
def is_on(self): """Return the state of the actuator.""" return self._is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_is_on" ]
[ 69, 4 ]
[ 71, 26 ]
python
en
['en', 'en', 'en']
True
VActuator.available
(self)
Return if the actuator is available.
Return if the actuator is available.
def available(self): """Return if the actuator is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 74, 4 ]
[ 76, 30 ]
python
en
['en', 'en', 'en']
True
VActuator.async_turn_off
(self, **kwargs)
Turn off the actuator.
Turn off the actuator.
async def async_turn_off(self, **kwargs): """Turn off the actuator.""" await self.update_state(0)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "update_state", "(", "0", ")" ]
[ 78, 4 ]
[ 80, 34 ]
python
en
['en', 'en', 'en']
True
VActuator.async_turn_on
(self, **kwargs)
Turn on the actuator.
Turn on the actuator.
async def async_turn_on(self, **kwargs): """Turn on the actuator.""" await self.update_state(1)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "update_state", "(", "1", ")" ]
[ 82, 4 ]
[ 84, 34 ]
python
en
['en', 'en', 'en']
True
VActuator.update_state
(self, state)
Update the state of the actuator.
Update the state of the actuator.
async def update_state(self, state): """Update the state of the actuator.""" payload = {"id": "state-num", "value": state} await self.consumer.actuatePeripheral( None, self._identifier, self._parent_mac, payload )
[ "async", "def", "update_state", "(", "self", ",", "state", ")", ":", "payload", "=", "{", "\"id\"", ":", "\"state-num\"", ",", "\"value\"", ":", "state", "}", "await", "self", ".", "consumer", ".", "actuatePeripheral", "(", "None", ",", "self", ".", "_id...
[ 86, 4 ]
[ 92, 9 ]
python
en
['en', 'en', 'en']
True
VActuator.async_update
(self)
Fetch state data from the actuator.
Fetch state data from the actuator.
async def async_update(self): """Fetch state data from the actuator.""" samples = await self.consumer.fetchPeripheralSample( None, self._identifier, self._parent_mac ) if samples is not None: for sample in samples: if sample.measurement == self._m...
[ "async", "def", "async_update", "(", "self", ")", ":", "samples", "=", "await", "self", ".", "consumer", ".", "fetchPeripheralSample", "(", "None", ",", "self", ".", "_identifier", ",", "self", ".", "_parent_mac", ")", "if", "samples", "is", "not", "None",...
[ 94, 4 ]
[ 112, 30 ]
python
en
['en', 'en', 'en']
True
supported
(event)
Return whether an event supports binary_sensor.
Return whether an event supports binary_sensor.
def supported(event): """Return whether an event supports binary_sensor.""" if isinstance(event, rfxtrxmod.ControlEvent): return True if isinstance(event, rfxtrxmod.SensorEvent): return event.values.get("Sensor Status") in [ *SENSOR_STATUS_ON, *SENSOR_STATUS_OFF, ...
[ "def", "supported", "(", "event", ")", ":", "if", "isinstance", "(", "event", ",", "rfxtrxmod", ".", "ControlEvent", ")", ":", "return", "True", "if", "isinstance", "(", "event", ",", "rfxtrxmod", ".", "SensorEvent", ")", ":", "return", "event", ".", "va...
[ 62, 0 ]
[ 71, 16 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass, config_entry, async_add_entities, )
Set up platform.
Set up platform.
async def async_setup_entry( hass, config_entry, async_add_entities, ): """Set up platform.""" sensors = [] device_ids = set() pt2262_devices = [] discovery_info = config_entry.data for packet_id, entity_info in discovery_info[CONF_DEVICES].items(): event = get_rfx_object(...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ",", ")", ":", "sensors", "=", "[", "]", "device_ids", "=", "set", "(", ")", "pt2262_devices", "=", "[", "]", "discovery_info", "=", "config_entry", ".", "data"...
[ 74, 0 ]
[ 148, 64 ]
python
en
['en', 'ru', 'en']
True
RfxtrxBinarySensor.__init__
( self, device, device_id, device_class=None, off_delay=None, data_bits=None, cmd_on=None, cmd_off=None, event=None, )
Initialize the RFXtrx sensor.
Initialize the RFXtrx sensor.
def __init__( self, device, device_id, device_class=None, off_delay=None, data_bits=None, cmd_on=None, cmd_off=None, event=None, ): """Initialize the RFXtrx sensor.""" super().__init__(device, device_id, event=event) sel...
[ "def", "__init__", "(", "self", ",", "device", ",", "device_id", ",", "device_class", "=", "None", ",", "off_delay", "=", "None", ",", "data_bits", "=", "None", ",", "cmd_on", "=", "None", ",", "cmd_off", "=", "None", ",", "event", "=", "None", ",", ...
[ 154, 4 ]
[ 173, 31 ]
python
en
['en', 'pl', 'en']
True
RfxtrxBinarySensor.async_added_to_hass
(self)
Restore device state.
Restore device state.
async def async_added_to_hass(self): """Restore device state.""" await super().async_added_to_hass() if self._event is None: old_state = await self.async_get_last_state() if old_state is not None: self._state = old_state.state == STATE_ON if self...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "if", "self", ".", "_event", "is", "None", ":", "old_state", "=", "await", "self", ".", "async_get_last_state", "(", ")", "if", ...
[ 175, 4 ]
[ 185, 31 ]
python
it
['it', 'it', 'en']
True
RfxtrxBinarySensor.force_update
(self)
We should force updates. Repeated states have meaning.
We should force updates. Repeated states have meaning.
def force_update(self) -> bool: """We should force updates. Repeated states have meaning.""" return True
[ "def", "force_update", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 188, 4 ]
[ 190, 19 ]
python
en
['en', 'en', 'en']
True
RfxtrxBinarySensor.device_class
(self)
Return the sensor class.
Return the sensor class.
def device_class(self): """Return the sensor class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 193, 4 ]
[ 195, 33 ]
python
en
['en', 'sq', 'en']
True
RfxtrxBinarySensor.is_on
(self)
Return true if the sensor state is True.
Return true if the sensor state is True.
def is_on(self): """Return true if the sensor state is True.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 198, 4 ]
[ 200, 26 ]
python
en
['en', 'mt', 'en']
True
RfxtrxBinarySensor._apply_event_lighting4
(self, event)
Apply event for a lighting 4 device.
Apply event for a lighting 4 device.
def _apply_event_lighting4(self, event): """Apply event for a lighting 4 device.""" if self._data_bits is not None: cmd = get_pt2262_cmd(event.device.id_string, self._data_bits) cmd = int(cmd, 16) if cmd == self._cmd_on: self._state = True ...
[ "def", "_apply_event_lighting4", "(", "self", ",", "event", ")", ":", "if", "self", ".", "_data_bits", "is", "not", "None", ":", "cmd", "=", "get_pt2262_cmd", "(", "event", ".", "device", ".", "id_string", ",", "self", ".", "_data_bits", ")", "cmd", "=",...
[ 202, 4 ]
[ 212, 30 ]
python
en
['en', 'en', 'en']
True
RfxtrxBinarySensor._apply_event
(self, event)
Apply command from rfxtrx.
Apply command from rfxtrx.
def _apply_event(self, event): """Apply command from rfxtrx.""" super()._apply_event(event) if event.device.packettype == DEVICE_PACKET_TYPE_LIGHTING4: self._apply_event_lighting4(event) else: self._apply_event_standard(event)
[ "def", "_apply_event", "(", "self", ",", "event", ")", ":", "super", "(", ")", ".", "_apply_event", "(", "event", ")", "if", "event", ".", "device", ".", "packettype", "==", "DEVICE_PACKET_TYPE_LIGHTING4", ":", "self", ".", "_apply_event_lighting4", "(", "ev...
[ 224, 4 ]
[ 230, 45 ]
python
en
['en', 'en', 'en']
True
RfxtrxBinarySensor._handle_event
(self, event, device_id)
Check if event applies to me and update.
Check if event applies to me and update.
def _handle_event(self, event, device_id): """Check if event applies to me and update.""" if device_id != self._device_id: return _LOGGER.debug( "Binary sensor update (Device ID: %s Class: %s Sub: %s)", event.device.id_string, event.device.__class...
[ "def", "_handle_event", "(", "self", ",", "event", ",", "device_id", ")", ":", "if", "device_id", "!=", "self", ".", "_device_id", ":", "return", "_LOGGER", ".", "debug", "(", "\"Binary sensor update (Device ID: %s Class: %s Sub: %s)\"", ",", "event", ".", "device...
[ 233, 4 ]
[ 264, 13 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up an alarm control panel for a Lupusec device.
Set up an alarm control panel for a Lupusec device.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up an alarm control panel for a Lupusec device.""" if discovery_info is None: return data = hass.data[LUPUSEC_DOMAIN] alarm_devices = [LupusecAlarm(data, data.lupusec.get_alarm())] add_entities(alarm_devices)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "data", "=", "hass", ".", "data", "[", "LUPUSEC_DOMAIN", "]", "alarm_devices", "=", ...
[ 22, 0 ]
[ 31, 31 ]
python
en
['en', 'en', 'en']
True
LupusecAlarm.icon
(self)
Return the icon.
Return the icon.
def icon(self): """Return the icon.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 38, 4 ]
[ 40, 19 ]
python
en
['en', 'sr', 'en']
True
LupusecAlarm.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" if self._device.is_standby: state = STATE_ALARM_DISARMED elif self._device.is_away: state = STATE_ALARM_ARMED_AWAY elif self._device.is_home: state = STATE_ALARM_ARMED_HOME elif self._devic...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "is_standby", ":", "state", "=", "STATE_ALARM_DISARMED", "elif", "self", ".", "_device", ".", "is_away", ":", "state", "=", "STATE_ALARM_ARMED_AWAY", "elif", "self", ".", "_device", ...
[ 43, 4 ]
[ 55, 20 ]
python
en
['en', 'en', 'en']
True
LupusecAlarm.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
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_ALARM_ARM_HOME", "|", "SUPPORT_ALARM_ARM_AWAY" ]
[ 58, 4 ]
[ 60, 62 ]
python
en
['en', 'en', 'en']
True
LupusecAlarm.alarm_arm_away
(self, code=None)
Send arm away command.
Send arm away command.
def alarm_arm_away(self, code=None): """Send arm away command.""" self._device.set_away()
[ "def", "alarm_arm_away", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_device", ".", "set_away", "(", ")" ]
[ 62, 4 ]
[ 64, 31 ]
python
en
['en', 'en', 'en']
True
LupusecAlarm.alarm_disarm
(self, code=None)
Send disarm command.
Send disarm command.
def alarm_disarm(self, code=None): """Send disarm command.""" self._device.set_standby()
[ "def", "alarm_disarm", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_device", ".", "set_standby", "(", ")" ]
[ 66, 4 ]
[ 68, 34 ]
python
en
['en', 'pt', 'en']
True
LupusecAlarm.alarm_arm_home
(self, code=None)
Send arm home command.
Send arm home command.
def alarm_arm_home(self, code=None): """Send arm home command.""" self._device.set_home()
[ "def", "alarm_arm_home", "(", "self", ",", "code", "=", "None", ")", ":", "self", ".", "_device", ".", "set_home", "(", ")" ]
[ 70, 4 ]
[ 72, 31 ]
python
en
['en', 'pt', 'en']
True
Config.refresh_config
(self)
refresh to get latest config
refresh to get latest config
def refresh_config(self): '''refresh to get latest config''' sql = 'select params from ExperimentProfile where id=? order by revision DESC' args = (self.experiment_id,) self.config = config_v0_to_v1(json_tricks.loads(self.conn.cursor().execute(sql, args).fetchone()[0]))
[ "def", "refresh_config", "(", "self", ")", ":", "sql", "=", "'select params from ExperimentProfile where id=? order by revision DESC'", "args", "=", "(", "self", ".", "experiment_id", ",", ")", "self", ".", "config", "=", "config_v0_to_v1", "(", "json_tricks", ".", ...
[ 87, 4 ]
[ 91, 109 ]
python
en
['en', 'en', 'en']
True
Config.get_config
(self)
get a value according to key
get a value according to key
def get_config(self): '''get a value according to key''' return self.config
[ "def", "get_config", "(", "self", ")", ":", "return", "self", ".", "config" ]
[ 93, 4 ]
[ 95, 26 ]
python
en
['en', 'en', 'en']
True
Experiments.add_experiment
(self, expId, port, startTime, platform, experiment_name, endTime='N/A', status='INITIALIZED', tag=[], pid=None, webuiUrl=[], logDir='', prefixUrl=None)
set {key:value} pairs to self.experiment
set {key:value} pairs to self.experiment
def add_experiment(self, expId, port, startTime, platform, experiment_name, endTime='N/A', status='INITIALIZED', tag=[], pid=None, webuiUrl=[], logDir='', prefixUrl=None): '''set {key:value} pairs to self.experiment''' with self.lock: self.experiments = self.read_file(...
[ "def", "add_experiment", "(", "self", ",", "expId", ",", "port", ",", "startTime", ",", "platform", ",", "experiment_name", ",", "endTime", "=", "'N/A'", ",", "status", "=", "'INITIALIZED'", ",", "tag", "=", "[", "]", ",", "pid", "=", "None", ",", "web...
[ 106, 4 ]
[ 124, 29 ]
python
en
['en', 'en', 'en']
True
Experiments.update_experiment
(self, expId, key, value)
Update experiment
Update experiment
def update_experiment(self, expId, key, value): '''Update experiment''' with self.lock: self.experiments = self.read_file() if expId not in self.experiments: return False if value is None: self.experiments[expId].pop(key, None) ...
[ "def", "update_experiment", "(", "self", ",", "expId", ",", "key", ",", "value", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "experiments", "=", "self", ".", "read_file", "(", ")", "if", "expId", "not", "in", "self", ".", "experiments", ...
[ 126, 4 ]
[ 137, 23 ]
python
en
['it', 'la', 'en']
False
Experiments.remove_experiment
(self, expId)
remove an experiment by id
remove an experiment by id
def remove_experiment(self, expId): '''remove an experiment by id''' with self.lock: self.experiments = self.read_file() if expId in self.experiments: self.experiments.pop(expId) self.write_file()
[ "def", "remove_experiment", "(", "self", ",", "expId", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "experiments", "=", "self", ".", "read_file", "(", ")", "if", "expId", "in", "self", ".", "experiments", ":", "self", ".", "experiments", "....
[ 139, 4 ]
[ 145, 29 ]
python
en
['en', 'en', 'en']
True
Experiments.get_all_experiments
(self)
return all of experiments
return all of experiments
def get_all_experiments(self): '''return all of experiments''' return self.experiments
[ "def", "get_all_experiments", "(", "self", ")", ":", "return", "self", ".", "experiments" ]
[ 147, 4 ]
[ 149, 31 ]
python
en
['en', 'en', 'en']
True
Experiments.write_file
(self)
save config to local file
save config to local file
def write_file(self): '''save config to local file''' try: with open(self.experiment_file, 'w') as file: json_tricks.dump(self.experiments, file, indent=4) except IOError as error: print('Error:', error) return ''
[ "def", "write_file", "(", "self", ")", ":", "try", ":", "with", "open", "(", "self", ".", "experiment_file", ",", "'w'", ")", "as", "file", ":", "json_tricks", ".", "dump", "(", "self", ".", "experiments", ",", "file", ",", "indent", "=", "4", ")", ...
[ 151, 4 ]
[ 158, 21 ]
python
en
['en', 'en', 'en']
True
Experiments.read_file
(self)
load config from local file
load config from local file
def read_file(self): '''load config from local file''' if os.path.exists(self.experiment_file): try: with open(self.experiment_file, 'r') as file: return json_tricks.load(file) except ValueError: return {} return {}
[ "def", "read_file", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "experiment_file", ")", ":", "try", ":", "with", "open", "(", "self", ".", "experiment_file", ",", "'r'", ")", "as", "file", ":", "return", "json_tri...
[ 160, 4 ]
[ 168, 17 ]
python
en
['en', 'en', 'en']
True
mock_transmission_api
()
Mock an api.
Mock an api.
def mock_transmission_api(): """Mock an api.""" with patch("transmissionrpc.Client"): yield
[ "def", "mock_transmission_api", "(", ")", ":", "with", "patch", "(", "\"transmissionrpc.Client\"", ")", ":", "yield" ]
[ 26, 0 ]
[ 29, 13 ]
python
en
['en', 'su', 'en']
True
mock_api_authentication_error
()
Mock an api.
Mock an api.
def mock_api_authentication_error(): """Mock an api.""" with patch( "transmissionrpc.Client", side_effect=TransmissionError("401: Unauthorized") ): yield
[ "def", "mock_api_authentication_error", "(", ")", ":", "with", "patch", "(", "\"transmissionrpc.Client\"", ",", "side_effect", "=", "TransmissionError", "(", "\"401: Unauthorized\"", ")", ")", ":", "yield" ]
[ 33, 0 ]
[ 38, 13 ]
python
en
['en', 'su', 'en']
True
mock_api_unknown_error
()
Mock an api.
Mock an api.
def mock_api_unknown_error(): """Mock an api.""" with patch("transmissionrpc.Client", side_effect=TransmissionError): yield
[ "def", "mock_api_unknown_error", "(", ")", ":", "with", "patch", "(", "\"transmissionrpc.Client\"", ",", "side_effect", "=", "TransmissionError", ")", ":", "yield" ]
[ 42, 0 ]
[ 45, 13 ]
python
en
['en', 'su', 'en']
True
test_setup_with_no_config
(hass)
Test that we do not discover anything or try to set up a Transmission client.
Test that we do not discover anything or try to set up a Transmission client.
async def test_setup_with_no_config(hass): """Test that we do not discover anything or try to set up a Transmission client.""" assert await async_setup_component(hass, transmission.DOMAIN, {}) is True assert transmission.DOMAIN not in hass.data
[ "async", "def", "test_setup_with_no_config", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "transmission", ".", "DOMAIN", ",", "{", "}", ")", "is", "True", "assert", "transmission", ".", "DOMAIN", "not", "in", "hass", "...
[ 48, 0 ]
[ 51, 47 ]
python
en
['en', 'en', 'en']
True
test_setup_with_config
(hass, api)
Test that we import the config and setup the client.
Test that we import the config and setup the client.
async def test_setup_with_config(hass, api): """Test that we import the config and setup the client.""" config = { transmission.DOMAIN: { transmission.CONF_NAME: "Transmission", transmission.CONF_HOST: "0.0.0.0", transmission.CONF_USERNAME: "user", transmi...
[ "async", "def", "test_setup_with_config", "(", "hass", ",", "api", ")", ":", "config", "=", "{", "transmission", ".", "DOMAIN", ":", "{", "transmission", ".", "CONF_NAME", ":", "\"Transmission\"", ",", "transmission", ".", "CONF_HOST", ":", "\"0.0.0.0\"", ",",...
[ 54, 0 ]
[ 72, 81 ]
python
en
['en', 'en', 'en']
True
test_successful_config_entry
(hass, api)
Test that configured transmission is configured successfully.
Test that configured transmission is configured successfully.
async def test_successful_config_entry(hass, api): """Test that configured transmission is configured successfully.""" entry = MOCK_ENTRY entry.add_to_hass(hass) assert await transmission.async_setup_entry(hass, entry) is True assert entry.options == { transmission.CONF_SCAN_INTERVAL: tran...
[ "async", "def", "test_successful_config_entry", "(", "hass", ",", "api", ")", ":", "entry", "=", "MOCK_ENTRY", "entry", ".", "add_to_hass", "(", "hass", ")", "assert", "await", "transmission", ".", "async_setup_entry", "(", "hass", ",", "entry", ")", "is", "...
[ 75, 0 ]
[ 86, 5 ]
python
en
['en', 'en', 'en']
True
test_setup_failed
(hass)
Test transmission failed due to an error.
Test transmission failed due to an error.
async def test_setup_failed(hass): """Test transmission failed due to an error.""" entry = MOCK_ENTRY entry.add_to_hass(hass) # test connection error raising ConfigEntryNotReady with patch( "transmissionrpc.Client", side_effect=TransmissionError("111: Connection refused"), ), p...
[ "async", "def", "test_setup_failed", "(", "hass", ")", ":", "entry", "=", "MOCK_ENTRY", "entry", ".", "add_to_hass", "(", "hass", ")", "# test connection error raising ConfigEntryNotReady", "with", "patch", "(", "\"transmissionrpc.Client\"", ",", "side_effect", "=", "...
[ 89, 0 ]
[ 109, 73 ]
python
en
['en', 'en', 'en']
True
test_unload_entry
(hass, api)
Test removing transmission client.
Test removing transmission client.
async def test_unload_entry(hass, api): """Test removing transmission client.""" entry = MOCK_ENTRY entry.add_to_hass(hass) with patch.object( hass.config_entries, "async_forward_entry_unload", return_value=mock_coro(True) ) as unload_entry: assert await transmission.async_setup_ent...
[ "async", "def", "test_unload_entry", "(", "hass", ",", "api", ")", ":", "entry", "=", "MOCK_ENTRY", "entry", ".", "add_to_hass", "(", "hass", ")", "with", "patch", ".", "object", "(", "hass", ".", "config_entries", ",", "\"async_forward_entry_unload\"", ",", ...
[ 112, 0 ]
[ 124, 67 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up OpenWeatherMap weather entity based on a config entry.
Set up OpenWeatherMap weather entity based on a config entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up OpenWeatherMap weather entity based on a config entry.""" domain_data = hass.data[DOMAIN][config_entry.entry_id] name = domain_data[ENTRY_NAME] weather_coordinator = domain_data[ENTRY_WEATHER_COORDINATOR] unique_id = f"{...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "domain_data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "name", "=", "domain_data", "[", "ENTRY_NAME", ...
[ 20, 0 ]
[ 29, 44 ]
python
en
['en', 'en', 'en']
True
OpenWeatherMapWeather.__init__
( self, name, unique_id, weather_coordinator: WeatherUpdateCoordinator, )
Initialize the sensor.
Initialize the sensor.
def __init__( self, name, unique_id, weather_coordinator: WeatherUpdateCoordinator, ): """Initialize the sensor.""" self._name = name self._unique_id = unique_id self._weather_coordinator = weather_coordinator
[ "def", "__init__", "(", "self", ",", "name", ",", "unique_id", ",", "weather_coordinator", ":", "WeatherUpdateCoordinator", ",", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_unique_id", "=", "unique_id", "self", ".", "_weather_coordinator", "=",...
[ 35, 4 ]
[ 44, 55 ]
python
en
['en', 'en', 'en']
True
OpenWeatherMapWeather.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" ]
[ 47, 4 ]
[ 49, 25 ]
python
en
['en', 'mi', 'en']
True
OpenWeatherMapWeather.unique_id
(self)
Return a unique_id for this entity.
Return a unique_id for this entity.
def unique_id(self): """Return a unique_id for this entity.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 52, 4 ]
[ 54, 30 ]
python
en
['en', 'en', 'en']
True
OpenWeatherMapWeather.should_poll
(self)
Return the polling requirement of the entity.
Return the polling requirement of the entity.
def should_poll(self): """Return the polling requirement of the entity.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 57, 4 ]
[ 59, 20 ]
python
en
['en', 'en', 'en']
True
OpenWeatherMapWeather.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return ATTRIBUTION
[ "def", "attribution", "(", "self", ")", ":", "return", "ATTRIBUTION" ]
[ 62, 4 ]
[ 64, 26 ]
python
en
['en', 'ja', 'en']
True
OpenWeatherMapWeather.condition
(self)
Return the current condition.
Return the current condition.
def condition(self): """Return the current condition.""" return self._weather_coordinator.data[ATTR_API_CONDITION]
[ "def", "condition", "(", "self", ")", ":", "return", "self", ".", "_weather_coordinator", ".", "data", "[", "ATTR_API_CONDITION", "]" ]
[ 67, 4 ]
[ 69, 65 ]
python
en
['en', 'en', 'en']
True
OpenWeatherMapWeather.temperature
(self)
Return the temperature.
Return the temperature.
def temperature(self): """Return the temperature.""" return self._weather_coordinator.data[ATTR_API_TEMPERATURE]
[ "def", "temperature", "(", "self", ")", ":", "return", "self", ".", "_weather_coordinator", ".", "data", "[", "ATTR_API_TEMPERATURE", "]" ]
[ 72, 4 ]
[ 74, 67 ]
python
en
['en', 'la', 'en']
True
OpenWeatherMapWeather.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 77, 4 ]
[ 79, 27 ]
python
en
['en', 'la', 'en']
True