From fb7bd1bfe1de8d8d79fa673c00961404f825f909 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 7 Mar 2016 20:20:07 +0100 Subject: [PATCH] Fix PEP257 issues --- homeassistant/components/automation/__init__.py | 11 +++++------ homeassistant/components/automation/event.py | 4 ++-- homeassistant/components/automation/mqtt.py | 4 ++-- .../components/automation/numeric_state.py | 10 ++++------ homeassistant/components/automation/state.py | 13 +++++-------- homeassistant/components/automation/sun.py | 4 ++-- homeassistant/components/automation/template.py | 8 ++++---- homeassistant/components/automation/time.py | 6 +++--- homeassistant/components/automation/zone.py | 6 +++--- 9 files changed, 30 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index cff61829f19..87b19d24c08 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -1,6 +1,5 @@ """ - -Allows to setup simple automation rules via the config file. +Allow to setup simple automation rules via the config file. For more details about this component, please refer to the documentation at https://home-assistant.io/components/automation/ @@ -39,20 +38,20 @@ def setup(hass, config): found = 1 while config_key in config: - # check for one block syntax + # Check for one block syntax if isinstance(config[config_key], dict): config_block = _migrate_old_config(config[config_key]) name = config_block.get(CONF_ALIAS, config_key) _setup_automation(hass, config_block, name, config) - # check for multiple block syntax + # Check for multiple block syntax elif isinstance(config[config_key], list): for list_no, config_block in enumerate(config[config_key]): name = config_block.get(CONF_ALIAS, "{}, {}".format(config_key, list_no)) _setup_automation(hass, config_block, name, config) - # any scalar value is incorrect + # Any scalar value is incorrect else: _LOGGER.error('Error in config in section %s.', config_key) @@ -131,7 +130,7 @@ def _migrate_old_config(config): def _process_if(hass, config, p_config, action): - """Processes if checks.""" + """Process if checks.""" cond_type = p_config.get(CONF_CONDITION_TYPE, DEFAULT_CONDITION_TYPE).lower() diff --git a/homeassistant/components/automation/event.py b/homeassistant/components/automation/event.py index 2f8f64151a6..80dd6c29f6b 100644 --- a/homeassistant/components/automation/event.py +++ b/homeassistant/components/automation/event.py @@ -1,5 +1,5 @@ """ -Offers event listening automation rules. +Offer event listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#event-trigger @@ -23,7 +23,7 @@ def trigger(hass, config, action): event_data = config.get(CONF_EVENT_DATA) def handle_event(event): - """Listens for events and calls the action when data matches.""" + """Listen for events and calls the action when data matches.""" if not event_data or all(val == event.data.get(key) for key, val in event_data.items()): action() diff --git a/homeassistant/components/automation/mqtt.py b/homeassistant/components/automation/mqtt.py index e0af679ad8a..db63d81e54b 100644 --- a/homeassistant/components/automation/mqtt.py +++ b/homeassistant/components/automation/mqtt.py @@ -1,5 +1,5 @@ """ -Offers MQTT listening automation rules. +Offer MQTT listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#mqtt-trigger @@ -25,7 +25,7 @@ def trigger(hass, config, action): return False def mqtt_automation_listener(msg_topic, msg_payload, qos): - """Listens for MQTT messages.""" + """Listen for MQTT messages.""" if payload is None or payload == msg_payload: action() diff --git a/homeassistant/components/automation/numeric_state.py b/homeassistant/components/automation/numeric_state.py index 4591a5c44cc..74f5b3ba805 100644 --- a/homeassistant/components/automation/numeric_state.py +++ b/homeassistant/components/automation/numeric_state.py @@ -1,7 +1,5 @@ """ -homeassistant.components.automation.numeric_state -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Offers numeric state listening automation rules. +Offer numeric state listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#numeric-state-trigger @@ -50,7 +48,7 @@ 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.""" + """Listen 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))): @@ -63,7 +61,7 @@ def trigger(hass, config, action): def if_action(hass, config): - """Wraps action method with state based condition.""" + """Wrap action method with state based condition.""" entity_id = config.get(CONF_ENTITY_ID) if entity_id is None: @@ -91,7 +89,7 @@ def if_action(hass, config): def _in_range(range_start, range_end, value): - """Checks if value is inside the range.""" + """Check if value is inside the range.""" try: value = float(value) except ValueError: diff --git a/homeassistant/components/automation/state.py b/homeassistant/components/automation/state.py index 75002e5a42f..d87d7e3fff6 100644 --- a/homeassistant/components/automation/state.py +++ b/homeassistant/components/automation/state.py @@ -1,5 +1,5 @@ """ -Offers state listening automation rules. +Offer state listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#state-trigger @@ -70,18 +70,15 @@ def trigger(hass, config, action): return None def state_automation_listener(entity, from_s, to_s): - """Listens for state changes and calls action.""" - + """Listen for state changes and calls action.""" def state_for_listener(now): - """Fires on state changes after a delay and calls action.""" + """Fire on state changes after a delay and calls action.""" hass.bus.remove_listener( EVENT_STATE_CHANGED, for_state_listener) action() def state_for_cancel_listener(entity, inner_from_s, inner_to_s): - """ - Fires on state changes and cancels for listener if state changed. - """ + """Fire on changes and cancel for listener if changed.""" if inner_to_s == to_s: return hass.bus.remove_listener(EVENT_TIME_CHANGED, for_time_listener) @@ -105,7 +102,7 @@ def trigger(hass, config, action): def if_action(hass, config): - """Wraps action method with state based condition.""" + """Wrap action method with state based condition.""" entity_id = config.get(CONF_ENTITY_ID) state = config.get(CONF_STATE) diff --git a/homeassistant/components/automation/sun.py b/homeassistant/components/automation/sun.py index 1c0afb5688e..63d7715ef7d 100644 --- a/homeassistant/components/automation/sun.py +++ b/homeassistant/components/automation/sun.py @@ -1,5 +1,5 @@ """ -Offers sun based automation rules. +Offer sun based automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#sun-trigger @@ -53,7 +53,7 @@ def trigger(hass, config, action): def if_action(hass, config): - """Wraps action method with sun based condition.""" + """Wrap action method with sun based condition.""" before = config.get(CONF_BEFORE) after = config.get(CONF_AFTER) diff --git a/homeassistant/components/automation/template.py b/homeassistant/components/automation/template.py index 05396f40b1c..aae892ea80d 100644 --- a/homeassistant/components/automation/template.py +++ b/homeassistant/components/automation/template.py @@ -1,5 +1,5 @@ """ -Offers template automation rules. +Offer template automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#template-trigger @@ -25,7 +25,7 @@ def trigger(hass, config, action): already_triggered = False def event_listener(event): - """Listens for state changes and calls action.""" + """Listen for state changes and calls action.""" nonlocal already_triggered template_result = _check_template(hass, value_template) @@ -41,7 +41,7 @@ def trigger(hass, config, action): def if_action(hass, config): - """Wraps action method with state based condition.""" + """Wrap action method with state based condition.""" value_template = config.get(CONF_VALUE_TEMPLATE) if value_template is None: @@ -52,7 +52,7 @@ def if_action(hass, config): def _check_template(hass, value_template): - """Checks if result of template is true.""" + """Check if result of template is true.""" try: value = template.render(hass, value_template, {}) except TemplateError: diff --git a/homeassistant/components/automation/time.py b/homeassistant/components/automation/time.py index efee80497ea..f28e95c6f7a 100644 --- a/homeassistant/components/automation/time.py +++ b/homeassistant/components/automation/time.py @@ -1,5 +1,5 @@ """ -Offers time listening automation rules. +Offer time listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#time-trigger @@ -40,7 +40,7 @@ def trigger(hass, config, action): return False def time_automation_listener(now): - """Listens for time changes and calls action.""" + """Listen for time changes and calls action.""" action() track_time_change(hass, time_automation_listener, @@ -50,7 +50,7 @@ def trigger(hass, config, action): def if_action(hass, config): - """Wraps action method with time based condition.""" + """Wrap action method with time based condition.""" before = config.get(CONF_BEFORE) after = config.get(CONF_AFTER) weekday = config.get(CONF_WEEKDAY) diff --git a/homeassistant/components/automation/zone.py b/homeassistant/components/automation/zone.py index ca4d61ecd2d..a5f7259b112 100644 --- a/homeassistant/components/automation/zone.py +++ b/homeassistant/components/automation/zone.py @@ -1,5 +1,5 @@ """ -Offers zone automation rules. +Offer zone automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#zone-trigger @@ -33,7 +33,7 @@ def trigger(hass, config, action): event = config.get(CONF_EVENT, DEFAULT_EVENT) def zone_automation_listener(entity, from_s, to_s): - """Listens for state changes and calls action.""" + """Listen for state changes and calls action.""" if from_s and None in (from_s.attributes.get(ATTR_LATITUDE), from_s.attributes.get(ATTR_LONGITUDE)) or \ None in (to_s.attributes.get(ATTR_LATITUDE), @@ -55,7 +55,7 @@ def trigger(hass, config, action): def if_action(hass, config): - """Wraps action method with zone based condition.""" + """Wrap action method with zone based condition.""" entity_id = config.get(CONF_ENTITY_ID) zone_entity_id = config.get(CONF_ZONE)