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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
IFTTTAlarmPanel.alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | def alarm_arm_home(self, code=None):
"""Send arm home command."""
if not self._check_code(code):
return
self.set_alarm_state(self._event_home, STATE_ALARM_ARMED_HOME) | [
"def",
"alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_check_code",
"(",
"code",
")",
":",
"return",
"self",
".",
"set_alarm_state",
"(",
"self",
".",
"_event_home",
",",
"STATE_ALARM_ARMED_HOME",
")"
] | [
167,
4
] | [
171,
70
] | python | en | ['en', 'pt', 'en'] | True |
IFTTTAlarmPanel.alarm_arm_night | (self, code=None) | Send arm night command. | Send arm night command. | def alarm_arm_night(self, code=None):
"""Send arm night command."""
if not self._check_code(code):
return
self.set_alarm_state(self._event_night, STATE_ALARM_ARMED_NIGHT) | [
"def",
"alarm_arm_night",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_check_code",
"(",
"code",
")",
":",
"return",
"self",
".",
"set_alarm_state",
"(",
"self",
".",
"_event_night",
",",
"STATE_ALARM_ARMED_NIGHT",
")"
] | [
173,
4
] | [
177,
72
] | python | en | ['en', 'zh', 'en'] | True |
IFTTTAlarmPanel.set_alarm_state | (self, event, state) | Call the IFTTT trigger service to change the alarm state. | Call the IFTTT trigger service to change the alarm state. | def set_alarm_state(self, event, state):
"""Call the IFTTT trigger service to change the alarm state."""
data = {ATTR_EVENT: event}
self.hass.services.call(DOMAIN, SERVICE_TRIGGER, data)
_LOGGER.debug("Called IFTTT integration to trigger event %s", event)
if self._optimistic:
... | [
"def",
"set_alarm_state",
"(",
"self",
",",
"event",
",",
"state",
")",
":",
"data",
"=",
"{",
"ATTR_EVENT",
":",
"event",
"}",
"self",
".",
"hass",
".",
"services",
".",
"call",
"(",
"DOMAIN",
",",
"SERVICE_TRIGGER",
",",
"data",
")",
"_LOGGER",
".",
... | [
179,
4
] | [
186,
31
] | python | en | ['en', 'en', 'en'] | True |
IFTTTAlarmPanel.push_alarm_state | (self, value) | Push the alarm state to the given value. | Push the alarm state to the given value. | def push_alarm_state(self, value):
"""Push the alarm state to the given value."""
if value in ALLOWED_STATES:
_LOGGER.debug("Pushed the alarm state to %s", value)
self._state = value | [
"def",
"push_alarm_state",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"ALLOWED_STATES",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Pushed the alarm state to %s\"",
",",
"value",
")",
"self",
".",
"_state",
"=",
"value"
] | [
188,
4
] | [
192,
31
] | python | en | ['en', 'en', 'en'] | True |
convert_examples_to_features | (
examples: List[InputExample],
label_list: List[str],
max_length: int,
tokenizer: PreTrainedTokenizer,
) |
Loads a data file into a list of `InputFeatures`
|
Loads a data file into a list of `InputFeatures`
| def convert_examples_to_features(
examples: List[InputExample],
label_list: List[str],
max_length: int,
tokenizer: PreTrainedTokenizer,
) -> List[InputFeatures]:
"""
Loads a data file into a list of `InputFeatures`
"""
label_map = {label: i for i, label in enumerate(label_list)}
fe... | [
"def",
"convert_examples_to_features",
"(",
"examples",
":",
"List",
"[",
"InputExample",
"]",
",",
"label_list",
":",
"List",
"[",
"str",
"]",
",",
"max_length",
":",
"int",
",",
"tokenizer",
":",
"PreTrainedTokenizer",
",",
")",
"->",
"List",
"[",
"InputFe... | [
507,
0
] | [
574,
19
] | python | en | ['en', 'error', 'th'] | False |
DataProcessor.get_train_examples | (self, data_dir) | Gets a collection of `InputExample`s for the train set. | Gets a collection of `InputExample`s for the train set. | def get_train_examples(self, data_dir):
"""Gets a collection of `InputExample`s for the train set."""
raise NotImplementedError() | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
235,
4
] | [
237,
35
] | python | en | ['en', 'en', 'en'] | True |
DataProcessor.get_dev_examples | (self, data_dir) | Gets a collection of `InputExample`s for the dev set. | Gets a collection of `InputExample`s for the dev set. | def get_dev_examples(self, data_dir):
"""Gets a collection of `InputExample`s for the dev set."""
raise NotImplementedError() | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
239,
4
] | [
241,
35
] | python | en | ['en', 'en', 'en'] | True |
DataProcessor.get_test_examples | (self, data_dir) | Gets a collection of `InputExample`s for the test set. | Gets a collection of `InputExample`s for the test set. | def get_test_examples(self, data_dir):
"""Gets a collection of `InputExample`s for the test set."""
raise NotImplementedError() | [
"def",
"get_test_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
243,
4
] | [
245,
35
] | python | en | ['en', 'en', 'en'] | True |
DataProcessor.get_labels | (self) | Gets the list of labels for this data set. | Gets the list of labels for this data set. | def get_labels(self):
"""Gets the list of labels for this data set."""
raise NotImplementedError() | [
"def",
"get_labels",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
247,
4
] | [
249,
35
] | python | en | ['en', 'en', 'en'] | True |
RaceProcessor.get_train_examples | (self, data_dir) | See base class. | See base class. | def get_train_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} train".format(data_dir))
high = os.path.join(data_dir, "train/high")
middle = os.path.join(data_dir, "train/middle")
high = self._read_txt(high)
middle = self._read_txt(middle)
... | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} train\"",
".",
"format",
"(",
"data_dir",
")",
")",
"high",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"train/high\"",
")",
... | [
255,
4
] | [
262,
60
] | python | en | ['en', 'en', 'en'] | True |
RaceProcessor.get_dev_examples | (self, data_dir) | See base class. | See base class. | def get_dev_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} dev".format(data_dir))
high = os.path.join(data_dir, "dev/high")
middle = os.path.join(data_dir, "dev/middle")
high = self._read_txt(high)
middle = self._read_txt(middle)
return... | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} dev\"",
".",
"format",
"(",
"data_dir",
")",
")",
"high",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"dev/high\"",
")",
"mid... | [
264,
4
] | [
271,
58
] | python | en | ['en', 'en', 'en'] | True |
RaceProcessor.get_test_examples | (self, data_dir) | See base class. | See base class. | def get_test_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} test".format(data_dir))
high = os.path.join(data_dir, "test/high")
middle = os.path.join(data_dir, "test/middle")
high = self._read_txt(high)
middle = self._read_txt(middle)
re... | [
"def",
"get_test_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} test\"",
".",
"format",
"(",
"data_dir",
")",
")",
"high",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"test/high\"",
")",
"... | [
273,
4
] | [
280,
59
] | python | en | ['en', 'en', 'en'] | True |
RaceProcessor.get_labels | (self) | See base class. | See base class. | def get_labels(self):
"""See base class."""
return ["0", "1", "2", "3"] | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"\"0\"",
",",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
"]"
] | [
282,
4
] | [
284,
35
] | python | en | ['en', 'en', 'en'] | True |
RaceProcessor._create_examples | (self, lines, set_type) | Creates examples for the training and dev sets. | Creates examples for the training and dev sets. | def _create_examples(self, lines, set_type):
"""Creates examples for the training and dev sets."""
examples = []
for (_, data_raw) in enumerate(lines):
race_id = "%s-%s" % (set_type, data_raw["race_id"])
article = data_raw["article"]
for i in range(len(data_ra... | [
"def",
"_create_examples",
"(",
"self",
",",
"lines",
",",
"set_type",
")",
":",
"examples",
"=",
"[",
"]",
"for",
"(",
"_",
",",
"data_raw",
")",
"in",
"enumerate",
"(",
"lines",
")",
":",
"race_id",
"=",
"\"%s-%s\"",
"%",
"(",
"set_type",
",",
"dat... | [
296,
4
] | [
316,
23
] | python | en | ['en', 'en', 'en'] | True |
SynonymProcessor.get_train_examples | (self, data_dir) | See base class. | See base class. | def get_train_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} train".format(data_dir))
return self._create_examples(self._read_csv(os.path.join(data_dir, "mctrain.csv")), "train") | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} train\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_csv",
"(",
"os",
".",
... | [
322,
4
] | [
325,
100
] | python | en | ['en', 'en', 'en'] | True |
SynonymProcessor.get_dev_examples | (self, data_dir) | See base class. | See base class. | def get_dev_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} dev".format(data_dir))
return self._create_examples(self._read_csv(os.path.join(data_dir, "mchp.csv")), "dev") | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} dev\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_csv",
"(",
"os",
".",
"pat... | [
327,
4
] | [
330,
95
] | python | en | ['en', 'en', 'en'] | True |
SynonymProcessor.get_test_examples | (self, data_dir) | See base class. | See base class. | def get_test_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} dev".format(data_dir))
return self._create_examples(self._read_csv(os.path.join(data_dir, "mctest.csv")), "test") | [
"def",
"get_test_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} dev\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_csv",
"(",
"os",
".",
"pa... | [
332,
4
] | [
336,
98
] | python | en | ['en', 'en', 'en'] | True |
SynonymProcessor.get_labels | (self) | See base class. | See base class. | def get_labels(self):
"""See base class."""
return ["0", "1", "2", "3", "4"] | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"\"0\"",
",",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
",",
"\"4\"",
"]"
] | [
338,
4
] | [
340,
40
] | python | en | ['en', 'en', 'en'] | True |
SynonymProcessor._create_examples | (self, lines: List[List[str]], type: str) | Creates examples for the training and dev sets. | Creates examples for the training and dev sets. | def _create_examples(self, lines: List[List[str]], type: str):
"""Creates examples for the training and dev sets."""
examples = [
InputExample(
example_id=line[0],
question="", # in the swag dataset, the
# common beginning of each
... | [
"def",
"_create_examples",
"(",
"self",
",",
"lines",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"type",
":",
"str",
")",
":",
"examples",
"=",
"[",
"InputExample",
"(",
"example_id",
"=",
"line",
"[",
"0",
"]",
",",
"question",
"=",
"\"\... | [
346,
4
] | [
362,
23
] | python | en | ['en', 'en', 'en'] | True |
SwagProcessor.get_train_examples | (self, data_dir) | See base class. | See base class. | def get_train_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} train".format(data_dir))
return self._create_examples(self._read_csv(os.path.join(data_dir, "train.csv")), "train") | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} train\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_csv",
"(",
"os",
".",
... | [
368,
4
] | [
371,
98
] | python | en | ['en', 'en', 'en'] | True |
SwagProcessor.get_dev_examples | (self, data_dir) | See base class. | See base class. | def get_dev_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} dev".format(data_dir))
return self._create_examples(self._read_csv(os.path.join(data_dir, "val.csv")), "dev") | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} dev\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_csv",
"(",
"os",
".",
"pat... | [
373,
4
] | [
376,
94
] | python | en | ['en', 'en', 'en'] | True |
SwagProcessor.get_test_examples | (self, data_dir) | See base class. | See base class. | def get_test_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} dev".format(data_dir))
raise ValueError(
"For swag testing, the input file does not contain a label column. It can not be tested in current code"
"setting!"
)
return se... | [
"def",
"get_test_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} dev\"",
".",
"format",
"(",
"data_dir",
")",
")",
"raise",
"ValueError",
"(",
"\"For swag testing, the input file does not contain a label column. It can not b... | [
378,
4
] | [
385,
96
] | python | en | ['en', 'en', 'en'] | True |
SwagProcessor.get_labels | (self) | See base class. | See base class. | def get_labels(self):
"""See base class."""
return ["0", "1", "2", "3"] | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"\"0\"",
",",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
"]"
] | [
387,
4
] | [
389,
35
] | python | en | ['en', 'en', 'en'] | True |
SwagProcessor._create_examples | (self, lines: List[List[str]], type: str) | Creates examples for the training and dev sets. | Creates examples for the training and dev sets. | def _create_examples(self, lines: List[List[str]], type: str):
"""Creates examples for the training and dev sets."""
if type == "train" and lines[0][-1] != "label":
raise ValueError("For training, the input file must contain a label column.")
examples = [
InputExample(
... | [
"def",
"_create_examples",
"(",
"self",
",",
"lines",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"type",
":",
"str",
")",
":",
"if",
"type",
"==",
"\"train\"",
"and",
"lines",
"[",
"0",
"]",
"[",
"-",
"1",
"]",
"!=",
"\"label\"",
":",
... | [
395,
4
] | [
413,
23
] | python | en | ['en', 'en', 'en'] | True |
ArcProcessor.get_train_examples | (self, data_dir) | See base class. | See base class. | def get_train_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} train".format(data_dir))
return self._create_examples(self._read_json(os.path.join(data_dir, "train.jsonl")), "train") | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} train\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_json",
"(",
"os",
".",
... | [
419,
4
] | [
422,
101
] | python | en | ['en', 'en', 'en'] | True |
ArcProcessor.get_dev_examples | (self, data_dir) | See base class. | See base class. | def get_dev_examples(self, data_dir):
"""See base class."""
logger.info("LOOKING AT {} dev".format(data_dir))
return self._create_examples(self._read_json(os.path.join(data_dir, "dev.jsonl")), "dev") | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"LOOKING AT {} dev\"",
".",
"format",
"(",
"data_dir",
")",
")",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_json",
"(",
"os",
".",
"pa... | [
424,
4
] | [
427,
97
] | python | en | ['en', 'en', 'en'] | True |
ArcProcessor.get_labels | (self) | See base class. | See base class. | def get_labels(self):
"""See base class."""
return ["0", "1", "2", "3"] | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"\"0\"",
",",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
"]"
] | [
433,
4
] | [
435,
35
] | python | en | ['en', 'en', 'en'] | True |
ArcProcessor._create_examples | (self, lines, type) | Creates examples for the training and dev sets. | Creates examples for the training and dev sets. | def _create_examples(self, lines, type):
"""Creates examples for the training and dev sets."""
# There are two types of labels. They should be normalized
def normalize(truth):
if truth in "ABCD":
return ord(truth) - ord("A")
elif truth in "1234":
... | [
"def",
"_create_examples",
"(",
"self",
",",
"lines",
",",
"type",
")",
":",
"# There are two types of labels. They should be normalized",
"def",
"normalize",
"(",
"truth",
")",
":",
"if",
"truth",
"in",
"\"ABCD\"",
":",
"return",
"ord",
"(",
"truth",
")",
"-",
... | [
442,
4
] | [
504,
23
] | python | en | ['en', 'en', 'en'] | True |
log_ha_config | (conf) | Log the returned config. | Log the returned config. | def log_ha_config(conf):
"""Log the returned config."""
cnt = 0
_LOGGER.debug("CONFIG - %s lines - %s errors", len(conf), len(conf.errors))
for key, val in conf.items():
_LOGGER.debug("#%s - %s: %s", cnt, key, val)
cnt += 1
for cnt, err in enumerate(conf.errors):
_LOGGER.debu... | [
"def",
"log_ha_config",
"(",
"conf",
")",
":",
"cnt",
"=",
"0",
"_LOGGER",
".",
"debug",
"(",
"\"CONFIG - %s lines - %s errors\"",
",",
"len",
"(",
"conf",
")",
",",
"len",
"(",
"conf",
".",
"errors",
")",
")",
"for",
"key",
",",
"val",
"in",
"conf",
... | [
28,
0
] | [
36,
49
] | python | en | ['en', 'da', 'en'] | True |
test_bad_core_config | (hass, loop) | Test a bad core config setup. | Test a bad core config setup. | async def test_bad_core_config(hass, loop):
"""Test a bad core config setup."""
files = {YAML_CONFIG_FILE: BAD_CORE_CONFIG}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
log_ha_config(res)
assert isinstance(res... | [
"async",
"def",
"test_bad_core_config",
"(",
"hass",
",",
"loop",
")",
":",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BAD_CORE_CONFIG",
"}",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"return_value",
"=",
"True",
")",
",",
"patch_yaml_files",
"(",
"fi... | [
39,
0
] | [
52,
29
] | python | en | ['en', 'st', 'en'] | True |
test_config_platform_valid | (hass, loop) | Test a valid platform setup. | Test a valid platform setup. | async def test_config_platform_valid(hass, loop):
"""Test a valid platform setup."""
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: demo"}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
log_ha_config(res)
... | [
"async",
"def",
"test_config_platform_valid",
"(",
"hass",
",",
"loop",
")",
":",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BASE_CONFIG",
"+",
"\"light:\\n platform: demo\"",
"}",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"return_value",
"=",
"True",
")... | [
55,
0
] | [
64,
29
] | python | en | ['en', 'da', 'en'] | True |
test_component_platform_not_found | (hass, loop) | Test errors if component or platform not found. | Test errors if component or platform not found. | async def test_component_platform_not_found(hass, loop):
"""Test errors if component or platform not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "beer:"}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_confi... | [
"async",
"def",
"test_component_platform_not_found",
"(",
"hass",
",",
"loop",
")",
":",
"# Make sure they don't exist",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BASE_CONFIG",
"+",
"\"beer:\"",
"}",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"return_value",
... | [
67,
0
] | [
82,
29
] | python | en | ['en', 'en', 'en'] | True |
test_component_platform_not_found_2 | (hass, loop) | Test errors if component or platform not found. | Test errors if component or platform not found. | async def test_component_platform_not_found_2(hass, loop):
"""Test errors if component or platform not found."""
# Make sure they don't exist
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await... | [
"async",
"def",
"test_component_platform_not_found_2",
"(",
"hass",
",",
"loop",
")",
":",
"# Make sure they don't exist",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BASE_CONFIG",
"+",
"\"light:\\n platform: beer\"",
"}",
"with",
"patch",
"(",
"\"os.path.isfile\"",
"... | [
85,
0
] | [
102,
29
] | python | en | ['en', 'en', 'en'] | True |
test_package_invalid | (hass, loop) | Test a valid platform setup. | Test a valid platform setup. | async def test_package_invalid(hass, loop):
"""Test a valid platform setup."""
files = {
YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]')
}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass... | [
"async",
"def",
"test_package_invalid",
"(",
"hass",
",",
"loop",
")",
":",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BASE_CONFIG",
"+",
"(",
"\" packages:\\n p1:\\n\"",
"' group: [\"a\"]'",
")",
"}",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"r... | [
105,
0
] | [
120,
46
] | python | en | ['en', 'da', 'en'] | True |
test_bootstrap_error | (hass, loop) | Test a valid platform setup. | Test a valid platform setup. | async def test_bootstrap_error(hass, loop):
"""Test a valid platform setup."""
files = {YAML_CONFIG_FILE: BASE_CONFIG + "automation: !include no.yaml"}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
log_ha_config(res)
... | [
"async",
"def",
"test_bootstrap_error",
"(",
"hass",
",",
"loop",
")",
":",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BASE_CONFIG",
"+",
"\"automation: !include no.yaml\"",
"}",
"with",
"patch",
"(",
"\"os.path.isfile\"",
",",
"return_value",
"=",
"True",
")",
... | [
123,
0
] | [
134,
29
] | python | en | ['en', 'da', 'en'] | True |
test_automation_config_platform | (hass) | Test automation async config. | Test automation async config. | async def test_automation_config_platform(hass):
"""Test automation async config."""
files = {
YAML_CONFIG_FILE: BASE_CONFIG
+ """
automation:
use_blueprint:
path: test_event_service.yaml
input:
trigger_event: blueprint_event
service_to_call: test.automation
""",
ha... | [
"async",
"def",
"test_automation_config_platform",
"(",
"hass",
")",
":",
"files",
"=",
"{",
"YAML_CONFIG_FILE",
":",
"BASE_CONFIG",
"+",
"\"\"\"\nautomation:\n use_blueprint:\n path: test_event_service.yaml\n input:\n trigger_event: blueprint_event\n service_to_call: te... | [
137,
0
] | [
167,
42
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the WSDOT sensor. | Set up the WSDOT sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the WSDOT sensor."""
sensors = []
for travel_time in config.get(CONF_TRAVEL_TIMES):
name = travel_time.get(CONF_NAME) or travel_time.get(CONF_ID)
sensors.append(
WashingtonStateTravelTimeSensor(
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"travel_time",
"in",
"config",
".",
"get",
"(",
"CONF_TRAVEL_TIMES",
")",
":",
"name",
"=",
"travel_tim... | [
53,
0
] | [
64,
31
] | python | en | ['en', 'su', 'en'] | True |
_parse_wsdot_timestamp | (timestamp) | Convert WSDOT timestamp to datetime. | Convert WSDOT timestamp to datetime. | def _parse_wsdot_timestamp(timestamp):
"""Convert WSDOT timestamp to datetime."""
if not timestamp:
return None
# ex: Date(1485040200000-0800)
milliseconds, tzone = re.search(r"Date\((\d+)([+-]\d\d)\d\d\)", timestamp).groups()
return datetime.fromtimestamp(
int(milliseconds) / 1000, ... | [
"def",
"_parse_wsdot_timestamp",
"(",
"timestamp",
")",
":",
"if",
"not",
"timestamp",
":",
"return",
"None",
"# ex: Date(1485040200000-0800)",
"milliseconds",
",",
"tzone",
"=",
"re",
".",
"search",
"(",
"r\"Date\\((\\d+)([+-]\\d\\d)\\d\\d\\)\"",
",",
"timestamp",
")... | [
144,
0
] | [
152,
5
] | python | cs | ['it', 'cs', 'en'] | False |
WashingtonStateTransportSensor.__init__ | (self, name, access_code) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, access_code):
"""Initialize the sensor."""
self._data = {}
self._access_code = access_code
self._name = name
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"access_code",
")",
":",
"self",
".",
"_data",
"=",
"{",
"}",
"self",
".",
"_access_code",
"=",
"access_code",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None"
] | [
76,
4
] | [
81,
26
] | python | en | ['en', 'en', 'en'] | True |
WashingtonStateTransportSensor.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"
] | [
84,
4
] | [
86,
25
] | python | en | ['en', 'mi', 'en'] | True |
WashingtonStateTransportSensor.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"
] | [
89,
4
] | [
91,
26
] | python | en | ['en', 'en', 'en'] | True |
WashingtonStateTransportSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
94,
4
] | [
96,
19
] | python | en | ['en', 'en', 'en'] | True |
WashingtonStateTravelTimeSensor.__init__ | (self, name, access_code, travel_time_id) | Construct a travel time sensor. | Construct a travel time sensor. | def __init__(self, name, access_code, travel_time_id):
"""Construct a travel time sensor."""
self._travel_time_id = travel_time_id
WashingtonStateTransportSensor.__init__(self, name, access_code) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"access_code",
",",
"travel_time_id",
")",
":",
"self",
".",
"_travel_time_id",
"=",
"travel_time_id",
"WashingtonStateTransportSensor",
".",
"__init__",
"(",
"self",
",",
"name",
",",
"access_code",
")"
] | [
102,
4
] | [
105,
72
] | python | en | ['es', 'pt', 'en'] | False |
WashingtonStateTravelTimeSensor.update | (self) | Get the latest data from WSDOT. | Get the latest data from WSDOT. | def update(self):
"""Get the latest data from WSDOT."""
params = {
ATTR_ACCESS_CODE: self._access_code,
ATTR_TRAVEL_TIME_ID: self._travel_time_id,
}
response = requests.get(RESOURCE, params, timeout=10)
if response.status_code != HTTP_OK:
_LOG... | [
"def",
"update",
"(",
"self",
")",
":",
"params",
"=",
"{",
"ATTR_ACCESS_CODE",
":",
"self",
".",
"_access_code",
",",
"ATTR_TRAVEL_TIME_ID",
":",
"self",
".",
"_travel_time_id",
",",
"}",
"response",
"=",
"requests",
".",
"get",
"(",
"RESOURCE",
",",
"par... | [
107,
4
] | [
119,
55
] | python | en | ['en', 'en', 'en'] | True |
WashingtonStateTravelTimeSensor.device_state_attributes | (self) | Return other details about the sensor state. | Return other details about the sensor state. | def device_state_attributes(self):
"""Return other details about the sensor state."""
if self._data is not None:
attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
for key in [
ATTR_AVG_TIME,
ATTR_NAME,
ATTR_DESCRIPTION,
ATTR_T... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
":",
"attrs",
"=",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}",
"for",
"key",
"in",
"[",
"ATTR_AVG_TIME",
",",
"ATTR_NAME",
",",
"ATTR_DESCRIPTION"... | [
122,
4
] | [
136,
24
] | python | en | ['en', 'en', 'en'] | True |
WashingtonStateTravelTimeSensor.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):
"""Return the unit this state is expressed in."""
return TIME_MINUTES | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"TIME_MINUTES"
] | [
139,
4
] | [
141,
27
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the ephember thermostat. | Set up the ephember thermostat. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the ephember thermostat."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
try:
ember = EphEmber(username, password)
zones = ember.get_zones()
for zone in zones:
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"username",
"=",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"try... | [
55,
0
] | [
69,
10
] | python | en | ['en', 'zu', 'en'] | True |
EphEmberThermostat.__init__ | (self, ember, zone) | Initialize the thermostat. | Initialize the thermostat. | def __init__(self, ember, zone):
"""Initialize the thermostat."""
self._ember = ember
self._zone_name = zone_name(zone)
self._zone = zone
self._hot_water = zone_is_hot_water(zone) | [
"def",
"__init__",
"(",
"self",
",",
"ember",
",",
"zone",
")",
":",
"self",
".",
"_ember",
"=",
"ember",
"self",
".",
"_zone_name",
"=",
"zone_name",
"(",
"zone",
")",
"self",
".",
"_zone",
"=",
"zone",
"self",
".",
"_hot_water",
"=",
"zone_is_hot_wat... | [
75,
4
] | [
80,
49
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
if self._hot_water:
return SUPPORT_AUX_HEAT
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_AUX_HEAT | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hot_water",
":",
"return",
"SUPPORT_AUX_HEAT",
"return",
"SUPPORT_TARGET_TEMPERATURE",
"|",
"SUPPORT_AUX_HEAT"
] | [
83,
4
] | [
88,
60
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.name | (self) | Return the name of the thermostat, if any. | Return the name of the thermostat, if any. | def name(self):
"""Return the name of the thermostat, if any."""
return self._zone_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_zone_name"
] | [
91,
4
] | [
93,
30
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.temperature_unit | (self) | Return the unit of measurement which this thermostat uses. | Return the unit of measurement which this thermostat uses. | def temperature_unit(self):
"""Return the unit of measurement which this thermostat uses."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"TEMP_CELSIUS"
] | [
96,
4
] | [
98,
27
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self):
"""Return the current temperature."""
return zone_current_temperature(self._zone) | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"return",
"zone_current_temperature",
"(",
"self",
".",
"_zone",
")"
] | [
101,
4
] | [
103,
51
] | python | en | ['en', 'la', 'en'] | True |
EphEmberThermostat.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
return zone_target_temperature(self._zone) | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"return",
"zone_target_temperature",
"(",
"self",
".",
"_zone",
")"
] | [
106,
4
] | [
108,
50
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.target_temperature_step | (self) | Return the supported step of target temperature. | Return the supported step of target temperature. | def target_temperature_step(self):
"""Return the supported step of target temperature."""
if self._hot_water:
return None
return 0.5 | [
"def",
"target_temperature_step",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hot_water",
":",
"return",
"None",
"return",
"0.5"
] | [
111,
4
] | [
116,
18
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.hvac_action | (self) | Return current HVAC action. | Return current HVAC action. | def hvac_action(self):
"""Return current HVAC action."""
if zone_is_active(self._zone):
return CURRENT_HVAC_HEAT
return CURRENT_HVAC_IDLE | [
"def",
"hvac_action",
"(",
"self",
")",
":",
"if",
"zone_is_active",
"(",
"self",
".",
"_zone",
")",
":",
"return",
"CURRENT_HVAC_HEAT",
"return",
"CURRENT_HVAC_IDLE"
] | [
119,
4
] | [
124,
32
] | python | en | ['en', 'da', 'en'] | True |
EphEmberThermostat.hvac_mode | (self) | Return current operation ie. heat, cool, idle. | Return current operation ie. heat, cool, idle. | def hvac_mode(self):
"""Return current operation ie. heat, cool, idle."""
mode = zone_mode(self._zone)
return self.map_mode_eph_hass(mode) | [
"def",
"hvac_mode",
"(",
"self",
")",
":",
"mode",
"=",
"zone_mode",
"(",
"self",
".",
"_zone",
")",
"return",
"self",
".",
"map_mode_eph_hass",
"(",
"mode",
")"
] | [
127,
4
] | [
130,
43
] | python | en | ['nl', 'en', 'en'] | True |
EphEmberThermostat.hvac_modes | (self) | Return the supported operations. | Return the supported operations. | def hvac_modes(self):
"""Return the supported operations."""
return OPERATION_LIST | [
"def",
"hvac_modes",
"(",
"self",
")",
":",
"return",
"OPERATION_LIST"
] | [
133,
4
] | [
135,
29
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.set_hvac_mode | (self, hvac_mode) | Set the operation mode. | Set the operation mode. | def set_hvac_mode(self, hvac_mode):
"""Set the operation mode."""
mode = self.map_mode_hass_eph(hvac_mode)
if mode is not None:
self._ember.set_mode_by_name(self._zone_name, mode)
else:
_LOGGER.error("Invalid operation mode provided %s", hvac_mode) | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"mode",
"=",
"self",
".",
"map_mode_hass_eph",
"(",
"hvac_mode",
")",
"if",
"mode",
"is",
"not",
"None",
":",
"self",
".",
"_ember",
".",
"set_mode_by_name",
"(",
"self",
".",
"_zone_name",
... | [
137,
4
] | [
143,
74
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.is_aux_heat | (self) | Return true if aux heater. | Return true if aux heater. | def is_aux_heat(self):
"""Return true if aux heater."""
return zone_is_boost_active(self._zone) | [
"def",
"is_aux_heat",
"(",
"self",
")",
":",
"return",
"zone_is_boost_active",
"(",
"self",
".",
"_zone",
")"
] | [
146,
4
] | [
149,
47
] | python | fr | ['fr', 'co', 'fr'] | True |
EphEmberThermostat.turn_aux_heat_on | (self) | Turn auxiliary heater on. | Turn auxiliary heater on. | def turn_aux_heat_on(self):
"""Turn auxiliary heater on."""
self._ember.activate_boost_by_name(
self._zone_name, zone_target_temperature(self._zone)
) | [
"def",
"turn_aux_heat_on",
"(",
"self",
")",
":",
"self",
".",
"_ember",
".",
"activate_boost_by_name",
"(",
"self",
".",
"_zone_name",
",",
"zone_target_temperature",
"(",
"self",
".",
"_zone",
")",
")"
] | [
151,
4
] | [
155,
9
] | python | en | ['fr', 'fi', 'en'] | False |
EphEmberThermostat.turn_aux_heat_off | (self) | Turn auxiliary heater off. | Turn auxiliary heater off. | def turn_aux_heat_off(self):
"""Turn auxiliary heater off."""
self._ember.deactivate_boost_by_name(self._zone_name) | [
"def",
"turn_aux_heat_off",
"(",
"self",
")",
":",
"self",
".",
"_ember",
".",
"deactivate_boost_by_name",
"(",
"self",
".",
"_zone_name",
")"
] | [
157,
4
] | [
159,
61
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.set_temperature | (self, **kwargs) | Set new target temperature. | Set new target temperature. | def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
if self._hot_water:
return
if temperature == self.target_temperature:
return
if temperat... | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"if",
"temperature",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_hot_water",
":",
"return",
"if",
"tem... | [
161,
4
] | [
176,
79
] | python | en | ['en', 'ca', 'en'] | True |
EphEmberThermostat.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self):
"""Return the minimum temperature."""
# Hot water temp doesn't support being changed
if self._hot_water:
return zone_target_temperature(self._zone)
return 5.0 | [
"def",
"min_temp",
"(",
"self",
")",
":",
"# Hot water temp doesn't support being changed",
"if",
"self",
".",
"_hot_water",
":",
"return",
"zone_target_temperature",
"(",
"self",
".",
"_zone",
")",
"return",
"5.0"
] | [
179,
4
] | [
185,
18
] | python | en | ['en', 'la', 'en'] | True |
EphEmberThermostat.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self):
"""Return the maximum temperature."""
if self._hot_water:
return zone_target_temperature(self._zone)
return 35.0 | [
"def",
"max_temp",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hot_water",
":",
"return",
"zone_target_temperature",
"(",
"self",
".",
"_zone",
")",
"return",
"35.0"
] | [
188,
4
] | [
193,
19
] | python | en | ['en', 'la', 'en'] | True |
EphEmberThermostat.update | (self) | Get the latest data. | Get the latest data. | def update(self):
"""Get the latest data."""
self._zone = self._ember.get_zone(self._zone_name) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_zone",
"=",
"self",
".",
"_ember",
".",
"get_zone",
"(",
"self",
".",
"_zone_name",
")"
] | [
195,
4
] | [
197,
58
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.map_mode_hass_eph | (operation_mode) | Map from Home Assistant mode to eph mode. | Map from Home Assistant mode to eph mode. | def map_mode_hass_eph(operation_mode):
"""Map from Home Assistant mode to eph mode."""
return getattr(ZoneMode, HA_STATE_TO_EPH.get(operation_mode), None) | [
"def",
"map_mode_hass_eph",
"(",
"operation_mode",
")",
":",
"return",
"getattr",
"(",
"ZoneMode",
",",
"HA_STATE_TO_EPH",
".",
"get",
"(",
"operation_mode",
")",
",",
"None",
")"
] | [
200,
4
] | [
202,
75
] | python | en | ['en', 'en', 'en'] | True |
EphEmberThermostat.map_mode_eph_hass | (operation_mode) | Map from eph mode to Home Assistant mode. | Map from eph mode to Home Assistant mode. | def map_mode_eph_hass(operation_mode):
"""Map from eph mode to Home Assistant mode."""
return EPH_TO_HA_STATE.get(operation_mode.name, HVAC_MODE_HEAT_COOL) | [
"def",
"map_mode_eph_hass",
"(",
"operation_mode",
")",
":",
"return",
"EPH_TO_HA_STATE",
".",
"get",
"(",
"operation_mode",
".",
"name",
",",
"HVAC_MODE_HEAT_COOL",
")"
] | [
205,
4
] | [
207,
76
] | python | en | ['en', 'en', 'en'] | True |
HfArgumentParserTest.argparsersEqual | (self, a: argparse.ArgumentParser, b: argparse.ArgumentParser) |
Small helper to check pseudo-equality of parsed arguments on `ArgumentParser` instances.
|
Small helper to check pseudo-equality of parsed arguments on `ArgumentParser` instances.
| def argparsersEqual(self, a: argparse.ArgumentParser, b: argparse.ArgumentParser) -> bool:
"""
Small helper to check pseudo-equality of parsed arguments on `ArgumentParser` instances.
"""
self.assertEqual(len(a._actions), len(b._actions))
for x, y in zip(a._actions, b._actions):
... | [
"def",
"argparsersEqual",
"(",
"self",
",",
"a",
":",
"argparse",
".",
"ArgumentParser",
",",
"b",
":",
"argparse",
".",
"ArgumentParser",
")",
"->",
"bool",
":",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"a",
".",
"_actions",
")",
",",
"len",
"(",
... | [
91,
4
] | [
99,
36
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up our socket to the AVR. | Set up our socket to the AVR. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up our socket to the AVR."""
host = config[CONF_HOST]
port = config[CONF_PORT]
name = config.get(CONF_NAME)
device = None
_LOGGER.info("Provisioning Anthem AVR device at %s:%d", host, port)
@call... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"port",
"=",
"config",
"[",
"CONF_PORT",
"]",
"name",
"=",
"config",
... | [
52,
0
] | [
78,
32
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.__init__ | (self, avr, name) | Initialize entity with transport. | Initialize entity with transport. | def __init__(self, avr, name):
"""Initialize entity with transport."""
super().__init__()
self.avr = avr
self._name = name | [
"def",
"__init__",
"(",
"self",
",",
"avr",
",",
"name",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"avr",
"=",
"avr",
"self",
".",
"_name",
"=",
"name"
] | [
84,
4
] | [
88,
25
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.async_added_to_hass | (self) | When entity is added to hass. | When entity is added to hass. | async def async_added_to_hass(self):
"""When entity is added to hass."""
self.async_on_remove(
async_dispatcher_connect(self.hass, DOMAIN, self.async_write_ha_state)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DOMAIN",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
93,
4
] | [
97,
9
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_ANTHEMAV | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_ANTHEMAV"
] | [
100,
4
] | [
102,
31
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
105,
4
] | [
107,
20
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.name | (self) | Return name of device. | Return name of device. | def name(self):
"""Return name of device."""
return self._name or self._lookup("model") | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name",
"or",
"self",
".",
"_lookup",
"(",
"\"model\"",
")"
] | [
110,
4
] | [
112,
50
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.state | (self) | Return state of power on/off. | Return state of power on/off. | def state(self):
"""Return state of power on/off."""
pwrstate = self._lookup("power")
if pwrstate is True:
return STATE_ON
if pwrstate is False:
return STATE_OFF
return None | [
"def",
"state",
"(",
"self",
")",
":",
"pwrstate",
"=",
"self",
".",
"_lookup",
"(",
"\"power\"",
")",
"if",
"pwrstate",
"is",
"True",
":",
"return",
"STATE_ON",
"if",
"pwrstate",
"is",
"False",
":",
"return",
"STATE_OFF",
"return",
"None"
] | [
115,
4
] | [
123,
19
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.is_volume_muted | (self) | Return boolean reflecting mute state on device. | Return boolean reflecting mute state on device. | def is_volume_muted(self):
"""Return boolean reflecting mute state on device."""
return self._lookup("mute", False) | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lookup",
"(",
"\"mute\"",
",",
"False",
")"
] | [
126,
4
] | [
128,
42
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.volume_level | (self) | Return volume level from 0 to 1. | Return volume level from 0 to 1. | def volume_level(self):
"""Return volume level from 0 to 1."""
return self._lookup("volume_as_percentage", 0.0) | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lookup",
"(",
"\"volume_as_percentage\"",
",",
"0.0",
")"
] | [
131,
4
] | [
133,
56
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.media_title | (self) | Return current input name (closest we have to media title). | Return current input name (closest we have to media title). | def media_title(self):
"""Return current input name (closest we have to media title)."""
return self._lookup("input_name", "No Source") | [
"def",
"media_title",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lookup",
"(",
"\"input_name\"",
",",
"\"No Source\"",
")"
] | [
136,
4
] | [
138,
54
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.app_name | (self) | Return details about current video and audio stream. | Return details about current video and audio stream. | def app_name(self):
"""Return details about current video and audio stream."""
return (
f"{self._lookup('video_input_resolution_text', '')} "
f"{self._lookup('audio_input_name', '')}"
) | [
"def",
"app_name",
"(",
"self",
")",
":",
"return",
"(",
"f\"{self._lookup('video_input_resolution_text', '')} \"",
"f\"{self._lookup('audio_input_name', '')}\"",
")"
] | [
141,
4
] | [
146,
9
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.source | (self) | Return currently selected input. | Return currently selected input. | def source(self):
"""Return currently selected input."""
return self._lookup("input_name", "Unknown") | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lookup",
"(",
"\"input_name\"",
",",
"\"Unknown\"",
")"
] | [
149,
4
] | [
151,
52
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.source_list | (self) | Return all active, configured inputs. | Return all active, configured inputs. | def source_list(self):
"""Return all active, configured inputs."""
return self._lookup("input_list", ["Unknown"]) | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lookup",
"(",
"\"input_list\"",
",",
"[",
"\"Unknown\"",
"]",
")"
] | [
154,
4
] | [
156,
54
] | python | en | ['en', 'nl', 'en'] | True |
AnthemAVR.async_select_source | (self, source) | Change AVR to the designated source (by name). | Change AVR to the designated source (by name). | async def async_select_source(self, source):
"""Change AVR to the designated source (by name)."""
self._update_avr("input_name", source) | [
"async",
"def",
"async_select_source",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"_update_avr",
"(",
"\"input_name\"",
",",
"source",
")"
] | [
158,
4
] | [
160,
46
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.async_turn_off | (self) | Turn AVR power off. | Turn AVR power off. | async def async_turn_off(self):
"""Turn AVR power off."""
self._update_avr("power", False) | [
"async",
"def",
"async_turn_off",
"(",
"self",
")",
":",
"self",
".",
"_update_avr",
"(",
"\"power\"",
",",
"False",
")"
] | [
162,
4
] | [
164,
40
] | python | en | ['en', 'kk', 'en'] | True |
AnthemAVR.async_turn_on | (self) | Turn AVR power on. | Turn AVR power on. | async def async_turn_on(self):
"""Turn AVR power on."""
self._update_avr("power", True) | [
"async",
"def",
"async_turn_on",
"(",
"self",
")",
":",
"self",
".",
"_update_avr",
"(",
"\"power\"",
",",
"True",
")"
] | [
166,
4
] | [
168,
39
] | python | en | ['en', 'no', 'en'] | True |
AnthemAVR.async_set_volume_level | (self, volume) | Set AVR volume (0 to 1). | Set AVR volume (0 to 1). | async def async_set_volume_level(self, volume):
"""Set AVR volume (0 to 1)."""
self._update_avr("volume_as_percentage", volume) | [
"async",
"def",
"async_set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"self",
".",
"_update_avr",
"(",
"\"volume_as_percentage\"",
",",
"volume",
")"
] | [
170,
4
] | [
172,
56
] | python | en | ['en', 'ru-Latn', 'en'] | True |
AnthemAVR.async_mute_volume | (self, mute) | Engage AVR mute. | Engage AVR mute. | async def async_mute_volume(self, mute):
"""Engage AVR mute."""
self._update_avr("mute", mute) | [
"async",
"def",
"async_mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"self",
".",
"_update_avr",
"(",
"\"mute\"",
",",
"mute",
")"
] | [
174,
4
] | [
176,
38
] | python | en | ['en', 'ky', 'it'] | False |
AnthemAVR._update_avr | (self, propname, value) | Update a property in the AVR. | Update a property in the AVR. | def _update_avr(self, propname, value):
"""Update a property in the AVR."""
_LOGGER.info("Sending command to AVR: set %s to %s", propname, str(value))
setattr(self.avr.protocol, propname, value) | [
"def",
"_update_avr",
"(",
"self",
",",
"propname",
",",
"value",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Sending command to AVR: set %s to %s\"",
",",
"propname",
",",
"str",
"(",
"value",
")",
")",
"setattr",
"(",
"self",
".",
"avr",
".",
"protocol",
"... | [
178,
4
] | [
181,
51
] | python | en | ['en', 'en', 'en'] | True |
AnthemAVR.dump_avrdata | (self) | Return state of avr object for debugging forensics. | Return state of avr object for debugging forensics. | def dump_avrdata(self):
"""Return state of avr object for debugging forensics."""
attrs = vars(self)
items_string = ", ".join(f"{item}: {item}" for item in attrs.items())
return f"dump_avrdata: {items_string}" | [
"def",
"dump_avrdata",
"(",
"self",
")",
":",
"attrs",
"=",
"vars",
"(",
"self",
")",
"items_string",
"=",
"\", \"",
".",
"join",
"(",
"f\"{item}: {item}\"",
"for",
"item",
"in",
"attrs",
".",
"items",
"(",
")",
")",
"return",
"f\"dump_avrdata: {items_string... | [
184,
4
] | [
188,
46
] | python | en | ['en', 'en', 'en'] | True |
test_lock_unlock | (hass, hk_driver, events) | Test if accessory and HA are updated accordingly. | Test if accessory and HA are updated accordingly. | async def test_lock_unlock(hass, hk_driver, events):
"""Test if accessory and HA are updated accordingly."""
code = "1234"
config = {ATTR_CODE: code}
entity_id = "lock.kitchen_door"
hass.states.async_set(entity_id, None)
await hass.async_block_till_done()
acc = Lock(hass, hk_driver, "Lock",... | [
"async",
"def",
"test_lock_unlock",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"code",
"=",
"\"1234\"",
"config",
"=",
"{",
"ATTR_CODE",
":",
"code",
"}",
"entity_id",
"=",
"\"lock.kitchen_door\"",
"hass",
".",
"states",
".",
"async_set",
"(",
... | [
17,
0
] | [
74,
46
] | python | en | ['en', 'en', 'en'] | True |
test_no_code | (hass, hk_driver, config, events) | Test accessory if lock doesn't require a code. | Test accessory if lock doesn't require a code. | async def test_no_code(hass, hk_driver, config, events):
"""Test accessory if lock doesn't require a code."""
entity_id = "lock.kitchen_door"
hass.states.async_set(entity_id, None)
await hass.async_block_till_done()
acc = Lock(hass, hk_driver, "Lock", entity_id, 2, config)
# Set from HomeKit
... | [
"async",
"def",
"test_no_code",
"(",
"hass",
",",
"hk_driver",
",",
"config",
",",
"events",
")",
":",
"entity_id",
"=",
"\"lock.kitchen_door\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"None",
")",
"await",
"hass",
".",
"async_block_... | [
78,
0
] | [
96,
46
] | python | en | ['en', 'en', 'en'] | True |
ResourceYAMLCollection.__init__ | (self, data) | Initialize a resource YAML collection. | Initialize a resource YAML collection. | def __init__(self, data):
"""Initialize a resource YAML collection."""
self.data = data | [
"def",
"__init__",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"data",
"=",
"data"
] | [
32,
4
] | [
34,
24
] | python | en | ['en', 'en', 'en'] | True |
ResourceYAMLCollection.async_get_info | (self) | Return the resources info for YAML mode. | Return the resources info for YAML mode. | async def async_get_info(self):
"""Return the resources info for YAML mode."""
return {"resources": len(self.async_items() or [])} | [
"async",
"def",
"async_get_info",
"(",
"self",
")",
":",
"return",
"{",
"\"resources\"",
":",
"len",
"(",
"self",
".",
"async_items",
"(",
")",
"or",
"[",
"]",
")",
"}"
] | [
36,
4
] | [
38,
59
] | python | en | ['en', 'en', 'en'] | True |
ResourceYAMLCollection.async_items | (self) | Return list of items in collection. | Return list of items in collection. | def async_items(self) -> List[dict]:
"""Return list of items in collection."""
return self.data | [
"def",
"async_items",
"(",
"self",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"return",
"self",
".",
"data"
] | [
41,
4
] | [
43,
24
] | python | en | ['en', 'en', 'en'] | True |
ResourceStorageCollection.__init__ | (self, hass: HomeAssistant, ll_config: LovelaceConfig) | Initialize the storage collection. | Initialize the storage collection. | def __init__(self, hass: HomeAssistant, ll_config: LovelaceConfig):
"""Initialize the storage collection."""
super().__init__(
storage.Store(hass, RESOURCES_STORAGE_VERSION, RESOURCE_STORAGE_KEY),
_LOGGER,
)
self.ll_config = ll_config | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"ll_config",
":",
"LovelaceConfig",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"storage",
".",
"Store",
"(",
"hass",
",",
"RESOURCES_STORAGE_VERSION",
",",
"RESOURCE_STORAGE_KEY",
... | [
53,
4
] | [
59,
34
] | python | en | ['en', 'en', 'en'] | True |
ResourceStorageCollection.async_get_info | (self) | Return the resources info for YAML mode. | Return the resources info for YAML mode. | async def async_get_info(self):
"""Return the resources info for YAML mode."""
if not self.loaded:
await self.async_load()
self.loaded = True
return {"resources": len(self.async_items() or [])} | [
"async",
"def",
"async_get_info",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"loaded",
":",
"await",
"self",
".",
"async_load",
"(",
")",
"self",
".",
"loaded",
"=",
"True",
"return",
"{",
"\"resources\"",
":",
"len",
"(",
"self",
".",
"async_ite... | [
61,
4
] | [
67,
59
] | python | en | ['en', 'en', 'en'] | True |
ResourceStorageCollection._async_load_data | (self) | Load the data. | Load the data. | async def _async_load_data(self) -> Optional[dict]:
"""Load the data."""
data = await self.store.async_load()
if data is not None:
return cast(Optional[dict], data)
# Import it from config.
try:
conf = await self.ll_config.async_load(False)
excep... | [
"async",
"def",
"_async_load_data",
"(",
"self",
")",
"->",
"Optional",
"[",
"dict",
"]",
":",
"data",
"=",
"await",
"self",
".",
"store",
".",
"async_load",
"(",
")",
"if",
"data",
"is",
"not",
"None",
":",
"return",
"cast",
"(",
"Optional",
"[",
"d... | [
69,
4
] | [
104,
19
] | python | en | ['en', 'en', 'en'] | True |
ResourceStorageCollection._process_create_data | (self, data: dict) | Validate the config is valid. | Validate the config is valid. | async def _process_create_data(self, data: dict) -> dict:
"""Validate the config is valid."""
data = self.CREATE_SCHEMA(data)
data[CONF_TYPE] = data.pop(CONF_RESOURCE_TYPE_WS)
return data | [
"async",
"def",
"_process_create_data",
"(",
"self",
",",
"data",
":",
"dict",
")",
"->",
"dict",
":",
"data",
"=",
"self",
".",
"CREATE_SCHEMA",
"(",
"data",
")",
"data",
"[",
"CONF_TYPE",
"]",
"=",
"data",
".",
"pop",
"(",
"CONF_RESOURCE_TYPE_WS",
")",... | [
106,
4
] | [
110,
19
] | python | en | ['en', 'en', 'en'] | True |
ResourceStorageCollection._get_suggested_id | (self, info: dict) | Return unique ID. | Return unique ID. | def _get_suggested_id(self, info: dict) -> str:
"""Return unique ID."""
return uuid.uuid4().hex | [
"def",
"_get_suggested_id",
"(",
"self",
",",
"info",
":",
"dict",
")",
"->",
"str",
":",
"return",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex"
] | [
113,
4
] | [
115,
31
] | python | en | ['fr', 'la', 'en'] | False |
ResourceStorageCollection._update_data | (self, data: dict, update_data: dict) | Return a new updated data object. | Return a new updated data object. | async def _update_data(self, data: dict, update_data: dict) -> dict:
"""Return a new updated data object."""
if not self.loaded:
await self.async_load()
self.loaded = True
update_data = self.UPDATE_SCHEMA(update_data)
if CONF_RESOURCE_TYPE_WS in update_data:
... | [
"async",
"def",
"_update_data",
"(",
"self",
",",
"data",
":",
"dict",
",",
"update_data",
":",
"dict",
")",
"->",
"dict",
":",
"if",
"not",
"self",
".",
"loaded",
":",
"await",
"self",
".",
"async_load",
"(",
")",
"self",
".",
"loaded",
"=",
"True",... | [
117,
4
] | [
127,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the UPB light based on a config entry. | Set up the UPB light based on a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the UPB light based on a config entry."""
upb = hass.data[DOMAIN][config_entry.entry_id]["upb"]
unique_id = config_entry.entry_id
async_add_entities(
UpbLight(upb.devices[dev], unique_id, upb) for dev in upb.devices
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"upb",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"\"upb\"",
"]",
"unique_id",
"=",
"config_entry",... | [
20,
0
] | [
39,
5
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.