From 15b2473224e71db0af6055bcb3e00f77066040a4 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 24 Apr 2017 05:16:52 +0200 Subject: [PATCH] Iterating the dictionary directly (#7251) --- homeassistant/components/lock/verisure.py | 13 ++++++------- homeassistant/components/media_player/lg_netcast.py | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/lock/verisure.py b/homeassistant/components/lock/verisure.py index 7e73ceb680e..e4fa2104da6 100644 --- a/homeassistant/components/lock/verisure.py +++ b/homeassistant/components/lock/verisure.py @@ -16,13 +16,13 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the Verisure platform.""" + """Set up the Verisure platform.""" locks = [] if int(hub.config.get(CONF_LOCKS, 1)): hub.update_locks() locks.extend([ VerisureDoorlock(device_id) - for device_id in hub.lock_status.keys() + for device_id in hub.lock_status ]) add_devices(locks) @@ -31,7 +31,7 @@ class VerisureDoorlock(LockDevice): """Representation of a Verisure doorlock.""" def __init__(self, device_id): - """Initialize the lock.""" + """Initialize the Verisure lock.""" self._id = device_id self._state = STATE_UNKNOWN self._digits = hub.config.get(CONF_CODE_DIGITS) @@ -72,8 +72,7 @@ class VerisureDoorlock(LockDevice): self._state = STATE_LOCKED elif hub.lock_status[self._id].status != 'pending': _LOGGER.error( - 'Unknown lock state %s', - hub.lock_status[self._id].status) + "Unknown lock state %s", hub.lock_status[self._id].status) self._changed_by = hub.lock_status[self._id].name @property @@ -84,13 +83,13 @@ class VerisureDoorlock(LockDevice): def unlock(self, **kwargs): """Send unlock command.""" hub.my_pages.lock.set(kwargs[ATTR_CODE], self._id, 'UNLOCKED') - _LOGGER.info('verisure doorlock unlocking') + _LOGGER.debug("Verisure doorlock unlocking") hub.my_pages.lock.wait_while_pending() self.update() def lock(self, **kwargs): """Send lock command.""" hub.my_pages.lock.set(kwargs[ATTR_CODE], self._id, 'LOCKED') - _LOGGER.info('verisure doorlock locking') + _LOGGER.debug("Verisure doorlock locking") hub.my_pages.lock.wait_while_pending() self.update() diff --git a/homeassistant/components/media_player/lg_netcast.py b/homeassistant/components/media_player/lg_netcast.py index 00e405c17b2..8afdf89a2e4 100644 --- a/homeassistant/components/media_player/lg_netcast.py +++ b/homeassistant/components/media_player/lg_netcast.py @@ -47,8 +47,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the LG TV platform.""" from pylgnetcast import LgNetCastClient - client = LgNetCastClient(config.get(CONF_HOST), - config.get(CONF_ACCESS_TOKEN)) + client = LgNetCastClient( + config.get(CONF_HOST), config.get(CONF_ACCESS_TOKEN)) add_devices([LgTVDevice(client, config[CONF_NAME])]) @@ -110,7 +110,7 @@ class LgTVDevice(MediaPlayerDevice): self._sources = dict(zip(channel_names, channel_list)) # sort source names by the major channel number source_tuples = [(k, self._sources[k].find('major').text) - for k in self._sources.keys()] + for k in self._sources] sorted_sources = sorted( source_tuples, key=lambda channel: int(channel[1])) self._source_names = [n for n, k in sorted_sources]