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
test_speed_to_states
()
Test speed conversion from Homekit to HA.
Test speed conversion from Homekit to HA.
def test_speed_to_states(): """Test speed conversion from Homekit to HA.""" speed_mapping = HomeKitSpeedMapping(["off", "low", "high"]) assert speed_mapping.speed_to_states(-1) == "off" assert speed_mapping.speed_to_states(0) == "off" assert speed_mapping.speed_to_states(33) == "off" assert spee...
[ "def", "test_speed_to_states", "(", ")", ":", "speed_mapping", "=", "HomeKitSpeedMapping", "(", "[", "\"off\"", ",", "\"low\"", ",", "\"high\"", "]", ")", "assert", "speed_mapping", ".", "speed_to_states", "(", "-", "1", ")", "==", "\"off\"", "assert", "speed_...
[ 297, 0 ]
[ 307, 55 ]
python
en
['en', 'en', 'en']
True
test_port_is_available
(hass)
Test we can get an available port and it is actually available.
Test we can get an available port and it is actually available.
async def test_port_is_available(hass): """Test we can get an available port and it is actually available.""" next_port = await hass.async_add_executor_job( find_next_available_port, DEFAULT_CONFIG_FLOW_PORT ) assert next_port assert await hass.async_add_executor_job(port_is_available, next...
[ "async", "def", "test_port_is_available", "(", "hass", ")", ":", "next_port", "=", "await", "hass", ".", "async_add_executor_job", "(", "find_next_available_port", ",", "DEFAULT_CONFIG_FLOW_PORT", ")", "assert", "next_port", "assert", "await", "hass", ".", "async_add_...
[ 310, 0 ]
[ 317, 74 ]
python
en
['en', 'en', 'en']
True
test_format_sw_version
()
Test format_sw_version method.
Test format_sw_version method.
async def test_format_sw_version(): """Test format_sw_version method.""" assert format_sw_version("soho+3.6.8+soho-release-rt120+10") == "3.6.8" assert format_sw_version("undefined-undefined-1.6.8") == "1.6.8" assert format_sw_version("56.0-76060") == "56.0.76060" assert format_sw_version(3.6) == "3...
[ "async", "def", "test_format_sw_version", "(", ")", ":", "assert", "format_sw_version", "(", "\"soho+3.6.8+soho-release-rt120+10\"", ")", "==", "\"3.6.8\"", "assert", "format_sw_version", "(", "\"undefined-undefined-1.6.8\"", ")", "==", "\"1.6.8\"", "assert", "format_sw_ver...
[ 320, 0 ]
[ 326, 47 ]
python
en
['en', 'da', 'en']
True
MaskedBertPreTrainedModel._init_weights
(self, module)
Initialize the weights
Initialize the weights
def _init_weights(self, module): """ Initialize the weights """ if isinstance(module, (nn.Linear, nn.Embedding)): # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 module.weight.da...
[ "def", "_init_weights", "(", "self", ",", "module", ")", ":", "if", "isinstance", "(", "module", ",", "(", "nn", ".", "Linear", ",", "nn", ".", "Embedding", ")", ")", ":", "# Slightly different from the TF version which uses truncated_normal for initialization", "# ...
[ 394, 4 ]
[ 404, 36 ]
python
en
['en', 'en', 'en']
True
get_module_by_name
(model, module_name)
Get a module specified by its module name Parameters ---------- model : pytorch model the pytorch model from which to get its module module_name : str the name of the required module Returns ------- module, module the parent module of the required module, the r...
Get a module specified by its module name
def get_module_by_name(model, module_name): """ Get a module specified by its module name Parameters ---------- model : pytorch model the pytorch model from which to get its module module_name : str the name of the required module Returns ------- module, module ...
[ "def", "get_module_by_name", "(", "model", ",", "module_name", ")", ":", "name_list", "=", "module_name", ".", "split", "(", "\".\"", ")", "for", "name", "in", "name_list", "[", ":", "-", "1", "]", ":", "if", "hasattr", "(", "model", ",", "name", ")", ...
[ 3, 0 ]
[ 29, 25 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass: HomeAssistant, config: dict)
Set up the Image integration.
Set up the Image integration.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the Image integration.""" image_dir = pathlib.Path(hass.config.path(DOMAIN)) hass.data[DOMAIN] = storage_collection = ImageStorageCollection(hass, image_dir) await storage_collection.async_load() collection.StorageCollectionWebsocke...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "image_dir", "=", "pathlib", ".", "Path", "(", "hass", ".", "config", ".", "path", "(", "DOMAIN", ")", ")", "hass", ".", "data", "[", "DOMAIN", "]...
[ 38, 0 ]
[ 53, 15 ]
python
en
['en', 'da', 'en']
True
_generate_thumbnail
(original_path, content_type, target_path, target_size)
Generate a size.
Generate a size.
def _generate_thumbnail(original_path, content_type, target_path, target_size): """Generate a size.""" image = ImageOps.exif_transpose(Image.open(original_path)) image.thumbnail(target_size) image.save(target_path, format=content_type.split("/", 1)[1])
[ "def", "_generate_thumbnail", "(", "original_path", ",", "content_type", ",", "target_path", ",", "target_size", ")", ":", "image", "=", "ImageOps", ".", "exif_transpose", "(", "Image", ".", "open", "(", "original_path", ")", ")", "image", ".", "thumbnail", "(...
[ 205, 0 ]
[ 209, 65 ]
python
en
['en', 'en', 'en']
True
ImageStorageCollection.__init__
(self, hass: HomeAssistant, image_dir: pathlib.Path)
Initialize media storage collection.
Initialize media storage collection.
def __init__(self, hass: HomeAssistant, image_dir: pathlib.Path) -> None: """Initialize media storage collection.""" super().__init__( Store(hass, STORAGE_VERSION, STORAGE_KEY), logging.getLogger(f"{__name__}.storage_collection"), ) self.async_add_listener(self._c...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "image_dir", ":", "pathlib", ".", "Path", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "Store", "(", "hass", ",", "STORAGE_VERSION", ",", "STORAGE_KEY", ")", ",...
[ 62, 4 ]
[ 69, 34 ]
python
en
['en', 'en', 'en']
True
ImageStorageCollection._process_create_data
(self, data: typing.Dict)
Validate the config is valid.
Validate the config is valid.
async def _process_create_data(self, data: typing.Dict) -> typing.Dict: """Validate the config is valid.""" data = self.CREATE_SCHEMA(dict(data)) uploaded_file: FileField = data["file"] if not uploaded_file.content_type.startswith("image/"): raise vol.Invalid("Only images ar...
[ "async", "def", "_process_create_data", "(", "self", ",", "data", ":", "typing", ".", "Dict", ")", "->", "typing", ".", "Dict", ":", "data", "=", "self", ".", "CREATE_SCHEMA", "(", "dict", "(", "data", ")", ")", "uploaded_file", ":", "FileField", "=", ...
[ 71, 4 ]
[ 86, 19 ]
python
en
['en', 'en', 'en']
True
ImageStorageCollection._get_suggested_id
(self, info: typing.Dict)
Suggest an ID based on the config.
Suggest an ID based on the config.
def _get_suggested_id(self, info: typing.Dict) -> str: """Suggest an ID based on the config.""" return info[CONF_ID]
[ "def", "_get_suggested_id", "(", "self", ",", "info", ":", "typing", ".", "Dict", ")", "->", "str", ":", "return", "info", "[", "CONF_ID", "]" ]
[ 119, 4 ]
[ 121, 28 ]
python
en
['en', 'en', 'en']
True
ImageStorageCollection._update_data
(self, data: dict, update_data: typing.Dict)
Return a new updated data object.
Return a new updated data object.
async def _update_data(self, data: dict, update_data: typing.Dict) -> typing.Dict: """Return a new updated data object.""" return {**data, **self.UPDATE_SCHEMA(update_data)}
[ "async", "def", "_update_data", "(", "self", ",", "data", ":", "dict", ",", "update_data", ":", "typing", ".", "Dict", ")", "->", "typing", ".", "Dict", ":", "return", "{", "*", "*", "data", ",", "*", "*", "self", ".", "UPDATE_SCHEMA", "(", "update_d...
[ 123, 4 ]
[ 125, 58 ]
python
en
['en', 'en', 'en']
True
ImageStorageCollection._change_listener
(self, change_type, item_id, data)
Handle change.
Handle change.
async def _change_listener(self, change_type, item_id, data): """Handle change.""" if change_type != collection.CHANGE_REMOVED: return await self.hass.async_add_executor_job(shutil.rmtree, self.image_dir / item_id)
[ "async", "def", "_change_listener", "(", "self", ",", "change_type", ",", "item_id", ",", "data", ")", ":", "if", "change_type", "!=", "collection", ".", "CHANGE_REMOVED", ":", "return", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "shutil...
[ 127, 4 ]
[ 132, 87 ]
python
en
['en', 'xh', 'en']
False
ImageUploadView.post
(self, request)
Handle upload.
Handle upload.
async def post(self, request): """Handle upload.""" # Increase max payload request._client_max_size = MAX_SIZE # pylint: disable=protected-access data = await request.post() item = await request.app["hass"].data[DOMAIN].async_create_item(data) return self.json(item)
[ "async", "def", "post", "(", "self", ",", "request", ")", ":", "# Increase max payload", "request", ".", "_client_max_size", "=", "MAX_SIZE", "# pylint: disable=protected-access", "data", "=", "await", "request", ".", "post", "(", ")", "item", "=", "await", "req...
[ 141, 4 ]
[ 148, 30 ]
python
en
['en', 'xh', 'en']
False
ImageServeView.__init__
( self, image_folder: pathlib.Path, image_collection: ImageStorageCollection )
Initialize image serve view.
Initialize image serve view.
def __init__( self, image_folder: pathlib.Path, image_collection: ImageStorageCollection ): """Initialize image serve view.""" self.transform_lock = asyncio.Lock() self.image_folder = image_folder self.image_collection = image_collection
[ "def", "__init__", "(", "self", ",", "image_folder", ":", "pathlib", ".", "Path", ",", "image_collection", ":", "ImageStorageCollection", ")", ":", "self", ".", "transform_lock", "=", "asyncio", ".", "Lock", "(", ")", "self", ".", "image_folder", "=", "image...
[ 158, 4 ]
[ 164, 48 ]
python
en
['en', 'en', 'en']
True
ImageServeView.get
(self, request: web.Request, image_id: str, filename: str)
Serve image.
Serve image.
async def get(self, request: web.Request, image_id: str, filename: str): """Serve image.""" image_size = filename.split("-", 1)[0] try: parts = image_size.split("x", 1) width = int(parts[0]) height = int(parts[1]) except (ValueError, IndexError) as err...
[ "async", "def", "get", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "image_id", ":", "str", ",", "filename", ":", "str", ")", ":", "image_size", "=", "filename", ".", "split", "(", "\"-\"", ",", "1", ")", "[", "0", "]", "try", ":...
[ 166, 4 ]
[ 202, 9 ]
python
en
['en', 'hr', 'en']
False
async_setup_ingress_view
(hass: HomeAssistantType, host: str)
Auth setup.
Auth setup.
def async_setup_ingress_view(hass: HomeAssistantType, host: str): """Auth setup.""" websession = hass.helpers.aiohttp_client.async_get_clientsession() hassio_ingress = HassIOIngress(host, websession) hass.http.register_view(hassio_ingress)
[ "def", "async_setup_ingress_view", "(", "hass", ":", "HomeAssistantType", ",", "host", ":", "str", ")", ":", "websession", "=", "hass", ".", "helpers", ".", "aiohttp_client", ".", "async_get_clientsession", "(", ")", "hassio_ingress", "=", "HassIOIngress", "(", ...
[ 22, 0 ]
[ 27, 43 ]
python
en
['en', 'haw', 'en']
False
_init_header
( request: web.Request, token: str )
Create initial header.
Create initial header.
def _init_header( request: web.Request, token: str ) -> Union[CIMultiDict, Dict[str, str]]: """Create initial header.""" headers = {} # filter flags for name, value in request.headers.items(): if name in ( hdrs.CONTENT_LENGTH, hdrs.CONTENT_ENCODING, hdrs....
[ "def", "_init_header", "(", "request", ":", "web", ".", "Request", ",", "token", ":", "str", ")", "->", "Union", "[", "CIMultiDict", ",", "Dict", "[", "str", ",", "str", "]", "]", ":", "headers", "=", "{", "}", "# filter flags", "for", "name", ",", ...
[ 161, 0 ]
[ 207, 18 ]
python
en
['en', 'gd', 'en']
True
_response_header
(response: aiohttp.ClientResponse)
Create response header.
Create response header.
def _response_header(response: aiohttp.ClientResponse) -> Dict[str, str]: """Create response header.""" headers = {} for name, value in response.headers.items(): if name in ( hdrs.TRANSFER_ENCODING, hdrs.CONTENT_LENGTH, hdrs.CONTENT_TYPE, hdrs.CONTENT...
[ "def", "_response_header", "(", "response", ":", "aiohttp", ".", "ClientResponse", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "headers", "=", "{", "}", "for", "name", ",", "value", "in", "response", ".", "headers", ".", "items", "(", ")", "...
[ 210, 0 ]
[ 224, 18 ]
python
en
['en', 'be', 'en']
True
_is_websocket
(request: web.Request)
Return True if request is a websocket.
Return True if request is a websocket.
def _is_websocket(request: web.Request) -> bool: """Return True if request is a websocket.""" headers = request.headers if ( "upgrade" in headers.get(hdrs.CONNECTION, "").lower() and headers.get(hdrs.UPGRADE, "").lower() == "websocket" ): return True return False
[ "def", "_is_websocket", "(", "request", ":", "web", ".", "Request", ")", "->", "bool", ":", "headers", "=", "request", ".", "headers", "if", "(", "\"upgrade\"", "in", "headers", ".", "get", "(", "hdrs", ".", "CONNECTION", ",", "\"\"", ")", ".", "lower"...
[ 227, 0 ]
[ 236, 16 ]
python
en
['en', 'fy', 'en']
True
_websocket_forward
(ws_from, ws_to)
Handle websocket message directly.
Handle websocket message directly.
async def _websocket_forward(ws_from, ws_to): """Handle websocket message directly.""" try: async for msg in ws_from: if msg.type == aiohttp.WSMsgType.TEXT: await ws_to.send_str(msg.data) elif msg.type == aiohttp.WSMsgType.BINARY: await ws_to.send_...
[ "async", "def", "_websocket_forward", "(", "ws_from", ",", "ws_to", ")", ":", "try", ":", "async", "for", "msg", "in", "ws_from", ":", "if", "msg", ".", "type", "==", "aiohttp", ".", "WSMsgType", ".", "TEXT", ":", "await", "ws_to", ".", "send_str", "("...
[ 239, 0 ]
[ 254, 56 ]
python
en
['en', 'xh', 'en']
True
HassIOIngress.__init__
(self, host: str, websession: aiohttp.ClientSession)
Initialize a Hass.io ingress view.
Initialize a Hass.io ingress view.
def __init__(self, host: str, websession: aiohttp.ClientSession): """Initialize a Hass.io ingress view.""" self._host = host self._websession = websession
[ "def", "__init__", "(", "self", ",", "host", ":", "str", ",", "websession", ":", "aiohttp", ".", "ClientSession", ")", ":", "self", ".", "_host", "=", "host", "self", ".", "_websession", "=", "websession" ]
[ 37, 4 ]
[ 40, 37 ]
python
en
['en', 'en', 'en']
True
HassIOIngress._create_url
(self, token: str, path: str)
Create URL to service.
Create URL to service.
def _create_url(self, token: str, path: str) -> str: """Create URL to service.""" return f"http://{self._host}/ingress/{token}/{path}"
[ "def", "_create_url", "(", "self", ",", "token", ":", "str", ",", "path", ":", "str", ")", "->", "str", ":", "return", "f\"http://{self._host}/ingress/{token}/{path}\"" ]
[ 42, 4 ]
[ 44, 60 ]
python
en
['en', 'en', 'en']
True
HassIOIngress._handle
( self, request: web.Request, token: str, path: str )
Route data to Hass.io ingress service.
Route data to Hass.io ingress service.
async def _handle( self, request: web.Request, token: str, path: str ) -> Union[web.Response, web.StreamResponse, web.WebSocketResponse]: """Route data to Hass.io ingress service.""" try: # Websocket if _is_websocket(request): return await self._handle...
[ "async", "def", "_handle", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "token", ":", "str", ",", "path", ":", "str", ")", "->", "Union", "[", "web", ".", "Response", ",", "web", ".", "StreamResponse", ",", "web", ".", "WebSocketResp...
[ 46, 4 ]
[ 61, 40 ]
python
en
['en', 'en', 'en']
True
HassIOIngress._handle_websocket
( self, request: web.Request, token: str, path: str )
Ingress route for websocket.
Ingress route for websocket.
async def _handle_websocket( self, request: web.Request, token: str, path: str ) -> web.WebSocketResponse: """Ingress route for websocket.""" if hdrs.SEC_WEBSOCKET_PROTOCOL in request.headers: req_protocols = [ str(proto.strip()) for proto in reque...
[ "async", "def", "_handle_websocket", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "token", ":", "str", ",", "path", ":", "str", ")", "->", "web", ".", "WebSocketResponse", ":", "if", "hdrs", ".", "SEC_WEBSOCKET_PROTOCOL", "in", "request", ...
[ 70, 4 ]
[ 112, 24 ]
python
en
['en', 'da', 'en']
True
HassIOIngress._handle_request
( self, request: web.Request, token: str, path: str )
Ingress route for request.
Ingress route for request.
async def _handle_request( self, request: web.Request, token: str, path: str ) -> Union[web.Response, web.StreamResponse]: """Ingress route for request.""" url = self._create_url(token, path) data = await request.read() source_header = _init_header(request, token) as...
[ "async", "def", "_handle_request", "(", "self", ",", "request", ":", "web", ".", "Request", ",", "token", ":", "str", ",", "path", ":", "str", ")", "->", "Union", "[", "web", ".", "Response", ",", "web", ".", "StreamResponse", "]", ":", "url", "=", ...
[ 114, 4 ]
[ 158, 27 ]
python
en
['en', 'en', 'en']
True
CG_BOHB.__init__
(self, configspace, min_points_in_model=None, top_n_percent=15, num_samples=64, random_fraction=1/3, bandwidth_factor=3, min_bandwidth=1e-3)
Fits for each given budget a kernel density estimator on the best N percent of the evaluated configurations on this budget. Parameters: ----------- configspace: ConfigSpace Configuration space object top_n_percent: int Determines the percentile of config...
Fits for each given budget a kernel density estimator on the best N percent of the evaluated configurations on this budget.
def __init__(self, configspace, min_points_in_model=None, top_n_percent=15, num_samples=64, random_fraction=1/3, bandwidth_factor=3, min_bandwidth=1e-3): """Fits for each given budget a kernel density estimator on the best N percent of the evaluated configurations on th...
[ "def", "__init__", "(", "self", ",", "configspace", ",", "min_points_in_model", "=", "None", ",", "top_n_percent", "=", "15", ",", "num_samples", "=", "64", ",", "random_fraction", "=", "1", "/", "3", ",", "bandwidth_factor", "=", "3", ",", "min_bandwidth", ...
[ 41, 4 ]
[ 105, 32 ]
python
en
['en', 'en', 'en']
True
CG_BOHB.sample_from_largest_budget
(self, info_dict)
We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" configurations, then prefer one with the largest l(x...
We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" configurations, then prefer one with the largest l(x...
def sample_from_largest_budget(self, info_dict): """We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" ...
[ "def", "sample_from_largest_budget", "(", "self", ",", "info_dict", ")", ":", "best", "=", "np", ".", "inf", "best_vector", "=", "None", "budget", "=", "max", "(", "self", ".", "kde_models", ".", "keys", "(", ")", ")", "l", "=", "self", ".", "kde_model...
[ 112, 4 ]
[ 199, 32 ]
python
en
['en', 'en', 'en']
True
CG_BOHB.get_config
(self, budget)
Function to sample a new configuration This function is called inside BOHB to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled Returns ------- config return a valid confi...
Function to sample a new configuration This function is called inside BOHB to query a new configuration
def get_config(self, budget): """Function to sample a new configuration This function is called inside BOHB to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled Returns ------- ...
[ "def", "get_config", "(", "self", ",", "budget", ")", ":", "logger", ".", "debug", "(", "'start sampling a new configuration.'", ")", "sample", "=", "None", "info_dict", "=", "{", "}", "# If no model is available, sample from prior", "# also mix in a fraction of random co...
[ 201, 4 ]
[ 235, 21 ]
python
en
['en', 'en', 'en']
True
CG_BOHB.new_result
(self, loss, budget, parameters, update_model=True)
Function to register finished runs. Every time a run has finished, this function should be called to register it with the loss. Parameters: ----------- loss: float the loss of the parameters budget: float the budget of the parameters para...
Function to register finished runs. Every time a run has finished, this function should be called to register it with the loss.
def new_result(self, loss, budget, parameters, update_model=True): """ Function to register finished runs. Every time a run has finished, this function should be called to register it with the loss. Parameters: ----------- loss: float the loss of the paramete...
[ "def", "new_result", "(", "self", ",", "loss", ",", "budget", ",", "parameters", ",", "update_model", "=", "True", ")", ":", "if", "loss", "is", "None", ":", "# One could skip crashed results, but we decided", "# assign a +inf loss and count them as bad configurations", ...
[ 260, 4 ]
[ 343, 65 ]
python
en
['en', 'error', 'th']
False
Model.train
(self, lr, cliprange, obs, returns, masks, actions, values, neglogpacs, states=None)
Train the model. Here we calculate advantage A(s,a) = R + yV(s') - V(s) Returns ------- obj = R + yV(s')
Train the model. Here we calculate advantage A(s,a) = R + yV(s') - V(s)
def train(self, lr, cliprange, obs, returns, masks, actions, values, neglogpacs, states=None): """ Train the model. Here we calculate advantage A(s,a) = R + yV(s') - V(s) Returns ------- obj = R + yV(s') """ advs = returns - values # ...
[ "def", "train", "(", "self", ",", "lr", ",", "cliprange", ",", "obs", ",", "returns", ",", "masks", ",", "actions", ",", "values", ",", "neglogpacs", ",", "states", "=", "None", ")", ":", "advs", "=", "returns", "-", "values", "# Normalize the advantages...
[ 119, 4 ]
[ 151, 14 ]
python
en
['en', 'error', 'th']
False
get_station_info
(station_state_file: str)
Get stations information from specified csv file. Args: station_state_file (str): File path that contains station initial state info. Returns: list: List of station information.
Get stations information from specified csv file.
def get_station_info(station_state_file: str): """Get stations information from specified csv file. Args: station_state_file (str): File path that contains station initial state info. Returns: list: List of station information. """ stations_info = [] if station_state_file.start...
[ "def", "get_station_info", "(", "station_state_file", ":", "str", ")", ":", "stations_info", "=", "[", "]", "if", "station_state_file", ".", "startswith", "(", "\"~\"", ")", ":", "station_state_file", "=", "os", ".", "path", ".", "expanduser", "(", "station_st...
[ 10, 0 ]
[ 36, 24 ]
python
en
['en', 'en', 'en']
True
test_failing_setups_no_entities
(hass, numato_fixture, monkeypatch)
When port setup fails, no entity shall be created.
When port setup fails, no entity shall be created.
async def test_failing_setups_no_entities(hass, numato_fixture, monkeypatch): """When port setup fails, no entity shall be created.""" monkeypatch.setattr(numato_fixture.NumatoDeviceMock, "setup", mockup_raise) assert await async_setup_component(hass, "numato", NUMATO_CFG) await hass.async_block_till_do...
[ "async", "def", "test_failing_setups_no_entities", "(", "hass", ",", "numato_fixture", ",", "monkeypatch", ")", ":", "monkeypatch", ".", "setattr", "(", "numato_fixture", ".", "NumatoDeviceMock", ",", "\"setup\"", ",", "mockup_raise", ")", "assert", "await", "async_...
[ 12, 0 ]
[ 18, 62 ]
python
en
['en', 'haw', 'en']
True
test_failing_sensor_update
(hass, numato_fixture, monkeypatch)
Test condition when a sensor update fails.
Test condition when a sensor update fails.
async def test_failing_sensor_update(hass, numato_fixture, monkeypatch): """Test condition when a sensor update fails.""" monkeypatch.setattr(numato_fixture.NumatoDeviceMock, "adc_read", mockup_raise) assert await async_setup_component(hass, "numato", NUMATO_CFG) await hass.async_block_till_done() a...
[ "async", "def", "test_failing_sensor_update", "(", "hass", ",", "numato_fixture", ",", "monkeypatch", ")", ":", "monkeypatch", ".", "setattr", "(", "numato_fixture", ".", "NumatoDeviceMock", ",", "\"adc_read\"", ",", "mockup_raise", ")", "assert", "await", "async_se...
[ 21, 0 ]
[ 26, 81 ]
python
en
['en', 'lb', 'en']
True
test_sensor_setup_without_discovery_info
(hass, config, numato_fixture)
Test handling of empty discovery_info.
Test handling of empty discovery_info.
async def test_sensor_setup_without_discovery_info(hass, config, numato_fixture): """Test handling of empty discovery_info.""" numato_fixture.discover() await discovery.async_load_platform(hass, "sensor", "numato", None, config) for entity_id in MOCKUP_ENTITY_IDS: assert entity_id not in hass.st...
[ "async", "def", "test_sensor_setup_without_discovery_info", "(", "hass", ",", "config", ",", "numato_fixture", ")", ":", "numato_fixture", ".", "discover", "(", ")", "await", "discovery", ".", "async_load_platform", "(", "hass", ",", "\"sensor\"", ",", "\"numato\"",...
[ 29, 0 ]
[ 37, 58 ]
python
en
['en', 'en', 'en']
True
SmappeeFlowHandler.async_oauth_create_entry
(self, data)
Create an entry for the flow.
Create an entry for the flow.
async def async_oauth_create_entry(self, data): """Create an entry for the flow.""" await self.async_set_unique_id(unique_id=f"{DOMAIN}Cloud") return self.async_create_entry(title=f"{DOMAIN}Cloud", data=data)
[ "async", "def", "async_oauth_create_entry", "(", "self", ",", "data", ")", ":", "await", "self", ".", "async_set_unique_id", "(", "unique_id", "=", "f\"{DOMAIN}Cloud\"", ")", "return", "self", ".", "async_create_entry", "(", "title", "=", "f\"{DOMAIN}Cloud\"", ","...
[ 28, 4 ]
[ 32, 73 ]
python
en
['en', 'en', 'en']
True
SmappeeFlowHandler.logger
(self)
Return logger.
Return logger.
def logger(self) -> logging.Logger: """Return logger.""" return logging.getLogger(__name__)
[ "def", "logger", "(", "self", ")", "->", "logging", ".", "Logger", ":", "return", "logging", ".", "getLogger", "(", "__name__", ")" ]
[ 35, 4 ]
[ 37, 42 ]
python
en
['es', 'no', 'en']
False
SmappeeFlowHandler.async_step_zeroconf
(self, discovery_info)
Handle zeroconf discovery.
Handle zeroconf discovery.
async def async_step_zeroconf(self, discovery_info): """Handle zeroconf discovery.""" if not discovery_info[CONF_HOSTNAME].startswith(SUPPORTED_LOCAL_DEVICES): # We currently only support Energy and Solar models (legacy) return self.async_abort(reason="invalid_mdns") se...
[ "async", "def", "async_step_zeroconf", "(", "self", ",", "discovery_info", ")", ":", "if", "not", "discovery_info", "[", "CONF_HOSTNAME", "]", ".", "startswith", "(", "SUPPORTED_LOCAL_DEVICES", ")", ":", "# We currently only support Energy and Solar models (legacy)", "ret...
[ 39, 4 ]
[ 67, 55 ]
python
de
['de', 'sr', 'en']
False
SmappeeFlowHandler.async_step_zeroconf_confirm
(self, user_input=None)
Confirm zeroconf flow.
Confirm zeroconf flow.
async def async_step_zeroconf_confirm(self, user_input=None): """Confirm zeroconf flow.""" errors = {} # Check if already configured (cloud) if self.is_cloud_device_already_added(): return self.async_abort(reason="already_configured_device") if user_input is None: ...
[ "async", "def", "async_step_zeroconf_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "# Check if already configured (cloud)", "if", "self", ".", "is_cloud_device_already_added", "(", ")", ":", "return", "self", ".", "async...
[ 69, 4 ]
[ 99, 9 ]
python
en
['eu', 'sr', 'en']
False
SmappeeFlowHandler.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" # If there is a CLOUD entry already, abort a new LOCAL entry if self.is_cloud_device_already_added(): return self.async_abort(reason="already_configured_device") return await self.a...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "# If there is a CLOUD entry already, abort a new LOCAL entry", "if", "self", ".", "is_cloud_device_already_added", "(", ")", ":", "return", "self", ".", "async_abort", "(", "rea...
[ 101, 4 ]
[ 108, 50 ]
python
en
['en', 'en', 'en']
True
SmappeeFlowHandler.async_step_environment
(self, user_input=None)
Decide environment, cloud or local.
Decide environment, cloud or local.
async def async_step_environment(self, user_input=None): """Decide environment, cloud or local.""" if user_input is None: return self.async_show_form( step_id="environment", data_schema=vol.Schema( { vol.Required("en...
[ "async", "def", "async_step_environment", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"environment\"", ",", "data_schema", "=", "vol", ".", "Sc...
[ 110, 4 ]
[ 134, 58 ]
python
en
['en', 'en', 'en']
True
SmappeeFlowHandler.async_step_local
(self, user_input=None)
Handle local flow.
Handle local flow.
async def async_step_local(self, user_input=None): """Handle local flow.""" if user_input is None: return self.async_show_form( step_id="local", data_schema=vol.Schema({vol.Required(CONF_HOST): str}), errors={}, ) # In a LOC...
[ "async", "def", "async_step_local", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"local\"", ",", "data_schema", "=", "vol", ".", "Schema", "("...
[ 136, 4 ]
[ 174, 9 ]
python
en
['en', 'en', 'en']
True
SmappeeFlowHandler.is_cloud_device_already_added
(self)
Check if a CLOUD device has already been added.
Check if a CLOUD device has already been added.
def is_cloud_device_already_added(self): """Check if a CLOUD device has already been added.""" for entry in self._async_current_entries(): if entry.unique_id is not None and entry.unique_id == f"{DOMAIN}Cloud": return True return False
[ "def", "is_cloud_device_already_added", "(", "self", ")", ":", "for", "entry", "in", "self", ".", "_async_current_entries", "(", ")", ":", "if", "entry", ".", "unique_id", "is", "not", "None", "and", "entry", ".", "unique_id", "==", "f\"{DOMAIN}Cloud\"", ":", ...
[ 176, 4 ]
[ 181, 20 ]
python
en
['en', 'en', 'en']
True
test_state_none
(hass)
Test with none state.
Test with none state.
async def test_state_none(hass): """Test with none state.""" with tempfile.TemporaryDirectory() as tempdirname: path = os.path.join(tempdirname, "switch_status") test_switch = { "command_on": f"echo 1 > {path}", "command_off": f"echo 0 > {path}", } assert ...
[ "async", "def", "test_state_none", "(", "hass", ")", ":", "with", "tempfile", ".", "TemporaryDirectory", "(", ")", "as", "tempdirname", ":", "path", "=", "os", ".", "path", ".", "join", "(", "tempdirname", ",", "\"switch_status\"", ")", "test_switch", "=", ...
[ 17, 0 ]
[ 58, 39 ]
python
en
['en', 'en', 'en']
True
test_state_value
(hass)
Test with state value.
Test with state value.
async def test_state_value(hass): """Test with state value.""" with tempfile.TemporaryDirectory() as tempdirname: path = os.path.join(tempdirname, "switch_status") test_switch = { "command_state": f"cat {path}", "command_on": f"echo 1 > {path}", "command_off":...
[ "async", "def", "test_state_value", "(", "hass", ")", ":", "with", "tempfile", ".", "TemporaryDirectory", "(", ")", "as", "tempdirname", ":", "path", "=", "os", ".", "path", ".", "join", "(", "tempdirname", ",", "\"switch_status\"", ")", "test_switch", "=", ...
[ 61, 0 ]
[ 104, 39 ]
python
en
['en', 'en', 'en']
True
test_state_json_value
(hass)
Test with state JSON value.
Test with state JSON value.
async def test_state_json_value(hass): """Test with state JSON value.""" with tempfile.TemporaryDirectory() as tempdirname: path = os.path.join(tempdirname, "switch_status") oncmd = json.dumps({"status": "ok"}) offcmd = json.dumps({"status": "nope"}) test_switch = { "...
[ "async", "def", "test_state_json_value", "(", "hass", ")", ":", "with", "tempfile", ".", "TemporaryDirectory", "(", ")", "as", "tempdirname", ":", "path", "=", "os", ".", "path", ".", "join", "(", "tempdirname", ",", "\"switch_status\"", ")", "oncmd", "=", ...
[ 107, 0 ]
[ 152, 39 ]
python
en
['en', 'en', 'en']
True
test_state_code
(hass)
Test with state code.
Test with state code.
async def test_state_code(hass): """Test with state code.""" with tempfile.TemporaryDirectory() as tempdirname: path = os.path.join(tempdirname, "switch_status") test_switch = { "command_state": f"cat {path}", "command_on": f"echo 1 > {path}", "command_off": f...
[ "async", "def", "test_state_code", "(", "hass", ")", ":", "with", "tempfile", ".", "TemporaryDirectory", "(", ")", "as", "tempdirname", ":", "path", "=", "os", ".", "path", ".", "join", "(", "tempdirname", ",", "\"switch_status\"", ")", "test_switch", "=", ...
[ 155, 0 ]
[ 197, 38 ]
python
en
['en', 'en', 'en']
True
test_assumed_state_should_be_true_if_command_state_is_none
(hass)
Test with state value.
Test with state value.
def test_assumed_state_should_be_true_if_command_state_is_none(hass): """Test with state value.""" # args: hass, device_name, friendly_name, command_on, command_off, # command_state, value_template init_args = [ hass, "test_device_name", "Test friendly name!", "echo...
[ "def", "test_assumed_state_should_be_true_if_command_state_is_none", "(", "hass", ")", ":", "# args: hass, device_name, friendly_name, command_on, command_off,", "# command_state, value_template", "init_args", "=", "[", "hass", ",", "\"test_device_name\"", ",", "\"Test friendly n...
[ 200, 0 ]
[ 222, 41 ]
python
en
['en', 'en', 'en']
True
test_entity_id_set_correctly
(hass)
Test that entity_id is set correctly from object_id.
Test that entity_id is set correctly from object_id.
def test_entity_id_set_correctly(hass): """Test that entity_id is set correctly from object_id.""" init_args = [ hass, "test_device_name", "Test friendly name!", "echo 'on command'", "echo 'off command'", False, None, 15, ] test_switch = c...
[ "def", "test_entity_id_set_correctly", "(", "hass", ")", ":", "init_args", "=", "[", "hass", ",", "\"test_device_name\"", ",", "\"Test friendly name!\"", ",", "\"echo 'on command'\"", ",", "\"echo 'off command'\"", ",", "False", ",", "None", ",", "15", ",", "]", "...
[ 225, 0 ]
[ 240, 52 ]
python
en
['en', 'en', 'en']
True
init
(empty=False)
Initialize the platform with entities.
Initialize the platform with entities.
def init(empty=False): """Initialize the platform with entities.""" global ENTITIES ENTITIES = ( [] if empty else [ MockRemote("TV", STATE_ON), MockRemote("DVD", STATE_OFF), MockRemote(None, STATE_OFF), ] )
[ "def", "init", "(", "empty", "=", "False", ")", ":", "global", "ENTITIES", "ENTITIES", "=", "(", "[", "]", "if", "empty", "else", "[", "MockRemote", "(", "\"TV\"", ",", "STATE_ON", ")", ",", "MockRemote", "(", "\"DVD\"", ",", "STATE_OFF", ")", ",", "...
[ 13, 0 ]
[ 25, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
( hass, config, async_add_entities_callback, discovery_info=None )
Return mock entities.
Return mock entities.
async def async_setup_platform( hass, config, async_add_entities_callback, discovery_info=None ): """Return mock entities.""" async_add_entities_callback(ENTITIES)
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities_callback", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities_callback", "(", "ENTITIES", ")" ]
[ 28, 0 ]
[ 32, 41 ]
python
af
['nl', 'af', 'en']
False
test_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", ...
[ 36, 0 ]
[ 43, 43 ]
python
en
['en', 'en', 'en']
True
test_import
(hass)
Test that the import works.
Test that the import works.
async def test_import(hass): """Test that the import works.""" with patch("bravia_tv.BraviaRC.connect", return_value=True), patch( "bravia_tv.BraviaRC.is_connected", return_value=True ), patch( "bravia_tv.BraviaRC.get_system_info", return_value=BRAVIA_SYSTEM_INFO ), patch( "homea...
[ "async", "def", "test_import", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"bravia_tv.BraviaRC.is_connected\"", ",", "return_value", "=", "True", ")", ",", "patch", "(...
[ 46, 0 ]
[ 66, 9 ]
python
en
['en', 'en', 'en']
True
test_import_cannot_connect
(hass)
Test that errors are shown when cannot connect to the host during import.
Test that errors are shown when cannot connect to the host during import.
async def test_import_cannot_connect(hass): """Test that errors are shown when cannot connect to the host during import.""" with patch("bravia_tv.BraviaRC.connect", return_value=True), patch( "bravia_tv.BraviaRC.is_connected", return_value=False ): result = await hass.config_entries.flow.asy...
[ "async", "def", "test_import_cannot_connect", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"bravia_tv.BraviaRC.is_connected\"", ",", "return_value", "=", "False", ")", ":",...
[ 69, 0 ]
[ 79, 51 ]
python
en
['en', 'en', 'en']
True
test_import_model_unsupported
(hass)
Test that errors are shown when the TV is not supported during import.
Test that errors are shown when the TV is not supported during import.
async def test_import_model_unsupported(hass): """Test that errors are shown when the TV is not supported during import.""" with patch("bravia_tv.BraviaRC.connect", return_value=True), patch( "bravia_tv.BraviaRC.is_connected", return_value=True ), patch("bravia_tv.BraviaRC.get_system_info", return_v...
[ "async", "def", "test_import_model_unsupported", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"bravia_tv.BraviaRC.is_connected\"", ",", "return_value", "=", "True", ")", ",...
[ 82, 0 ]
[ 92, 54 ]
python
en
['en', 'en', 'en']
True
test_import_no_ip_control
(hass)
Test that errors are shown when IP Control is disabled on the TV during import.
Test that errors are shown when IP Control is disabled on the TV during import.
async def test_import_no_ip_control(hass): """Test that errors are shown when IP Control is disabled on the TV during import.""" with patch("bravia_tv.BraviaRC.connect", side_effect=NoIPControl("No IP Control")): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": ...
[ "async", "def", "test_import_no_ip_control", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "side_effect", "=", "NoIPControl", "(", "\"No IP Control\"", ")", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".",...
[ 95, 0 ]
[ 103, 50 ]
python
en
['en', 'en', 'en']
True
test_import_duplicate_error
(hass)
Test that errors are shown when duplicates are added during import.
Test that errors are shown when duplicates are added during import.
async def test_import_duplicate_error(hass): """Test that errors are shown when duplicates are added during import.""" config_entry = MockConfigEntry( domain=DOMAIN, unique_id="very_unique_string", data={ CONF_HOST: "bravia-host", CONF_PIN: "1234", CON...
[ "async", "def", "test_import_duplicate_error", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"very_unique_string\"", ",", "data", "=", "{", "CONF_HOST", ":", "\"bravia-host\"", ",", "CONF_PIN"...
[ 106, 0 ]
[ 129, 55 ]
python
en
['en', 'en', 'en']
True
test_user_invalid_host
(hass)
Test that errors are shown when the host is invalid.
Test that errors are shown when the host is invalid.
async def test_user_invalid_host(hass): """Test that errors are shown when the host is invalid.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "invalid/host"} ) assert result["errors"] == {CONF_HOST: "invalid_host"}
[ "async", "def", "test_user_invalid_host", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ",", "data", "=", "{", ...
[ 132, 0 ]
[ 138, 58 ]
python
en
['en', 'en', 'en']
True
test_authorize_cannot_connect
(hass)
Test that errors are shown when cannot connect to host at the authorize step.
Test that errors are shown when cannot connect to host at the authorize step.
async def test_authorize_cannot_connect(hass): """Test that errors are shown when cannot connect to host at the authorize step.""" with patch("bravia_tv.BraviaRC.connect", return_value=True): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data={C...
[ "async", "def", "test_authorize_cannot_connect", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "return_value", "=", "True", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "("...
[ 141, 0 ]
[ 151, 61 ]
python
en
['en', 'en', 'en']
True
test_authorize_model_unsupported
(hass)
Test that errors are shown when the TV is not supported at the authorize step.
Test that errors are shown when the TV is not supported at the authorize step.
async def test_authorize_model_unsupported(hass): """Test that errors are shown when the TV is not supported at the authorize step.""" with patch("bravia_tv.BraviaRC.connect", return_value=True), patch( "bravia_tv.BraviaRC.is_connected", return_value=True ), patch("bravia_tv.BraviaRC.get_system_info...
[ "async", "def", "test_authorize_model_unsupported", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"bravia_tv.BraviaRC.is_connected\"", ",", "return_value", "=", "True", ")", ...
[ 154, 0 ]
[ 166, 64 ]
python
en
['en', 'en', 'en']
True
test_authorize_no_ip_control
(hass)
Test that errors are shown when IP Control is disabled on the TV.
Test that errors are shown when IP Control is disabled on the TV.
async def test_authorize_no_ip_control(hass): """Test that errors are shown when IP Control is disabled on the TV.""" with patch("bravia_tv.BraviaRC.connect", side_effect=NoIPControl("No IP Control")): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER...
[ "async", "def", "test_authorize_no_ip_control", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "side_effect", "=", "NoIPControl", "(", "\"No IP Control\"", ")", ")", ":", "result", "=", "await", "hass", ".", "config_entries", "...
[ 169, 0 ]
[ 177, 50 ]
python
en
['en', 'en', 'en']
True
test_duplicate_error
(hass)
Test that errors are shown when duplicates are added.
Test that errors are shown when duplicates are added.
async def test_duplicate_error(hass): """Test that errors are shown when duplicates are added.""" config_entry = MockConfigEntry( domain=DOMAIN, unique_id="very_unique_string", data={ CONF_HOST: "bravia-host", CONF_PIN: "1234", CONF_MAC: "AA:BB:CC:DD:E...
[ "async", "def", "test_duplicate_error", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"very_unique_string\"", ",", "data", "=", "{", "CONF_HOST", ":", "\"bravia-host\"", ",", "CONF_PIN", ":"...
[ 180, 0 ]
[ 206, 55 ]
python
en
['en', 'en', 'en']
True
test_create_entry
(hass)
Test that the user step works.
Test that the user step works.
async def test_create_entry(hass): """Test that the user step works.""" with patch("bravia_tv.BraviaRC.connect", return_value=True), patch( "bravia_tv.BraviaRC.is_connected", return_value=True ), patch( "bravia_tv.BraviaRC.get_system_info", return_value=BRAVIA_SYSTEM_INFO ), patch( ...
[ "async", "def", "test_create_entry", "(", "hass", ")", ":", "with", "patch", "(", "\"bravia_tv.BraviaRC.connect\"", ",", "return_value", "=", "True", ")", ",", "patch", "(", "\"bravia_tv.BraviaRC.is_connected\"", ",", "return_value", "=", "True", ")", ",", "patch"...
[ 209, 0 ]
[ 237, 9 ]
python
en
['en', 'en', 'en']
True
test_options_flow
(hass)
Test config flow options.
Test config flow options.
async def test_options_flow(hass): """Test config flow options.""" config_entry = MockConfigEntry( domain=DOMAIN, unique_id="very_unique_string", data={ CONF_HOST: "bravia-host", CONF_PIN: "1234", CONF_MAC: "AA:BB:CC:DD:EE:FF", }, title...
[ "async", "def", "test_options_flow", "(", "hass", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"very_unique_string\"", ",", "data", "=", "{", "CONF_HOST", ":", "\"bravia-host\"", ",", "CONF_PIN", ":", ...
[ 240, 0 ]
[ 271, 83 ]
python
en
['en', 'fr', 'en']
True
config
()
Provide a copy of the numato domain's test configuration. This helps to quickly change certain aspects of the configuration scoped to each individual test.
Provide a copy of the numato domain's test configuration.
def config(): """Provide a copy of the numato domain's test configuration. This helps to quickly change certain aspects of the configuration scoped to each individual test. """ return deepcopy(NUMATO_CFG)
[ "def", "config", "(", ")", ":", "return", "deepcopy", "(", "NUMATO_CFG", ")" ]
[ 13, 0 ]
[ 19, 31 ]
python
en
['en', 'it', 'en']
True
numato_fixture
(monkeypatch)
Inject the numato mockup into numato homeassistant module.
Inject the numato mockup into numato homeassistant module.
def numato_fixture(monkeypatch): """Inject the numato mockup into numato homeassistant module.""" module_mock = numato_mock.NumatoModuleMock() monkeypatch.setattr(numato, "gpio", module_mock) return module_mock
[ "def", "numato_fixture", "(", "monkeypatch", ")", ":", "module_mock", "=", "numato_mock", ".", "NumatoModuleMock", "(", ")", "monkeypatch", ".", "setattr", "(", "numato", ",", "\"gpio\"", ",", "module_mock", ")", "return", "module_mock" ]
[ 23, 0 ]
[ 27, 22 ]
python
en
['en', 'sm', 'en']
True
async_setup
(hass: HomeAssistant, config: dict)
Set up Nest components with dispatch between old/new flows.
Set up Nest components with dispatch between old/new flows.
async def async_setup(hass: HomeAssistant, config: dict): """Set up Nest components with dispatch between old/new flows.""" hass.data[DOMAIN] = {} if DOMAIN not in config: return True if CONF_PROJECT_ID not in config[DOMAIN]: return await async_setup_legacy(hass, config) if CONF_S...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "if", "CONF_PROJECT_ID", "not"...
[ 129, 0 ]
[ 159, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Nest from a config entry with dispatch between old/new flows.
Set up Nest from a config entry with dispatch between old/new flows.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Nest from a config entry with dispatch between old/new flows.""" if DATA_SDM not in entry.data: return await async_setup_legacy_entry(hass, entry) implementation = ( await config_entry_oauth2_flow.async_get_con...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "if", "DATA_SDM", "not", "in", "entry", ".", "data", ":", "return", "await", "async_setup_legacy_entry", "(", "hass", ",", "entry", ")", "impl...
[ 188, 0 ]
[ 234, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" if DATA_SDM not in entry.data: # Legacy API return True subscriber = hass.data[DOMAIN][entry.entry_id] subscriber.stop_async() unload_ok = all( await asyncio.gather( ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "if", "DATA_SDM", "not", "in", "entry", ".", "data", ":", "# Legacy API", "return", "True", "subscriber", "=", "hass", ".", "data", "[", "D...
[ 237, 0 ]
[ 256, 20 ]
python
en
['en', 'es', 'en']
True
nest_update_event_broker
(hass, nest)
Dispatch SIGNAL_NEST_UPDATE to devices when nest stream API received data. Used for the legacy nest API. Runs in its own thread.
Dispatch SIGNAL_NEST_UPDATE to devices when nest stream API received data.
def nest_update_event_broker(hass, nest): """ Dispatch SIGNAL_NEST_UPDATE to devices when nest stream API received data. Used for the legacy nest API. Runs in its own thread. """ _LOGGER.debug("Listening for nest.update_event") while hass.is_running: nest.update_event.wait() ...
[ "def", "nest_update_event_broker", "(", "hass", ",", "nest", ")", ":", "_LOGGER", ".", "debug", "(", "\"Listening for nest.update_event\"", ")", "while", "hass", ".", "is_running", ":", "nest", ".", "update_event", ".", "wait", "(", ")", "if", "not", "hass", ...
[ 259, 0 ]
[ 279, 57 ]
python
en
['en', 'error', 'th']
False
async_setup_legacy
(hass, config)
Set up Nest components using the legacy nest API.
Set up Nest components using the legacy nest API.
async def async_setup_legacy(hass, config): """Set up Nest components using the legacy nest API.""" if DOMAIN not in config: return True conf = config[DOMAIN] local_auth.initialize(hass, conf[CONF_CLIENT_ID], conf[CONF_CLIENT_SECRET]) filename = config.get(CONF_FILENAME, NEST_CONFIG_FILE)...
[ "async", "def", "async_setup_legacy", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "conf", "=", "config", "[", "DOMAIN", "]", "local_auth", ".", "initialize", "(", "hass", ",", "conf", "[", "CONF_CLI...
[ 282, 0 ]
[ 305, 15 ]
python
en
['en', 'zu', 'en']
True
async_setup_legacy_entry
(hass, entry)
Set up Nest from legacy config entry.
Set up Nest from legacy config entry.
async def async_setup_legacy_entry(hass, entry): """Set up Nest from legacy config entry.""" nest = Nest(access_token=entry.data["tokens"]["access_token"]) _LOGGER.debug("proceeding with setup") conf = hass.data.get(DATA_NEST_CONFIG, {}) hass.data[DATA_NEST] = NestLegacyDevice(hass, conf, nest) ...
[ "async", "def", "async_setup_legacy_entry", "(", "hass", ",", "entry", ")", ":", "nest", "=", "Nest", "(", "access_token", "=", "entry", ".", "data", "[", "\"tokens\"", "]", "[", "\"access_token\"", "]", ")", "_LOGGER", ".", "debug", "(", "\"proceeding with ...
[ 308, 0 ]
[ 439, 15 ]
python
en
['en', 'en', 'en']
True
SignalUpdateCallback.__init__
(self, hass: HomeAssistant)
Initialize EventCallback.
Initialize EventCallback.
def __init__(self, hass: HomeAssistant): """Initialize EventCallback.""" self._hass = hass
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ")", ":", "self", ".", "_hass", "=", "hass" ]
[ 165, 4 ]
[ 167, 25 ]
python
en
['en', 'zu', 'en']
False
SignalUpdateCallback.handle_event
(self, event_message: EventMessage)
Process an incoming EventMessage.
Process an incoming EventMessage.
def handle_event(self, event_message: EventMessage): """Process an incoming EventMessage.""" _LOGGER.debug("Update %s @ %s", event_message.event_id, event_message.timestamp) traits = event_message.resource_update_traits if traits: _LOGGER.debug("Trait update %s", traits.keys(...
[ "def", "handle_event", "(", "self", ",", "event_message", ":", "EventMessage", ")", ":", "_LOGGER", ".", "debug", "(", "\"Update %s @ %s\"", ",", "event_message", ".", "event_id", ",", "event_message", ".", "timestamp", ")", "traits", "=", "event_message", ".", ...
[ 169, 4 ]
[ 185, 61 ]
python
en
['en', 'en', 'en']
True
NestLegacyDevice.__init__
(self, hass, conf, nest)
Init Nest Devices.
Init Nest Devices.
def __init__(self, hass, conf, nest): """Init Nest Devices.""" self.hass = hass self.nest = nest self.local_structure = conf.get(CONF_STRUCTURE)
[ "def", "__init__", "(", "self", ",", "hass", ",", "conf", ",", "nest", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "nest", "=", "nest", "self", ".", "local_structure", "=", "conf", ".", "get", "(", "CONF_STRUCTURE", ")" ]
[ 445, 4 ]
[ 449, 55 ]
python
en
['en', 'en', 'en']
True
NestLegacyDevice.initialize
(self)
Initialize Nest.
Initialize Nest.
def initialize(self): """Initialize Nest.""" try: # Do not optimize next statement, it is here for initialize # persistence Nest API connection. structure_names = [s.name for s in self.nest.structures] if self.local_structure is None: self....
[ "def", "initialize", "(", "self", ")", ":", "try", ":", "# Do not optimize next statement, it is here for initialize", "# persistence Nest API connection.", "structure_names", "=", "[", "s", ".", "name", "for", "s", "in", "self", ".", "nest", ".", "structures", "]", ...
[ 451, 4 ]
[ 463, 19 ]
python
en
['en', 'pl', 'it']
False
NestLegacyDevice.structures
(self)
Generate a list of structures.
Generate a list of structures.
def structures(self): """Generate a list of structures.""" try: for structure in self.nest.structures: if structure.name not in self.local_structure: _LOGGER.debug( "Ignoring structure %s, not in %s", structu...
[ "def", "structures", "(", "self", ")", ":", "try", ":", "for", "structure", "in", "self", ".", "nest", ".", "structures", ":", "if", "structure", ".", "name", "not", "in", "self", ".", "local_structure", ":", "_LOGGER", ".", "debug", "(", "\"Ignoring str...
[ 465, 4 ]
[ 479, 84 ]
python
en
['en', 'en', 'en']
True
NestLegacyDevice.thermostats
(self)
Generate a list of thermostats.
Generate a list of thermostats.
def thermostats(self): """Generate a list of thermostats.""" return self._devices("thermostats")
[ "def", "thermostats", "(", "self", ")", ":", "return", "self", ".", "_devices", "(", "\"thermostats\"", ")" ]
[ 481, 4 ]
[ 483, 43 ]
python
en
['en', 'en', 'en']
True
NestLegacyDevice.smoke_co_alarms
(self)
Generate a list of smoke co alarms.
Generate a list of smoke co alarms.
def smoke_co_alarms(self): """Generate a list of smoke co alarms.""" return self._devices("smoke_co_alarms")
[ "def", "smoke_co_alarms", "(", "self", ")", ":", "return", "self", ".", "_devices", "(", "\"smoke_co_alarms\"", ")" ]
[ 485, 4 ]
[ 487, 47 ]
python
en
['en', 'en', 'en']
True
NestLegacyDevice.cameras
(self)
Generate a list of cameras.
Generate a list of cameras.
def cameras(self): """Generate a list of cameras.""" return self._devices("cameras")
[ "def", "cameras", "(", "self", ")", ":", "return", "self", ".", "_devices", "(", "\"cameras\"", ")" ]
[ 489, 4 ]
[ 491, 39 ]
python
en
['en', 'en', 'en']
True
NestLegacyDevice._devices
(self, device_type)
Generate a list of Nest devices.
Generate a list of Nest devices.
def _devices(self, device_type): """Generate a list of Nest devices.""" try: for structure in self.nest.structures: if structure.name not in self.local_structure: _LOGGER.debug( "Ignoring structure %s, not in %s", ...
[ "def", "_devices", "(", "self", ",", "device_type", ")", ":", "try", ":", "for", "structure", "in", "self", ".", "nest", ".", "structures", ":", "if", "structure", ".", "name", "not", "in", "self", ".", "local_structure", ":", "_LOGGER", ".", "debug", ...
[ 493, 4 ]
[ 521, 84 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.__init__
(self, structure, device, variable)
Initialize the sensor.
Initialize the sensor.
def __init__(self, structure, device, variable): """Initialize the sensor.""" self.structure = structure self.variable = variable if device is not None: # device specific self.device = device self._name = f"{self.device.name_long} {self.variable.repla...
[ "def", "__init__", "(", "self", ",", "structure", ",", "device", ",", "variable", ")", ":", "self", ".", "structure", "=", "structure", "self", ".", "variable", "=", "variable", "if", "device", "is", "not", "None", ":", "# device specific", "self", ".", ...
[ 527, 4 ]
[ 542, 25 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.name
(self)
Return the name of the nest, if any.
Return the name of the nest, if any.
def name(self): """Return the name of the nest, if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 545, 4 ]
[ 547, 25 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 550, 4 ]
[ 552, 25 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.should_poll
(self)
Do not need poll thanks using Nest streaming API.
Do not need poll thanks using Nest streaming API.
def should_poll(self): """Do not need poll thanks using Nest streaming API.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 555, 4 ]
[ 557, 20 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.unique_id
(self)
Return unique id based on device serial and variable.
Return unique id based on device serial and variable.
def unique_id(self): """Return unique id based on device serial and variable.""" return f"{self.device.serial}-{self.variable}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self.device.serial}-{self.variable}\"" ]
[ 560, 4 ]
[ 562, 54 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.device_info
(self)
Return information about the device.
Return information about the device.
def device_info(self): """Return information about the device.""" if not hasattr(self.device, "name_long"): name = self.structure.name model = "Structure" else: name = self.device.name_long if self.device.is_thermostat: model = "The...
[ "def", "device_info", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ".", "device", ",", "\"name_long\"", ")", ":", "name", "=", "self", ".", "structure", ".", "name", "model", "=", "\"Structure\"", "else", ":", "name", "=", "self", ".", ...
[ 565, 4 ]
[ 586, 9 ]
python
en
['en', 'en', 'en']
True
NestSensorDevice.update
(self)
Do not use NestSensorDevice directly.
Do not use NestSensorDevice directly.
def update(self): """Do not use NestSensorDevice directly.""" raise NotImplementedError
[ "def", "update", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 588, 4 ]
[ 590, 33 ]
python
en
['en', 'cs', 'en']
True
NestSensorDevice.async_added_to_hass
(self)
Register update signal handler.
Register update signal handler.
async def async_added_to_hass(self): """Register update signal handler.""" async def async_update_state(): """Update sensor state.""" await self.async_update_ha_state(True) self.async_on_remove( async_dispatcher_connect(self.hass, SIGNAL_NEST_UPDATE, async_u...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "async", "def", "async_update_state", "(", ")", ":", "\"\"\"Update sensor state.\"\"\"", "await", "self", ".", "async_update_ha_state", "(", "True", ")", "self", ".", "async_on_remove", "(", "async_dispat...
[ 592, 4 ]
[ 601, 9 ]
python
en
['en', 'lb', 'en']
True
PiHoleFlowHandler.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" return await self.async_step_init(user_input)
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_init", "(", "user_input", ")" ]
[ 35, 4 ]
[ 37, 53 ]
python
en
['en', 'en', 'en']
True
PiHoleFlowHandler.async_step_import
(self, user_input=None)
Handle a flow initiated by import.
Handle a flow initiated by import.
async def async_step_import(self, user_input=None): """Handle a flow initiated by import.""" return await self.async_step_init(user_input, is_import=True)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_init", "(", "user_input", ",", "is_import", "=", "True", ")" ]
[ 39, 4 ]
[ 41, 69 ]
python
en
['en', 'en', 'en']
True
PiHoleFlowHandler.async_step_init
(self, user_input, is_import=False)
Handle init step of a flow.
Handle init step of a flow.
async def async_step_init(self, user_input, is_import=False): """Handle init step of a flow.""" errors = {} if user_input is not None: host = ( user_input[CONF_HOST] if is_import else f"{user_input[CONF_HOST]}:{user_input[CONF_PORT]}" ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", ",", "is_import", "=", "False", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "host", "=", "(", "user_input", "[", "CONF_HOST", "]", "if", "is_import", ...
[ 43, 4 ]
[ 116, 9 ]
python
en
['en', 'en', 'en']
True
mock_requester
()
Create a mock for YandexMapsRequester.
Create a mock for YandexMapsRequester.
def mock_requester(): """Create a mock for YandexMapsRequester.""" with patch("aioymaps.YandexMapsRequester") as requester: instance = requester.return_value instance.get_stop_info = AsyncMock(return_value=REPLY) yield instance
[ "def", "mock_requester", "(", ")", ":", "with", "patch", "(", "\"aioymaps.YandexMapsRequester\"", ")", "as", "requester", ":", "instance", "=", "requester", ".", "return_value", "instance", ".", "get_stop_info", "=", "AsyncMock", "(", "return_value", "=", "REPLY",...
[ 18, 0 ]
[ 23, 22 ]
python
en
['en', 'en', 'en']
True
assert_setup_sensor
(hass, config, count=1)
Set up the sensor and assert it's been created.
Set up the sensor and assert it's been created.
async def assert_setup_sensor(hass, config, count=1): """Set up the sensor and assert it's been created.""" with assert_setup_component(count): assert await async_setup_component(hass, sensor.DOMAIN, config) await hass.async_block_till_done()
[ "async", "def", "assert_setup_sensor", "(", "hass", ",", "config", ",", "count", "=", "1", ")", ":", "with", "assert_setup_component", "(", "count", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "sensor", ".", "DOMAIN", ",", "config...
[ 49, 0 ]
[ 53, 42 ]
python
en
['en', 'en', 'en']
True
test_setup_platform_valid_config
(hass, mock_requester)
Test that sensor is set up properly with valid config.
Test that sensor is set up properly with valid config.
async def test_setup_platform_valid_config(hass, mock_requester): """Test that sensor is set up properly with valid config.""" await assert_setup_sensor(hass, TEST_CONFIG)
[ "async", "def", "test_setup_platform_valid_config", "(", "hass", ",", "mock_requester", ")", ":", "await", "assert_setup_sensor", "(", "hass", ",", "TEST_CONFIG", ")" ]
[ 56, 0 ]
[ 58, 48 ]
python
en
['en', 'en', 'en']
True
test_setup_platform_invalid_config
(hass, mock_requester)
Check an invalid configuration.
Check an invalid configuration.
async def test_setup_platform_invalid_config(hass, mock_requester): """Check an invalid configuration.""" await assert_setup_sensor( hass, {"sensor": {"platform": "yandex_transport", "stopid": 1234}}, count=0 )
[ "async", "def", "test_setup_platform_invalid_config", "(", "hass", ",", "mock_requester", ")", ":", "await", "assert_setup_sensor", "(", "hass", ",", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"yandex_transport\"", ",", "\"stopid\"", ":", "1234", "}", "}"...
[ 61, 0 ]
[ 65, 5 ]
python
en
['en', 'en', 'en']
True
test_name
(hass, mock_requester)
Return the name if set in the configuration.
Return the name if set in the configuration.
async def test_name(hass, mock_requester): """Return the name if set in the configuration.""" await assert_setup_sensor(hass, TEST_CONFIG) state = hass.states.get("sensor.test_name") assert state.name == TEST_CONFIG["sensor"][CONF_NAME]
[ "async", "def", "test_name", "(", "hass", ",", "mock_requester", ")", ":", "await", "assert_setup_sensor", "(", "hass", ",", "TEST_CONFIG", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.test_name\"", ")", "assert", "state", ".", "name"...
[ 68, 0 ]
[ 72, 57 ]
python
en
['en', 'en', 'en']
True
test_state
(hass, mock_requester)
Return the contents of _state.
Return the contents of _state.
async def test_state(hass, mock_requester): """Return the contents of _state.""" await assert_setup_sensor(hass, TEST_CONFIG) state = hass.states.get("sensor.test_name") assert state.state == RESULT_STATE
[ "async", "def", "test_state", "(", "hass", ",", "mock_requester", ")", ":", "await", "assert_setup_sensor", "(", "hass", ",", "TEST_CONFIG", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.test_name\"", ")", "assert", "state", ".", "stat...
[ 75, 0 ]
[ 79, 38 ]
python
en
['en', 'en', 'en']
True
test_filtered_attributes
(hass, mock_requester)
Return the contents of attributes.
Return the contents of attributes.
async def test_filtered_attributes(hass, mock_requester): """Return the contents of attributes.""" await assert_setup_sensor(hass, TEST_CONFIG) state = hass.states.get("sensor.test_name") state_attrs = {key: state.attributes[key] for key in FILTERED_ATTRS} assert state_attrs == FILTERED_ATTRS
[ "async", "def", "test_filtered_attributes", "(", "hass", ",", "mock_requester", ")", ":", "await", "assert_setup_sensor", "(", "hass", ",", "TEST_CONFIG", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.test_name\"", ")", "state_attrs", "=",...
[ 82, 0 ]
[ 87, 40 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up Eufy switches.
Set up Eufy switches.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up Eufy switches.""" if discovery_info is None: return add_entities([EufySwitch(discovery_info)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "add_entities", "(", "[", "EufySwitch", "(", "discovery_info", ")", "]", ",", "True",...
[ 6, 0 ]
[ 10, 52 ]
python
en
['en', 'zu', 'en']
True
EufySwitch.__init__
(self, device)
Initialize the light.
Initialize the light.
def __init__(self, device): """Initialize the light.""" self._state = None self._name = device["name"] self._address = device["address"] self._code = device["code"] self._type = device["type"] self._switch = lakeside.switch(self._address, self._code, self._type) ...
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_name", "=", "device", "[", "\"name\"", "]", "self", ".", "_address", "=", "device", "[", "\"address\"", "]", "self", ".", "_code", "=", "devic...
[ 16, 4 ]
[ 25, 30 ]
python
en
['en', 'en', 'en']
True