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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
zone | (
hass: HomeAssistant,
zone_ent: None | str | State,
entity: None | str | State,
) | Test if zone-condition matches.
Async friendly.
| Test if zone-condition matches. | def zone(
hass: HomeAssistant,
zone_ent: None | str | State,
entity: None | str | State,
) -> bool:
"""Test if zone-condition matches.
Async friendly.
"""
if zone_ent is None:
raise ConditionErrorMessage("zone", "no zone specified")
if isinstance(zone_ent, str):
zone_en... | [
"def",
"zone",
"(",
"hass",
":",
"HomeAssistant",
",",
"zone_ent",
":",
"None",
"|",
"str",
"|",
"State",
",",
"entity",
":",
"None",
"|",
"str",
"|",
"State",
",",
")",
"->",
"bool",
":",
"if",
"zone_ent",
"is",
"None",
":",
"raise",
"ConditionError... | [
828,
0
] | [
874,
5
] | python | en | ['nl', 'en', 'en'] | True |
zone_from_config | (
config: ConfigType, config_validation: bool = True
) | Wrap action method with zone based condition. | Wrap action method with zone based condition. | def zone_from_config(
config: ConfigType, config_validation: bool = True
) -> ConditionCheckerType:
"""Wrap action method with zone based condition."""
if config_validation:
config = cv.ZONE_CONDITION_SCHEMA(config)
entity_ids = config.get(CONF_ENTITY_ID, [])
zone_entity_ids = config.get(CON... | [
"def",
"zone_from_config",
"(",
"config",
":",
"ConfigType",
",",
"config_validation",
":",
"bool",
"=",
"True",
")",
"->",
"ConditionCheckerType",
":",
"if",
"config_validation",
":",
"config",
"=",
"cv",
".",
"ZONE_CONDITION_SCHEMA",
"(",
"config",
")",
"entit... | [
877,
0
] | [
915,
21
] | python | en | ['en', 'en', 'en'] | True |
async_device_from_config | (
hass: HomeAssistant, config: ConfigType, config_validation: bool = True
) | Test a device condition. | Test a device condition. | async def async_device_from_config(
hass: HomeAssistant, config: ConfigType, config_validation: bool = True
) -> ConditionCheckerType:
"""Test a device condition."""
if config_validation:
config = cv.DEVICE_CONDITION_SCHEMA(config)
platform = await async_get_device_automation_platform(
h... | [
"async",
"def",
"async_device_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"config_validation",
":",
"bool",
"=",
"True",
")",
"->",
"ConditionCheckerType",
":",
"if",
"config_validation",
":",
"config",
"=",
"cv",
".",... | [
918,
0
] | [
932,
5
] | python | en | ['es', 'en', 'en'] | True |
async_trigger_from_config | (
hass: HomeAssistant, config: ConfigType, config_validation: bool = True
) | Test a trigger condition. | Test a trigger condition. | async def async_trigger_from_config(
hass: HomeAssistant, config: ConfigType, config_validation: bool = True
) -> ConditionCheckerType:
"""Test a trigger condition."""
if config_validation:
config = cv.TRIGGER_CONDITION_SCHEMA(config)
trigger_id = config[CONF_ID]
@trace_condition_function
... | [
"async",
"def",
"async_trigger_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"config_validation",
":",
"bool",
"=",
"True",
")",
"->",
"ConditionCheckerType",
":",
"if",
"config_validation",
":",
"config",
"=",
"cv",
"."... | [
935,
0
] | [
952,
21
] | python | en | ['en', 'en', 'en'] | True |
async_validate_condition_config | (
hass: HomeAssistant, config: ConfigType | Template
) | Validate config. | Validate config. | async def async_validate_condition_config(
hass: HomeAssistant, config: ConfigType | Template
) -> ConfigType | Template:
"""Validate config."""
if isinstance(config, Template):
return config
condition = config[CONF_CONDITION]
if condition in ("and", "not", "or"):
conditions = []
... | [
"async",
"def",
"async_validate_condition_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
"|",
"Template",
")",
"->",
"ConfigType",
"|",
"Template",
":",
"if",
"isinstance",
"(",
"config",
",",
"Template",
")",
":",
"return",
"con... | [
955,
0
] | [
980,
17
] | python | en | ['en', 'la', 'it'] | False |
async_extract_entities | (config: ConfigType | Template) | Extract entities from a condition. | Extract entities from a condition. | def async_extract_entities(config: ConfigType | Template) -> set[str]:
"""Extract entities from a condition."""
referenced: set[str] = set()
to_process = deque([config])
while to_process:
config = to_process.popleft()
if isinstance(config, Template):
continue
condit... | [
"def",
"async_extract_entities",
"(",
"config",
":",
"ConfigType",
"|",
"Template",
")",
"->",
"set",
"[",
"str",
"]",
":",
"referenced",
":",
"set",
"[",
"str",
"]",
"=",
"set",
"(",
")",
"to_process",
"=",
"deque",
"(",
"[",
"config",
"]",
")",
"wh... | [
984,
0
] | [
1008,
21
] | python | en | ['en', 'en', 'en'] | True |
async_extract_devices | (config: ConfigType | Template) | Extract devices from a condition. | Extract devices from a condition. | def async_extract_devices(config: ConfigType | Template) -> set[str]:
"""Extract devices from a condition."""
referenced = set()
to_process = deque([config])
while to_process:
config = to_process.popleft()
if isinstance(config, Template):
continue
condition = config... | [
"def",
"async_extract_devices",
"(",
"config",
":",
"ConfigType",
"|",
"Template",
")",
"->",
"set",
"[",
"str",
"]",
":",
"referenced",
"=",
"set",
"(",
")",
"to_process",
"=",
"deque",
"(",
"[",
"config",
"]",
")",
"while",
"to_process",
":",
"config",... | [
1012,
0
] | [
1036,
21
] | python | en | ['en', 'en', 'en'] | True |
TestEnumClass.testEnumClass | (self) | Test EnumClass | Test EnumClass | def testEnumClass(self):
"""Test EnumClass"""
# FIXME: construct object with mandatory attributes with example values
# model = EnumClass() # noqa: E501
pass | [
"def",
"testEnumClass",
"(",
"self",
")",
":",
"# FIXME: construct object with mandatory attributes with example values",
"# model = EnumClass() # noqa: E501",
"pass"
] | [
29,
4
] | [
33,
12
] | python | en | ['en', 'fy', 'ur'] | False |
async_setup | (hass: HomeAssistant, config: ConfigType) | Plum Lightpad Platform initialization. | Plum Lightpad Platform initialization. | async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Plum Lightpad Platform initialization."""
if DOMAIN not in config:
return True
conf = config[DOMAIN]
_LOGGER.info("Found Plum Lightpad configuration in config, importing")
hass.async_create_task(
hass.config... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"_LOGGER",
".",
"info",
... | [
37,
0
] | [
51,
15
] | python | en | ['pt', 'lv', 'en'] | False |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Plum Lightpad from a config entry. | Set up Plum Lightpad from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Plum Lightpad from a config entry."""
_LOGGER.debug("Setting up config entry with ID = %s", entry.unique_id)
username = entry.data.get(CONF_USERNAME)
password = entry.data.get(CONF_PASSWORD)
try:
plum =... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Setting up config entry with ID = %s\"",
",",
"entry",
".",
"unique_id",
")",
"username",
"=",
"ent... | [
54,
0
] | [
83,
15
] | python | en | ['en', 'en', 'en'] | True |
test_significant_change | () | Detect Light significant changes. | Detect Light significant changes. | async def test_significant_change():
"""Detect Light significant changes."""
assert not async_check_significant_change(None, "on", {}, "on", {})
assert async_check_significant_change(None, "on", {}, "off", {})
# Brightness
assert not async_check_significant_change(
None, "on", {ATTR_BRIGHTN... | [
"async",
"def",
"test_significant_change",
"(",
")",
":",
"assert",
"not",
"async_check_significant_change",
"(",
"None",
",",
"\"on\"",
",",
"{",
"}",
",",
"\"on\"",
",",
"{",
"}",
")",
"assert",
"async_check_significant_change",
"(",
"None",
",",
"\"on\"",
"... | [
13,
0
] | [
69,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Vultr subscription switch. | Set up the Vultr subscription switch. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Vultr subscription switch."""
vultr = hass.data[DATA_VULTR]
subscription = config.get(CONF_SUBSCRIPTION)
name = config.get(CONF_NAME)
if subscription not in vultr.data:
_LOGGER.error("Subscription %s not fou... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"vultr",
"=",
"hass",
".",
"data",
"[",
"DATA_VULTR",
"]",
"subscription",
"=",
"config",
".",
"get",
"(",
"CONF_SUBSCRIPTION",
")",
"na... | [
38,
0
] | [
49,
64
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.__init__ | (self, vultr, subscription, name) | Initialize a new Vultr switch. | Initialize a new Vultr switch. | def __init__(self, vultr, subscription, name):
"""Initialize a new Vultr switch."""
self._vultr = vultr
self._name = name
self.subscription = subscription
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"vultr",
",",
"subscription",
",",
"name",
")",
":",
"self",
".",
"_vultr",
"=",
"vultr",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"subscription",
"=",
"subscription",
"self",
".",
"data",
"=",
"None"
] | [
55,
4
] | [
61,
24
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
try:
return self._name.format(self.data["label"])
except (TypeError, KeyError):
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_name",
".",
"format",
"(",
"self",
".",
"data",
"[",
"\"label\"",
"]",
")",
"except",
"(",
"TypeError",
",",
"KeyError",
")",
":",
"return",
"self",
".",
"_name"
] | [
64,
4
] | [
69,
29
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.is_on | (self) | Return true if switch is on. | Return true if switch is on. | def is_on(self):
"""Return true if switch is on."""
return self.data["power_status"] == "running" | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
"[",
"\"power_status\"",
"]",
"==",
"\"running\""
] | [
72,
4
] | [
74,
53
] | python | en | ['en', 'fy', 'en'] | True |
VultrSwitch.icon | (self) | Return the icon of this server. | Return the icon of this server. | def icon(self):
"""Return the icon of this server."""
return "mdi:server" if self.is_on else "mdi:server-off" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:server\"",
"if",
"self",
".",
"is_on",
"else",
"\"mdi:server-off\""
] | [
77,
4
] | [
79,
63
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.extra_state_attributes | (self) | Return the state attributes of the Vultr subscription. | Return the state attributes of the Vultr subscription. | def extra_state_attributes(self):
"""Return the state attributes of the Vultr subscription."""
return {
ATTR_ALLOWED_BANDWIDTH: self.data.get("allowed_bandwidth_gb"),
ATTR_AUTO_BACKUPS: self.data.get("auto_backups"),
ATTR_COST_PER_MONTH: self.data.get("cost_per_month"... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ALLOWED_BANDWIDTH",
":",
"self",
".",
"data",
".",
"get",
"(",
"\"allowed_bandwidth_gb\"",
")",
",",
"ATTR_AUTO_BACKUPS",
":",
"self",
".",
"data",
".",
"get",
"(",
"\"auto_backups\"",
... | [
82,
4
] | [
98,
9
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.turn_on | (self, **kwargs) | Boot-up the subscription. | Boot-up the subscription. | def turn_on(self, **kwargs):
"""Boot-up the subscription."""
if self.data["power_status"] != "running":
self._vultr.start(self.subscription) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"data",
"[",
"\"power_status\"",
"]",
"!=",
"\"running\"",
":",
"self",
".",
"_vultr",
".",
"start",
"(",
"self",
".",
"subscription",
")"
] | [
100,
4
] | [
103,
48
] | python | en | ['en', 'en', 'en'] | True |
VultrSwitch.turn_off | (self, **kwargs) | Halt the subscription. | Halt the subscription. | def turn_off(self, **kwargs):
"""Halt the subscription."""
if self.data["power_status"] == "running":
self._vultr.halt(self.subscription) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"data",
"[",
"\"power_status\"",
"]",
"==",
"\"running\"",
":",
"self",
".",
"_vultr",
".",
"halt",
"(",
"self",
".",
"subscription",
")"
] | [
105,
4
] | [
108,
47
] | python | en | ['en', 'ga', 'en'] | True |
VultrSwitch.update | (self) | Get the latest data from the device and update the data. | Get the latest data from the device and update the data. | def update(self):
"""Get the latest data from the device and update the data."""
self._vultr.update()
self.data = self._vultr.data[self.subscription] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_vultr",
".",
"update",
"(",
")",
"self",
".",
"data",
"=",
"self",
".",
"_vultr",
".",
"data",
"[",
"self",
".",
"subscription",
"]"
] | [
110,
4
] | [
113,
55
] | python | en | ['en', 'en', 'en'] | True |
mock_rflink | (
hass, config, domain, monkeypatch, failures=None, failcommand=False
) | Create mock RFLink asyncio protocol, test component setup. | Create mock RFLink asyncio protocol, test component setup. | async def mock_rflink(
hass, config, domain, monkeypatch, failures=None, failcommand=False
):
"""Create mock RFLink asyncio protocol, test component setup."""
transport, protocol = (Mock(), Mock())
async def send_command_ack(*command):
return not failcommand
protocol.send_command_ack = Moc... | [
"async",
"def",
"mock_rflink",
"(",
"hass",
",",
"config",
",",
"domain",
",",
"monkeypatch",
",",
"failures",
"=",
"None",
",",
"failcommand",
"=",
"False",
")",
":",
"transport",
",",
"protocol",
"=",
"(",
"Mock",
"(",
")",
",",
"Mock",
"(",
")",
"... | [
20,
0
] | [
65,
69
] | python | ceb | ['es', 'ceb', 'en'] | False |
test_version_banner | (hass, monkeypatch) | Test sending unknown commands doesn't cause issues. | Test sending unknown commands doesn't cause issues. | async def test_version_banner(hass, monkeypatch):
"""Test sending unknown commands doesn't cause issues."""
# use sensor domain during testing main platform
domain = "sensor"
config = {
"rflink": {"port": "/dev/ttyABC0"},
domain: {
"platform": "rflink",
"devices":... | [
"async",
"def",
"test_version_banner",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"# use sensor domain during testing main platform",
"domain",
"=",
"\"sensor\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"domain",
":... | [
68,
0
] | [
90,
5
] | python | en | ['en', 'en', 'en'] | True |
test_send_no_wait | (hass, monkeypatch) | Test command sending without ack. | Test command sending without ack. | async def test_send_no_wait(hass, monkeypatch):
"""Test command sending without ack."""
domain = "switch"
config = {
"rflink": {"port": "/dev/ttyABC0", "wait_for_ack": False},
domain: {
"platform": "rflink",
"devices": {
"protocol_0_0": {"name": "test"... | [
"async",
"def",
"test_send_no_wait",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"switch\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"\"wait_for_ack\"",
":",
"False",
"}",
",",
"domain",
":",
"{",... | [
93,
0
] | [
114,
65
] | python | en | ['en', 'en', 'en'] | True |
test_cover_send_no_wait | (hass, monkeypatch) | Test command sending to a cover device without ack. | Test command sending to a cover device without ack. | async def test_cover_send_no_wait(hass, monkeypatch):
"""Test command sending to a cover device without ack."""
domain = "cover"
config = {
"rflink": {"port": "/dev/ttyABC0", "wait_for_ack": False},
domain: {
"platform": "rflink",
"devices": {
"RTS_010... | [
"async",
"def",
"test_cover_send_no_wait",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"cover\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"\"wait_for_ack\"",
":",
"False",
"}",
",",
"domain",
":",
... | [
117,
0
] | [
138,
66
] | python | en | ['en', 'en', 'en'] | True |
test_send_command | (hass, monkeypatch) | Test send_command service. | Test send_command service. | async def test_send_command(hass, monkeypatch):
"""Test send_command service."""
domain = "rflink"
config = {"rflink": {"port": "/dev/ttyABC0"}}
# setup mocking rflink module
_, _, protocol, _ = await mock_rflink(hass, config, domain, monkeypatch)
await hass.services.async_call(
domain... | [
"async",
"def",
"test_send_command",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"rflink\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
"}",
"# setup mocking rflink module",
"_",
",",
"_",
",",
"protoc... | [
141,
0
] | [
156,
68
] | python | en | ['en', 'fr', 'en'] | True |
test_send_command_invalid_arguments | (hass, monkeypatch) | Test send_command service. | Test send_command service. | async def test_send_command_invalid_arguments(hass, monkeypatch):
"""Test send_command service."""
domain = "rflink"
config = {"rflink": {"port": "/dev/ttyABC0"}}
# setup mocking rflink module
_, _, protocol, _ = await mock_rflink(hass, config, domain, monkeypatch)
# one argument missing
w... | [
"async",
"def",
"test_send_command_invalid_arguments",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"rflink\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
"}",
"# setup mocking rflink module",
"_",
",",
"_"... | [
159,
0
] | [
189,
77
] | python | en | ['en', 'fr', 'en'] | True |
test_send_command_event_propagation | (hass, monkeypatch) | Test event propagation for send_command service. | Test event propagation for send_command service. | async def test_send_command_event_propagation(hass, monkeypatch):
"""Test event propagation for send_command service."""
domain = "light"
config = {
"rflink": {"port": "/dev/ttyABC0"},
domain: {
"platform": "rflink",
"devices": {
"protocol_0_1": {"name... | [
"async",
"def",
"test_send_command_event_propagation",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"light\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"domain",
":",
"{",
"\"platform\"",
":",
"\... | [
192,
0
] | [
231,
60
] | python | en | ['en', 'en', 'en'] | True |
test_reconnecting_after_disconnect | (hass, monkeypatch) | An unexpected disconnect should cause a reconnect. | An unexpected disconnect should cause a reconnect. | async def test_reconnecting_after_disconnect(hass, monkeypatch):
"""An unexpected disconnect should cause a reconnect."""
domain = "sensor"
config = {
"rflink": {"port": "/dev/ttyABC0", CONF_RECONNECT_INTERVAL: 0},
domain: {"platform": "rflink"},
}
# setup mocking rflink module
... | [
"async",
"def",
"test_reconnecting_after_disconnect",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"sensor\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"CONF_RECONNECT_INTERVAL",
":",
"0",
"}",
",",
"do... | [
234,
0
] | [
255,
38
] | python | en | ['en', 'en', 'en'] | True |
test_reconnecting_after_failure | (hass, monkeypatch) | A failure to reconnect should be retried. | A failure to reconnect should be retried. | async def test_reconnecting_after_failure(hass, monkeypatch):
"""A failure to reconnect should be retried."""
domain = "sensor"
config = {
"rflink": {"port": "/dev/ttyABC0", CONF_RECONNECT_INTERVAL: 0},
domain: {"platform": "rflink"},
}
# success first time but fail second
failu... | [
"async",
"def",
"test_reconnecting_after_failure",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"sensor\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"CONF_RECONNECT_INTERVAL",
":",
"0",
"}",
",",
"domai... | [
258,
0
] | [
282,
38
] | python | en | ['en', 'en', 'en'] | True |
test_error_when_not_connected | (hass, monkeypatch) | Sending command should error when not connected. | Sending command should error when not connected. | async def test_error_when_not_connected(hass, monkeypatch):
"""Sending command should error when not connected."""
domain = "switch"
config = {
"rflink": {"port": "/dev/ttyABC0", CONF_RECONNECT_INTERVAL: 0},
domain: {
"platform": "rflink",
"devices": {
... | [
"async",
"def",
"test_error_when_not_connected",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"switch\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
",",
"CONF_RECONNECT_INTERVAL",
":",
"0",
"}",
",",
"domain"... | [
285,
0
] | [
312,
77
] | python | en | ['en', 'en', 'en'] | True |
test_async_send_command_error | (hass, monkeypatch) | Sending command should error when protocol fails. | Sending command should error when protocol fails. | async def test_async_send_command_error(hass, monkeypatch):
"""Sending command should error when protocol fails."""
domain = "rflink"
config = {"rflink": {"port": "/dev/ttyABC0"}}
# setup mocking rflink module
_, _, protocol, _ = await mock_rflink(
hass, config, domain, monkeypatch, failcom... | [
"async",
"def",
"test_async_send_command_error",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"rflink\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
"}",
"# setup mocking rflink module",
"_",
",",
"_",
",... | [
315,
0
] | [
333,
80
] | python | en | ['en', 'it', 'en'] | True |
test_race_condition | (hass, monkeypatch) | Test race condition for unknown components. | Test race condition for unknown components. | async def test_race_condition(hass, monkeypatch):
"""Test race condition for unknown components."""
domain = "light"
config = {"rflink": {"port": "/dev/ttyABC0"}, domain: {"platform": "rflink"}}
tmp_entity = TMP_ENTITY.format("test3")
# setup mocking rflink module
event_callback, _, _, _ = awai... | [
"async",
"def",
"test_race_condition",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"domain",
"=",
"\"light\"",
"config",
"=",
"{",
"\"rflink\"",
":",
"{",
"\"port\"",
":",
"\"/dev/ttyABC0\"",
"}",
",",
"domain",
":",
"{",
"\"platform\"",
":",
"\"rflink\"",
"}... | [
336,
0
] | [
369,
35
] | python | en | ['en', 'en', 'en'] | True |
test_not_connected | (hass, monkeypatch) | Test Error when sending commands to a disconnected device. | Test Error when sending commands to a disconnected device. | async def test_not_connected(hass, monkeypatch):
"""Test Error when sending commands to a disconnected device."""
import pytest
from homeassistant.core import HomeAssistantError
test_device = RflinkCommand("DUMMY_DEVICE")
RflinkCommand.set_rflink_protocol(None)
with pytest.raises(HomeAssistant... | [
"async",
"def",
"test_not_connected",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"import",
"pytest",
"from",
"homeassistant",
".",
"core",
"import",
"HomeAssistantError",
"test_device",
"=",
"RflinkCommand",
"(",
"\"DUMMY_DEVICE\"",
")",
"RflinkCommand",
".",
"set_r... | [
372,
0
] | [
381,
58
] | python | en | ['en', 'en', 'en'] | True |
is_serial_port | (value: str) | Validate that value is a windows serial port or a unix device. | Validate that value is a windows serial port or a unix device. | def is_serial_port(value: str) -> str:
"""Validate that value is a windows serial port or a unix device."""
if sys.platform.startswith("win"):
ports = (f"COM{idx + 1}" for idx in range(256))
if value in ports:
return value
raise vol.Invalid(f"{value} is not a serial port")
... | [
"def",
"is_serial_port",
"(",
"value",
":",
"str",
")",
"->",
"str",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"ports",
"=",
"(",
"f\"COM{idx + 1}\"",
"for",
"idx",
"in",
"range",
"(",
"256",
")",
")",
"if",
"val... | [
57,
0
] | [
64,
29
] | python | en | ['en', 'en', 'en'] | True |
is_socket_address | (value: str) | Validate that value is a valid address. | Validate that value is a valid address. | def is_socket_address(value: str) -> str:
"""Validate that value is a valid address."""
try:
socket.getaddrinfo(value, None)
return value
except OSError as err:
raise vol.Invalid("Device is not a valid domain name or ip address") from err | [
"def",
"is_socket_address",
"(",
"value",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"socket",
".",
"getaddrinfo",
"(",
"value",
",",
"None",
")",
"return",
"value",
"except",
"OSError",
"as",
"err",
":",
"raise",
"vol",
".",
"Invalid",
"(",
"\"Dev... | [
67,
0
] | [
73,
85
] | python | en | ['en', 'en', 'en'] | True |
try_connect | (
hass: HomeAssistant, gateway_type: ConfGatewayType, user_input: dict[str, Any]
) | Try to connect to a gateway and report if it worked. | Try to connect to a gateway and report if it worked. | async def try_connect(
hass: HomeAssistant, gateway_type: ConfGatewayType, user_input: dict[str, Any]
) -> bool:
"""Try to connect to a gateway and report if it worked."""
if gateway_type == "MQTT":
return True # Do not validate MQTT, as that does not use connection made.
try:
gateway_r... | [
"async",
"def",
"try_connect",
"(",
"hass",
":",
"HomeAssistant",
",",
"gateway_type",
":",
"ConfGatewayType",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"if",
"gateway_type",
"==",
"\"MQTT\"",
":",
"return",
"True... | [
76,
0
] | [
121,
20
] | python | en | ['en', 'en', 'en'] | True |
get_mysensors_gateway | (
hass: HomeAssistant, gateway_id: GatewayId
) | Return the Gateway for a given GatewayId. | Return the Gateway for a given GatewayId. | def get_mysensors_gateway(
hass: HomeAssistant, gateway_id: GatewayId
) -> BaseAsyncGateway | None:
"""Return the Gateway for a given GatewayId."""
if MYSENSORS_GATEWAYS not in hass.data[DOMAIN]:
hass.data[DOMAIN][MYSENSORS_GATEWAYS] = {}
gateways = hass.data[DOMAIN].get(MYSENSORS_GATEWAYS)
... | [
"def",
"get_mysensors_gateway",
"(",
"hass",
":",
"HomeAssistant",
",",
"gateway_id",
":",
"GatewayId",
")",
"->",
"BaseAsyncGateway",
"|",
"None",
":",
"if",
"MYSENSORS_GATEWAYS",
"not",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
":",
"hass",
".",
"data... | [
124,
0
] | [
131,
35
] | python | en | ['en', 'cy', 'en'] | True |
setup_gateway | (
hass: HomeAssistant, entry: ConfigEntry
) | Set up the Gateway for the given ConfigEntry. | Set up the Gateway for the given ConfigEntry. | async def setup_gateway(
hass: HomeAssistant, entry: ConfigEntry
) -> BaseAsyncGateway | None:
"""Set up the Gateway for the given ConfigEntry."""
ready_gateway = await _get_gateway(
hass,
gateway_type=entry.data[CONF_GATEWAY_TYPE],
device=entry.data[CONF_DEVICE],
version=en... | [
"async",
"def",
"setup_gateway",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"BaseAsyncGateway",
"|",
"None",
":",
"ready_gateway",
"=",
"await",
"_get_gateway",
"(",
"hass",
",",
"gateway_type",
"=",
"entry",
".",
"data",
... | [
134,
0
] | [
154,
24
] | python | en | ['en', 'en', 'en'] | True |
_get_gateway | (
hass: HomeAssistant,
gateway_type: ConfGatewayType,
device: str,
version: str,
event_callback: Callable[[Message], None],
persistence_file: str | None = None,
baud_rate: int | None = None,
tcp_port: int | None = None,
topic_in_prefix: str | None = None,
topic_out_prefix: str | ... | Return gateway after setup of the gateway. | Return gateway after setup of the gateway. | async def _get_gateway(
hass: HomeAssistant,
gateway_type: ConfGatewayType,
device: str,
version: str,
event_callback: Callable[[Message], None],
persistence_file: str | None = None,
baud_rate: int | None = None,
tcp_port: int | None = None,
topic_in_prefix: str | None = None,
to... | [
"async",
"def",
"_get_gateway",
"(",
"hass",
":",
"HomeAssistant",
",",
"gateway_type",
":",
"ConfGatewayType",
",",
"device",
":",
"str",
",",
"version",
":",
"str",
",",
"event_callback",
":",
"Callable",
"[",
"[",
"Message",
"]",
",",
"None",
"]",
",",
... | [
157,
0
] | [
237,
18
] | python | en | ['en', 'da', 'en'] | True |
finish_setup | (
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) | Load any persistent devices and platforms and start gateway. | Load any persistent devices and platforms and start gateway. | async def finish_setup(
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) -> None:
"""Load any persistent devices and platforms and start gateway."""
discover_tasks = []
start_tasks = []
discover_tasks.append(_discover_persistent_devices(hass, entry, gateway))
start_tasks.appe... | [
"async",
"def",
"finish_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"gateway",
":",
"BaseAsyncGateway",
")",
"->",
"None",
":",
"discover_tasks",
"=",
"[",
"]",
"start_tasks",
"=",
"[",
"]",
"discover_tasks",
".",
"appen... | [
240,
0
] | [
252,
39
] | python | en | ['en', 'en', 'en'] | True |
_discover_persistent_devices | (
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) | Discover platforms for devices loaded via persistence file. | Discover platforms for devices loaded via persistence file. | async def _discover_persistent_devices(
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) -> None:
"""Discover platforms for devices loaded via persistence file."""
new_devices = defaultdict(list)
for node_id in gateway.sensors:
if not validate_node(gateway, node_id):
... | [
"async",
"def",
"_discover_persistent_devices",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"gateway",
":",
"BaseAsyncGateway",
")",
"->",
"None",
":",
"new_devices",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"node_id",
"in",
"... | [
255,
0
] | [
270,
76
] | python | en | ['en', 'en', 'en'] | True |
gw_stop | (
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) | Stop the gateway. | Stop the gateway. | async def gw_stop(
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) -> None:
"""Stop the gateway."""
connect_task = hass.data[DOMAIN].pop(
MYSENSORS_GATEWAY_START_TASK.format(entry.entry_id), None
)
if connect_task is not None and not connect_task.done():
connect_... | [
"async",
"def",
"gw_stop",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"gateway",
":",
"BaseAsyncGateway",
")",
"->",
"None",
":",
"connect_task",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"pop",
"(",
"MYSENSORS_GATEW... | [
273,
0
] | [
282,
24
] | python | en | ['en', 'ht', 'en'] | True |
_gw_start | (
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) | Start the gateway. | Start the gateway. | async def _gw_start(
hass: HomeAssistant, entry: ConfigEntry, gateway: BaseAsyncGateway
) -> None:
"""Start the gateway."""
gateway_ready = asyncio.Event()
def gateway_connected(_: BaseAsyncGateway) -> None:
"""Handle gateway connected."""
gateway_ready.set()
gateway.on_conn_made =... | [
"async",
"def",
"_gw_start",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"gateway",
":",
"BaseAsyncGateway",
")",
"->",
"None",
":",
"gateway_ready",
"=",
"asyncio",
".",
"Event",
"(",
")",
"def",
"gateway_connected",
"(",
"_",
... | [
285,
0
] | [
324,
9
] | python | en | ['en', 'de', 'en'] | True |
_gw_callback_factory | (
hass: HomeAssistant, gateway_id: GatewayId
) | Return a new callback for the gateway. | Return a new callback for the gateway. | def _gw_callback_factory(
hass: HomeAssistant, gateway_id: GatewayId
) -> Callable[[Message], None]:
"""Return a new callback for the gateway."""
@callback
def mysensors_callback(msg: Message) -> None:
"""Handle messages from a MySensors gateway.
All MySenors messages are received here... | [
"def",
"_gw_callback_factory",
"(",
"hass",
":",
"HomeAssistant",
",",
"gateway_id",
":",
"GatewayId",
")",
"->",
"Callable",
"[",
"[",
"Message",
"]",
",",
"None",
"]",
":",
"@",
"callback",
"def",
"mysensors_callback",
"(",
"msg",
":",
"Message",
")",
"-... | [
327,
0
] | [
351,
29
] | python | en | ['en', 'ig', 'en'] | True |
WiffiFlowHandler.async_get_options_flow | (config_entry) | Create Wiffi server setup option flow. | Create Wiffi server setup option flow. | def async_get_options_flow(config_entry):
"""Create Wiffi server setup option flow."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
23,
4
] | [
25,
47
] | python | en | ['en', 'et', 'en'] | True |
WiffiFlowHandler.async_step_user | (self, user_input=None) | Handle the start of the config flow.
Called after wiffi integration has been selected in the 'add integration
UI'. The user_input is set to None in this case. We will open a config
flow form then.
This function is also called if the form has been submitted. user_input
contains a... | Handle the start of the config flow. | async def async_step_user(self, user_input=None):
"""Handle the start of the config flow.
Called after wiffi integration has been selected in the 'add integration
UI'. The user_input is set to None in this case. We will open a config
flow form then.
This function is also called ... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"_async_show_form",
"(",
")",
"# received input from form or configuration.yaml",
"try",
":",
"# try to start serv... | [
27,
4
] | [
52,
65
] | python | en | ['en', 'en', 'en'] | True |
WiffiFlowHandler._async_show_form | (self, errors=None) | Show the config flow form to the user. | Show the config flow form to the user. | def _async_show_form(self, errors=None):
"""Show the config flow form to the user."""
data_schema = {vol.Required(CONF_PORT, default=DEFAULT_PORT): int}
return self.async_show_form(
step_id="user", data_schema=vol.Schema(data_schema), errors=errors or {}
) | [
"def",
"_async_show_form",
"(",
"self",
",",
"errors",
"=",
"None",
")",
":",
"data_schema",
"=",
"{",
"vol",
".",
"Required",
"(",
"CONF_PORT",
",",
"default",
"=",
"DEFAULT_PORT",
")",
":",
"int",
"}",
"return",
"self",
".",
"async_show_form",
"(",
"st... | [
55,
4
] | [
61,
9
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
67,
4
] | [
69,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Manage the options. | Manage the options. | async def async_step_init(self, user_input=None):
"""Manage the options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
return self.async_show_form(
step_id="init",
data_schema=vol.Schema(
{
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
"data",
"=",
"user_input",
")",
"return",
... | [
71,
4
] | [
88,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Set up this platform for a specific ConfigEntry(==Gateway). | Set up this platform for a specific ConfigEntry(==Gateway). | async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up this platform for a specific ConfigEntry(==Gateway)."""
@callback
def async_discover(discovery_info: DiscoveryInfo) -> None:
"""Discover and add a M... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"None",
":",
"@",
"callback",
"def",
"async_discover",
"(",
"discovery_info",
":... | [
36,
0
] | [
62,
5
] | python | en | ['en', 'en', 'en'] | True |
MySensorsBinarySensor.is_on | (self) | Return True if the binary sensor is on. | Return True if the binary sensor is on. | def is_on(self) -> bool:
"""Return True if the binary sensor is on."""
return self._values.get(self.value_type) == STATE_ON | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_values",
".",
"get",
"(",
"self",
".",
"value_type",
")",
"==",
"STATE_ON"
] | [
69,
4
] | [
71,
60
] | python | en | ['en', 'fy', 'en'] | True |
MySensorsBinarySensor.device_class | (self) | Return the class of this sensor, from DEVICE_CLASSES. | Return the class of this sensor, from DEVICE_CLASSES. | def device_class(self) -> str | None:
"""Return the class of this sensor, from DEVICE_CLASSES."""
pres = self.gateway.const.Presentation
device_class = SENSORS.get(pres(self.child_type).name)
if device_class in DEVICE_CLASSES:
return device_class
return None | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
"|",
"None",
":",
"pres",
"=",
"self",
".",
"gateway",
".",
"const",
".",
"Presentation",
"device_class",
"=",
"SENSORS",
".",
"get",
"(",
"pres",
"(",
"self",
".",
"child_type",
")",
".",
"name",
... | [
74,
4
] | [
80,
19
] | python | en | ['en', 'en', 'en'] | True |
load_fonts | (patterns, expected_count=None, font_class=None) | Load all fonts specified in the patterns.
Also assert that the number of the fonts found is exactly the same as
expected_count. | Load all fonts specified in the patterns. | def load_fonts(patterns, expected_count=None, font_class=None):
"""Load all fonts specified in the patterns.
Also assert that the number of the fonts found is exactly the same as
expected_count."""
if font_class is None:
font_class = ttLib.TTFont
all_font_files = []
for pattern in pat... | [
"def",
"load_fonts",
"(",
"patterns",
",",
"expected_count",
"=",
"None",
",",
"font_class",
"=",
"None",
")",
":",
"if",
"font_class",
"is",
"None",
":",
"font_class",
"=",
"ttLib",
".",
"TTFont",
"all_font_files",
"=",
"[",
"]",
"for",
"pattern",
"in",
... | [
46,
0
] | [
64,
36
] | python | en | ['en', 'en', 'en'] | True |
TestItalicAngle.test_italic_angle | (self) | Tests the italic angle of fonts to be correct. | Tests the italic angle of fonts to be correct. | def test_italic_angle(self):
"""Tests the italic angle of fonts to be correct."""
for font in self.fonts:
post_table = font["post"]
if "Italic" in font_data.font_name(font):
expected_angle = self.expected_italic_angle
else:
expected_ang... | [
"def",
"test_italic_angle",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"post_table",
"=",
"font",
"[",
"\"post\"",
"]",
"if",
"\"Italic\"",
"in",
"font_data",
".",
"font_name",
"(",
"font",
")",
":",
"expected_angle",
"=",
"se... | [
79,
4
] | [
87,
68
] | python | en | ['en', 'en', 'en'] | True |
TestMetaInfo.parse_metadata | (self, font) | Parse font name to infer weight and slope. | Parse font name to infer weight and slope. | def parse_metadata(self, font):
"""Parse font name to infer weight and slope."""
font_name = font_data.font_name(font)
bold = ("Bold" in font_name) or (
self.mark_heavier_as_bold and "Black" in font_name
)
italic = "Italic" in font_name
return bold, italic | [
"def",
"parse_metadata",
"(",
"self",
",",
"font",
")",
":",
"font_name",
"=",
"font_data",
".",
"font_name",
"(",
"font",
")",
"bold",
"=",
"(",
"\"Bold\"",
"in",
"font_name",
")",
"or",
"(",
"self",
".",
"mark_heavier_as_bold",
"and",
"\"Black\"",
"in",
... | [
99,
4
] | [
107,
27
] | python | en | ['en', 'en', 'en'] | True |
TestMetaInfo.test_mac_style | (self) | Tests the macStyle of the fonts to be correct. | Tests the macStyle of the fonts to be correct. | def test_mac_style(self):
"""Tests the macStyle of the fonts to be correct."""
for font in self.fonts:
bold, italic = self.parse_metadata(font)
expected_mac_style = (italic << 1) | bold
self.assertEqual(font["head"].macStyle, expected_mac_style) | [
"def",
"test_mac_style",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"bold",
",",
"italic",
"=",
"self",
".",
"parse_metadata",
"(",
"font",
")",
"expected_mac_style",
"=",
"(",
"italic",
"<<",
"1",
")",
"|",
"bold",
"self",
... | [
109,
4
] | [
115,
71
] | python | en | ['en', 'en', 'en'] | True |
TestMetaInfo.test_fs_selection | (self) | Tests the fsSelection to be correct. | Tests the fsSelection to be correct. | def test_fs_selection(self):
"""Tests the fsSelection to be correct."""
for font in self.fonts:
bold, italic = self.parse_metadata(font)
expected_fs_type = ((bold << 5) | italic) or (1 << 6)
if italic and self.mark_italic_as_oblique:
expected_fs_type ... | [
"def",
"test_fs_selection",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"bold",
",",
"italic",
"=",
"self",
".",
"parse_metadata",
"(",
"font",
")",
"expected_fs_type",
"=",
"(",
"(",
"bold",
"<<",
"5",
")",
"|",
"italic",
... | [
117,
4
] | [
125,
72
] | python | en | ['en', 'en', 'en'] | True |
TestMetaInfo.test_fs_type | (self) | Tests the fsType of the fonts. | Tests the fsType of the fonts. | def test_fs_type(self):
"""Tests the fsType of the fonts."""
for font in self.fonts:
self.assertEqual(font["OS/2"].fsType, self.expected_os2_fsType) | [
"def",
"test_fs_type",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"self",
".",
"assertEqual",
"(",
"font",
"[",
"\"OS/2\"",
"]",
".",
"fsType",
",",
"self",
".",
"expected_os2_fsType",
")"
] | [
127,
4
] | [
131,
75
] | python | en | ['en', 'en', 'en'] | True |
TestMetaInfo.test_vendor_id | (self) | Tests the vendor ID of the fonts. | Tests the vendor ID of the fonts. | def test_vendor_id(self):
"""Tests the vendor ID of the fonts."""
for font in self.fonts:
self.assertEqual(font["OS/2"].achVendID, self.expected_os2_achVendID) | [
"def",
"test_vendor_id",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"self",
".",
"assertEqual",
"(",
"font",
"[",
"\"OS/2\"",
"]",
".",
"achVendID",
",",
"self",
".",
"expected_os2_achVendID",
")"
] | [
133,
4
] | [
136,
81
] | python | en | ['en', 'en', 'en'] | True |
TestNames.test_copyright | (self) | Tests the copyright message. | Tests the copyright message. | def test_copyright(self):
"""Tests the copyright message."""
for records in self.names:
self.assertEqual(records[0], self.expected_copyright) | [
"def",
"test_copyright",
"(",
"self",
")",
":",
"for",
"records",
"in",
"self",
".",
"names",
":",
"self",
".",
"assertEqual",
"(",
"records",
"[",
"0",
"]",
",",
"self",
".",
"expected_copyright",
")"
] | [
171,
4
] | [
174,
65
] | python | en | ['en', 'en', 'en'] | True |
TestNames.parse_filename | (self, filename) | Parse expected name attributes from filename. | Parse expected name attributes from filename. | def parse_filename(self, filename):
"""Parse expected name attributes from filename."""
name_nosp = self.family_name.replace(" ", "")
condensed_name_nosp = self.condensed_family_name.replace(" ", "")
family_names = "%s|%s" % (condensed_name_nosp, name_nosp)
filename_match = not... | [
"def",
"parse_filename",
"(",
"self",
",",
"filename",
")",
":",
"name_nosp",
"=",
"self",
".",
"family_name",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
"condensed_name_nosp",
"=",
"self",
".",
"condensed_family_name",
".",
"replace",
"(",
"\" \"",
","... | [
176,
4
] | [
192,
36
] | python | en | ['en', 'en', 'en'] | True |
TestNames.build_style | (self, weight, slope) | Build style (typographic subfamily) out of weight and slope. | Build style (typographic subfamily) out of weight and slope. | def build_style(self, weight, slope):
"""Build style (typographic subfamily) out of weight and slope."""
style = weight
if slope:
if style == "Regular":
style = "Italic"
else:
style += " " + slope
return style | [
"def",
"build_style",
"(",
"self",
",",
"weight",
",",
"slope",
")",
":",
"style",
"=",
"weight",
"if",
"slope",
":",
"if",
"style",
"==",
"\"Regular\"",
":",
"style",
"=",
"\"Italic\"",
"else",
":",
"style",
"+=",
"\" \"",
"+",
"slope",
"return",
"sty... | [
194,
4
] | [
203,
20
] | python | en | ['en', 'en', 'en'] | True |
TestNames.test_family_name | (self) | Tests the family name. | Tests the family name. | def test_family_name(self):
"""Tests the family name."""
for font_file, records in zip(self.font_files, self.names):
family, weight, _ = self.parse_filename(font_file)
# check that family name includes weight, if not regular or bold
if weight not in ["Regular", "Bo... | [
"def",
"test_family_name",
"(",
"self",
")",
":",
"for",
"font_file",
",",
"records",
"in",
"zip",
"(",
"self",
".",
"font_files",
",",
"self",
".",
"names",
")",
":",
"family",
",",
"weight",
",",
"_",
"=",
"self",
".",
"parse_filename",
"(",
"font_fi... | [
205,
4
] | [
222,
52
] | python | en | ['en', 'en', 'en'] | True |
TestNames.test_subfamily_name | (self) | Tests the subfamily name. | Tests the subfamily name. | def test_subfamily_name(self):
"""Tests the subfamily name."""
for font_file, records in zip(self.font_files, self.names):
_, weight, slope = self.parse_filename(font_file)
subfam = records[2]
# check that subfamily is just a combination of bold and italic
... | [
"def",
"test_subfamily_name",
"(",
"self",
")",
":",
"for",
"font_file",
",",
"records",
"in",
"zip",
"(",
"self",
".",
"font_files",
",",
"self",
".",
"names",
")",
":",
"_",
",",
"weight",
",",
"slope",
"=",
"self",
".",
"parse_filename",
"(",
"font_... | [
224,
4
] | [
245,
78
] | python | en | ['en', 'en', 'en'] | True |
TestNames.test_unique_identifier_and_full_name | (self) | Tests the unique identifier and full name. | Tests the unique identifier and full name. | def test_unique_identifier_and_full_name(self):
"""Tests the unique identifier and full name."""
for font_file, records in zip(self.font_files, self.names):
family, weight, slope = self.parse_filename(font_file)
style = self.build_style(weight, slope)
expected_name = ... | [
"def",
"test_unique_identifier_and_full_name",
"(",
"self",
")",
":",
"for",
"font_file",
",",
"records",
"in",
"zip",
"(",
"self",
".",
"font_files",
",",
"self",
".",
"names",
")",
":",
"family",
",",
"weight",
",",
"slope",
"=",
"self",
".",
"parse_file... | [
247,
4
] | [
257,
49
] | python | en | ['en', 'en', 'en'] | True |
TestNames.test_postscript_name | (self) | Tests the postscript name. | Tests the postscript name. | def test_postscript_name(self):
"""Tests the postscript name."""
for font_file, records in zip(self.font_files, self.names):
family, weight, slope = self.parse_filename(font_file)
style = self.build_style(weight, slope)
expected_name = (family + "-" + style).replace("... | [
"def",
"test_postscript_name",
"(",
"self",
")",
":",
"for",
"font_file",
",",
"records",
"in",
"zip",
"(",
"self",
".",
"font_files",
",",
"self",
".",
"names",
")",
":",
"family",
",",
"weight",
",",
"slope",
"=",
"self",
".",
"parse_filename",
"(",
... | [
259,
4
] | [
265,
55
] | python | en | ['en', 'en', 'en'] | True |
TestNames.test_postscript_name_for_spaces | (self) | Tests that there are no spaces in PostScript names. | Tests that there are no spaces in PostScript names. | def test_postscript_name_for_spaces(self):
"""Tests that there are no spaces in PostScript names."""
for records in self.names:
self.assertFalse(" " in records[6]) | [
"def",
"test_postscript_name_for_spaces",
"(",
"self",
")",
":",
"for",
"records",
"in",
"self",
".",
"names",
":",
"self",
".",
"assertFalse",
"(",
"\" \"",
"in",
"records",
"[",
"6",
"]",
")"
] | [
267,
4
] | [
270,
47
] | python | en | ['en', 'en', 'en'] | True |
TestDigitWidths.test_digit_widths | (self) | Tests all decimal digits to make sure they have the same width. | Tests all decimal digits to make sure they have the same width. | def test_digit_widths(self):
"""Tests all decimal digits to make sure they have the same width."""
for font in self.fonts:
hmtx_table = font["hmtx"]
widths = [hmtx_table[digit][0] for digit in self.digits]
self.assertEqual(len(set(widths)), 1) | [
"def",
"test_digit_widths",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"hmtx_table",
"=",
"font",
"[",
"\"hmtx\"",
"]",
"widths",
"=",
"[",
"hmtx_table",
"[",
"digit",
"]",
"[",
"0",
"]",
"for",
"digit",
"in",
"self",
".",... | [
291,
4
] | [
296,
49
] | python | en | ['en', 'en', 'en'] | True |
TestDigitWidths.test_superscript_digits | (self) | Tests that 'numr' features maps digits to Unicode superscripts. | Tests that 'numr' features maps digits to Unicode superscripts. | def test_superscript_digits(self):
"""Tests that 'numr' features maps digits to Unicode superscripts."""
ascii_digits = "0123456789"
superscript_digits = u"⁰¹²³⁴⁵⁶⁷⁸⁹"
for font_file in self.font_files:
numr_glyphs = layout.get_advances(
ascii_digits, font_file... | [
"def",
"test_superscript_digits",
"(",
"self",
")",
":",
"ascii_digits",
"=",
"\"0123456789\"",
"superscript_digits",
"=",
"u\"⁰¹²³⁴⁵⁶⁷⁸⁹\"",
"for",
"font_file",
"in",
"self",
".",
"font_files",
":",
"numr_glyphs",
"=",
"layout",
".",
"get_advances",
"(",
"ascii_dig... | [
298,
4
] | [
307,
61
] | python | en | ['en', 'en', 'en'] | True |
TestCharacterCoverage.test_inclusion | (self) | Tests for characters which should be included. | Tests for characters which should be included. | def test_inclusion(self):
"""Tests for characters which should be included."""
for font in self.fonts:
charset = coverage.character_set(font)
for char in self.include:
self.assertIn(char, charset) | [
"def",
"test_inclusion",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"charset",
"=",
"coverage",
".",
"character_set",
"(",
"font",
")",
"for",
"char",
"in",
"self",
".",
"include",
":",
"self",
".",
"assertIn",
"(",
"char",
... | [
316,
4
] | [
322,
44
] | python | en | ['en', 'en', 'en'] | True |
TestCharacterCoverage.test_exclusion | (self) | Tests that characters which should be excluded are absent. | Tests that characters which should be excluded are absent. | def test_exclusion(self):
"""Tests that characters which should be excluded are absent."""
for font in self.fonts:
charset = coverage.character_set(font)
for char in self.exclude:
self.assertNotIn(char, charset) | [
"def",
"test_exclusion",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"charset",
"=",
"coverage",
".",
"character_set",
"(",
"font",
")",
"for",
"char",
"in",
"self",
".",
"exclude",
":",
"self",
".",
"assertNotIn",
"(",
"char... | [
324,
4
] | [
330,
47
] | python | en | ['en', 'en', 'en'] | True |
TestCharacterCoverage.test_format_4_cmap_preset | (self) | Test that fonts contain a MS Unicode BMP encoded cmap, as recommended
by the spec: https://www.microsoft.com/typography/otspec/cmap.htm
| Test that fonts contain a MS Unicode BMP encoded cmap, as recommended
by the spec: https://www.microsoft.com/typography/otspec/cmap.htm
| def test_format_4_cmap_preset(self):
"""Test that fonts contain a MS Unicode BMP encoded cmap, as recommended
by the spec: https://www.microsoft.com/typography/otspec/cmap.htm
"""
for font in self.fonts:
found = False
for cmap in font["cmap"].tables:
... | [
"def",
"test_format_4_cmap_preset",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"found",
"=",
"False",
"for",
"cmap",
"in",
"font",
"[",
"\"cmap\"",
"]",
".",
"tables",
":",
"if",
"(",
"cmap",
".",
"format",
",",
"cmap",
".... | [
332,
4
] | [
342,
34
] | python | en | ['en', 'en', 'en'] | True |
TestLigatures.test_active_ligatures | (self) | Tests that some ligatures are formed by certain features. | Tests that some ligatures are formed by certain features. | def test_active_ligatures(self):
"""Tests that some ligatures are formed by certain features."""
self._run_ligature_test(self.active, True) | [
"def",
"test_active_ligatures",
"(",
"self",
")",
":",
"self",
".",
"_run_ligature_test",
"(",
"self",
".",
"active",
",",
"True",
")"
] | [
359,
4
] | [
362,
50
] | python | en | ['en', 'en', 'en'] | True |
TestLigatures.test_inactive_ligatures | (self) | Tests that some ligatures are not formed by certain features. | Tests that some ligatures are not formed by certain features. | def test_inactive_ligatures(self):
"""Tests that some ligatures are not formed by certain features."""
self._run_ligature_test(self.inactive, False) | [
"def",
"test_inactive_ligatures",
"(",
"self",
")",
":",
"self",
".",
"_run_ligature_test",
"(",
"self",
".",
"inactive",
",",
"False",
")"
] | [
364,
4
] | [
367,
53
] | python | en | ['en', 'en', 'en'] | True |
TestFeatures.test_num_features | (self) | Tests that lnum/onum/pnum/tnum features behave appropriately. | Tests that lnum/onum/pnum/tnum features behave appropriately. | def test_num_features(self):
"""Tests that lnum/onum/pnum/tnum features behave appropriately."""
def run_test(
glyph_order, glyph_set, fontfile, tags, proportional=False, oldstyle=False
):
num = glyph_order[layout.get_glyphs("1", fontfile)[0]]
styled = glyph... | [
"def",
"test_num_features",
"(",
"self",
")",
":",
"def",
"run_test",
"(",
"glyph_order",
",",
"glyph_set",
",",
"fontfile",
",",
"tags",
",",
"proportional",
"=",
"False",
",",
"oldstyle",
"=",
"False",
")",
":",
"num",
"=",
"glyph_order",
"[",
"layout",
... | [
394,
4
] | [
441,
72
] | python | en | ['en', 'la', 'en'] | True |
TestFeatures.run_sub_coverage_test | (self, feature, reqs_path) | Tests that a substitution feature is supported for a required set. | Tests that a substitution feature is supported for a required set. | def run_sub_coverage_test(self, feature, reqs_path):
"""Tests that a substitution feature is supported for a required set."""
with open(reqs_path) as reqs_file:
reqs_list = []
for line in reqs_file.readlines():
input_cp, output_name = line[: line.index(" #")].spl... | [
"def",
"run_sub_coverage_test",
"(",
"self",
",",
"feature",
",",
"reqs_path",
")",
":",
"with",
"open",
"(",
"reqs_path",
")",
"as",
"reqs_file",
":",
"reqs_list",
"=",
"[",
"]",
"for",
"line",
"in",
"reqs_file",
".",
"readlines",
"(",
")",
":",
"input_... | [
443,
4
] | [
466,
13
] | python | en | ['en', 'en', 'en'] | True |
TestFeatures.test_smcp_coverage | (self) | Tests that smcp is supported for a required set. | Tests that smcp is supported for a required set. | def test_smcp_coverage(self):
"""Tests that smcp is supported for a required set."""
self.run_sub_coverage_test("smcp", self.smcp_reqs_path) | [
"def",
"test_smcp_coverage",
"(",
"self",
")",
":",
"self",
".",
"run_sub_coverage_test",
"(",
"\"smcp\"",
",",
"self",
".",
"smcp_reqs_path",
")"
] | [
468,
4
] | [
471,
63
] | python | en | ['en', 'en', 'en'] | True |
TestFeatures.test_c2sc_coverage | (self) | Tests that c2sc is supported for a required set. | Tests that c2sc is supported for a required set. | def test_c2sc_coverage(self):
"""Tests that c2sc is supported for a required set."""
self.run_sub_coverage_test("c2sc", self.c2sc_reqs_path) | [
"def",
"test_c2sc_coverage",
"(",
"self",
")",
":",
"self",
".",
"run_sub_coverage_test",
"(",
"\"c2sc\"",
",",
"self",
".",
"c2sc_reqs_path",
")"
] | [
473,
4
] | [
476,
63
] | python | en | ['en', 'en', 'en'] | True |
TestFeatures.test_unic_coverage | (self) | Tests that unic is supported for a required set. | Tests that unic is supported for a required set. | def test_unic_coverage(self):
"""Tests that unic is supported for a required set."""
self.run_sub_coverage_test("unic", self.unic_reqs_path) | [
"def",
"test_unic_coverage",
"(",
"self",
")",
":",
"self",
".",
"run_sub_coverage_test",
"(",
"\"unic\"",
",",
"self",
".",
"unic_reqs_path",
")"
] | [
478,
4
] | [
481,
63
] | python | en | ['en', 'en', 'en'] | True |
TestVerticalMetrics.test_ymin_ymax | (self) | Tests yMin and yMax to be equal to expected values. | Tests yMin and yMax to be equal to expected values. | def test_ymin_ymax(self):
"""Tests yMin and yMax to be equal to expected values."""
for font in self.fonts:
head_table = font["head"]
self.assertEqual(head_table.yMin, self.expected_head_yMin)
self.assertEqual(head_table.yMax, self.expected_head_yMax) | [
"def",
"test_ymin_ymax",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"head_table",
"=",
"font",
"[",
"\"head\"",
"]",
"self",
".",
"assertEqual",
"(",
"head_table",
".",
"yMin",
",",
"self",
".",
"expected_head_yMin",
")",
"sel... | [
490,
4
] | [
496,
70
] | python | en | ['en', 'en', 'en'] | True |
TestVerticalMetrics.test_glyphs_ymin_ymax | (self) | Tests yMin and yMax of all glyphs to not go outside the range. | Tests yMin and yMax of all glyphs to not go outside the range. | def test_glyphs_ymin_ymax(self):
"""Tests yMin and yMax of all glyphs to not go outside the range."""
out_of_bounds = []
for font_file, font in zip(self.font_files, self.fonts):
glyf_table = font["glyf"]
for glyph_name in glyf_table.glyphOrder:
try:
... | [
"def",
"test_glyphs_ymin_ymax",
"(",
"self",
")",
":",
"out_of_bounds",
"=",
"[",
"]",
"for",
"font_file",
",",
"font",
"in",
"zip",
"(",
"self",
".",
"font_files",
",",
"self",
".",
"fonts",
")",
":",
"glyf_table",
"=",
"font",
"[",
"\"glyf\"",
"]",
"... | [
498,
4
] | [
523,
9
] | python | en | ['en', 'en', 'en'] | True |
TestVerticalMetrics.test_hhea_table_metrics | (self) | Tests ascent, descent, and lineGap to be equal to expected values. | Tests ascent, descent, and lineGap to be equal to expected values. | def test_hhea_table_metrics(self):
"""Tests ascent, descent, and lineGap to be equal to expected values."""
for font in self.fonts:
hhea_table = font["hhea"]
self.assertEqual(hhea_table.descent, self.expected_hhea_descent)
self.assertEqual(hhea_table.ascent, self.exp... | [
"def",
"test_hhea_table_metrics",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"hhea_table",
"=",
"font",
"[",
"\"hhea\"",
"]",
"self",
".",
"assertEqual",
"(",
"hhea_table",
".",
"descent",
",",
"self",
".",
"expected_hhea_descent"... | [
525,
4
] | [
532,
76
] | python | en | ['en', 'en', 'en'] | True |
TestVerticalMetrics.test_os2_metrics | (self) | Tests OS/2 vertical metrics to be equal to expected values. | Tests OS/2 vertical metrics to be equal to expected values. | def test_os2_metrics(self):
"""Tests OS/2 vertical metrics to be equal to expected values."""
for font in self.fonts:
os2_table = font["OS/2"]
self.assertEqual(os2_table.sTypoDescender, self.expected_os2_sTypoDescender)
self.assertEqual(os2_table.sTypoAscender, self.... | [
"def",
"test_os2_metrics",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"os2_table",
"=",
"font",
"[",
"\"OS/2\"",
"]",
"self",
".",
"assertEqual",
"(",
"os2_table",
".",
"sTypoDescender",
",",
"self",
".",
"expected_os2_sTypoDescen... | [
534,
4
] | [
543,
82
] | python | en | ['en', 'en', 'en'] | True |
TestHints.test_existance_of_hints | (self) | Tests all glyphs and makes sure non-composite ones have hints. | Tests all glyphs and makes sure non-composite ones have hints. | def test_existance_of_hints(self):
"""Tests all glyphs and makes sure non-composite ones have hints."""
missing_hints = []
for font in self.fonts:
glyf_table = font["glyf"]
for glyph_name in font.getGlyphOrder():
glyph = glyf_table[glyph_name]
... | [
"def",
"test_existance_of_hints",
"(",
"self",
")",
":",
"missing_hints",
"=",
"[",
"]",
"for",
"font",
"in",
"self",
".",
"fonts",
":",
"glyf_table",
"=",
"font",
"[",
"\"glyf\"",
"]",
"for",
"glyph_name",
"in",
"font",
".",
"getGlyphOrder",
"(",
")",
"... | [
552,
4
] | [
564,
44
] | python | en | ['en', 'en', 'en'] | True |
TestHints.test_height_of_lowercase_o | (self) | Tests the height of the lowercase o in low resolutions. | Tests the height of the lowercase o in low resolutions. | def test_height_of_lowercase_o(self):
"""Tests the height of the lowercase o in low resolutions."""
for fontfile in self.fontfiles:
for size in range(8, 30): # Kind of arbitrary
o_height = get_rendered_char_height(fontfile, size, "o")
n_height = get_rendered_... | [
"def",
"test_height_of_lowercase_o",
"(",
"self",
")",
":",
"for",
"fontfile",
"in",
"self",
".",
"fontfiles",
":",
"for",
"size",
"in",
"range",
"(",
"8",
",",
"30",
")",
":",
"# Kind of arbitrary",
"o_height",
"=",
"get_rendered_char_height",
"(",
"fontfile"... | [
566,
4
] | [
572,
52
] | python | en | ['en', 'en', 'en'] | True |
TestGlyphAreas.setUp | (self) | Determine which glyphs are intentionally unchanged. | Determine which glyphs are intentionally unchanged. | def setUp(self):
"""Determine which glyphs are intentionally unchanged."""
self.unchanged = set()
master_a, master_b = self.getGlyphSets(
self.master_glyph_sets, self.master_weights_to_test
)
pen_a = GlyphAreaPen(master_a)
pen_b = GlyphAreaPen(master_b)
... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"unchanged",
"=",
"set",
"(",
")",
"master_a",
",",
"master_b",
"=",
"self",
".",
"getGlyphSets",
"(",
"self",
".",
"master_glyph_sets",
",",
"self",
".",
"master_weights_to_test",
")",
"pen_a",
"=",
"G... | [
655,
4
] | [
676,
40
] | python | en | ['en', 'en', 'en'] | True |
TestGlyphAreas.getGlyphSets | (self, glyph_sets, weights) | Filter glyph sets to only those with certain weights. | Filter glyph sets to only those with certain weights. | def getGlyphSets(self, glyph_sets, weights):
"""Filter glyph sets to only those with certain weights."""
glyph_set_map = {
noto_fonts.parse_weight(font_file): glyph_set
for font_file, glyph_set in zip(*glyph_sets)
if all(style not in font_file for style in self.exclu... | [
"def",
"getGlyphSets",
"(",
"self",
",",
"glyph_sets",
",",
"weights",
")",
":",
"glyph_set_map",
"=",
"{",
"noto_fonts",
".",
"parse_weight",
"(",
"font_file",
")",
":",
"glyph_set",
"for",
"font_file",
",",
"glyph_set",
"in",
"zip",
"(",
"*",
"glyph_sets",... | [
678,
4
] | [
686,
50
] | python | en | ['en', 'en', 'en'] | True |
TestGlyphAreas.test_output | (self) | Test that empty or intentionally unchanged glyphs are unchanged, and
everything else is changed.
| Test that empty or intentionally unchanged glyphs are unchanged, and
everything else is changed.
| def test_output(self):
"""Test that empty or intentionally unchanged glyphs are unchanged, and
everything else is changed.
"""
glyph_sets = self.getGlyphSets(
self.instance_glyph_sets, self.instance_weights_to_test
)
standard = glyph_sets[0]
pen = Gl... | [
"def",
"test_output",
"(",
"self",
")",
":",
"glyph_sets",
"=",
"self",
".",
"getGlyphSets",
"(",
"self",
".",
"instance_glyph_sets",
",",
"self",
".",
"instance_weights_to_test",
")",
"standard",
"=",
"glyph_sets",
"[",
"0",
"]",
"pen",
"=",
"GlyphAreaPen",
... | [
688,
4
] | [
724,
58
] | python | en | ['en', 'en', 'en'] | True |
TestSpacingMarks.test_individual_spacing_marks | (self) | Tests that spacing marks are spacing by themselves. | Tests that spacing marks are spacing by themselves. | def test_individual_spacing_marks(self):
"""Tests that spacing marks are spacing by themselves."""
for font in self.font_files:
print("Testing %s for stand-alone spacing marks..." % font)
for mark in self.marks_to_test:
mark = unichr(mark)
advances... | [
"def",
"test_individual_spacing_marks",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"font_files",
":",
"print",
"(",
"\"Testing %s for stand-alone spacing marks...\"",
"%",
"font",
")",
"for",
"mark",
"in",
"self",
".",
"marks_to_test",
":",
"mark",
... | [
738,
4
] | [
746,
51
] | python | en | ['en', 'en', 'en'] | True |
TestSpacingMarks.test_spacing_marks_in_combination | (self) | Tests that spacing marks do not combine with base letters. | Tests that spacing marks do not combine with base letters. | def test_spacing_marks_in_combination(self):
"""Tests that spacing marks do not combine with base letters."""
for font in self.font_files:
print("Testing %s for spacing marks in combination..." % font)
for base_letter in (
u"A\u00C6BCDEFGHIJKLMNO\u00D8\u01A0PRST"
... | [
"def",
"test_spacing_marks_in_combination",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"font_files",
":",
"print",
"(",
"\"Testing %s for spacing marks in combination...\"",
"%",
"font",
")",
"for",
"base_letter",
"in",
"(",
"u\"A\\u00C6BCDEFGHIJKLMNO\\u00... | [
748,
4
] | [
772,
21
] | python | en | ['en', 'en', 'en'] | True |
TestSoftDottedChars.test_combinations | (self) | Tests that soft-dotted characters lose their dots when combined. | Tests that soft-dotted characters lose their dots when combined. | def test_combinations(self):
"""Tests that soft-dotted characters lose their dots when combined."""
for font in self.font_files:
print("Testing %s for soft-dotted combinations..." % font)
# TODO: replace the following list with actual derivation based on
# Unicode's... | [
"def",
"test_combinations",
"(",
"self",
")",
":",
"for",
"font",
"in",
"self",
".",
"font_files",
":",
"print",
"(",
"\"Testing %s for soft-dotted combinations...\"",
"%",
"font",
")",
"# TODO: replace the following list with actual derivation based on",
"# Unicode's soft-do... | [
786,
4
] | [
809,
21
] | python | en | ['en', 'en', 'en'] | True |
async_get_scanner | (hass, config) | Return the UPC device scanner. | Return the UPC device scanner. | async def async_get_scanner(hass, config):
"""Return the UPC device scanner."""
conf = config[DOMAIN]
session = hass.helpers.aiohttp_client.async_get_clientsession()
connect_box = ConnectBox(session, conf[CONF_PASSWORD], host=conf[CONF_HOST])
# Check login data
try:
await connect_box.as... | [
"async",
"def",
"async_get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"session",
"=",
"hass",
".",
"helpers",
".",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
")",
"connect_box",
"=",
"ConnectBox",
"... | [
29,
0
] | [
50,
40
] | python | en | ['en', 'no', 'en'] | True |
UPCDeviceScanner.__init__ | (self, connect_box: ConnectBox) | Initialize the scanner. | Initialize the scanner. | def __init__(self, connect_box: ConnectBox) -> None:
"""Initialize the scanner."""
self.connect_box: ConnectBox = connect_box | [
"def",
"__init__",
"(",
"self",
",",
"connect_box",
":",
"ConnectBox",
")",
"->",
"None",
":",
"self",
".",
"connect_box",
":",
"ConnectBox",
"=",
"connect_box"
] | [
56,
4
] | [
58,
50
] | python | en | ['en', 'en', 'en'] | True |
UPCDeviceScanner.async_scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | async def async_scan_devices(self) -> list[str]:
"""Scan for new devices and return a list with found device IDs."""
try:
await self.connect_box.async_get_devices()
except ConnectBoxError:
return []
return [device.mac for device in self.connect_box.devices] | [
"async",
"def",
"async_scan_devices",
"(",
"self",
")",
"->",
"list",
"[",
"str",
"]",
":",
"try",
":",
"await",
"self",
".",
"connect_box",
".",
"async_get_devices",
"(",
")",
"except",
"ConnectBoxError",
":",
"return",
"[",
"]",
"return",
"[",
"device",
... | [
60,
4
] | [
67,
66
] | python | en | ['en', 'en', 'en'] | True |
UPCDeviceScanner.async_get_device_name | (self, device: str) | Get the device name (the name of the wireless device not used). | Get the device name (the name of the wireless device not used). | async def async_get_device_name(self, device: str) -> str | None:
"""Get the device name (the name of the wireless device not used)."""
for connected_device in self.connect_box.devices:
if (
connected_device.mac == device
and connected_device.hostname.lower() ... | [
"async",
"def",
"async_get_device_name",
"(",
"self",
",",
"device",
":",
"str",
")",
"->",
"str",
"|",
"None",
":",
"for",
"connected_device",
"in",
"self",
".",
"connect_box",
".",
"devices",
":",
"if",
"(",
"connected_device",
".",
"mac",
"==",
"device"... | [
69,
4
] | [
78,
19
] | python | en | ['en', 'en', 'en'] | True |
entry | (hass) | Mock config entry added to HA. | Mock config entry added to HA. | def entry(hass):
"""Mock config entry added to HA."""
entry = MockConfigEntry(domain=DOMAIN, data={"host": "1.2.3.4"})
entry.add_to_hass(hass)
return entry | [
"def",
"entry",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"\"host\"",
":",
"\"1.2.3.4\"",
"}",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"return",
"entry"
] | [
11,
0
] | [
15,
16
] | python | en | ['en', 'en', 'en'] | True |
mock_iotawatt | (entry) | Mock iotawatt. | Mock iotawatt. | def mock_iotawatt(entry):
"""Mock iotawatt."""
with patch("homeassistant.components.iotawatt.coordinator.Iotawatt") as mock:
instance = mock.return_value
instance.connect = AsyncMock(return_value=True)
instance.update = AsyncMock()
instance.getSensors.return_value = {"sensors": {... | [
"def",
"mock_iotawatt",
"(",
"entry",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.iotawatt.coordinator.Iotawatt\"",
")",
"as",
"mock",
":",
"instance",
"=",
"mock",
".",
"return_value",
"instance",
".",
"connect",
"=",
"AsyncMock",
"(",
"return_value... | [
19,
0
] | [
26,
22
] | python | en | ['en', 'sv', 'it'] | False |
test_form | (hass: HomeAssistant) | Test we get the form. | Test we get the form. | async def test_form(hass: HomeAssistant) -> None:
"""Test we get the form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors"] is None
with patch("adax.get_adax_token", re... | [
"async",
"def",
"test_form",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
"."... | [
16,
0
] | [
40,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass: HomeAssistant) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass: HomeAssistant) -> None:
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"adax.get_adax_token",
return_value=None,
):
... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_... | [
43,
0
] | [
58,
58
] | python | en | ['en', 'en', 'en'] | True |
test_flow_entry_already_exists | (hass: HomeAssistant) | Test user input for config_entry that already exists. | Test user input for config_entry that already exists. | async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
"""Test user input for config_entry that already exists."""
first_entry = MockConfigEntry(
domain="adax",
data=TEST_DATA,
unique_id=TEST_DATA[ACCOUNT_ID],
)
first_entry.add_to_hass(hass)
with patch("adax... | [
"async",
"def",
"test_flow_entry_already_exists",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"first_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"adax\"",
",",
"data",
"=",
"TEST_DATA",
",",
"unique_id",
"=",
"TEST_DATA",
"[",
"ACCOUNT_I... | [
61,
0
] | [
77,
51
] | 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.