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
GeniusClimateZone.hvac_modes
(self)
Return the list of available hvac operation modes.
Return the list of available hvac operation modes.
def hvac_modes(self) -> List[str]: """Return the list of available hvac operation modes.""" return list(HA_HVAC_TO_GH)
[ "def", "hvac_modes", "(", "self", ")", "->", "List", "[", "str", "]", ":", "return", "list", "(", "HA_HVAC_TO_GH", ")" ]
[ 69, 4 ]
[ 71, 34 ]
python
en
['en', 'en', 'en']
True
GeniusClimateZone.hvac_action
(self)
Return the current running hvac operation if supported.
Return the current running hvac operation if supported.
def hvac_action(self) -> Optional[str]: """Return the current running hvac operation if supported.""" if "_state" in self._zone.data: # only for v3 API if not self._zone.data["_state"].get("bIsActive"): return CURRENT_HVAC_OFF if self._zone.data["_state"].get("bO...
[ "def", "hvac_action", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "\"_state\"", "in", "self", ".", "_zone", ".", "data", ":", "# only for v3 API", "if", "not", "self", ".", "_zone", ".", "data", "[", "\"_state\"", "]", ".", "get", ...
[ 74, 4 ]
[ 82, 19 ]
python
en
['en', 'en', 'en']
True
GeniusClimateZone.preset_mode
(self)
Return the current preset mode, e.g., home, away, temp.
Return the current preset mode, e.g., home, away, temp.
def preset_mode(self) -> Optional[str]: """Return the current preset mode, e.g., home, away, temp.""" return GH_PRESET_TO_HA.get(self._zone.data["mode"])
[ "def", "preset_mode", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "GH_PRESET_TO_HA", ".", "get", "(", "self", ".", "_zone", ".", "data", "[", "\"mode\"", "]", ")" ]
[ 85, 4 ]
[ 87, 59 ]
python
en
['en', 'pt', 'en']
True
GeniusClimateZone.preset_modes
(self)
Return a list of available preset modes.
Return a list of available preset modes.
def preset_modes(self) -> Optional[List[str]]: """Return a list of available preset modes.""" if "occupied" in self._zone.data: # if has a movement sensor return [PRESET_ACTIVITY, PRESET_BOOST] return [PRESET_BOOST]
[ "def", "preset_modes", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "if", "\"occupied\"", "in", "self", ".", "_zone", ".", "data", ":", "# if has a movement sensor", "return", "[", "PRESET_ACTIVITY", ",", "PRESET_BOOST", "]", ...
[ 90, 4 ]
[ 94, 29 ]
python
en
['en', 'en', 'en']
True
GeniusClimateZone.async_set_hvac_mode
(self, hvac_mode: str)
Set a new hvac mode.
Set a new hvac mode.
async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set a new hvac mode.""" await self._zone.set_mode(HA_HVAC_TO_GH.get(hvac_mode))
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "_zone", ".", "set_mode", "(", "HA_HVAC_TO_GH", ".", "get", "(", "hvac_mode", ")", ")" ]
[ 96, 4 ]
[ 98, 63 ]
python
en
['en', 'pt', 'en']
True
GeniusClimateZone.async_set_preset_mode
(self, preset_mode: str)
Set a new preset mode.
Set a new preset mode.
async def async_set_preset_mode(self, preset_mode: str) -> None: """Set a new preset mode.""" await self._zone.set_mode(HA_PRESET_TO_GH.get(preset_mode, "timer"))
[ "async", "def", "async_set_preset_mode", "(", "self", ",", "preset_mode", ":", "str", ")", "->", "None", ":", "await", "self", ".", "_zone", ".", "set_mode", "(", "HA_PRESET_TO_GH", ".", "get", "(", "preset_mode", ",", "\"timer\"", ")", ")" ]
[ 100, 4 ]
[ 102, 76 ]
python
en
['en', 'ca', 'en']
True
get_unique_prefix
( location: hdate.Location, language: str, candle_lighting_offset: Optional[int], havdalah_offset: Optional[int], )
Create a prefix for unique ids.
Create a prefix for unique ids.
def get_unique_prefix( location: hdate.Location, language: str, candle_lighting_offset: Optional[int], havdalah_offset: Optional[int], ) -> str: """Create a prefix for unique ids.""" config_properties = [ location.latitude, location.longitude, location.timezone, l...
[ "def", "get_unique_prefix", "(", "location", ":", "hdate", ".", "Location", ",", "language", ":", "str", ",", "candle_lighting_offset", ":", "Optional", "[", "int", "]", ",", "havdalah_offset", ":", "Optional", "[", "int", "]", ",", ")", "->", "str", ":", ...
[ 77, 0 ]
[ 95, 22 ]
python
en
['fr', 'it', 'en']
False
async_setup
(hass, config)
Set up the Jewish Calendar component.
Set up the Jewish Calendar component.
async def async_setup(hass, config): """Set up the Jewish Calendar component.""" name = config[DOMAIN][CONF_NAME] language = config[DOMAIN][CONF_LANGUAGE] latitude = config[DOMAIN].get(CONF_LATITUDE, hass.config.latitude) longitude = config[DOMAIN].get(CONF_LONGITUDE, hass.config.longitude) dia...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "name", "=", "config", "[", "DOMAIN", "]", "[", "CONF_NAME", "]", "language", "=", "config", "[", "DOMAIN", "]", "[", "CONF_LANGUAGE", "]", "latitude", "=", "config", "[", "DOMAIN", "...
[ 98, 0 ]
[ 136, 15 ]
python
en
['en', 'ca', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 19, 0 ]
[ 21, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 25, 0 ]
[ 27, 30 ]
python
en
['en', 'fy', 'en']
True
test_get_actions
(hass, device_reg, entity_reg)
Test we get the expected actions from a fan.
Test we get the expected actions from a fan.
async def test_get_actions(hass, device_reg, entity_reg): """Test we get the expected actions from a fan.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, connect...
[ "async", "def", "test_get_actions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")", ...
[ 30, 0 ]
[ 54, 48 ]
python
en
['en', 'en', 'en']
True
test_action
(hass)
Test for turn_on and turn_off actions.
Test for turn_on and turn_off actions.
async def test_action(hass): """Test for turn_on and turn_off actions.""" assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger": { "platform": "event", ...
[ "async", "def", "test_action", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",", "{", "automation", ".", "DOMAIN", ":", "[", "{", "\"trigger\"", ":", "{", "\"platform\"", ":", "\"event\"", ...
[ 57, 0 ]
[ 103, 34 ]
python
en
['en', 'en', 'en']
True
_disallow_id
(conf: Dict[str, Any])
Disallow ID in config.
Disallow ID in config.
def _disallow_id(conf: Dict[str, Any]) -> Dict[str, Any]: """Disallow ID in config.""" if CONF_ID in conf: raise vol.Invalid("ID is not allowed for the homeassistant auth provider.") return conf
[ "def", "_disallow_id", "(", "conf", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "CONF_ID", "in", "conf", ":", "raise", "vol", ".", "Invalid", "(", "\"ID is not allowed for the homeassistant auth prov...
[ 21, 0 ]
[ 26, 15 ]
python
en
['en', 'en', 'en']
True
async_get_provider
(hass: HomeAssistant)
Get the provider.
Get the provider.
def async_get_provider(hass: HomeAssistant) -> "HassAuthProvider": """Get the provider.""" for prv in hass.auth.auth_providers: if prv.type == "homeassistant": return cast(HassAuthProvider, prv) raise RuntimeError("Provider not found")
[ "def", "async_get_provider", "(", "hass", ":", "HomeAssistant", ")", "->", "\"HassAuthProvider\"", ":", "for", "prv", "in", "hass", ".", "auth", ".", "auth_providers", ":", "if", "prv", ".", "type", "==", "\"homeassistant\"", ":", "return", "cast", "(", "Has...
[ 33, 0 ]
[ 39, 44 ]
python
en
['en', 'en', 'en']
True
Data.__init__
(self, hass: HomeAssistant)
Initialize the user data store.
Initialize the user data store.
def __init__(self, hass: HomeAssistant) -> None: """Initialize the user data store.""" self.hass = hass self._store = hass.helpers.storage.Store( STORAGE_VERSION, STORAGE_KEY, private=True ) self._data: Optional[Dict[str, Any]] = None # Legacy mode will allow ...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "self", ".", "hass", "=", "hass", "self", ".", "_store", "=", "hass", ".", "helpers", ".", "storage", ".", "Store", "(", "STORAGE_VERSION", ",", "STORAGE_KEY", "...
[ 56, 4 ]
[ 66, 30 ]
python
en
['en', 'en', 'en']
True
Data.normalize_username
(self, username: str)
Normalize a username based on the mode.
Normalize a username based on the mode.
def normalize_username(self, username: str) -> str: """Normalize a username based on the mode.""" if self.is_legacy: return username return username.strip().casefold()
[ "def", "normalize_username", "(", "self", ",", "username", ":", "str", ")", "->", "str", ":", "if", "self", ".", "is_legacy", ":", "return", "username", "return", "username", ".", "strip", "(", ")", ".", "casefold", "(", ")" ]
[ 69, 4 ]
[ 74, 42 ]
python
en
['en', 'en', 'en']
True
Data.async_load
(self)
Load stored data.
Load stored data.
async def async_load(self) -> None: """Load stored data.""" data = await self._store.async_load() if data is None: data = {"users": []} seen: Set[str] = set() for user in data["users"]: username = user["username"] # check if we have duplica...
[ "async", "def", "async_load", "(", "self", ")", "->", "None", ":", "data", "=", "await", "self", ".", "_store", ".", "async_load", "(", ")", "if", "data", "is", "None", ":", "data", "=", "{", "\"users\"", ":", "[", "]", "}", "seen", ":", "Set", "...
[ 76, 4 ]
[ 118, 25 ]
python
en
['en', 'en', 'en']
True
Data.users
(self)
Return users.
Return users.
def users(self) -> List[Dict[str, str]]: """Return users.""" return self._data["users"]
[ "def", "users", "(", "self", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "return", "self", ".", "_data", "[", "\"users\"", "]" ]
[ 121, 4 ]
[ 123, 34 ]
python
de
['de', 'ig', 'en']
False
Data.validate_login
(self, username: str, password: str)
Validate a username and password. Raises InvalidAuth if auth invalid.
Validate a username and password.
def validate_login(self, username: str, password: str) -> None: """Validate a username and password. Raises InvalidAuth if auth invalid. """ username = self.normalize_username(username) dummy = b"$2b$12$CiuFGszHx9eNHxPuQcwBWez4CwDTOcLTX5CbOpV6gef2nYuXkY7BO" found = None ...
[ "def", "validate_login", "(", "self", ",", "username", ":", "str", ",", "password", ":", "str", ")", "->", "None", ":", "username", "=", "self", ".", "normalize_username", "(", "username", ")", "dummy", "=", "b\"$2b$12$CiuFGszHx9eNHxPuQcwBWez4CwDTOcLTX5CbOpV6gef2n...
[ 125, 4 ]
[ 148, 29 ]
python
en
['en', 'en', 'en']
True
Data.hash_password
( # pylint: disable=no-self-use self, password: str, for_storage: bool = False )
Encode a password.
Encode a password.
def hash_password( # pylint: disable=no-self-use self, password: str, for_storage: bool = False ) -> bytes: """Encode a password.""" hashed: bytes = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12)) if for_storage: hashed = base64.b64encode(hashed) ret...
[ "def", "hash_password", "(", "# pylint: disable=no-self-use", "self", ",", "password", ":", "str", ",", "for_storage", ":", "bool", "=", "False", ")", "->", "bytes", ":", "hashed", ":", "bytes", "=", "bcrypt", ".", "hashpw", "(", "password", ".", "encode", ...
[ 150, 4 ]
[ 158, 21 ]
python
en
['en', 'pt', 'en']
True
Data.add_auth
(self, username: str, password: str)
Add a new authenticated user/pass.
Add a new authenticated user/pass.
def add_auth(self, username: str, password: str) -> None: """Add a new authenticated user/pass.""" username = self.normalize_username(username) if any( self.normalize_username(user["username"]) == username for user in self.users ): raise InvalidUser self...
[ "def", "add_auth", "(", "self", ",", "username", ":", "str", ",", "password", ":", "str", ")", "->", "None", ":", "username", "=", "self", ".", "normalize_username", "(", "username", ")", "if", "any", "(", "self", ".", "normalize_username", "(", "user", ...
[ 160, 4 ]
[ 174, 9 ]
python
en
['en', 'en', 'en']
True
Data.async_remove_auth
(self, username: str)
Remove authentication.
Remove authentication.
def async_remove_auth(self, username: str) -> None: """Remove authentication.""" username = self.normalize_username(username) index = None for i, user in enumerate(self.users): if self.normalize_username(user["username"]) == username: index = i ...
[ "def", "async_remove_auth", "(", "self", ",", "username", ":", "str", ")", "->", "None", ":", "username", "=", "self", ".", "normalize_username", "(", "username", ")", "index", "=", "None", "for", "i", ",", "user", "in", "enumerate", "(", "self", ".", ...
[ 177, 4 ]
[ 190, 29 ]
python
de
['de', 'sr', 'en']
False
Data.change_password
(self, username: str, new_password: str)
Update the password. Raises InvalidUser if user cannot be found.
Update the password.
def change_password(self, username: str, new_password: str) -> None: """Update the password. Raises InvalidUser if user cannot be found. """ username = self.normalize_username(username) for user in self.users: if self.normalize_username(user["username"]) == username...
[ "def", "change_password", "(", "self", ",", "username", ":", "str", ",", "new_password", ":", "str", ")", "->", "None", ":", "username", "=", "self", ".", "normalize_username", "(", "username", ")", "for", "user", "in", "self", ".", "users", ":", "if", ...
[ 192, 4 ]
[ 204, 29 ]
python
en
['en', 'nl', 'en']
True
HassLoginFlow.async_step_init
( self, user_input: Optional[Dict[str, str]] = None )
Handle the step of the form.
Handle the step of the form.
async def async_step_init( self, user_input: Optional[Dict[str, str]] = None ) -> Dict[str, Any]: """Handle the step of the form.""" errors = {} if user_input is not None: try: await cast(HassAuthProvider, self._auth_provider).async_validate_login( ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "errors", "=", "{", "}", "if", "user_input", "is", ...
[ 317, 4 ]
[ 341, 9 ]
python
en
['en', 'en', 'en']
True
storage_setup
(hass, hass_storage)
Storage setup.
Storage setup.
def storage_setup(hass, hass_storage): """Storage setup.""" async def _storage(items=None, config=None): if items is None: hass_storage[DOMAIN] = { "key": DOMAIN, "version": 1, "data": { "items": [ {...
[ "def", "storage_setup", "(", "hass", ",", "hass_storage", ")", ":", "async", "def", "_storage", "(", "items", "=", "None", ",", "config", "=", "None", ")", ":", "if", "items", "is", "None", ":", "hass_storage", "[", "DOMAIN", "]", "=", "{", "\"key\"", ...
[ 39, 0 ]
[ 69, 19 ]
python
en
['en', 'bs', 'en']
False
async_set_date_and_time
(hass, entity_id, dt_value)
Set date and / or time of input_datetime.
Set date and / or time of input_datetime.
async def async_set_date_and_time(hass, entity_id, dt_value): """Set date and / or time of input_datetime.""" await hass.services.async_call( DOMAIN, SERVICE_SET_DATETIME, { ATTR_ENTITY_ID: entity_id, ATTR_DATE: dt_value.date(), ATTR_TIME: dt_value.tim...
[ "async", "def", "async_set_date_and_time", "(", "hass", ",", "entity_id", ",", "dt_value", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SET_DATETIME", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", ",", "ATTR_DATE", ...
[ 72, 0 ]
[ 83, 5 ]
python
en
['en', 'en', 'en']
True
async_set_datetime
(hass, entity_id, dt_value)
Set date and / or time of input_datetime.
Set date and / or time of input_datetime.
async def async_set_datetime(hass, entity_id, dt_value): """Set date and / or time of input_datetime.""" await hass.services.async_call( DOMAIN, SERVICE_SET_DATETIME, {ATTR_ENTITY_ID: entity_id, ATTR_DATETIME: dt_value}, blocking=True, )
[ "async", "def", "async_set_datetime", "(", "hass", ",", "entity_id", ",", "dt_value", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SET_DATETIME", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", ",", "ATTR_DATETIME", ...
[ 86, 0 ]
[ 93, 5 ]
python
en
['en', 'en', 'en']
True
async_set_timestamp
(hass, entity_id, timestamp)
Set date and / or time of input_datetime.
Set date and / or time of input_datetime.
async def async_set_timestamp(hass, entity_id, timestamp): """Set date and / or time of input_datetime.""" await hass.services.async_call( DOMAIN, SERVICE_SET_DATETIME, {ATTR_ENTITY_ID: entity_id, ATTR_TIMESTAMP: timestamp}, blocking=True, )
[ "async", "def", "async_set_timestamp", "(", "hass", ",", "entity_id", ",", "timestamp", ")", ":", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SET_DATETIME", ",", "{", "ATTR_ENTITY_ID", ":", "entity_id", ",", "ATTR_TIMESTAMP"...
[ 96, 0 ]
[ 103, 5 ]
python
en
['en', 'en', 'en']
True
test_invalid_configs
(hass)
Test config.
Test config.
async def test_invalid_configs(hass): """Test config.""" invalid_configs = [ None, {}, {"name with space": None}, {"test_no_value": {"has_time": False, "has_date": False}}, ] for cfg in invalid_configs: assert not await async_setup_component(hass, DOMAIN, {DOMAIN:...
[ "async", "def", "test_invalid_configs", "(", "hass", ")", ":", "invalid_configs", "=", "[", "None", ",", "{", "}", ",", "{", "\"name with space\"", ":", "None", "}", ",", "{", "\"test_no_value\"", ":", "{", "\"has_time\"", ":", "False", ",", "\"has_date\"", ...
[ 106, 0 ]
[ 115, 75 ]
python
en
['en', 'en', 'en']
False
test_set_datetime
(hass)
Test set_datetime method using date & time.
Test set_datetime method using date & time.
async def test_set_datetime(hass): """Test set_datetime method using date & time.""" await async_setup_component( hass, DOMAIN, {DOMAIN: {"test_datetime": {"has_time": True, "has_date": True}}} ) entity_id = "input_datetime.test_datetime" dt_obj = datetime.datetime(2017, 9, 7, 19, 46, 30) ...
[ "async", "def", "test_set_datetime", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_datetime\"", ":", "{", "\"has_time\"", ":", "True", ",", "\"has_date\"", ":", "True", "}", "}", ...
[ 118, 0 ]
[ 141, 62 ]
python
en
['id', 'en', 'en']
True
test_set_datetime_2
(hass)
Test set_datetime method using datetime.
Test set_datetime method using datetime.
async def test_set_datetime_2(hass): """Test set_datetime method using datetime.""" await async_setup_component( hass, DOMAIN, {DOMAIN: {"test_datetime": {"has_time": True, "has_date": True}}} ) entity_id = "input_datetime.test_datetime" dt_obj = datetime.datetime(2017, 9, 7, 19, 46, 30) ...
[ "async", "def", "test_set_datetime_2", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_datetime\"", ":", "{", "\"has_time\"", ":", "True", ",", "\"has_date\"", ":", "True", "}", "}", ...
[ 144, 0 ]
[ 167, 62 ]
python
en
['id', 'et', 'en']
False
test_set_datetime_3
(hass)
Test set_datetime method using timestamp.
Test set_datetime method using timestamp.
async def test_set_datetime_3(hass): """Test set_datetime method using timestamp.""" await async_setup_component( hass, DOMAIN, {DOMAIN: {"test_datetime": {"has_time": True, "has_date": True}}} ) entity_id = "input_datetime.test_datetime" dt_obj = datetime.datetime(2017, 9, 7, 19, 46, 30) ...
[ "async", "def", "test_set_datetime_3", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_datetime\"", ":", "{", "\"has_time\"", ":", "True", ",", "\"has_date\"", ":", "True", "}", "}", ...
[ 170, 0 ]
[ 193, 62 ]
python
en
['en', 'da', 'en']
True
test_set_datetime_time
(hass)
Test set_datetime method with only time.
Test set_datetime method with only time.
async def test_set_datetime_time(hass): """Test set_datetime method with only time.""" await async_setup_component( hass, DOMAIN, {DOMAIN: {"test_time": {"has_time": True, "has_date": False}}} ) entity_id = "input_datetime.test_time" dt_obj = datetime.datetime(2017, 9, 7, 19, 46, 30) t...
[ "async", "def", "test_set_datetime_time", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_time\"", ":", "{", "\"has_time\"", ":", "True", ",", "\"has_date\"", ":", "False", "}", "}", ...
[ 196, 0 ]
[ 214, 72 ]
python
en
['en', 'en', 'en']
True
test_set_invalid
(hass)
Test set_datetime method with only time.
Test set_datetime method with only time.
async def test_set_invalid(hass): """Test set_datetime method with only time.""" initial = "2017-01-01" await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_date": {"has_time": False, "has_date": True, "initial": initial} } }, ...
[ "async", "def", "test_set_invalid", "(", "hass", ")", ":", "initial", "=", "\"2017-01-01\"", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_date\"", ":", "{", "\"has_time\"", ":", "False", ",", "\"has_date\"...
[ 217, 0 ]
[ 245, 33 ]
python
en
['en', 'en', 'en']
True
test_set_invalid_2
(hass)
Test set_datetime method with date and datetime.
Test set_datetime method with date and datetime.
async def test_set_invalid_2(hass): """Test set_datetime method with date and datetime.""" initial = "2017-01-01" await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_date": {"has_time": False, "has_date": True, "initial": initial} } ...
[ "async", "def", "test_set_invalid_2", "(", "hass", ")", ":", "initial", "=", "\"2017-01-01\"", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_date\"", ":", "{", "\"has_time\"", ":", "False", ",", "\"has_date...
[ 248, 0 ]
[ 276, 33 ]
python
en
['en', 'en', 'en']
True
test_set_datetime_date
(hass)
Test set_datetime method with only date.
Test set_datetime method with only date.
async def test_set_datetime_date(hass): """Test set_datetime method with only date.""" await async_setup_component( hass, DOMAIN, {DOMAIN: {"test_date": {"has_time": False, "has_date": True}}} ) entity_id = "input_datetime.test_date" dt_obj = datetime.datetime(2017, 9, 7, 19, 46) date_...
[ "async", "def", "test_set_datetime_date", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_date\"", ":", "{", "\"has_time\"", ":", "False", ",", "\"has_date\"", ":", "True", "}", "}", ...
[ 279, 0 ]
[ 298, 67 ]
python
en
['en', 'en', 'en']
True
test_restore_state
(hass)
Ensure states are restored on startup.
Ensure states are restored on startup.
async def test_restore_state(hass): """Ensure states are restored on startup.""" mock_restore_cache( hass, ( State("input_datetime.test_time", "19:46:00"), State("input_datetime.test_date", "2017-09-07"), State("input_datetime.test_datetime", "2017-09-07 19:46...
[ "async", "def", "test_restore_state", "(", "hass", ")", ":", "mock_restore_cache", "(", "hass", ",", "(", "State", "(", "\"input_datetime.test_time\"", ",", "\"19:46:00\"", ")", ",", "State", "(", "\"input_datetime.test_date\"", ",", "\"2017-09-07\"", ")", ",", "S...
[ 301, 0 ]
[ 356, 54 ]
python
en
['en', 'en', 'en']
True
test_default_value
(hass)
Test default value if none has been set via initial or restore state.
Test default value if none has been set via initial or restore state.
async def test_default_value(hass): """Test default value if none has been set via initial or restore state.""" await async_setup_component( hass, DOMAIN, { DOMAIN: { "test_time": {"has_time": True, "has_date": False}, "test_date": {"has_time":...
[ "async", "def", "test_default_value", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "DOMAIN", ":", "{", "\"test_time\"", ":", "{", "\"has_time\"", ":", "True", ",", "\"has_date\"", ":", "False", "}", ",", "\...
[ 359, 0 ]
[ 384, 65 ]
python
en
['en', 'en', 'en']
True
test_input_datetime_context
(hass, hass_admin_user)
Test that input_datetime context works.
Test that input_datetime context works.
async def test_input_datetime_context(hass, hass_admin_user): """Test that input_datetime context works.""" assert await async_setup_component( hass, "input_datetime", {"input_datetime": {"only_date": {"has_date": True}}} ) state = hass.states.get("input_datetime.only_date") assert state is...
[ "async", "def", "test_input_datetime_context", "(", "hass", ",", "hass_admin_user", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"input_datetime\"", ",", "{", "\"input_datetime\"", ":", "{", "\"only_date\"", ":", "{", "\"has_date\"", ":"...
[ 387, 0 ]
[ 407, 55 ]
python
en
['en', 'en', 'en']
True
test_reload
(hass, hass_admin_user, hass_read_only_user)
Test reload service.
Test reload service.
async def test_reload(hass, hass_admin_user, hass_read_only_user): """Test reload service.""" count_start = len(hass.states.async_entity_ids()) ent_reg = await entity_registry.async_get_registry(hass) assert await async_setup_component( hass, DOMAIN, { DOMAIN: { ...
[ "async", "def", "test_reload", "(", "hass", ",", "hass_admin_user", ",", "hass_read_only_user", ")", ":", "count_start", "=", "len", "(", "hass", ".", "states", ".", "async_entity_ids", "(", ")", ")", "ent_reg", "=", "await", "entity_registry", ".", "async_get...
[ 410, 0 ]
[ 480, 69 ]
python
en
['en', 'da', 'en']
True
test_load_from_storage
(hass, storage_setup)
Test set up from storage.
Test set up from storage.
async def test_load_from_storage(hass, storage_setup): """Test set up from storage.""" assert await storage_setup() state = hass.states.get(f"{DOMAIN}.datetime_from_storage") assert state.state == INITIAL_DATETIME assert state.attributes.get(ATTR_EDITABLE)
[ "async", "def", "test_load_from_storage", "(", "hass", ",", "storage_setup", ")", ":", "assert", "await", "storage_setup", "(", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "f\"{DOMAIN}.datetime_from_storage\"", ")", "assert", "state", ".", "state"...
[ 483, 0 ]
[ 488, 46 ]
python
en
['en', 'en', 'en']
True
test_editable_state_attribute
(hass, storage_setup)
Test editable attribute.
Test editable attribute.
async def test_editable_state_attribute(hass, storage_setup): """Test editable attribute.""" assert await storage_setup( config={ DOMAIN: { "from_yaml": { CONF_HAS_DATE: True, CONF_HAS_TIME: True, CONF_NAME: "yaml da...
[ "async", "def", "test_editable_state_attribute", "(", "hass", ",", "storage_setup", ")", ":", "assert", "await", "storage_setup", "(", "config", "=", "{", "DOMAIN", ":", "{", "\"from_yaml\"", ":", "{", "CONF_HAS_DATE", ":", "True", ",", "CONF_HAS_TIME", ":", "...
[ 491, 0 ]
[ 512, 46 ]
python
de
['de', 'et', 'en']
False
test_ws_list
(hass, hass_ws_client, storage_setup)
Test listing via WS.
Test listing via WS.
async def test_ws_list(hass, hass_ws_client, storage_setup): """Test listing via WS.""" assert await storage_setup(config={DOMAIN: {"from_yaml": {CONF_HAS_DATE: True}}}) client = await hass_ws_client(hass) await client.send_json({"id": 6, "type": f"{DOMAIN}/list"}) resp = await client.receive_json...
[ "async", "def", "test_ws_list", "(", "hass", ",", "hass_ws_client", ",", "storage_setup", ")", ":", "assert", "await", "storage_setup", "(", "config", "=", "{", "DOMAIN", ":", "{", "\"from_yaml\"", ":", "{", "CONF_HAS_DATE", ":", "True", "}", "}", "}", ")"...
[ 515, 0 ]
[ 532, 68 ]
python
hmn
['nl', 'hmn', 'it']
False
test_ws_delete
(hass, hass_ws_client, storage_setup)
Test WS delete cleans up entity registry.
Test WS delete cleans up entity registry.
async def test_ws_delete(hass, hass_ws_client, storage_setup): """Test WS delete cleans up entity registry.""" assert await storage_setup() input_id = "from_storage" input_entity_id = f"{DOMAIN}.datetime_from_storage" ent_reg = await entity_registry.async_get_registry(hass) state = hass.states...
[ "async", "def", "test_ws_delete", "(", "hass", ",", "hass_ws_client", ",", "storage_setup", ")", ":", "assert", "await", "storage_setup", "(", ")", "input_id", "=", "\"from_storage\"", "input_entity_id", "=", "f\"{DOMAIN}.datetime_from_storage\"", "ent_reg", "=", "awa...
[ 535, 0 ]
[ 557, 72 ]
python
en
['en', 'en', 'en']
True
test_update
(hass, hass_ws_client, storage_setup)
Test updating min/max updates the state.
Test updating min/max updates the state.
async def test_update(hass, hass_ws_client, storage_setup): """Test updating min/max updates the state.""" assert await storage_setup() input_id = "from_storage" input_entity_id = f"{DOMAIN}.datetime_from_storage" ent_reg = await entity_registry.async_get_registry(hass) state = hass.states.ge...
[ "async", "def", "test_update", "(", "hass", ",", "hass_ws_client", ",", "storage_setup", ")", ":", "assert", "await", "storage_setup", "(", ")", "input_id", "=", "\"from_storage\"", "input_entity_id", "=", "f\"{DOMAIN}.datetime_from_storage\"", "ent_reg", "=", "await"...
[ 560, 0 ]
[ 590, 68 ]
python
en
['en', 'en', 'en']
True
test_ws_create
(hass, hass_ws_client, storage_setup)
Test create WS.
Test create WS.
async def test_ws_create(hass, hass_ws_client, storage_setup): """Test create WS.""" assert await storage_setup(items=[]) input_id = "new_datetime" input_entity_id = f"{DOMAIN}.{input_id}" ent_reg = await entity_registry.async_get_registry(hass) state = hass.states.get(input_entity_id) ass...
[ "async", "def", "test_ws_create", "(", "hass", ",", "hass_ws_client", ",", "storage_setup", ")", ":", "assert", "await", "storage_setup", "(", "items", "=", "[", "]", ")", "input_id", "=", "\"new_datetime\"", "input_entity_id", "=", "f\"{DOMAIN}.{input_id}\"", "en...
[ 593, 0 ]
[ 623, 42 ]
python
en
['en', 'gd', 'en']
True
test_setup_no_config
(hass, hass_admin_user)
Test component setup with no config.
Test component setup with no config.
async def test_setup_no_config(hass, hass_admin_user): """Test component setup with no config.""" count_start = len(hass.states.async_entity_ids()) assert await async_setup_component(hass, DOMAIN, {}) with patch( "homeassistant.config.load_yaml_config_file", autospec=True, return_value={} )...
[ "async", "def", "test_setup_no_config", "(", "hass", ",", "hass_admin_user", ")", ":", "count_start", "=", "len", "(", "hass", ".", "states", ".", "async_entity_ids", "(", ")", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", ...
[ 626, 0 ]
[ 642, 61 ]
python
en
['en', 'pt', 'en']
True
ConfigEntryAuth.__init__
( self, hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation, )
Initialize NEW_NAME Auth.
Initialize NEW_NAME Auth.
def __init__( self, hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation, ): """Initialize NEW_NAME Auth.""" self.hass = hass self.config_entry = config_entry self.ses...
[ "def", "__init__", "(", "self", ",", "hass", ":", "core", ".", "HomeAssistant", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ",", "implementation", ":", "config_entry_oauth2_flow", ".", "AbstractOAuth2Implementation", ",", ")", ":", "self", ".",...
[ 17, 4 ]
[ 29, 44 ]
python
en
['en', 'en', 'en']
True
ConfigEntryAuth.refresh_tokens
(self)
Refresh and return new NEW_NAME tokens using Home Assistant OAuth2 session.
Refresh and return new NEW_NAME tokens using Home Assistant OAuth2 session.
def refresh_tokens(self) -> str: """Refresh and return new NEW_NAME tokens using Home Assistant OAuth2 session.""" run_coroutine_threadsafe( self.session.async_ensure_token_valid(), self.hass.loop ).result() return self.session.token["access_token"]
[ "def", "refresh_tokens", "(", "self", ")", "->", "str", ":", "run_coroutine_threadsafe", "(", "self", ".", "session", ".", "async_ensure_token_valid", "(", ")", ",", "self", ".", "hass", ".", "loop", ")", ".", "result", "(", ")", "return", "self", ".", "...
[ 31, 4 ]
[ 37, 49 ]
python
en
['en', 'en', 'en']
True
AsyncConfigEntryAuth.__init__
( self, websession: ClientSession, oauth_session: config_entry_oauth2_flow.OAuth2Session, )
Initialize NEW_NAME auth.
Initialize NEW_NAME auth.
def __init__( self, websession: ClientSession, oauth_session: config_entry_oauth2_flow.OAuth2Session, ): """Initialize NEW_NAME auth.""" super().__init__(websession) self._oauth_session = oauth_session
[ "def", "__init__", "(", "self", ",", "websession", ":", "ClientSession", ",", "oauth_session", ":", "config_entry_oauth2_flow", ".", "OAuth2Session", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "websession", ")", "self", ".", "_oauth_session", "=",...
[ 43, 4 ]
[ 50, 43 ]
python
en
['de', 'en', 'en']
True
AsyncConfigEntryAuth.async_get_access_token
(self)
Return a valid access token.
Return a valid access token.
async def async_get_access_token(self) -> str: """Return a valid access token.""" if not self._oauth_session.valid_token: await self._oauth_session.async_ensure_token_valid() return self._oauth_session.token["access_token"]
[ "async", "def", "async_get_access_token", "(", "self", ")", "->", "str", ":", "if", "not", "self", ".", "_oauth_session", ".", "valid_token", ":", "await", "self", ".", "_oauth_session", ".", "async_ensure_token_valid", "(", ")", "return", "self", ".", "_oauth...
[ 52, 4 ]
[ 57, 56 ]
python
en
['en', 'lb', 'en']
True
async_get_conditions
( hass: HomeAssistant, device_id: str )
List device conditions for Humidifier devices.
List device conditions for Humidifier devices.
async def async_get_conditions( hass: HomeAssistant, device_id: str ) -> List[Dict[str, str]]: """List device conditions for Humidifier devices.""" registry = await entity_registry.async_get_registry(hass) conditions = await toggle_entity.async_get_conditions(hass, device_id, DOMAIN) # Get all the ...
[ "async", "def", "async_get_conditions", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "registry", "=", "await", "entity_registry", ".", "async_get_registry", "(", "ha...
[ 37, 0 ]
[ 62, 21 ]
python
en
['fr', 'en', 'en']
True
async_condition_from_config
( config: ConfigType, config_validation: bool )
Create a function to test a device condition.
Create a function to test a device condition.
def async_condition_from_config( config: ConfigType, config_validation: bool ) -> condition.ConditionCheckerType: """Create a function to test a device condition.""" if config_validation: config = CONDITION_SCHEMA(config) if config[CONF_TYPE] == "is_mode": attribute = const.ATTR_MODE ...
[ "def", "async_condition_from_config", "(", "config", ":", "ConfigType", ",", "config_validation", ":", "bool", ")", "->", "condition", ".", "ConditionCheckerType", ":", "if", "config_validation", ":", "config", "=", "CONDITION_SCHEMA", "(", "config", ")", "if", "c...
[ 66, 0 ]
[ 83, 24 ]
python
en
['en', 'en', 'en']
True
async_get_condition_capabilities
(hass, config)
List condition capabilities.
List condition capabilities.
async def async_get_condition_capabilities(hass, config): """List condition capabilities.""" state = hass.states.get(config[CONF_ENTITY_ID]) condition_type = config[CONF_TYPE] fields = {} if condition_type == "is_mode": if state: modes = state.attributes.get(const.ATTR_AVAILABL...
[ "async", "def", "async_get_condition_capabilities", "(", "hass", ",", "config", ")", ":", "state", "=", "hass", ".", "states", ".", "get", "(", "config", "[", "CONF_ENTITY_ID", "]", ")", "condition_type", "=", "config", "[", "CONF_TYPE", "]", "fields", "=", ...
[ 86, 0 ]
[ 103, 77 ]
python
en
['ro', 'sr', 'en']
False
async_setup_entry
(hass, entry, async_add_entities)
Set up the Pi-hole binary sensor.
Set up the Pi-hole binary sensor.
async def async_setup_entry(hass, entry, async_add_entities): """Set up the Pi-hole binary sensor.""" name = entry.data[CONF_NAME] hole_data = hass.data[PIHOLE_DOMAIN][entry.entry_id] binary_sensors = [ PiHoleBinarySensor( hole_data[DATA_KEY_API], hole_data[DATA_KEY_COORD...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "name", "=", "entry", ".", "data", "[", "CONF_NAME", "]", "hole_data", "=", "hass", ".", "data", "[", "PIHOLE_DOMAIN", "]", "[", "entry", ".", "entry_id", ...
[ 8, 0 ]
[ 20, 44 ]
python
en
['en', 'haw', 'en']
True
PiHoleBinarySensor.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" ]
[ 27, 4 ]
[ 29, 25 ]
python
en
['en', 'mi', 'en']
True
PiHoleBinarySensor.unique_id
(self)
Return the unique id of the sensor.
Return the unique id of the sensor.
def unique_id(self): """Return the unique id of the sensor.""" return f"{self._server_unique_id}/Status"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._server_unique_id}/Status\"" ]
[ 32, 4 ]
[ 34, 49 ]
python
en
['en', 'la', 'en']
True
PiHoleBinarySensor.is_on
(self)
Return if the service is on.
Return if the service is on.
def is_on(self): """Return if the service is on.""" return self.api.data.get("status") == "enabled"
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "api", ".", "data", ".", "get", "(", "\"status\"", ")", "==", "\"enabled\"" ]
[ 37, 4 ]
[ 39, 55 ]
python
en
['en', 'en', 'en']
True
test_flow_import
(hass, caplog)
Test import flow.
Test import flow.
async def test_flow_import(hass, caplog): """Test import flow.""" mocked_hole = _create_mocked_hole() with _patch_config_flow_hole(mocked_hole), _patch_setup(): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA ) ...
[ "async", "def", "test_flow_import", "(", "hass", ",", "caplog", ")", ":", "mocked_hole", "=", "_create_mocked_hole", "(", ")", "with", "_patch_config_flow_hole", "(", "mocked_hole", ")", ",", "_patch_setup", "(", ")", ":", "result", "=", "await", "hass", ".", ...
[ 37, 0 ]
[ 53, 55 ]
python
de
['de', 'fr', 'en']
False
test_flow_import_invalid
(hass, caplog)
Test import flow with invalid server.
Test import flow with invalid server.
async def test_flow_import_invalid(hass, caplog): """Test import flow with invalid server.""" mocked_hole = _create_mocked_hole(True) with _patch_config_flow_hole(mocked_hole), _patch_setup(): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, ...
[ "async", "def", "test_flow_import_invalid", "(", "hass", ",", "caplog", ")", ":", "mocked_hole", "=", "_create_mocked_hole", "(", "True", ")", "with", "_patch_config_flow_hole", "(", "mocked_hole", ")", ",", "_patch_setup", "(", ")", ":", "result", "=", "await",...
[ 56, 0 ]
[ 65, 82 ]
python
en
['en', 'en', 'en']
True
test_flow_user
(hass)
Test user initialized flow.
Test user initialized flow.
async def test_flow_user(hass): """Test user initialized flow.""" mocked_hole = _create_mocked_hole() with _patch_config_flow_hole(mocked_hole), _patch_setup(): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, ) asse...
[ "async", "def", "test_flow_user", "(", "hass", ")", ":", "mocked_hole", "=", "_create_mocked_hole", "(", ")", "with", "_patch_config_flow_hole", "(", "mocked_hole", ")", ",", "_patch_setup", "(", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ...
[ 68, 0 ]
[ 96, 55 ]
python
da
['da', 'pl', 'en']
False
test_flow_user_invalid
(hass)
Test user initialized flow with invalid server.
Test user initialized flow with invalid server.
async def test_flow_user_invalid(hass): """Test user initialized flow with invalid server.""" mocked_hole = _create_mocked_hole(True) with _patch_config_flow_hole(mocked_hole), _patch_setup(): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, da...
[ "async", "def", "test_flow_user_invalid", "(", "hass", ")", ":", "mocked_hole", "=", "_create_mocked_hole", "(", "True", ")", "with", "_patch_config_flow_hole", "(", "mocked_hole", ")", ",", "_patch_setup", "(", ")", ":", "result", "=", "await", "hass", ".", "...
[ 99, 0 ]
[ 108, 61 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Abode binary sensor devices.
Set up Abode binary sensor devices.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Abode binary sensor devices.""" data = hass.data[DOMAIN] device_types = [ CONST.TYPE_CONNECTIVITY, CONST.TYPE_MOISTURE, CONST.TYPE_MOTION, CONST.TYPE_OCCUPANCY, CONST.TYPE_OPENING, ] ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "device_types", "=", "[", "CONST", ".", "TYPE_CONNECTIVITY", ",", "CONST", ".", "TYPE_MOISTURE", ...
[ 12, 0 ]
[ 29, 32 ]
python
en
['en', 'pt', 'en']
True
AbodeBinarySensor.is_on
(self)
Return True if the binary sensor is on.
Return True if the binary sensor is on.
def is_on(self): """Return True if the binary sensor is on.""" return self._device.is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "is_on" ]
[ 36, 4 ]
[ 38, 33 ]
python
en
['en', 'fy', 'en']
True
AbodeBinarySensor.device_class
(self)
Return the class of the binary sensor.
Return the class of the binary sensor.
def device_class(self): """Return the class of the binary sensor.""" if self._device.get_value("is_window") == "1": return DEVICE_CLASS_WINDOW return self._device.generic_type
[ "def", "device_class", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "get_value", "(", "\"is_window\"", ")", "==", "\"1\"", ":", "return", "DEVICE_CLASS_WINDOW", "return", "self", ".", "_device", ".", "generic_type" ]
[ 41, 4 ]
[ 45, 40 ]
python
en
['en', 'tg', 'en']
True
get_split_dataset
(dset_name, batch_size, n_worker, val_size, data_root='../data', shuffle=True)
split the train set into train / val for rl search
split the train set into train / val for rl search
def get_split_dataset(dset_name, batch_size, n_worker, val_size, data_root='../data', shuffle=True): ''' split the train set into train / val for rl search ''' if shuffle: index_sampler = SubsetRandomSampler else: # every time we use the same order for the split subset class Sub...
[ "def", "get_split_dataset", "(", "dset_name", ",", "batch_size", ",", "n_worker", ",", "val_size", ",", "data_root", "=", "'../data'", ",", "shuffle", "=", "True", ")", ":", "if", "shuffle", ":", "index_sampler", "=", "SubsetRandomSampler", "else", ":", "# eve...
[ 75, 0 ]
[ 155, 44 ]
python
en
['en', 'error', 'th']
False
test_form
(hass)
Test we get the user initiated form.
Test we get the user initiated form.
async def test_form(hass): """Test we get the user initiated form.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == data_entry_flow.R...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 19, 0 ]
[ 39, 52 ]
python
en
['en', 'en', 'en']
True
test_user_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_user_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.nightscout.NightscoutAPI.get_server_status", ...
[ "async", "def", "test_user_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}"...
[ 42, 0 ]
[ 58, 58 ]
python
en
['en', 'en', 'en']
True
test_user_form_api_key_required
(hass)
Test we handle an unauthorized error.
Test we handle an unauthorized error.
async def test_user_form_api_key_required(hass): """Test we handle an unauthorized error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.nightscout.NightscoutAPI.get_server_status", ...
[ "async", "def", "test_user_form_api_key_required", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "...
[ 61, 0 ]
[ 80, 56 ]
python
br
['br', 'en', 'it']
False
test_user_form_unexpected_exception
(hass)
Test we handle unexpected exception.
Test we handle unexpected exception.
async def test_user_form_unexpected_exception(hass): """Test we handle unexpected exception.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.nightscout.NightscoutAPI.get_server_status",...
[ "async", "def", "test_user_form_unexpected_exception", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER",...
[ 83, 0 ]
[ 99, 51 ]
python
en
['de', 'en', 'en']
True
test_user_form_duplicate
(hass)
Test duplicate entries.
Test duplicate entries.
async def test_user_form_duplicate(hass): """Test duplicate entries.""" with _patch_glucose_readings(), _patch_server_status(): unique_id = hash_from_url(CONFIG[CONF_URL]) entry = MockConfigEntry(domain=DOMAIN, unique_id=unique_id) await hass.config_entries.async_add(entry) resul...
[ "async", "def", "test_user_form_duplicate", "(", "hass", ")", ":", "with", "_patch_glucose_readings", "(", ")", ",", "_patch_server_status", "(", ")", ":", "unique_id", "=", "hash_from_url", "(", "CONFIG", "[", "CONF_URL", "]", ")", "entry", "=", "MockConfigEntr...
[ 102, 0 ]
[ 114, 55 ]
python
en
['fr', 'en', 'en']
True
_deprecated_platform
(value)
Validate if platform is deprecated.
Validate if platform is deprecated.
def _deprecated_platform(value): """Validate if platform is deprecated.""" if value == "google": raise vol.Invalid( "google tts service has been renamed to google_translate," " please update your configuration." ) return value
[ "def", "_deprecated_platform", "(", "value", ")", ":", "if", "value", "==", "\"google\"", ":", "raise", "vol", ".", "Invalid", "(", "\"google tts service has been renamed to google_translate,\"", "\" please update your configuration.\"", ")", "return", "value" ]
[ 73, 0 ]
[ 80, 16 ]
python
en
['en', 'af', 'en']
True
async_setup
(hass, config)
Set up TTS.
Set up TTS.
async def async_setup(hass, config): """Set up TTS.""" tts = SpeechManager(hass) try: conf = config[DOMAIN][0] if config.get(DOMAIN, []) else {} use_cache = conf.get(CONF_CACHE, DEFAULT_CACHE) cache_dir = conf.get(CONF_CACHE_DIR, DEFAULT_CACHE_DIR) time_memory = conf.get(CON...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "tts", "=", "SpeechManager", "(", "hass", ")", "try", ":", "conf", "=", "config", "[", "DOMAIN", "]", "[", "0", "]", "if", "config", ".", "get", "(", "DOMAIN", ",", "[", "]", ")...
[ 110, 0 ]
[ 218, 15 ]
python
en
['en', 'yi', 'en']
True
_hash_options
(options: Dict)
Hashes an options dictionary.
Hashes an options dictionary.
def _hash_options(options: Dict) -> str: """Hashes an options dictionary.""" opts_hash = hashlib.blake2s(digest_size=5) for key, value in sorted(options.items()): opts_hash.update(str(key).encode()) opts_hash.update(str(value).encode()) return opts_hash.hexdigest()
[ "def", "_hash_options", "(", "options", ":", "Dict", ")", "->", "str", ":", "opts_hash", "=", "hashlib", ".", "blake2s", "(", "digest_size", "=", "5", ")", "for", "key", ",", "value", "in", "sorted", "(", "options", ".", "items", "(", ")", ")", ":", ...
[ 221, 0 ]
[ 228, 32 ]
python
en
['en', 'en', 'en']
True
_init_tts_cache_dir
(hass, cache_dir)
Init cache folder.
Init cache folder.
def _init_tts_cache_dir(hass, cache_dir): """Init cache folder.""" if not os.path.isabs(cache_dir): cache_dir = hass.config.path(cache_dir) if not os.path.isdir(cache_dir): _LOGGER.info("Create cache dir %s", cache_dir) os.mkdir(cache_dir) return cache_dir
[ "def", "_init_tts_cache_dir", "(", "hass", ",", "cache_dir", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "cache_dir", ")", ":", "cache_dir", "=", "hass", ".", "config", ".", "path", "(", "cache_dir", ")", "if", "not", "os", ".", "pat...
[ 527, 0 ]
[ 534, 20 ]
python
en
['en', 'zh', 'en']
True
_get_cache_files
(cache_dir)
Return a dict of given engine files.
Return a dict of given engine files.
def _get_cache_files(cache_dir): """Return a dict of given engine files.""" cache = {} folder_data = os.listdir(cache_dir) for file_data in folder_data: record = _RE_VOICE_FILE.match(file_data) if record: key = KEY_PATTERN.format( record.group(1), record.grou...
[ "def", "_get_cache_files", "(", "cache_dir", ")", ":", "cache", "=", "{", "}", "folder_data", "=", "os", ".", "listdir", "(", "cache_dir", ")", "for", "file_data", "in", "folder_data", ":", "record", "=", "_RE_VOICE_FILE", ".", "match", "(", "file_data", "...
[ 537, 0 ]
[ 549, 16 ]
python
en
['en', 'en', 'en']
True
get_base_url
(hass)
Get base URL.
Get base URL.
def get_base_url(hass): """Get base URL.""" return hass.data[BASE_URL_KEY]
[ "def", "get_base_url", "(", "hass", ")", ":", "return", "hass", ".", "data", "[", "BASE_URL_KEY", "]" ]
[ 614, 0 ]
[ 616, 34 ]
python
en
['nl', 'jv', 'en']
False
SpeechManager.__init__
(self, hass)
Initialize a speech store.
Initialize a speech store.
def __init__(self, hass): """Initialize a speech store.""" self.hass = hass self.providers = {} self.use_cache = DEFAULT_CACHE self.cache_dir = DEFAULT_CACHE_DIR self.time_memory = DEFAULT_TIME_MEMORY self.base_url = None self.file_cache = {} self...
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "providers", "=", "{", "}", "self", ".", "use_cache", "=", "DEFAULT_CACHE", "self", ".", "cache_dir", "=", "DEFAULT_CACHE_DIR", "self", ".", "time_memor...
[ 234, 4 ]
[ 244, 27 ]
python
cs
['cs', 'lb', 'en']
False
SpeechManager.async_init_cache
(self, use_cache, cache_dir, time_memory, base_url)
Init config folder and load file cache.
Init config folder and load file cache.
async def async_init_cache(self, use_cache, cache_dir, time_memory, base_url): """Init config folder and load file cache.""" self.use_cache = use_cache self.time_memory = time_memory self.base_url = base_url try: self.cache_dir = await self.hass.async_add_executor_jo...
[ "async", "def", "async_init_cache", "(", "self", ",", "use_cache", ",", "cache_dir", ",", "time_memory", ",", "base_url", ")", ":", "self", ".", "use_cache", "=", "use_cache", "self", ".", "time_memory", "=", "time_memory", "self", ".", "base_url", "=", "bas...
[ 246, 4 ]
[ 267, 47 ]
python
en
['en', 'en', 'en']
True
SpeechManager.async_clear_cache
(self)
Read file cache and delete files.
Read file cache and delete files.
async def async_clear_cache(self): """Read file cache and delete files.""" self.mem_cache = {} def remove_files(): """Remove files from filesystem.""" for filename in self.file_cache.values(): try: os.remove(os.path.join(self.cache_dir...
[ "async", "def", "async_clear_cache", "(", "self", ")", ":", "self", ".", "mem_cache", "=", "{", "}", "def", "remove_files", "(", ")", ":", "\"\"\"Remove files from filesystem.\"\"\"", "for", "filename", "in", "self", ".", "file_cache", ".", "values", "(", ")",...
[ 269, 4 ]
[ 282, 28 ]
python
en
['en', 'it', 'en']
True
SpeechManager.async_register_engine
(self, engine, provider, config)
Register a TTS provider.
Register a TTS provider.
def async_register_engine(self, engine, provider, config): """Register a TTS provider.""" provider.hass = self.hass if provider.name is None: provider.name = engine self.providers[engine] = provider
[ "def", "async_register_engine", "(", "self", ",", "engine", ",", "provider", ",", "config", ")", ":", "provider", ".", "hass", "=", "self", ".", "hass", "if", "provider", ".", "name", "is", "None", ":", "provider", ".", "name", "=", "engine", "self", "...
[ 285, 4 ]
[ 290, 41 ]
python
en
['en', 'sv', 'en']
True
SpeechManager.async_get_url
( self, engine, message, cache=None, language=None, options=None )
Get URL for play message. This method is a coroutine.
Get URL for play message.
async def async_get_url( self, engine, message, cache=None, language=None, options=None ): """Get URL for play message. This method is a coroutine. """ provider = self.providers[engine] msg_hash = hashlib.sha1(bytes(message, "utf-8")).hexdigest() use_cache = ...
[ "async", "def", "async_get_url", "(", "self", ",", "engine", ",", "message", ",", "cache", "=", "None", ",", "language", "=", "None", ",", "options", "=", "None", ")", ":", "provider", "=", "self", ".", "providers", "[", "engine", "]", "msg_hash", "=",...
[ 292, 4 ]
[ 344, 58 ]
python
en
['en', 'en', 'en']
True
SpeechManager.async_get_tts_audio
(self, engine, key, message, cache, language, options)
Receive TTS and store for view in cache. This method is a coroutine.
Receive TTS and store for view in cache.
async def async_get_tts_audio(self, engine, key, message, cache, language, options): """Receive TTS and store for view in cache. This method is a coroutine. """ provider = self.providers[engine] extension, data = await provider.async_get_tts_audio(message, language, options) ...
[ "async", "def", "async_get_tts_audio", "(", "self", ",", "engine", ",", "key", ",", "message", ",", "cache", ",", "language", ",", "options", ")", ":", "provider", "=", "self", ".", "providers", "[", "engine", "]", "extension", ",", "data", "=", "await",...
[ 346, 4 ]
[ 373, 23 ]
python
en
['en', 'en', 'en']
True
SpeechManager.async_save_tts_audio
(self, key, filename, data)
Store voice data to file and file_cache. This method is a coroutine.
Store voice data to file and file_cache.
async def async_save_tts_audio(self, key, filename, data): """Store voice data to file and file_cache. This method is a coroutine. """ voice_file = os.path.join(self.cache_dir, filename) def save_speech(): """Store speech to filesystem.""" with open(voic...
[ "async", "def", "async_save_tts_audio", "(", "self", ",", "key", ",", "filename", ",", "data", ")", ":", "voice_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "cache_dir", ",", "filename", ")", "def", "save_speech", "(", ")", ":", "\"\"\...
[ 375, 4 ]
[ 391, 62 ]
python
en
['en', 'en', 'en']
True
SpeechManager.async_file_to_mem
(self, key)
Load voice from file cache into memory. This method is a coroutine.
Load voice from file cache into memory.
async def async_file_to_mem(self, key): """Load voice from file cache into memory. This method is a coroutine. """ filename = self.file_cache.get(key) if not filename: raise HomeAssistantError(f"Key {key} not in file cache!") voice_file = os.path.join(self.c...
[ "async", "def", "async_file_to_mem", "(", "self", ",", "key", ")", ":", "filename", "=", "self", ".", "file_cache", ".", "get", "(", "key", ")", "if", "not", "filename", ":", "raise", "HomeAssistantError", "(", "f\"Key {key} not in file cache!\"", ")", "voice_...
[ 393, 4 ]
[ 415, 58 ]
python
en
['en', 'en', 'en']
True
SpeechManager._async_store_to_memcache
(self, key, filename, data)
Store data to memcache and set timer to remove it.
Store data to memcache and set timer to remove it.
def _async_store_to_memcache(self, key, filename, data): """Store data to memcache and set timer to remove it.""" self.mem_cache[key] = {MEM_CACHE_FILENAME: filename, MEM_CACHE_VOICE: data} @callback def async_remove_from_mem(): """Cleanup memcache.""" self.mem_c...
[ "def", "_async_store_to_memcache", "(", "self", ",", "key", ",", "filename", ",", "data", ")", ":", "self", ".", "mem_cache", "[", "key", "]", "=", "{", "MEM_CACHE_FILENAME", ":", "filename", ",", "MEM_CACHE_VOICE", ":", "data", "}", "@", "callback", "def"...
[ 418, 4 ]
[ 427, 74 ]
python
en
['en', 'en', 'en']
True
SpeechManager.async_read_tts
(self, filename)
Read a voice file and return binary. This method is a coroutine.
Read a voice file and return binary.
async def async_read_tts(self, filename): """Read a voice file and return binary. This method is a coroutine. """ record = _RE_VOICE_FILE.match(filename.lower()) if not record: raise HomeAssistantError("Wrong tts file format!") key = KEY_PATTERN.format( ...
[ "async", "def", "async_read_tts", "(", "self", ",", "filename", ")", ":", "record", "=", "_RE_VOICE_FILE", ".", "match", "(", "filename", ".", "lower", "(", ")", ")", "if", "not", "record", ":", "raise", "HomeAssistantError", "(", "\"Wrong tts file format!\"",...
[ 429, 4 ]
[ 448, 60 ]
python
en
['en', 'en', 'en']
True
SpeechManager.write_tags
(filename, data, provider, message, language, options)
Write ID3 tags to file. Async friendly.
Write ID3 tags to file.
def write_tags(filename, data, provider, message, language, options): """Write ID3 tags to file. Async friendly. """ data_bytes = io.BytesIO(data) data_bytes.name = filename data_bytes.seek(0) album = provider.name artist = language if options ...
[ "def", "write_tags", "(", "filename", ",", "data", ",", "provider", ",", "message", ",", "language", ",", "options", ")", ":", "data_bytes", "=", "io", ".", "BytesIO", "(", "data", ")", "data_bytes", ".", "name", "=", "filename", "data_bytes", ".", "seek...
[ 451, 4 ]
[ 484, 36 ]
python
en
['en', 'en', 'en']
True
Provider.default_language
(self)
Return the default language.
Return the default language.
def default_language(self): """Return the default language.""" return None
[ "def", "default_language", "(", "self", ")", ":", "return", "None" ]
[ 494, 4 ]
[ 496, 19 ]
python
en
['en', 'et', 'en']
True
Provider.supported_languages
(self)
Return a list of supported languages.
Return a list of supported languages.
def supported_languages(self): """Return a list of supported languages.""" return None
[ "def", "supported_languages", "(", "self", ")", ":", "return", "None" ]
[ 499, 4 ]
[ 501, 19 ]
python
en
['en', 'en', 'en']
True
Provider.supported_options
(self)
Return a list of supported options like voice, emotionen.
Return a list of supported options like voice, emotionen.
def supported_options(self): """Return a list of supported options like voice, emotionen.""" return None
[ "def", "supported_options", "(", "self", ")", ":", "return", "None" ]
[ 504, 4 ]
[ 506, 19 ]
python
en
['en', 'en', 'en']
True
Provider.default_options
(self)
Return a dict include default options.
Return a dict include default options.
def default_options(self): """Return a dict include default options.""" return None
[ "def", "default_options", "(", "self", ")", ":", "return", "None" ]
[ 509, 4 ]
[ 511, 19 ]
python
en
['it', 'en', 'en']
True
Provider.get_tts_audio
(self, message, language, options=None)
Load tts audio file from provider.
Load tts audio file from provider.
def get_tts_audio(self, message, language, options=None): """Load tts audio file from provider.""" raise NotImplementedError()
[ "def", "get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 513, 4 ]
[ 515, 35 ]
python
en
['en', 'en', 'en']
True
Provider.async_get_tts_audio
(self, message, language, options=None)
Load tts audio file from provider. Return a tuple of file extension and data as bytes.
Load tts audio file from provider.
async def async_get_tts_audio(self, message, language, options=None): """Load tts audio file from provider. Return a tuple of file extension and data as bytes. """ return await self.hass.async_add_executor_job( ft.partial(self.get_tts_audio, message, language, options=option...
[ "async", "def", "async_get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "ft", ".", "partial", "(", "self", ".", "get_tts_audio", ...
[ 517, 4 ]
[ 524, 9 ]
python
en
['en', 'en', 'en']
True
TextToSpeechUrlView.__init__
(self, tts)
Initialize a tts view.
Initialize a tts view.
def __init__(self, tts): """Initialize a tts view.""" self.tts = tts
[ "def", "__init__", "(", "self", ",", "tts", ")", ":", "self", ".", "tts", "=", "tts" ]
[ 559, 4 ]
[ 561, 22 ]
python
en
['en', 'en', 'en']
True
TextToSpeechUrlView.post
(self, request: web.Request)
Generate speech and provide url.
Generate speech and provide url.
async def post(self, request: web.Request) -> web.Response: """Generate speech and provide url.""" try: data = await request.json() except ValueError: return self.json_message("Invalid JSON specified", HTTP_BAD_REQUEST) if not data.get(ATTR_PLATFORM) and data.get(...
[ "async", "def", "post", "(", "self", ",", "request", ":", "web", ".", "Request", ")", "->", "web", ".", "Response", ":", "try", ":", "data", "=", "await", "request", ".", "json", "(", ")", "except", "ValueError", ":", "return", "self", ".", "json_mes...
[ 563, 4 ]
[ 589, 19 ]
python
en
['en', 'en', 'en']
True
TextToSpeechView.__init__
(self, tts)
Initialize a tts view.
Initialize a tts view.
def __init__(self, tts): """Initialize a tts view.""" self.tts = tts
[ "def", "__init__", "(", "self", ",", "tts", ")", ":", "self", ".", "tts", "=", "tts" ]
[ 599, 4 ]
[ 601, 22 ]
python
en
['en', 'en', 'en']
True
TextToSpeechView.get
(self, request: web.Request, filename: str)
Start a get request.
Start a get request.
async def get(self, request: web.Request, filename: str) -> web.Response: """Start a get request.""" try: content, data = await self.tts.async_read_tts(filename) except HomeAssistantError as err: _LOGGER.error("Error on load tts: %s", err) return web.Response(...
[ "async", "def", "get", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "filename", ":", "str", ")", "->", "web", ".", "Response", ":", "try", ":", "content", ",", "data", "=", "await", "self", ".", "tts", ".", "async_read_tts", "(", "...
[ 603, 4 ]
[ 611, 60 ]
python
en
['en', 'lb', 'en']
True
test_component_dependencies
(hass)
Test if we can get the proper load order of components.
Test if we can get the proper load order of components.
async def test_component_dependencies(hass): """Test if we can get the proper load order of components.""" mock_integration(hass, MockModule("mod1")) mock_integration(hass, MockModule("mod2", ["mod1"])) mod_3 = mock_integration(hass, MockModule("mod3", ["mod2"])) assert {"mod1", "mod2", "mod3"} == ...
[ "async", "def", "test_component_dependencies", "(", "hass", ")", ":", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"mod1\"", ")", ")", "mock_integration", "(", "hass", ",", "MockModule", "(", "\"mod2\"", ",", "[", "\"mod1\"", "]", ")", ")", "mo...
[ 11, 0 ]
[ 51, 9 ]
python
en
['en', 'en', 'en']
True
test_component_loader
(hass)
Test loading components.
Test loading components.
def test_component_loader(hass): """Test loading components.""" components = loader.Components(hass) assert components.http.CONFIG_SCHEMA is http.CONFIG_SCHEMA assert hass.components.http.CONFIG_SCHEMA is http.CONFIG_SCHEMA
[ "def", "test_component_loader", "(", "hass", ")", ":", "components", "=", "loader", ".", "Components", "(", "hass", ")", "assert", "components", ".", "http", ".", "CONFIG_SCHEMA", "is", "http", ".", "CONFIG_SCHEMA", "assert", "hass", ".", "components", ".", ...
[ 54, 0 ]
[ 58, 67 ]
python
en
['de', 'en', 'en']
True