Modify docstrings to match PEP257

This commit is contained in:
Fabian Affolter 2016-03-07 17:14:55 +01:00
parent 5222c19b4c
commit 6ac9210919
9 changed files with 48 additions and 68 deletions

View file

@ -1,6 +1,5 @@
"""
homeassistant.components.automation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to setup simple automation rules via the config file.
For more details about this component, please refer to the documentation at
@ -35,7 +34,7 @@ _LOGGER = logging.getLogger(__name__)
def setup(hass, config):
""" Sets up automation. """
"""Setup the automation."""
config_key = DOMAIN
found = 1
@ -64,8 +63,7 @@ def setup(hass, config):
def _setup_automation(hass, config_block, name, config):
""" Setup one instance of automation """
"""Setup one instance of automation."""
action = _get_action(hass, config_block.get(CONF_ACTION, {}), name)
if action is None:
@ -83,8 +81,7 @@ def _setup_automation(hass, config_block, name, config):
def _get_action(hass, config, name):
""" Return an action based on a config. """
"""Return an action based on a configuration."""
if CONF_SERVICE not in config:
_LOGGER.error('Error setting up %s, no action specified.', name)
return None
@ -100,7 +97,7 @@ def _get_action(hass, config, name):
def _migrate_old_config(config):
""" Migrate old config to new. """
"""Migrate old configuration to new."""
if CONF_PLATFORM not in config:
return config
@ -135,7 +132,6 @@ def _migrate_old_config(config):
def _process_if(hass, config, p_config, action):
"""Processes if checks."""
cond_type = p_config.get(CONF_CONDITION_TYPE,
DEFAULT_CONDITION_TYPE).lower()
@ -178,7 +174,7 @@ def _process_if(hass, config, p_config, action):
def _process_trigger(hass, config, trigger_configs, name, action):
""" Setup triggers. """
"""Setup the triggers."""
if isinstance(trigger_configs, dict):
trigger_configs = [trigger_configs]
@ -195,7 +191,7 @@ def _process_trigger(hass, config, trigger_configs, name, action):
def _resolve_platform(method, hass, config, platform):
""" Find automation platform. """
"""Find the automation platform."""
if platform is None:
return None
platform = prepare_setup_platform(hass, config, DOMAIN, platform)

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.event
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers event listening automation rules.
For more details about this automation rule, please refer to the documentation
@ -15,7 +13,7 @@ _LOGGER = logging.getLogger(__name__)
def trigger(hass, config, action):
""" Listen for events based on config. """
"""Listen for events based on configuration."""
event_type = config.get(CONF_EVENT_TYPE)
if event_type is None:

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers MQTT listening automation rules.
For more details about this automation rule, please refer to the documentation
@ -17,7 +15,7 @@ CONF_PAYLOAD = 'payload'
def trigger(hass, config, action):
""" Listen for state changes based on `config`. """
"""Listen for state changes based on configuration."""
topic = config.get(CONF_TOPIC)
payload = config.get(CONF_PAYLOAD)

View file

@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
def _renderer(hass, value_template, state):
"""Render state value."""
"""Render the state value."""
if value_template is None:
return state.state
@ -29,7 +29,7 @@ def _renderer(hass, value_template, state):
def trigger(hass, config, action):
""" Listen for state changes based on `config`. """
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
if entity_id is None:
@ -51,7 +51,6 @@ def trigger(hass, config, action):
# pylint: disable=unused-argument
def state_automation_listener(entity, from_s, to_s):
"""Listens for state changes and calls action."""
# Fire action if we go from outside range into range
if _in_range(above, below, renderer(to_s)) and \
(from_s is None or not _in_range(above, below, renderer(from_s))):
@ -65,7 +64,6 @@ def trigger(hass, config, action):
def if_action(hass, config):
"""Wraps action method with state based condition."""
entity_id = config.get(CONF_ENTITY_ID)
if entity_id is None:
@ -93,7 +91,7 @@ def if_action(hass, config):
def _in_range(range_start, range_end, value):
""" Checks if value is inside the range """
"""Checks if value is inside the range."""
try:
value = float(value)
except ValueError:

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.state
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers state listening automation rules.
For more details about this automation rule, please refer to the documentation
@ -25,7 +23,7 @@ CONF_FOR = "for"
def get_time_config(config):
""" Helper function to extract the time specified in the config """
"""Helper function to extract the time specified in the configuration."""
if CONF_FOR not in config:
return None
@ -51,7 +49,7 @@ def get_time_config(config):
def trigger(hass, config, action):
""" Listen for state changes based on `config`. """
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
if entity_id is None:
@ -81,8 +79,9 @@ def trigger(hass, config, action):
action()
def state_for_cancel_listener(entity, inner_from_s, inner_to_s):
""" Fires on state changes and cancels
for listener if state changed. """
"""
Fires on state changes and cancels for listener if state changed.
"""
if inner_to_s == to_s:
return
hass.bus.remove_listener(EVENT_TIME_CHANGED, for_time_listener)

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.sun
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers sun based automation rules.
For more details about this automation rule, please refer to the documentation
@ -29,7 +27,7 @@ _LOGGER = logging.getLogger(__name__)
def trigger(hass, config, action):
""" Listen for events based on config. """
"""Listen for events based on configuration."""
event = config.get(CONF_EVENT)
if event is None:
@ -106,8 +104,7 @@ def if_action(hass, config):
return sun.next_setting(hass) + after_offset
def time_if():
""" Validate time based if-condition """
"""Validate time based if-condition."""
now = dt_util.now()
before = before_func()
after = after_func()
@ -126,6 +123,7 @@ def if_action(hass, config):
def _parse_offset(raw_offset):
"""Parse the offset."""
if raw_offset is None:
return timedelta(0)

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers template automation rules.
For more details about this automation rule, please refer to the documentation
@ -16,7 +14,7 @@ _LOGGER = logging.getLogger(__name__)
def trigger(hass, config, action):
""" Listen for state changes based on `config`. """
"""Listen for state changes based on configuration."""
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is None:
@ -44,7 +42,6 @@ def trigger(hass, config, action):
def if_action(hass, config):
"""Wraps action method with state based condition."""
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is None:
@ -55,7 +52,7 @@ def if_action(hass, config):
def _check_template(hass, value_template):
""" Checks if result of template is true """
"""Checks if result of template is true."""
try:
value = template.render(hass, value_template, {})
except TemplateError:

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers time listening automation rules.
For more details about this automation rule, please refer to the documentation
@ -24,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
def trigger(hass, config, action):
""" Listen for state changes based on `config`. """
"""Listen for state changes based on configuration."""
if CONF_AFTER in config:
after = dt_util.parse_time_str(config[CONF_AFTER])
if after is None:
@ -76,7 +74,7 @@ def if_action(hass, config):
return None
def time_if():
""" Validate time based if-condition """
"""Validate time based if-condition."""
now = dt_util.now()
if before is not None and now > now.replace(hour=before.hour,
minute=before.minute):

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.automation.zone
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Offers zone automation rules.
For more details about this automation rule, please refer to the documentation
@ -22,7 +20,7 @@ DEFAULT_EVENT = EVENT_ENTER
def trigger(hass, config, action):
""" Listen for state changes based on `config`. """
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
zone_entity_id = config.get(CONF_ZONE)