Fix PEP257 issues

This commit is contained in:
Fabian Affolter 2016-03-07 23:01:34 +01:00
parent 1b8b2acb51
commit 91731c7234
5 changed files with 58 additions and 59 deletions

View file

@ -1,7 +1,5 @@
"""
homeassistant.components.rollershutter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rollershutter component.
Support for Roller shutters.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/rollershutter/
@ -36,7 +34,7 @@ ATTR_CURRENT_POSITION = 'current_position'
def is_open(hass, entity_id=None):
""" Returns if the rollershutter is open based on the statemachine. """
"""Return if the roller shutter is open based on the statemachine."""
entity_id = entity_id or ENTITY_ID_ALL_ROLLERSHUTTERS
return hass.states.is_state(entity_id, STATE_OPEN)
@ -54,7 +52,7 @@ def move_down(hass, entity_id=None):
def stop(hass, entity_id=None):
""" Stops all or specified rollershutter. """
"""Stop all or specified roller shutter."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
hass.services.call(DOMAIN, SERVICE_STOP, data)
@ -67,7 +65,7 @@ def setup(hass, config):
component.setup(config)
def handle_rollershutter_service(service):
""" Handles calls to the rollershutter services. """
"""Handle calls to the roller shutter services."""
target_rollershutters = component.extract_from_service(service)
for rollershutter in target_rollershutters:
@ -98,20 +96,20 @@ def setup(hass, config):
class RollershutterDevice(Entity):
""" Represents a rollershutter within Home Assistant. """
# pylint: disable=no-self-use
"""Representation a rollers hutter."""
# pylint: disable=no-self-use
@property
def current_position(self):
"""
Return current position of rollershutter.
"""Return current position of roller shutter.
None is unknown, 0 is closed, 100 is fully open.
"""
raise NotImplementedError()
@property
def state(self):
""" Returns the state of the rollershutter. """
"""Return the state of the roller shutter."""
current = self.current_position
if current is None:

View file

@ -16,7 +16,6 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup roller shutter controlled by shell commands."""
rollershutters = config.get('rollershutters', {})
devices = []
@ -35,15 +34,15 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes
class CommandRollershutter(RollershutterDevice):
""" Represents a rollershutter - can be controlled using shell cmd. """
"""Representation a command line roller shutter."""
# pylint: disable=too-many-arguments
def __init__(self, hass, name, command_up, command_down, command_stop,
command_state, value_template):
"""Initialize the roller shutter."""
self._hass = hass
self._name = name
self._state = None # Unknown
self._state = None
self._command_up = command_up
self._command_down = command_down
self._command_stop = command_stop
@ -75,24 +74,24 @@ class CommandRollershutter(RollershutterDevice):
@property
def should_poll(self):
""" Only poll if we have statecmd. """
"""Only poll if we have state command."""
return self._command_state is not None
@property
def name(self):
""" The name of the rollershutter. """
"""Return the name of the roller shutter."""
return self._name
@property
def current_position(self):
"""
Return current position of rollershutter.
"""Return current position of roller shutter.
None is unknown, 0 is closed, 100 is fully open.
"""
return self._state
def _query_state(self):
""" Query for state. """
"""Query for the state."""
if not self._command_state:
_LOGGER.error('No state command specified')
return

View file

@ -18,9 +18,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoRollershutter(RollershutterDevice):
"""Represents a roller shutter."""
"""Representation of a demo roller shutter."""
# pylint: disable=no-self-use
def __init__(self, hass, name, position):
"""Initialize the roller shutter."""
self.hass = hass
self._name = name
self._position = position
@ -29,7 +31,7 @@ class DemoRollershutter(RollershutterDevice):
@property
def name(self):
"""Returns the name of the roller shutter."""
"""Return the name of the roller shutter."""
return self._name
@property
@ -59,7 +61,7 @@ class DemoRollershutter(RollershutterDevice):
self._moving_up = False
def stop(self, **kwargs):
"""Stops the roller shutter."""
"""Stop the roller shutter."""
if self._listener is not None:
self.hass.bus.remove_listener(EVENT_TIME_CHANGED, self._listener)
self._listener = None

View file

@ -24,7 +24,6 @@ DEFAULT_PAYLOAD_STOP = "STOP"
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Add MQTT Rollershutter."""
if config.get('command_topic') is None:
_LOGGER.error("Missing required variable: command_topic")
return False
@ -43,9 +42,11 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes
class MqttRollershutter(RollershutterDevice):
"""Represents a rollershutter that can be controlled using MQTT."""
"""Representation of a roller shutter that can be controlled using MQTT."""
def __init__(self, hass, name, state_topic, command_topic, qos,
payload_up, payload_down, payload_stop, value_template):
"""Initialize the roller shutter."""
self._state = None
self._hass = hass
self._name = name
@ -80,13 +81,13 @@ class MqttRollershutter(RollershutterDevice):
@property
def name(self):
"""The name of the rollershutter."""
"""Return the name of the roller shutter."""
return self._name
@property
def current_position(self):
"""
Return current position of rollershutter.
"""Return current position of roller shutter.
None is unknown, 0 is closed, 100 is fully open.
"""
return self._state

View file

@ -1,7 +1,5 @@
"""
homeassistant.components.rollershutter.scsgate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure a SCSGate rollershutter.
Allow to configure a SCSGate roller shutter.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/rollershutter.scsgate/
@ -15,8 +13,7 @@ DEPENDENCIES = ['scsgate']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Add the SCSGate swiches defined inside of the configuration file. """
"""Setup the SCSGate roller shutter."""
devices = config.get('devices')
rollershutters = []
logger = logging.getLogger(__name__)
@ -42,31 +39,33 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes
class SCSGateRollerShutter(RollershutterDevice):
""" Represents a rollershutter that can be controlled using SCSGate. """
"""Representation of SCSGate rollershutter."""
def __init__(self, scs_id, name, logger):
"""Initialize the roller shutter."""
self._scs_id = scs_id
self._name = name
self._logger = logger
@property
def scs_id(self):
""" SCSGate ID """
"""Return the SCSGate ID."""
return self._scs_id
@property
def should_poll(self):
""" No polling needed """
"""No polling needed."""
return False
@property
def name(self):
""" The name of the rollershutter. """
"""Return the name of the roller shutter."""
return self._name
@property
def current_position(self):
"""
Return current position of rollershutter.
"""Return current position of roller shutter.
None is unknown, 0 is closed, 100 is fully open.
"""
return None
@ -92,7 +91,7 @@ class SCSGateRollerShutter(RollershutterDevice):
scsgate.SCSGATE.append_task(HaltRollerShutterTask(target=self._scs_id))
def process_event(self, message):
""" Handle a SCSGate message related with this rollershutter """
"""Handle a SCSGate message related with this roller shutter."""
self._logger.debug(
"Rollershutter %s, got message %s",
self._scs_id, message.toggled)