Fix PEP257 issues

This commit is contained in:
Fabian Affolter 2016-03-07 22:13:18 +01:00
parent f6bc1a4575
commit 6879e39d6c
5 changed files with 25 additions and 16 deletions

View File

@ -41,13 +41,13 @@ _LOGGER = logging.getLogger(__name__)
def is_locked(hass, entity_id=None): def is_locked(hass, entity_id=None):
"""Returns if the lock is locked based on the statemachine.""" """Return if the lock is locked based on the statemachine."""
entity_id = entity_id or ENTITY_ID_ALL_LOCKS entity_id = entity_id or ENTITY_ID_ALL_LOCKS
return hass.states.is_state(entity_id, STATE_LOCKED) return hass.states.is_state(entity_id, STATE_LOCKED)
def lock(hass, entity_id=None, code=None): def lock(hass, entity_id=None, code=None):
"""Locks all or specified locks.""" """Lock all or specified locks."""
data = {} data = {}
if code: if code:
data[ATTR_CODE] = code data[ATTR_CODE] = code
@ -58,7 +58,7 @@ def lock(hass, entity_id=None, code=None):
def unlock(hass, entity_id=None, code=None): def unlock(hass, entity_id=None, code=None):
"""Unlocks all or specified locks.""" """Unlock all or specified locks."""
data = {} data = {}
if code: if code:
data[ATTR_CODE] = code data[ATTR_CODE] = code
@ -76,7 +76,7 @@ def setup(hass, config):
component.setup(config) component.setup(config)
def handle_lock_service(service): def handle_lock_service(service):
"""Handles calls to the lock services.""" """Handle calls to the lock services."""
target_locks = component.extract_from_service(service) target_locks = component.extract_from_service(service)
if ATTR_CODE not in service.data: if ATTR_CODE not in service.data:
@ -104,7 +104,8 @@ def setup(hass, config):
class LockDevice(Entity): class LockDevice(Entity):
"""Represents a lock.""" """Representation of a lock."""
# pylint: disable=no-self-use # pylint: disable=no-self-use
@property @property
def code_format(self): def code_format(self):
@ -113,15 +114,15 @@ class LockDevice(Entity):
@property @property
def is_locked(self): def is_locked(self):
"""Is the lock locked or unlocked.""" """Return true if the lock is locked."""
return None return None
def lock(self, **kwargs): def lock(self, **kwargs):
"""Locks the lock.""" """Lock the lock."""
raise NotImplementedError() raise NotImplementedError()
def unlock(self, **kwargs): def unlock(self, **kwargs):
"""Unlocks the lock.""" """Unlock the lock."""
raise NotImplementedError() raise NotImplementedError()
@property @property

View File

@ -10,7 +10,7 @@ from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the demo lock platform. """ """Setup the demo lock platform."""
add_devices_callback([ add_devices_callback([
DemoLock('Front Door', STATE_LOCKED), DemoLock('Front Door', STATE_LOCKED),
DemoLock('Kitchen Door', STATE_UNLOCKED) DemoLock('Kitchen Door', STATE_UNLOCKED)
@ -18,8 +18,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class DemoLock(LockDevice): class DemoLock(LockDevice):
"""Provides a demo lock.""" """Representation of a demo lock."""
def __init__(self, name, state): def __init__(self, name, state):
"""Initialize the lock."""
self._name = name self._name = name
self._state = state self._state = state

View File

@ -46,8 +46,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes # pylint: disable=too-many-arguments, too-many-instance-attributes
class MqttLock(LockDevice): class MqttLock(LockDevice):
"""Represents a lock that can be toggled using MQTT.""" """Represents a lock that can be toggled using MQTT."""
def __init__(self, hass, name, state_topic, command_topic, qos, retain, def __init__(self, hass, name, state_topic, command_topic, qos, retain,
payload_lock, payload_unlock, optimistic, value_template): payload_lock, payload_unlock, optimistic, value_template):
"""Initialize the lock."""
self._state = False self._state = False
self._hass = hass self._hass = hass
self._name = name self._name = name

View File

@ -15,7 +15,7 @@ ATTR_CODE = 'code'
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Sets up the Verisure platform.""" """Setup the Verisure platform."""
locks = [] locks = []
if int(hub.config.get('locks', '1')): if int(hub.config.get('locks', '1')):
hub.update_locks() hub.update_locks()
@ -28,25 +28,27 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=abstract-method # pylint: disable=abstract-method
class VerisureDoorlock(LockDevice): class VerisureDoorlock(LockDevice):
"""Represents a Verisure doorlock.""" """Representation of a Verisure doorlock."""
def __init__(self, device_id): def __init__(self, device_id):
"""Initialize the lock."""
self._id = device_id self._id = device_id
self._state = STATE_UNKNOWN self._state = STATE_UNKNOWN
self._digits = int(hub.config.get('code_digits', '4')) self._digits = int(hub.config.get('code_digits', '4'))
@property @property
def name(self): def name(self):
"""Returns the name of the lock.""" """Return the name of the lock."""
return 'Lock {}'.format(self._id) return 'Lock {}'.format(self._id)
@property @property
def state(self): def state(self):
"""Returns the state of the lock.""" """Return the state of the lock."""
return self._state return self._state
@property @property
def code_format(self): def code_format(self):
"""Six digit code required.""" """Return the required six digit code."""
return '^\\d{%s}$' % self._digits return '^\\d{%s}$' % self._digits
def update(self): def update(self):

View File

@ -31,8 +31,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class WinkLockDevice(LockDevice): class WinkLockDevice(LockDevice):
"""Represents a Wink lock.""" """Representation of a Wink lock."""
def __init__(self, wink): def __init__(self, wink):
"""Initialize the lock."""
self.wink = wink self.wink = wink
@property @property