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
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the ZoneMinder sensor platform.
Set up the ZoneMinder sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ZoneMinder sensor platform.""" include_archived = config.get(CONF_INCLUDE_ARCHIVED) sensors = [] for zm_client in hass.data[ZONEMINDER_DOMAIN].values(): monitors = zm_client.get_monitors() if not monitors...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "include_archived", "=", "config", ".", "get", "(", "CONF_INCLUDE_ARCHIVED", ")", "sensors", "=", "[", "]", "for", "zm_client", "in", "has...
[ 39, 0 ]
[ 56, 25 ]
python
en
['en', 'da', 'en']
True
ZMSensorMonitors.__init__
(self, monitor)
Initialize monitor sensor.
Initialize monitor sensor.
def __init__(self, monitor): """Initialize monitor sensor.""" self._monitor = monitor self._state = None self._is_available = None
[ "def", "__init__", "(", "self", ",", "monitor", ")", ":", "self", ".", "_monitor", "=", "monitor", "self", ".", "_state", "=", "None", "self", ".", "_is_available", "=", "None" ]
[ 62, 4 ]
[ 66, 33 ]
python
en
['en', 'zu', 'it']
False
ZMSensorMonitors.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"{self._monitor.name} Status"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._monitor.name} Status\"" ]
[ 69, 4 ]
[ 71, 45 ]
python
en
['en', 'mi', 'en']
True
ZMSensorMonitors.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 74, 4 ]
[ 76, 26 ]
python
en
['en', 'en', 'en']
True
ZMSensorMonitors.available
(self)
Return True if Monitor is available.
Return True if Monitor is available.
def available(self): """Return True if Monitor is available.""" return self._is_available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_is_available" ]
[ 79, 4 ]
[ 81, 33 ]
python
en
['en', 'en', 'en']
True
ZMSensorMonitors.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" state = self._monitor.function if not state: self._state = None else: self._state = state.value self._is_available = self._monitor.is_available
[ "def", "update", "(", "self", ")", ":", "state", "=", "self", ".", "_monitor", ".", "function", "if", "not", "state", ":", "self", ".", "_state", "=", "None", "else", ":", "self", ".", "_state", "=", "state", ".", "value", "self", ".", "_is_available...
[ 83, 4 ]
[ 90, 55 ]
python
en
['en', 'nl', 'en']
True
ZMSensorEvents.__init__
(self, monitor, include_archived, sensor_type)
Initialize event sensor.
Initialize event sensor.
def __init__(self, monitor, include_archived, sensor_type): """Initialize event sensor.""" self._monitor = monitor self._include_archived = include_archived self.time_period = TimePeriod.get_time_period(sensor_type) self._state = None
[ "def", "__init__", "(", "self", ",", "monitor", ",", "include_archived", ",", "sensor_type", ")", ":", "self", ".", "_monitor", "=", "monitor", "self", ".", "_include_archived", "=", "include_archived", "self", ".", "time_period", "=", "TimePeriod", ".", "get_...
[ 96, 4 ]
[ 102, 26 ]
python
en
['en', 'pt', 'en']
True
ZMSensorEvents.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"{self._monitor.name} {self.time_period.title}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._monitor.name} {self.time_period.title}\"" ]
[ 105, 4 ]
[ 107, 63 ]
python
en
['en', 'mi', 'en']
True
ZMSensorEvents.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return "Events"
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "\"Events\"" ]
[ 110, 4 ]
[ 112, 23 ]
python
en
['en', 'en', 'en']
True
ZMSensorEvents.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 115, 4 ]
[ 117, 26 ]
python
en
['en', 'en', 'en']
True
ZMSensorEvents.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" self._state = self._monitor.get_events(self.time_period, self._include_archived)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_state", "=", "self", ".", "_monitor", ".", "get_events", "(", "self", ".", "time_period", ",", "self", ".", "_include_archived", ")" ]
[ 119, 4 ]
[ 121, 88 ]
python
en
['en', 'nl', 'en']
True
ZMSensorRunState.__init__
(self, client)
Initialize run state sensor.
Initialize run state sensor.
def __init__(self, client): """Initialize run state sensor.""" self._state = None self._is_available = None self._client = client
[ "def", "__init__", "(", "self", ",", "client", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_is_available", "=", "None", "self", ".", "_client", "=", "client" ]
[ 127, 4 ]
[ 131, 29 ]
python
co
['ro', 'co', 'en']
False
ZMSensorRunState.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return "Run State"
[ "def", "name", "(", "self", ")", ":", "return", "\"Run State\"" ]
[ 134, 4 ]
[ 136, 26 ]
python
en
['en', 'mi', 'en']
True
ZMSensorRunState.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 139, 4 ]
[ 141, 26 ]
python
en
['en', 'en', 'en']
True
ZMSensorRunState.available
(self)
Return True if ZoneMinder is available.
Return True if ZoneMinder is available.
def available(self): """Return True if ZoneMinder is available.""" return self._is_available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_is_available" ]
[ 144, 4 ]
[ 146, 33 ]
python
en
['en', 'en', 'en']
True
ZMSensorRunState.update
(self)
Update the sensor.
Update the sensor.
def update(self): """Update the sensor.""" self._state = self._client.get_active_state() self._is_available = self._client.is_available
[ "def", "update", "(", "self", ")", ":", "self", ".", "_state", "=", "self", ".", "_client", ".", "get_active_state", "(", ")", "self", ".", "_is_available", "=", "self", ".", "_client", ".", "is_available" ]
[ 148, 4 ]
[ 151, 54 ]
python
en
['en', 'nl', 'en']
True
mock_supervisor_fixture
()
Mock Supervisor.
Mock Supervisor.
def mock_supervisor_fixture(): """Mock Supervisor.""" with patch("homeassistant.components.hassio.is_hassio", return_value=True): yield
[ "def", "mock_supervisor_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.hassio.is_hassio\"", ",", "return_value", "=", "True", ")", ":", "yield" ]
[ 13, 0 ]
[ 16, 13 ]
python
en
['es', 'no', 'en']
False
mock_addon_info
()
Mock Supervisor add-on info.
Mock Supervisor add-on info.
def mock_addon_info(): """Mock Supervisor add-on info.""" with patch("homeassistant.components.hassio.async_get_addon_info") as addon_info: addon_info.return_value = {} yield addon_info
[ "def", "mock_addon_info", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.hassio.async_get_addon_info\"", ")", "as", "addon_info", ":", "addon_info", ".", "return_value", "=", "{", "}", "yield", "addon_info" ]
[ 20, 0 ]
[ 24, 24 ]
python
en
['es', 'no', 'en']
False
mock_addon_running
(addon_info)
Mock add-on already running.
Mock add-on already running.
def mock_addon_running(addon_info): """Mock add-on already running.""" addon_info.return_value["state"] = "started" return addon_info
[ "def", "mock_addon_running", "(", "addon_info", ")", ":", "addon_info", ".", "return_value", "[", "\"state\"", "]", "=", "\"started\"", "return", "addon_info" ]
[ 28, 0 ]
[ 31, 21 ]
python
en
['en', 'cy', 'en']
True
mock_addon_installed
(addon_info)
Mock add-on already installed but not running.
Mock add-on already installed but not running.
def mock_addon_installed(addon_info): """Mock add-on already installed but not running.""" addon_info.return_value["state"] = "stopped" addon_info.return_value["version"] = "1.0" return addon_info
[ "def", "mock_addon_installed", "(", "addon_info", ")", ":", "addon_info", ".", "return_value", "[", "\"state\"", "]", "=", "\"stopped\"", "addon_info", ".", "return_value", "[", "\"version\"", "]", "=", "\"1.0\"", "return", "addon_info" ]
[ 35, 0 ]
[ 39, 21 ]
python
en
['en', 'en', 'en']
True
mock_addon_options
(addon_info)
Mock add-on options.
Mock add-on options.
def mock_addon_options(addon_info): """Mock add-on options.""" addon_info.return_value["options"] = {} return addon_info
[ "def", "mock_addon_options", "(", "addon_info", ")", ":", "addon_info", ".", "return_value", "[", "\"options\"", "]", "=", "{", "}", "return", "addon_info" ]
[ 43, 0 ]
[ 46, 21 ]
python
en
['en', 'bg', 'en']
True
mock_set_addon_options
()
Mock set add-on options.
Mock set add-on options.
def mock_set_addon_options(): """Mock set add-on options.""" with patch( "homeassistant.components.hassio.async_set_addon_options" ) as set_options: yield set_options
[ "def", "mock_set_addon_options", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.hassio.async_set_addon_options\"", ")", "as", "set_options", ":", "yield", "set_options" ]
[ 50, 0 ]
[ 55, 25 ]
python
en
['en', 'et', 'en']
True
mock_install_addon
()
Mock install add-on.
Mock install add-on.
def mock_install_addon(): """Mock install add-on.""" with patch("homeassistant.components.hassio.async_install_addon") as install_addon: yield install_addon
[ "def", "mock_install_addon", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.hassio.async_install_addon\"", ")", "as", "install_addon", ":", "yield", "install_addon" ]
[ 59, 0 ]
[ 62, 27 ]
python
en
['en', 'cy', 'en']
True
mock_start_addon
()
Mock start add-on.
Mock start add-on.
def mock_start_addon(): """Mock start add-on.""" with patch("homeassistant.components.hassio.async_start_addon") as start_addon: yield start_addon
[ "def", "mock_start_addon", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.hassio.async_start_addon\"", ")", "as", "start_addon", ":", "yield", "start_addon" ]
[ 66, 0 ]
[ 69, 25 ]
python
en
['en', 'fy', 'en']
True
test_user_not_supervisor_create_entry
(hass)
Test the user step creates an entry not on Supervisor.
Test the user step creates an entry not on Supervisor.
async def test_user_not_supervisor_create_entry(hass): """Test the user step creates an entry not on Supervisor.""" hass.config.components.add("mqtt") await setup.async_setup_component(hass, "persistent_notification", {}) with patch( "homeassistant.components.ozw.async_setup", return_value=True...
[ "async", "def", "test_user_not_supervisor_create_entry", "(", "hass", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", ...
[ 72, 0 ]
[ 97, 48 ]
python
en
['en', 'en', 'en']
True
test_mqtt_not_setup
(hass)
Test that mqtt is required.
Test that mqtt is required.
async def test_mqtt_not_setup(hass): """Test that mqtt is required.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "abort" assert result["reason"] == "mqtt_required"
[ "async", "def", "test_mqtt_not_setup", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")", ...
[ 100, 0 ]
[ 106, 46 ]
python
en
['en', 'en', 'en']
True
test_one_instance_allowed
(hass)
Test that only one instance is allowed.
Test that only one instance is allowed.
async def test_one_instance_allowed(hass): """Test that only one instance is allowed.""" entry = MockConfigEntry(domain=DOMAIN, data={}, title=TITLE) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) asse...
[ "async", "def", "test_one_instance_allowed", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "data", "=", "{", "}", ",", "title", "=", "TITLE", ")", "entry", ".", "add_to_hass", "(", "hass", ")", "result", "=", ...
[ 109, 0 ]
[ 118, 56 ]
python
en
['en', 'en', 'en']
True
test_not_addon
(hass, supervisor)
Test opting out of add-on on Supervisor.
Test opting out of add-on on Supervisor.
async def test_not_addon(hass, supervisor): """Test opting out of add-on on Supervisor.""" hass.config.components.add("mqtt") await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOUR...
[ "async", "def", "test_not_addon", "(", "hass", ",", "supervisor", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", ...
[ 121, 0 ]
[ 150, 48 ]
python
en
['en', 'en', 'en']
True
test_addon_running
(hass, supervisor, addon_running)
Test add-on already running on Supervisor.
Test add-on already running on Supervisor.
async def test_addon_running(hass, supervisor, addon_running): """Test add-on already running on Supervisor.""" hass.config.components.add("mqtt") await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source"...
[ "async", "def", "test_addon_running", "(", "hass", ",", "supervisor", ",", "addon_running", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_no...
[ 153, 0 ]
[ 182, 48 ]
python
en
['en', 'fi', 'en']
True
test_addon_info_failure
(hass, supervisor, addon_info)
Test add-on info failure.
Test add-on info failure.
async def test_addon_info_failure(hass, supervisor, addon_info): """Test add-on info failure.""" hass.config.components.add("mqtt") addon_info.side_effect = HassioAPIError() await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( ...
[ "async", "def", "test_addon_info_failure", "(", "hass", ",", "supervisor", ",", "addon_info", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "addon_info", ".", "side_effect", "=", "HassioAPIError", "(", ")", "await", "s...
[ 185, 0 ]
[ 200, 50 ]
python
de
['ms', 'de', 'en']
False
test_addon_installed
( hass, supervisor, addon_installed, addon_options, set_addon_options, start_addon )
Test add-on already installed but not running on Supervisor.
Test add-on already installed but not running on Supervisor.
async def test_addon_installed( hass, supervisor, addon_installed, addon_options, set_addon_options, start_addon ): """Test add-on already installed but not running on Supervisor.""" hass.config.components.add("mqtt") await setup.async_setup_component(hass, "persistent_notification", {}) result = a...
[ "async", "def", "test_addon_installed", "(", "hass", ",", "supervisor", ",", "addon_installed", ",", "addon_options", ",", "set_addon_options", ",", "start_addon", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "await", "...
[ 203, 0 ]
[ 237, 48 ]
python
en
['en', 'en', 'en']
True
test_set_addon_config_failure
( hass, supervisor, addon_installed, addon_options, set_addon_options )
Test add-on set config failure.
Test add-on set config failure.
async def test_set_addon_config_failure( hass, supervisor, addon_installed, addon_options, set_addon_options ): """Test add-on set config failure.""" hass.config.components.add("mqtt") set_addon_options.side_effect = HassioAPIError() await setup.async_setup_component(hass, "persistent_notification",...
[ "async", "def", "test_set_addon_config_failure", "(", "hass", ",", "supervisor", ",", "addon_installed", ",", "addon_options", ",", "set_addon_options", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "set_addon_options", ".",...
[ 240, 0 ]
[ 260, 56 ]
python
en
['en', 'cy', 'en']
True
test_start_addon_failure
( hass, supervisor, addon_installed, addon_options, set_addon_options, start_addon )
Test add-on start failure.
Test add-on start failure.
async def test_start_addon_failure( hass, supervisor, addon_installed, addon_options, set_addon_options, start_addon ): """Test add-on start failure.""" hass.config.components.add("mqtt") start_addon.side_effect = HassioAPIError() await setup.async_setup_component(hass, "persistent_notification", {}...
[ "async", "def", "test_start_addon_failure", "(", "hass", ",", "supervisor", ",", "addon_installed", ",", "addon_options", ",", "set_addon_options", ",", "start_addon", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "start_a...
[ 263, 0 ]
[ 283, 61 ]
python
de
['ms', 'de', 'en']
False
test_addon_not_installed
( hass, supervisor, addon_installed, install_addon, addon_options, set_addon_options, start_addon, )
Test add-on not installed.
Test add-on not installed.
async def test_addon_not_installed( hass, supervisor, addon_installed, install_addon, addon_options, set_addon_options, start_addon, ): """Test add-on not installed.""" hass.config.components.add("mqtt") addon_installed.return_value["version"] = None await setup.async_setup_c...
[ "async", "def", "test_addon_not_installed", "(", "hass", ",", "supervisor", ",", "addon_installed", ",", "install_addon", ",", "addon_options", ",", "set_addon_options", ",", "start_addon", ",", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "("...
[ 286, 0 ]
[ 327, 48 ]
python
en
['en', 'en', 'en']
True
test_install_addon_failure
(hass, supervisor, addon_installed, install_addon)
Test add-on install failure.
Test add-on install failure.
async def test_install_addon_failure(hass, supervisor, addon_installed, install_addon): """Test add-on install failure.""" hass.config.components.add("mqtt") addon_installed.return_value["version"] = None install_addon.side_effect = HassioAPIError() await setup.async_setup_component(hass, "persisten...
[ "async", "def", "test_install_addon_failure", "(", "hass", ",", "supervisor", ",", "addon_installed", ",", "install_addon", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "addon_installed", ".", "return_value", "[", "\"vers...
[ 330, 0 ]
[ 345, 53 ]
python
en
['en', 'cy', 'en']
True
Party.play_next_track
(self)
Dequeue the next song and play it
Dequeue the next song and play it
def play_next_track(self): """ Dequeue the next song and play it """ next_track_entry = self.dequeue_next_song() if next_track_entry: self.play_track(next_track_entry.track_key, next_track_entry.submitter) else: self.skip_stop() self.clear_skippers()
[ "def", "play_next_track", "(", "self", ")", ":", "next_track_entry", "=", "self", ".", "dequeue_next_song", "(", ")", "if", "next_track_entry", ":", "self", ".", "play_track", "(", "next_track_entry", ".", "track_key", ",", "next_track_entry", ".", "submitter", ...
[ 136, 2 ]
[ 143, 25 ]
python
en
['en', 'en', 'en']
True
Party.clear_skippers
(self)
GILLIGANNNNNN!!!
GILLIGANNNNNN!!!
def clear_skippers(self): """GILLIGANNNNNN!!!""" self.skippers = set()
[ "def", "clear_skippers", "(", "self", ")", ":", "self", ".", "skippers", "=", "set", "(", ")" ]
[ 145, 2 ]
[ 147, 25 ]
python
en
['en', 'is', 'it']
False
mock_path
()
Mock path lib.
Mock path lib.
def mock_path(): """Mock path lib.""" with patch("homeassistant.components.freebox.router.Path"): yield
[ "def", "mock_path", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.freebox.router.Path\"", ")", ":", "yield" ]
[ 7, 0 ]
[ 10, 13 ]
python
en
['en', 'uk', 'en']
True
Batman_Transit.initialize_model
(self, mc, **kwargs)
Initialization with random transit parameters
Initialization with random transit parameters
def initialize_model(self, mc, **kwargs): if mc.common_models[self.planet_ref].use_semimajor_axis: """ a is the semi-major axis (in units of stellar radii) """ self.list_pams_common.update({'a': None}) self.use_semimajor_axis = True else: """ rho is the d...
[ "def", "initialize_model", "(", "self", ",", "mc", ",", "*", "*", "kwargs", ")", ":", "if", "mc", ".", "common_models", "[", "self", ".", "planet_ref", "]", ".", "use_semimajor_axis", ":", "\"\"\" a is the semi-major axis (in units of stellar radii) \"\"\"", "self",...
[ 56, 4 ]
[ 110, 60 ]
python
en
['en', 'en', 'en']
True
Batman_Transit.compute
(self, variable_value, dataset, x0_input=None)
:param variable_value: :param dataset: :param x0_input: :return:
:param variable_value: :param dataset: :param x0_input: :return:
def compute(self, variable_value, dataset, x0_input=None): """ :param variable_value: :param dataset: :param x0_input: :return: """ if self.use_semimajor_axis: # semi-major axis (in units of stellar radii) self.batman_params.a = variable_v...
[ "def", "compute", "(", "self", ",", "variable_value", ",", "dataset", ",", "x0_input", "=", "None", ")", ":", "if", "self", ".", "use_semimajor_axis", ":", "# semi-major axis (in units of stellar radii)", "self", ".", "batman_params", ".", "a", "=", "variable_valu...
[ 135, 4 ]
[ 217, 71 ]
python
en
['en', 'error', 'th']
False
check_translations_directory_name
(integration: Integration)
Check that the correct name is used for the translations directory.
Check that the correct name is used for the translations directory.
def check_translations_directory_name(integration: Integration) -> None: """Check that the correct name is used for the translations directory.""" legacy_translations = integration.path / ".translations" translations = integration.path / "translations" if translations.is_dir(): # No action requ...
[ "def", "check_translations_directory_name", "(", "integration", ":", "Integration", ")", "->", "None", ":", "legacy_translations", "=", "integration", ".", "path", "/", "\".translations\"", "translations", "=", "integration", ".", "path", "/", "\"translations\"", "if"...
[ 36, 0 ]
[ 46, 79 ]
python
en
['en', 'en', 'en']
True
find_references
(strings, prefix, found)
Find references.
Find references.
def find_references(strings, prefix, found): """Find references.""" for key, value in strings.items(): if isinstance(value, dict): find_references(value, f"{prefix}::{key}", found) continue match = re.match(RE_REFERENCE, value) if match: found.append...
[ "def", "find_references", "(", "strings", ",", "prefix", ",", "found", ")", ":", "for", "key", ",", "value", "in", "strings", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "find_references", "(", "value", ",", ...
[ 49, 0 ]
[ 59, 82 ]
python
en
['en', 'da', 'en']
False
removed_title_validator
(config, integration, value)
Mark removed title.
Mark removed title.
def removed_title_validator(config, integration, value): """Mark removed title.""" if not config.specific_integrations: raise vol.Invalid(REMOVED_TITLE_MSG) # Don't mark it as an error yet for custom components to allow backwards compat. integration.add_warning("translations", REMOVED_TITLE_MSG...
[ "def", "removed_title_validator", "(", "config", ",", "integration", ",", "value", ")", ":", "if", "not", "config", ".", "specific_integrations", ":", "raise", "vol", ".", "Invalid", "(", "REMOVED_TITLE_MSG", ")", "# Don't mark it as an error yet for custom components t...
[ 62, 0 ]
[ 69, 16 ]
python
en
['en', 'en', 'en']
True
lowercase_validator
(value)
Validate value is lowercase.
Validate value is lowercase.
def lowercase_validator(value): """Validate value is lowercase.""" if value.lower() != value: raise vol.Invalid("Needs to be lowercase") return value
[ "def", "lowercase_validator", "(", "value", ")", ":", "if", "value", ".", "lower", "(", ")", "!=", "value", ":", "raise", "vol", ".", "Invalid", "(", "\"Needs to be lowercase\"", ")", "return", "value" ]
[ 72, 0 ]
[ 77, 16 ]
python
en
['en', 'en', 'en']
True
gen_data_entry_schema
( *, config: Config, integration: Integration, flow_title: int, require_step_title: bool, )
Generate a data entry schema.
Generate a data entry schema.
def gen_data_entry_schema( *, config: Config, integration: Integration, flow_title: int, require_step_title: bool, ): """Generate a data entry schema.""" step_title_class = vol.Required if require_step_title else vol.Optional schema = { vol.Optional("flow_title"): cv.string_with_...
[ "def", "gen_data_entry_schema", "(", "*", ",", "config", ":", "Config", ",", "integration", ":", "Integration", ",", "flow_title", ":", "int", ",", "require_step_title", ":", "bool", ",", ")", ":", "step_title_class", "=", "vol", ".", "Required", "if", "requ...
[ 80, 0 ]
[ 110, 17 ]
python
en
['en', 'de', 'en']
True
gen_strings_schema
(config: Config, integration: Integration)
Generate a strings schema.
Generate a strings schema.
def gen_strings_schema(config: Config, integration: Integration): """Generate a strings schema.""" return vol.Schema( { vol.Optional("title"): cv.string_with_no_html, vol.Optional("config"): gen_data_entry_schema( config=config, integration=integra...
[ "def", "gen_strings_schema", "(", "config", ":", "Config", ",", "integration", ":", "Integration", ")", ":", "return", "vol", ".", "Schema", "(", "{", "vol", ".", "Optional", "(", "\"title\"", ")", ":", "cv", ".", "string_with_no_html", ",", "vol", ".", ...
[ 113, 0 ]
[ 144, 5 ]
python
co
['en', 'co', 'it']
False
gen_auth_schema
(config: Config, integration: Integration)
Generate auth schema.
Generate auth schema.
def gen_auth_schema(config: Config, integration: Integration): """Generate auth schema.""" return vol.Schema( { vol.Optional("mfa_setup"): { str: gen_data_entry_schema( config=config, integration=integration, flow_ti...
[ "def", "gen_auth_schema", "(", "config", ":", "Config", ",", "integration", ":", "Integration", ")", ":", "return", "vol", ".", "Schema", "(", "{", "vol", ".", "Optional", "(", "\"mfa_setup\"", ")", ":", "{", "str", ":", "gen_data_entry_schema", "(", "conf...
[ 147, 0 ]
[ 160, 5 ]
python
de
['de', 'de', 'it']
True
gen_platform_strings_schema
(config: Config, integration: Integration)
Generate platform strings schema like strings.sensor.json. Example of valid data: { "state": { "moon__phase": { "full": "Full" } } }
Generate platform strings schema like strings.sensor.json.
def gen_platform_strings_schema(config: Config, integration: Integration): """Generate platform strings schema like strings.sensor.json. Example of valid data: { "state": { "moon__phase": { "full": "Full" } } } """ def device_class_valida...
[ "def", "gen_platform_strings_schema", "(", "config", ":", "Config", ",", "integration", ":", "Integration", ")", ":", "def", "device_class_validator", "(", "value", ")", ":", "\"\"\"Key validator for platorm states.\n\n Platform states are only allowed to provide states fo...
[ 163, 0 ]
[ 203, 5 ]
python
en
['nl', 'fy', 'en']
False
validate_translation_file
(config: Config, integration: Integration, all_strings)
Validate translation files for integration.
Validate translation files for integration.
def validate_translation_file(config: Config, integration: Integration, all_strings): """Validate translation files for integration.""" if config.specific_integrations: check_translations_directory_name(integration) strings_files = [integration.path / "strings.json"] # Also validate translatio...
[ "def", "validate_translation_file", "(", "config", ":", "Config", ",", "integration", ":", "Integration", ",", "all_strings", ")", ":", "if", "config", ".", "specific_integrations", ":", "check_translations_directory_name", "(", "integration", ")", "strings_files", "=...
[ 209, 0 ]
[ 294, 13 ]
python
en
['en', 'da', 'en']
True
validate
(integrations: Dict[str, Integration], config: Config)
Handle JSON files inside integrations.
Handle JSON files inside integrations.
def validate(integrations: Dict[str, Integration], config: Config): """Handle JSON files inside integrations.""" if config.specific_integrations: all_strings = None else: all_strings = upload.generate_upload_data() for integration in integrations.values(): validate_translation_f...
[ "def", "validate", "(", "integrations", ":", "Dict", "[", "str", ",", "Integration", "]", ",", "config", ":", "Config", ")", ":", "if", "config", ".", "specific_integrations", ":", "all_strings", "=", "None", "else", ":", "all_strings", "=", "upload", ".",...
[ 297, 0 ]
[ 305, 67 ]
python
en
['en', 'da', 'en']
True
FBNetTrainer.__init__
( self, model, model_optim, criterion, device, device_ids, lookup_table, train_loader, valid_loader, n_epochs=120, load_ckpt=False, arch_path=None, logger=None, )
Parameters ---------- model : pytorch model the user model, which has mutables model_optim : pytorch optimizer the user defined optimizer criterion : pytorch loss the main task loss, nn.CrossEntropyLoss() is for classification device :...
Parameters ---------- model : pytorch model the user model, which has mutables model_optim : pytorch optimizer the user defined optimizer criterion : pytorch loss the main task loss, nn.CrossEntropyLoss() is for classification device :...
def __init__( self, model, model_optim, criterion, device, device_ids, lookup_table, train_loader, valid_loader, n_epochs=120, load_ckpt=False, arch_path=None, logger=None, ): """ Parameters ...
[ "def", "__init__", "(", "self", ",", "model", ",", "model_optim", ",", "criterion", ",", "device", ",", "device_ids", ",", "lookup_table", ",", "train_loader", ",", "valid_loader", ",", "n_epochs", "=", "120", ",", "load_ckpt", "=", "False", ",", "arch_path"...
[ 21, 4 ]
[ 104, 22 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer._layer_choice_sample
(self)
Sample the index of network within layer choice
Sample the index of network within layer choice
def _layer_choice_sample(self): """ Sample the index of network within layer choice """ stages = [stage_name for stage_name in self.lookup_table.layer_num] stage_lnum = [self.lookup_table.layer_num[stage] for stage in stages] # get the choice idx in each layer ch...
[ "def", "_layer_choice_sample", "(", "self", ")", ":", "stages", "=", "[", "stage_name", "for", "stage_name", "in", "self", ".", "lookup_table", ".", "layer_num", "]", "stage_lnum", "=", "[", "self", ".", "lookup_table", ".", "layer_num", "[", "stage", "]", ...
[ 106, 4 ]
[ 136, 27 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer._get_perf_cost
(self, requires_grad=True)
Get the accumulated performance cost.
Get the accumulated performance cost.
def _get_perf_cost(self, requires_grad=True): """ Get the accumulated performance cost. """ perf_cost = Variable( torch.zeros(1), requires_grad=requires_grad ).to(self.device, non_blocking=True) for latency in self.mutator.get_weighted_latency(): ...
[ "def", "_get_perf_cost", "(", "self", ",", "requires_grad", "=", "True", ")", ":", "perf_cost", "=", "Variable", "(", "torch", ".", "zeros", "(", "1", ")", ",", "requires_grad", "=", "requires_grad", ")", ".", "to", "(", "self", ".", "device", ",", "no...
[ 138, 4 ]
[ 149, 24 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer._validate
(self)
Do validation. During validation, LayerChoices use the mixed-op. Returns ------- float, float, float average loss, average top1 accuracy, average top5 accuracy
Do validation. During validation, LayerChoices use the mixed-op.
def _validate(self): """ Do validation. During validation, LayerChoices use the mixed-op. Returns ------- float, float, float average loss, average top1 accuracy, average top5 accuracy """ self.valid_loader.batch_sampler.drop_last = False batc...
[ "def", "_validate", "(", "self", ")", ":", "self", ".", "valid_loader", ".", "batch_sampler", ".", "drop_last", "=", "False", "batch_time", "=", "AverageMeter", "(", "\"batch_time\"", ")", "losses", "=", "AverageMeter", "(", "\"losses\"", ")", "top1", "=", "...
[ 151, 4 ]
[ 203, 45 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer._train_epoch
(self, epoch, optimizer, arch_train=False)
Train one epoch.
Train one epoch.
def _train_epoch(self, epoch, optimizer, arch_train=False): """ Train one epoch. """ batch_time = AverageMeter("batch_time") data_time = AverageMeter("data_time") losses = AverageMeter("losses") top1 = AverageMeter("top1") top5 = AverageMeter("top5") ...
[ "def", "_train_epoch", "(", "self", ",", "epoch", ",", "optimizer", ",", "arch_train", "=", "False", ")", ":", "batch_time", "=", "AverageMeter", "(", "\"batch_time\"", ")", "data_time", "=", "AverageMeter", "(", "\"data_time\"", ")", "losses", "=", "AverageMe...
[ 205, 4 ]
[ 266, 43 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer._warm_up
(self)
Warm up the model, while the architecture weights are not trained.
Warm up the model, while the architecture weights are not trained.
def _warm_up(self): """ Warm up the model, while the architecture weights are not trained. """ for epoch in range(self.epoch, self.start_epoch): self.logger.info("\n--------Warmup epoch: %d--------\n", epoch + 1) self._train_epoch(epoch, self.model_optim) ...
[ "def", "_warm_up", "(", "self", ")", ":", "for", "epoch", "in", "range", "(", "self", ".", "epoch", ",", "self", ".", "start_epoch", ")", ":", "self", ".", "logger", ".", "info", "(", "\"\\n--------Warmup epoch: %d--------\\n\"", ",", "epoch", "+", "1", ...
[ 268, 4 ]
[ 292, 53 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer._train
(self)
Train the model, it trains model weights and architecute weights. Architecture weights are trained according to the schedule. Before updating architecture weights, ```requires_grad``` is enabled. Then, it is disabled after the updating, in order not to update architecture weight...
Train the model, it trains model weights and architecute weights. Architecture weights are trained according to the schedule. Before updating architecture weights, ```requires_grad``` is enabled. Then, it is disabled after the updating, in order not to update architecture weight...
def _train(self): """ Train the model, it trains model weights and architecute weights. Architecture weights are trained according to the schedule. Before updating architecture weights, ```requires_grad``` is enabled. Then, it is disabled after the updating, in order not to updat...
[ "def", "_train", "(", "self", ")", ":", "arch_param_num", "=", "self", ".", "mutator", ".", "num_arch_params", "(", ")", "self", ".", "logger", ".", "info", "(", "\"#arch_params: {}\"", ".", "format", "(", "arch_param_num", ")", ")", "self", ".", "epoch", ...
[ 294, 4 ]
[ 346, 36 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer.save_checkpoint
(self, epoch, filename, choice_names=None)
Save checkpoint of the whole model. Saving model weights and architecture weights as ```filename```, and saving currently chosen architecture in ```arch_path```.
Save checkpoint of the whole model. Saving model weights and architecture weights as ```filename```, and saving currently chosen architecture in ```arch_path```.
def save_checkpoint(self, epoch, filename, choice_names=None): """ Save checkpoint of the whole model. Saving model weights and architecture weights as ```filename```, and saving currently chosen architecture in ```arch_path```. """ state = { "model": self.mod...
[ "def", "save_checkpoint", "(", "self", ",", "epoch", ",", "filename", ",", "choice_names", "=", "None", ")", ":", "state", "=", "{", "\"model\"", ":", "self", ".", "model", ".", "state_dict", "(", ")", ",", "\"optim\"", ":", "self", ".", "model_optim", ...
[ 348, 4 ]
[ 364, 39 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer.load_checkpoint
(self, filename)
Load the checkpoint from ```ckpt_path```.
Load the checkpoint from ```ckpt_path```.
def load_checkpoint(self, filename): """ Load the checkpoint from ```ckpt_path```. """ ckpt = torch.load(filename) self.epoch = ckpt["epoch"] self.model.load_state_dict(ckpt["model"]) self.model_optim.load_state_dict(ckpt["optim"])
[ "def", "load_checkpoint", "(", "self", ",", "filename", ")", ":", "ckpt", "=", "torch", ".", "load", "(", "filename", ")", "self", ".", "epoch", "=", "ckpt", "[", "\"epoch\"", "]", "self", ".", "model", ".", "load_state_dict", "(", "ckpt", "[", "\"mode...
[ 366, 4 ]
[ 373, 55 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer.train
(self)
Train the whole model.
Train the whole model.
def train(self): """ Train the whole model. """ if self.load_ckpt: ckpt_path = self.config.model_dir filename = os.path.join(ckpt_path, "checkpoint_best.pth") if os.path.exists(filename): self.load_checkpoint(filename) if self....
[ "def", "train", "(", "self", ")", ":", "if", "self", ".", "load_ckpt", ":", "ckpt_path", "=", "self", ".", "config", ".", "model_dir", "filename", "=", "os", ".", "path", ".", "join", "(", "ckpt_path", ",", "\"checkpoint_best.pth\"", ")", "if", "os", "...
[ 375, 4 ]
[ 387, 21 ]
python
en
['en', 'error', 'th']
False
FBNetTrainer.export
(self, file_name)
Export the chosen architecture into a file Parameters ---------- file_name : str the file that stores exported chosen architecture
Export the chosen architecture into a file
def export(self, file_name): """ Export the chosen architecture into a file Parameters ---------- file_name : str the file that stores exported chosen architecture """ exported_arch = self.mutator.sample_final() with open(file_name, "w") as f:...
[ "def", "export", "(", "self", ",", "file_name", ")", ":", "exported_arch", "=", "self", ".", "mutator", ".", "sample_final", "(", ")", "with", "open", "(", "file_name", ",", "\"w\"", ")", "as", "f", ":", "json", ".", "dump", "(", "exported_arch", ",", ...
[ 389, 4 ]
[ 406, 13 ]
python
en
['en', 'error', 'th']
False
conv3x3
(in_planes, out_planes, stride=1)
3x3 convolution with padding
3x3 convolution with padding
def conv3x3(in_planes, out_planes, stride=1): "3x3 convolution with padding" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=True)
[ "def", "conv3x3", "(", "in_planes", ",", "out_planes", ",", "stride", "=", "1", ")", ":", "return", "nn", ".", "Conv2d", "(", "in_planes", ",", "out_planes", ",", "kernel_size", "=", "3", ",", "stride", "=", "stride", ",", "padding", "=", "1", ",", "...
[ 10, 0 ]
[ 13, 42 ]
python
en
['en', 'ja', 'en']
True
JuiceNetDevice.__init__
(self, device, sensor_type, coordinator)
Initialise the sensor.
Initialise the sensor.
def __init__(self, device, sensor_type, coordinator): """Initialise the sensor.""" super().__init__(coordinator) self.device = device self.type = sensor_type
[ "def", "__init__", "(", "self", ",", "device", ",", "sensor_type", ",", "coordinator", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "device", "=", "device", "self", ".", "type", "=", "sensor_type" ]
[ 10, 4 ]
[ 14, 31 ]
python
en
['en', 'sm', 'en']
True
JuiceNetDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return self.device.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "device", ".", "name" ]
[ 17, 4 ]
[ 19, 31 ]
python
en
['en', 'en', 'en']
True
JuiceNetDevice.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return f"{self.device.id}-{self.type}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self.device.id}-{self.type}\"" ]
[ 22, 4 ]
[ 24, 46 ]
python
ca
['fr', 'ca', 'en']
False
JuiceNetDevice.device_info
(self)
Return device information about this JuiceNet Device.
Return device information about this JuiceNet Device.
def device_info(self): """Return device information about this JuiceNet Device.""" return { "identifiers": {(DOMAIN, self.device.id)}, "name": self.device.name, "manufacturer": "JuiceNet", }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "device", ".", "id", ")", "}", ",", "\"name\"", ":", "self", ".", "device", ".", "name", ",", "\"manufacturer\"", ":", "\"JuiceNet...
[ 27, 4 ]
[ 33, 9 ]
python
en
['en', 'en', 'en']
True
ExitApp.__init__
(self, reason, exit_code=1)
Initialize the exit app exception.
Initialize the exit app exception.
def __init__(self, reason, exit_code=1): """Initialize the exit app exception.""" self.reason = reason self.exit_code = exit_code
[ "def", "__init__", "(", "self", ",", "reason", ",", "exit_code", "=", "1", ")", ":", "self", ".", "reason", "=", "reason", "self", ".", "exit_code", "=", "exit_code" ]
[ 6, 4 ]
[ 9, 34 ]
python
en
['en', 'en', 'en']
True
test_ps4_integration_setup
(hass)
Test PS4 integration is setup.
Test PS4 integration is setup.
async def test_ps4_integration_setup(hass): """Test PS4 integration is setup.""" await ps4.async_setup(hass, {}) await hass.async_block_till_done() assert hass.data[PS4_DATA].protocol is not None
[ "async", "def", "test_ps4_integration_setup", "(", "hass", ")", ":", "await", "ps4", ".", "async_setup", "(", "hass", ",", "{", "}", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert", "hass", ".", "data", "[", "PS4_DATA", "]", ".", "...
[ 108, 0 ]
[ 112, 51 ]
python
en
['en', 'da', 'en']
True
test_creating_entry_sets_up_media_player
(hass)
Test setting up PS4 loads the media player.
Test setting up PS4 loads the media player.
async def test_creating_entry_sets_up_media_player(hass): """Test setting up PS4 loads the media player.""" mock_flow = "homeassistant.components.ps4.PlayStation4FlowHandler.async_step_user" with patch( "homeassistant.components.ps4.media_player.async_setup_entry", return_value=True, ) a...
[ "async", "def", "test_creating_entry_sets_up_media_player", "(", "hass", ")", ":", "mock_flow", "=", "\"homeassistant.components.ps4.PlayStation4FlowHandler.async_step_user\"", "with", "patch", "(", "\"homeassistant.components.ps4.media_player.async_setup_entry\"", ",", "return_value",...
[ 115, 0 ]
[ 129, 42 ]
python
en
['en', 'en', 'en']
True
test_config_flow_entry_migrate
(hass)
Test that config flow entry is migrated correctly.
Test that config flow entry is migrated correctly.
async def test_config_flow_entry_migrate(hass): """Test that config flow entry is migrated correctly.""" # Start with the config entry at Version 1. manager = hass.config_entries mock_entry = MOCK_ENTRY_VERSION_1 mock_entry.add_to_manager(manager) mock_e_registry = mock_registry(hass) mock_e...
[ "async", "def", "test_config_flow_entry_migrate", "(", "hass", ")", ":", "# Start with the config entry at Version 1.", "manager", "=", "hass", ".", "config_entries", "mock_entry", "=", "MOCK_ENTRY_VERSION_1", "mock_entry", ".", "add_to_manager", "(", "manager", ")", "moc...
[ 132, 0 ]
[ 178, 71 ]
python
en
['en', 'en', 'en']
True
test_media_player_is_setup
(hass)
Test media_player is setup correctly.
Test media_player is setup correctly.
async def test_media_player_is_setup(hass): """Test media_player is setup correctly.""" await setup_mock_component(hass) assert len(hass.data[PS4_DATA].devices) == 1
[ "async", "def", "test_media_player_is_setup", "(", "hass", ")", ":", "await", "setup_mock_component", "(", "hass", ")", "assert", "len", "(", "hass", ".", "data", "[", "PS4_DATA", "]", ".", "devices", ")", "==", "1" ]
[ 181, 0 ]
[ 184, 48 ]
python
en
['en', 'en', 'en']
True
setup_mock_component
(hass)
Set up Mock Media Player.
Set up Mock Media Player.
async def setup_mock_component(hass): """Set up Mock Media Player.""" entry = MockConfigEntry(domain=ps4.DOMAIN, data=MOCK_DATA, version=VERSION) entry.add_to_manager(hass.config_entries) await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) await hass.async_block_till_done()
[ "async", "def", "setup_mock_component", "(", "hass", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "ps4", ".", "DOMAIN", ",", "data", "=", "MOCK_DATA", ",", "version", "=", "VERSION", ")", "entry", ".", "add_to_manager", "(", "hass", ".", ...
[ 187, 0 ]
[ 192, 38 ]
python
en
['en', 'da', 'en']
True
test_games_reformat_to_dict
(hass)
Test old data format is converted to new format.
Test old data format is converted to new format.
def test_games_reformat_to_dict(hass): """Test old data format is converted to new format.""" with patch( "homeassistant.components.ps4.load_json", return_value=MOCK_GAMES_DATA_OLD_STR_FORMAT, ), patch("homeassistant.components.ps4.save_json", side_effect=MagicMock()), patch( "os.pat...
[ "def", "test_games_reformat_to_dict", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.ps4.load_json\"", ",", "return_value", "=", "MOCK_GAMES_DATA_OLD_STR_FORMAT", ",", ")", ",", "patch", "(", "\"homeassistant.components.ps4.save_json\"", ",", "side...
[ 195, 0 ]
[ 215, 68 ]
python
en
['en', 'en', 'en']
True
test_load_games
(hass)
Test that games are loaded correctly.
Test that games are loaded correctly.
def test_load_games(hass): """Test that games are loaded correctly.""" with patch( "homeassistant.components.ps4.load_json", return_value=MOCK_GAMES ), patch("homeassistant.components.ps4.save_json", side_effect=MagicMock()), patch( "os.path.isfile", return_value=True ): mock_gam...
[ "def", "test_load_games", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.ps4.load_json\"", ",", "return_value", "=", "MOCK_GAMES", ")", ",", "patch", "(", "\"homeassistant.components.ps4.save_json\"", ",", "side_effect", "=", "MagicMock", "(", ...
[ 218, 0 ]
[ 234, 64 ]
python
en
['en', 'en', 'en']
True
test_loading_games_returns_dict
(hass)
Test that loading games always returns a dict.
Test that loading games always returns a dict.
def test_loading_games_returns_dict(hass): """Test that loading games always returns a dict.""" with patch( "homeassistant.components.ps4.load_json", side_effect=HomeAssistantError ), patch("homeassistant.components.ps4.save_json", side_effect=MagicMock()), patch( "os.path.isfile", return_va...
[ "def", "test_loading_games_returns_dict", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.ps4.load_json\"", ",", "side_effect", "=", "HomeAssistantError", ")", ",", "patch", "(", "\"homeassistant.components.ps4.save_json\"", ",", "side_effect", "=",...
[ 237, 0 ]
[ 265, 25 ]
python
en
['en', 'en', 'en']
True
test_send_command
(hass)
Test send_command service.
Test send_command service.
async def test_send_command(hass): """Test send_command service.""" await setup_mock_component(hass) mock_func = "{}{}".format( "homeassistant.components.ps4", ".media_player.PS4Device.async_send_command" ) mock_devices = hass.data[PS4_DATA].devices assert len(mock_devices) == 1 mo...
[ "async", "def", "test_send_command", "(", "hass", ")", ":", "await", "setup_mock_component", "(", "hass", ")", "mock_func", "=", "\"{}{}\"", ".", "format", "(", "\"homeassistant.components.ps4\"", ",", "\".media_player.PS4Device.async_send_command\"", ")", "mock_devices",...
[ 268, 0 ]
[ 290, 56 ]
python
en
['en', 'fr', 'en']
True
setup
(hass, config)
Set up the Raspberry PI GPIO component.
Set up the Raspberry PI GPIO component.
def setup(hass, config): """Set up the Raspberry PI GPIO component.""" def cleanup_gpio(event): """Stuff to do before stopping.""" GPIO.cleanup() def prepare_gpio(event): """Stuff to do when Home Assistant starts.""" hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gp...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "def", "cleanup_gpio", "(", "event", ")", ":", "\"\"\"Stuff to do before stopping.\"\"\"", "GPIO", ".", "cleanup", "(", ")", "def", "prepare_gpio", "(", "event", ")", ":", "\"\"\"Stuff to do when Home Assistant...
[ 9, 0 ]
[ 22, 15 ]
python
en
['en', 'pt', 'en']
True
setup_output
(port)
Set up a GPIO as output.
Set up a GPIO as output.
def setup_output(port): """Set up a GPIO as output.""" GPIO.setup(port, GPIO.OUT)
[ "def", "setup_output", "(", "port", ")", ":", "GPIO", ".", "setup", "(", "port", ",", "GPIO", ".", "OUT", ")" ]
[ 25, 0 ]
[ 27, 30 ]
python
en
['en', 'el-Latn', 'en']
True
setup_input
(port, pull_mode)
Set up a GPIO as input.
Set up a GPIO as input.
def setup_input(port, pull_mode): """Set up a GPIO as input.""" GPIO.setup(port, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)
[ "def", "setup_input", "(", "port", ",", "pull_mode", ")", ":", "GPIO", ".", "setup", "(", "port", ",", "GPIO", ".", "IN", ",", "GPIO", ".", "PUD_DOWN", "if", "pull_mode", "==", "\"DOWN\"", "else", "GPIO", ".", "PUD_UP", ")" ]
[ 30, 0 ]
[ 32, 84 ]
python
en
['en', 'haw', 'en']
True
write_output
(port, value)
Write a value to a GPIO.
Write a value to a GPIO.
def write_output(port, value): """Write a value to a GPIO.""" GPIO.output(port, value)
[ "def", "write_output", "(", "port", ",", "value", ")", ":", "GPIO", ".", "output", "(", "port", ",", "value", ")" ]
[ 35, 0 ]
[ 37, 28 ]
python
en
['en', 'pt', 'en']
True
read_input
(port)
Read a value from a GPIO.
Read a value from a GPIO.
def read_input(port): """Read a value from a GPIO.""" return GPIO.input(port)
[ "def", "read_input", "(", "port", ")", ":", "return", "GPIO", ".", "input", "(", "port", ")" ]
[ 40, 0 ]
[ 42, 27 ]
python
en
['en', 'en', 'en']
True
edge_detect
(port, event_callback, bounce)
Add detection for RISING and FALLING events.
Add detection for RISING and FALLING events.
def edge_detect(port, event_callback, bounce): """Add detection for RISING and FALLING events.""" GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback, bouncetime=bounce)
[ "def", "edge_detect", "(", "port", ",", "event_callback", ",", "bounce", ")", ":", "GPIO", ".", "add_event_detect", "(", "port", ",", "GPIO", ".", "BOTH", ",", "callback", "=", "event_callback", ",", "bouncetime", "=", "bounce", ")" ]
[ 45, 0 ]
[ 47, 86 ]
python
en
['en', 'en', 'en']
True
get_cluster
()
Get cluster. Returns: None.
Get cluster.
def get_cluster(): """Get cluster. Returns: None. """ cluster_details = redis_controller.get_cluster_details() cluster_details["master"] = redis_controller.get_master_details() return cluster_details
[ "def", "get_cluster", "(", ")", ":", "cluster_details", "=", "redis_controller", ".", "get_cluster_details", "(", ")", "cluster_details", "[", "\"master\"", "]", "=", "redis_controller", ".", "get_master_details", "(", ")", "return", "cluster_details" ]
[ 19, 0 ]
[ 28, 26 ]
python
da
['et', 'da', 'en']
False
create_cluster
(**kwargs)
Create cluster. Returns: None.
Create cluster.
def create_cluster(**kwargs): """Create cluster. Returns: None. """ cluster_details = kwargs["json_dict"] redis_controller.set_cluster_details(cluster_details=cluster_details) return cluster_details
[ "def", "create_cluster", "(", "*", "*", "kwargs", ")", ":", "cluster_details", "=", "kwargs", "[", "\"json_dict\"", "]", "redis_controller", ".", "set_cluster_details", "(", "cluster_details", "=", "cluster_details", ")", "return", "cluster_details" ]
[ 33, 0 ]
[ 43, 26 ]
python
en
['en', 'en', 'en']
False
_hass_state_to_position_start
(state)
Convert hass state to homekit position state.
Convert hass state to homekit position state.
def _hass_state_to_position_start(state): """Convert hass state to homekit position state.""" if state == STATE_OPENING: return HK_POSITION_GOING_TO_MAX if state == STATE_CLOSING: return HK_POSITION_GOING_TO_MIN return HK_POSITION_STOPPED
[ "def", "_hass_state_to_position_start", "(", "state", ")", ":", "if", "state", "==", "STATE_OPENING", ":", "return", "HK_POSITION_GOING_TO_MAX", "if", "state", "==", "STATE_CLOSING", ":", "return", "HK_POSITION_GOING_TO_MIN", "return", "HK_POSITION_STOPPED" ]
[ 404, 0 ]
[ 410, 30 ]
python
en
['en', 'en', 'en']
True
OpeningDeviceBase.__init__
(self, *args, category, service)
Initialize a OpeningDeviceBase accessory object.
Initialize a OpeningDeviceBase accessory object.
def __init__(self, *args, category, service): """Initialize a OpeningDeviceBase accessory object.""" super().__init__(*args, category=category) state = self.hass.states.get(self.entity_id) self.features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) self._supports_stop = sel...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "category", ",", "service", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "category", "=", "category", ")", "state", "=", "self", ".", "hass", ".", "states", ".", "get", ...
[ 199, 4 ]
[ 227, 13 ]
python
en
['en', 'zu', 'en']
True
OpeningDeviceBase.set_stop
(self, value)
Stop the cover motion from HomeKit.
Stop the cover motion from HomeKit.
def set_stop(self, value): """Stop the cover motion from HomeKit.""" if value != 1: return self.call_service(DOMAIN, SERVICE_STOP_COVER, {ATTR_ENTITY_ID: self.entity_id})
[ "def", "set_stop", "(", "self", ",", "value", ")", ":", "if", "value", "!=", "1", ":", "return", "self", ".", "call_service", "(", "DOMAIN", ",", "SERVICE_STOP_COVER", ",", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_id", "}", ")" ]
[ 229, 4 ]
[ 233, 87 ]
python
en
['en', 'en', 'en']
True
OpeningDeviceBase.set_tilt
(self, value)
Set tilt to value if call came from HomeKit.
Set tilt to value if call came from HomeKit.
def set_tilt(self, value): """Set tilt to value if call came from HomeKit.""" _LOGGER.info("%s: Set tilt to %d", self.entity_id, value) # HomeKit sends values between -90 and 90. # We'll have to normalize to [0,100] value = round((value + 90) / 180.0 * 100.0) params = {...
[ "def", "set_tilt", "(", "self", ",", "value", ")", ":", "_LOGGER", ".", "info", "(", "\"%s: Set tilt to %d\"", ",", "self", ".", "entity_id", ",", "value", ")", "# HomeKit sends values between -90 and 90.", "# We'll have to normalize to [0,100]", "value", "=", "round"...
[ 236, 4 ]
[ 246, 81 ]
python
en
['en', 'en', 'en']
True
OpeningDeviceBase.async_update_state
(self, new_state)
Update cover position and tilt after state changed.
Update cover position and tilt after state changed.
def async_update_state(self, new_state): """Update cover position and tilt after state changed.""" # update tilt current_tilt = new_state.attributes.get(ATTR_CURRENT_TILT_POSITION) if isinstance(current_tilt, (float, int)): # HomeKit sends values between -90 and 90. ...
[ "def", "async_update_state", "(", "self", ",", "new_state", ")", ":", "# update tilt", "current_tilt", "=", "new_state", ".", "attributes", ".", "get", "(", "ATTR_CURRENT_TILT_POSITION", ")", "if", "isinstance", "(", "current_tilt", ",", "(", "float", ",", "int"...
[ 249, 4 ]
[ 261, 61 ]
python
en
['da', 'en', 'en']
True
OpeningDevice.__init__
(self, *args, category, service)
Initialize a WindowCovering accessory object.
Initialize a WindowCovering accessory object.
def __init__(self, *args, category, service): """Initialize a WindowCovering accessory object.""" super().__init__(*args, category=category, service=service) state = self.hass.states.get(self.entity_id) self.char_current_position = self.serv_cover.configure_char( CHAR_CURREN...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "category", ",", "service", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "category", "=", "category", ",", "service", "=", "service", ")", "state", "=", "self", ".", "ha...
[ 270, 4 ]
[ 284, 38 ]
python
en
['en', 'en', 'en']
True
OpeningDevice.move_cover
(self, value)
Move cover to value if call came from HomeKit.
Move cover to value if call came from HomeKit.
def move_cover(self, value): """Move cover to value if call came from HomeKit.""" _LOGGER.debug("%s: Set position to %d", self.entity_id, value) params = {ATTR_ENTITY_ID: self.entity_id, ATTR_POSITION: value} self.call_service(DOMAIN, SERVICE_SET_COVER_POSITION, params, value)
[ "def", "move_cover", "(", "self", ",", "value", ")", ":", "_LOGGER", ".", "debug", "(", "\"%s: Set position to %d\"", ",", "self", ".", "entity_id", ",", "value", ")", "params", "=", "{", "ATTR_ENTITY_ID", ":", "self", ".", "entity_id", ",", "ATTR_POSITION",...
[ 287, 4 ]
[ 291, 76 ]
python
en
['en', 'en', 'en']
True
OpeningDevice.async_update_state
(self, new_state)
Update cover position and tilt after state changed.
Update cover position and tilt after state changed.
def async_update_state(self, new_state): """Update cover position and tilt after state changed.""" current_position = new_state.attributes.get(ATTR_CURRENT_POSITION) if isinstance(current_position, (float, int)): current_position = int(current_position) if self.char_curre...
[ "def", "async_update_state", "(", "self", ",", "new_state", ")", ":", "current_position", "=", "new_state", ".", "attributes", ".", "get", "(", "ATTR_CURRENT_POSITION", ")", "if", "isinstance", "(", "current_position", ",", "(", "float", ",", "int", ")", ")", ...
[ 294, 4 ]
[ 308, 45 ]
python
en
['da', 'en', 'en']
True
test_form
(hass)
Test we get the form.
Test we get the form.
async def test_form(hass): """Test we get the 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"] == "form" assert result["errors...
[ "async", "def", "test_form", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(...
[ 22, 0 ]
[ 62, 48 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_auth
(hass)
Test we handle invalid auth.
Test we handle invalid auth.
async def test_form_invalid_auth(hass): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) rachio_mock = _mock_rachio_return_value( get=({"status": 200}, {"username": "myusername"}), inf...
[ "async", "def", "test_form_invalid_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")"...
[ 65, 0 ]
[ 84, 56 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_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} ) rachio_mock = _mock_rachio_return_value( get=({"status": 599}, {"username": "myusername"}), ...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 87, 0 ]
[ 106, 58 ]
python
en
['en', 'en', 'en']
True
test_form_homekit
(hass)
Test that we abort from homekit if rachio is already setup.
Test that we abort from homekit if rachio is already setup.
async def test_form_homekit(hass): """Test that we abort from homekit if rachio is already setup.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "homekit"}, data={"properties": ...
[ "async", "def", "test_form_homekit", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_ini...
[ 109, 0 ]
[ 136, 51 ]
python
en
['en', 'en', 'en']
True
test_attributes
(hass)
Test the alarm control panel attributes are correct.
Test the alarm control panel attributes are correct.
async def test_attributes(hass): """Test the alarm control panel attributes are correct.""" with patch( "homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request", return_value=RESPONSE_DISARMED, ) as mock_request: await setup_platform(hass, ALARM_DOMAIN) ...
[ "async", "def", "test_attributes", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request\"", ",", "return_value", "=", "RESPONSE_DISARMED", ",", ")", "as", "mock_request", ":", "await", "setup_pla...
[ 33, 0 ]
[ 43, 65 ]
python
en
['en', 'en', 'en']
True
test_arm_home_success
(hass)
Test arm home method success.
Test arm home method success.
async def test_arm_home_success(hass): """Test arm home method success.""" responses = [RESPONSE_DISARMED, RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_STAY] with patch( "homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request", side_effect=responses, ): await...
[ "async", "def", "test_arm_home_success", "(", "hass", ")", ":", "responses", "=", "[", "RESPONSE_DISARMED", ",", "RESPONSE_ARM_SUCCESS", ",", "RESPONSE_ARMED_STAY", "]", "with", "patch", "(", "\"homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request...
[ 46, 0 ]
[ 61, 73 ]
python
en
['en', 'fr', 'en']
True
test_arm_home_failure
(hass)
Test arm home method failure.
Test arm home method failure.
async def test_arm_home_failure(hass): """Test arm home method failure.""" responses = [RESPONSE_DISARMED, RESPONSE_ARM_FAILURE, RESPONSE_DISARMED] with patch( "homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request", side_effect=responses, ): await s...
[ "async", "def", "test_arm_home_failure", "(", "hass", ")", ":", "responses", "=", "[", "RESPONSE_DISARMED", ",", "RESPONSE_ARM_FAILURE", ",", "RESPONSE_DISARMED", "]", "with", "patch", "(", "\"homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request\"...
[ 64, 0 ]
[ 80, 71 ]
python
en
['en', 'gd', 'en']
True
test_arm_away_success
(hass)
Test arm away method success.
Test arm away method success.
async def test_arm_away_success(hass): """Test arm away method success.""" responses = [RESPONSE_DISARMED, RESPONSE_ARM_SUCCESS, RESPONSE_ARMED_AWAY] with patch( "homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request", side_effect=responses, ): await...
[ "async", "def", "test_arm_away_success", "(", "hass", ")", ":", "responses", "=", "[", "RESPONSE_DISARMED", ",", "RESPONSE_ARM_SUCCESS", ",", "RESPONSE_ARMED_AWAY", "]", "with", "patch", "(", "\"homeassistant.components.totalconnect.TotalConnectClient.TotalConnectClient.request...
[ 83, 0 ]
[ 97, 73 ]
python
en
['en', 'su', 'en']
True