Fix PEP257 issues

pull/1501/head
Fabian Affolter 2016-03-07 20:21:43 +01:00
parent f6bc1a4575
commit 3a4250133a
6 changed files with 32 additions and 21 deletions

View File

@ -50,7 +50,7 @@ def setup(hass, config):
component.setup(config)
def alarm_service_handler(service):
"""Maps services to methods on Alarm."""
"""Map services to methods on Alarm."""
target_alarms = component.extract_from_service(service)
if ATTR_CODE not in service.data:
@ -121,7 +121,8 @@ def alarm_trigger(hass, code=None, entity_id=None):
# pylint: disable=no-self-use
class AlarmControlPanel(Entity):
"""An ABC for alarm control devices."""
"""An abstract class for alarm control devices."""
@property
def code_format(self):
"""Regex for code format or None if no code is required."""

View File

@ -1,5 +1,5 @@
"""
Interfaces with Verisure alarm control panel.
Interfaces with Alarm.com alarm control panels.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.alarmdotcom/
@ -39,8 +39,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes
# pylint: disable=abstract-method
class AlarmDotCom(alarm.AlarmControlPanel):
"""Represents a Alarm.com status."""
"""Represent an Alarm.com status."""
def __init__(self, hass, name, code, username, password):
"""Initialize the Alarm.com status."""
from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
self._alarm = Alarmdotcom(username, password, timeout=10)
self._hass = hass
@ -56,7 +58,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
@property
def name(self):
"""Returns the name of the device."""
"""Return the name of the alarm."""
return self._name
@property
@ -66,7 +68,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
@property
def state(self):
"""Returns the state of the device."""
"""Return the state of the device."""
if self._alarm.state == 'Disarmed':
return STATE_ALARM_DISARMED
elif self._alarm.state == 'Armed Stay':

View File

@ -22,7 +22,7 @@ DEFAULT_TRIGGER_TIME = 120
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Sets up the manual alarm platform."""
"""Setup the manual alarm platform."""
add_devices([ManualAlarm(
hass,
config.get('name', DEFAULT_ALARM_NAME),
@ -42,7 +42,9 @@ class ManualAlarm(alarm.AlarmControlPanel):
When triggered, will be pending for 'trigger_time'. After that will be
triggered for 'trigger_time', after that we return to disarmed.
"""
def __init__(self, hass, name, code, pending_time, trigger_time):
"""Initalize the manual alarm panel."""
self._state = STATE_ALARM_DISARMED
self._hass = hass
self._name = name
@ -58,12 +60,12 @@ class ManualAlarm(alarm.AlarmControlPanel):
@property
def name(self):
"""Returns the name of the device."""
"""Return the name of the device."""
return self._name
@property
def state(self):
"""Returns the state of the device."""
"""Return the state of the device."""
if self._state in (STATE_ALARM_ARMED_HOME,
STATE_ALARM_ARMED_AWAY) and \
self._pending_time and self._state_ts + self._pending_time > \

View File

@ -24,7 +24,7 @@ DEPENDENCIES = ['mqtt']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Sets up the MQTT platform."""
"""Setup the MQTT platform."""
if config.get('state_topic') is None:
_LOGGER.error("Missing required variable: state_topic")
return False
@ -48,9 +48,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes
# pylint: disable=abstract-method
class MqttAlarm(alarm.AlarmControlPanel):
"""Represents a MQTT alarm status."""
"""Represent a MQTT alarm status."""
def __init__(self, hass, name, state_topic, command_topic, qos,
payload_disarm, payload_arm_home, payload_arm_away, code):
"""Initalize the MQTT alarm panel."""
self._state = STATE_UNKNOWN
self._hass = hass
self._name = name
@ -81,12 +83,12 @@ class MqttAlarm(alarm.AlarmControlPanel):
@property
def name(self):
"""Returns the name of the device."""
"""Return the name of the device."""
return self._name
@property
def state(self):
""" Returns the state of the device. """
"""Return the state of the device."""
return self._state
@property

View File

@ -29,8 +29,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class NX584Alarm(alarm.AlarmControlPanel):
"""Represents the NX584-based alarm panel. """
"""Represents the NX584-based alarm panel."""
def __init__(self, hass, host, name):
"""Initalize the nx584 alarm panel."""
from nx584 import client
self._hass = hass
self._host = host
@ -48,17 +50,17 @@ class NX584Alarm(alarm.AlarmControlPanel):
@property
def name(self):
"""Returns the name of the device."""
"""Return the name of the device."""
return self._name
@property
def code_format(self):
"""Characters if code is defined."""
"""The characters if code is defined."""
return '[0-9]{4}([0-9]{2})?'
@property
def state(self):
"""Returns the state of the device."""
"""Return the state of the device."""
try:
part = self._alarm.list_partitions()[0]
zones = self._alarm.list_zones()

View File

@ -30,25 +30,27 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=abstract-method
class VerisureAlarm(alarm.AlarmControlPanel):
"""Represents a Verisure alarm status."""
"""Represent a Verisure alarm status."""
def __init__(self, device_id):
"""Initalize the Verisure alarm panel."""
self._id = device_id
self._state = STATE_UNKNOWN
self._digits = int(hub.config.get('code_digits', '4'))
@property
def name(self):
"""Returns the name of the device."""
"""Return the name of the device."""
return 'Alarm {}'.format(self._id)
@property
def state(self):
"""Returns the state of the device."""
"""Return the state of the device."""
return self._state
@property
def code_format(self):
"""Code format as regex."""
"""The code format as regex."""
return '^\\d{%s}$' % self._digits
def update(self):